📄 module.c
字号:
char checked[2000]; int i = -1; checked[0] = 0; if(!libname) { SetLastError(ERROR_INVALID_PARAMETER); return 0; } wm=MODULE_FindModule(libname); if(wm) return wm->module;// if(fs_installed==0)// install_fs(); while (wm == 0 && listpath[++i]) { if (i < 2) { if (i == 0) /* check just original file name */ strncpy(path, libname, 511); else /* check default user path */ strncpy(path, def_path, 300); } else if (strcmp(def_path, listpath[i])) /* path from the list */ strncpy(path, listpath[i], 300); else continue; if (i > 0) { strcat(path, "/"); strncat(path, libname, 100); } path[511] = 0; wm = MODULE_LoadLibraryExA( path, hfile, flags ); if (!wm) { if (checked[0]) strcat(checked, ", "); strcat(checked, path); checked[1500] = 0; } } if ( wm ) { if ( !MODULE_DllProcessAttach( wm, NULL ) ) { WARN_(module)("Attach failed for module '%s', \n", libname); MODULE_FreeLibrary(wm); SetLastError(ERROR_DLL_INIT_FAILED); MODULE_RemoveFromList(wm); wm = NULL; } } if (!wm) printf("Win32 LoadLibrary failed to load: %s\n", checked);#define RVA(x) ((char *)wm->module+(unsigned int)(x)) if (strstr(libname,"vp31vfw.dll") && wm) { int i; // sse hack moved from patch dll into runtime patching if (PE_FindExportedFunction(wm, "DriverProc", TRUE)==RVA(0x1000)) { fprintf(stderr, "VP3 DLL found\n"); for (i=0;i<18;i++) RVA(0x4bd6)[i]=0x90; } } // remove a few divs in the VP codecs that make trouble if (strstr(libname,"vp5vfw.dll") && wm) { int i; if (PE_FindExportedFunction(wm, "DriverProc", TRUE)==RVA(0x3930)) { for (i=0;i<3;i++) RVA(0x4e86)[i]=0x90; for (i=0;i<3;i++) RVA(0x5a23)[i]=0x90; for (i=0;i<3;i++) RVA(0x5bff)[i]=0x90; } else { fprintf(stderr, "Unsupported VP5 version\n"); return 0; } } if (strstr(libname,"vp6vfw.dll") && wm) { int i; if (PE_FindExportedFunction(wm, "DriverProc", TRUE)==RVA(0x3ef0)) { // looks like VP 6.1.0.2 for (i=0;i<6;i++) RVA(0x7268)[i]=0x90; for (i=0;i<6;i++) RVA(0x7e83)[i]=0x90; for (i=0;i<6;i++) RVA(0x806a)[i]=0x90; } else if (PE_FindExportedFunction(wm, "DriverProc", TRUE)==RVA(0x4120)) { // looks like VP 6.2.0.10 for (i=0;i<6;i++) RVA(0x7688)[i]=0x90; for (i=0;i<6;i++) RVA(0x82c3)[i]=0x90; for (i=0;i<6;i++) RVA(0x84aa)[i]=0x90; for (i=0;i<6;i++) RVA(0x1d2cc)[i]=0x90; for (i=0;i<6;i++) RVA(0x2179d)[i]=0x90; for (i=0;i<6;i++) RVA(0x1977f)[i]=0x90; } else if (PE_FindExportedFunction(wm, "DriverProc", TRUE)==RVA(0x3e70)) { // looks like VP 6.0.7.3 for (i=0;i<6;i++) RVA(0x7559)[i]=0x90; for (i=0;i<6;i++) RVA(0x81c3)[i]=0x90; for (i=0;i<6;i++) RVA(0x839e)[i]=0x90; } else { fprintf(stderr, "Unsupported VP6 version\n"); return 0; } } // Windows Media Video 9 Advanced if (strstr(libname,"wmvadvd.dll") && wm) { // The codec calls IsRectEmpty with coords 0,0,0,0 => result is 0 // but it really wants the rectangle to be not empty if (PE_FindExportedFunction(wm, "CreateInstance", TRUE)==RVA(0xb812)) { // Dll version is 10.0.0.3645 *RVA(0x8b0f)=0xeb; // Jump always, ignoring IsRectEmpty result } else { fprintf(stderr, "Unsupported WMVA version\n"); return 0; } } if (strstr(libname,"QuickTime.qts") && wm) { void** ptr; void *dispatch_addr; int i;// dispatch_addr = GetProcAddress(wm->module, "theQuickTimeDispatcher", TRUE); dispatch_addr = PE_FindExportedFunction(wm, "theQuickTimeDispatcher", TRUE); if (dispatch_addr == RVA(0x124c30)) { fprintf(stderr, "QuickTime5 DLLs found\n"); ptr = (void **)RVA(0x375ca4); // dispatch_ptr for (i=0;i<5;i++) RVA(0x19e842)[i]=0x90; // make_new_region ? for (i=0;i<28;i++) RVA(0x19e86d)[i]=0x90; // call__call_CreateCompatibleDC ? for (i=0;i<5;i++) RVA(0x19e898)[i]=0x90; // jmp_to_call_loadbitmap ? for (i=0;i<9;i++) RVA(0x19e8ac)[i]=0x90; // call__calls_OLE_shit ? for (i=0;i<106;i++) RVA(0x261b10)[i]=0x90; // disable threads#if 0 /* CreateThread callers */ for (i=0;i<5;i++) RVA(0x1487c5)[i]=0x90; for (i=0;i<5;i++) RVA(0x14b275)[i]=0x90; for (i=0;i<5;i++) RVA(0x1a24b1)[i]=0x90; for (i=0;i<5;i++) RVA(0x1afc5a)[i]=0x90; for (i=0;i<5;i++) RVA(0x2f799c)[i]=0x90; for (i=0;i<5;i++) RVA(0x2f7efe)[i]=0x90; for (i=0;i<5;i++) RVA(0x2fa33e)[i]=0x90;#endif#if 0 /* TerminateQTML fix */ for (i=0;i<47;i++) RVA(0x2fa3b8)[i]=0x90; // terminate thread for (i=0;i<47;i++) RVA(0x2f7f78)[i]=0x90; // terminate thread for (i=0;i<77;i++) RVA(0x1a13d5)[i]=0x90; RVA(0x08e0ae)[0] = 0xc3; // font/dc remover for (i=0;i<24;i++) RVA(0x07a1ad)[i]=0x90; // destroy window#endif } else if (dispatch_addr == RVA(0x13b330)) { fprintf(stderr, "QuickTime6 DLLs found\n"); ptr = (void **)RVA(0x3b9524); // dispatcher_ptr for (i=0;i<5;i++) RVA(0x2730cc)[i]=0x90; // make_new_region for (i=0;i<28;i++) RVA(0x2730f7)[i]=0x90; // call__call_CreateCompatibleDC for (i=0;i<5;i++) RVA(0x273122)[i]=0x90; // jmp_to_call_loadbitmap for (i=0;i<9;i++) RVA(0x273131)[i]=0x90; // call__calls_OLE_shit for (i=0;i<96;i++) RVA(0x2ac852)[i]=0x90; // disable threads } else if (dispatch_addr == RVA(0x13c3e0)) { fprintf(stderr, "QuickTime6.3 DLLs found\n"); ptr = (void **)RVA(0x3ca01c); // dispatcher_ptr for (i=0;i<5;i++) RVA(0x268f6c)[i]=0x90; // make_new_region for (i=0;i<28;i++) RVA(0x268f97)[i]=0x90; // call__call_CreateCompatibleDC for (i=0;i<5;i++) RVA(0x268fc2)[i]=0x90; // jmp_to_call_loadbitmap for (i=0;i<9;i++) RVA(0x268fd1)[i]=0x90; // call__calls_OLE_shit for (i=0;i<96;i++) RVA(0x2b4722)[i]=0x90; // disable threads } else { fprintf(stderr, "Unsupported QuickTime version (%p)\n", dispatch_addr); return 0; } fprintf(stderr,"QuickTime.qts patched!!! old entry=%p\n",ptr[0]);#ifdef EMU_QTX_API report_entry = report_func; report_ret = report_func_ret; wrapper_target=ptr[0]; ptr[0]=wrapper;#endif }#undef RVA return wm ? wm->module : 0;}/*********************************************************************** * LoadLibraryA (KERNEL32) */HMODULE WINAPI LoadLibraryA(LPCSTR libname) { return LoadLibraryExA(libname,0,0);}/*********************************************************************** * FreeLibrary */WIN_BOOL WINAPI FreeLibrary(HINSTANCE hLibModule){ WIN_BOOL retv = FALSE; WINE_MODREF *wm; wm=MODULE32_LookupHMODULE(hLibModule); if ( !wm || !hLibModule ) { SetLastError( ERROR_INVALID_HANDLE ); return 0; } else retv = MODULE_FreeLibrary( wm ); MODULE_RemoveFromList(wm); /* garbage... */ if (local_wm == NULL) my_garbagecollection(); return retv;}/*********************************************************************** * MODULE_DecRefCount * * NOTE: Assumes that the process critical section is held! */static void MODULE_DecRefCount( WINE_MODREF *wm ){ int i; if ( wm->flags & WINE_MODREF_MARKER ) return; if ( wm->refCount <= 0 ) return; --wm->refCount; TRACE("(%s) refCount: %d\n", wm->modname, wm->refCount ); if ( wm->refCount == 0 ) { wm->flags |= WINE_MODREF_MARKER; for ( i = 0; i < wm->nDeps; i++ ) if ( wm->deps[i] ) MODULE_DecRefCount( wm->deps[i] ); wm->flags &= ~WINE_MODREF_MARKER; }}/*********************************************************************** * GetProcAddress (KERNEL32.257) */FARPROC WINAPI GetProcAddress( HMODULE hModule, LPCSTR function ){ return MODULE_GetProcAddress( hModule, function, TRUE );}#ifdef DEBUG_QTX_API/* http://lists.apple.com/archives/quicktime-api/2003/Jan/msg00278.html*/struct ComponentParameters { unsigned char flags; /* call modifiers: sync/async, deferred, immed, etc */ unsigned char paramSize; /* size in bytes of actual parameters passed to this call */ short what; /* routine selector, negative for Component management calls */ long params[1]; /* actual parameters for the indicated routine */};typedef struct ComponentParameters ComponentParameters;static char* component_func(int what){if (what < 0) // Range 0: Standard Component Callsswitch(what){case -1: return "kComponentOpenSelect";case -2: return "kComponentCloseSelect";case -3: return "kComponentCanDoSelect";case -4: return "kComponentVersionSelect";case -5: return "kComponentRegisterSelect";case -6: return "kComponentTargetSelect";case -7: return "kComponentUnregisterSelect";}if (what >= 0 && what <= 0xff) // Range 1: Generic codecsswitch(what & 0xff){case 0: return "kImageCodecGetCodecInfoSelect";case 1: return "kImageCodecGetCompressionTimeSelect";case 2: return "kImageCodecGetMaxCompressionSizeSelect";case 3: return "kImageCodecPreCompressSelect";case 4: return "kImageCodecBandCompressSelect";case 5: return "kImageCodecPreDecompressSelect";case 6: return "kImageCodecBandDecompressSelect";case 7: return "kImageCodecBusySelect";// finish this list from the above URLcase 0x10: return "kImageCodecIsImageDescriptionEquivalentSelect";case 0x12: return "kImageCodecDisposeMemorySelect";case 0x14: return "kImageCodecNewImageBufferMemorySelect";case 0x28: return "kImageCodecRequestGammaLevelSelect";}//if (what >= 0x100 && what <= 0x1ff) // Range 2: Specific to QT Photo JPEG codecsif (what >= 0x200 && what <= 0x2ff) // Range 3: Base Decompressorswitch(what & 0xff){case 0: return "Preflight";case 1: return "Initialize";case 2: return "BeginBand";case 3: return "DrawBand";case 4: return "EndBand";case 5: return "QueueStarting";case 6: return "QueueStopping";}return "???";}static int c_level=0;static int dump_component(char* name,int type,void* _orig, ComponentParameters *params,void** glob){ int ( *orig)(ComponentParameters *params, void** glob) = _orig; int ret,i; fprintf(stderr,"%*sComponentCall: %s flags=0x%X size=%d what=0x%X %s\n",3*c_level,"",name,params->flags, params->paramSize, params->what, component_func(params->what)); for(i=0;i<params->paramSize/4;i++) fprintf(stderr,"%*s param[%d] = 0x%X\n",3*c_level,"",i,params->params[i]); ++c_level; ret=orig(params,glob); --c_level; if(ret>=0x1000) fprintf(stderr,"%*s return=0x%X\n",3*c_level,"",ret); else fprintf(stderr,"%*s return=%d\n",3*c_level,"",ret); return ret;}#define DECL_COMPONENT(sname,name,type) \ static void* real_ ## sname = NULL; \ static int fake_ ## sname(ComponentParameters *params,void** glob){ \ return dump_component(name,type,real_ ## sname, params, glob); \ }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -