Skip to content

Latest commit

 

History

History
146 lines (122 loc) · 3.85 KB

File metadata and controls

146 lines (122 loc) · 3.85 KB

ShowString from graphic.dll

  • Some versions of the game may use ShowStringEx or ShowStringW.
  • Some ideas:
    • Create unique player names for specific players
    • Customize guild name size or style
    • Custom NPC names
    • Custom MOB/entity names
    • Custom Server name
    • Custom FPS / PING display
    • Render stronger outlines
    • Store strings & re-render with your own system
  • Modifications can be done in real time, such as changing the font size, current font type, and more.

Posts:

Demo

Example2 Example

Structures and types

typedef struct {
    int width;
    int height;
} C3_SIZE;

typedef struct {
    int x;
    int y;
} C3_POS;

enum RENDER_TEXT_STYLE {
    STYLE_DEFAULT = 0,
    STYLE_BOLD = 1,
};

typedef C3_SIZE(__cdecl* tShowStringEx)(
    int, int, unsigned long, const char*, const char*, int,
    bool, RENDER_TEXT_STYLE, unsigned long, C3_POS
);

tShowStringEx oShowStringEx = nullptr;

Getting the Function Pointer

HMODULE hGraphic = GetModuleHandleA("graphic.dll");

oShowStringEx = (tShowStringEx)GetProcAddress(
    hGraphic,
    "?ShowStringEx@CMyBitmap@@SA?AUC3_SIZE@@HHKPBD0H_NW4RENDER_TEXT_STYLE@@KUC3_POS@@@Z"
);

Our modification

float fRed = 0.0f, fGreen = 0.0f, fBlue = 0.0f;
float fTime = 0.0f;
DWORD lastTick = 0;

void updateRainbowColors() {
	DWORD currentTick = GetTickCount();

	float deltaTime = (currentTick - lastTick) / 1000.0f;
	lastTick = currentTick;

	fTime += deltaTime;

	fRed = (sin(fTime) + 1.0f) / 2.0f;
	fGreen = (sin(fTime + 2.0f) + 1.0f) / 2.0f;
	fBlue = (sin(fTime + 4.0f) + 1.0f) / 2.0f;
}

D3DCOLOR gRainbow() {
	return D3DCOLOR_RGBA(static_cast<int>(fRed * 255),
		static_cast<int>(fGreen * 255),
		static_cast<int>(fBlue * 255),
		255);
}

Hooked ShowStringEx

This example targets the FPS/ping counter (FpsAver), but it can be adapted to intercept any text rendered by the game.

C3_SIZE __cdecl hkShowStringEx(
    int iPosX, int iPosY, DWORD color,
    const char* pszString, const char* pszFont,
    int nFontSize, bool bAntialias,
    RENDER_TEXT_STYLE style, DWORD secondColor,
    C3_POS ptOffset
) {
    // Target FPS/Ping text
    if (strstr(pszString, "FpsAver") != nullptr) { // or "C3Ver:DX"
        updateRainbowColors();
        return oShowStringEx(
            iPosX, iPosY, gRainbow(),
            pszString, pszFont,
            nFontSize, bAntialias,
            style, secondColor,
            ptOffset
        );
    }

    return oShowStringEx(
        iPosX, iPosY, color,
        pszString, pszFont,
        nFontSize, bAntialias,
        style, secondColor,
        ptOffset
    );
}

Variant ShowStringW

"?ShowStringW@CMyBitmap@@SA?AUC3_SIZE@@HHKPBGPBDH_NW4RENDER_TEXT_STYLE@@KUC3_POS@@@Z"
typedef C3_SIZE(__cdecl* tShowStringW)(int, int, DWORD, const wchar_t*, const char*, int, bool, RENDER_TEXT_STYLE, DWORD, C3_POS);

tShowStringW oShowStringW = nullptr;

C3_SIZE __cdecl hkShowStringW(int iPosX, int iPosY, DWORD color, const wchar_t* pszString, const char* pszFont, int nFontSize, bool bAntialias, RENDER_TEXT_STYLE style, DWORD secondColor, C3_POS ptOffset)
{
    //your code...
    //manage wchar_t* & find your specific target, for now we'll coloring everything
    return oShowStringW(
        iPosX, iPosY, gRainbow(),
        pszString, pszFont,
        nFontSize, bAntialias,
        style, secondColor,
        ptOffset
    );
}

Other addresses

//29-7-2016 graphic.dll dx8

"?ShowStringEx@CMyBitmap@@SA?AUCMySize@@HHKPBD0HHW4RENDER_TEXT_STYLE@@KAAUCMyPos@@@Z"

"?ShowStringW@CMyBitmap@@SA?AUCMySize@@HHKPBGPBDHHW4RENDER_TEXT_STYLE@@KAAUCMyPos@@@Z"