STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Classes | Macros | Typedefs | Enumerations | Functions | Variables
delayimp.h File Reference

Go to the source code of this file.

Classes

struct  ImgDelayDescr
 
struct  DelayLoadProc
 
struct  DelayLoadInfo
 

Macros

#define _DELAY_IMP_VER   2
 
#define ExternC   extern
 
#define VcppException(sev, err)   ((sev) | (FACILITY_VISUALCPP<<16) | err)
 

Typedefs

typedef IMAGE_THUNK_DATA * PImgThunkData
 
typedef const IMAGE_THUNK_DATA * PCImgThunkData
 
typedef DWORD RVA
 
typedef struct ImgDelayDescr ImgDelayDescr
 
typedef struct ImgDelayDescrPImgDelayDescr
 
typedef const ImgDelayDescrPCImgDelayDescr
 
typedef struct DelayLoadProc DelayLoadProc
 
typedef struct DelayLoadInfo DelayLoadInfo
 
typedef struct DelayLoadInfoPDelayLoadInfo
 
typedef FARPROC(WINAPI * PfnDliHook) (unsigned dliNotify, PDelayLoadInfo pdli)
 

Enumerations

enum  DLAttr { dlattrRva = 0x1 }
 
enum  {
  dliStartProcessing, dliNoteStartProcessing = dliStartProcessing, dliNotePreLoadLibrary, dliNotePreGetProcAddress,
  dliFailLoadLib, dliFailGetProc, dliNoteEndProcessing
}
 

Functions

ExternC BOOL WINAPI __FUnloadDelayLoadedDLL2 (LPCSTR szDll)
 
ExternC HRESULT WINAPI __HrLoadAllImportsForDll (LPCSTR szDll)
 

Variables

ExternC const PfnDliHook __pfnDliNotifyHook2
 
ExternC const PfnDliHook __pfnDliFailureHook2
 

Macro Definition Documentation

#define _DELAY_IMP_VER   2
#define ExternC   extern
#define VcppException (   sev,
  err 
)    ((sev) | (FACILITY_VISUALCPP<<16) | err)

Typedef Documentation

typedef struct DelayLoadInfo DelayLoadInfo
typedef struct DelayLoadProc DelayLoadProc
typedef struct ImgDelayDescr ImgDelayDescr
typedef const IMAGE_THUNK_DATA* PCImgThunkData
typedef struct DelayLoadInfo * PDelayLoadInfo
typedef FARPROC(WINAPI * PfnDliHook) (unsigned dliNotify, PDelayLoadInfo pdli)
typedef struct ImgDelayDescr * PImgDelayDescr
typedef IMAGE_THUNK_DATA* PImgThunkData
typedef DWORD RVA

Enumeration Type Documentation

anonymous enum
Enumerator
dliStartProcessing 
dliNoteStartProcessing 
dliNotePreLoadLibrary 
dliNotePreGetProcAddress 
dliFailLoadLib 
dliFailGetProc 
dliNoteEndProcessing 
45  {
46  dliStartProcessing, // used to bypass or note helper only
48 
49  dliNotePreLoadLibrary, // called just before LoadLibrary, can
50  // override w/ new HMODULE return val
51  dliNotePreGetProcAddress, // called just before GetProcAddress, can
52  // override w/ new FARPROC return value
53  dliFailLoadLib, // failed to load library, fix it by
54  // returning a valid HMODULE
55  dliFailGetProc, // failed to get proc address, fix it by
56  // returning a valid FARPROC
57  dliNoteEndProcessing, // called after all processing is done, no
58  // no bypass possible at this point except
59  // by longjmp()/throw()/RaiseException.
60  };
Definition: delayimp.h:53
Definition: delayimp.h:47
Definition: delayimp.h:46
Definition: delayimp.h:57
Definition: delayimp.h:49
Definition: delayimp.h:55
Definition: delayimp.h:51
enum DLAttr
Enumerator
dlattrRva 
36  { // Delay Load Attributes
37  dlattrRva = 0x1, // RVAs are used instead of pointers
38  // Having this set indicates a VC7.0
39  // and above delay load descriptor.
40  };
Definition: delayimp.h:37

Function Documentation

ExternC BOOL WINAPI __FUnloadDelayLoadedDLL2 ( LPCSTR  szDll)
414  {
415  BOOL fRet = FALSE;
416  PCImgDelayDescr pidd = PiddFromDllName(szDll);
417 
418  if ((pidd != NULL) &&
419  (pidd->rvaUnloadIAT != 0)) {
420  HMODULE * phmod = PFromRva<HMODULE*>(pidd->rvaHmod);
421  HMODULE hmod = *phmod;
422  if (hmod != NULL) {
423 
424  DloadAcquireSectionWriteAccess();
425 
426  OverlayIAT(
427  PFromRva<PImgThunkData>(pidd->rvaIAT),
428  PFromRva<PCImgThunkData>(pidd->rvaUnloadIAT)
429  );
430  ::FreeLibrary(hmod);
431  *phmod = NULL;
432 
433  DloadReleaseSectionWriteAccess();
434 
435  fRet = TRUE;
436  }
437 
438  }
439  return fRet;
440  }
RVA rvaUnloadIAT
Definition: delayimp.h:29
#define NULL
Definition: vcruntime.h:236
RVA rvaHmod
Definition: delayimp.h:25
RVA rvaIAT
Definition: delayimp.h:26
static PCImgDelayDescr PiddFromDllName(LPCSTR szDll)
Definition: delayhlp.cpp:160
static void WINAPI OverlayIAT(PImgThunkData pitdDst, PCImgThunkData pitdSrc)
Definition: delayhlp.cpp:142
Definition: delayimp.h:22
ExternC HRESULT WINAPI __HrLoadAllImportsForDll ( LPCSTR  szDll)
444  {
445  HRESULT hrRet = HRESULT_FROM_WIN32(ERROR_MOD_NOT_FOUND);
446  PCImgDelayDescr pidd = PiddFromDllName(szDll);
447 
448  if (pidd != NULL) {
449  // Found a matching DLL name, now process it.
450  //
451  // Set up the internal structure
452  //
453  FARPROC * ppfnIATEntry = PFromRva<FARPROC*>(pidd->rvaIAT);
454  size_t cpfnIATEntries = CountOfImports(PCImgThunkData(ppfnIATEntry));
455  FARPROC * ppfnIATEntryMax = ppfnIATEntry + cpfnIATEntries;
456 
457  for (;ppfnIATEntry < ppfnIATEntryMax; ppfnIATEntry++) {
458  __delayLoadHelper2(pidd, ppfnIATEntry);
459  }
460 
461  // Done, indicate some semblance of success
462  //
463  hrRet = S_OK;
464  }
465  return hrRet;
466  }
#define NULL
Definition: vcruntime.h:236
#define S_OK
Definition: comutil.h:62
RVA rvaIAT
Definition: delayimp.h:26
static PCImgDelayDescr PiddFromDllName(LPCSTR szDll)
Definition: delayhlp.cpp:160
Definition: delayimp.h:22
unsigned CountOfImports(PCImgThunkData pitdBase)
Definition: delayhlp.cpp:106
const IMAGE_THUNK_DATA * PCImgThunkData
Definition: delayimp.h:19
FARPROC WINAPI __delayLoadHelper2(PCImgDelayDescr pidd, FARPROC *ppfnIATEntry)
Definition: delayhlp.cpp:210

Variable Documentation

ExternC const PfnDliHook __pfnDliFailureHook2
ExternC const PfnDliHook __pfnDliNotifyHook2