Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- -----------------------------------------
- * Game hacking QTS ( Quickie Tip Series )
- * no. 7 - Dynamic format strings class
- -----------------------------------------
- * Author: SEGnosis - GHAnon.net
- * Thanks to:
- * bitterbanana - No known site
- * Drunken Cheetah - No known site
- * fatboy88 - No known site
- * Geek4Ever - No known site
- * learn_more - www.uc-forum.com
- * Novocaine - http://ilsken.net/blog/?page_id=64
- * Philly0494 - No known site
- * Roverturbo - www.uc-forum.com
- * SilentKarma - www.halocoders.com - offline
- * Strife - www.uc-forum.com
- * Wieter20 - No known site
- */
- //----------------------------------//
- class C_Strings
- {
- public:
- C_Strings(); // Constructor
- ~C_Strings(); // De-constructor
- char* _sprintf( char* szString, ... ); // Prototype
- void AppendSprintfQueue( char* szNewSpace ); // Prototype
- void ClearSprintfQueue( void ); // Prototype
- private:
- DWORD* m_pdwSprintfQueue; // Pointer that will hold the address of the area that will hold the addresses of the allocated char strings
- DWORD m_dwSizeofSprintfQueue; // The number of allocated char strings
- }Strings; // Instance
- //----------------------------------//
- //----------------------------------//
- C_Strings::C_Strings()
- {
- m_pdwSprintfQueue = 0; // Default
- m_dwSizeofSprintfQueue = 0; // Default
- }
- //----------------------------------//
- C_Strings::~C_Strings()
- {
- }
- //----------------------------------//
- //----------------------------------//
- char* C_Strings::_sprintf( char* szString, ... )
- {
- char* szBuffer = new char[ 1024 ]; // Allocate a new char array of 1mb ( 1024 bytes )
- AppendSprintfQueue( szBuffer ); // Store the address of the string in the queue
- va_list va_alist; // Make a new char*
- va_start( va_alist, szString );
- vsprintf( szBuffer, szString, va_alist); // Place string with parameters embedded into szBuffer
- va_end ( va_alist );
- return szBuffer; // return char string
- }
- //----------------------------------//
- void C_Strings::AppendSprintfQueue( char* szNewSpace )
- {
- DWORD* pdwTemp = new DWORD[ ++m_dwSizeofSprintfQueue ]; // Create a new dword pointer of the m_dwSizeofSprintfQueue += 1
- if( m_pdwSprintfQueue ) // If m_pdwSprintfQueue has more than one index
- {
- memcpy( pdwTemp, m_pdwSprintfQueue, m_dwSizeofSprintfQueue * sizeof( DWORD ) ); // Save all the data from m_pdwSprintfQueue into pdwTemp
- delete[] m_pdwSprintfQueue; // Free the data/memory in m_pdwSprintfQueue
- }
- pdwTemp[ m_dwSizeofSprintfQueue - 1 ] = ( DWORD )szNewSpace; // Inside the last index, save the address of the new string
- m_pdwSprintfQueue = pdwTemp; // Give the pointer to m_pdwSprintfQueue
- }
- //----------------------------------//
- void C_Strings::ClearSprintfQueue( void )
- {
- for( int i = 0; i < m_dwSizeofSprintfQueue; i++ )// Go through all the indexes of m_pdwSprintfQueue
- {
- char* pDel = ( char* )m_pdwSprintfQueue[ i ]; // Make a pointer that refrences the string
- delete[] pDel; // Free the memory in that pointer
- }
- delete[] m_pdwSprintfQueue; // Clear the queue of addresses
- m_pdwSprintfQueue = 0; // Default
- m_dwSizeofSprintfQueue = 0; // Default
- }
- //----------------------------------//
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement