I decided to make myself a "cool" crosshair.)))))
and for one to learn to draw in D3D.
I drawed this.
Code:
void CrossHair1(LPDIRECT3DDEVICE9 pDevice, int size, int strong, D3DCOLOR xcolor)
{
int iCenterX = GetSystemMetrics( 0 ) / 2;
int iCenterY = GetSystemMetrics( 1 ) / 2;
if( iCenterX < 20 && iCenterY < 20 )
{
iCenterX = ( GetSystemMetrics( 1 ) / 2 );
iCenterY = ( GetSystemMetrics( 0 ) / 2 );
}
D3DRECT rec1 = { iCenterX- size, iCenterY - 1, iCenterX+ size -1 , iCenterY+ strong };
D3DRECT rec2 = { iCenterX -1, iCenterY- size, iCenterX+ strong ,iCenterY+ size -1 };
pDevice->Clear(1, &rec1, D3DCLEAR_TARGET, xcolor, 1000, 0);
pDevice->Clear(1, &rec2, D3DCLEAR_TARGET, xcolor, 100, 0);
}
void CrossHair2(LPDIRECT3DDEVICE9 pDevice, int size, int strong, D3DCOLOR xcolor)
{
int iCenterX = GetSystemMetrics( 0 ) / 2;
int iCenterY = GetSystemMetrics( 1 ) / 2;
if( iCenterX < 20 && iCenterY < 20 )
{
iCenterX = ( GetSystemMetrics( 1 ) / 2 );
iCenterY = ( GetSystemMetrics( 0 ) / 2 );
}
D3DRECT rec5 = {iCenterX-3, iCenterY - 2, iCenterX+ 3-1, iCenterY+1};
D3DRECT rec6 = {iCenterX - 2, iCenterY-3, iCenterX+ 1,iCenterY+3-1};
pDevice->Clear( 1, &rec5, D3DCLEAR_TARGET, xcolor, 0, 0 );
pDevice->Clear( 1, &rec6, D3DCLEAR_TARGET, xcolor, 0, 0 );
}
Works fine in the game.
But when I draw this:
Code:
void CrossHair4(int x, int y, LPDIRECT3DDEVICE9 pDevice)
{
DrawCircle(x, y, 8, 8, Red);//Circle
FillRGB(x-17, y, 10, 1,Red,pDevice);//Left line
FillRGB(x+9, y, 10, 1,Red,pDevice); // Right line
FillRGB(x, y - 17, 1, 10,Red,pDevice);//Top line
FillRGB(x, y + 9, 1, 10,Red,pDevice);//Bottom line
}
My Game is crashed. why?
I have two Hooks:
1. for menu
2. for wallhack
Code:
DWORD WINAPI Hook(LPVOID lpArgs)
{
DWORD dwD3D9 = 0;
while(!dwD3D9) {
Sleep(100);
dwD3D9 = (DWORD)GetModuleHandleA("d3d9.dll");
}
DWORD dwVTable[2] = { 0 };
CreateDevice(dwVTable);
oReset = (tReset) DetourCreate((PBYTE) dwVTable[0], (PBYTE) &hkReset, 5);
oPresent = (tPresent)DetourCreate((PBYTE) dwVTable[1], (PBYTE) &hkPresent, 5);
return FALSE;
}
void D3D_Hook()
{
switch(GAME)
{
case Game::CombatArms:
{
DWORD dwVTable[2] = { 0 };
DWORD *vtbl;
DWORD hD3D=0;
do {
hD3D = (DWORD)GetModuleHandleA("d3d9.dll");
Sleep(10);
}
while(!hD3D);
DWORD adr = FindPattern(hD3D, 0x128000, (PBYTE)"\xC7\x06\x00\x00\x00\x00\x89\x86\x00\x00\x00\x00\x89\x86", "xx????xx????xx");
if(adr)
{
memcpy(&vtbl,(void *)(adr+2),4);
nomar = vtbl[152] + 5;
pDrawIndexedPrimitive = (DrawIndexedPrimitive_)DetourCreate((PBYTE)(vtbl[152]),(PBYTE)MyDIP_CA,5);
return;
}
}
break;
break;
}
}
Explain what the problem is. Please)))