设为首页收藏本站

鑫郁飞网络技术-郁金香灬外挂技术

 找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

郁金香 外挂开发(实战)郁金香 终身VIP 尊贵特权郁金香 VIP学员办理任鸟飞2015外挂教程
◆求市场玩家辅助销售代理权◆论坛VIP会员账号郁金香游戏外挂制作 终极教程   ◆求市场玩家辅助销售代理权◆
查看: 766|回复: 11

D3D游戏透视 人物上色代码 d3d菜单 人物 线条绘制

  [复制链接]
发表于 2016-9-30 13:19:19 | 显示全部楼层 |阅读模式
本帖最后由 CPrime 于 2016-9-30 13:21 编辑

#include
#include
#include
#include
#pragma comment (lib, "d3d9.lib")
#pragma comment(lib, "d3dx9.lib")
LPDIRECT3DDEVICE9 pDevice;
ID3DXLine *pLine;
IDirect3DTexture9 *texRed;
IDirect3DTexture9 *texGreen;
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 hkPressF4=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; 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.1def c0, %f, %f, %f, %fmov 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 )
{
    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 );
if(zimu)
{
DrawFont ( 30, 50, D3DCOLOR_ARGB(255,0,255,0), "透视辅助" );
DrawFont ( 50, 70, D3DCOLOR_ARGB(255,0,255,0), "F2 十字准星" );
DrawFont ( 50, 90, D3DCOLOR_ARGB(255,0,255,0), "F3 人物透视" );
DrawFont ( 50, 110, D3DCOLOR_ARGB(255,0,255,0), "F4 人物上色" );
DrawFont ( 50, 130, D3DCOLOR_ARGB(255,0,255,0), "F5 人物线条" );
DrawFont ( 25, 150, D3DCOLOR_ARGB(255,0,255,0), "Home键开启/关闭菜单" );
}
//游戏字幕
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);
   pDrawIndexedPrimitive(pDevice, Type, BaseVertexIndex, MinIndex, NumVertices, StartIndex,
PrimitiveCount);
   pDevice->SetRenderState(D3DRS_ZENABLE,true);
  }
}
     if (hkPressF4) //人物上色,请回复以示支持哈,回复后显示 上色代码
游客,如果您要查看本帖隐藏内容请回复

//-----

        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 )
{
  
  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);
  for (;;Sleep (1))
{
  if (GetAsyncKeyState (VK_F2)&1)
  {
   Xhair= !Xhair;
  }
  if (GetAsyncKeyState (VK_F3)&1)     
  {
   hack2 = !hack2;
  }
  if (GetAsyncKeyState (VK_F4)&1)
  {
            hkPressF4 = !hkPressF4;
  }
  if (GetAsyncKeyState (VK_F5)&1)
  {
   hack4 = !hack4;
  }
  if (GetAsyncKeyState (VK_HOME)&1)
  {
   zimu = !zimu;
  }
}
return FALSE;
}

郁金香外挂教程,学习中...
回复

使用道具 举报

发表于 2016-10-5 06:42:07 | 显示全部楼层
看看学习一下
郁金香外挂教程,学习中...
回复 支持 反对

使用道具 举报

发表于 2016-10-6 09:02:14 | 显示全部楼层

看看学习一下   学习
郁金香外挂教程,学习中...
回复 支持 反对

使用道具 举报

发表于 2016-10-6 09:43:15 | 显示全部楼层
学习一下
郁金香外挂教程,学习中...
回复

使用道具 举报

发表于 2016-10-6 21:26:51 | 显示全部楼层
代码好长
郁金香外挂教程,学习中...
回复

使用道具 举报

发表于 2016-10-9 03:05:23 | 显示全部楼层
支持一下,
郁金香外挂教程,学习中...
回复

使用道具 举报

发表于 2016-10-18 22:56:04 | 显示全部楼层
支持一下大神..
郁金香外挂教程,学习中...
回复 支持 反对

使用道具 举报

发表于 2016-10-19 12:57:25 | 显示全部楼层
厉害了我的哥
郁金香外挂教程,学习中...
回复 支持 反对

使用道具 举报

发表于 2016-11-2 17:49:21 | 显示全部楼层
谢谢楼主,我拿去研究研究。
郁金香外挂教程,学习中...
回复 支持 反对

使用道具 举报

发表于 2016-11-2 17:50:29 | 显示全部楼层
等滴答滴答滴答滴答滴答滴答滴答滴答滴答滴答滴答滴答滴
郁金香外挂教程,学习中...
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|小黑屋|鑫郁飞网络技术-郁金香灬老师 ( 苏ICP备10059359号   

GMT+8, 2017-5-23 09:15 , Processed in 0.451360 second(s), 26 queries .

Powered by Discuz! X3.2 Licensed

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表