ftbk86
驱动牛犊
驱动牛犊
  • 注册日期2005-11-29
  • 最后登录2016-01-09
  • 粉丝0
  • 关注0
  • 积分57分
  • 威望402点
  • 贡献值0点
  • 好评度15点
  • 原创分0分
  • 专家分0分
阅读:2187回复:1

HOOK getcursorPos为什么不行呢!大侠看看呢!

楼主#
更多 发布于:2012-02-17 12:31


typedef BOOL (WINAPI* TRUEGetCursorPos)(LPPOINT lpPoint);
TRUEGetCursorPos pTGetcursorPos = NULL;
unsigned char gcode1[5];

BOOL MyGetCursorPos(LPPOINT lpPoint)
{
    DWORD dwOldProtect;
    DWORD lOldProtect=0;    
    VirtualProtect(pTGetcursorPos, 5, PAGE_READWRITE, &dwOldProtect);
    CopyMemory(pTGetcursorPos, &gcode1, 5);
    VirtualProtect(pTGetcursorPos, 5, dwOldProtect, &dwOldProtect);

    BOOL bRet = pTGetcursorPos(lpPoint);

    unsigned char JmpCode[5]={0xe9,0x00,0x00,0x00,0x00};
    int JmpOffset = (char*)MyGetCursorPos - ((char*)pTGetcursorPos) -5;
    CopyMemory(JmpCode+1,&JmpOffset,4);
    VirtualProtect((char*)pTGetcursorPos,5,PAGE_READWRITE,&lOldProtect);
    CopyMemory(&gcode1,pTGetcursorPos,5);
    CopyMemory((char*)pTGetcursorPos,JmpCode,5);
    VirtualProtect((char*)pTGetcursorPos,5,lOldProtect,&lOldProtect);
    return bRet;
}
、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、
//以下是跳转代码


        DWORD lOldProtect=0;
    HMODULE hDSound = LoadLibrary(_T("user32.dll"));
    char *pDirectSoundCreate = (char*)GetProcAddress(hDSound,"GetCursorPos");
    pTGetcursorPos = (TRUEGetCursorPos)((char*)pDirectSoundCreate);

    unsigned char JmpCode[5]={0xe9,0x00,0x00,0x00,0x00};
    int JmpOffset = (char*)MyGetCursorPos - ((char*)pDirectSoundCreate) -5;
    CopyMemory(JmpCode+1,&JmpOffset,4);

    VirtualProtect((char*)pDirectSoundCreate,5,PAGE_READWRITE,&lOldProtect);
    CopyMemory(&gcode1,pDirectSoundCreate,5);
    CopyMemory((char*)pDirectSoundCreate,JmpCode,5);
    VirtualProtect((char*)pDirectSoundCreate,5,lOldProtect,&lOldProtect);    
    FreeLibrary(hDSound);
znsoft
管理员
管理员
  • 注册日期2001-03-23
  • 最后登录2023-10-25
  • 粉丝300
  • 关注6
  • 积分910分
  • 威望14796点
  • 贡献值7点
  • 好评度2410点
  • 原创分5分
  • 专家分100分
  • 社区居民
  • 最爱沙发
  • 社区明星
沙发#
发布于:2012-02-18 08:22
你想实现什么效果?现在是什么情况、
http://www.zndev.com 免费源码交换网 ----------------------------- 软件创造价值,驱动提供力量! 淡泊以明志,宁静以致远。 ---------------------------------- 勤用搜索,多查资料,先搜再问。
游客

返回顶部