ReactOS 0.4.16-dev-1946-g52006dd
delayimp.c File Reference
#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
#include <delayimp.h>
Include dependency graph for delayimp.c:

Go to the source code of this file.

Functions

FORCEINLINE unsigned IndexFromPImgThunkData (PCImgThunkData pData, PCImgThunkData pBase)
 
FORCEINLINE PVOID PFromRva (RVA rva)
 
FARPROC WINAPI __delayLoadHelper2 (PCImgDelayDescr pidd, PImgThunkData pIATEntry)
 

Variables

PfnDliHook __pfnDliNotifyHook2
 Custom delay-loading hooks for loading the Setup DLLs from a suitable path.
 
PfnDliHook __pfnDliFailureHook2
 
PfnDliHook __pfnDliNotifyHook2Default = NULL
 
PfnDliHook __pfnDliFailureHook2Default = NULL
 
const IMAGE_DOS_HEADER __ImageBase
 

Function Documentation

◆ __delayLoadHelper2()

FARPROC WINAPI __delayLoadHelper2 ( PCImgDelayDescr  pidd,
PImgThunkData  pIATEntry 
)

Definition at line 58 of file delayimp.c.

59{
60 DelayLoadInfo dli = {0};
61 int index;
62 PImgThunkData pIAT;
63 PImgThunkData pINT;
64 HMODULE *phMod;
65
66 pIAT = PFromRva(pidd->rvaIAT);
67 pINT = PFromRva(pidd->rvaINT);
68 phMod = PFromRva(pidd->rvaHmod);
69 index = IndexFromPImgThunkData(pIATEntry, pIAT);
70
71 dli.cb = sizeof(dli);
72 dli.pidd = pidd;
73 dli.ppfn = (FARPROC*)&pIAT[index].u1.Function;
74 dli.szDll = PFromRva(pidd->rvaDLLName);
75 dli.dlp.fImportByName = !IMAGE_SNAP_BY_ORDINAL(pINT[index].u1.Ordinal);
76 if (dli.dlp.fImportByName)
77 {
78 /* u1.AddressOfData points to a IMAGE_IMPORT_BY_NAME struct */
79 PIMAGE_IMPORT_BY_NAME piibn = PFromRva((RVA)pINT[index].u1.AddressOfData);
80 dli.dlp.szProcName = (LPCSTR)&piibn->Name;
81 }
82 else
83 {
84 dli.dlp.dwOrdinal = IMAGE_ORDINAL(pINT[index].u1.Ordinal);
85 }
86
88 {
90 if (dli.pfnCur)
91 {
92 pIAT[index].u1.Function = (DWORD_PTR)dli.pfnCur;
95
96 return dli.pfnCur;
97 }
98 }
99
100 dli.hmodCur = *phMod;
101
102 if (dli.hmodCur == NULL)
103 {
106 if (dli.hmodCur == NULL)
107 {
108 dli.hmodCur = LoadLibraryA(dli.szDll);
109 if (dli.hmodCur == NULL)
110 {
114
115 if (dli.hmodCur == NULL)
116 {
117 ULONG_PTR args[] = { (ULONG_PTR)&dli };
119
120 /* If we survive the exception, we are expected to use pfnCur directly.. */
121 return dli.pfnCur;
122 }
123 }
124 }
125 *phMod = dli.hmodCur;
126 }
127
129
132 if (dli.pfnCur == NULL)
133 {
134 /* dli.dlp.szProcName might also contain the ordinal */
136 if (dli.pfnCur == NULL)
137 {
141
142 if (dli.pfnCur == NULL)
143 {
144 ULONG_PTR args[] = { (ULONG_PTR)&dli };
146 }
147
148 //return NULL;
149 }
150 }
151
152 pIAT[index].u1.Function = (DWORD_PTR)dli.pfnCur;
154
157
158 return dli.pfnCur;
159}
#define index(s, c)
Definition: various.h:29
PfnDliHook __pfnDliFailureHook2
Definition: reactos.c:2964
PfnDliHook __pfnDliNotifyHook2
Custom delay-loading hooks for loading the Setup DLLs from a suitable path.
Definition: reactos.c:2963
FORCEINLINE unsigned IndexFromPImgThunkData(PCImgThunkData pData, PCImgThunkData pBase)
Definition: delayimp.c:40
FORCEINLINE PVOID PFromRva(RVA rva)
Definition: delayimp.c:49
#define VcppException(sev, err)
Definition: delayimp.cpp:32
@ dliNoteEndProcessing
Definition: delayimp.h:39
@ dliFailLoadLib
Definition: delayimp.h:37
@ dliNotePreGetProcAddress
Definition: delayimp.h:36
@ dliNotePreLoadLibrary
Definition: delayimp.h:35
@ dliFailGetProc
Definition: delayimp.h:38
@ dliStartProcessing
Definition: delayimp.h:34
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define ERROR_MOD_NOT_FOUND
Definition: compat.h:104
int(* FARPROC)()
Definition: compat.h:36
DWORD RVA
Definition: compat.h:1262
#define GetProcAddress(x, y)
Definition: compat.h:753
VOID WINAPI RaiseException(_In_ DWORD dwExceptionCode, _In_ DWORD dwExceptionFlags, _In_ DWORD nNumberOfArguments, _In_opt_ const ULONG_PTR *lpArguments)
Definition: except.c:700
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
#define ULONG_PTR
Definition: config.h:101
GLuint index
Definition: glext.h:6031
GLdouble u1
Definition: glext.h:8308
if(dx< 0)
Definition: linetemp.h:194
#define ERROR_SEVERITY_ERROR
Definition: ntbasedef.h:608
#define IMAGE_SNAP_BY_ORDINAL(Ordinal)
Definition: ntimage.h:567
#define IMAGE_ORDINAL(Ordinal)
Definition: pedump.c:337
PCImgDelayDescr pidd
Definition: delayimp.h:68
HMODULE hmodCur
Definition: delayimp.h:72
DWORD cb
Definition: delayimp.h:67
FARPROC pfnCur
Definition: delayimp.h:73
LPCSTR szDll
Definition: delayimp.h:70
DelayLoadProc dlp
Definition: delayimp.h:71
FARPROC * ppfn
Definition: delayimp.h:69
DWORD dwLastError
Definition: delayimp.h:74
BOOL fImportByName
Definition: delayimp.h:57
DWORD dwOrdinal
Definition: delayimp.h:61
LPCSTR szProcName
Definition: delayimp.h:60
RVA rvaDLLName
Definition: delayimp.h:45
union _IMAGE_THUNK_DATA32::@2314 u1
Definition: match.c:390
#define DWORD_PTR
Definition: treelist.c:76
uint32_t ULONG_PTR
Definition: typedefs.h:65
HANDLE HMODULE
Definition: typedefs.h:77
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define ERROR_PROC_NOT_FOUND
Definition: winerror.h:321
const char * LPCSTR
Definition: xmlstorage.h:183

◆ IndexFromPImgThunkData()

FORCEINLINE unsigned IndexFromPImgThunkData ( PCImgThunkData  pData,
PCImgThunkData  pBase 
)

Definition at line 40 of file delayimp.c.

41{
42 return pData - pBase;
43}
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830

Referenced by __delayLoadHelper2().

◆ PFromRva()

FORCEINLINE PVOID PFromRva ( RVA  rva)

Definition at line 49 of file delayimp.c.

50{
51 return (PVOID)(((ULONG_PTR)(rva)) + ((ULONG_PTR)&__ImageBase));
52}
const IMAGE_DOS_HEADER __ImageBase

Referenced by __delayLoadHelper2().

Variable Documentation

◆ __ImageBase

const IMAGE_DOS_HEADER __ImageBase
extern

Referenced by PFromRva().

◆ __pfnDliFailureHook2

PfnDliHook __pfnDliFailureHook2
extern

Definition at line 2964 of file reactos.c.

Referenced by __delayLoadHelper2(), and START_TEST().

◆ __pfnDliFailureHook2Default

PfnDliHook __pfnDliFailureHook2Default = NULL

Definition at line 23 of file delayimp.c.

◆ __pfnDliNotifyHook2

PfnDliHook __pfnDliNotifyHook2
extern

Custom delay-loading hooks for loading the Setup DLLs from a suitable path.

Definition at line 2963 of file reactos.c.

Referenced by __delayLoadHelper2().

◆ __pfnDliNotifyHook2Default

PfnDliHook __pfnDliNotifyHook2Default = NULL

Definition at line 22 of file delayimp.c.