|
发表于 2023-2-1 21:05:40
|
查看: 8106 |
回复: 0
- #include <Windows.h>
- #include <d3d9.h>
- #include <d3dx9.h>
- #include <cstdio>
-
- #pragma comment (lib, "d3d9.lib")
- #pragma comment(lib, "d3dx9.lib")
- LPDIRECT3DDEVICE9 pDevice;
- ID3DXLine *pLine;
- IDirect3DTexture9 *texRed;
- IDirect3DTexture9 *texGreen;
- IDirect3DPixelShader9 *Front,
- *Back;
- bool shangse=true;
- bool Xhair=false;
- static LPD3DXFONT m_pFont1 = NULL;
- BOOL FontCreated=false;
- int a=10;
- bool WallHack=false;
- bool zimu=true;
- bool hack2=1;
- bool hack3=0;
- bool hack4=0;
- bool xiantiao=false;
- HRESULT GenerateTexture(IDirect3DDevice9 *pD3Ddev, IDirect3DTexture9 **ppD3Dtex, DWORD colour32)
- {
- if( FAILED(pD3Ddev->CreateTexture(8, 8, 1, 0, D3DFMT_A4R4G4B4, D3DPOOL_MANAGED, ppD3Dtex,NULL)) )
- return E_FAIL;
- WORD colour16 = ((WORD)((colour32>>28)&0xF)<<12)
- |(WORD)(((colour32>>20)&0xF)<<8)
- |(WORD)(((colour32>>12)&0xF)<<4)
- |(WORD)(((colour32>>4)&0xF)<<0);
- D3DLOCKED_RECT d3dlr;
- (*ppD3Dtex)->LockRect(0, &d3dlr, 0, 0);
- WORD *pDst16 = (WORD*)d3dlr.pBits;
- for(int xy=0; xy < 8*8; xy++)
- *pDst16++ = colour16;
- (*ppD3Dtex)->UnlockRect(0);
- return S_OK;
- }
- void InitObjects( IDirect3DDevice9 * pDevice )
- {
- if(!FontCreated){
- D3DXCreateFont( pDevice, 12, 0, FW_NORMAL, 1, 0, DEFAULT_CHARSET, OUT_DEVICE_PRECIS, ANTIALIASED_QUALITY, FF_DONTCARE | DEFAULT_PITCH, "Visitor TT2 (BRK)", &m_pFont1 );
- FontCreated=true;
- }
- }
- void SetLightChams(float A, float R, float G, float B, IDirect3DDevice9 *pDevice)
- {
- D3DMATERIAL9 pMaterial;
- ZeroMemory(&pMaterial, sizeof(D3DMATERIAL9));
- pDevice->SetRenderState(D3DRS_LIGHTING, TRUE); //Enable Lighting
- //Ambient
- pMaterial.Ambient.a = (A/255);
- pMaterial.Ambient.r = (R/255);
- pMaterial.Ambient.g = (G/255);
- pMaterial.Ambient.b = (B/255);
- //Diffuse
- pMaterial.Diffuse.a = (A/255);
- pMaterial.Diffuse.r = (R/255);
- pMaterial.Diffuse.g = (G/255);
- pMaterial.Diffuse.b = (B/255);
- //Specular
- pMaterial.Specular.a = (A/255);
- pMaterial.Specular.r = (R/255);
- pMaterial.Specular.g = (G/255);
- pMaterial.Specular.b = (B/255);
- pDevice->SetMaterial(&pMaterial);
- }
- void DrawFont (int X, int Y, D3DCOLOR Color, char *format, ...)
- {
- char buffer[256];
- va_list args;
- va_start (args, format);
- vsprintf (buffer,format, args);
- RECT FontRect = { X, Y, X + 120, Y + 16 };
- m_pFont1->DrawText( NULL, buffer, -1, &FontRect, DT_NOCLIP , Color );
- va_end (args);
- }
- void *DetourFunction(BYTE *src, const BYTE *dst, const int len)
- {
- BYTE *jmp = (BYTE*)malloc(len+5);
- DWORD dwBack;
- VirtualProtect(src, len, PAGE_EXECUTE_READWRITE, &dwBack);
- memcpy(jmp, src, len);
- jmp += len;
- jmp[0] = 0xE9;
- *(DWORD*)(jmp+1) = (DWORD)(src+len - jmp) - 5;
- src[0] = 0xE9;
- *(DWORD*)(src+1) = (DWORD)(dst - src) - 5;
- for (int i=5; i<len; i++) src=0x90;
- VirtualProtect(src, len, dwBack, &dwBack);
- return (jmp-len);
- }
- void FillRGB( int x, int y, int w, int h, D3DCOLOR color, IDirect3DDevice9* pDevice )
- {
- D3DRECT rec = { x, y, x + w, y + h };
- pDevice->Clear( 1, &rec, D3DCLEAR_TARGET, color, 0, 0 );
- }
- HRESULT CreateMyShader(IDirect3DPixelShader9 **pShader, IDirect3DDevice9 *Device, float red, float green, float blue, float alpha )
- {
- ID3DXBuffer *MyBuffer = NULL;
- char MyShader[ 256 ];
- sprintf( MyShader, "ps.1.1\ndef c0, %f, %f, %f, %f\nmov r0,c0", red/255, green/255, blue/255, alpha/255 );
- D3DXAssembleShader( MyShader, sizeof( MyShader ), NULL, NULL, 0, &MyBuffer , NULL );
- if( FAILED( Device->CreatePixelShader((const DWORD*)MyBuffer ->GetBufferPointer(), pShader)) )return E_FAIL;
- return S_OK;
- }
- DWORD WINAPI dwWaitThread( LPVOID lpArgs );
- typedef HRESULT(WINAPI* DrawIndexedPrimitive_)(LPDIRECT3DDEVICE9 pDevice, D3DPRIMITIVETYPE Type, INT BaseVertexIndex, UINT MinIndex, UINT NumVertices, UINT StartIndex, UINT PrimitiveCount);
- DrawIndexedPrimitive_ pDrawIndexedPrimitive;
- typedef HRESULT ( WINAPI *EndScene_)( IDirect3DDevice9 * pDevice );
- EndScene_ pEndScene;
- typedef HRESULT ( WINAPI *CreateQuery_)(LPDIRECT3DDEVICE9 pDevice, D3DQUERYTYPE Type,IDirect3DQuery9** ppQuery);
- CreateQuery_ pCreateQuery;
- HRESULT WINAPI hkCreateQuery(LPDIRECT3DDEVICE9 pDevice, D3DQUERYTYPE Type,IDirect3DQuery9** ppQuery)
- {
- if( Type == D3DQUERYTYPE_OCCLUSION )
- {
- Type = D3DQUERYTYPE_TIMESTAMP;
- }
- return pCreateQuery( pDevice, Type, ppQuery );
- }
- HRESULT WINAPI hkEndScene( IDirect3DDevice9 * pDevice )
- {
- //HWND hwnd1;
- //hwnd1=FindWindow (TEXT("透视程序"),TEXT("透视程序"));
- //if(hwnd1==0)
- //{
- // MessageBox( NULL, "透视EXE程序不存在,调用注意走路掉进下水道!", "", MB_ICONERROR | MB_ICONSTOP );
- // ExitProcess(0);
- //}
- if (shangse)
- {
- GenerateTexture(pDevice, &texRed,D3DCOLOR_ARGB(255,255,0,0));//上色背景 红
- GenerateTexture(pDevice, &texGreen,D3DCOLOR_ARGB(255,0,255,0));//上色背景 绿
- shangse=false;
- }
- //CreateMyShader( &Front, pDevice, 255, 0, 0, 255 );
- //CreateMyShader( &Back, pDevice, 255, 255, 0, 255 );
- InitObjects( pDevice );
- DrawFont ( 3, 10, D3DCOLOR_ARGB(255,238,17,216), "逆战 透视程序" );//238,17,216
- // ..........
- if(zimu)
- {
- //DrawFont ( 5, 30, D3DCOLOR_ARGB(255,0,255,0), "" );
- DrawFont ( 5, 50, D3DCOLOR_ARGB(255,0,255,0), "1键 完美准星" );
- DrawFont ( 5, 70, D3DCOLOR_ARGB(255,0,255,0), "2键 人物透视" );
- DrawFont ( 5, 90, D3DCOLOR_ARGB(255,0,255,0), "3键 人物上色" );
- DrawFont ( 5, 110, D3DCOLOR_ARGB(255,0,255,0), "透视程序 " );
- //DrawFont ( 5, 90, D3DCOLOR_ARGB(255,0,255,0), "4 人物线条" );
- DrawFont ( 5, 130, D3DCOLOR_ARGB(255,0,255,0), "END键开启/关闭提示菜单" );
- }
- //游戏字幕
- if (Xhair)
- {
- //准星
- D3DVIEWPORT9 gViewPort;
- pDevice->GetViewport(&gViewPort);
- float ScreenCenterX = ( float )gViewPort.Width / 2;
- float ScreenCenterY = ( float )gViewPort.Height / 2;
- FillRGB(ScreenCenterX-20, ScreenCenterY, 40, 1,D3DCOLOR_ARGB(255,71,65,64),pDevice);//Purple
- FillRGB(ScreenCenterX, ScreenCenterY-20, 1, 40,D3DCOLOR_ARGB(255,71,65,64),pDevice);
- FillRGB(ScreenCenterX-17, ScreenCenterY, 34, 1,D3DCOLOR_ARGB(255,0,0,255),pDevice);//Blue
- FillRGB(ScreenCenterX, ScreenCenterY-17, 1, 34,D3DCOLOR_ARGB(255,0,0,255),pDevice);
- FillRGB(ScreenCenterX-14, ScreenCenterY, 28, 1,D3DCOLOR_ARGB(255,255,240,0),pDevice);//Cyan
- FillRGB(ScreenCenterX, ScreenCenterY-14, 1, 28,D3DCOLOR_ARGB(255,255,240,0),pDevice);
- FillRGB(ScreenCenterX-11, ScreenCenterY, 22, 1,D3DCOLOR_ARGB(255,0,255,0),pDevice);//Green
- FillRGB(ScreenCenterX, ScreenCenterY-11, 1, 22,D3DCOLOR_ARGB(255,0,255,0),pDevice);
- FillRGB(ScreenCenterX-9, ScreenCenterY, 18, 1,D3DCOLOR_ARGB(255,255,255,0),pDevice);//Yellow
- FillRGB(ScreenCenterX, ScreenCenterY-9, 1, 18,D3DCOLOR_ARGB(255,255,255,0),pDevice);
- FillRGB(ScreenCenterX-6, ScreenCenterY, 12, 1,D3DCOLOR_ARGB(255,198,255,0),pDevice);//Orange
- FillRGB(ScreenCenterX, ScreenCenterY-6, 1, 12,D3DCOLOR_ARGB(255,198,255,0),pDevice);
- FillRGB(ScreenCenterX-3, ScreenCenterY, 6, 1,D3DCOLOR_ARGB(255,255,0,0),pDevice);//Red
- FillRGB(ScreenCenterX, ScreenCenterY-3, 1, 6,D3DCOLOR_ARGB(255,255,0,0),pDevice);
- }
- return ( *pEndScene )( pDevice );
- }
- HRESULT WINAPI nDrawIndexedPrimitive(LPDIRECT3DDEVICE9 pDevice, D3DPRIMITIVETYPE Type, INT BaseVertexIndex, UINT MinIndex,UINT NumVertices, UINT StartIndex, UINT PrimitiveCount)
- {
- IDirect3DVertexBuffer9* pStreamData = NULL;
- UINT iOffsetInBytes,iStride;
- pDevice->GetStreamSource(0,&pStreamData,&iOffsetInBytes,&iStride);
- // if (GetAsyncKeyState (VK_F6)&1)
- // {
- // a++;
- // }
- // if (GetAsyncKeyState (VK_F7)&1)
- //{
- // a--;
- // }
- DWORD dwOldZEnable = D3DZB_TRUE;
- if (hack2)
- {
- if(iStride==32)
- {
- pDevice->SetRenderState(D3DRS_ZENABLE,false);
- pDevice->SetRenderState(D3DRS_ZENABLE,true);
- DWORD dwOldZEnable;
- pDevice->GetRenderState(D3DRS_ZENABLE,&dwOldZEnable);
- pDevice->SetRenderState(D3DRS_ZENABLE,D3DZB_FALSE);
- pDevice->SetRenderState(D3DRS_ZFUNC,D3DCMP_NEVER);
- pDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
- pDrawIndexedPrimitive(pDevice, Type, BaseVertexIndex, MinIndex, NumVertices, StartIndex, PrimitiveCount);
- pDevice->SetRenderState(D3DRS_ZENABLE,dwOldZEnable);
- pDevice->SetRenderState(D3DRS_ZFUNC,D3DCMP_LESSEQUAL);
- pDrawIndexedPrimitive(pDevice, Type, BaseVertexIndex, MinIndex, NumVertices, StartIndex, PrimitiveCount);
- }
- }
- if (hack3)
- {
- if(iStride==32)
- {
- DWORD dwOldZEnable;
- pDevice->SetTexture(0,NULL);
- pDevice->SetPixelShader( Front );
- pDevice->SetTexture( 0, texGreen);
- pDevice->GetRenderState(D3DRS_ZENABLE,&dwOldZEnable);
- pDevice->SetRenderState(D3DRS_ZENABLE,D3DZB_FALSE);
- pDevice->SetRenderState(D3DRS_ZFUNC,D3DCMP_NEVER);
- pDrawIndexedPrimitive(pDevice, Type, BaseVertexIndex, MinIndex, NumVertices, StartIndex, PrimitiveCount);
- pDevice->SetRenderState(D3DRS_ZENABLE,dwOldZEnable);
- pDevice->SetRenderState(D3DRS_ZFUNC,D3DCMP_LESSEQUAL);
- pDevice->SetTexture( 0, texRed);
- pDevice->SetPixelShader( Back );
- pDevice->SetRenderState(D3DRS_ZENABLE,false);
- SetLightChams(255,60,73,196, pDevice);
- pDevice->SetTexture( 0, texGreen);
- pDrawIndexedPrimitive(pDevice, Type, BaseVertexIndex, MinIndex, NumVertices, StartIndex, PrimitiveCount);
- pDevice->SetRenderState(D3DRS_ZENABLE,true);
- pDevice->SetTexture( 0, texRed);
- SetLightChams(255,255,0,255, pDevice);
- }
- }
- if (hack4)
- {
- if (iStride==32)
- {
- pDevice->SetRenderState( D3DRS_FILLMODE, D3DFILL_WIREFRAME );
- pDrawIndexedPrimitive(pDevice, Type, BaseVertexIndex, MinIndex, NumVertices, StartIndex, PrimitiveCount);
- pDevice->SetRenderState( D3DRS_FILLMODE, D3DFILL_WIREFRAME );
- }
-
- }
- return pDrawIndexedPrimitive(pDevice, Type, BaseVertexIndex, MinIndex, NumVertices, StartIndex, PrimitiveCount);
- }
- void InitDevice( DWORD * dwVTable )
- {
- LPDIRECT3D9 pD3d9 = NULL;
- LPDIRECT3DDEVICE9 pD3DDevice = NULL;
- pD3d9 = Direct3DCreate9( D3D_SDK_VERSION );
- if ( pD3d9 == NULL )
- {
- MessageBox( NULL, "[ERROR] Direct3DCreate9 Failed", "Fatal Error", MB_ICONERROR | MB_ICONSTOP );
- return;
- }
- D3DPRESENT_PARAMETERS pPresentParms;
- ZeroMemory( &pPresentParms, sizeof( pPresentParms ));
- pPresentParms.Windowed = TRUE;
- pPresentParms.BackBufferFormat = D3DFMT_UNKNOWN;
- pPresentParms.SwapEffect = D3DSWAPEFFECT_DISCARD;
- if ( FAILED ( pD3d9->CreateDevice ( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, GetDesktopWindow(), D3DCREATE_SOFTWARE_VERTEXPROCESSING, &pPresentParms, &pD3DDevice )))
- {
- MessageBox( NULL, "[ERROR] CreateDevice Failed", "Fatal Error", MB_ICONERROR | MB_ICONSTOP );
- return;
- }
- DWORD * dwTable = ( DWORD* ) pD3DDevice;
- dwTable = ( DWORD* ) dwTable[0];
- dwVTable[0] = dwTable[82];
- dwVTable[1] = dwTable[42];
- dwVTable[2] = dwTable[118];
- }
- BOOL APIENTRY DllMain( HMODULE hModule, DWORD dwReason, LPVOID lpReserved )
- {
- if ( dwReason == DLL_PROCESS_ATTACH )
- {
- //if ()
- //{
- //MessageBox( NULL, "没检测到透视综合社区EXE进程,DLL与EXE对接失败.!", "系统提示:", MB_ICONERROR | MB_ICONSTOP );
- //exit(0);//未检测到透视EXE数据验证.
- //}
- CreateThread( NULL, NULL, &dwWaitThread, NULL, NULL, NULL );
- }
- return TRUE;
- }
- DWORD WINAPI dwWaitThread( LPVOID lpArgs )
- {
- DWORD dwD3d9 = NULL;
- while ( !dwD3d9 )
- {
- Sleep(1);
- dwD3d9 = ( DWORD ) GetModuleHandle( "D3d9.dll" );
- }
- DWORD dwVTable[2] = {0};
- InitDevice( dwVTable );
- pDrawIndexedPrimitive=(DrawIndexedPrimitive_) DetourFunction(( PBYTE ) dwVTable[0], ( PBYTE ) &nDrawIndexedPrimitive,12);
- pEndScene=(EndScene_) DetourFunction(( PBYTE ) dwVTable[1], ( PBYTE ) &hkEndScene,5);
- pCreateQuery=(CreateQuery_)DetourFunction(( PBYTE ) dwVTable[2], ( PBYTE ) &hkCreateQuery,5);
- Xhair= !Xhair;
- for (;;Sleep (1))
- {
- if (GetAsyncKeyState (VK_NUMPAD1)&1)
- {
- Xhair= !Xhair;//准星
- }
- if (GetAsyncKeyState (VK_NUMPAD2)&1)
- {
- hack2 = !hack2;//人物透视
- }
- if (GetAsyncKeyState (VK_NUMPAD3)&1)
- {
- hack3 = !hack3;//人物上色
- }
- if (GetAsyncKeyState (VK_NUMPAD4)&1)
- {
- MessageBox( NULL, "[ERROR]此功能暂不开放.", "透视提示:", MB_ICONERROR | MB_ICONSTOP );
- //hack4 = !hack4;//人物线条
- }
- if (GetAsyncKeyState (VK_END)&1)
- {
- zimu = !zimu;//字幕
- }
- }
- return FALSE;
- }
复制代码
|
游戏安全课程 学员办理咨询联系QQ150330575 手机 139 9636 2600 免费课程 在 www.bilibili.com 搜 郁金香灬老师
|
|