Solved D3D Help

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

FloppyWhale

Jr.Coder
Full Member
Nobleman
Jan 12, 2015
65
308
0
Hi guys! I've been trying to make a D3D9 menu for some time now. I've been stumped on this one error I keep getting which is LNK2019. Yes I've looked this up before posting this, I've still yet to find the solution. The full error code is :
Error LNK2019 unresolved external symbol _D3DXCreateFontA@48 referenced in function "long __stdcall Present(struct IDirect3DDevice9 *,struct tagRECT const *,struct tagRECT const *,struct HWND__ *,struct _RGNDATA const *)" (?Present@@YGJPAUIDirect3DDevice9@@PBUtagRECT@@1PAUHWND__@@PBU_RGNDATA@@@Z)

Here's the code where it occurs:
C++:
HRESULT WINAPI Present(LPDIRECT3DDEVICE9 pDevice, CONST RECT *pSourceRect, CONST RECT *pDestRect, HWND hDestWindowOverride, CONST RGNDATA *pDirtyRegion) {
	if (PFont) {
		PFont->Release();
		PFont = NULL;
		bFont = FALSE;
	}

	if (!bFont) {
		D3DXCreateFont(pDevice, 14, 0, 400, 1, 0, 1, 0, 4, 0 | (0 << 4), "Arial", &PFont);
		bFont = TRUE;
	}

	if (GetAsyncKeyState(VK_INSERT) & 1)
		menu.ShowMenu != menu.ShowMenu;

	if (menu.ShowMenu && PFont) {
		pDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
		GetTimeFormat(0, 0, 0, 0, timeStruct, 15);
		DrawBox(menu.matrixPos[0] - 10, menu.matrixPos[1] - 22, 162, 20, TBlack, Green, pDevice);
		DrawBorder(menu.matrixPos[0] - 10, menu.matrixPos[1] - 22, 162, 20, 1, Green, pDevice);
		WriteText(menu.matrixPos[0], menu.matrixPos[1] - 20, Yellow, menuTitle);
		sprintf_s(timeString, "%s", timeStruct);
		WriteText(menu.matrixPos[0] + 100, menu.matrixPos[1] - 20, Yellow, timeString);
		DrawBox(menu.matrixPos[0] - 10, menu.matrixPos[1], 162, ((menu.Current * 15) - 5), TBlack, Green, pDevice);
		DrawBorder(menu.matrixPos[0] - 10, menu.matrixPos[1], 162, ((menu.Current * 15) - 5), 1, Green, pDevice);
		DrawBorder(menu.matrixPos[0] - 10, ((menu.matrixPos[2] + 2) + (menu.MenuSelection * 15)), 162, 13, 1, Cyan, pDevice);
Anyhelp is appreciated!
 

Lovelace

Jr.Coder
Full Member
Nobleman
Oct 23, 2015
83
938
5
Last edited:

FloppyWhale

Jr.Coder
Full Member
Nobleman
Jan 12, 2015
65
308
0
did you import d3dx9.h?
I did. I tried with #pragma comment(lib, "d3dx9.lib"); but that tells me that it can't be found when it's clearly in the directory. I get the above error when I move the d3dx9.lib into the project folder and do #pragma comment(lib, "lib\\d3dx9.lib");
I also do have it included.
 

mambda

headass
Escobar Tier VIP
Trump Tier Donator
Jun 25, 2014
2,297
37,938
269
Well the first one wont work unless your path settings have chosen the architecture, as in the DX sdk folders are set up as Lib\<x86/x64>\LibHere.lib

try to hardcode the full path and see if that works, if it does then its an error in your library path settings
 

Rake

Cesspool Admin
Administrator
Jan 21, 2014
12,092
78,998
2,372
I also had that problem when I upgraded to VS2015, so I had to downgrade back again to VS2013]
Thanks for sharing this information LoveLace we get this question alot.

So basically if I want to learn D3D9 I have to downgrade to 2013? Does anyone know an alternative solution?
 

mambda

headass
Escobar Tier VIP
Trump Tier Donator
Jun 25, 2014
2,297
37,938
269
You dont have to downgrade to use previous SDKs, just tell VS where the libraries are in your Includes/Libraries directory options and it works fine
 

GAFO666

Hacker
Meme Tier VIP
Aug 19, 2012
520
3,188
23
C++:
#include <d3dx9.h>
#include <d3d9.h>

#pragma comment (lib , "d3dx9")
#pragma comment(lib, "d3d9")

Paths examble:
Inc :
C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Include

Lib:
C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Lib\x86
works for me on vs:
- 2013 ultimate
- 2015 ultimate

NOT tottaly SURE but someone at university mentioned:
win10 should be downwards compatible until win7 , same goes for win8
means progs compiled on 7 work normaly on 8 & 10 but not the other way around
 

MasterG

Coder
Dank Tier Donator
Nobleman
Mar 14, 2015
102
888
1
C++:
#include <d3dx9.h>
#include <d3d9.h>

#pragma comment (lib , "d3dx9")
#pragma comment(lib, "d3d9")

Paths examble:
Inc :
C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Include

Lib:
C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Lib\x86
works for me on vs:
- 2013 ultimate
- 2015 ultimate

NOT tottaly SURE but someone at university mentioned:
win10 should be downwards compatible until win7 , same goes for win8
means progs compiled on 7 work normaly on 8 & 10 but not the other way around
Its the compatibility mode thing on windows.
 

Lovelace

Jr.Coder
Full Member
Nobleman
Oct 23, 2015
83
938
5
NOT tottaly SURE but someone at university mentioned:
win10 should be downwards compatible until win7 , same goes for win8
means progs compiled on 7 work normaly on 8 & 10 but not the other way around
Ah that totally makes sense considering how I'm still stuck with Win 7.
 

FloppyWhale

Jr.Coder
Full Member
Nobleman
Jan 12, 2015
65
308
0
Well the first one wont work unless your path settings have chosen the architecture, as in the DX sdk folders are set up as Lib\<x86/x64>\LibHere.lib

try to hardcode the full path and see if that works, if it does then its an error in your library path settings
What should I base my architecture on? My PC or the game?
 

FloppyWhale

Jr.Coder
Full Member
Nobleman
Jan 12, 2015
65
308
0
If you're using Visual Studio 2015...

I also had that problem when I upgraded to VS2015, so I had to downgrade back again to VS2013. Older versions of DirectX is deprecated on VS2015.

https://blogs.msdn.microsoft.com/chuckw/2015/08/05/where-is-the-directx-sdk-2015-edition/

otherwise make sure you've added the required libraries



and something like this

C++:
#include <d3dx9.h>
#pragma comment(lib, "d3dx9.lib")
Thanks for the info. I will install VS 2013 right away. I've had a feeling D3D9 would be deprecated from VS 2015 since its release was close to Windows 10.
 

mambda

headass
Escobar Tier VIP
Trump Tier Donator
Jun 25, 2014
2,297
37,938
269
Whatever youre building your binary to be, is what you set the architecture to, if x86, then x86, if x64, then x64

you do NOT have to install vs2013 to use d3d9, just a waste of disk space
 

FloppyWhale

Jr.Coder
Full Member
Nobleman
Jan 12, 2015
65
308
0
Whatever youre building your binary to be, is what you set the architecture to, if x86, then x86, if x64, then x64

you do NOT have to install vs2013 to use d3d9, just a waste of disk space
Alrighty, I got passed that part. Now I have 2 errors, which are the same. I have no clue by what it means by "Invalid type conversion"

Here are the 2 functions:
C++:
typedef HRESULT(WINAPI * tReset)(LPDIRECT3DDEVICE9 pDevice, D3DPRESENT_PARAMETERS * pPresentationParametrs);
tReset oReset;

typedef HRESULT(WINAPI * tPresent)(LPDIRECT3DDEVICE9 pDevice, const RECT *pSourceTect, const RECT *pDestRect, HWND hDestWindowOverride, const RGNDATA *pDirtyRegion);
tPresent oPresent;
Then here's where I'm trying to call:
C++:
oReset = (tReset)DetourCreate((PBYTE)vTable[0], (PBYTE)&Reset, 5);
oPresent = (tPresent)DetourCreate((PBYTE)vTable[1], (PBYTE)&Present, 5);
I get the errors on the (tReset) & (tPresent) parts. I have no clue what's wrong with it.
 

FloppyWhale

Jr.Coder
Full Member
Nobleman
Jan 12, 2015
65
308
0
Alrighty, I got passed that part. Now I have 2 errors, which are the same. I have no clue by what it means by "Invalid type conversion"

Here are the 2 functions:
C++:
typedef HRESULT(WINAPI * tReset)(LPDIRECT3DDEVICE9 pDevice, D3DPRESENT_PARAMETERS * pPresentationParametrs);
tReset oReset;

typedef HRESULT(WINAPI * tPresent)(LPDIRECT3DDEVICE9 pDevice, const RECT *pSourceTect, const RECT *pDestRect, HWND hDestWindowOverride, const RGNDATA *pDirtyRegion);
tPresent oPresent;
Then here's where I'm trying to call:
C++:
oReset = (tReset)DetourCreate((PBYTE)vTable[0], (PBYTE)&Reset, 5);
oPresent = (tPresent)DetourCreate((PBYTE)vTable[1], (PBYTE)&Present, 5);
I get the errors on the (tReset) & (tPresent) parts. I have no clue what's wrong with it.
Nevermind. Fixed it. I had the DetourFunction returning the wrong thing. :p
 

Lovelace

Jr.Coder
Full Member
Nobleman
Oct 23, 2015
83
938
5
Nice!

Whatever youre building your binary to be, is what you set the architecture to, if x86, then x86, if x64, then x64

you do NOT have to install vs2013 to use d3d9, just a waste of disk space
Then why didn't it compile on my computer even though I'm sure I had the correct settings and library paths etc.? This is really weird.
 

mambda

headass
Escobar Tier VIP
Trump Tier Donator
Jun 25, 2014
2,297
37,938
269
Nice!



Then why didn't it compile on my computer even though I'm sure I had the correct settings and library paths etc.? This is really weird.
Dunno, you can try again and tell me your errors and i can try to help you out if you want
 

GAFO666

Hacker
Meme Tier VIP
Aug 19, 2012
520
3,188
23
for those which dont want complicated dx9 hook and want easy way:

C++:
LRESULT CALLBACK MsgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	
	return DefWindowProc(hwnd, uMsg, wParam, lParam); 
}

typedef HRESULT(WINAPI* tEndScene)(LPDIRECT3DDEVICE9 pDevice);
tEndScene oEndScene;
DWORD WINAPI HookAndName();
HRESULT WINAPI hkEnd(LPDIRECT3DDEVICE9 pDevice);


DWORD GetDx9VtableFunction(int index)
{
	WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, NULL, NULL, "DX", NULL };
	RegisterClassEx(&wc);
	HWND hWnd = CreateWindow("DX", NULL, WS_OVERLAPPEDWINDOW, 100, 100, 300, 300, GetDesktopWindow(), NULL, wc.hInstance, NULL);
	LPDIRECT3D9 pD3D = Direct3DCreate9(D3D_SDK_VERSION);
	D3DPRESENT_PARAMETERS d3dpp;
	ZeroMemory(&d3dpp, sizeof(d3dpp));
	d3dpp.Windowed = TRUE;
	d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
	d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
	LPDIRECT3DDEVICE9 pd3dDevice;
	pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &pd3dDevice);
	DWORD* pVTable = (DWORD*)pd3dDevice;
	pVTable = (DWORD*)pVTable[0];
	DWORD Foo = pVTable[index];
	DestroyWindow(hWnd);
	//dummyHwnd = hWnd;

	return Foo;
}

DWORD WINAPI HookAndName()
{	
	oEndScene = (tEndScene)DetourFunction((PBYTE)GetDx9VtableFunction(42), (PBYTE)hkEnd);
	return 0xDEADBEEF;
};


HRESULT WINAPI hkEnd(LPDIRECT3DDEVICE9 pDevice)
{
	//do shit in dx9
	return oEndScene(pDevice);
}

edit:
here is a list of vtable functions:
https://www.unkn0wncheats.me/forum/direct3d/66594-d3d9-vtables.html

DIP is on 82 :
C++:
GetDx9VtableFunction(82)
 
Last edited:
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.

Similar threads

Community Mods