OldSchoolHack

Register / Login English

H4x BFP4f Fixed


icon H4x BFP4f Fixed #1

Join Date: Aug 2007

Posts: 8643

User-Rating:

199 positive
33 negative
5$Hack Source - Looked through it to find what i needed to do(did not use any functions)
Revolty - His base gave me inspiration
rzBase - Some functions
5$Base for p4f - Base
Jugga - Classes
some other people(i forgot)
Me(boboben1) - Adding features to 5$Base for p4f.

Features:

Name Esp
Health Esp
Distance Esp

Sourcecode:
CPP Code:
  1. /**********************Battlefield Play4Free************************/
  2. /*************************Working Base******************************/
  3. /**************************12/14/2010*******************************/
  4. /*Credits to: zoomgod, Strife, Winslow, GetModuleHandle, Freaky123**/
  5. /***Patrick, R4z8r, learn_more, doobie, KozmoK, Sparten, smoochy,***/
  6. /**********************Jugga, Vossy, freitag************************/
  7.  
  8. /****************Creator of this base: 5$andimyours*****************/
  9.  
  10. /* This is a UC-Forum-ONLY public release.
  11. /* Please do not discuss or share this outside of the UnKnoWnCheaTs forum.
  12. /* This information or any part of it may only be distributed outside of
  13. /* UnKnoWnCheaTs forum in binary/compiled form.
  14. /* Please credit all of the above UC-Forum members for this information.
  15. /*
  16. /* This information is distributed in the hope that it will be useful,
  17. /* but WITHOUT ANY WARRANTY, without even the implied warranty of
  18. /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */
  19.  
  20.  
  21. #include "BFP4F_Classes.h"
  22. #include "Functions.h"
  23. #include <Tlhelp32.h>
  24. bool lon = false;
  25. HMODULE hmRendDx9Base = NULL;
  26. DWORD dwInitDllBase = NULL;
  27. #define IsPlayerValid(p) ( (p) && (p->Alive) && (p->Soldier) && (p->Soldier->soldier_ptr) /*&& (p->SoldierObj->soldier_ptr->Matrix)*/ )
  28. bool Initialized = false;
  29. LPDIRECT3DDEVICE9 pDevice;
  30. D3DVIEWPORT9 Viewport;
  31. bool Fire = false;
  32. void SetMyCursorPos(FLOAT PosX, FLOAT PosY)
  33. {
  34. //Credits: Razor
  35. FLOAT ScreenX = (float)Viewport.Width/2;
  36. FLOAT ScreenY = (float)Viewport.Height/2;
  37. //PosX -= ScreenX;
  38. //PosY -= ScreenY;
  39.  
  40. mouse_event( 0x1, PosX, PosY, NULL, NULL );
  41. }
  42. ID3DXFont *pFont;
  43. #define dWhite D3DCOLOR_RGBA(255, 255, 255, 255)
  44. #define dRed D3DCOLOR_RGBA(255, 000, 000, 255)
  45. #define dGreen D3DCOLOR_RGBA(000, 255, 000, 255)
  46. #define dBlue D3DCOLOR_RGBA(000, 000, 255, 255)
  47. #define dBlack D3DCOLOR_RGBA(128, 128, 128, 255)
  48. #define dPurple D3DCOLOR_RGBA(125, 000, 255, 255)
  49. #define dGrey D3DCOLOR_RGBA(128, 128, 128, 255)
  50. #define dYellow D3DCOLOR_RGBA(255, 255, 000, 255)
  51. #define dOrange D3DCOLOR_RGBA(255, 125, 000, 255)
  52. CClassManager* pClassManager;
  53. CRenderer* pRenderer;
  54. CPlayerManager* pPlayerManager;
  55. CPlayer* pLocalPlayer;
  56. CInputManager* pInputManager;
  57. CActionBuffer* pActionBuffer;
  58. DWORD oActionBuffer = 0;
  59. CObjectManager* pObjectManager;
  60. CDebugTextWriter* pDebugTextWriter;
  61. DWORD dwWorldToScreen;
  62. #define PATT_CLASSMANAGER "\x89\x35\x99\x99\x99\x99\xFF\x15\x99\x99\x99\x99\x8B\x0D\x99\x99\x99\x99\x8B\x01"
  63. #define MASK_CLASSMANAGER "xx????xx????xx????xx"
  64. float actionBuffer[64] = {0};
  65. void wtoc(CHAR*, const WCHAR*);
  66. DWORD GetModuleSize(LPSTR strModuleName)
  67. {
  68. MODULEENTRY32 lpme= {0};
  69. DWORD dwSize=0;
  70. DWORD PID=GetCurrentProcessId();
  71. BOOL isMod=0;
  72. char chModName[256];
  73.  
  74. strcpy(chModName,strModuleName);
  75. _strlwr(chModName);
  76.  
  77. HANDLE hSnapshotModule=CreateToolhelp32Snapshot(TH32CS_SNAPMODULE ,PID);
  78. if (hSnapshotModule)
  79. {
  80. lpme.dwSize=sizeof(lpme);
  81. isMod=Module32First(hSnapshotModule,&lpme);
  82. while(isMod)
  83. {
  84. char wtocI[256] = {0};
  85. wtoc(wtocI,lpme.szExePath);
  86. if (strcmp(_strlwr(wtocI),chModName))
  87. {
  88. dwSize=(DWORD)lpme.modBaseSize;
  89. CloseHandle(hSnapshotModule);
  90. return dwSize;
  91. }
  92. isMod=Module32Next(hSnapshotModule,&lpme);
  93. }
  94. }
  95. CloseHandle(hSnapshotModule);
  96.  
  97. return 0;
  98. }
  99.  
  100. __declspec( naked ) bool WINAPI bWorldToScreen( D3DXVECTOR3* pVecInOut )
  101. {
  102. _asm mov ecx, pDebugTextWriter;
  103. _asm jmp [ dwWorldToScreen ];
  104. }
  105.  
  106. #define SmoPat "\x81\xEC\x00\x00\x00\x00\xD9\xEE\x8B\x0D\x00\x00\x00\x00\x8B\x01\xD9\x54\x24\x04\x8B\x50\x6C\xD9\x54\x24\x08\x56"
  107. #define SmoMask "xx????xxxx????xxxxxxxxxxxxxx"
  108.  
  109. DWORD FindPattern(DWORD, DWORD, BYTE*, char*);
  110.  
  111. bool FindMyWorldToScreen()
  112. {
  113. DWORD dwRendererBase = (DWORD)GetModuleHandle( L"RendDx9.dll" );
  114. //MessageBox(0,L"Before.",L"Victory",0);
  115. DWORD dwRendererSize = GetModuleSize("RendDx9.dll");
  116. //MessageBox(0,L"After.",L"Victory",0);
  117. dwWorldToScreen = FindPattern( dwRendererBase,dwRendererSize,(PBYTE)SmoPat, SmoMask );
  118.  
  119. if(!dwWorldToScreen)
  120. return false;
  121.  
  122. return true;
  123. }
  124.  
  125. DWORD FindPattern(DWORD start_offset, DWORD size, BYTE* pattern, char mask[] )
  126. {
  127. DWORD pos = 0;
  128. int searchLen = strlen(mask) - 1;
  129.  
  130. for( DWORD retAddress = start_offset; retAddress < start_offset + size; retAddress++ )
  131. {
  132. if( *(BYTE*)retAddress == pattern[pos] || mask[pos] == '?' ){
  133. if( mask[pos+1] == '\0' )
  134. return (retAddress - searchLen);
  135. pos++;
  136. }
  137. else
  138. pos = 0;
  139. }
  140. return NULL;
  141. }
  142. /*CActionBuffer* _stdcall hkActionBuffer()
  143. {
  144. //MessageBox(0,L"F***PB",0,0);
  145. _asm call oActionBuffer;
  146. _asm mov pActionBuffer, eax;
  147.  
  148. _asm pushad;
  149.  
  150. if( pActionBuffer )
  151. {
  152. for ( int i = 0; i < 64; i++ )
  153. {
  154. pActionBuffer->inputKeys[ i ] += actionBuffer[ i ];
  155.  
  156. //actionBuffer[ i ] = 0.0f;
  157. if (GetAsyncKeyState(VK_UP) || (GetAsyncKeyState(VK_UP) && GetAsyncKeyState(0x41)) || (GetAsyncKeyState(VK_UP) && GetAsyncKeyState(0x53)))
  158. {
  159. pActionBuffer->inputKeys[3] = 99999.0f;
  160. }
  161. }
  162. }
  163. _asm popad;
  164. return pActionBuffer;
  165. }//*/
  166.  
  167. CActionBuffer* hkActionBuffer()
  168. {
  169. __asm call oActionBuffer;
  170. __asm mov pActionBuffer, eax;
  171. __asm pushad;
  172.  
  173. if(pActionBuffer)
  174. {
  175. for(int i = 0; i < 255; i ++)
  176. {
  177. pActionBuffer->inputKeys[i] += actionBuffer[i];
  178. actionBuffer[i] = 0.0f;
  179. }
  180. }
  181.  
  182. __asm popad;
  183. return pActionBuffer;
  184. }
  185. int zoomhack = 1;
  186. void HackRoutine()
  187. {
  188. //if (GetAsyncKeyState(VK_NUMPAD1))
  189. // lon = !lon;
  190. //if (Fire)
  191. ///{
  192. // mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
  193. // Sleep(25);
  194. // mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
  195. // Fire = false;
  196. //}
  197. if (GetAsyncKeyState(VK_ADD)&1)
  198. {
  199. zoomhack += 1;
  200. }
  201. else if (GetAsyncKeyState(VK_SUBTRACT)&1)
  202. {
  203. zoomhack -= 1;
  204. }
  205. }
  206.  
  207. DWORD WINAPI HookFunctions(LPVOID)
  208. {
  209. while (hmRendDx9Base==NULL)
  210. {
  211. hmRendDx9Base = GetModuleHandle(L"RendDx9.dll");
  212. if (hmRendDx9Base == NULL) Sleep(200);
  213. }
  214.  
  215. while(dwInitDllBase == NULL)
  216. {
  217. dwInitDllBase = (DWORD)GetProcAddress(hmRendDx9Base, "initDll");
  218. if (dwInitDllBase == NULL) Sleep(200);
  219. }
  220. CloseHandle(hmRendDx9Base);
  221.  
  222. DWORD dwPointerOffset = FindPattern(dwInitDllBase, dwInitDllBase + 512, (BYTE*)PATT_CLASSMANAGER, MASK_CLASSMANAGER);
  223.  
  224. DWORD* dwPointerOffset2 = (DWORD*)(dwPointerOffset + 2);
  225.  
  226. pClassManager = *((CClassManager**)((DWORD)*dwPointerOffset2));
  227.  
  228. while(pRenderer == NULL)
  229. pRenderer = (CRenderer *)pClassManager->GetClassPointerByName(&string("Renderer"));
  230.  
  231. while(!pPlayerManager)
  232. pPlayerManager = (CPlayerManager*)pClassManager->GetClassPointerByName( &string("PlayerManager") );
  233. //MessageBoxW(0,L"Woot!",L"Victory",0);
  234. while(!pInputManager)
  235. pInputManager = (CInputManager*)pClassManager->GetClassPointerByName( &string("InputManager") );
  236. while(!pObjectManager)
  237. pObjectManager = (CObjectManager*)pClassManager->GetClassPointerByName( &string("ObjectManager") );
  238. while(!pDebugTextWriter)
  239. pDebugTextWriter = (CDebugTextWriter*) pClassManager->GetClassPointerByName( &string("DebugTextWriter") );
  240. while(!FindMyWorldToScreen())
  241. Sleep(100);
  242. //MessageBoxW(0,L"Woot2!",L"Victory",0);
  243. //oActionBuffer = (DWORD)HookVTableFunction((DWORD**)pInputManager,(PBYTE)&hkActionBuffer,13);
  244. MessageBoxW(0,L"Woot!",L"Victory",0);
  245. //MessageBoxW(0,L"Woot23!",L"Victory",0);
  246. while(1)
  247. {
  248. HackRoutine();
  249. Sleep(2);
  250. }
  251.  
  252. return 0;
  253. }
  254.  
  255.  
  256. typedef HRESULT (WINAPI* tEndScene)(LPDIRECT3DDEVICE9 pDevice);
  257. tEndScene oEndScene;
  258.  
  259. void Initialize(LPDIRECT3DDEVICE9 pDevice)
  260. {
  261. D3DXCreateFont( pDevice, 10, 0, FW_THIN, 1, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, ANTIALIASED_QUALITY, DEFAULT_PITCH | FF_DONTCARE, L"Lucida Console", &pFont);
  262. Initialized = true;
  263. }
  264. int GetTextLength ( char *szString, ... )
  265. {
  266. char szText[512];
  267. memset(szText,0,512);
  268. strcpy(szText,szString);
  269. unsigned int i = 0, iStrLen = 0;
  270. while (i < strlen(szText))
  271. {
  272. switch(szText[i])
  273. {
  274. case ' ':
  275. iStrLen += 4;
  276. break;
  277. case 'e':
  278. iStrLen += 6;
  279. break;
  280. case 'i':
  281. iStrLen += 2;
  282. break;
  283. case 'j':
  284. iStrLen += 3;
  285. break;
  286. case 'k':
  287. iStrLen += 6;
  288. break;
  289. case 'l':
  290. iStrLen += 2;
  291. break;
  292. case 'm':
  293. iStrLen += 10;
  294. break;
  295. case 'r':
  296. iStrLen += 4;
  297. case 'v':
  298. iStrLen += 7;
  299. break;
  300. case 'w':
  301. iStrLen += 9;
  302. break;
  303. case 'y':
  304. iStrLen += 7;
  305. break;
  306. case 'A':
  307. iStrLen += 7;
  308. break;
  309. case 'C':
  310. iStrLen += 7;
  311. break;
  312. case 'H':
  313. iStrLen += 7;
  314. break;
  315. case 'I':
  316. iStrLen += 2;
  317. break;
  318. case 'K':
  319. iStrLen += 7;
  320. break;
  321. case 'M':
  322. iStrLen += 9;
  323. break;
  324. case 'O':
  325. iStrLen += 7;
  326. break;
  327. case 'P':
  328. iStrLen += 7;
  329. break;
  330. case 'Q':
  331. iStrLen += 7;
  332. break;
  333. case 'R':
  334. iStrLen += 6;
  335. break;
  336. case 'V':
  337. iStrLen += 7;
  338. break;
  339. case 'W':
  340. iStrLen += 11;
  341. break;
  342. case 'X':
  343. iStrLen += 8;
  344. break;
  345. case 'Y':
  346. iStrLen += 7;
  347. break;
  348. default:
  349. iStrLen += 5;
  350. break;
  351. }
  352. i++;
  353. }
  354. return iStrLen;
  355. }
  356. void wtoc(CHAR* Dest, const WCHAR* Source)
  357. {
  358. int i = 0;
  359.  
  360. while(Source[i] != '\0')
  361. {
  362. Dest[i] = (CHAR)Source[i];
  363. ++i;
  364. }
  365. }
  366.  
  367. //=====================================================================================
  368. /*
  369. || ::DESCRIPTION::
  370. || This function will convert a CHAR string to a WCHAR string.
  371. ||
  372. || Param 1 :: Pointer to a buffer that will contain the converted string. Ensure this
  373. || buffer is large enough; if not, buffer overrun errors will occur.
  374. || Param 2 :: Constant pointer to a source CHAR string to be converted to WCHAR
  375. */
  376. void ctow(WCHAR* Dest, const CHAR* Source)
  377. {
  378. int i = 0;
  379.  
  380. while(Source[i] != '\0')
  381. {
  382. Dest[i] = (WCHAR)Source[i];
  383. ++i;
  384. }
  385. }
  386. void fillrgba( int x, int y, int w, int h, int r, int g,int b,int a)
  387. {
  388.  
  389. D3DRECT rec = { x, y, x + w, y + h };
  390. pDevice->Clear( 1, &rec, D3DCLEAR_TARGET, D3DCOLOR_ARGB(a,r,g,b), 0, 0 );
  391. }
  392. void Drawopx(int x, int y, int width, int height, int r, int g, int b, int a, int line)
  393. {
  394. fillrgba(x,y+height,width,line,r,g,b,a);
  395. fillrgba(x,y,line,height,r,g,b,a);
  396. fillrgba(x,y,width,line,r,g,b,a);
  397. fillrgba(x+width,y,line,height,r,g,b,a);
  398. }
  399. __inline float GetDistance( const D3DXVECTOR3& From, const D3DXVECTOR3& To )
  400. {
  401. float Angle[3] = {0,0,0};
  402. Angle[0] = To.x-From.x;
  403. Angle[1] = To.y-From.y;
  404. Angle[2] = To.z-From.z;
  405. return sqrtf( Angle[0] * Angle[0] + Angle[1] * Angle[1] + Angle[2] * Angle[2] );
  406. }
  407. CPlayer* GetClosestByCrosshair()
  408. {
  409. FLOAT ScreenX = (FLOAT)Viewport.Width / 2.0f;
  410. FLOAT ScreenY = (FLOAT)Viewport.Height / 2.0f;
  411. FLOAT Nearest = (FLOAT)INT_MAX;
  412. FLOAT PosX = 0.0f, PosY = 0.0f;
  413.  
  414. CPlayer* saved_target = NULL;
  415. bool AimingAtEnemy = false;
  416.  
  417. CPlayer* pRet = NULL;
  418.  
  419. if(!pLocalPlayer)
  420. return 0;
  421.  
  422. CObject* pLocalInfo = pLocalPlayer->Soldier ? pLocalPlayer->Soldier->soldier_ptr : NULL;
  423.  
  424. if(!pLocalInfo)
  425. return 0;
  426.  
  427. for(int i = 0; i < 255; i++)
  428. {
  429. CPlayer* pPlayer = pPlayerManager->GetPlayerByIndex(i);
  430.  
  431. if (!IsPlayerValid(pPlayer))
  432. continue;
  433.  
  434. if (pPlayer == pLocalPlayer)
  435. continue;
  436.  
  437.  
  438. CObject* pInfo = pPlayer->SoldierObj ? pPlayer->Soldier->soldier_ptr : NULL;
  439.  
  440. CArmor* pHealth = pInfo->Health;
  441.  
  442.  
  443. if(pHealth->fHealth <= 0.0f || !pPlayer->Alive)
  444. continue;
  445.  
  446. D3DXVECTOR3 vOut;
  447. GET_ORIGIN_FROMMATRIX( &vOut, &pInfo->Matrix );
  448. if( bWorldToScreen(&vOut) )
  449. continue;
  450.  
  451. PosX = vOut.x > ScreenX ? vOut.x - ScreenX : ScreenX - vOut.x;
  452. PosY = vOut.y > ScreenY ? vOut.y - ScreenY : ScreenY - vOut.y;
  453.  
  454. FLOAT Temp = sqrt( PosX*PosX + PosY*PosY );
  455.  
  456. if(Temp > Nearest)
  457. continue;
  458.  
  459. pRet = pPlayer;
  460. Nearest = Temp;
  461. }
  462.  
  463. return pRet;
  464. }
  465. float oldzoom;
  466. inline void ZoomHack(float value)
  467. {
  468. pPlayerManager->LocalPlayer->zoom2 = value;
  469. }
  470. HRESULT WINAPI hkEndScene(LPDIRECT3DDEVICE9 pDevice)
  471. {
  472. pDevice->GetViewport(&Viewport);
  473. if(!Initialized)Initialize(pDevice);
  474. pDevice->SetRenderState(D3DRS_FOGENABLE,FALSE);
  475.  
  476. /*static bool done = false;
  477.   if (!done)
  478.   {
  479.   MessageBox(0,L"One Time On Endscene",0,0);
  480.   done = true;
  481.   }//*/
  482. //if (IsBadReadPtr(pPlayerManager->LocalPlayer,4)) return oEndScene(pDevice);
  483. if (IsPlayerValid(pPlayerManager->LocalPlayer))
  484. {
  485. //char pLocalInfo[33];
  486. //char Buf1[33];
  487. //itoa(pPlayerManager->LocalPlayer->Soldier->soldier_ptr->Health->fHealth,Buf1,10);
  488. //sprintf(pLocalInfo,"%s [Health: %s]",pPlayerManager->LocalPlayer->Name,Buf1);
  489. //pDebugTextWriter->OutlinedText(10,10,dWhite,&string(pLocalInfo));
  490.  
  491. for ( int i = 0; i < 255; i++ )
  492. {
  493. //if (IsBadReadPtr(pPlayerManager->GetPlayerByIndex( i ),4)) continue;
  494. //if (!IsPlayerValid(pPlayerManager->GetPlayerByIndex( i ))) continue;
  495. if (IsPlayerValid(pPlayerManager->GetPlayerByIndex( i )))
  496. {
  497.  
  498. if( pPlayerManager->GetPlayerByIndex( i ) == pPlayerManager->LocalPlayer )
  499. continue;
  500. static float oldzoom = pPlayerManager->LocalPlayer->zoom2;
  501. #ifdef __ZOOMHACK__
  502. ZoomHack((float)zoomhack);
  503. char zh[16];
  504. sprintf(zh,"Zoomhack is %d",zoomhack);
  505. pDebugTextWriter->OutlinedText(10,10,dWhite,&string(zh));
  506. #endif
  507. D3DXVECTOR3 lpOrigin, tpOrigin;
  508.  
  509. GET_ORIGIN_FROMMATRIX(&lpOrigin, &pPlayerManager->LocalPlayer->Soldier->soldier_ptr->Matrix);
  510. GET_ORIGIN_FROMMATRIX(&tpOrigin, &pPlayerManager->GetPlayerByIndex( i )->Soldier->soldier_ptr->Matrix);
  511.  
  512. if(!tpOrigin || !lpOrigin || !pPlayerManager->GetPlayerByIndex( i )->Name || !pPlayerManager->GetPlayerByIndex( i )->Soldier->soldier_ptr->Health)
  513. continue;
  514.  
  515. float flDistance = GetDistance(tpOrigin, lpOrigin);
  516.  
  517. char PlayerInfo[512];
  518. char Buf[33];
  519. itoa(pPlayerManager->GetPlayerByIndex( i )->Soldier->soldier_ptr->Health->fHealth,Buf,10);
  520. sprintf( PlayerInfo, "[%.0f m] %s [Health: %s]", flDistance, pPlayerManager->GetPlayerByIndex( i )->Name,Buf);
  521. if(pPlayerManager->GetPlayerByIndex( i )->Soldier->soldier_ptr->Health->fHealth <= 0.0f)
  522. continue;
  523.  
  524. if( tpOrigin )
  525. {
  526. if(bWorldToScreen(&tpOrigin))
  527. {
  528. if(pPlayerManager->GetPlayerByIndex( i )->Team != pPlayerManager->LocalPlayer->Team)
  529. {
  530. pDebugTextWriter->OutlinedText( tpOrigin.x - ( GetTextLength(PlayerInfo) ) / 2, tpOrigin.y - 20, dRed, &string(PlayerInfo));
  531. RECT rect;
  532. rect.left = tpOrigin.x - ( GetTextLength(PlayerInfo) ) / 2;
  533. rect.top = tpOrigin.y - 20;
  534.  
  535. Drawopx( tpOrigin.x - 250/flDistance, tpOrigin.y - (450/flDistance), 450/flDistance, 1050/flDistance,255 , 000,000, 255, 1);
  536.  
  537. }
  538. /*if (GetAsyncKeyState(VK_RBUTTON)&1)
  539.   {
  540.   POINT vecc;
  541.   GetCursorPos(&vecc);
  542.   FLOAT PosX = 0.0f, PosY = 0.0f;
  543.   FLOAT GPosX = 0.0f, GPosY = 0.0f;
  544.   int modex = 0;
  545.   int modey = 0;
  546.   D3DXVECTOR3 tpOrigi;
  547.   for (int g = 0; g < 255; g++)
  548.   {
  549.   if (IsPlayerValid(pPlayerManager->GetPlayerByIndex(g)))
  550.   {
  551.   if (pPlayerManager->GetPlayerByIndex(g) != pPlayerManager->LocalPlayer)
  552.   {
  553.   if(( pPlayerManager->GetPlayerByIndex( i )->Name || pPlayerManager->GetPlayerByIndex( i )->Soldier->soldier_ptr->Health ) && (pPlayerManager->GetPlayerByIndex( i )->Soldier->soldier_ptr->Health->fHealth > 0.0f))
  554.   {
  555.   GET_ORIGIN_FROMMATRIX(&tpOrigi,&pPlayerManager->GetPlayerByIndex(g)->Soldier->soldier_ptr->Matrix);
  556.   FLOAT ScreenX = (FLOAT)Viewport.Width / 2.0f;
  557.   FLOAT ScreenY = (FLOAT)Viewport.Height / 2.0f;
  558.  
  559.   FLOAT Nearest = (FLOAT)INT_MAX;
  560.   if (tpOrigi)
  561.   {
  562.   if ( bWorldToScreen(&tpOrigi))
  563.   {
  564.   PosX = tpOrigi.x > ScreenX ? tpOrigi.x - ScreenX : ScreenX - tpOrigi.x;
  565.   PosY = tpOrigi.y > ScreenY ? tpOrigi.y - ScreenY : ScreenY - tpOrigi.y;
  566.   modex = tpOrigi.x > ScreenX ? 2 : 1;
  567.   modey = tpOrigi.y > ScreenY ? 2 : 1;
  568.   FLOAT Temp = sqrt( PosX*PosX + PosY*PosY );
  569.   if (Temp <= Nearest)
  570.   {
  571.   Nearest = Temp;
  572.   GPosX = PosX;
  573.   GPosY = PosY;
  574.   }
  575.   }
  576.   }
  577.   }
  578.   }
  579.   }
  580.   }
  581.   if (PosX && PosY)
  582.   {
  583.   if (GPosX != 0 && GPosY != 0)
  584.   {
  585.   if (modex == 1)
  586.   {
  587.   GPosX += vecc.x;
  588.   }
  589.   if (modex == 2)
  590.   {
  591.   GPosX -= vecc.x;
  592.   }
  593.   if (modey == 1)
  594.   {
  595.   GPosY += vecc.y;
  596.   }
  597.   if (modey == 2)
  598.   {
  599.   GPosY -= vecc.y;
  600.   }
  601.   SetMyCursorPos(GPosX,GPosY);
  602.   }
  603.   }
  604.   }//*/
  605. /*if (lon == true)
  606.   {
  607.   pDebugTextWriter->OutlinedText(10,10,dWhite,&string("Triggerbot = on"));
  608.   FLOAT vX, vY;
  609.   vX = Viewport.Width/2;
  610.   vY = Viewport.Height/2;
  611.   FLOAT PosX = tpOrigin.x > vX ? tpOrigin.x - vX : vX - tpOrigin.x;
  612.   FLOAT PosY = tpOrigin.y > vY ? tpOrigin.y - vY : vY - tpOrigin.y;
  613.   #ifdef __O__
  614.   if ((tpOrigin.x - 250/flDistance < PosX || tpOrigin.y + 450/flDistance > PosY) && (tpOrigin.x - (450/flDistance-1050/flDistance) < PosX || tpOrigin.y + (1050/flDistance-250/flDistance) > PosY))
  615.   #else
  616.   if ((tpOrigin.x - 250/flDistance < vX || tpOrigin.y + 450/flDistance > vY) && (tpOrigin.x - (450/flDistance-1050/flDistance) < vX || tpOrigin.y + (1050/flDistance-250/flDistance) > vY))
  617.   #endif
  618.   {
  619.   Fire = true;
  620.   }
  621.   }
  622.   else
  623.   {
  624.   pDebugTextWriter->OutlinedText(10,10,dWhite,&string("Triggerbot = off"));
  625.   }//*/
  626. if(pPlayerManager->GetPlayerByIndex( i )->Team == pPlayerManager->LocalPlayer->Team)
  627. {
  628. pDebugTextWriter->OutlinedText( tpOrigin.x - ( GetTextLength(PlayerInfo) ) / 2, tpOrigin.y - 20, dBlue, &string(PlayerInfo));
  629. RECT rect;
  630. rect.left = tpOrigin.x - ( GetTextLength(PlayerInfo) ) / 2;
  631. rect.top = tpOrigin.y - 20;
  632.  
  633. Drawopx( tpOrigin.x - 250/flDistance, tpOrigin.y - (450/flDistance), 450/flDistance, 1050/flDistance, 000, 000, 255,255, 1);
  634. }
  635. }
  636. }
  637. }
  638. }
  639. }
  640.  
  641. return oEndScene(pDevice);
  642. }
  643.  
  644. DWORD WINAPI D3DHook(LPVOID)
  645. {
  646. while(hmRendDx9Base == NULL){hmRendDx9Base = GetModuleHandleA("RendDX9.dll");Sleep(250);}
  647. CloseHandle(hmRendDx9Base);
  648.  
  649. while(pDevice == NULL)
  650. pDevice = (LPDIRECT3DDEVICE9)pRenderer->pDirect3Ddev;
  651.  
  652. DWORD* GameDevice = (DWORD*)pDevice;
  653. GameDevice = (DWORD*)GameDevice[0];
  654. //MessageBox(0,L"Hooking Endscene",0,0);
  655. while (!oEndScene)
  656. oEndScene = (tEndScene) DetourFunction( (PBYTE)GameDevice[42], (PBYTE)&hkEndScene );
  657. return 0;
  658. }
  659.  
  660. BOOL APIENTRY DllMain( HMODULE hModule, DWORD ulReason, LPVOID lpReserved )
  661. {
  662. switch (ulReason)
  663. {
  664. case DLL_PROCESS_ATTACH:
  665. {
  666. CreateThread( 0, 0, D3DHook, 0, 0, 0 );
  667. CreateThread( 0, 0, HookFunctions, 0, 0, 0 );
  668. }
  669. break;
  670. case DLL_THREAD_DETACH:
  671. break;
  672. }
  673. return TRUE;
  674. }
Download H4x BFP4f Fixed

__________________

Hallo