Skip to content
MPGHThe Dark Arts
/
RegisterLog in
Forum
Community
What's NewLatest posts across the boardTrendingHottest threads right nowSubscribedThreads you follow
Discussion
GeneralIntroductionsEntertainmentDebate FortFlaming & Rage
Board
News & AnnouncementsMPGH TimesSuggestions & HelpGiveaways
More Sections
Art & Graphic DesignProgrammingHackingCryptocurrency
Hacks & Cheats
Games
ValorantCS2 / CS:GOCall of Duty / WarzoneFortniteApex LegendsEscape From Tarkov
+14 moreLeague of LegendsGTA VMinecraftRustROTMGBattlefieldTroveBattleOnCombat ArmsCrossFireBlackshotRuneScapeDayZDead by Daylight
Resources
Game Hacking TutorialsReverse EngineeringGeneral Game HackingAnti-CheatConsole Game Hacking
Tools
Game Hacking ToolsTrainers & CheatsHack/Release NewsNew
Submit a release →Share your cheat, tool, or config with the community.
AINEW
AI Tools
General & DiscussionPrompt EngineeringLLM JailbreaksHotAI Agents & AutomationLocal / Open Models
AI × Gaming
AI Aimbots & VisionML Anti-CheatGame Bots & Automation
Create
AI Coding / Vibe CodingAI Art & MediaAI Voice & TTS
The AI frontier →Where game hacking meets modern machine learning. Jump in.
Marketplace
Buy & Sell
SellingBuyingTradingUser Services
Trust & Safety
Middleman LoungeMarketplace TalkVouch Copy Profiles
Money
Cryptocurrency TalkCurrency ExchangeWork & Job Offers
Start selling →List accounts, services, and goods. Use the middleman to trade safe.
MPGH The Dark Arts

A community for offensive security research, reverse engineering, and AI.

Community

ForumMarketplaceSearch

Account

RegisterLog in

Legal

Privacy PolicyForum RulesHelp & FAQ
© 2026 MPGH · All rights reserved.Built by the community, for the community. For educational purposes onlyContent is shared for security research and education — we don't condone illegal use. You're responsible for complying with applicable laws. Use at your own risk.
Home › Forum › Programming › C++/C Programming › [CODE]VTable hooking

Post[CODE]VTable hooking

Posts 1–5 of 5 · Page 1 of 1
Hell_Demon
Hell_Demon
[CODE]VTable hooking
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;
}
A bit of a mess, but it works

Example usage:
Code:
UINT (__stdcall *oGetAdapterCount)(void);
UINT __stdcall xGetAdapterCount(void)
{
	MessageBox(0, L"hooked", L"hook", MB_OK);
	return oGetAdapterCount();
}

int main()
{
	HANDLE hDll = LoadLibrary(L"d3d9.dll");
	IDirect3D9 *pD9 = Direct3DCreate9(D3D_SDK_VERSION);
	//the index of GetAdapterCount is 4
	oGetAdapterCount = (UINT (__stdcall *)(void))hookVFunc(*(DWORD**)pD9, 4, (DWORD*)&xGetAdapterCount);
	pD9->GetAdapterCount();
	system("pause");
	return 1;
}
Have fun?

~ Hell
#1 · 15y ago
Void
Void
Noice, VirtualProtect + pointers.
Naws, gj HD, makes patching the vtable much cleaner.

Btw, still no type definitions for those long casts? D:

Code:
oGetAdapterCount = (UINT (__stdcall *)(void))hookVFunc(*(DWORD**)pD9, 4, (DWORD*)&xGetAdapterCount);
Luckily that function doesn't even take any arguments.
#2 · 15y ago
Hell_Demon
Hell_Demon
compile
error: cannot cast from DWORD * to UINT (__stdcall *)(void)
C&P the typecast
compile
success

/victory.
#3 · 15y ago
Hell_Demon
Hell_Demon
^5[^9AU^5]^9Wesley: hookVFunc(0x40CE14, 40, (DWORD*)&yuorEndScene);
Tweak: Yeah
^5[^9AU^5]^9Wesley: or *(DWORD*)0x40CE14, not sure
^5[^9AU^5]^9Wesley: it really cant be that hard lol
Tweak: I believe it worked.
Tweak: I injected, and nothing happened (no crash)
Tweak: so
^5[^9AU^5]^9Wesley: k
^5[^9AU^5]^9Wesley: did u return orig function?
Tweak: er
^5[^9AU^5]^9Wesley: shove a messagebox in there
Tweak: In hookVFunc?
Tweak: hmmm
Tweak: nothing
^5[^9AU^5]^9Wesley: no
^5[^9AU^5]^9Wesley: in your hooked func >.>
Tweak: owait
Tweak: failme
Tweak: I'm using it as a dll
Tweak: and it has int main
^5[^9AU^5]^9Wesley: *facepalm*
^5[^9AU^5]^9Wesley: might wanna go read up on C++ basics
Tweak: the code was copy pasted....
Tweak: To see if it would work
#4 · 15y ago
Void
Void
Quote Originally Posted by Hell_Demon View Post
^5[^9AU^5]^9Wesley: hookVFunc(0x40CE14, 40, (DWORD*)&yuorEndScene);
Tweak: Yeah
^5[^9AU^5]^9Wesley: or *(DWORD*)0x40CE14, not sure
^5[^9AU^5]^9Wesley: it really cant be that hard lol
Tweak: I believe it worked.
Tweak: I injected, and nothing happened (no crash)
Tweak: so
^5[^9AU^5]^9Wesley: k
^5[^9AU^5]^9Wesley: did u return orig function?
Tweak: er
^5[^9AU^5]^9Wesley: shove a messagebox in there
Tweak: In hookVFunc?
Tweak: hmmm
Tweak: nothing
^5[^9AU^5]^9Wesley: no
^5[^9AU^5]^9Wesley: in your hooked func >.>
Tweak: owait
Tweak: failme
Tweak: I'm using it as a dll
Tweak: and it has int main
^5[^9AU^5]^9Wesley: *facepalm*
^5[^9AU^5]^9Wesley: might wanna go read up on C++ basics
Tweak: the code was copy pasted....
Tweak: To see if it would work
Wow... \:

This is what happens when you try and help leechers.
#5 · 15y ago
Posts 1–5 of 5 · Page 1 of 1

Post a Reply

Similar Threads

  • [Source]Vtable Hook?By SoreBack in Combat Arms Hacks & Cheats
    17Last post 17y ago
  • Vtable hooking/Vmt hookingBy SirKinky in Alliance of Valiant Arms (AVA) Discussions
    2Last post 14y ago
  • Vtable hook sourceBy nitega in All Points Bulletin Reloaded Hacks
    26Last post 14y ago
  • -How to make .dll[Vtable Hook]-By gokhanw in All Points Bulletin Reloaded Hacks
    16Last post 14y ago
  • how the vtable hook works?By romencool in All Points Bulletin Reloaded Hacks
    3Last post 14y ago

Tags for this Thread

None