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

Go to the source code of this file.

Macros

#define _DLOAD_DLOADSUP_H
 
#define DLOAD_INLINE   __inline
 
#define FAST_FAIL_DLOAD_PROTECTION_FAILURE   25
 
#define IMAGE_GUARD_PROTECT_DELAYLOAD_IAT   0x00001000
 
#define DLOAD_ASSERT(_exp)   ((void) 0)
 
#define DLOAD_UNSUPPORTED   ((HMODULE)0x1)
 

Typedefs

typedef _In_ PCIMAGE_DELAYLOAD_DESCRIPTOR DelayloadDescriptor
 
typedef _In_ PCIMAGE_DELAYLOAD_DESCRIPTOR _In_opt_ PDELAYLOAD_FAILURE_DLL_CALLBACK FailureDllHook
 
typedef _In_ PCIMAGE_DELAYLOAD_DESCRIPTOR _In_opt_ PDELAYLOAD_FAILURE_DLL_CALLBACK _In_opt_ PDELAYLOAD_FAILURE_SYSTEM_ROUTINE FailureSystemHook
 
typedef _In_ PCIMAGE_DELAYLOAD_DESCRIPTOR _In_opt_ PDELAYLOAD_FAILURE_DLL_CALLBACK _In_opt_ PDELAYLOAD_FAILURE_SYSTEM_ROUTINE _Out_ PIMAGE_THUNK_DATA ThunkAddress
 
typedef _In_ PCIMAGE_DELAYLOAD_DESCRIPTOR _In_opt_ PDELAYLOAD_FAILURE_DLL_CALLBACK _In_opt_ PDELAYLOAD_FAILURE_SYSTEM_ROUTINE _Out_ PIMAGE_THUNK_DATA _Reserved_ ULONG Flags
 
typedef _In_ LPCSTR TargetDllName
 

Functions

typedef PVOID (NTAPI *ResolveDelayLoadedAPIProc)(_In_ PVOID ParentModuleBase
 
typedef NTSTATUS (NTAPI *ResolveDelayLoadsFromDllProc)(_In_ PVOID ParentBase
 
DLOAD_INLINE BOOLEAN DloadResolve (VOID)
 
DLOAD_INLINE PVOID WINAPI Dload__delayLoadHelper2 (_In_ PCIMAGE_DELAYLOAD_DESCRIPTOR DelayloadDescriptor, _Out_ PIMAGE_THUNK_DATA ThunkAddress, _Out_ PBOOLEAN NativeHandled)
 
DLOAD_INLINE HRESULT WINAPI Dload__HrLoadAllImportsForDll (_In_ LPCSTR DllName, _Out_ PBOOLEAN NativeHandled)
 

Variables

HMODULE DloadKernel32
 
ResolveDelayLoadedAPIProc DloadResolveDelayLoadedAPI
 
ResolveDelayLoadsFromDllProc DloadResolveDelayLoadsFromDll
 

Macro Definition Documentation

#define _DLOAD_DLOADSUP_H
#define DLOAD_ASSERT (   _exp)    ((void) 0)
#define DLOAD_INLINE   __inline
#define DLOAD_UNSUPPORTED   ((HMODULE)0x1)
#define FAST_FAIL_DLOAD_PROTECTION_FAILURE   25
#define IMAGE_GUARD_PROTECT_DELAYLOAD_IAT   0x00001000

Typedef Documentation

typedef _In_ PCIMAGE_DELAYLOAD_DESCRIPTOR DelayloadDescriptor
typedef _In_ PCIMAGE_DELAYLOAD_DESCRIPTOR _In_opt_ PDELAYLOAD_FAILURE_DLL_CALLBACK FailureDllHook
typedef _In_ PCIMAGE_DELAYLOAD_DESCRIPTOR _In_opt_ PDELAYLOAD_FAILURE_DLL_CALLBACK _In_opt_ PDELAYLOAD_FAILURE_SYSTEM_ROUTINE FailureSystemHook
typedef _In_ LPCSTR _Reserved_ ULONG Flags
typedef _In_ LPCSTR TargetDllName
typedef _In_ PCIMAGE_DELAYLOAD_DESCRIPTOR _In_opt_ PDELAYLOAD_FAILURE_DLL_CALLBACK _In_opt_ PDELAYLOAD_FAILURE_SYSTEM_ROUTINE _Out_ PIMAGE_THUNK_DATA ThunkAddress

Function Documentation

DLOAD_INLINE PVOID WINAPI Dload__delayLoadHelper2 ( _In_ PCIMAGE_DELAYLOAD_DESCRIPTOR  DelayloadDescriptor,
_Out_ PIMAGE_THUNK_DATA  ThunkAddress,
_Out_ PBOOLEAN  NativeHandled 
)
830 {
831 
832  PVOID Symbol;
833 
834  if (DloadResolve() == FALSE) {
835  *NativeHandled = FALSE;
836  return NULL;
837  }
838 
839  *NativeHandled = TRUE;
840 
843  (PDELAYLOAD_FAILURE_DLL_CALLBACK)__pfnDliFailureHook2,
844  DelayLoadFailureHook,
845  ThunkAddress,
846  0);
847 
848  return Symbol;
849 }
#define NULL
Definition: vcruntime.h:236
DLOAD_INLINE BOOLEAN DloadResolve(VOID)
Definition: dloadsup.h:729
typedef PVOID(NTAPI *ResolveDelayLoadedAPIProc)(_In_ PVOID ParentModuleBase
ResolveDelayLoadedAPIProc DloadResolveDelayLoadedAPI
Definition: dloadsup.h:189
_In_ PCIMAGE_DELAYLOAD_DESCRIPTOR _In_opt_ PDELAYLOAD_FAILURE_DLL_CALLBACK _In_opt_ PDELAYLOAD_FAILURE_SYSTEM_ROUTINE _Out_ PIMAGE_THUNK_DATA ThunkAddress
Definition: dloadsup.h:172
const IMAGE_DOS_HEADER __ImageBase
Definition: delayhlp.cpp:95
_In_ PCIMAGE_DELAYLOAD_DESCRIPTOR DelayloadDescriptor
Definition: dloadsup.h:172
ExternC const PfnDliHook __pfnDliFailureHook2
Definition: delayimp.h:141
DLOAD_INLINE HRESULT WINAPI Dload__HrLoadAllImportsForDll ( _In_ LPCSTR  DllName,
_Out_ PBOOLEAN  NativeHandled 
)
882 {
883 
884  NTSTATUS Status;
885 
886  if (DloadResolve() == FALSE) {
887  *NativeHandled = FALSE;
888  return HRESULT_FROM_WIN32(ERROR_MOD_NOT_FOUND);
889  }
890 
891  *NativeHandled = TRUE;
892 
894  DllName,
895  0);
896 
897  if (Status == STATUS_DLL_NOT_FOUND) {
898  return HRESULT_FROM_WIN32(ERROR_MOD_NOT_FOUND);
899 
900  } else {
901  return S_OK;
902  }
903 }
#define S_OK
Definition: comutil.h:62
typedef NTSTATUS(NTAPI *ResolveDelayLoadsFromDllProc)(_In_ PVOID ParentBase
DLOAD_INLINE BOOLEAN DloadResolve(VOID)
Definition: dloadsup.h:729
typedef PVOID(NTAPI *ResolveDelayLoadedAPIProc)(_In_ PVOID ParentModuleBase
ResolveDelayLoadsFromDllProc DloadResolveDelayLoadsFromDll
Definition: dloadsup.h:190
const IMAGE_DOS_HEADER __ImageBase
Definition: delayhlp.cpp:95
DLOAD_INLINE BOOLEAN DloadResolve ( VOID  )
751 {
752 
753  HMODULE Kernel32;
754 
755  Kernel32 = (HMODULE)ReadPointerAcquire((PVOID *) &DloadKernel32);
756  if (Kernel32 == DLOAD_UNSUPPORTED) {
757  return FALSE;
758  }
759  if (Kernel32 != NULL) {
760  return TRUE;
761  }
762 
763  Kernel32 = GetModuleHandleW(L"api-ms-win-core-delayload-l1-1-1.dll");
764  if (Kernel32 == NULL) {
765  Kernel32 = GetModuleHandleW(L"KERNEL32.DLL");
766  if (Kernel32 == NULL) {
767  Kernel32 = DLOAD_UNSUPPORTED;
768  goto Done;
769  }
770  }
771 
773  (ResolveDelayLoadedAPIProc)GetProcAddress(Kernel32,
774  "ResolveDelayLoadedAPI");
775 
777  Kernel32 = DLOAD_UNSUPPORTED;
778  goto Done;
779  }
780 
782  (ResolveDelayLoadsFromDllProc)GetProcAddress(Kernel32,
783  "ResolveDelayLoadsFromDll");
784 
786  Kernel32 = DLOAD_UNSUPPORTED;
787  goto Done;
788  }
789 
790 Done:
791  WritePointerRelease((PVOID *)&DloadKernel32, Kernel32);
792  return (Kernel32 != DLOAD_UNSUPPORTED);
793 }
#define NULL
Definition: vcruntime.h:236
typedef PVOID(NTAPI *ResolveDelayLoadedAPIProc)(_In_ PVOID ParentModuleBase
ResolveDelayLoadedAPIProc DloadResolveDelayLoadedAPI
Definition: dloadsup.h:189
#define DLOAD_UNSUPPORTED
Definition: dloadsup.h:165
ResolveDelayLoadsFromDllProc DloadResolveDelayLoadsFromDll
Definition: dloadsup.h:190
HMODULE DloadKernel32
Definition: dloadsup.h:188
typedef NTSTATUS ( NTAPI *  ResolveDelayLoadsFromDllProc)
typedef PVOID ( NTAPI *  ResolveDelayLoadedAPIProc)

Variable Documentation

HMODULE DloadKernel32
ResolveDelayLoadedAPIProc DloadResolveDelayLoadedAPI
ResolveDelayLoadsFromDllProc DloadResolveDelayLoadsFromDll