mirror of
https://github.com/solemnwarning/ipxwrapper
synced 2024-12-30 16:45:37 +01:00
Call LoadLibrary() in first find_sym() call rather than DllMain() in stub DLLs as it causes crashes in some conditions.
This commit is contained in:
parent
a1eff83b9a
commit
f0ea3fbea9
@ -26,23 +26,24 @@ extern char const *dllname;
|
|||||||
void __stdcall *find_sym(char const *symbol);
|
void __stdcall *find_sym(char const *symbol);
|
||||||
void debug(char const *fmt, ...);
|
void debug(char const *fmt, ...);
|
||||||
|
|
||||||
BOOL WINAPI DllMain(HINSTANCE me, DWORD why, LPVOID res) {
|
static void load_dlls() {
|
||||||
char sysdir[1024], path[1024];
|
char sysdir[1024], path[1024];
|
||||||
|
|
||||||
if(why == DLL_PROCESS_ATTACH) {
|
GetSystemDirectory(sysdir, 1024);
|
||||||
GetSystemDirectory(sysdir, 1024);
|
snprintf(path, 1024, "%s\\%s", sysdir, dllname);
|
||||||
snprintf(path, 1024, "%s\\%s", sysdir, dllname);
|
|
||||||
|
ipxdll = LoadLibrary("ipxwrapper.dll");
|
||||||
ipxdll = LoadLibrary("ipxwrapper.dll");
|
if(!ipxdll) {
|
||||||
if(!ipxdll) {
|
abort();
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
sysdll = LoadLibrary(path);
|
|
||||||
if(!sysdll) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sysdll = LoadLibrary(path);
|
||||||
|
if(!sysdll) {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL WINAPI DllMain(HINSTANCE me, DWORD why, LPVOID res) {
|
||||||
if(why == DLL_PROCESS_DETACH) {
|
if(why == DLL_PROCESS_DETACH) {
|
||||||
if(sysdll) {
|
if(sysdll) {
|
||||||
FreeLibrary(sysdll);
|
FreeLibrary(sysdll);
|
||||||
@ -59,14 +60,16 @@ BOOL WINAPI DllMain(HINSTANCE me, DWORD why, LPVOID res) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void __stdcall *find_sym(char const *symbol) {
|
void __stdcall *find_sym(char const *symbol) {
|
||||||
void *ptr = NULL;
|
if(!ipxdll) {
|
||||||
|
load_dlls();
|
||||||
if(!ptr) {
|
|
||||||
ptr = GetProcAddress(ipxdll, symbol);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void *ptr = GetProcAddress(ipxdll, symbol);
|
||||||
|
|
||||||
if(!ptr) {
|
if(!ptr) {
|
||||||
ptr = GetProcAddress(sysdll, symbol);
|
ptr = GetProcAddress(sysdll, symbol);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!ptr) {
|
if(!ptr) {
|
||||||
debug("Missing symbol in %s: %s", dllname, symbol);
|
debug("Missing symbol in %s: %s", dllname, symbol);
|
||||||
abort();
|
abort();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user