forked from win32ss/VxKex
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathKexDll.h
59 lines (49 loc) · 1.51 KB
/
KexDll.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#pragma once
#include <Windows.h>
#include <KexComm.h>
#include <KexData.h>
#include <NtDll.h>
#undef WINBASEAPI
#define WINBASEAPI
#undef WINUSERAPI
#define WINUSERAPI
#undef WINPATHCCHAPI
#define WINPATHCCHAPI
#undef DLLAPI
#define DLLAPI
#define PROXY_FUNCTION(ExportedName) P_##ExportedName
#define HOOK_FUNCTION(OriginalName) H_##OriginalName
#define _STR(x) #x
#define STR(x) _STR(x)
#ifdef _DEBUG
# define ODS(...) { WCHAR __ods_buf[1024]; snwprintf_s(__ods_buf, ARRAYSIZE(__ods_buf), _TRUNCATE, L(__FUNCTION__) L"(" L(__FILE__) L":" L(STR(__LINE__)) L"): " __VA_ARGS__); OutputDebugString(__ods_buf); }
# define ODS_ENTRY(...) { WCHAR __ods_buf[1024]; snwprintf_s(__ods_buf, ARRAYSIZE(__ods_buf), _TRUNCATE, L"Function called: " L(__FUNCTION__) __VA_ARGS__); OutputDebugString(__ods_buf); }
#else
# define ODS(...)
# define ODS_ENTRY(...)
#endif
INLINE LPCWSTR GetExeBaseName(
VOID)
{
LPWSTR lpszLastBackslash = wcsrchr(NtCurrentPeb()->ProcessParameters->ImagePathName.Buffer, '\\');
if (!lpszLastBackslash) {
return L"";
} else {
return lpszLastBackslash + 1;
}
}
INLINE BOOL IsExeBaseName(
IN LPCWSTR lpszExeBaseNameToCompare)
{
return !wcsicmp(GetExeBaseName(), lpszExeBaseNameToCompare);
}
INLINE PKEX_PROCESS_DATA KexGetKexData(
VOID)
{
PKEX_PROCESS_DATA KexData = (PKEX_PROCESS_DATA) NtCurrentPeb()->SubSystemData;
if (!KexData) {
ODS(L"ERROR: SubSystemData pointer is NULL");
NtTerminateProcess(GetCurrentProcess(), 0);
}
return KexData;
}