流沙团
VirtualTable Hook
2020-7-19 流沙团


关键是定位虚表的位置







#include "stdafx.h"
#include <windows.h>

class Base{

public:
virtual void Print(){
printf("gyarmy.com\n");
}

};

void hookPrint(){
printf("hook_gyarmy\n");
}


int main(int argc, char* argv[])
{
Base *pb = new Base();

//关键定位虚表的位置
DWORD *pVtAddr = (DWORD*)*(DWORD*)pb;

DWORD dwOldProtect = 0;

VirtualProtect(pVtAddr,4,PAGE_EXECUTE_READWRITE,&dwOldProtect);
*pVtAddr = (DWORD)hookPrint;

pb->Print();

delete pb;

return 0;
}

发表评论:
昵称

邮件地址 (选填)

个人主页 (选填)

内容