havok_mk

Untitled

Apr 4th, 2012
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 19.88 KB | None | 0 0
  1. #include "Cwall.h"
  2. #include "CMenu.h"
  3.  
  4. //
  5. #include <conio.h>
  6.  
  7.  
  8. #include <d3d9.h>
  9.  
  10. #include <iostream>
  11. #include <windows.h>
  12. #include <vector>
  13. #include <stdio.h>
  14. #include <stdlib.h>
  15. #include <tchar.h>
  16. #include "CStruc.h"
  17. #pragma comment(lib, "d3d9.lib")
  18. //
  19. #include <d3dx9.h>
  20. #pragma comment(lib, "d3dx9.lib")
  21. #define NumVertices 1
  22. #define chams (NumVertices == 1557 || NumVertices == 1666 || NumVertices == 1765)
  23.  
  24.  
  25.  
  26. LPDIRECT3DTEXTURE9 g_pTexRed    = NULL;
  27. LPDIRECT3DTEXTURE9 g_pTexOrange = NULL;
  28.  
  29. const BYTE red[ 58 ] = {
  30.     0x42, 0x4D, 0x3A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x28, 0x00,
  31.     0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x18, 0x00, 0x00, 0x00,
  32.     0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  33.     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00
  34. };
  35.  
  36. const BYTE orange[ 58 ] = {
  37.     0x42, 0x4D, 0x3A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x28, 0x00,
  38.     0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x18, 0x00, 0x00, 0x00,
  39.     0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  40.     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA5, 0xFF, 0x00
  41. };
  42.  
  43. //---------------------------------------------------------------------------------------------------------------------------------
  44.  
  45.  
  46.  
  47.  
  48. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  49. typedef HRESULT ( WINAPI * DrawIPrim )
  50.  
  51.     ( LPDIRECT3DDEVICE9, D3DPRIMITIVETYPE,
  52.         INT, UINT, UINT, UINT, UINT );
  53.  
  54. void Jump( DWORD Address, DWORD Your_Detour );
  55. DWORD Old = NULL;
  56.  
  57. int xhair;
  58. int xhair2;
  59. int xhair3;
  60. int string;
  61. int wireframe;
  62. LPD3DXFONT g_pFont;
  63. LPDIRECT3DDEVICE9 pDevice;
  64.  
  65. //wepon name and all that by cardoow
  66. int nameTag;
  67. typedef bool (*w2s_)(int unknown, w2s_t * w2scalc, Vec3 vPoint, float Screen[2]);
  68. w2s_ w2s = (w2s_)0x514820;
  69.  
  70. typedef w2s_t *(*GetCalc_)();
  71. GetCalc_ GetCalc = (GetCalc_)0x4CE3C0;
  72.  
  73. typedef bool (*RankIcon_)(int Rank, int Prestige, DWORD ptr);
  74. RankIcon_ RankIcon = (RankIcon_)0x5330D0;
  75. //end right here
  76.  
  77. IDirect3DPixelShader9 *Red,*Yellow,*Green,*Blue,*Purple,*Pink,*Orange,*White,*Black;
  78. LPDIRECT3DDEVICE9 m_pD3Ddev;
  79. D3DCOLOR colBlack = D3DCOLOR_XRGB( 0, 0, 0 );
  80. D3DCOLOR colRed = D3DCOLOR_XRGB(255, 0, 0);
  81. LPDIRECT3D9 pD3D;
  82. DrawIPrim pDrawIPrim = NULL;
  83. PDEVICE     pDevice1;
  84. FONT        pFont = NULL;
  85.  
  86. DWORD dwEndscene_hook = NULL;
  87. DWORD dwEndscene_ret = NULL;
  88. DWORD dwDIP_hook = NULL;
  89. DWORD dwDIP_ret = NULL;
  90. DWORD dwReset_hook = NULL;
  91. DWORD dwReset_ret = NULL;
  92. DWORD bJump = NULL;
  93.  
  94. D3DVIEWPORT9 Viewport;
  95. D3DVIEWPORT9 g_ViewPort;
  96. D3DRECT RectA;
  97. D3DRECT RectB;
  98. DWORD CrossHairColor = D3DCOLOR_ARGB( 255, 20, 255, 20 );
  99. DWORD ScreenCenterX = NULL;
  100. DWORD ScreenCenterY = NULL;
  101. //LPD3DXFONT pFont = NULL;
  102. HMODULE D3D9 = NULL;
  103. UINT fHeight = 16;
  104. RECT FontRect;
  105.  
  106. D3DPRESENT_PARAMETERS D3D_PP = {0};
  107. IDirect3D9 * (WINAPI *oDirect3DCreate9)(UINT SDKVersion);
  108. //=====================================================================================
  109. //pixelshader Section
  110. HRESULT GenerateShader(IDirect3DDevice9 *pDev, IDirect3DPixelShader9 **pShader, float r, float g, float b )//credits silentk
  111. {
  112.     char szShader[ 256 ];
  113.     ID3DXBuffer *pShaderBuf = NULL;
  114.     sprintf( szShader, "ps.1.1\ndef c0, %f, %f, %f, %f\nmov r0,c0", r, g, b, 1.0f );
  115.     D3DXAssembleShader( szShader, sizeof( szShader ), NULL, NULL, 0, &pShaderBuf, NULL );
  116.     if( FAILED( pDev->CreatePixelShader((const DWORD*)pShaderBuf->GetBufferPointer(), pShader)) )return E_FAIL;
  117.     return S_OK;
  118. }
  119.  
  120.  
  121.  
  122.  
  123. //end here
  124.  
  125. void PostReset(PDEVICE pde){
  126.     if (pDevice1 != pde)
  127.     {
  128.         pDevice1 = pde;
  129.         try
  130.         {
  131.             if (pFont != NULL){
  132.                 pFont->Release();
  133.                                  
  134.             }
  135.  
  136.         } catch (...) {}
  137.         pFont = NULL;
  138.             D3DXCreateFontA(pde, 14, 0, FW_BOLD, 0, 0, DEFAULT_CHARSET, OUT_TT_ONLY_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial", &pFont);      
  139.  
  140.     }  
  141.     if( pFont == NULL)
  142.         D3DXCreateFontA(pde, 14, 0, FW_BOLD, 0, 0, DEFAULT_CHARSET, OUT_TT_ONLY_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial", &pFont);              
  143.  
  144.  
  145. }
  146. void myFillRGB( int x, int y, int w, int h, D3DCOLOR color, IDirect3DDevice9* pDevice )
  147. {    
  148.     D3DRECT rec = { x, y, x + w, y + h };    
  149.     pDevice->Clear( 1, &rec, D3DCLEAR_TARGET, color, 0, 0 );
  150.  
  151. }
  152. void PrintText(char pString[], int x, int y, D3DCOLOR col, ID3DXFont *font)
  153. {
  154.     RECT FontRect = { x, y, x+500, y+30 };
  155.     font->DrawText( NULL, pString, -1, &FontRect, DT_LEFT | DT_WORDBREAK, col);
  156. }
  157.  
  158. void DisplaySomeText()
  159. {
  160.     #define RED D3DCOLOR_ARGB(255, 255, 0, 0)
  161.     #define DEEPPINK D3DCOLOR_ARGB(155, 255, 20, 147)
  162.     #define NAVY D3DCOLOR_ARGB(255,00,00,128)  
  163.  
  164.     D3DXCreateFontA(pDevice, 14, 0, FW_BOLD, 0, 0, DEFAULT_CHARSET, OUT_TT_ONLY_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial", &g_pFont );
  165.  
  166. PrintText("._.[100x100]", 100, 100, DEEPPINK , pFont);
  167. PrintText("@Nukem [200x200]", 200,200,NAVY, pFont);
  168. PrintText("Orange[500x500]", 500,500,RED, pFont);
  169. PrintText("._.[100x650]", 100,650,NAVY, pFont);
  170.  
  171.  
  172. }
  173.  
  174.  
  175. VOID WINAPI MY_MAIN_ENDSCENE( LPDIRECT3DDEVICE9 pDev )
  176. {
  177.     if (pFont){
  178.         RenderMenu(pDev);
  179.        
  180.         //DisplaySomeText();
  181.     }else{
  182.         PostReset(pDev);   
  183.         RenderMenu(pDev);
  184.  
  185.         //DisplaySomeText();
  186.     }
  187.  
  188. if( pFont == NULL )
  189.         D3DXCreateFontA( pDev, fHeight, 0, FW_BOLD, 0, TRUE,
  190.             DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY,
  191.                 DEFAULT_PITCH | FF_DONTCARE, "Calibri", &pFont );
  192.  
  193.     if( pFont != NULL )
  194.     {
  195.         int istrlen = strlen( "Galaretka." ) * 3;
  196.         FontRect.left = ScreenCenterX - istrlen;
  197.         FontRect.top = Viewport.Height - fHeight - fHeight;
  198.         FontRect.right = Viewport.Width;
  199.         FontRect.bottom = Viewport.Height;
  200.  
  201.         pFont->DrawTextA( 0, "Galaretka.", -1, &FontRect,
  202.             DT_NOCLIP, D3DCOLOR_ARGB( 255, 20, 128, 255 ) );
  203.     }
  204.  
  205.  
  206.    
  207. if (xhair)
  208. {
  209. D3DRECT rec2 = {ScreenCenterX-8, ScreenCenterY, ScreenCenterX+8, ScreenCenterY+1};
  210. D3DRECT rec3 = {ScreenCenterX, ScreenCenterY-8, ScreenCenterX+1, ScreenCenterY+8};
  211. pDev->Clear(1, &rec2, D3DCLEAR_TARGET,colRed, 0, 0);
  212. pDev->Clear(1, &rec3, D3DCLEAR_TARGET,colRed, 0, 0);
  213. DisplaySomeText();
  214. }
  215.  
  216. if(xhair)
  217.      {
  218. /*pDev->GetViewport(&g_ViewPort);
  219. ScreenCenterX = (float)g_ViewPort.Width / 2;
  220. ScreenCenterY = (float)g_ViewPort.Height / 2;
  221. D3DRECT rec4 = {ScreenCenterX-35, ScreenCenterY, ScreenCenterX+ 35, ScreenCenterY+1};
  222. D3DRECT rec5 = {ScreenCenterX, ScreenCenterY-35, ScreenCenterX+ 1,ScreenCenterY+35};
  223. pDev->Clear( 1, &rec4, D3DCLEAR_TARGET, D3DXCOLOR(0.62745098, 0.125490, 0.959999, 1.0), 0, 0 );//purple
  224. pDev->Clear( 1, &rec5, D3DCLEAR_TARGET, D3DXCOLOR(0.62745098, 0.125490, 0.959999, 1.0), 0, 0 );
  225. D3DRECT rec6 = {ScreenCenterX-30, ScreenCenterY, ScreenCenterX+ 30, ScreenCenterY+1};
  226. D3DRECT rec7 = {ScreenCenterX, ScreenCenterY-30, ScreenCenterX+ 1,ScreenCenterY+30};
  227. pDev->Clear( 1, &rec6, D3DCLEAR_TARGET, D3DXCOLOR(0.0, 0.0, 1.0, 1.0), 0, 0 );//blue
  228. pDev->Clear( 1, &rec7, D3DCLEAR_TARGET, D3DXCOLOR(0.0, 0.0, 1.0, 1.0), 0, 0 );
  229. D3DRECT rec8 = {ScreenCenterX-25, ScreenCenterY, ScreenCenterX+ 25, ScreenCenterY+1};
  230. D3DRECT rec9 = {ScreenCenterX, ScreenCenterY-25, ScreenCenterX+ 1,ScreenCenterY+25};
  231. pDev->Clear( 1, &rec8, D3DCLEAR_TARGET, D3DXCOLOR(0.0, 1.0, 1.0, 1.0), 0, 0 );//cyan
  232. pDev->Clear( 1, &rec9, D3DCLEAR_TARGET, D3DXCOLOR(0.0, 1.0, 1.0, 1.0), 0, 0 );
  233. D3DRECT rec10 = {ScreenCenterX-20, ScreenCenterY, ScreenCenterX+ 20, ScreenCenterY+1};
  234. D3DRECT rec11 = {ScreenCenterX, ScreenCenterY-20, ScreenCenterX+ 1,ScreenCenterY+20};
  235. pDev->Clear( 1, &rec10, D3DCLEAR_TARGET, D3DXCOLOR(0.0, 1.0, 0.0, 1.0), 0, 0 );// green
  236. pDev->Clear( 1, &rec11, D3DCLEAR_TARGET, D3DXCOLOR(0.0, 1.0, 0.0, 1.0), 0, 0 );
  237. D3DRECT rec12 = {ScreenCenterX-15, ScreenCenterY, ScreenCenterX+ 15, ScreenCenterY+1};
  238. D3DRECT rec13 = {ScreenCenterX, ScreenCenterY-15, ScreenCenterX+ 1,ScreenCenterY+15};
  239. pDev->Clear( 1, &rec12, D3DCLEAR_TARGET, D3DXCOLOR(1.0, 1.0, 0.0, 1.0), 0, 0 );// yellow
  240. pDev->Clear( 1, &rec13, D3DCLEAR_TARGET, D3DXCOLOR(1.0, 1.0, 0.0, 1.0), 0, 0 );
  241.  
  242. D3DRECT rec14 = {ScreenCenterX-10, ScreenCenterY, ScreenCenterX+ 10, ScreenCenterY+1};
  243. D3DRECT rec15 = {ScreenCenterX, ScreenCenterY-10, ScreenCenterX+ 1,ScreenCenterY+10};
  244. pDev->Clear( 1, &rec14, D3DCLEAR_TARGET, D3DXCOLOR(1.0, 0.549019608, 0.0, 1.0), 0, 0 );// orange
  245. pDev->Clear( 1, &rec15, D3DCLEAR_TARGET, D3DXCOLOR(1.0, 0.549019608, 0.0, 1.0), 0, 0 );
  246. D3DRECT rec16 = {ScreenCenterX-5, ScreenCenterY, ScreenCenterX+ 5, ScreenCenterY+1};
  247. D3DRECT rec17 = {ScreenCenterX, ScreenCenterY-5, ScreenCenterX+ 1,ScreenCenterY+5};
  248. pDev->Clear( 1, &rec16, D3DCLEAR_TARGET, D3DXCOLOR(1.0, 0.0, 0.0, 1.0), 0, 0 );//red
  249. pDev->Clear( 1, &rec17, D3DCLEAR_TARGET, D3DXCOLOR(1.0, 0.0, 0.0, 1.0), 0, 0 );
  250. */
  251. }
  252.  
  253.  
  254.  
  255. if (xhair2)
  256. {
  257.     D3DRECT rec1 = {ScreenCenterX-25, ScreenCenterY, ScreenCenterX+ 25, ScreenCenterY+1};
  258.     D3DRECT rec2 = {ScreenCenterX, ScreenCenterY-25, ScreenCenterX+ 1,ScreenCenterY+25};  
  259.    pDev->Clear( 1, &rec1, D3DCLEAR_TARGET, D3DXCOLOR(1.0, 0.0, 0.0, 1.0), 0,  0 );
  260.    pDev->Clear( 1, &rec2, D3DCLEAR_TARGET, D3DXCOLOR(1.0, 0.0, 0.0, 1.0), 0,  0 );
  261. //red
  262.  
  263.    
  264.     D3DRECT rec3 = {ScreenCenterX-15, ScreenCenterY, ScreenCenterX+ 15, ScreenCenterY+1};
  265.     D3DRECT rec4 = {ScreenCenterX, ScreenCenterY-15, ScreenCenterX+ 1,ScreenCenterY+15};  
  266.    pDev->Clear( 1, &rec3, D3DCLEAR_TARGET, D3DXCOLOR(0.0, 0.0, 0.0, 0.0), 0,  0 );
  267.    pDev->Clear( 1, &rec4, D3DCLEAR_TARGET, D3DXCOLOR(0.0, 0.0, 0.0, 0.0), 0,  0 );
  268. // black
  269.    
  270.     D3DRECT rec5 = {ScreenCenterX-3, ScreenCenterY, ScreenCenterX+ 3, ScreenCenterY+1};
  271.     D3DRECT rec6 = {ScreenCenterX, ScreenCenterY-3, ScreenCenterX+ 1,ScreenCenterY+3};  
  272.    pDev->Clear( 1, &rec5, D3DCLEAR_TARGET, D3DXCOLOR(1.0, 0.0, 0.0, 1.0), 0,  0 );
  273.    pDev->Clear( 1, &rec6, D3DCLEAR_TARGET, D3DXCOLOR(1.0, 0.0, 0.0, 1.0), 0,  0 );
  274. // black
  275. }
  276.  
  277.  
  278.  
  279. if(xhair3)
  280.     {
  281.     D3DRECT rec2 = {ScreenCenterX-10, ScreenCenterY, ScreenCenterX+10, ScreenCenterY+1};
  282.     D3DRECT rec3 = {ScreenCenterX, ScreenCenterY-10, ScreenCenterX+ 1,ScreenCenterY+10};                                
  283.    pDev->Clear(1, &rec2, D3DCLEAR_TARGET,D3DXCOLOR(1.0, 0.0, 0.0, 1.0), 0, 0 );//red
  284.    pDev->Clear(1, &rec3, D3DCLEAR_TARGET,D3DXCOLOR(1.0, 0.0, 0.0, 1.0), 0, 0 );
  285.     }
  286.  
  287.  
  288. if(string)
  289.      {
  290.     /*D3DRECT rec2 = {ScreenCenterX-15, ScreenCenterY, ScreenCenterX+ 15, ScreenCenterY+2};
  291.     D3DRECT rec3 = {ScreenCenterX, ScreenCenterY-15, ScreenCenterX+ 2,ScreenCenterY+15};
  292.                                
  293.    pDev->Clear(1, &rec2, D3DCLEAR_TARGET,D3DXCOLOR(1.0, 1.0, 0.0, 1.0), 0, 0 );// yellow
  294.    pDev->Clear(1, &rec3, D3DCLEAR_TARGET,D3DXCOLOR(1.0, 1.0, 0.0, 1.0), 0, 0 );
  295.    
  296.     */
  297.          DisplaySomeText();
  298.          /*
  299.          numvert 1557 - NOGI SAS
  300.          numvert 1666 - tułów SAS
  301.          numvert 1765 - pas z bronią PMC
  302.          */
  303.  
  304.          if(NumVertices == 1557 || NumVertices == 1666 || NumVertices == 1765)
  305.          {
  306.              pDevice->SetRenderState(D3DRS_ZENABLE,false);
  307.                 pDevice->SetRenderState( D3DRS_FILLMODE,D3DFILL_SOLID );
  308.                 pDevice->SetPixelShader(Red);
  309.         oDrawIndexedPrimitive(pDevice, PrimType, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);
  310.                 pDevice->SetRenderState(D3DRS_ZENABLE,true);
  311.                 pDevice->SetRenderState( D3DRS_FILLMODE,D3DFILL_SOLID );
  312.                 pDevice->SetPixelShader(Orange);
  313.          }
  314. }
  315.    
  316.     GenerateShader(pDev, &Red, 1.0f,0.0f ,0.0f);
  317.     GenerateShader(pDev, &Yellow,1.0f,1.0f,0.0f);
  318.     GenerateShader(pDev, &Green,0.0f,1.0f,0.0f);
  319.     GenerateShader(pDev, &Blue,0.0f,0.0f,1.0f);
  320.     GenerateShader(pDev, &Purple,102.0f,0,153.0f);
  321.     GenerateShader(pDev, &Pink,255.0f,20.0f,147.0f);
  322.     GenerateShader(pDev, &Orange,255.0f,165.0f,0.0f);
  323.     GenerateShader(pDev, &Black,0.0f,0.0f,0.0f);
  324.     GenerateShader(pDev, &White,1.0f,1.0f,1.0f);
  325.  
  326.    if(nameTag)
  327.    {
  328.        void DrawNameTags( CEntity * pEnt, float Alpha );
  329.  
  330.  
  331.     }
  332.  
  333.     }
  334. //here is a extra methods to get info on game.
  335. void DrawNameTags( CEntity * pEnt, float Alpha )
  336. {
  337.     DWORD dwNameTags = 0x580C30;
  338.    
  339.     __asm{
  340.         push Alpha
  341.         push pEnt
  342.         push 0x0
  343.         call [dwNameTags]
  344.         add esp, 0xC
  345.     }
  346. }
  347.  
  348. //end here
  349.  
  350.  
  351.    
  352.  
  353.  
  354. __declspec(naked) void MyEndscene( )
  355. {
  356.     __asm
  357.     {
  358.         MOV DWORD PTR SS:[EBP-0x10],ESP
  359.         MOV ESI,DWORD PTR SS:[EBP+0x8]
  360.         XOR EBX,EBX                     //replace patched code
  361.         PUSHFD
  362.         PUSHAD
  363.         PUSH [EBP+0x8]
  364.         CALL MY_MAIN_ENDSCENE;
  365.         POPAD
  366.         POPFD
  367.         CMP ESI,EBX                     //replace patched code
  368.         jmp dwEndscene_ret;             //jump back to normal endscene
  369.     }
  370. }
  371.  
  372. VOID WINAPI MY_MAIN_DIP( LPDIRECT3DDEVICE9 pDev,
  373.     D3DPRIMITIVETYPE Type, INT BIndex, UINT MIndex,
  374.         UINT NVertices, UINT SIndex, UINT PCount )
  375. {
  376.     LPDIRECT3DVERTEXBUFFER9 Stream_Data;
  377.     UINT Offset = 0;
  378.     UINT Stride = 0;
  379.  
  380.     if( pDev->GetStreamSource( 0, &Stream_Data, &Offset, &Stride ) == S_OK )
  381.         Stream_Data->Release();
  382.  
  383.         if(g_pTexRed == NULL)
  384.             {
  385.                 D3DXCreateTextureFromFileInMemory(pDevice, (LPCVOID)&red, sizeof(red), &g_pTexRed);
  386.         }
  387.         if(g_pTexOrange == NULL)
  388.             {
  389.                 D3DXCreateTextureFromFileInMemory(pDevice, (LPCVOID)&orange, sizeof(orange), &g_pTexOrange);
  390.         }
  391.  
  392.         GenerateShader( pDevice, &Red,  1.0f, 0.0f, 0.0f);
  393.         GenerateShader( pDevice, &Green,  0.0f, 1.0f, 0.0f);
  394.    
  395.  
  396.     if( Stride == 44 )
  397.     {
  398.         if(wireframe)
  399.         {
  400.         bJump = TRUE;
  401.         pDev->SetRenderState( D3DRS_ZENABLE, D3DZB_FALSE);
  402.         pDev->SetPixelShader(Red);
  403.         pDrawIPrim( pDev, Type, BIndex, MIndex,
  404.             NVertices, SIndex, PCount );
  405.  
  406.         pDev->SetRenderState( D3DRS_ZENABLE, D3DZB_TRUE);
  407.         pDev->SetPixelShader(White);
  408.         bJump = FALSE;
  409.         }
  410.     }
  411. }
  412.  
  413.  
  414. __declspec(naked) void MyDIP( )
  415. {
  416.     __asm
  417.     {
  418.         MOV EDI,DWORD PTR SS:[EBP+0x8]
  419.         XOR EBX,EBX                    
  420.         CMP EDI,EBX                     // replace patched code
  421.         PUSHFD
  422.         PUSHAD
  423.         MOV EDX,[bJump]
  424.         CMP EDX,0x0
  425.         JG DONE
  426.         PUSH [EBP+0x20]                 // Push arguments of DIP
  427.         PUSH [EBP+0x1C]    
  428.         PUSH [EBP+0x18]    
  429.         PUSH [EBP+0x14]    
  430.         PUSH [EBP+0x10]    
  431.         PUSH [EBP+0x0C]    
  432.         PUSH [EBP+0x08]    
  433.         CALL MY_MAIN_DIP
  434.         DONE: POPAD
  435.         POPFD
  436.         jmp dwDIP_ret;                  // jump back to normal DIP
  437.     }
  438. }
  439.  
  440. VOID WINAPI MY_MAIN_RESET( )
  441. {
  442.     if( pFont != NULL )
  443.         if( pFont->Release( ) == S_OK )
  444.             pFont = NULL;
  445.  
  446.     if( pFont )
  447.         pFont->OnLostDevice();
  448.    
  449.    
  450.    
  451.     if(pFont == D3D_OK) {
  452.        if( pFont )
  453.         pFont->OnLostDevice();
  454.      
  455.      
  456.     }
  457.    
  458. }
  459.  
  460.    
  461.  
  462.  
  463. /*__declspec(naked) void MyReset( )
  464. {
  465.     __asm
  466.     {
  467.         PUSHAD
  468.         PUSHFD
  469.         CALL MY_MAIN_RESET
  470.         POPFD
  471.         POPAD
  472.         MOV ESI,DWORD PTR SS:[EBP-0x08]
  473.         MOV EDI,DWORD PTR SS:[EBP-0x04]
  474.         POP EBX
  475.         JMP dwReset_ret
  476.     }
  477. }
  478. */
  479. //=====================================================================================
  480.  
  481. VOID WINAPI GETD3D( VOID )
  482. {
  483.     HWND ConsoleWindow = GetConsoleWindow( );
  484.     //ShowWindow( ConsoleWindow, SW_HIDE ); // Your Choice ...
  485.  
  486.     while( D3D9 == NULL )
  487.     {
  488.         D3D9 = GetModuleHandleA( "d3d9.dll" );
  489.         Sleep( 100 );
  490.     }
  491.  
  492.     *(PDWORD)&oDirect3DCreate9 = (DWORD)
  493.         GetProcAddress( D3D9, "Direct3DCreate9" );
  494.  
  495.     _cprintf( "Direct3DCreate9\n" );
  496.     pD3D = oDirect3DCreate9( D3D_SDK_VERSION );
  497.  
  498.     D3D_PP.Windowed = TRUE;
  499.     D3D_PP.SwapEffect = D3DSWAPEFFECT_DISCARD;
  500.     D3D_PP.BackBufferFormat = D3DFMT_UNKNOWN;
  501.  
  502.     _cprintf( "CreateDevice\n" );
  503.     pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
  504.         ConsoleWindow, D3DCREATE_SOFTWARE_VERTEXPROCESSING,
  505.             &D3D_PP, &m_pD3Ddev );
  506.  
  507.     PDWORD VTABLE = *(DWORD**)m_pD3Ddev;
  508.  
  509.     dwEndscene_hook = VTABLE[42] + 0x2A;
  510.     dwEndscene_ret = dwEndscene_hook + 0x0A;
  511.     dwDIP_hook = VTABLE[82] + 0x2D;
  512.     dwDIP_ret = dwDIP_hook + 0x7;
  513.     dwReset_hook = VTABLE[16] + 165;
  514.     dwReset_ret = dwReset_hook + 0x7;
  515.  
  516.     *(PDWORD)&pDrawIPrim = (DWORD)VTABLE[82];
  517.  
  518.     _cprintf( "Jump\n" );
  519.     Jump( (DWORD)dwEndscene_hook, (DWORD)MyEndscene );
  520.     Jump( (DWORD)dwDIP_hook, (DWORD)MyDIP );
  521. //  Jump( (DWORD)dwReset_hook, (DWORD)MyReset );
  522.    
  523.     _cprintf( "Done\n" );
  524.     Sleep( 400 );
  525.     m_pD3Ddev->Release( );
  526.     pD3D->Release( );
  527.     FreeConsole( );
  528. }
  529.  
  530. //=====================================================================================
  531.  
  532. BOOL WINAPI DllMain( HINSTANCE hModule, DWORD dwReason, LPVOID lpvReserved )
  533. {
  534.     if( dwReason == DLL_PROCESS_ATTACH )
  535.     {
  536.         DisableThreadLibraryCalls( hModule );
  537.         AllocConsole( );
  538.         _cprintf( "Ready\n" );
  539.         CreateThread( NULL, NULL, (LPTHREAD_START_ROUTINE)
  540.             GETD3D, NULL, NULL, NULL);
  541.     }
  542.     return TRUE;
  543. }
  544.  
  545. //=====================================================================================
  546.  
  547. void Jump( DWORD Address, DWORD Your_Detour )
  548. {
  549.     VirtualProtect( (LPVOID)Address, 5,
  550.         PAGE_EXECUTE_READWRITE, &Old );
  551.  
  552.     *(PBYTE)Address = (BYTE)0xE9;
  553.  
  554.     *(PDWORD)(Address + 1) =
  555.         ( Your_Detour - Address - 5) ;
  556.  
  557.     VirtualProtect( (LPVOID)Address, 5,
  558.         Old, &Old );
  559. }
  560.  
  561. //=====================================================================================
  562.  
  563. //////////////////////HACK PART////////////////////////////////////////////////////////////////
  564. // group states
  565. int     CH_cheats     = 1;
  566. int     CH_Wall       = 1;
  567. // item  states
  568. int     a[15], b[15], c[15];
  569.  
  570. // none standard options
  571. char    *opt_Grp[]     = { ("+"),("-") };
  572. char    *opt_OffOn[]   = { ("Off"),("On") };
  573. char    *opt_CRSHAR[]  = { ("Off"),("Blue"),("Green"),("Red"),("Orange"),("Black"),("White")};
  574.  
  575. D3DMenu *pMenu = NULL;
  576.  
  577. // --- simple FPS vars and function
  578. char sFPS[20]= "xxx Fps";
  579. int   FPScounter = 0;
  580. float FPSfLastTickCount = 0.0f;
  581. float FPSfCurrentTickCount;
  582.  
  583. void FPScheckW(char*str)
  584. {
  585.     FPSfCurrentTickCount = clock() * 0.001f;
  586.     FPScounter++;
  587.  
  588.     if((FPSfCurrentTickCount - FPSfLastTickCount) > 1.0f) {
  589.         FPSfLastTickCount = FPSfCurrentTickCount;
  590.         sprintf(str, "%d",FPScounter);
  591.         FPScounter = 0;
  592.     }
  593. }
  594. void MakeMenu(){
  595.    
  596.     //pMenu->AddGroup(  ("[D3D Hacks]"), &CH_cheats, opt_Grp);
  597.   if (CH_cheats) {
  598.         pMenu->AddItem(("xhair")        , &xhair    , opt_OffOn);
  599.         pMenu->AddItem(("xhair2")       , &xhair2   , opt_OffOn);
  600.         pMenu->AddItem(("xhair3")       , &xhair3   , opt_OffOn);
  601.         pMenu->AddItem(("String & chams")       , &string   , opt_OffOn);
  602.  
  603.   }
  604.   if (CH_Wall)
  605.   {
  606.         pMenu->AddItem(("wireFrame")        , &wireframe    , opt_OffOn);
  607.         pMenu->AddItem(("NameTag")      , &nameTag  , opt_OffOn);
  608.  
  609.         pMenu->AddText("Framerate", sFPS);
  610.         pMenu->AddText("Galaretka Haxxery 2012");
  611.   }
  612.  
  613. }
  614.  
  615. void RenderMenu(PDEVICE pDev){
  616.  
  617.     if (pMenu==0) {                                             // first time , create the menu
  618.         pMenu = new D3DMenu("Features",300,130,20,50, true);    // title, maxitems,width
  619.         pMenu->visible=0;                                       // make it visible
  620.         pMenu->col_title=0xffffffff;                            // change title color to white
  621.     }
  622.    
  623.     else  {
  624.                D3DCOLOR xcolor;
  625.  
  626.         switch(a[6]){
  627.         case 0: xcolor = D3DCOLOR_ARGB( 255, 0, 0, 255 );//("Blue"),
  628.             break;
  629.         case 1: xcolor = D3DCOLOR_ARGB( 255, 0, 0, 255 );//("Green"),
  630.             break;
  631.         case 2: xcolor = D3DCOLOR_ARGB( 255, 0, 255, 0 );//("Red"),
  632.             break;
  633.         case 3: xcolor = D3DCOLOR_ARGB( 255, 255, 0, 0 );//("Orange")
  634.             break;
  635.         case 4: xcolor = D3DCOLOR_ARGB(255 , 255 , 165 , 0 );//("Black"),
  636.             break;
  637.         case 5: xcolor = D3DCOLOR_ARGB (255 , 0 , 0 , 0 );//("White")
  638.             break;
  639.         case 6: xcolor = D3DCOLOR_ARGB (255 , 255 , 255 , 255 );
  640.             break;
  641.         }
  642.         if( a[6] > 0 ){
  643.  
  644.             int size = 10, strong = 1;
  645.             D3DVIEWPORT9 viewP;
  646.             pDev->GetViewport( &viewP );
  647.             int iCenterX = (viewP.Width / 2) - 1;
  648.             int iCenterY = (viewP.Height / 2) -1;
  649.             if( iCenterX < 10 && iCenterY < 10 )
  650.             {
  651.                 iCenterX = ( GetSystemMetrics( 0 ) / 2 );
  652.                 iCenterY = ( GetSystemMetrics( 1 ) / 2 );
  653.             }
  654.            D3DRECT rec2 = {ScreenCenterX-8, ScreenCenterY, ScreenCenterX+8, ScreenCenterY+1};
  655. D3DRECT rec3 = {ScreenCenterX, ScreenCenterY-8, ScreenCenterX+1, ScreenCenterY+8};
  656.             pDev->Clear(1, &rec2, D3DCLEAR_TARGET, xcolor, 0,  0);
  657.             pDev->Clear(1, &rec3, D3DCLEAR_TARGET, xcolor, 0,  0);
  658.         }
  659.  
  660.            if(pMenu->visible) FPScheckW(sFPS);
  661.         if (pMenu->noitems==0) MakeMenu();
  662.         pMenu->Show(pFont, pDev);
  663.         pMenu->Nav();
  664.     }
  665.   }
Advertisement
Add Comment
Please, Sign In to add comment