WeaponLogger

Posts 1–15 of 19 · Page 1 of 2
WeaponLogger
Well, this code doesn't work anymore. I need to know at least if weapon logger still exist? It doesnt log weapon name when I use this code by Brimir. Game crashes when start logging or stop before the "weapon name". (IDK WHO'S CODE THIS WAS, ALL I KNOW IS WHO POSTED THIS CODE.) Thanks!
Code:
DWORD cshell = (DWORD)GetModuleHandleA( "CShell.dll" );
DWORD weapon = *(DWORD*)( cshell + 0xA65EE8);
std::ofstream file;
file.open("Logger.txt");
for(int i = 0; i < 600; i++) { //You can see later how many weapons there are. Then you can lower the loop.
	  DWORD wapens = *(DWORD*)(weapon +(4*i));
	  char * weaponname = (char*)(wapens + 0x0008);
          file << "Item number: " << i << " ID: " << hex << i << " Name: " << (LPCTSTR)weaponname << ".\n";
}
file.close();
Copy & Pasta nooby friendly.

Code:
class CWeapon
{
public:
char _0x0000[10];
	char Name[26]; //0x000A 
};//Size=0x000E

const void __cdecl add_log( const char *fmt, ... )
{
	std::ofstream ofile;

	ofile.open( "C:\\WEPLOG.txt", std::ios::app );

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

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

	ofile << logbuf << std::endl;

	ofile.close( );
}

DWORD FindPattern( DWORD dwStart, DWORD dwLen, BYTE *pszPatt, char pszMask[ ] )
{
	unsigned int i = NULL;
	int iLen = strlen( pszMask ) - 1;

	for( DWORD dwRet = dwStart; dwRet < dwStart + dwLen; dwRet++ )
	{
		if( *( BYTE * ) dwRet == pszPatt[ i ] || pszMask[ i ] == '?' )
		{
			if( pszMask[ i + 1 ] == '\0' )
				return( dwRet - iLen );
			i++;
		}
		else i = NULL;
	}

	return NULL;
}

void getPatterns( DWORD *dwWeaponManager, DWORD *dwMaxWeapons )
{
	while( !GetModuleHandle( "ClientFX.fxd" ) )
		Sleep( 1 );

	MODULEINFO objModInfo;
	memset( &objModInfo, 0, sizeof( MODULEINFO ) );
	GetModuleInformation( GetCurrentProcess( ), GetModuleHandle( "CShell.dll" ), &objModInfo, sizeof( MODULEINFO ) );

	add_log( "CShell( Base: 0x%X , Size: 0x%X )",
			 objModInfo.lpBaseOfDll, objModInfo.SizeOfImage );

	if( !objModInfo.lpBaseOfDll )
		return;

	DWORD pattWeaponManager = FindPattern( ( DWORD ) objModInfo.lpBaseOfDll, objModInfo.SizeOfImage,
		( PBYTE ) "\x8B\x0D\x00\x00\x00\x00\x8B\x04\xB1\xD9\xE8\x68\x00\x00\x00\x00", ( char * ) "xx????xxxxxx????" );

	pattWeaponManager = *( DWORD * ) ( pattWeaponManager + 0x02 );
	pattWeaponManager = *( DWORD * ) ( pattWeaponManager );
	*dwWeaponManager  = pattWeaponManager;

	DWORD pattMaxWeapons = FindPattern( ( DWORD ) objModInfo.lpBaseOfDll, objModInfo.SizeOfImage,
		( PBYTE ) "\x81\xFF\x00\x00\x00\x00\x0F\x8C\x00\x00\x00\x00\x38\x1D\x00\x00\x00\x00", ( char * ) "xx????xx????xx????" );

	pattMaxWeapons = *( DWORD * ) ( pattMaxWeapons + 0x02 );
	*dwMaxWeapons  = pattMaxWeapons;
}

DWORD WINAPI dwWeaponLogger( void * )
{
	DWORD dwWeaponManager = 0, dwMaxWeapons = 0;
	getPatterns( &dwWeaponManager, &dwMaxWeapons );

	add_log( "Logger( WepMgr: 0x%X , MaxWeapons: %i )",
			 dwWeaponManager, dwMaxWeapons );

	while( ( !dwWeaponManager && !dwMaxWeapons ) )
		Sleep( 1 );

	for( int i = 0; i < ( int ) dwMaxWeapons; i++ )
	{
		CWeapon *pWeapon = *( CWeapon ** ) ( dwWeaponManager + ( 4 * i ) );

		if( pWeapon != 0 )
			add_log( "[ %i ] %s", i, pWeapon->Name );
	}

	return 0;
}
1. for(int i = 0; i < 600; i++)
2. char * weaponname = (char*)(wapens + 10)
Quote Originally Posted by mamo007 View Post
1. for(int i = 0; i < 600; i++)
2. char * weaponname = (char*)(wapens + 10)
how to update the weapon name offset? (char*)(wapens + 10)
Quote Originally Posted by akbargain View Post
how to update the weapon name offset? (char*)(wapens + 10)
String: WeaponName or something like that
Thanks! I'll try this. ^_^
luizimloko's code is working fine. I just adjusted some codes to make less complicated but really working smooth! Thank you very much sir and also mamo007 for giving me such information how to update the name offset ^_^ both thanked with + rep

Thanks to M4Z3 for the effort to help me. + rep

ALTHOUGH I have one more question about the code.

This
Code:
class CWeapon
{
public:
char _0x0000[10]; <--- WHY 10?
char Name[26]; <--- WHY 26?
};//Size=0x000E
I am a noob yes but I wanna learn, please understand ^_^.
I am not that familiar with structure/tags/members/class. I want to understand, anybody willing to help me to understand the structure given? THANKS!
Quote Originally Posted by akbargain View Post
luizimloko's code is working fine. I just adjusted some codes to make less complicated but really working smooth! Thank you very much sir and also mamo007 for giving me such information how to update the name offset ^_^ both thanked with + rep

Thanks to M4Z3 for the effort to help me. + rep

ALTHOUGH I have one more question about the code.

This
Code:
class CWeapon
{
public:
char _0x0000[10]; <--- WHY 10?
char Name[26]; <--- WHY 26?
};//Size=0x000E
I am a noob yes but I wanna learn, please understand ^_^.
I am not that familiar with structure/tags/members/class. I want to understand, anybody willing to help me to understand the structure given? THANKS!
Why 10? Because it's the offset of weapon name.
Why 26? It's the maximum lenght of a weapon's name.

This is like the sprintf from c++ (someone correct me if I'm wrong).

Code:
1009B371  |. 55             PUSH EBP                                                  <- (Parameter) Object ID
1009B372  |. 8D4E 0A        LEA ECX,DWORD PTR DS:[ESI+0xA]                   <- ESI is the base of the weapon. ESI + 0xA is weapon name.
1009B375  |. 51             PUSH ECX                                                             <- (Parameter) WeaponName
1009B376  |. 68 60A6CF10    PUSH Dumped2.10CFA660                               ;  ASCII "WeaponName = %s , objectID = %u"
1009B37B  |. FFD0           CALL EAX                                                            <- Calls the function
In C++ it would be something like this:
Code:
char text[100];
sprintf_s(text, "WeaponName = %s , objectID = %u", WeaponName, ObjectID); //The variable names are illustrative
Quote Originally Posted by vaisefud3 View Post
Why 10? Because it's the offset of weapon name.
Why 26? It's the maximum lenght of a weapon's name.

This is like the sprintf from c++ (someone correct me if I'm wrong).

Code:
1009B371  |. 55             PUSH EBP                                                  <- (Parameter) Object ID
1009B372  |. 8D4E 0A        LEA ECX,DWORD PTR DS:[ESI+0xA]                   <- ESI is the base of the weapon. ESI + 0xA is weapon name.
1009B375  |. 51             PUSH ECX                                                             <- (Parameter) WeaponName
1009B376  |. 68 60A6CF10    PUSH Dumped2.10CFA660                               ;  ASCII "WeaponName = %s , objectID = %u"
1009B37B  |. FFD0           CALL EAX                                                            <- Calls the function
In C++ it would be something like this:
Code:
char text[100];
sprintf_s(text, "WeaponName = %s , objectID = %u", WeaponName, ObjectID); //The variable names are illustrative
Wow very informative!
Hmmm what if I wanna add weapon class? weapon class offset is int 0x2 what it'll be in struct?
coz I made 2 struct to make weapon name and weapon class work
Quote Originally Posted by akbargain View Post
Wow very informative!
Hmmm what if I wanna add weapon class? weapon class offset is int 0x2 what it'll be in struct?
coz I made 2 struct to make weapon name and weapon class work
Yep, you're getting the point. It's the same thing. I just couldn't find that with olly right now.
If you need:

Code:
class cWeapon
{
public:
	char _0x0000[2]; //0x0000 
	__int16 WeaponClass; //0x0002 
	char _0x0004[6]; //0x0004 
	char WeaponName[64]; //0x00A
};
Quote Originally Posted by vaisefud3 View Post
Yep, you're getting the point. It's the same thing. I just couldn't find that with olly right now.
If you need:

Code:
class cWeapon
{
public:
	char _0x0000[2]; //0x0000 
	__int16 WeaponClass; //0x0002 <--- why 0x2?
	char _0x0004[6]; //0x0004  <---- why 0x4? isn't the name offset is 0xA?
	char WeaponName[64]; //0x00A <---- AND WHY 64?
};
Sorry for this much question but.
Quote Originally Posted by akbargain View Post
Sorry for this much question but.
The size of a char is 1 byte, so, to get to the offset 0x2 (WeaponClass) you need 2 chars.
The size of a __int16 is 2 bytes, so, the next item is at 0x4.
Again, chars, so 0x4(current offset) + 0x6(6 chars X the size of a char(1) = 0xA -> WeaponName offset.
The last, 64, is what I use as the maximum size of the WeaponName.
Quote Originally Posted by vaisefud3 View Post
The size of a char is 1 byte, so, to get to the offset 0x2 (WeaponClass) you need 2 chars.
The size of a __int16 is 2 bytes, so, the next item is at 0x4.
Again, chars, so 0x4(current offset) + 0x6(6 chars X the size of a char(1) = 0xA -> WeaponName offset.
The last, 64, is what I use as the maximum size of the WeaponName.
Best answer of the day! Thank you so much. ^_^
Quote Originally Posted by akbargain View Post
Best answer of the day! Thank you so much. ^_^
You are welcome
Posts 1–15 of 19 · Page 1 of 2

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us