unit LibLoaderAPI;
interface
uses
Windows;
var
LoadLibraryEx: function(lpFileName: PChar; Reserved: THandle; dwFlags: DWORD): HMODULE; stdcall;
SetDllDirectory: function(lpPathName: PChar): BOOL; stdcall;
SetSearchPathMode: function(Flags: DWORD): BOOL; stdcall;
AddDllDirectory: function(Path: PWideChar): Pointer; stdcall;
RemoveDllDirectory: function(Cookie: Pointer): BOOL; stdcall;
SetDefaultDllDirectories: function(DirectoryFlags: DWORD): BOOL; stdcall;
function IsKB959426Installed: Boolean;
function IsKB2533623Installed: Boolean;
const
// LoadLibraryEx:
DONT_RESOLVE_DLL_REFERENCES = $00000001;
LOAD_LIBRARY_AS_DATAFILE = $00000002;
LOAD_WITH_ALTERED_SEARCH_PATH = $00000008;
LOAD_IGNORE_CODE_AUTHZ_LEVEL = $00000010;
LOAD_LIBRARY_AS_IMAGE_RESOURCE = $00000020;
LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE = $00000040;
LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR = $00000100;
LOAD_LIBRARY_SEARCH_APPLICATION_DIR = $00000200;
LOAD_LIBRARY_SEARCH_USER_DIRS = $00000400;
LOAD_LIBRARY_SEARCH_SYSTEM32 = $00000800;
LOAD_LIBRARY_SEARCH_DEFAULT_DIRS = $00001000;
// SetSearchPathMode:
BASE_SEARCH_PATH_ENABLE_SAFE_SEARCHMODE = $00000001;
BASE_SEARCH_PATH_PERMANENT = $00008000;
BASE_SEARCH_PATH_DISABLE_SAFE_SEARCHMODE = $00010000;
// SetDefaultDllDirectories:
// LOAD_LIBRARY_SEARCH_APPLICATION_DIR = $00000200;
// LOAD_LIBRARY_SEARCH_USER_DIRS = $00000400;
// LOAD_LIBRARY_SEARCH_SYSTEM32 = $00000800;
// LOAD_LIBRARY_SEARCH_DEFAULT_DIRS = $00001000;
implementation
function IsKB959426Installed: Boolean; // XP SP2
begin
Result := Assigned(SetSearchPathMode);
end;
function IsKB2533623Installed: Boolean; // Vista/7 with KB2533623
begin
Result := Assigned(AddDllDirectory);
end;
procedure LoadFuncs;
var
LibKernel32: HMODULE;
begin
LibKernel32 := GetModuleHandle(kernel32);
LoadLibraryEx := GetProcAddress(LibKernel32, {$IFDEF UNICODE}'LoadLibraryExW'{$ELSE}'LoadLibraryExA'{$ENDIF});
SetDllDirectory := GetProcAddress(LibKernel32, {$IFDEF UNICODE}'SetDllDirectoryW'{$ELSE}'SetDllDirectoryA'{$ENDIF});
SetSearchPathMode := GetProcAddress(LibKernel32, 'SetSearchPathMode');
AddDllDirectory := GetProcAddress(LibKernel32, 'AddDllDirectory');
RemoveDllDirectory := GetProcAddress(LibKernel32, 'RemoveDllDirectory');
SetDefaultDllDirectories := GetProcAddress(LibKernel32, 'SetDefaultDllDirectories');
end;
initialization
LoadFuncs;
end.
Comments
0 B
|👍
/👎
0 B
|👍
/👎