Guide How to Hook DirectX 9 - Direct3D Hooking Tutorials

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat


Piece of shit
Escobar Tier VIP
Fleep Tier Donator
Jun 29, 2017
How long you been coding/hacking?
3 years
DirectX is a graphics API whose purpose is to communicate with hardware (like your GPU) to render video, 3D and 2D graphics and some other stuff in games without worrying about specific implementations. When we are hacking games, we want to make cool looking hacks with an UI to make easier for people to use them or just make an ESP Hack.

People usually start hacking games like CS GO, which uses DirectX 9. In this guide you will learn the steps to make your menu hacks using DirectX 9.

How to Hook DirectX 9 - Direct3D Hooking Tutorials

Where you can learn the API
You need to learn the basics of 3D Game Programming and how DirectX 9 Works. Here are some links/suggestions to tutorials and books: <- read the free tutorials
Drunken Hyena : DirectX 9 Tutorials - C++ <- here you can learn the basic concepts too
ChiliTomatoNoodle's Beginner C++ Game Programming DirectX playlist

If you like reading books, I recommend "Beginning DirectX 9 (Game Development Series)".

How to include D3D9X

Some old source code and tutorials utilize the D3D9X library. This is deprecated and is no longer part of the Windows/VS SDK. Read more here.

You must download Direct3d9 SDK June 2010 to get this lib. Download Here and install. Then go to your project properties and add these to your project dependency include folders:


Sometimes you need to manually define these:
C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include
C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Lib\x86

Learn more about Direct3D9 here

How you can draw stuff in games
You can do this externally or internally. To do this externally, make a DirectX overlay by making a transparent window and cover the game window with it. To do this internally, you need to hook a function that is related to drawing/rendering like EndScene, Present. I'm going to talk more about these two methods below.

Source Code - D3D9 EndScene Hook Template Using Dummy Device

Read this tutorial from @timb3r regarding d3d9 hooking

Steps to draw your stuff internally
1-Get d3d device
2-Get the vTable address
3-Hook a function in the vTable like EndScene, Present and put your menu stuff in the hook

Getting d3d device
To get the vTable address, you need to find pDevice/create a dummy device. Here are some tutorials/sources:

Broihon's functions to create a dummy device
Tutorial - How to find pDevice in DirectX 9 games
Traxin's Dx9 Hook Help Source
Video Tutorial - CS:GO How to Hook DirectX9

Video Tutorial - CSGO Direct3D9 EndScene Hook & D3D9 ESP Tutorial Series

VTable Hooking
In order to hook DirectX 9 functions, you need to know how vTables and vTable hooking works. Here are some tutorials/sources about it:

C++ vPointers and vTables playlist
Great VMT Hooking Article
Tutorial - VTables and Hooking Them
Tutorial - vTable Hooking / VMT hooking
Source Code - VTableHookManager Class

Hooking the functions
Tutorial - Direct3D9 Hooking / DirectX Hook - Need For Speed: Most Wanted
Tutorial - Direct3D9 Hooking / DirectX Hook - Need For Speed: Most Wanted

Drawing your stuff
After doing all these steps, you are free to draw anything you want by putting your code inside the hooked functions.

DirectX11 / Direct3D11 Hooking
Improving your Cheat Template (Hooking DirectX11) - Niemand - Cyber Security
How to Hook DirectX 11 + ImGui (Vermintide 2) - Niemand - Cyber Security


As I said before, you need to make a DirectX overlay by making a transparent window and cover the game window with it. Here's some sources so you can get an idea about how it works:

Source Code - DirectX 9 - Overlay
Release - C++ DirectX External Overlay Working For Any Game / Program
More info here

Sources and Examples of Menu Hacks

Here are some sources to give you ideas. Don't copypaste the code, try learning how it works.

Source Code - My D3D Menu
Source Code - TheProxy D3D Menu
Source Code - DirectX D3D Menu Source Code
Tutorial - Movable D3D Menu
Release - iPower's GTA: SA Menu + Source -> Coded a shit menu class but just to give an idea about how it works.

Other tools/tutorials/sources

Release - Direct3d9 Stride Logger
Source Code - DX9 - Image Class
Release - Microsoft DirectX 9.0 Summer 2004 SDK Download

Well that's it! Feel free to give your opinion about this guide and add some stuff to it!
Last edited by a moderator:


Full Member
Oct 2, 2016
Any resources of how to make your own GUI inside the game you're working with?


I'm not your friend
Jan 21, 2014
Any resources of how to make your own GUI inside the game you're working with?
Basically you find out what graphics library the game uses, most games use Direct3D. Then you learn how to use Direct3D from scratch in your own programs. Then you learn how to make basic hacks & hooking. Then you hook a graphics function that gets called once per frame, which you revers engineer. This will be one of the functions you already learned about what you learned how to use the graphics library. Then you do whatever you want inside that hook to draw on the screen.

And read this: ESP Overview
  • Like
Reactions: malwareboy


Full Member
Oct 23, 2015
A great GUI would be GWEN. Look it up on GitHub. It works for all graphics/rendering libraries. If you're planning to develop your own GUI, this'll serve as a great example. It uses an image file to serve as a skin for the windows and controls and uses textures to draw the images, so don't worry about lagging. It doesn't lag at all.


Jun 15, 2014
hello guys :) it's my first time posting on this forum and i need help. i'm quit new to c++ (i know how to make a basic dll with some cool d3d stuff).
i made a chams cheat for warface. it works fine but when the first game is finnished and i get into another one i can't see the ennemies behind walls anymore (they are still filled with color) here is my chams code:

if (ReturnAddress == (void *)Player&& boolchams) {
			Device->SetRenderState(D3DRS_ZENABLE, FALSE);
			Device->SetRenderState(D3DRS_ZFUNC, D3DCMP_NEVER);
			Device->SetTexture(0, texRed);
			Orginal_DrawIndexedPrimitive(Device, PrimType, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);
			Device->SetRenderState(D3DRS_ZENABLE, TRUE);
			Device->SetRenderState(D3DRS_ZFUNC, D3DCMP_LESSEQUAL);
			Device->SetTexture(0, texBlue);
Last edited by a moderator:
  • Love
Reactions: joker2020


I'm not your friend
Jan 21, 2014
This is awesome, thank you for making this!


Meme Tier VIP
Dank Tier Donator
Apr 1, 2015
What would be some advantages and disadvantages between external and internal?
Jul 15, 2018
I'm trying to use the stb_truetype library to rasterize fonts in directx, but I'm having problems with the background texture, there always appears a black background in texture like in this screenshot:

auto load_font( const char* font_dir ) -> std::optional< stbtt_fontinfo >
    auto font_info = stbtt_fontinfo { };
    auto raw_font = std::fopen( font_dir, "rb" );
    if ( !raw_font )
        return std::nullopt;
    std::fseek( raw_font, 0, SEEK_END );
    auto font_size = std::ftell( raw_font );
    std::fseek( raw_font, 0, SEEK_SET );
    auto font = new std::uint8_t[ font_size ];
    fread( font, font_size, 1, raw_font );
    fclose( raw_font );
    return ( stbtt_InitFont( &font_info, font, 0 ) ) ? std::make_optional( font_info ) : std::nullopt;
auto gen_text_texture( IDirect3DDevice9* device, const stbtt_fontinfo font_info, const std::string& txt ) -> IDirect3DTexture9*
    if ( == nullptr )
        return nullptr;
    auto b_w = 512, b_h = 20, l_f = 20;
    auto bitmap = std::make_unique< std::uint8_t[] >( b_w * b_h );
    auto scale = stbtt_ScaleForPixelHeight( &font_info, l_f );
    auto x = 0, ascent = 0, descent = 0, lineGap = 0;
    stbtt_GetFontVMetrics( &font_info, &ascent, &descent, &lineGap );
    ascent *= scale;
    descent *= scale;
    for ( auto i = 0u; i < txt.size(); ++i )
        auto c_x1 = 0, c_y1 = 0, c_x2 = 0, c_y2 = 0;
        stbtt_GetCodepointBitmapBox( &font_info, txt[ i ], scale, scale, &c_x1, &c_y1, &c_x2, &c_y2 );
        auto y = ascent + c_y1;
        auto byteOffset = x + ( y  * b_w );
        stbtt_MakeCodepointBitmap( &font_info, bitmap.get() + byteOffset, c_x2 - c_x1, c_y2 - c_y1, b_w, scale, scale, txt[ i ] );
        auto ax = 0;
        stbtt_GetCodepointHMetrics( &font_info, txt[ i ], &ax, 0 );
        x += ax * scale;
        auto kern = stbtt_GetCodepointKernAdvance( &font_info, txt[ i ], txt[ i + 1 ] );
        x += kern * scale;
    IDirect3DTexture9* texture { };
    if ( FAILED( D3DXCreateTexture( device, b_w, b_h, 1, D3DUSAGE_DYNAMIC, D3DFMT_L8, D3DPOOL_DEFAULT, &texture ) ) )
        return nullptr;
    D3DLOCKED_RECT rect;
    if ( FAILED( texture->LockRect( 0, &rect, nullptr, 0 ) ) )
        return nullptr;
    memcpy( rect.pBits, bitmap.get(), b_w * b_h );
    texture->UnlockRect( 0 );
    return texture;
auto print_text( IDirect3DDevice9* device, ID3DXSprite* sprite, const stbtt_fontinfo font_info, float x, float y, const std::string& txt, D3DCOLOR color ) -> void
    auto txt_texture = gen_text_texture( device, font_info, txt );
    if ( txt_texture )
        if ( sprite && SUCCEEDED( sprite->Begin( D3DXSPRITE_ALPHABLEND ) ) )
            sprite->Draw( txt_texture, nullptr, nullptr, &D3DXVECTOR3 { x, y, 0.f }, color );
auto create_sprite( IDirect3DDevice9* device ) -> ID3DXSprite*
    ID3DXSprite* output { };
    D3DXCreateSprite( device, &output );
    return output;
auto __stdcall hk_endscene( IDirect3DDevice9* device ) -> HRESULT
    static auto windows_arial_font = load_font( "C:\\Windows\\Fonts\\Arial.ttf" ).value_or( stbtt_fontinfo { } );
    static auto font_sprite = create_sprite( device );
    print_text( device, font_sprite, windows_arial_font, 50.f, 50.f, "Teste", D3DCOLOR_ARGB( 255, 255, 000, 000 ) );
    print_text( device, font_sprite, windows_arial_font, 50.f, 90.f, "Test test", D3DCOLOR_ARGB( 255, 255, 000, 000 ) );
    return o_endscene( device );


Escobar Tier VIP
Trump Tier Donator
Jun 25, 2014
perhaps you should create your texture with a better format than just L8 (only accounts for luminance), preferably something with an alpha channel


I'm not your friend
Jan 21, 2014
How to include Direct3D headers and libs in your project so they'll link correctly, use the environment variable in the VS include directories: $(DXSDK_DIR)\

Sometimes you may need to manually define this one:
C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include

Sometimes you may need to manually define this one:
C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Lib\x86

read this too Where is the DirectX SDK (2015 Edition)?
Last edited:


Meme Tier VIP
Jul 6, 2015
How do I draw ✔✗➤ using D3DXCreateFont, I changed DEFAULT_CHARSET to SYMBOL_CHARSET, but Sysmbol is drawn differently, not drawn ✔✗➤


Dank Tier Donator
Feb 2, 2018
How do I draw ✔✗➤ using D3DXCreateFont, I changed DEFAULT_CHARSET to SYMBOL_CHARSET, but Sysmbol is drawn differently, not drawn ✔✗➤
Aren't those Unicode characters? Try drawing them like you would any other string but instead of using the DrawText function use DrawTextW and draw those as wide char. I can only assume that's what you're doing wrong I'd need to see the code for how you draw the text.
Attention! Before you post:

Read the How to Ask Questions Guide
99% of questions are answered in the Beginner's Guide, do it before asking a question.

No Hack Requests. Post in the correct section.  Search the forum first. Read the rules.

How to make a good post:

  • Fill out the form correctly
  • Tell us the game name & coding language
  • Post everything we need to know to help you
  • Ask specific questions, be descriptive
  • Post errors, line numbers & screenshots
  • Post code snippets using code tags
  • If it's a large project, zip it up and attach it

If you do not comply, your post may be deleted.  We want to help, please make a good post and we will do our best to help you.

Community Mods