-
Автор темы
- #1
Привет
Сама функция
Тут хуки
Сам класс хука
Возможно ли по другому отрисовать surface
Сама функция
Код:
typedef void(__stdcall* PaintTraverse_t)(vgui::VPANEL,bool,bool);
void __stdcall C_Hook::new_PaintTraverse(vgui::VPANEL vguiPanel, bool forceRepaint, bool allowForce)
{
pPanelHook->Function<PaintTraverse_t>(40)(vguiPanel, forceRepaint, allowForce);
static unsigned int drawPanel;
if (!drawPanel)
if (strstr(m_pPanel->GetName(vguiPanel), "MatSystemTopPanel"))
drawPanel = vguiPanel;
DO_ONCE(gDraw.Font();
m_pEngine->GetScreenSize(sScreenSize.m_iWidth, sScreenSize.m_iHeight);
);
if (vguiPanel != drawPanel)
return;
gOther.UpdateFont();
gMenu.Render();
}
Тут хуки
Код:
unsigned long dwPanel = (unsigned long)m_pPanel;
pPanelHook = new C_VMT(&dwPanel);
pPanelHook->Hook((unsigned long)C_Hook::new_PaintTraverse, 40);
C_VMT:
C_VMT* HOOK:
class C_VMT
{
C_VMT(const C_VMT &other);
C_VMT &operator = (const C_VMT &other);
public:
C_VMT(DWORD *Instance)
{
ppInstance = (*(PDWORD**)Instance);
pOldVMT = *ppInstance;
VMTSize = dwGetVMTCount(pOldVMT);
if (VMTSize <= 0) return;
pNewVMT = new DWORD[VMTSize];
memcpy(pNewVMT, pOldVMT, sizeof(DWORD) * VMTSize);
*ppInstance = (pNewVMT);
Instance = pNewVMT;
}
void Hook(DWORD dwNewFunc, unsigned int iIndex)
{
if (pNewVMT && pOldVMT && iIndex <= VMTSize && iIndex >= 0)
{
pNewVMT[iIndex] = dwNewFunc;
}
}
void Unhook(unsigned int iIndex)
{
if (pNewVMT && pOldVMT && iIndex <= VMTSize && iIndex >= 0)
{
pNewVMT[iIndex] = pOldVMT[iIndex];
}
}
DWORD OldPointer(int iIndex)
{
return pOldVMT[iIndex];
}
DWORD NewPointer(int iIndex)
{
return pNewVMT[iIndex];
}
template<typename T> T Function(int Index)
{
return (T)(pOldVMT[Index]);
}
private:
DWORD dwGetVMTCount(PDWORD pdwVMT)
{
DWORD dwIndex = 0;
for (dwIndex = 0; pdwVMT[dwIndex]; dwIndex++)
{
if (IsBadCodePtr((FARPROC)pdwVMT[dwIndex]))//Error
{
break;
}
}
return dwIndex;
}
DWORD** ppInstance;
DWORD* pNewVMT, *pOldVMT;
DWORD VMTSize;
};