ReactOS 0.4.15-dev-8093-g3285f69
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
 
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 60 of file delayimp.c.

61{
62 DelayLoadInfo dli = {0};
63 int index;
64 PImgThunkData pIAT;
65 PImgThunkData pINT;
66 HMODULE *phMod;
67
68 pIAT = PFromRva(pidd->rvaIAT);
69 pINT = PFromRva(pidd->rvaINT);
70 phMod = PFromRva(pidd->rvaHmod);
71 index = IndexFromPImgThunkData(pIATEntry, pIAT);
72
73 dli.cb = sizeof(dli);
74 dli.pidd = pidd;
75 dli.ppfn = (FARPROC*)&pIAT[index].u1.Function;
76 dli.szDll = PFromRva(pidd->rvaDLLName);
77 dli.dlp.fImportByName = !IMAGE_SNAP_BY_ORDINAL(pINT[index].u1.Ordinal);
78 if (dli.dlp.fImportByName)
79 {
80 /* u1.AddressOfData points to a IMAGE_IMPORT_BY_NAME struct */
81 PIMAGE_IMPORT_BY_NAME piibn = PFromRva((RVA)pINT[index].u1.AddressOfData);
82 dli.dlp.szProcName = (LPCSTR)&piibn->Name;
83 }
84 else
85 {
86 dli.dlp.dwOrdinal = IMAGE_ORDINAL(pINT[index].u1.Ordinal);
87 }
88
90 {
92 if (dli.pfnCur)
93 {
94 pIAT[index].u1.Function = (DWORD_PTR)dli.pfnCur;
97
98 return dli.pfnCur;
99 }
100 }
101
102 dli.hmodCur = *phMod;
103
104 if (dli.hmodCur == NULL)
105 {
108 if (dli.hmodCur == NULL)
109 {
110 dli.hmodCur = LoadLibraryA(dli.szDll);
111 if (dli.hmodCur == NULL)
112 {
116
117 if (dli.hmodCur == NULL)
118 {
119 ULONG_PTR args[] = { (ULONG_PTR)&dli };
121
122 /* If we survive the exception, we are expected to use pfnCur directly.. */
123 return dli.pfnCur;
124 }
125 }
126 }
127 *phMod = dli.hmodCur;
128 }
129
131
134 if (dli.pfnCur == NULL)
135 {
136 /* dli.dlp.szProcName might also contain the ordinal */
138 if (dli.pfnCur == NULL)
139 {
143
144 if (dli.pfnCur == NULL)
145 {
146 ULONG_PTR args[] = { (ULONG_PTR)&dli };
148 }
149
150 //return NULL;
151 }
152 }
153
154 pIAT[index].u1.Function = (DWORD_PTR)dli.pfnCur;
156
159
160 return dli.pfnCur;
161}
#define index(s, c)
Definition: various.h:29
PfnDliHook __pfnDliFailureHook2
Definition: delayimp.c:20
PfnDliHook __pfnDliNotifyHook2
Definition: delayimp.c:19
FORCEINLINE unsigned IndexFromPImgThunkData(PCImgThunkData pData, PCImgThunkData pBase)
Definition: delayimp.c:42
FORCEINLINE PVOID PFromRva(RVA rva)
Definition: delayimp.c:51
#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:596
#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::@2138 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:199
const char * LPCSTR
Definition: xmlstorage.h:183

◆ IndexFromPImgThunkData()

FORCEINLINE unsigned IndexFromPImgThunkData ( PCImgThunkData  pData,
PCImgThunkData  pBase 
)

Definition at line 42 of file delayimp.c.

43{
44 return pData - pBase;
45}
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 51 of file delayimp.c.

52{
53 return (PVOID)(((ULONG_PTR)(rva)) + ((ULONG_PTR)&__ImageBase));
54}
const IMAGE_DOS_HEADER __ImageBase

Referenced by __delayLoadHelper2().

Variable Documentation

◆ __ImageBase

const IMAGE_DOS_HEADER __ImageBase
extern

Referenced by PFromRva().

◆ __pfnDliFailureHook2

PfnDliHook __pfnDliFailureHook2

Definition at line 20 of file delayimp.c.

Referenced by __delayLoadHelper2(), and START_TEST().

◆ __pfnDliFailureHook2Default

PfnDliHook __pfnDliFailureHook2Default = NULL

Definition at line 25 of file delayimp.c.

◆ __pfnDliNotifyHook2

PfnDliHook __pfnDliNotifyHook2

Definition at line 19 of file delayimp.c.

Referenced by __delayLoadHelper2(), and START_TEST().

◆ __pfnDliNotifyHook2Default

PfnDliHook __pfnDliNotifyHook2Default = NULL

Definition at line 24 of file delayimp.c.