-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdynmcimp.c
More file actions
55 lines (50 loc) · 1.22 KB
/
Copy pathdynmcimp.c
File metadata and controls
55 lines (50 loc) · 1.22 KB
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
#include <tchar.h>
#include <windows.h>
HMODULE kernel32;
PVOID WINAPI IslEncodePointer(PVOID ptr)
{
return (PVOID)(~(ULONG_PTR)ptr);
}
typedef PVOID (WINAPI ENCODEPOINTER)(PVOID);
#if defined(_WIN64)
ENCODEPOINTER *__imp_EncodePointer = IslEncodePointer;
#else
extern ENCODEPOINTER *_imp__EncodePointer;
#endif
PVOID WINAPI IslDecodePointer(PVOID ptr)
{
return (PVOID)(~(ULONG_PTR)ptr);
}
typedef PVOID (WINAPI DECODEPOINTER)(PVOID);
#if defined(_WIN64)
DECODEPOINTER *__imp_DecodePointer = IslDecodePointer;
#else
extern DECODEPOINTER *_imp__DecodePointer;
#endif
void InitializeDelayedLoadEntryPoints()
{
kernel32 = LoadLibrary(TEXT("KERNEL32.DLL"));
if(kernel32)
{
__imp_EncodePointer = (ENCODEPOINTER*)GetProcAddress(kernel32, "EncodePointer");
if(!__imp_EncodePointer)
{
__imp_EncodePointer = IslEncodePointer;
}
__imp_DecodePointer = (DECODEPOINTER*)GetProcAddress(kernel32, "DecodePointer");
if(!__imp_DecodePointer)
{
__imp_DecodePointer = IslDecodePointer;
}
}
}
void FreeDelayedLoadEntryPoints()
{
__imp_EncodePointer = IslEncodePointer;
__imp_DecodePointer = IslDecodePointer;
if(kernel32)
{
FreeLibrary(kernel32);
kernel32 = NULL;
}
}