UnrealSkill-VIP
Gostaria de reagir a esta mensagem? Crie uma conta em poucos cliques ou inicie sessão para continuar.

[Source] Squeenie's Model Logger D3D9

Ir em baixo

[Source] Squeenie's Model Logger D3D9 Empty [Source] Squeenie's Model Logger D3D9

Mensagem por uNreal 9/7/2020, 17:57

main:
Código:
#include <iostream>
#include <Windows.h>
#include <fstream>
#include <math.h>
#include <time.h>
#include "detours.h"
#include <Psapi.h>
#include <TlHelp32.h>
#include <d3d9.h>
#include <d3dx9.h>
#include "DXFuncs.h"
#include "cModel.h"
#pragma comment(lib, "d3d9.lib")
#pragma comment(lib, "d3dx9.lib")
#pragma comment(lib, "detours.lib")
#pragma comment(lib, "Psapi.lib")
#define HOOK(func,addy)   o##func = (t##func)DetourFunction((PBYTE)addy,(PBYTE)m##func)

typedef HRESULT (WINAPI* tEndScene)(LPDIRECT3DDEVICE9 pDevice);
tEndScene oEndScene;

typedef HRESULT (WINAPI* tDrawIndexedPrimitive)(LPDIRECT3DDEVICE9 pDevice, D3DPRIMITIVETYPE PrimType,INT BaseVertexIndex,UINT MinVertexIndex,UINT NumVertices,UINT startIndex,UINT primCount);
tDrawIndexedPrimitive oDrawIndexedPrimitive;

using namespace std;

const int MODELS_TO_LOG = 500;

RECT m_Rect;
LPDIRECT3DTEXTURE9 Red = NULL;
LPDIRECT3DTEXTURE9 Yellow = NULL;
LPDIRECT3DTEXTURE9 Green = NULL;
LPDIRECT3DTEXTURE9 Blue = NULL;
int iSelection = 0;

bool bPopList = false, bDrawElements = false, bAddNew = false;
int iNumElements = 0;
cModel List[MODELS_TO_LOG];
HRESULT WINAPI mEndScene(LPDIRECT3DDEVICE9 pDevice)
{
   m_Rect.left = 10;
   m_Rect.top = 10;
   if(dx_Font == NULL)
      D3DXCreateFont(pDevice, 15, 0, FW_BOLD, 1, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, ANTIALIASED_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Verdana", &dx_Font);

   return oEndScene(pDevice);
}

void ClearList()
{
   char b[32];
   m_Rect.top = 70;
   strcpy(b, "Clearing List");
   dx_Font->DrawTextA(NULL, b, sizeof(b), &m_Rect, DT_NOCLIP, D3DCOLOR_XRGB(0, 0, 255));
   for(int i = 0; i < 100; ++i)
   {
      List[i].NumVertices = 0;
      List[i].primCount = 0;
   }
   iNumElements = 0;
}

HRESULT WINAPI mDrawIndexedPrimitive(LPDIRECT3DDEVICE9 pDevice, D3DPRIMITIVETYPE PrimType,INT BaseVertexIndex,UINT MinVertexIndex,UINT NumVertices,UINT startIndex,UINT primCount)
{
   static int iItems = 0;
   if(GetAsyncKeyState(VK_DELETE)&1)
   {
      iItems = 0;
      iSelection = 0;
      for(int i = 0; i < MODELS_TO_LOG; ++i)
      {
         List[i].NumVertices = -1;
         List[i].primCount = -1;
      }
   }
   if(GetAsyncKeyState(VK_END)&1)
   {
      bDrawElements = !bDrawElements;
   }
   if(GetAsyncKeyState(VK_UP)&1)
   {
      if(iSelection < iItems + 1)
         iSelection++;
   }
   if(GetAsyncKeyState(VK_DOWN)&1)
   {
      if(iSelection > 0)
         iSelection--;
   }


   if(dx_Font == NULL)
      D3DXCreateFont(pDevice, 15, 0, FW_BOLD, 1, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, ANTIALIASED_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Verdana", &dx_Font);
   if(Red == NULL)
      D3DXCreateTextureFromFileInMemory(pDevice, (LPCVOID)&bRed, sizeof(bRed), &Red);
   if(Green == NULL)
      D3DXCreateTextureFromFileInMemory(pDevice, (LPCVOID)&bGreen, sizeof(bGreen), &Green);

   char b[32];

   m_Rect.left = 10;
   m_Rect.top = 30;
   itoa(iSelection, b, 10);
   dx_Font->DrawTextA(NULL, b, strlen(b), &m_Rect, DT_NOCLIP, D3DCOLOR_XRGB(255, 0, 0));

   
   if(bDrawElements)
   {
      m_Rect.top = 50;
      strcpy(b, "Enabled");
      dx_Font->DrawTextA(NULL, b, strlen(b), &m_Rect, DT_NOCLIP, D3DCOLOR_XRGB(0, 0, 255));
   }
   else
   {
      m_Rect.top = 50;
      strcpy(b, "Disabled");
      dx_Font->DrawTextA(NULL, b, strlen(b), &m_Rect, DT_NOCLIP, D3DCOLOR_XRGB(0, 0, 255));
   }

   if(bDrawElements)
   {
      m_Rect.top = 80;
      strcpy(b, itoa(List[iSelection].primCount, b, 10));
      dx_Font->DrawTextA(NULL, b, strlen(b), &m_Rect, DT_NOCLIP, D3DCOLOR_XRGB(0, 0, 255));
      m_Rect.top = 90;
      strcpy(b, itoa(List[iSelection].NumVertices, b, 10));
      dx_Font->DrawTextA(NULL, b, strlen(b), &m_Rect, DT_NOCLIP, D3DCOLOR_XRGB(0, 0, 255));
      if(iItems > 0)
      {
         if(List[iSelection].NumVertices == NumVertices && List[iSelection].primCount == primCount)
         {
            {
               pDevice->SetRenderState( D3DRS_ZENABLE,false );
               pDevice->SetRenderState( D3DRS_FILLMODE,D3DFILL_SOLID );
               pDevice->SetTexture(0, Green);
               oDrawIndexedPrimitive(pDevice, PrimType, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);
               pDevice->SetRenderState( D3DRS_ZENABLE, true );
               pDevice->SetRenderState( D3DRS_FILLMODE,D3DFILL_SOLID );
               pDevice->SetTexture(0, Red);
            }
         }
      }
   }
   
   if( iItems < MODELS_TO_LOG)
   {
      for(int i = 0; i < iItems + 1; ++i)
      {
         if(List[i].NumVertices == NumVertices && List[i].primCount == primCount)
         {
            break;
         }
         if(List[i].NumVertices == -1)
         {
         List[iItems].NumVertices = NumVertices;
         List[iItems].primCount = primCount;
         iItems++;
         break;
         }
      }
      
   }

   return oDrawIndexedPrimitive(pDevice, PrimType, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);
}

void SetHooks()
{
   DWORD table[3] = {0};

   DX_Init(table);

   HOOK(EndScene,table[ES]);
   HOOK(DrawIndexedPrimitive,table[DIP]);   
}

int WINAPI DllThread()
{   
   SetHooks();
   //AllocConsole();
   return 0;
}

BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD Reason, LPVOID lpReserved)
{
   switch(Reason)
   {
   case DLL_PROCESS_ATTACH:
      CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE) DllThread, NULL, NULL, NULL);
      break;
   }
   return true;
}

cModel.h:
Código:
class cModel
{
public:
   int primCount, NumVertices;
};

DXFuncs.h:
Código:
#include <Windows.h>
#include <d3dx9.h>
#include <d3d9.h>

const int ES = 0;
const int DIP = 1;
const int SSS = 2;

ID3DXFont* dx_Font = NULL;

//Credits to Drunken Cheetah
LRESULT CALLBACK MsgProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam){return DefWindowProc(hwnd, uMsg, wParam, lParam);}
void DX_Init(DWORD* table)
{
   WNDCLASSEX wc = {sizeof(WNDCLASSEX),CS_CLASSDC,MsgProc,0L,0L,GetModuleHandle(NULL),NULL,NULL,NULL,NULL,"DX",NULL};
   RegisterClassEx(&wc);
   HWND hWnd = CreateWindow("DX",NULL,WS_OVERLAPPEDWINDOW,100,100,300,300,GetDesktopWindow(),NULL,wc.hInstance,NULL);
   LPDIRECT3D9 pD3D = Direct3DCreate9( D3D_SDK_VERSION );
   D3DPRESENT_PARAMETERS d3dpp;
   ZeroMemory( &d3dpp, sizeof(d3dpp) );
   d3dpp.Windowed = TRUE;
   d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
   d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
   LPDIRECT3DDEVICE9 pd3dDevice;
   pD3D->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hWnd,D3DCREATE_SOFTWARE_VERTEXPROCESSING,&d3dpp,&pd3dDevice);
   DWORD* pVTable = (DWORD*)pd3dDevice;
   pVTable = (DWORD*)pVTable[0];

   table[ES]   = pVTable[42];
   table[DIP]   = pVTable[82];
   table[SSS]   = pVTable[100];

   DestroyWindow(hWnd);
}

void DrawFilledBox(ID3DXLine* pLine, int x, int y, int w, int h, int r, int g, int b, int a)
{
    D3DXVECTOR2 vLine[2];

    pLine->SetWidth( w );
    pLine->SetAntialias( false );
    pLine->SetGLLines( true );
   
    vLine[0].x = x + w/2;
    vLine[0].y = y;
    vLine[1].x = x + w/2;
    vLine[1].y = y + h;

    pLine->Begin( );
    pLine->Draw( vLine, 2, D3DCOLOR_RGBA( r, g, b, a ) );
    pLine->End( );
}

void DrawLine(ID3DXLine* pLine, float StartX, float StartY, float EndX, float EndY, int w, int r, int g, int b, int a)
{
   

    D3DXVECTOR2 vLine[2];

    pLine->SetWidth( w );
    pLine->SetAntialias( false );
    pLine->SetGLLines( true );
   
    vLine[0].x = StartX;
    vLine[0].y = StartY;
    vLine[1].x = EndX;
    vLine[1].y = EndY;

    pLine->Begin( );
    pLine->Draw( vLine, 2, D3DCOLOR_RGBA( r, g, b, a ) );
    pLine->End( );
}

void DrawBox(ID3DXLine* pLine, int x, int y, int width, int height, int px, int r, int g, int b, int a)
{
    DrawFilledBox(pLine, x,y+height,width,px,r,g,b,a);
    DrawFilledBox(pLine, x-px,y,px,height,r,g,b,a);
    DrawFilledBox(pLine, x,y-px,width,px,r,g,b,a);
    DrawFilledBox(pLine, x+width,y,px,height,r,g,b,a);
}

void DrawString(int x, int y, DWORD color, const char *fmt, ...)
{
   RECT FontPos = { x, y, x + 120, y + 16 };
   char buf[1024] = {'\0'};
   va_list va_alist;

   va_start(va_alist, fmt);
   vsprintf(buf, fmt, va_alist);
   va_end(va_alist);
   
   dx_Font->DrawText(NULL, buf, -1, &FontPos, DT_NOCLIP, color);
}

const BYTE bPink[] =
{
0x89,0x50,0x4E,0x47,0xD,0xA,0x1A,0xA,0x0,0x0,
0x0,0xD,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x1,
0x0,0x0,0x0,0x1,0x8,0x2,0x0,0x0,0x0,0x90,
0x77,0x53,0xDE,0x0,0x0,0x0,0x1,0x73,0x52,0x47,
0x42,0x0,0xAE,0xCE,0x1C,0xE9,0x0,0x0,0x0,0x4,
0x67,0x41,0x4D,0x41,0x0,0x0,0xB1,0x8F,0xB,0xFC,
0x61,0x5,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,
0x0,0x0,0xE,0xC3,0x0,0x0,0xE,0xC3,0x1,0xC7,
0x6F,0xA8,0x64,0x0,0x0,0x0,0xC,0x49,0x44,0x41,
0x54,0x18,0x57,0x63,0xF8,0xC7,0xFE,0xF,0x0,0x4,
0xA,0x2,0x4,0x4,0x9,0x62,0x3E,0x0,0x0,0x0,
0x0,0x49,0x45,0x4E,0x44,0xAE,0x42,0x60,0x82
};

const BYTE bRed[] =
{
0x42, 0x4D, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x36, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01,
0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x12, 0x0B, 0x00, 0x00, 0x12, 0x0B, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xFF, 0x00, 0x00, 0x50};

const BYTE bGreen[] =
{
0x89,0x50,0x4E,0x47,0xD,0xA,0x1A,0xA,0x0,0x0,
0x0,0xD,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x1,
0x0,0x0,0x0,0x1,0x8,0x2,0x0,0x0,0x0,0x90,
0x77,0x53,0xDE,0x0,0x0,0x0,0x1,0x73,0x52,0x47,
0x42,0x0,0xAE,0xCE,0x1C,0xE9,0x0,0x0,0x0,0x4,
0x67,0x41,0x4D,0x41,0x0,0x0,0xB1,0x8F,0xB,0xFC,
0x61,0x5,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,
0x0,0x0,0xE,0xC3,0x0,0x0,0xE,0xC3,0x1,0xC7,
0x6F,0xA8,0x64,0x0,0x0,0x0,0xC,0x49,0x44,0x41,
0x54,0x18,0x57,0x63,0x10,0xF9,0xC0,0xF,0x0,0x2,
0x2F,0x1,0x14,0xC0,0x8B,0x46,0xFD,0x0,0x0,0x0,
0x0,0x49,0x45,0x4E,0x44,0xAE,0x42,0x60,0x82
};

const BYTE bBlue[60] =
{
0x42, 0x4D, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x36, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01,
0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x12, 0x0B, 0x00, 0x00, 0x12, 0x0B, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xFF, 0x00, 0x00, 0x00, 0x00, 0x00
};

const BYTE bWhite[] =
{
0x89,0x50,0x4E,0x47,0xD,0xA,0x1A,0xA,0x0,0x0,
0x0,0xD,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x1,
0x0,0x0,0x0,0x1,0x8,0x2,0x0,0x0,0x0,0x90,
0x77,0x53,0xDE,0x0,0x0,0x0,0x1,0x73,0x52,0x47,
0x42,0x0,0xAE,0xCE,0x1C,0xE9,0x0,0x0,0x0,0x4,
0x67,0x41,0x4D,0x41,0x0,0x0,0xB1,0x8F,0xB,0xFC,
0x61,0x5,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,
0x0,0x0,0xE,0xC3,0x0,0x0,0xE,0xC3,0x1,0xC7,
0x6F,0xA8,0x64,0x0,0x0,0x0,0xC,0x49,0x44,0x41,
0x54,0x18,0x57,0x63,0xF8,0xFF,0xFF,0x3F,0x0,0x5,
0xFE,0x2,0xFE,0xA7,0x35,0x81,0x84,0x0,0x0,0x0,
0x0,0x49,0x45,0x4E,0x44,0xAE,0x42,0x60,0x82
};

const BYTE bOrange[] =
{
0x89,0x50,0x4E,0x47,0xD,0xA,0x1A,0xA,0x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cheetah & squeenie
uNreal
uNreal
ADM
ADM


Voltar ao Topo Ir em baixo

Voltar ao Topo


 
Permissão neste fórum:
Você não pode responder aos tópicos neste fórum