Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > 12Sky2
You last visited: Today at 11:19

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



how to hooking d3dx library and change font and size

Discussion on how to hooking d3dx library and change font and size within the 12Sky2 forum part of the MMORPGs category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Apr 2020
Posts: 19
Received Thanks: 4
how to hooking d3dx library and change font and size

Hello, when I examined the exe I used with ida, the font was created with the "d3dxcreatefontindirecta" function. I tried to hook this function with the minhook library, but the client gave an error. I think my mistake is in calling the function.


My code;
Code:
// Hooks.h
#pragma once

#include "Core.h"
#include <WinSock2.h>
#include <WS2tcpip.h>
#include <d3dx9.h>
#include "MinHook.h"
#pragma comment(lib, "d3dx9.lib")
#pragma comment(lib, "ws2_32.lib")
#pragma comment(lib, "kernel32.lib")

// Connect
typedef int (WINAPI* CONNECT)(SOCKET, const struct sockaddr*, int);
extern CONNECT oConnect;
int WINAPI HookedConnect(SOCKET s, const struct sockaddr* name, int namelen);

// CreateFileA
bool IsAllowedDirectory(const std::string& dir);
std::tuple<std::string, std::string, std::string>SplitPath(const std::string& filePath);
typedef HANDLE(WINAPI* tCreateFileA)(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode,
    LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition,
    DWORD dwFlagsAndAttributes, HANDLE hTemplateFile);
extern tCreateFileA oCreateFileA;
HANDLE WINAPI HookedCreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode,
    LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition,
    DWORD dwFlagsAndAttributes, HANDLE hTemplateFile);

// Font
typedef int(__thiscall* tFont)(char*);
extern tFont oFont;
BOOL hookedFont(char *thisPtr);

typedef HRESULT(WINAPI* tD3DXCreateFontIndirectA)(LPDIRECT3DDEVICE9, CONST D3DXFONT_DESCA*, LPD3DXFONT*);
extern tD3DXCreateFontIndirectA oD3DXCreateFontIndirectA;
HRESULT WINAPI HookedD3DXCreateFontIndirectA(LPDIRECT3DDEVICE9 pDevice, CONST D3DXFONT_DESCA* pDesc, LPD3DXFONT* ppFont);

// Declare the function to install and uninstall the hook
DWORD InstallHook();
DWORD UninstallHook();


// Hooks.cpp
#include "Hooks.h"

DWORD InstallHook()
{
    // Initialize MinHook
    if (MH_Initialize() != MH_OK) {
        // Handle initialization error
        return 1;
    }

    // Create a hook for the connect function
    if (MH_CreateHookApi(L"ws2_32.dll", "connect", &HookedConnect, reinterpret_cast<LPVOID*>(&oConnect)) != MH_OK) {
        // Handle hook creation error
        return 1;
    }

    // Create a hook for the CreateFileA function
    if (MH_CreateHookApi(L"kernel32.dll", "CreateFileA", &HookedCreateFileA, reinterpret_cast<LPVOID*>(&oCreateFileA)) != MH_OK) {
        // Handle hook creation error
        return 1;
    }

    // Create a hook for the Font function
    oFont = reinterpret_cast<tFont>(0x004BDF60); // Replace with the actual address
    if (MH_CreateHook(reinterpret_cast<void*>(oFont), &hookedFont, reinterpret_cast<void**>(&oFont)) != MH_OK) {
        // Handle hook creation error
        return 1;
    }

    if (MH_CreateHookApi(L"D3DX9_42.dll", "D3DXCreateFontIndirectA", &HookedD3DXCreateFontIndirectA, reinterpret_cast<LPVOID*>(&oD3DXCreateFontIndirectA)) != MH_OK) {
        // Handle hook creation error
        MessageBoxA(NULL, "MinHook Error", "MinHook Error", MB_OK);
        return 1;
    }


    // Enable the hook
    if (MH_EnableHook(MH_ALL_HOOKS) != MH_OK) {
        // Handle hook enable error
        return 1;
    }

    return 0;
}

DWORD UninstallHook()
{
    // Disable the hook
    if (MH_DisableHook(MH_ALL_HOOKS) != MH_OK) {
        // Handle hook disable error
        return 1;
    }

    // Uninitialize MinHook
    if (MH_Uninitialize() != MH_OK) {
        // Handle uninitialization error
        return 2;
    }

    return 0;
}

// CreateFileA.cpp
#include "Hooks.h"
#include <Shlwapi.h>

tFont oFont = nullptr;

BOOL hookedFont(char *thisPtr)
{
    std::string fontPath = "G01_GFONT\\gigassoft_12.ttf";

    if (!PathFileExistsA(fontPath.c_str())) {
        return 0;
    }
    else {
        if (!AddFontResourceA(fontPath.c_str())) {
            return 0;
        }
        else {
            return 1;
        }
    }
   
}

tD3DXCreateFontIndirectA oD3DXCreateFontIndirectA = nullptr;
HRESULT WINAPI HookedD3DXCreateFontIndirectA(LPDIRECT3DDEVICE9 pDevice, CONST D3DXFONT_DESCA* pDesc, LPD3DXFONT* ppFont) {

    // Yeni font parametreleri
    D3DXFONT_DESCA newFontDesc;
    ZeroMemory(&newFontDesc, sizeof(newFontDesc));
    newFontDesc.Height = 48;  // Punto boyutu
    newFontDesc.Width = 0;
    newFontDesc.Weight = FW_NORMAL;
    newFontDesc.MipLevels = 1;
    newFontDesc.Italic = FALSE;
    newFontDesc.CharSet = DEFAULT_CHARSET;
    newFontDesc.OutputPrecision = OUT_DEFAULT_PRECIS;
    newFontDesc.Quality = DEFAULT_QUALITY;
    newFontDesc.PitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
    strcpy_s(newFontDesc.FaceName, "Arial");  // Font adı

    HRESULT result = oD3DXCreateFontIndirectA(pDevice, &newFontDesc, ppFont);

    if (result >= 0)
    {
        MessageBoxA(NULL, "test", "test", NULL);
    }

    return result;
}
Thanks in advance for your help...
@ @ @ @ @ @
sLowNight2 is offline  
Old 08/19/2025, 13:23   #2

 
Mega Byte's Avatar
 
elite*gold: 0
Join Date: Dec 2009
Posts: 1,777
Received Thanks: 1,003
More than font size would need to change the positions it renders and size of areas it might wrap too if any.

I suspect that you can hook d3d functions through patching the vtable.
The addresses are different you need a signature scan to find the device then get the vtable.
But in saying this I have not hooked the font stuff.

Good luck
Mega Byte is offline  
Old 08/19/2025, 16:31   #3
 
elite*gold: 0
Join Date: Aug 2025
Posts: 57
Received Thanks: 12
Quote:
Originally Posted by Mega Byte View Post
More than font size would need to change the positions it renders and size of areas it might wrap too if any.

I suspect that you can hook d3d functions through patching the vtable.
The addresses are different you need a signature scan to find the device then get the vtable.
But in saying this I have not hooked the font stuff.

Good luck
Ohh good morning!
zahter31 is offline  
Old 08/22/2025, 18:56   #4
 
elite*gold: 0
Join Date: May 2015
Posts: 62
Received Thanks: 8
xmetrix is offline  
Reply


Similar Threads Similar Threads
[SIZE="4"][FONT="Arial Black"][B] Server 1 Gold [S] E*Gold/PSC[/FONT][/SIZE]
03/04/2013 - Nostale Trading - 23 Replies
Wie im Titel erwähnt, verkaufe ich mein NosTale-Gold... Ich nehme als Zahlungsmittel an...: 1. E*Gold 2. Paysafecard, diese könnt ihr auch gleich einlösen, und dann kann ich euch 26 E*Gold für jeweils 1,5kk verkaufen,,.... dann habt ihr auch eine Sicherheit^^ Ich wähle meinen Kurs 1€= 1,5kk EDIT--> 4.03.2013 Sonderangebot:
[FONT="Arial Black"][SIZE="7"]Need for Speed World down ?[/SIZE][/FONT]
06/10/2012 - Need for Speed World - 0 Replies
ist ned for speed down weil ich komme rein nur bis stüzpunkt und wen ich auf den welter fahren will ladet er 20 min lang und pasiert nixx auser laden neustarte neue instalieren alles versucht und so xD
[FONT="Tahoma"][SIZE="6"][/SIZE][/FONT] KAUFE CROSSFIRE ACC
02/17/2012 - CrossFire Trading - 1 Replies
Suche Crossfire Acc wo mindesten QBZ drauf ist . Privat Nachricht oder Skype adden : jisyx3 Danke ! :):mofo:
VK 1st Lt [FONT="Tahoma"][SIZE="6"][/SIZE][/FONT]
11/14/2011 - CrossFire Trading - 3 Replies
Verkaufe meinen VK 1st Lt & 4 Striche voll. Waffen : Ak47 Silver, Anaconda Adv, AWM, DE , M4 Custom, QBZ, M16A2, Thompson. ca. 23k GP & 5503 BP Char : SWAT , STAR , SPOP 17 Ribbons
[SIZE="3"][FONT="Arial Black"]Vk Acc (kommt aufs Angebot an)[/FONT][/SIZE]
10/26/2010 - 4Story Trading - 5 Replies
hi leute, möchte hier meinen xhadra/valo acc vllt verkaufen. kommt auf das angebot drauf an ^^ ist ein bogi lvl 29 aber viel gold. sehr gutes eq wird dann bei intresse genauer beschrieben. bei interesse schreiben. sry wegen der Beschreibung ;)



All times are GMT +1. The time now is 11:23.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.