Error - Tried alot
So this error is really getting on my nerves:
I've done:
- Installed SDK
- detours
- Directories
Help please? and thanks
---------- Post added at 03:54 PM ---------- Previous post was at 03:16 PM ----------
Help please!
Main.h:
D3D Hook.h:
main.cpp:
I've done:
- Installed SDK
- detours
- Directories
Help please? and thanks

Code:
------ Build started: Project: 181chook, Configuration: Release Win32 ------ Compiling... main.cpp Linking... main.obj : error LNK2001: unresolved external symbol _D3DXCreateFontA@48 main.obj : error LNK2001: unresolved external symbol _Direct3DCreate9@4 C:\Users\Owned\Documents\Visual Studio 2008\Projects\181chook\Release\181chook.dll : fatal error LNK1120: 2 unresolved externals Build log was saved at "file://c:\Users\Owned\Documents\Visual Studio 2008\Projects\181chook\181chook\Release\BuildLog.htm" 181chook - 3 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
---------- Post added at 03:54 PM ---------- Previous post was at 03:16 PM ----------
Help please!
Main.h:
Code:
#include <Windows.h> #include <Windowsx.h> #include <fstream> #include <iostream> #include <shlwapi.h> #include <tlhelp32.h> #include <psapi.h> #include <math.h> #include <vector> #pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") #pragma comment(lib,"d3dx9.lib") #pragma comment(lib,"d3d9.lib") #pragma comment(lib,"user32.lib") #pragma comment(lib, "Psapi.lib") #pragma warning(disable:4244 4996 4018 4305 4005 4245 ) using namespace std; UINT g_uiStride; HMODULE g_hModule;
Code:
#include <d3dx9.h>
#include <detours.h>
#include <Windows.h>
#pragma warning( disable : 4099 4245 )
#pragma comment(lib, "d3dx9.lib")
#pragma comment(lib, "d3d9.lib")
HRESULT WINAPI hkEndScene ( LPDIRECT3DDEVICE9 pDevice );
HRESULT WINAPI hkDrawIndexedPrimitive ( LPDIRECT3DDEVICE9 pDevice, D3DPRIMITIVETYPE PrimType,INT BaseVertexIndex,UINT MinVertexIndex,UINT NumVertices,UINT startIndex,UINT primCount);
HRESULT WINAPI hkSetStreamSource ( LPDIRECT3DDEVICE9 pDevice, UINT StreamNumber, IDirect3DVertexBuffer9* pStreamData, UINT OffsetInBytes, UINT Stride );
HRESULT WINAPI hkReset ( LPDIRECT3DDEVICE9 pDevice, D3DPRESENT_PARAMETERS* pPresentationParameters );
LRESULT CALLBACK d3dMsgProc ( HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam );
DWORD WINAPI d3dHookThread ( LPVOID );
void Created3dWindow ( DWORD* table );
void CreateHookThread ( void );
#define HOOK(func,addy) o##func = (t##func)DetourFunction((PBYTE)addy,(PBYTE)hk##func)
#define ES 0
#define RES 1
#define DIP 2
#define SSS 3
#define VTABLE_AMOUNT 4
typedef HRESULT (WINAPI* tSetStreamSource)(LPDIRECT3DDEVICE9 pDevice,UINT StreamNumber,IDirect3DVertexBuffer9* pStreamData,UINT OffsetInBytes,UINT Stride);
tSetStreamSource oSetStreamSource;
typedef HRESULT (WINAPI* tEndScene)(LPDIRECT3DDEVICE9 pDevice);
tEndScene oEndScene;
typedef HRESULT (WINAPI* tDrawIndexedPrimitive)(LPDIRECT3DDEVICE9 pDevice, D3DPRIMITIVETYPE PrimType,INT BaseVertexIndex,UINT MinVertexIndex,UINT NumVertices,UINT startIndex,UINT primCount);
tDrawIndexedPrimitive oDrawIndexedPrimitive;
typedef HRESULT (WINAPI* tReset)(LPDIRECT3DDEVICE9 pDevice, D3DPRESENT_PARAMETERS* pPresentationParameters);
tReset oReset;
//--//
class C_Hook
{
public:
void Created3dWindow (DWORD* table);
void CreateHookThread(void);
void SetTimeout (void);
DWORD vTable[VTABLE_AMOUNT];
private:
}CHook;
void C_Hook::CreateHookThread ( void )
{
CreateThread(NULL, 0, d3dHookThread, NULL, NULL, 0);
}
void C_Hook::Created3dWindow(DWORD* table)
{
WNDCLASSEX wc = { sizeof( WNDCLASSEX ), CS_CLASSDC, d3dMsgProc, 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 ];
table[ES] = pVTable[42];
table[RES] = pVTable[16];
table[DIP] = pVTable[82];
table[SSS] = pVTable[100];
DestroyWindow( hWnd );
}
LRESULT CALLBACK d3dMsgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
return DefWindowProc(hwnd, Message, wParam, lParam);
}
DWORD WINAPI d3dHookThread(LPVOID)
{
while(GetModuleHandle("d3d9.dll") == NULL)
Sleep(250);
CHook.Created3dWindow(CHook.vTable);
HOOK(EndScene,CHook.vTable[ES]);
HOOK(Reset,CHook.vTable[RES]);
HOOK(DrawIndexedPrimitive,CHook.vTable[DIP]);
HOOK(SetStreamSource,CHook.vTable[SSS]);
return 0;
}
Code:
#include "Main.h"
#include "D3D Hook.h"
HRESULT WINAPI hkEndScene ( LPDIRECT3DDEVICE9 pDevice );
HRESULT WINAPI hkDrawIndexedPrimitive ( LPDIRECT3DDEVICE9 pDevice, D3DPRIMITIVETYPE PrimType,INT BaseVertexIndex,UINT MinVertexIndex,UINT NumVertices,UINT startIndex,UINT primCount);
HRESULT WINAPI hkSetStreamSource ( LPDIRECT3DDEVICE9 pDevice, UINT StreamNumber, IDirect3DVertexBuffer9* pStreamData, UINT OffsetInBytes, UINT Stride );
HRESULT WINAPI hkReset ( LPDIRECT3DDEVICE9 pDevice, D3DPRESENT_PARAMETERS* pPresentationParameters );
BOOL WINAPI DllMain ( HMODULE hModule, DWORD dwReason, LPVOID lpvReserved );
LPD3DXFONT pFont;
void drawString(int x, int y, D3DXCOLOR color, char* szpString, ...)
{
char szResult[1024];
RECT rtFontPosition;
va_list va_alist;
szResult[0] = '\0';
SetRect(&rtFontPosition, x, y, x + 1, y + 1);
va_start(va_alist, szpString);
vsprintf(szResult, szpString, va_alist);
va_end (va_alist);
pFont->DrawText(0, szResult, -1, &rtFontPosition, DT_LEFT | DT_NOCLIP, color);
}
HRESULT WINAPI hkEndScene( LPDIRECT3DDEVICE9 pDevice )
{
__asm nop
if(pFont == NULL)
D3DXCreateFont(pDevice, 14, 0, FW_MEDIUM, 1, 0 ,DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, NONANTIALIASED_QUALITY, DEFAULT_PITCH | FF_SCRIPT, "Consolas", &pFont);
drawString(20, 20 , D3DCOLOR_XRGB(255, 0, 0), "Hello World!");
return oEndScene( pDevice );
}
HRESULT WINAPI hkDrawIndexedPrimitive( LPDIRECT3DDEVICE9 pDevice, D3DPRIMITIVETYPE PrimType,INT BaseVertexIndex,UINT MinVertexIndex,UINT NumVertices,UINT startIndex,UINT primCount)
{
__asm nop
return oDrawIndexedPrimitive( pDevice, PrimType, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount );
}
HRESULT WINAPI hkSetStreamSource( LPDIRECT3DDEVICE9 pDevice,UINT StreamNumber,IDirect3DVertexBuffer9* pStreamData,UINT OffsetInBytes,UINT Stride)
{
__asm nop
if( !StreamNumber )
g_uiStride = Stride;
return oSetStreamSource( pDevice, StreamNumber, pStreamData, OffsetInBytes, Stride );
}
HRESULT WINAPI hkReset( LPDIRECT3DDEVICE9 pDevice, D3DPRESENT_PARAMETERS* pPresentationParameters )
{
if(pFont != NULL)
pFont->OnLostDevice();
HRESULT iReturnValue = oReset(pDevice, pPresentationParameters);
if( iReturnValue == D3D_OK )
{
if(pFont != NULL)
pFont->OnResetDevice();
}
return iReturnValue;
}
BOOL WINAPI DllMain( HMODULE hModule, DWORD dwReason, LPVOID lpvReserved )
{
switch( dwReason )
{
case DLL_PROCESS_ATTACH:
g_hModule = hModule;
DisableThreadLibraryCalls( hModule );
CHook.CreateHookThread();
break;
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}