|
PathFileExists release版本编译失败问题
经过检查,屏蔽了下列库文件及引用的函数,还是报错,说明与下列的库无关 #pragma comment(lib, "Shlwapi.lib") //仅为了使用API PathFileExists #include "Shlwapi.h" 迷茫ing...同样的代码,为啥debug可以编译过,而release不行... |
|
|
|
cpp文件调用ASM编译的函数问题
ASM文件: .386 .model flat, stdcall ;32 bit memory model 这个定义是不是代表所有proc都是stdcall方式? sub_41B9A0 proc near ; CODE XREF: sub_40D80C+3Ep .... retn sub_41B9A0 endp 实际上应该是cdel方式. 我把上面的.model flat, stdcall ;32 bit memory model 改成.model flat, cdel ;32 bit memory model后,再次编译就暴一大堆data段定义错误?如下: error A2034: must be in segment block error A2034: must be in segment block 是不是这样修改错了? |
|
多个进程窗口前置问题
逻辑没有错.原因应该就是setforgroundwindow的功能问题. |
|
多个进程窗口前置问题
我看了网上写的,大概意思是说当前如果有工作窗口的情况下,单单调用setforgroundwindow不会改变工作窗口,加上实际测试,第一种方式确实不行. 所以网上说的第三者那个方法,欺骗windows,把要激活的窗口线程附加到当前工作窗口,然后激活. 应该就是这么个道理 |
|
多个进程窗口前置问题
网上找到3个方案,以测试为导向,给出结论.内部原理没有细究,清楚的高手还请指点下: 一:测试结果:有些XP系统管用,有些不管用 ////这几个API组合,不一定会将焦点切换至指定窗口 ::SetWindowPos(g_hwnd, HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE); ::SetWindowPos(g_hwnd, HWND_NOTOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE); ::SetForegroundWindow(g_hwnd); //::SetActiveWindow(g_wnd); //这个没起作用 二. //使用未公开API,在窗口全部非最小化状况下,不会更换窗口,更别谈激活了 if (SwitchToThisWindow) { SwitchToThisWindow(g_hwnd, TRUE); } 三.目前来看都管用 /* 用附加本线程到最前面窗口的线程,从而欺骗windows。 这个可以 */ DWORD pid = GetWindowThreadProcessId(::GetForegroundWindow(), NULL); AttachThreadInput(pid, g_pstSharedData->dwThreadID, TRUE); ::SetForegroundWindow(g_hwnd); ::SetFocus(g_hwnd); AttachThreadInput(pid, g_pstSharedData->dwThreadID, FALSE); |
|
汇编函数中获取指定位置的代码片段
换了一种思路,用jmp解决了这个问题,代码如下: //获取调用call GetCurrentIP此指令的地址 __declspec(naked) int GetCurrentIP() { _asm { mov eax, [esp] sub eax, 0x5 ret } } //计算新返回地址NewRetAddr mov edi, 0x123 //获取地址标记 mov esi,esi //TEST mov esi,esi mov esi,esi mov esi,esi jmp NewRetAddr //call会导致进入系统异常 Contine: pop eax //pop模拟原API的代码地址 mov [esp], edx //更改返回地址 mov edi,0 //取消获取地址标记 jmp eax //调用模拟的原API代码 NewRetAddr: push eax //第一次执行压入的是模拟原API的代码地址 第二次执行压入的是模拟API返回结果 call GetCurrentIP //获取当前指令地址 sub eax, 0x1 //减去push eax指令长度1 mov edx, eax //将call NewRetAddr后下一条指令地址保存至edx中 cmp edi, 0x123 jz Contine 这个测试没有问题. 对于用call为什么异常,知道的朋友还请指点下 ths! |
|
编译错误问题 error C2420
你的编译器版本不是VC6吧? 这个源码应该在高级版本应该是通过的,我一直怀疑是vc6的问题呢 |
|
编译错误问题 error C2420
这样肯定不行的,编译错误告警提示 CHook都不能用 |
|
编译错误问题 error C2420
静态成员函数声明: static int __stdcall HookProcDispatch(int nHookAddress, t_Context *pContext); 函数指针定义: typedef int (__stdcall * MYFUN)(int nHookAddress, CHook::t_Context *pContext); MYFUN pFun = CHook::HookProcDispatch; __declspec(naked) void CHook::HookProcHandle() { //查表,调用相应的函数 __asm { pushad mov eax, esp push eax //压入CONTEXT结构 add eax, 0x20 //移动到nHookAddress的地址处 mov edx, dword ptr [eax] //修正返回地址 sub edx, 0x5 mov dword ptr [eax], edx push edx //压入hook地址 mov ebx, eax lea eax, [ebx-0x14] mov eax, dword ptr [eax] add eax, 4 mov dword ptr [ebx-0x14], eax //mov edx, HookProcDispatch mov edx, pFun //改成函数指针,就能调用了 call edx mov dword ptr [ebx], eax popad ret //返回到原来的代码 } } 上面这样修改一翻后,可以编译成功. 估计是VC6版本老,不支持直接嵌入C++静态成员函数 请高手解释下,谢谢 |
|
编译错误问题 error C2420
__declspec(naked) void CHook::HookProcHandle() { //查表,调用相应的函数 __asm { pushad mov eax, esp push eax //压入CONTEXT结构 add eax, 0x20 //移动到nHookAddress的地址处 mov edx, dword ptr [eax] //修正返回地址 sub edx, 0x5 mov dword ptr [eax], edx push edx //压入hook地址 mov ebx, eax lea eax, [ebx-0x14] mov eax, dword ptr [eax] add eax, 4 mov dword ptr [ebx-0x14], eax mov edx, CHook::HookProcDispatch ///////编译错误:error C2420: 'CHook' : illegal symbol in second operand call edx mov dword ptr [ebx], eax popad ret //返回到原来的代码 } } int CHook::HookProcDispatch(int nHookAddress, t_Context *pContext) { CHook *pHook = CHook::GetHookInstance(); EnterCriticalSection(&pHook->m_Cs); map<int, t_HookInfo*>::iterator iter = pHook->m_mapHookInfo.find(nHookAddress); LeaveCriticalSection(&pHook->m_Cs); if (iter != pHook->m_mapHookInfo.end()) { CHook::t_HookInfo *pHookInfo = (CHook::t_HookInfo*)((*iter).second); if (pHookInfo->pfnProc.pThis == NULL) { //C 函数 CHook::HookCProc pfnHookCProc = pHookInfo->pfnProc.u.pfnHookCProc; pfnHookCProc(nHookAddress, pContext); } else { //C++类成员函数 CHook::HookProc pfnHookProc = pHookInfo->pfnProc.u.pfnHookProc; void *pThis = pHookInfo->pfnProc.pThis; __asm { pushad mov ecx, pThis push pContext push nHookAddress mov edx, pfnHookProc call edx popad } } //返回地址 return (int)(pHookInfo->szOldCode); } return 0; } //hook类 class CHook { protected: CHook(void); public: ~CHook(void); struct t_HookInfo; struct t_Context; //函数类型 typedef void (__cdecl *HookCProc)(int nHookAddress, t_Context *pContext); typedef void (__cdecl CHook::*HookProc)(int nHookAddress, t_Context *pContext); public: bool AddHook(int nHookAddress, CHook::HookCProc nHookProc); bool AddHook(int nHookAddress, CHook::HookProc nHookProc, void *pThis); void RemoveHook(int nHookAddress); protected: //返回当前指令的长度 int GetOpCodeSize(BYTE* startaddress); //Hook指定代码地址处 int HookAddress(int nHookAddress, t_HookInfo *pHookInfo); //恢复指定代码处的地址 int RemoveAddress(int nHookAddress, t_HookInfo *pHookInfo); public: struct t_HookProc { void *pThis; union { HookCProc pfnHookCProc; HookProc pfnHookProc; }u; }; struct t_HookInfo { int nHookAddress; t_HookProc pfnProc; int nRetAddress; //返回地址 char szOldCode[32]; int nOldCodeSize; }; struct t_Context { int nEdi; int nEsi; int nEbp; int nEsp; int nEbx; int nEdx; int nEcx; int nEax; }; protected: public: map<int, t_HookInfo*> m_mapHookInfo; CRITICAL_SECTION m_Cs; public: static CHook *m_pHook; static CHook* GetHookInstance(); static void HookProcHandle(); static int __stdcall HookProcDispatch(int nHookAddress, t_Context *pContext); }; 确实是静态成员函数. 这个代码是从下面下载的: http://bbs.pediy.com/showthread.php?t=115449 我只是把hash_map改成了map,因为vc6没有hash_map. 就剩下这个错误,估计是vc6编译有问题,不知道怎么改了... |
操作理由
RANk
{{ user_info.golds == '' ? 0 : user_info.golds }}
雪币
{{ experience }}
课程经验
{{ score }}
学习收益
{{study_duration_fmt}}
学习时长
基本信息
荣誉称号:
{{ honorary_title }}
能力排名:
No.{{ rank_num }}
等 级:
LV{{ rank_lv-100 }}
活跃值:
在线值:
浏览人数:{{ visits }}
最近活跃:{{ last_active_time }}
注册时间:{{ user_info.create_date_jsonfmt }}
勋章
兑换勋章
证书
证书查询 >
能力值