VirtualTable Hook

关键是定位虚表的位置


#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;
}

原文链接: VirtualTable Hook 版权所有,转载时请注明出处,违者必究。
注明出处格式:流沙团 ( https://gyarmy.com/post-589.html )

发表评论

0则评论给“VirtualTable Hook”