I hooked PaintTraverse, well I'm trying. Is PaintTraverse 39 in the vtable? And which module is it, vgui2.dll I assume?
Also, I'm doing this for CSS.
Heres my hooking code:
Code:
DWORD *HookVFunc(DWORD *vtable, int index, DWORD *newFunction)
{
DWORD dwOldProt, *oldFunc;
VirtualProtect(&vtable[index], 4, PAGE_EXECUTE_READWRITE, &dwOldProt);
oldFunc=(DWORD*)vtable[index];
vtable[index]=(DWORD)newFunction;
VirtualProtect(&vtable[index], 4, dwOldProt, &dwOldProt);
return oldFunc;
}
That is used to hook it, you gave that to me
Code:
//In Globals area
void (__stdcall *oPaintTraverse)(VPANEL, bool, bool);
void __stdcall xPaintTraverse(VPANEL hookpanel, bool forceRepaint, bool allowForce)
{
HANDLE hnd = GetStdHandle(STD_OUTPUT_HANDLE);
g_pISurface->DrawSetColor(255,0,0,255);
g_pISurface->DrawFilledRect(0,0,100,100);
WriteText(hnd,"Paint Traverse");
oPaintTraverse(hookpanel,forceRepaint,allowForce);
}
//In my winmain
CreateInterfaceFn PaintTraverseInt = (CreateInterfaceFn)GetProcAddress(GetModuleHandle("vgui2.dll"),"CreateInterface");
PaintTraverseHook = (DWORD *)PaintTraverseInt(VGUI_PANEL_INTERFACE_VERSION,NULL);
oPaintTraverse = (void (__stdcall *)(VPANEL, bool, bool))HookVFunc(*(DWORD**)PaintTraverseHook, 39,(DWORD*) &xPaintTraverse);
This doesn't crash or anything, it runs perfectly fine it just doesn't run the xPaintTraverse, to my knowledge. And there is nothing else wrong in the game so.
~lilneo