PostD3D Stride Logger 2013

Posts 1–5 of 5 · Page 1 of 1
D3D Stride Logger 2013
This is Zooom stride logger based on getting all base textures in a stride
and iterating through them then setting texture and log the model rec.

Produces very accurate model rec.

Sample result:
 
Code:
Log
(BaseIndex == 0 && MinIndex == 0 && NumVertices == 3124 && StartIndex == 992568 && PrimitiveCount == 4132 && Stride == 32)
(BaseIndex == 0 && MinIndex == 0 && NumVertices == 1970 && StartIndex == 1006096 && PrimitiveCount == 2186 && Stride == 32)
(BaseIndex == 0 && MinIndex == 0 && NumVertices == 470 && StartIndex == 1016712 && PrimitiveCount == 352 && Stride == 32)
(BaseIndex == 0 && MinIndex == 0 && NumVertices == 1252 && StartIndex == 1013232 && PrimitiveCount == 1160 && Stride == 32)


How to use:
1 Choose Stride
2 Increase Tex num until you get your desired texture colored.
3 Enable log.
4 Run circles around player or whatever with increasing radius or play game.
5 Adjust Tex num more to find both close and far range model rec or whatever.

Whenever a model rec has been logged already it will not log it again making it faster to find what your looking for.

Credits:
Zooom

 
Code:
#include <windows.h>
#include <fstream>
#include <stdio.h>
#include <vector>

#include <d3d9.h>
#include <d3dx9.h>

#pragma comment( lib, "d3d9.lib" )
#pragma comment( lib, "d3dx9.lib" )
#pragma warning( disable : 4996 )

using namespace std;
//-------------------------------------------------------------------

typedef struct _STRIDELOG{
INT Base; UINT Min;
UINT Num; UINT Start;
UINT Prim;
}STRIDELOG,*PSTRIDELOG;

HRESULT ( WINAPI* oReset )
( LPDIRECT3DDEVICE9, D3DPRESENT_PARAMETERS* );

HRESULT ( WINAPI* oEndScene )
( LPDIRECT3DDEVICE9 );

HRESULT ( WINAPI* oDrawIdP )
( LPDIRECT3DDEVICE9, D3DPRIMITIVETYPE,
INT, UINT, UINT, UINT, UINT );

STRIDELOG StrideLog;
vector<STRIDELOG> STRIDE;
vector<DWORD> BASETEX;
LPDIRECT3DBASETEXTURE9 BTEX = NULL;
LPDIRECT3DTEXTURE9 Green = NULL;
LPD3DXFONT pFont = NULL;
D3DVIEWPORT9 Vpt;
D3DLOCKED_RECT d3dlr;
ofstream ofile;
char dlldir[320];
char strbuff[260];
UINT iStride = 0;
UINT iBaseTex = 0;
bool Found = false;
bool Startlog = false;

void __cdecl add_log
(const char *fmt, ...);

//-------------------------------------------------------------------

PVOID WINAPI DetourFunc
( PBYTE Src, PBYTE Dst, INT len )
{
DWORD dwback;
PBYTE jmp = (PBYTE)malloc(len+5);

VirtualProtect( Src, len, 0x04, &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;

VirtualProtect( Src, len, dwback, &dwback );

return (jmp-len);
}

//-------------------------------------------------------------------

HRESULT WINAPI nDrawIdP
( LPDIRECT3DDEVICE9 pDev, D3DPRIMITIVETYPE Type,
INT Base, UINT Min, UINT Num, UINT Start, UINT Prim )
{
LPDIRECT3DVERTEXBUFFER9 Stream_Data;
UINT Offset = 0;
UINT Stride = 0;

if(pDev->GetStreamSource
( 0, &Stream_Data, &Offset, &Stride )==S_OK)
Stream_Data->Release();

if(Stride == iStride)
{
pDev->GetTexture( 0, &BTEX );
Found = false;

for( UINT i = 0;i < BASETEX.size();i++ )
if( BASETEX[i] == (DWORD)BTEX )
Found = true;

if( Found == false )
BASETEX.push_back
( (DWORD)BTEX );

if( BASETEX[iBaseTex] == (DWORD)BTEX && Green )
{
pDev->SetTexture( 0, Green );
pDev->SetRenderState( D3DRS_ZENABLE, FALSE );
oDrawIdP( pDev, Type, Base, Min, Num, Start, Prim );
pDev->SetRenderState( D3DRS_ZENABLE, TRUE );

if( Startlog == true )
{
Found = false;
for( UINT i = 0;i < STRIDE.size();i++ )
if( STRIDE[i].Base == Base )
if( STRIDE[i].Min == Min )
if( STRIDE[i].Num == Num )
if( STRIDE[i].Start == Start )
if( STRIDE[i].Prim == Prim )
Found = true;

if( Found == false )
{
StrideLog.Base = Base;
StrideLog.Min = Min;
StrideLog.Num = Num;
StrideLog.Start = Start;
StrideLog.Prim = Prim;

sprintf( strbuff, "(BaseIndex == %i && MinIndex == %i && NumVertices == %i && " \
"StartIndex == %i && PrimitiveCount == %i && Stride == %i)", \
Base, Min, Num, Start, Prim, Stride );


add_log( strbuff );

STRIDE.push_back
( StrideLog );
}
}
}
}

return oDrawIdP( pDev, Type,
Base, Min, Num, Start, Prim );
}

//-------------------------------------------------------------------

HRESULT WINAPI nEndScene
( LPDIRECT3DDEVICE9 pDev )
{
pDev->GetViewport( &Vpt );

RECT FRect = { Vpt.Width-250,Vpt.Height-300,
Vpt.Width,Vpt.Height };

if( Green == NULL )
if( pDev->CreateTexture(8, 8, 1, 0, D3DFMT_A8R8G8B8,
D3DPOOL_MANAGED, &Green, NULL) == S_OK)
if( Green->LockRect( 0, &d3dlr, 0, D3DLOCK_DONOTWAIT |
D3DLOCK_NOSYSLOCK ) == S_OK )
{
for(UINT xy=0; xy < 8*8; xy++)
((PDWORD)d3dlr.pBits)[xy] = 0xFF00FF00;

Green->UnlockRect( 0 );
}

if( pFont == NULL )
D3DXCreateFontA( pDev, 16, 0, 700, 0, 0, 1, 0,
0, DEFAULT_PITCH | FF_DONTCARE, "Calibri", &pFont );

sprintf( strbuff, "Num of Textures: %i\nStride: %i\nBase Tex Num: %i\n\nSTRIDE LOGGER V1\n\n" \
"Log Enable: %i\n\nNUM1: Stride++\nNUM2: Stride--\nNUM3: BaseTexNum++" \
"\nNUM4: BaseTexNum--\nNUM0: Log On/Off", \
BASETEX.size(), iStride, iBaseTex + 1, Startlog );

if( pFont )
pFont->DrawTextA( 0, strbuff, -1, &FRect,
DT_CENTER|DT_NOCLIP, 0xFF00FF00);

if( GetAsyncKeyState( VK_NUMPAD1 ) &1 )
{iStride++;BASETEX.clear();iBaseTex = 0;}

if( GetAsyncKeyState( VK_NUMPAD2 ) &1 )
if( iStride > 0 )
{iStride--;BASETEX.clear();iBaseTex = 0;};

if( GetAsyncKeyState( VK_NUMPAD3 ) &1 )
if(iBaseTex < BASETEX.size() - 1)iBaseTex++;

if( GetAsyncKeyState( VK_NUMPAD4 ) &1 )
if( iBaseTex > 0 )
iBaseTex--;

if( GetAsyncKeyState( VK_NUMPAD0 ) &1 )
{Startlog = !Startlog;STRIDE.clear();}

return oEndScene( pDev );
}

//-------------------------------------------------------------------

HRESULT WINAPI nReset
( LPDIRECT3DDEVICE9 pDev,
D3DPRESENT_PARAMETERS* PresP )
{
if( pFont ) {pFont->Release();pFont = NULL;}

return oReset( pDev, PresP );
}

//-------------------------------------------------------------------

VOID WINAPI THREAD( )
{
DWORD D3D9DLL = NULL;

while( D3D9DLL== NULL )
{
D3D9DLL = (DWORD)
GetModuleHandleA( "d3d9.dll" );
Sleep( 100 );
}

if( D3D9DLL != NULL )
{
*(PDWORD)&oEndScene = (DWORD)DetourFunc
( PBYTE(D3D9DLL + 0x0001ce09), (PBYTE)nEndScene, 5 );

*(PDWORD)&oReset = (DWORD)DetourFunc
( PBYTE(D3D9DLL + 0x00058dda), (PBYTE)nReset, 5 );

*(PDWORD)&oDrawIdP = (DWORD)DetourFunc
( PBYTE(D3D9DLL + 0x00027651), (PBYTE)nDrawIdP, 5 );
}
}

//-------------------------------------------------------------------

void __cdecl add_log (const char *fmt, ...)
{
if(ofile != NULL)
{
if(!fmt) { return; }

va_list va_alist;
char logbuf[256] = {0};

va_start (va_alist, fmt);
_vsnprintf (logbuf+strlen(logbuf),
sizeof(logbuf) - strlen(logbuf), fmt, va_alist);
va_end (va_alist);

ofile << logbuf << endl;
}
}

//-------------------------------------------------------------------

BOOL WINAPI DllMain( HMODULE hModule,
DWORD dwReason, LPVOID lpReserved )
{
if( dwReason == DLL_PROCESS_ATTACH )
{
DisableThreadLibraryCalls( hModule );
GetModuleFileNameA( hModule, dlldir, 320 );
dlldir[strlen(dlldir)-3] = 0;
strcat(dlldir,"txt");

ofile.open(dlldir, ios::app);
add_log("\nxDD Log");

CreateThread( NULL, NULL, (LPTHREAD_START_ROUTINE)
THREAD, NULL, NULL, NULL );
}

return TRUE;
}

//-------------------------------------------------------------------


some screenshots:













Gj! :] tank's..
....Oh THanks But.

TThe DIp Is Detected In My Game :P I DOnt Know How To Hook....:P
Great work, but may I suggest for you to clean this up a little bit. It's kind of messy, also don't declare the entire namespace variables. It adds the referenced statements which you aren't using into the registry stack which can cause lag. Instead, use this method: using std::"Name of variable you will use." Other than that, good work.
Nicely done.
will help me highlight certain items in battlefield such as helicopters or anti-tank mines
Posts 1–5 of 5 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us