Description
Cheat_Code is an open-source project that is written in C++ for educational purposes. It aims to be the most useful and library for developing trainers for offline and single player games.
Documentation
The documentation for Cheat_Code is not yet completed.
Why Did I Create Cheat_Code?
I created Cheat_Code for several reasons. One reason is mainly because I enjoy programming. Because, programming makes me think. Another reason is because I enjoy helping others who shares the same interests as me. And maybe in the near future, Cheat_Code could end up being a very useful library for many developers who enjoy making game trainers. It could make programming easier for them. Also, they can learn from the source codes of Cheat_Code. Those are some reasons why I created Cheat_Code.
Latest Version: 1.1
Downloads
Sharing is caring.
Cheat_Code version 1.1 can be downloaded right
here as .zip.
The first version (version 1) of Cheat_Code can be downloaded right
here as .zip.
Preview
Feel free to do some copying and pasting! Please do some review.
Cheat_Code.h
Code:
#ifndef CHEAT_CODE_HEADER
#define CHEAT_CODE_HEADER
#pragma region READ_ME
//////////////////////////////////////////////////////////////////////////////
// //
// Copyright (c) 2013 - 2014, "The cheat_code" <cheat_code@aim.com>. //
// Use the code is allowed under the Artistic License 2.0 terms, //
// as specified in the LICENSE file distributed with this code, //
// or available from: http://opensource.org/licenses/artistic-license-2.0 //
// //
//////////////////////////////////////////////////////////////////////////////
#pragma endregion READ_ME
#pragma region RELEASE_INFO
//////////////////////////////////////////////////////////////////////////////
// //
// Author: "The cheat_code" <cheat_code@aim.com>. //
// Version: 1.1 //
// Released Date: 2/28/2013 //
// //
//////////////////////////////////////////////////////////////////////////////
#pragma endregion RELEASE_INFO
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#define CHEAT_CODE_NOPS 0
#define CHEAT_CODE_ORGINAL_DISABLE_BYTES 0
#define CHEAT_CODE_DEPENDENT 0
namespace Cheat_Code
{
class Cheat
{
public:
typedef struct FLAG_STRUCT
{
enum __Flags
{
None = 0x00,
EnableBytes_NOP = 0x01,
#pragma region NO MIXING
DisableBytes_NOP = 0x02,
DisableBytes_Original = 0x04,
DisableBytes_OriginalEx = 0x08,
#pragma endregion
AutoDisable = 0x10
};
} CheatFlags;
Cheat( void ) :
Address( 0 ),
EnableBytes( 0 ),
DisableBytes( 0 ),
Enabled( false ),
Flags( CheatFlags::None )
{ };
Cheat( __in unsigned long p_Address,
__in char* p_EnableBytes,
__in char* p_DisableBytes,
__in unsigned int p_EnableBytesLength,
__in unsigned int p_DisableBytesLength,
__in bool p_Enabled,
__in_opt unsigned int p_Flags = CheatFlags::None ) :
Address( p_Address ),
EnableBytes( p_EnableBytes ),
DisableBytes( p_DisableBytes ),
EnableBytesLength( p_EnableBytesLength ),
DisableBytesLength( p_DisableBytesLength ),
Enabled( p_Enabled ),
Flags( p_Flags )
{
if( p_Flags ) FlagHandler( );
if( p_Enabled ) Enable( true );
};
~Cheat( void )
{
if( Flags &( CheatFlags::AutoDisable )
&& Enabled )
Enable( false );
if( Flags &( CheatFlags::EnableBytes_NOP )
&& EnableBytes != NULL )
delete [ ] EnableBytes;
if( Flags &( CheatFlags::DisableBytes_NOP ) ||
Flags &( CheatFlags::DisableBytes_Original )
&& DisableBytes != NULL )
delete [ ] DisableBytes;
};
public:
unsigned long Address;
char* EnableBytes;
char* DisableBytes;
unsigned int EnableBytesLength;
unsigned int DisableBytesLength;
private:
unsigned int Flags;
bool Enabled;
public:
bool IsEnabled( void ) { return( Enabled ); };
int Enable( __in bool p_Enable );
private:
void FlagHandler( void );
};
namespace Util
{
void WriteMemory( __in unsigned long Address,
__in char* Bytes,
__in unsigned int Length );
void WriteNOP( __in unsigned long Address, __in unsigned int Length );
};
};
#endif // CHEAT_CODE_HEADER
Cheat_Code.cpp
Code:
#pragma region READ_ME
//////////////////////////////////////////////////////////////////////////////
// //
// Copyright (c) 2013 - 2014, "The cheat_code" <cheat_code@aim.com>. //
// Use the code is allowed under the Artistic License 2.0 terms, //
// as specified in the LICENSE file distributed with this code, //
// or available from: http://opensource.org/licenses/artistic-license-2.0 //
// //
//////////////////////////////////////////////////////////////////////////////
#pragma endregion READ_ME
#include "Cheat_Code.h"
void Cheat_Code::Cheat::FlagHandler( void )
{
if( Flags &( CheatFlags::EnableBytes_NOP ) )
{
this->EnableBytes = new char[ this->EnableBytesLength + 1 ];
::memset( this->EnableBytes, 0x90, sizeof( char ) * this->EnableBytesLength );
this->EnableBytes[ this->EnableBytesLength ] = '\0';
}
if( this->Flags &( CheatFlags::DisableBytes_NOP ) )
{
this->DisableBytes = new char[ this->DisableBytesLength + 1 ];
::memset( this->DisableBytes, 0x90, sizeof( char ) * this->DisableBytesLength );
this->DisableBytes[ this->DisableBytesLength ] = '\0';
}
else if( this->Flags &( CheatFlags::DisableBytes_Original ) )
{
this->DisableBytes = new char[ DisableBytesLength + 1 ];
::memcpy( ( void * )this->DisableBytes,
( const void* )this->Address,
( sizeof( char ) * this->DisableBytesLength ) );
this->DisableBytes[ this->DisableBytesLength ] = '\0';
}
else if( this->Flags &( CheatFlags::DisableBytes_OriginalEx ) )
{
this->DisableBytes = new char[ this->EnableBytesLength + 1 ];
::memcpy( ( void * )this->DisableBytes,
( const void* )this->Address,
( sizeof( char ) * this->EnableBytesLength ) );
this->DisableBytes[ this->EnableBytesLength ] = '\0';
this->DisableBytesLength = this->EnableBytesLength;
}
};
int Cheat_Code::Cheat::Enable( __in bool p_Enable )
{
if( p_Enable != this->Enabled )
{
if( p_Enable && this->EnableBytes > 0 && this->EnableBytesLength != 0 )
Util::WriteMemory( this->Address, this->EnableBytes, this->EnableBytesLength );
else if( !p_Enable && this->DisableBytes > 0 && this->DisableBytesLength != 0 )
Util::WriteMemory( this->Address, this->DisableBytes, this->DisableBytesLength );
else return( 0 );
this->Enabled = p_Enable;
}
return( 1 );
};
void Cheat_Code::Util::WriteMemory( __in unsigned long Address,
__in char* Bytes,
__in unsigned int Length )
{
unsigned long OriginalProtection = 0;
::VirtualProtect( ( void* )( Address ), Length, PAGE_EXECUTE_READWRITE, &OriginalProtection );
::memcpy( ( void * )Address, Bytes, Length );
::VirtualProtect( ( void* )( Address ), Length, OriginalProtection, &OriginalProtection );
};
void Cheat_Code::Util::WriteNOP( __in unsigned long Address, __in unsigned int Length )
{
char NOPs[ 50 ];
::memset( NOPs, 0x90, Length );
Cheat_Code::Util::WriteMemory( Address, NOPs, Length );
};
Known Bugs/Problems
If you believe you have found a new bug within Cheat_Code, please report it.
Code:
[S]Currently, there are no known bugs within the latest version of[/S]
[S]Cheat_Code nor are there any problems with it.[/S]
Wiccaan @ **************** has found an error in Cheat_Code::Util::WriteMemory( ... ). Which has been resolved.
History of Changes
This is where we shall log all changes that are made within Cheat_Code.
Code:
[S]Currently, nothing of Cheat_Code has been changed.[/S]
- Fixed error within Cheat_Code::Util::WriteMemory( ... ).
- Added a new function: Cheat_Code::Util::WriteNOP( ... ).
Suggestions and Reviews Are Not Ignored
Feel free to share your suggestions and/or reviews!
Author
The
cheat_code <cheat_code@aim.com>
Contributors
Currently, there are no contributors.