diff --git a/common.h b/common.h index 85196c1..ee072e4 100644 --- a/common.h +++ b/common.h @@ -18,6 +18,7 @@ namespace wibo { void *resolveVersion(const char *name); void *resolveKernel32(const char *name); void *resolveUser32(const char *name); + void *resolveOle32(const char *name); void *resolveAdvApi32(const char *name); void *resolveLmgr11(uint16_t ordinal); void *resolveStubByName(const char *dllName, const char *funcName); diff --git a/main.cpp b/main.cpp index facaa7a..0002237 100644 --- a/main.cpp +++ b/main.cpp @@ -45,11 +45,6 @@ DEFINE_STUBS(3, 0) DEFINE_STUBS(3, 1) DEFINE_STUBS(3, 2) DEFINE_STUBS(3, 3) #undef DEFINE_STUB #undef DEFINE_STUBS -uint32_t __attribute__((stdcall)) CoInitialize(void *pvReserved) { - DEBUG_LOG("CoInitialize(...)\n"); - return 0; // S_OK I think? -} - void *wibo::resolveStubByName(const char *dllName, const char *funcName) { if (strcmp(dllName, "KERNEL32.dll") == 0) { void *func = wibo::resolveKernel32(funcName); @@ -72,7 +67,9 @@ void *wibo::resolveStubByName(const char *dllName, const char *funcName) { return func; } if (strcmp(dllName, "ole32.dll") == 0) { - if (strcmp(funcName, "CoInitialize") == 0) return (void *) CoInitialize; + void *func = wibo::resolveOle32(funcName); + if (func) + return func; } DEBUG_LOG("Missing function: %s (%s)\n", dllName, funcName); diff --git a/ole32.cpp b/ole32.cpp new file mode 100644 index 0000000..352599a --- /dev/null +++ b/ole32.cpp @@ -0,0 +1,36 @@ +#include "common.h" + +namespace ole32 { + int WIN_FUNC CoInitialize(void *pvReserved) { + DEBUG_LOG("CoInitialize(...)\n"); + return 0; // S_OK + } + + struct GUID { + unsigned int Data1; + unsigned short Data2; + unsigned short Data3; + unsigned char Data4[8]; + }; + + int WIN_FUNC CoCreateInstance( + const GUID *rclsid, + void *pUnkOuter, + unsigned int dwClsContext, + const GUID *riid, + void **ppv + ) { + // for mwcc_41_60126: + // rclsid = CLSID_ShellLink (0x21401), riid = IID_IShellLinkA (0x214ee) + // and then it crashes with a null pointer deref + DEBUG_LOG("CoCreateInstance 0x%x %p %d 0x%x %p\n", rclsid->Data1, pUnkOuter, dwClsContext, riid->Data1, *ppv); + *ppv = 0; + return 1; + } +} + +void *wibo::resolveOle32(const char *name) { + if (strcmp(name, "CoInitialize") == 0) return (void *) ole32::CoInitialize; + if (strcmp(name, "CoCreateInstance") == 0) return (void *) ole32::CoCreateInstance; + return 0; +}