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

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

楼主#
更多 发布于:2012-02-17 12:34
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);
游客

返回顶部