[Help]Another Compile Error =X

Posts 16–26 of 26 · Page 2 of 2
Still having this problem?
GodHack will help you with this post!
I know I need to lear C++...
Ah, here is my DirectX.cpp and .h

DirectX.cpp

[php]#include "DirectX.h"
#include "Menu.h"

oReset pReset;
oPresent pPresent;

cDirectx Directx;
LPDIRECT3DDEVICE9 g_pDevice = 0;

void refont( LPDIRECT3DDEVICE9 pDevice)
{

if (g_pDevice != pDevice)
{
g_pDevice = pDevice;

try
{
if (Directx.pFont != 0)
Directx.pFont->Release();
} catch (...) {}
Directx.pFont = 0;
D3DXCreateFont(pDevice, 15, 0, 350, 0, 0, DEFAULT_CHARSET, OUT_TT_ONLY_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial", &Directx.pFont );
}

if (g_pDevice != pDevice)
{
g_pDevice = pDevice;
try
{
if (Directx.pFont2 != 0)
Directx.pFont2->Release();
} catch (...) {}
Directx.pFont2 = 0;
D3DXCreateFont(pDevice, 18, 0, 700, 0, 0, DEFAULT_CHARSET, OUT_TT_ONLY_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial Black", &Directx.pFont2 );
}
}

void cDirectx:rawTri(LPDIRECT3DDEVICE9 dev, int x, int y, int w, int h, DWORD Color)
{
D3DRECT BarRect = { x, y, x + w, y + h };
dev->Clear(1, &BarRect, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, Color, 0, 0);
}

void cDirectx:rawString(int x, int y, DWORD color, LPD3DXFONT g_pFont, const char *fmt, ...)
{
RECT FontPos = { x, y, x + 120, y + 16 };
char buf[1024] = {'\0'};
va_list va_alist;

va_start(va_alist, fmt);
vsprintf_s(buf, fmt, va_alist);
va_end(va_alist);

g_pFont->DrawText(NULL, buf, -1, &FontPos, DT_NOCLIP, color);
}


//Credits to Azorbix i think
HRESULT cDirectx::GenerateTexture(IDirect3DDevice9 *pD3Ddev, IDirect3DTexture9 **ppD3Dtex, DWORD colour32)
{
if( FAILED(pD3Ddev->CreateTexture(8, 8, 1, 0, D3DFMT_A4R4G4B4, D3DPOOL_MANAGED, ppD3Dtex,NULL)) )
return E_FAIL;

WORD colour16 = ((WORD)((colour32>>28)&0xF)<<12)
|(WORD)(((colour32>>20)&0xF)<<8)
|(WORD)(((colour32>>12)&0xF)<<4)
|(WORD)(((colour32>>4)&0xF)<<0);

D3DLOCKED_RECT d3dlr;
(*ppD3Dtex)->LockRect(0, &d3dlr, 0, 0);
WORD *pDst16 = (WORD*)d3dlr.pBits;

for(int xy=0; xy < 8*8; xy++)
*pDst16++ = colour16;

(*ppD3Dtex)->UnlockRect(0);

return S_OK;
}

HRESULT WINAPI gellReset(LPDIRECT3DDEVICE9 pDevice, D3DPRESENT_PARAMETERS* pPresentationParameters )
{
Sprite->OnLostDevice();
Directx.pFont->OnLostDevice();
Directx.pFont2->OnLostDevice();

HRESULT hRet = pReset(pDevice, pPresentationParameters);

Sprite->OnResetDevice();
Directx.pFont->OnResetDevice();
Directx.pFont2->OnResetDevice();

return hRet;
}

HRESULT WINAPI gellPresent(LPDIRECT3DDEVICE9 pDevice, CONST RECT *pSourceRect, CONST RECT *pDestRect, HWND hDestWindowOverride, CONST RGNDATA *pDirtyRegion)
{
Base.RenderFrame(pDevice);

return pPresent(pDevice, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
}

void cDirectx::Hook(void)
{
DWORD Reset = Base.GetPointer(16);
DWORD Present = Base.GetPointer(17);

pReset = (oReset) DetourCreate(( BYTE* )Reset, ( BYTE* )gellReset );
pPresent = (oPresent) DetourCreate(( BYTE* )Present, ( BYTE* )gellPresent );
}
[/php]

DirectX.h

[php]#ifndef __DIRECTX_H__
#define __DIRECTX_H__

#pragma once

#include "Files.h"

typedef HRESULT ( WINAPI* oPresent ) ( LPDIRECT3DDEVICE9 pDevice, CONST RECT *pSourceRect, CONST RECT *pDestRect, HWND hDestWindowOverride, CONST RGNDATA *pDirtyRegion);
typedef HRESULT ( WINAPI* oReset )( LPDIRECT3DDEVICE9 pDevice, D3DPRESENT_PARAMETERS* pPresentationParameters );

class cDirectx{
public:
LPD3DXFONT pFont;
LPD3DXFONT pFont2;
void Hook(void);
void DrawTri(LPDIRECT3DDEVICE9 dev, int x, int y, int w, int h, DWORD Color);
void DrawString(int x, int y, DWORD color, LPD3DXFONT g_pFont, const char *fmt, ...);
HRESULT GenerateTexture(IDirect3DDevice9 *pD3Ddev, IDirect3DTexture9 **ppD3Dtex, DWORD colour32);

};

extern cDirectx Directx;

#endif

[/php]
Quote Originally Posted by CanYouDoIt View Post
I know I need to lear C++...
Ah, here is my DirectX.cpp and .h

DirectX.cpp

[php]#include "DirectX.h"
#include "Menu.h"

oReset pReset;
oPresent pPresent;

cDirectx Directx;
LPDIRECT3DDEVICE9 g_pDevice = 0;

void refont( LPDIRECT3DDEVICE9 pDevice)
{

if (g_pDevice != pDevice)
{
g_pDevice = pDevice;

try
{
if (Directx.pFont != 0)
Directx.pFont->Release();
} catch (...) {}
Directx.pFont = 0;
D3DXCreateFont(pDevice, 15, 0, 350, 0, 0, DEFAULT_CHARSET, OUT_TT_ONLY_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial", &Directx.pFont );
}

if (g_pDevice != pDevice)
{
g_pDevice = pDevice;
try
{
if (Directx.pFont2 != 0)
Directx.pFont2->Release();
} catch (...) {}
Directx.pFont2 = 0;
D3DXCreateFont(pDevice, 18, 0, 700, 0, 0, DEFAULT_CHARSET, OUT_TT_ONLY_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial Black", &Directx.pFont2 );
}
}

void cDirectx:rawTri(LPDIRECT3DDEVICE9 dev, int x, int y, int w, int h, DWORD Color)
{
D3DRECT BarRect = { x, y, x + w, y + h };
dev->Clear(1, &BarRect, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, Color, 0, 0);
}

void cDirectx:rawString(int x, int y, DWORD color, LPD3DXFONT g_pFont, const char *fmt, ...)
{
RECT FontPos = { x, y, x + 120, y + 16 };
char buf[1024] = {'\0'};
va_list va_alist;

va_start(va_alist, fmt);
vsprintf_s(buf, fmt, va_alist);
va_end(va_alist);

g_pFont->DrawText(NULL, buf, -1, &FontPos, DT_NOCLIP, color);
}


//Credits to Azorbix i think
HRESULT cDirectx::GenerateTexture(IDirect3DDevice9 *pD3Ddev, IDirect3DTexture9 **ppD3Dtex, DWORD colour32)
{
if( FAILED(pD3Ddev->CreateTexture(8, 8, 1, 0, D3DFMT_A4R4G4B4, D3DPOOL_MANAGED, ppD3Dtex,NULL)) )
return E_FAIL;

WORD colour16 = ((WORD)((colour32>>28)&0xF)<<12)
|(WORD)(((colour32>>20)&0xF)<<8)
|(WORD)(((colour32>>12)&0xF)<<4)
|(WORD)(((colour32>>4)&0xF)<<0);

D3DLOCKED_RECT d3dlr;
(*ppD3Dtex)->LockRect(0, &d3dlr, 0, 0);
WORD *pDst16 = (WORD*)d3dlr.pBits;

for(int xy=0; xy < 8*8; xy++)
*pDst16++ = colour16;

(*ppD3Dtex)->UnlockRect(0);

return S_OK;
}

HRESULT WINAPI gellReset(LPDIRECT3DDEVICE9 pDevice, D3DPRESENT_PARAMETERS* pPresentationParameters )
{
Sprite->OnLostDevice();
Directx.pFont->OnLostDevice();
Directx.pFont2->OnLostDevice();

HRESULT hRet = pReset(pDevice, pPresentationParameters);

Sprite->OnResetDevice();
Directx.pFont->OnResetDevice();
Directx.pFont2->OnResetDevice();

return hRet;
}

HRESULT WINAPI gellPresent(LPDIRECT3DDEVICE9 pDevice, CONST RECT *pSourceRect, CONST RECT *pDestRect, HWND hDestWindowOverride, CONST RGNDATA *pDirtyRegion)
{
Base.RenderFrame(pDevice);

return pPresent(pDevice, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
}

void cDirectx::Hook(void)
{
DWORD Reset = Base.GetPointer(16);
DWORD Present = Base.GetPointer(17);

pReset = (oReset) DetourCreate(( BYTE* )Reset, ( BYTE* )gellReset );
pPresent = (oPresent) DetourCreate(( BYTE* )Present, ( BYTE* )gellPresent );
}
[/php]

DirectX.h

[php]#ifndef __DIRECTX_H__
#define __DIRECTX_H__

#pragma once

#include "Files.h"

typedef HRESULT ( WINAPI* oPresent ) ( LPDIRECT3DDEVICE9 pDevice, CONST RECT *pSourceRect, CONST RECT *pDestRect, HWND hDestWindowOverride, CONST RGNDATA *pDirtyRegion);
typedef HRESULT ( WINAPI* oReset )( LPDIRECT3DDEVICE9 pDevice, D3DPRESENT_PARAMETERS* pPresentationParameters );

class cDirectx{
public:
LPD3DXFONT pFont;
LPD3DXFONT pFont2;
void Hook(void);
void DrawTri(LPDIRECT3DDEVICE9 dev, int x, int y, int w, int h, DWORD Color);
void DrawString(int x, int y, DWORD color, LPD3DXFONT g_pFont, const char *fmt, ...);
HRESULT GenerateTexture(IDirect3DDevice9 *pD3Ddev, IDirect3DTexture9 **ppD3Dtex, DWORD colour32);

};

extern cDirectx Directx;

#endif

[/php]
i think he have only the base , not the source with everything !
Quote Originally Posted by CanYouDoIt View Post
I know I need to lear C++...
Ah, here is my DirectX.cpp and .h

DirectX.cpp

[php]#include "DirectX.h"
#include "Menu.h"

oReset pReset;
oPresent pPresent;

cDirectx Directx;
LPDIRECT3DDEVICE9 g_pDevice = 0;

void refont( LPDIRECT3DDEVICE9 pDevice)
{

if (g_pDevice != pDevice)
{
g_pDevice = pDevice;

try
{
if (Directx.pFont != 0)
Directx.pFont->Release();
} catch (...) {}
Directx.pFont = 0;
D3DXCreateFont(pDevice, 15, 0, 350, 0, 0, DEFAULT_CHARSET, OUT_TT_ONLY_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial", &Directx.pFont );
}

if (g_pDevice != pDevice)
{
g_pDevice = pDevice;
try
{
if (Directx.pFont2 != 0)
Directx.pFont2->Release();
} catch (...) {}
Directx.pFont2 = 0;
D3DXCreateFont(pDevice, 18, 0, 700, 0, 0, DEFAULT_CHARSET, OUT_TT_ONLY_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial Black", &Directx.pFont2 );
}
}

void cDirectx:rawTri(LPDIRECT3DDEVICE9 dev, int x, int y, int w, int h, DWORD Color)
{
D3DRECT BarRect = { x, y, x + w, y + h };
dev->Clear(1, &BarRect, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, Color, 0, 0);
}

void cDirectx:rawString(int x, int y, DWORD color, LPD3DXFONT g_pFont, const char *fmt, ...)
{
RECT FontPos = { x, y, x + 120, y + 16 };
char buf[1024] = {'\0'};
va_list va_alist;

va_start(va_alist, fmt);
vsprintf_s(buf, fmt, va_alist);
va_end(va_alist);

g_pFont->DrawText(NULL, buf, -1, &FontPos, DT_NOCLIP, color);
}


//Credits to Azorbix i think
HRESULT cDirectx::GenerateTexture(IDirect3DDevice9 *pD3Ddev, IDirect3DTexture9 **ppD3Dtex, DWORD colour32)
{
if( FAILED(pD3Ddev->CreateTexture(8, 8, 1, 0, D3DFMT_A4R4G4B4, D3DPOOL_MANAGED, ppD3Dtex,NULL)) )
return E_FAIL;

WORD colour16 = ((WORD)((colour32>>28)&0xF)<<12)
|(WORD)(((colour32>>20)&0xF)<<8)
|(WORD)(((colour32>>12)&0xF)<<4)
|(WORD)(((colour32>>4)&0xF)<<0);

D3DLOCKED_RECT d3dlr;
(*ppD3Dtex)->LockRect(0, &d3dlr, 0, 0);
WORD *pDst16 = (WORD*)d3dlr.pBits;

for(int xy=0; xy < 8*8; xy++)
*pDst16++ = colour16;

(*ppD3Dtex)->UnlockRect(0);

return S_OK;
}

HRESULT WINAPI gellReset(LPDIRECT3DDEVICE9 pDevice, D3DPRESENT_PARAMETERS* pPresentationParameters )
{
Sprite->OnLostDevice();
Directx.pFont->OnLostDevice();
Directx.pFont2->OnLostDevice();

HRESULT hRet = pReset(pDevice, pPresentationParameters);

Sprite->OnResetDevice();
Directx.pFont->OnResetDevice();
Directx.pFont2->OnResetDevice();

return hRet;
}

HRESULT WINAPI gellPresent(LPDIRECT3DDEVICE9 pDevice, CONST RECT *pSourceRect, CONST RECT *pDestRect, HWND hDestWindowOverride, CONST RGNDATA *pDirtyRegion)
{
Base.RenderFrame(pDevice);

return pPresent(pDevice, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
}

void cDirectx::Hook(void)
{
DWORD Reset = Base.GetPointer(16);
DWORD Present = Base.GetPointer(17);

pReset = (oReset) DetourCreate(( BYTE* )Reset, ( BYTE* )gellReset );
pPresent = (oPresent) DetourCreate(( BYTE* )Present, ( BYTE* )gellPresent );
}
[/php]

DirectX.h

[php]#ifndef __DIRECTX_H__
#define __DIRECTX_H__

#pragma once

#include "Files.h"

typedef HRESULT ( WINAPI* oPresent ) ( LPDIRECT3DDEVICE9 pDevice, CONST RECT *pSourceRect, CONST RECT *pDestRect, HWND hDestWindowOverride, CONST RGNDATA *pDirtyRegion);
typedef HRESULT ( WINAPI* oReset )( LPDIRECT3DDEVICE9 pDevice, D3DPRESENT_PARAMETERS* pPresentationParameters );

class cDirectx{
public:
LPD3DXFONT pFont;
LPD3DXFONT pFont2;
void Hook(void);
void DrawTri(LPDIRECT3DDEVICE9 dev, int x, int y, int w, int h, DWORD Color);
void DrawString(int x, int y, DWORD color, LPD3DXFONT g_pFont, const char *fmt, ...);
HRESULT GenerateTexture(IDirect3DDevice9 *pD3Ddev, IDirect3DTexture9 **ppD3Dtex, DWORD colour32);

};

extern cDirectx Directx;

#endif

[/php]
you don't even have the function DetourCreate O.o
Quote Originally Posted by GodHack2 View Post
you don't even have the function DetourCreate O.o
I'll need to create this function?

/Fuck.
Quote Originally Posted by CanYouDoIt View Post
I'll need to create this function?

/Fuck.
you should probably learn the basics first b4 going into "game hacking"
because if you didn't have that function your error will be DetourCreate is undefined
so you do have that function but you just miss placed it
Learn what your doing
Well, my english isn't good to read english books of C++.
The brazilian books are totally the same thing, show how you create "Hello Word", and explain the functions of this "command".
And i search for VC++ books, and i failed.
So, I can't study by the internet.
did you read my post? i said you dont have the function detourcreate in your project. you may have somewhere "extern void* DetourCreate(...)" and thats why it causing the linker error (you told the compiler the function exists, but it doesnt). otherwise the compiler would say the function doesnt exist.

seriously, stop coding
Quote Originally Posted by Gordon` View Post
did you read my post? i said you dont have the function detourcreate in your project. you may have somewhere "extern void* DetourCreate(...)" and thats why it causing the linker error (you told the compiler the function exists, but it doesnt). otherwise the compiler would say the function doesnt exist.

seriously, stop coding
/facepalm

Lol This site is awesome
Lol just add this to Detours.h :
[php]void *DetourCreate(BYTE *src, const BYTE *dst, const int minlen=0);[/php]

And This To Detours.cpp :
[php]void *DetourCreate(BYTE *src, const BYTE *dst, int minlen)
{
BYTE *jmp, *org;
DWORD dwBack;
int len;

len=DetourASMlen(src,(minlen<6)?6:minlen);
if (len==0 && minlen>=6) len=minlen;
if (len==0) return 0;

org=jmp = (BYTE*)malloc(len+5+1); // room for nobytes + jmplen + size byte
jmp[0]=len; // save length in first byte
jmp++;

VirtualProtect(src, len, PAGE_EXECUTE_READWRITE, &dwBack);
memcpy(jmp, src, len);
jmp += len;
jmp[0] = 0xE9;
*(DWORD*)(jmp+1) = (DWORD)(src+len - jmp) - 5;

src[0] = 0x68; // different hook, push address ret
*(DWORD*)(src+1) = (DWORD)(dst);
src[5] = 0xc3;
for (int i=6; i<len; i++) src[i] = 0x90;
VirtualProtect(src, len, dwBack, &dwBack);

return &org[1]; // return entry point, byte 0 = length
}[/php]

100% Works .. So simple error 2 fix ..
Posts 16–26 of 26 · Page 2 of 2

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us