-
-
[旧帖] [求助]关于编译器的 DWORD 类型 | _asm jmp dword数组[下标] 0.00雪花
-
发表于: 2015-8-28 13:56 1477
-
#pragma region//----------------------------------------------------------------------------------------------定义导出函数表 #pragma comment(linker, "/EXPORT:AddWebPluginPath=_New_AddWebPluginPath,@1") #pragma comment(linker, "/EXPORT:CreateWebBrowser=_New_CreateWebBrowser,@2") #pragma comment(linker, "/EXPORT:OsrShutDown=_New_OsrShutDown,@3") #pragma comment(linker, "/EXPORT:ReleaseWebBrowser=_New_ReleaseWebBrowser,@4") #pragma comment(linker, "/EXPORT:SetCefProterty=_New_SetCefProterty,@5") #pragma endregion #pragma region//----------------------------------------------------------------------------------------------定义枚举数据及跳转表 enum FunctionsJmpIndex{ f_AddWebPluginPath, f_CreateWebBrowser, f_OsrShutDown, f_ReleaseWebBrowser, f_SetCefProterty, f_FunctionsJmpMaxIndex }; void * FunctionsJmp[FunctionsJmpIndex::f_FunctionsJmpMaxIndex] = { NULL }; #pragma endregion #pragma region//----------------------------------------------------------------------------------------------定义导出函数的实现 extern "C" __declspec(naked) void __cdecl New_AddWebPluginPath(){ [COLOR="Red"]__asm jmp FunctionsJmp[f_AddWebPluginPath * 4];[/COLOR] } extern "C" __declspec(naked) void __cdecl New_CreateWebBrowser(){ [COLOR="red"]__asm jmp FunctionsJmp[f_CreateWebBrowser * 4];[/COLOR] } extern "C" __declspec(naked) void __cdecl New_OsrShutDown(){ [COLOR="red"] __asm jmp FunctionsJmp[f_OsrShutDown * 4];[/COLOR] } extern "C" __declspec(naked) void __cdecl New_ReleaseWebBrowser(){ __asm jmp FunctionsJmp[f_ReleaseWebBrowser * 4]; } extern "C" __declspec(naked) void __cdecl New_SetCefProterty(){ [COLOR="red"]__asm jmp FunctionsJmp[f_SetCefProterty * 4];[/COLOR] } #pragma endregion #pragma region//----------------------------------------------------------------------------------------------模块数据初始化函数 //注意:函数内部会加载原模块,模块名称可以在源代码中随意修改 //这个函数必须在dll的main函数中去引用,一旦初始化失败,那么不许继续运行,否则会导致程序崩溃 BOOL InitLinklibraryModule(){ //#error "需要替换下面的dll名称后才可以正常使用 | [原模块名称.dll] ->[?????? .dll]" HMODULE hModule = LoadLibraryW(L"OsrWebBrowserEx.dll"); //加载原链接库模块 if (NULL == hModule) return FALSE; FunctionsJmp[FunctionsJmpIndex::f_AddWebPluginPath] = (void *)GetProcAddress(hModule, "AddWebPluginPath"); if (NULL == FunctionsJmp[FunctionsJmpIndex::f_AddWebPluginPath]) return FALSE; FunctionsJmp[FunctionsJmpIndex::f_CreateWebBrowser] = (void *)GetProcAddress(hModule, "CreateWebBrowser"); if (NULL == FunctionsJmp[FunctionsJmpIndex::f_CreateWebBrowser]) return FALSE; FunctionsJmp[FunctionsJmpIndex::f_OsrShutDown] = (void *)GetProcAddress(hModule, "OsrShutDown"); if (NULL == FunctionsJmp[FunctionsJmpIndex::f_OsrShutDown]) return FALSE; FunctionsJmp[FunctionsJmpIndex::f_ReleaseWebBrowser] = (void *)GetProcAddress(hModule, "ReleaseWebBrowser"); if (NULL == FunctionsJmp[FunctionsJmpIndex::f_ReleaseWebBrowser]) return FALSE; FunctionsJmp[FunctionsJmpIndex::f_SetCefProterty] = (void *)GetProcAddress(hModule, "SetCefProterty"); if (NULL == FunctionsJmp[FunctionsJmpIndex::f_SetCefProterty]) return FALSE; return TRUE; }; #pragma endregion
上面红色的位置,如果不 *4 的话 编译器他是 +1 字节 的形式 去使用 DWORD 数组的,这是为什么?
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课
赞赏
看原图
赞赏
雪币:
留言: