Solved DirectX menu crash

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat
Status
Not open for further replies.

till0sch

Respected Hacker
Dank Tier VIP
Dank Tier Donator
Oct 14, 2012
1,104
12,593
51
Hey guys,

I have the following code:

C++:
#include "menu.h"
#include <conio.h>

static ID3DXFont* font = NULL;
BOOL fontonce = false;

static RECT r;

D3DCOLOR FontColor = D3DCOLOR_XRGB(255, 255, 0);

void ResetFont()
{
	font->OnLostDevice();
	font->OnResetDevice();
}

void Draw_Text(LPCSTR TextToDraw, D3DCOLOR color)
{
	font->DrawTextA(NULL, TextToDraw, strlen(TextToDraw), &r, DT_NOCLIP, color);
}

void DrawMenu(LPDIRECT3DDEVICE9 pDevice)
{
	if (font != 0)
	{
		font->Release();
	}

	font = 0;
	D3DXCreateFontA(pDevice, 16, 6, FW_BOLD, 0, 0, DEFAULT_CHARSET, OUT_TT_ONLY_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial", &font);

	Draw_Text("DX hook", D3DCOLOR_XRGB(255, 0, 255));
}
which crashes. I have already stepped through it with a debugger. Without calling Draw_Text, my game which I inject into, doesn't crash.. Also does my D3DXCreateFontA return S_OK. The ResetFont gets called by my Reset hook and the DrawMenu by my EndScene hook.


Other hooks I coded previously work well with the same SDK. I have both, 2004 summer and 2010 June installed and tested with both.

Following it with a debugger until it ultimatley crashes, it ends up at CSprite::End or something similar-named.

To the crash:



I know, that recreating the font all time isn't necessary but that's the result of trying to test eveything out.
 

till0sch

Respected Hacker
Dank Tier VIP
Dank Tier Donator
Oct 14, 2012
1,104
12,593
51
I did actually manage to fix this. It was neither code related nor compiler related. I reinstalled the SDK (2010, June) and also my directX to 2010 June (the newest I could get for DirectX 9.0C) and now it does work.

Regardless of that am I asking myself what actually caused that error but still, /closed.
 

till0sch

Respected Hacker
Dank Tier VIP
Dank Tier Donator
Oct 14, 2012
1,104
12,593
51
static RECT r;
The rectangle isn't initialized. That's the only problem I can see atm.
Tried that, didn't fix the issue...
The error says something on different calling conventions. I know but those are obviously, but any idea?

Because actually I'm just adding that function (DrawText) from d3dx9.h, so no wrong definition by my side...

This must be a compiler issue related to Visual Studio 2013.
The same compiled source with the same SDK I compiled with Visual Studio 2010 once (Don't have it installed anymore) works. I injected that DLL I had built with VS2010 and it didn't crash.


So far, thanks for your help..
 
Last edited:
Status
Not open for further replies.
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