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 );
}
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
}
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;
}
}
VOID DrawCircle(int X, int Y, int radius, int numSides, DWORD Color)
{
#define PI 3.14159265358979f
D3DXVECTOR2 Line[128];
float Step = PI * 2.0 / numSides;
int Count = 0;
for (float a=0; a < PI*2.0; a += Step)
{
float X1 = radius * cos(a) + X;
float Y1 = radius * sin(a) + Y;
float X2 = radius * cos(a+Step) + X;
float Y2 = radius * sin(a+Step) + Y;
Line[Count].x = X1;
Line[Count].y = Y1;
Line[Count+1].x = X2;
Line[Count+1].y = Y2;
Count += 2;
}
}
void DrawLine(float x, float y, float x2, float y2, float width, DWORD color)
{
D3DXVECTOR2 vLine[2];
pLine->SetWidth( width );
pLine->SetAntialias( false );
pLine->SetGLLines( true );
vLine[0].x = x;
vLine[0].y = y;
vLine[1].x = x2;
vLine[1].y = y2;
pLine->Begin();
pLine->Draw( vLine, 2, color );
pLine->End();
}
void CrossHair(int Value, D3DCOLOR Color, LPDIRECT3DDEVICE9 pDevice)
{
D3DVIEWPORT9 Viewport;
pDevice->GetViewport(&Viewport);
DWORD ScreenX = Viewport.Width / 2;
DWORD ScreenY = Viewport.Height / 2;
if (Value == 1){
DrawCircle(ScreenX-1,ScreenY-1,8,8,Red);
FillRGB(ScreenX-18, ScreenY-1, 10, 1,Red,pDevice);
FillRGB(ScreenX+8, ScreenY-1, 10, 1,Red,pDevice);
FillRGB(ScreenX-1, ScreenY-18, 1, 10,Red,pDevice);
FillRGB(ScreenX-1, ScreenY+8, 1, 10,Red,pDevice);
FillRGB(ScreenX-1, ScreenY-1, 1, 1, Red, pDevice);
}
if (Value == 2){
DrawCircle(ScreenX,ScreenY,8,8,Red);//circulo
FillRGB(ScreenX-17, ScreenY, 10, 1,Red,pDevice);//Left line
FillRGB(ScreenX+9, ScreenY, 10, 1,Red,pDevice); // Right line
FillRGB(ScreenX, ScreenY-17, 1, 10,Red,pDevice);//Top line
FillRGB(ScreenX, ScreenY+9, 1, 10,Red,pDevice);//Bottom line
}
if (Value == 3){
FillRGB(ScreenX-13, ScreenY, 10, 1,Red,pDevice);//Left line
FillRGB(ScreenX+4, ScreenY, 10, 1,Red,pDevice);//Right line
FillRGB(ScreenX, ScreenY-13, 1, 10,Red,pDevice);//Top line
FillRGB(ScreenX, ScreenY+4, 1, 10,Red,pDevice);//Bottom line
}
if (GetAsyncKeyState(VK_LBUTTON) <0){
DrawCircle(ScreenX-1, ScreenY-1, 22,22,Color);
}
}