Kutu_Kucing

c

Sep 21st, 2018
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.02 KB | None | 0 0
  1. DWORD m_pCaps, SelectShader = 0;
  2. class cCaps
  3. {
  4. public:
  5. char _0x0000[336];
  6.     DWORD ShaderMode; //0x0150
  7.  
  8. };//Size=0x0184
  9. class i3Shader
  10. {
  11. public:
  12. };
  13. class i3RenderContext_DIP
  14. {
  15. public:
  16.     char pad_0000[12]; //0x0000
  17.     class i3Timer* i3Timer; //0x000C
  18.     class i3RenderTarget* i3RenderTarget; //0x0010
  19.     class i3TextureDX* i3TextureDX; //0x0014
  20.     class i3VertexArrayDX* i3VertexArrayDX; //0x0018
  21.     class i3IndexArray* i3IndexArray; //0x001C
  22.     BYTE VertexCount; //0x0020
  23.     char pad_0021[2123]; //0x0021
  24.     class N00001F9F* N000008ED; //0x086C
  25.     class N00002011* N000008EC; //0x0870
  26.     char pad_0874[32]; //0x0874
  27.     class i3GfxPerformanceReport* i3GfxPerformanceReport; //0x0894
  28.     DWORD DrawCount; //0x0898
  29.     DWORD DrawPrimCount; //0x089C
  30.     char pad_08A0[17704]; //0x08A0
  31.     class i3TextureCubeDX* i3TextureCubeDX; //0x4DC8
  32.     char pad_4DCC[996]; //0x4DCC
  33.     class i3Shader* Shader; //0x51B0
  34.     class i3ShaderCache* i3ShaderCache; //0x51B4
  35.     char pad_51B8[540]; //0x51B8
  36.     LPDIRECT3DDEVICE9 pDevice; //0x53D4
  37.     char pad_53D8[12]; //0x53D8
  38.     class i3RenderTarget* i3RenderTarget2; //0x53E4
  39.     char pad_53E8[148]; //0x53E8
  40.     class i3GfxFontDXManager* i3GfxFontDXManager; //0x547C
  41.     class i3GfxFontDX2Manager* i3GfxFontDX2Manager2; //0x5480
  42.     class i3GfxFontDX2Manager* i3GfxFontDX2Manager3; //0x5484
  43.     char pad_5488[20]; //0x5488
  44.     DWORD DrawSize; //0x549C
  45.     char pad_54A0[12]; //0x54A0
  46.     DWORD DrawSize2; //0x54AC
  47.     char pad_54B0[4]; //0x54B0
  48.     class N00004C4B* N00001AB1; //0x54B4
  49.     char pad_54B8[8]; //0x54B8
  50.     DWORD dwSize; //0x54C0
  51.     DWORD isReady; //0x54C4
  52.     char pad_54C8[3908]; //0x54C8
  53. }; //Size: 0x640C
  54. typedef void (__thiscall* tSelectShader)(void *p, i3Shader* , int);
  55. tSelectShader oSelectShader;
  56.  
  57. HRESULT WINAPI hkDrawIndexedPrimitive(LPDIRECT3DDEVICE9 pDevice, D3DPRIMITIVETYPE PrimType,INT BaseVertexIndex,UINT MinVertexIndex,UINT NumVertices,UINT startIndex,UINT primCount)
  58. {
  59.  
  60.     pDevice->SetFVF         ( D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1 );
  61.     pDevice->GetPixelShader(&oldlShader2);
  62.     pDevice->SetTexture     ( 0, NULL );
  63.     pDevice->SetPixelShader(0);
  64.     pDevice->SetRenderState(D3DRS_ZENABLE, FALSE);
  65.     pDevice->SetRenderState(D3DRS_STENCILENABLE, FALSE);
  66.  
  67.  
  68.     pDevice->SetRenderState(D3DRS_ZENABLE, TRUE);
  69.     pDevice->SetRenderState(D3DRS_STENCILENABLE, TRUE);
  70.     pDevice->SetPixelShader(oldlShader2);
  71.     return pDevice->DrawIndexedPrimitive(PrimType, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);
  72. }
  73. i3Shader* __fastcall myDrawIndexedPrim2(void *p, void *Unknown, i3Shader *Shader, D3DPRIMITIVETYPE I3G_PRIMITIVE, unsigned int startIdx, unsigned int primCount)
  74. {
  75.  
  76.     unsigned int dwRenderContext;
  77.     int dwDrawPrimitiveSize;
  78.     int dwDrawPrimitiveSize_Count;
  79.     int dwDrawPrimitiveSize_VertexBufferData;
  80.     int dwOffset;
  81.     int dwBufferData;
  82.     int i;
  83.     int size2 = 0;
  84.     oSelectShader = (tSelectShader)SelectShader;
  85.     dwRenderContext = (unsigned int)(p);
  86.     i3RenderContext_DIP* pRC = (i3RenderContext_DIP*)(p);
  87.     //dwDrawCount       = (unsigned int)*(DWORD*)(i3RenderContext + 0x89C);
  88.     *(DWORD *)(dwRenderContext + 0x898) += primCount;
  89.     (*(DWORD*)(dwRenderContext + 0x89C))++;
  90.    
  91.     cCaps* pCaps = (cCaps*)(*(DWORD*)(m_pCaps));
  92.     if(pCaps->ShaderMode)
  93.     {
  94.         oSelectShader(p, Shader, 0);
  95.     }
  96.    
  97.     if((*(DWORD *)(dwRenderContext + 0x20) >> 5) & 1 && *(DWORD *)(dwRenderContext + 0x54C4) == 1)
  98.     {
  99.         dwDrawPrimitiveSize                     = *(DWORD *)(dwRenderContext + 0x54B4);
  100.         dwDrawPrimitiveSize_Count               = *(DWORD *)(dwDrawPrimitiveSize + 0x8C);
  101.         dwDrawPrimitiveSize_VertexBufferData    = *(DWORD *)(dwDrawPrimitiveSize + 0xE0);
  102.         dwOffset                                = dwDrawPrimitiveSize   * *(DWORD *)(dwRenderContext + 0x54C0);
  103.         dwBufferData                                = dwDrawPrimitiveSize_VertexBufferData;
  104.  
  105.         for ( i = dwDrawPrimitiveSize_Count; size2 < *(DWORD *)(dwRenderContext + 0x54AC); dwDrawPrimitiveSize_VertexBufferData = dwBufferData )
  106.         {
  107.             (*(void (__stdcall **)(DWORD, signed int, int, int, DWORD))(**(DWORD **)(dwRenderContext + 0x53D4) + 0x190))(
  108.             *(DWORD *)(dwRenderContext + 0x53D4),
  109.             1,
  110.             dwDrawPrimitiveSize_VertexBufferData,
  111.             dwOffset,
  112.             0);
  113.  
  114.             hkDrawIndexedPrimitive((LPDIRECT3DDEVICE9)*(DWORD *)(dwRenderContext + 0x53D4), I3G_PRIMITIVE, 0, 0, 5, startIdx, primCount);
  115.             dwOffset += dwDrawPrimitiveSize_Count;//i
  116.             ++size2;
  117.         }
  118.     }
  119.     else {
  120.         hkDrawIndexedPrimitive((LPDIRECT3DDEVICE9)*(DWORD *)(dwRenderContext + 0x53D4), I3G_PRIMITIVE, 0, 0, 5, startIdx, primCount);
  121.     }
  122.    
  123.    
  124.    
  125.    
  126.     return pRC->Shader;
  127. }
  128.  
  129.  
  130. void ThreadHook()
  131. {
  132. DWORD hGfxDx      = (DWORD)GetModuleHandleA("i3GfxDx.dll");
  133. DWORD dwScane     = (DWORD)GetModuleHandleA("i3SceneDx.dll");
  134.     if(hGfxDx)
  135.     {
  136.     DWORD dwDrawPrime       = hGfxDx + 0x62260;
  137.     DWORD ResultSearch      = dwScane+0x69AFF;
  138.     DWORD EndSearch         = *(DWORD*)(ResultSearch + 2);
  139.     DWORD dwPrime           = *(DWORD*)(EndSearch);
  140.  
  141.         if(dwPrime)
  142.         {
  143.             HMODULE hGfxDx    = LoadLibraryA("i3GfxDx.dll");
  144.  
  145.             m_pCaps      = (DWORD)GetProcAddress(hGfxDx,"?m_pCaps@i3RenderContext@@1PAVi3GfxCaps@@A");
  146.             SelectShader = (DWORD)GetProcAddress(hGfxDx,"?SelectShader@i3RenderContext@@QAEXPAVi3Shader@@H@Z");
  147.             xMakePTR((PBYTE)EndSearch,(DWORD)myDrawIndexedPrim2);
  148.         }
  149.     }
  150. }
Advertisement
Add Comment
Please, Sign In to add comment