b0ccdb47c2969766ed8781c2ec9587c697e34832
[reactos.git] / reactos / sdk / include / psdk / delayimp.h
1 #ifndef _delayimp_h
2 #define _delayimp_h
3
4 #ifdef __GNUC__
5 /* Hack, for bug in ld. Will be removed soon. */
6 #define __ImageBase _image_base__
7 #endif
8
9 #define DELAYLOAD_VERSION 0x200
10
11 typedef DWORD RVA;
12 typedef IMAGE_THUNK_DATA *PImgThunkData;
13 typedef const IMAGE_THUNK_DATA *PCImgThunkData;
14
15 enum DLAttr
16 {
17 dlattrRva = 0x1,
18 };
19
20 /* Notification codes */
21 enum
22 {
23 dliStartProcessing,
24 dliNotePreLoadLibrary,
25 dliNotePreGetProcAddress,
26 dliFailLoadLib,
27 dliFailGetProc,
28 dliNoteEndProcessing,
29 };
30
31 typedef struct ImgDelayDescr
32 {
33 DWORD grAttrs;
34 RVA rvaDLLName;
35 RVA rvaHmod;
36 RVA rvaIAT;
37 RVA rvaINT;
38 RVA rvaBoundIAT;
39 RVA rvaUnloadIAT;
40 DWORD dwTimeStamp;
41 } ImgDelayDescr, *PImgDelayDescr;
42 typedef const ImgDelayDescr *PCImgDelayDescr;
43
44 typedef struct DelayLoadProc
45 {
46 BOOL fImportByName;
47 union
48 {
49 LPCSTR szProcName;
50 DWORD dwOrdinal;
51 };
52 } DelayLoadProc;
53
54 typedef struct DelayLoadInfo
55 {
56 DWORD cb;
57 PCImgDelayDescr pidd;
58 FARPROC *ppfn;
59 LPCSTR szDll;
60 DelayLoadProc dlp;
61 HMODULE hmodCur;
62 FARPROC pfnCur;
63 DWORD dwLastError;
64 } DelayLoadInfo, *PDelayLoadInfo;
65
66 typedef FARPROC (WINAPI *PfnDliHook)(unsigned, PDelayLoadInfo);
67
68 FORCEINLINE
69 unsigned
70 IndexFromPImgThunkData(PCImgThunkData pData, PCImgThunkData pBase)
71 {
72 return pData - pBase;
73 }
74
75 extern const IMAGE_DOS_HEADER __ImageBase;
76
77 FORCEINLINE
78 PVOID
79 PFromRva(RVA rva)
80 {
81 return (PVOID)(((ULONG_PTR)(rva)) + ((ULONG_PTR)&__ImageBase));
82 }
83
84
85 extern PfnDliHook __pfnDliNotifyHook2;
86 extern PfnDliHook __pfnDliFailureHook2;
87
88 #endif /* not _delayimp_h */