Version: 1
Version 2:
Version 2:
SetBtnFlag (BUTTONBIT flag)
ClearBtnFlag (BUTTONBIT flag)
WriteText (label/editbox/button const char * text)
GetBtnFlag
WriteBtnFlag
Example usage:
(AccountName - from UI\FrameDef\Glue\BattleNetMain.fdf )
- When entering battlenet (if you click on the nickname) - displays a message with your nickname xD
Code:
class WarcraftButton
{
typedef void *( __fastcall * GetBtnAddrGAME )( const char * a2 , int tmp );
GetBtnAddrGAME GetBtnAddr_p;
bool fistnameset = false;
char * buttonname;
enum BUTTONBIT : unsigned
{
STATE_BUTTON_ENABLED = 0 ,
STATE_BUTTON_FOCUSED = 1 ,
STATE_BUTTON_PRESSED = 2 ,
STATE_BUTTON_MOUSEOVER = 4 ,
STATE_BUTTON_CHECKED = 5
};
public:
~WarcraftButton( )
{
if ( fistnameset )
delete[ ] buttonname;
}
WarcraftButton( const char * name )
{
int namesize = strlen( name ) + 1;
if ( fistnameset )
delete[ ] buttonname;
buttonname = new char[ strlen( name ) + 1 ];
sprintf_s( buttonname , namesize , "%s" , name );
fistnameset = true;
IsOk( );
}
void SetButtonName( const char * name )
{
int namesize = strlen( name ) + 1;
if ( fistnameset )
delete[ ] buttonname;
buttonname = new char[ strlen( name ) + 1 ];
sprintf_s( buttonname , namesize , "%s" , name );
fistnameset = true;
}
bool IsOk( )
{
if ( GetModuleHandle( "Game.dll" ) )
{
if ( fistnameset )
{
GetBtnAddr_p = ( GetBtnAddrGAME ) ( ( DWORD ) GetModuleHandle( "Game.dll" ) + 0x5FA970 );
return GetBtnAddr( ) > 0;
}
}
return false;
}
bool IsBtnEnabled( )
{
if ( IsOk() )
{
return is_btn_bit_set( STATE_BUTTON_ENABLED );
}
return false;
}
bool IsBtnFocused( )
{
if ( IsOk() )
{
return is_btn_bit_set( STATE_BUTTON_FOCUSED );
}
return false;
}
bool IsBtnPressed( )
{
if ( IsOk() )
{
return is_btn_bit_set( STATE_BUTTON_PRESSED );
}
return false;
}
bool IsBtnMouseOver( )
{
if ( IsOk() )
{
return is_btn_bit_set( STATE_BUTTON_MOUSEOVER );
}
return false;
}
bool IsChecked( )
{
if ( IsOk() )
{
return is_btn_bit_set( STATE_BUTTON_CHECKED);
}
return false;
}
int GetBtnStringSize( )
{
if ( IsOk() )
{
return *( int* ) ( GetBtnAddr( ) + 0x1E8 );
}
return 0;
}
int GetBtnStringAddr( )
{
if ( IsOk() )
{
if ( GetBtnStringSize( ) > 0 )
return *( int* ) ( GetBtnAddr( ) + 0x1E4 );
}
return 0;
}
const char * Author( )
{
return "Absol (d3scene.ru)";
}
const char * Version( )
{
return "Fist release d3scene.ru!";
}
private:
int GetBtnAddr( )
{
if ( !fistnameset )
return 0;
if ( !buttonname )
return 0;
return ( int ) GetBtnAddr_p( buttonname , 0 );
}
bool is_btn_bit_set( unsigned bitindex )
{
unsigned value = *( unsigned char * ) ( GetBtnAddr( ) + 0x1D4 );
return ( value & ( 1 << bitindex ) ) != 0;
}
};
int GetBtnStringSize( )
{
if ( IsOk() )
{
return *( int* ) ( GetBtnAddr( ) + 0x1E8 );
}
return 0;
}
int GetBtnStringAddr( )
{
if ( IsOk() )
{
if ( GetBtnStringSize( ) > 0 )
return *( int* ) ( GetBtnAddr( ) + 0x1E4 );
}
return 0;
}
const char * Author( )
{
return "Absol (d3scene.ru)";
}
const char * Version( )
{
return "Fist release d3scene.ru!";
}
private:
int GetBtnAddr( )
{
if ( !fistnameset )
return 0;
if ( !buttonname )
return 0;
return ( int ) GetBtnAddr_p( buttonname , 0 );
}
bool is_btn_bit_set( unsigned bitindex )
{
unsigned value = *( unsigned char * ) ( GetBtnAddr( ) + 0x1D4 );
return ( value & ( 1 << bitindex ) ) != 0;
}
};
Code:
class WarcraftButton
{
typedef void *( __fastcall * GetBtnAddrGAME )( const char * a2 , int tmp );
GetBtnAddrGAME GetBtnAddr_p;
bool fistnameset = false;
char * buttonname;
unsigned char btnflag = 0;
public:
enum BUTTONBIT : unsigned
{
STATE_BUTTON_ENABLED = 0 ,
STATE_BUTTON_FOCUSED = 1 ,
STATE_BUTTON_PRESSED = 2 ,
STATE_BUTTON_MOUSEOVER = 4 ,
STATE_BUTTON_CHECKED = 5 ,
STATE_BUTTON_CURSOR = 5
};
~WarcraftButton( )
{
if ( fistnameset )
delete[ ] buttonname;
}
WarcraftButton( const char * name )
{
int namesize = strlen( name ) + 1;
if ( fistnameset )
delete[ ] buttonname;
buttonname = new char[ strlen( name ) + 1 ];
sprintf_s( buttonname , namesize , "%s" , name );
fistnameset = true;
if ( IsOk( ) )
{
btnflag = GetBtnFlag( );
}
}
void SetButtonName( const char * name )
{
int namesize = strlen( name ) + 1;
if ( fistnameset )
delete[ ] buttonname;
buttonname = new char[ strlen( name ) + 1 ];
sprintf_s( buttonname , namesize , "%s" , name );
fistnameset = true;
}
bool IsOk( )
{
if ( GetModuleHandle( "Game.dll" ) )
{
if ( fistnameset )
{
GetBtnAddr_p = ( GetBtnAddrGAME ) ( ( DWORD ) GetModuleHandle( "Game.dll" ) + 0x5FA970 );
return GetBtnAddr( ) > 0;
}
}
return false;
}
bool IsBtnEnabled( )
{
if ( IsOk() )
{
return is_btn_bit_set( STATE_BUTTON_ENABLED );
}
return false;
}
bool IsBtnFocused( )
{
if ( IsOk() )
{
return is_btn_bit_set( STATE_BUTTON_FOCUSED );
}
return false;
}
bool IsBtnPressed( )
{
if ( IsOk() )
{
return is_btn_bit_set( STATE_BUTTON_PRESSED );
}
return false;
}
bool IsBtnMouseOver( )
{
if ( IsOk() )
{
return is_btn_bit_set( STATE_BUTTON_MOUSEOVER );
}
return false;
}
bool IsChecked( )
{
if ( IsOk() )
{
return is_btn_bit_set( STATE_BUTTON_CHECKED);
}
return false;
}
int GetBtnStringSize( )
{
if ( IsOk() )
{
return *( int* ) ( GetBtnAddr( ) + 0x1E8 );
}
return 0;
}
int GetBtnStringAddr( )
{
if ( IsOk() )
{
if ( GetBtnStringSize( ) > 0 )
{
int returnaddr = *( int* ) ( GetBtnAddr( ) + 0x1E4 );
if ( returnaddr < 1000 )
{
returnaddr = *( int* ) ( GetBtnAddr( ) + 0x1E8 + 4 );
}
if ( returnaddr < 1000 )
{
returnaddr = *( int* ) ( GetBtnAddr( ) + 0x1E8 + 8 );
}
if ( returnaddr < 1000 )
{
returnaddr = 0;
}
return returnaddr;
}
}
return 0;
}
const char * Author( )
{
return "Absol (d3scene.ru)";
}
const char * Version( )
{
return "2 beta!";
}
void SetBtnFlag( unsigned value )
{
bit_set( btnflag , value );
WriteBtnFlag( btnflag );
}
void ClearBtnFlag( unsigned value )
{
bit_clear( btnflag , value );
WriteBtnFlag( btnflag );
}
void WriteText( const char * text )
{
*( int* ) ( GetBtnAddr( ) + 0x1E8 ) = strlen( text );
if ( GetBtnStringAddr( ) < 1000 )
{
;
}
else
{
unsigned char nullbyte = 0;
WriteProcessMemory( GetCurrentProcess( ) , ( void * ) ( GetBtnStringAddr( ) ) , text , strlen( text ) , 0 );
WriteProcessMemory( GetCurrentProcess( ) , ( void * ) ( GetBtnStringAddr( ) + strlen( text ) ) , &nullbyte ,1 , 0 );
}
}
int GetBtnAddr( )
{
if ( !fistnameset )
return 0;
if ( !buttonname )
return 0;
return ( int ) GetBtnAddr_p( buttonname , 0 );
}
unsigned char GetBtnFlag( )
{
if ( IsOk( ) )
{
return *( unsigned char * ) ( GetFlagAddr( ) );
}
return 0;
}
void WriteBtnFlag( unsigned char flag )
{
if ( IsOk( ) )
{
*( unsigned char * ) ( GetFlagAddr( ) ) = flag;
}
}
private:
int GetFlagAddr( )
{
return GetBtnAddr( ) + 0x1D4;
}
bool is_btn_bit_set( unsigned bitindex )
{
unsigned value = GetBtnFlag();
return ( value & ( 1 << bitindex ) ) != 0;
}
unsigned bit_set( unsigned value , unsigned bitindex )
{
return value | ( 1 << bitindex );
}
unsigned bit_clear( unsigned value , unsigned bitindex )
{
return value & ~( 1 << bitindex );
}
};
SetBtnFlag (BUTTONBIT flag)
ClearBtnFlag (BUTTONBIT flag)
WriteText (label/editbox/button const char * text)
GetBtnFlag
WriteBtnFlag
Example usage:
(AccountName - from UI\FrameDef\Glue\BattleNetMain.fdf )
Code:
unsigned long __stdcall thread( LPVOID a1 )
{
WarcraftButton tempbutton ( "AccountName" ); // AccountName - from UI\FrameDef\Glue\BattleNetMain.fdf
while ( !tempbutton.IsOk( ) ) // if false - not found!
{
Sleep( 100 );
}
while ( true )
{
if ( !tempbutton.IsChecked( ) )
{
while ( !tempbutton.IsChecked( ) )
{
Sleep( 10 );
}
int btntextsize = tempbutton.GetBtnStringSize( );
if ( btntextsize > 1 )
{
char * accountc = new char[ btntextsize+1 ];
accountc[ btntextsize ] = '\0';
ReadProcessMemory( GetCurrentProcess( ) , ( void* ) tempbutton.GetBtnStringAddr( ) , accountc , btntextsize , 0 );
MessageBox( NULL , accountc , tempbutton.Author() , MB_OK );
delete[ ]accountc;
}
}
Sleep( 20 );
}
return 0;
}
HANDLE hThread;
BOOL WINAPI DllMain( HINSTANCE hDLL , UINT reason , LPVOID reserved )
{
if ( reason == DLL_PROCESS_ATTACH )
{
hThread = CreateThread( 0 , 0 , thread , 0 , 0 , 0 );
}
else if ( reason == DLL_PROCESS_DETACH )
{
TerminateThread( hThread , 0 );
}
return TRUE;
}