├── .gitignore ├── CCAPI ├── CCAPI.sln ├── CCAPI.v11.suo ├── CCAPI │ ├── CCAPI.cpp │ ├── CCAPI.h │ ├── CCAPI.vcxproj │ ├── CCAPI.vcxproj.filters │ ├── CCAPI.vcxproj.user │ ├── ChunkFuzzySearch.cpp │ ├── ChunkFuzzySearch.h │ ├── ChunkValueSearch.cpp │ ├── ChunkValueSearch.h │ ├── Common.h │ ├── DumpMemory.cpp │ ├── DumpMemory.h │ ├── DumpTask.cpp │ ├── DumpTask.h │ ├── Helpers.h │ ├── Makefile │ ├── MemoryOperator.cpp │ ├── MemoryOperator.h │ ├── NumberInput.h │ ├── RangeMemory.cpp │ ├── RangeMemory.h │ ├── RangeTask.cpp │ ├── RangeTask.h │ ├── SearchMemory.cpp │ ├── SearchMemory.h │ ├── SearchTask.cpp │ ├── SearchTask.h │ ├── Task.cpp │ ├── Task.h │ ├── Types.cpp │ └── Types.h └── Makefile ├── LICENSE ├── Makefile ├── Makefile.common ├── Manual ├── Manual.docx ├── Manual.html └── cccheat.css ├── README.md ├── Trainer ├── Makefile ├── Trainer │ ├── Interface.cpp │ ├── Interface.h │ ├── Makefile │ ├── Trainer.cpp │ ├── Trainer.h │ ├── Trainer.v11.suo │ ├── Trainer.vcxproj │ ├── Trainer.vcxproj.filters │ ├── Trainer.vcxproj.user │ ├── TrainerTable.cpp │ ├── TrainerTable.h │ ├── ui_trainer.cxx │ └── ui_trainer.h ├── ui_trainer.cxx └── ui_trainer.h ├── UI ├── Makefile ├── UI.sln ├── UI.suo ├── UI.v11.suo ├── UI │ ├── AddressOffsetGroup.cpp │ ├── AddressOffsetGroup.h │ ├── CodeTable.cpp │ ├── CodeTable.h │ ├── Common.h │ ├── DumpManager.cpp │ ├── DumpManager.h │ ├── DumpScan.cpp │ ├── DumpScan.h │ ├── IDeactivate.h │ ├── IPInput.cpp │ ├── IPInput.h │ ├── InfoWindow.cpp │ ├── InfoWindow.h │ ├── InterfaceCCAPI.cpp │ ├── InterfaceCCAPI.h │ ├── Makefile │ ├── NumberInput.cpp │ ├── NumberInput.h │ ├── PointerEditorWindow.cpp │ ├── PointerEditorWindow.h │ ├── PointerScannerTable.cpp │ ├── PointerScannerTable.h │ ├── PointerScannerWindow.cpp │ ├── PointerScannerWindow.h │ ├── RangeTable.cpp │ ├── RangeTable.h │ ├── ResultTable.cpp │ ├── ResultTable.h │ ├── SearchOperationChoice.cpp │ ├── SearchOperationChoice.h │ ├── TrainerCreator.cpp │ ├── TrainerCreator.h │ ├── TrainerItemCodeTable.cpp │ ├── TrainerItemCodeTable.h │ ├── TrainerItemWindow.cpp │ ├── TrainerItemWindow.h │ ├── TrainerMakerWindow.cpp │ ├── TrainerMakerWindow.h │ ├── TrainerSrc.cpp │ ├── TrainerSrc.h │ ├── UI.filters │ ├── UI.user │ ├── UI.vcxproj │ ├── ValueInput.cpp │ ├── ValueInput.h │ ├── ValueTypeChoice.cpp │ ├── ValueTypeChoice.h │ ├── ValueViewerTable.cpp │ ├── ValueViewerTable.h │ ├── ValueViewerWindow.cpp │ ├── ValueViewerWindow.h │ ├── main.cpp │ ├── rkWindow.cpp │ ├── rkWindow.h │ ├── ui_main.cxx │ ├── ui_main.fl │ └── ui_main.h └── ui_main └── bin ├── CCCheat └── CCCheat.exe /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | *.obj 6 | 7 | # Compiled Dynamic libraries 8 | *.so 9 | *.dylib 10 | *.dll 11 | 12 | # Compiled Static libraries 13 | *.lai 14 | *.la 15 | *.a 16 | *.lib 17 | 18 | # Executables 19 | *.exe 20 | *.out 21 | *.app 22 | -------------------------------------------------------------------------------- /CCAPI/CCAPI.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Express 2012 for Windows Desktop 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CCAPI", "CCAPI\CCAPI.vcxproj", "{49636B42-2793-433D-B441-E65E42F3D542}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Release|Win32 = Release|Win32 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {49636B42-2793-433D-B441-E65E42F3D542}.Debug|Win32.ActiveCfg = Debug|Win32 13 | {49636B42-2793-433D-B441-E65E42F3D542}.Debug|Win32.Build.0 = Debug|Win32 14 | {49636B42-2793-433D-B441-E65E42F3D542}.Release|Win32.ActiveCfg = Release|Win32 15 | {49636B42-2793-433D-B441-E65E42F3D542}.Release|Win32.Build.0 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /CCAPI/CCAPI.v11.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/primetime00/CCCheat/827fcfb0f06946ed9cde5a10dd489b4a677209ff/CCAPI/CCAPI.v11.suo -------------------------------------------------------------------------------- /CCAPI/CCAPI/CCAPI.h: -------------------------------------------------------------------------------- 1 | #ifndef _CCAPI_ 2 | #define _CCAPI_ 3 | 4 | #if defined(_WIN32) || defined(WIN32) 5 | #include 6 | typedef int ssize_t; 7 | #else 8 | #include 9 | #include 10 | #include 11 | #endif 12 | #include 13 | #include 14 | #include "Common.h" 15 | 16 | 17 | #define CCAPI_PORT_20 1977 18 | #define CCAPI_PORT_25 1978 19 | 20 | #define CCAPI_MAX_BYTE_REQUEST 0x10000 21 | #define CCAPI_DATA_BUFFER 0x15000 22 | 23 | #define CCAPI_COMMAND_GETPROCESSLIST 0x04 24 | #define CCAPI_COMMAND_GETPROCESSNAME 0x05 25 | #define CCAPI_COMMAND_READPROCESSMEMORY 0x02 26 | #define CCAPI_COMMAND_WRITEPROCESSMEMORY 0x03 27 | 28 | #define CCAPI_SIZE_GETPROCESSLIST 0x10 29 | #define CCAPI_SIZE_GETPROCESSNAME 0x14 30 | #define CCAPI_SIZE_READPROCESSMEMORY 0x20 31 | #define CCAPI_SIZE_WRITEPROCESSMEMORY 0x20 32 | 33 | #define CCAPI_ERROR_NO_ERROR 0x00 34 | #define CCAPI_ERROR_NO_CONNECT 0x01 35 | #define CCAPI_ERROR_NO_ATTACH 0x02 36 | #define CCAPI_ERROR_CANCEL 0x03 37 | #define CCAPI_ERROR_FILE_FAIL 0x04 38 | 39 | #define PS3_INT_SIZE 4 40 | 41 | 42 | 43 | using namespace std; 44 | 45 | #define MAX_CONNECTIONS 10 46 | 47 | class ConnectionManager 48 | { 49 | public: 50 | ConnectionManager() { connectionManager = this; } 51 | ~ConnectionManager() { 52 | killAllConnections(); 53 | connectionManager = 0; 54 | } 55 | 56 | struct Connection { 57 | int sock; 58 | bool available; 59 | Connection() { sock = 0; available = true; } 60 | }; 61 | 62 | bool requestConnection(int &sock, string ipAddress, int hostVersion); 63 | void releaseConnection(int sock); 64 | void killAllConnections(); 65 | static ConnectionManager *connectionManager; 66 | static void startUp() { 67 | #if defined(_WIN32) || defined(WIN32) 68 | WSADATA wsaData; 69 | WSAStartup(0x0202, &wsaData); 70 | #endif 71 | } 72 | 73 | private: 74 | Connection connection[MAX_CONNECTIONS]; 75 | }; 76 | 77 | class CCAPI 78 | { 79 | public: 80 | CCAPI(string ip); 81 | ~CCAPI() {delete [] dataBuffer;} 82 | static void startup() { 83 | if (!initialized) 84 | { 85 | #if defined(_WIN32) || defined(WIN32) 86 | WSADATA wsaData; 87 | WSAStartup(0x0202, &wsaData); 88 | #endif 89 | initialized = true; 90 | } 91 | } 92 | static unsigned char bitConv[]; 93 | static bool initialized; 94 | 95 | int connect(void); 96 | int disconnect(void); 97 | int receiveData(void); 98 | int requestProcessIDList(void); 99 | int requestProcessName(unsigned int processID); 100 | int requestReadMemory(unsigned int processID, unsigned int offset, unsigned int length); 101 | int requestWriteMemory(unsigned int processID, unsigned int offset, unsigned int length, char *data); 102 | int attach(void); 103 | int readMemory(unsigned int offset, unsigned int length); 104 | int validateMemory(unsigned int offset); 105 | int writeMemory(unsigned int offset, unsigned int length, char *data); 106 | 107 | char *getData(unsigned int &length) { length = getDataSize(dataBuffer)-16; return &dataBuffer[16]; } 108 | bool insertData(unsigned int pos, char *data, unsigned int size); 109 | 110 | bool isConnected() { return connected; } 111 | bool isAttached() { return attached; } 112 | void setHostVersion(int ver) { hostVersion = ver; } 113 | 114 | 115 | private: 116 | unsigned int _conv32(unsigned int val) { 117 | //return BSWAP32( (bitConv[((char*)&val)[0]] << 24) + (bitConv[((char*)&val)[1]] << 16) + (bitConv[((char*)&val)[2]] << 8) + (bitConv[((char*)&val)[3]] << 0) ); 118 | return ( (bitConv[((unsigned char*)&val)[0]] << 24) + (bitConv[((unsigned char*)&val)[1]] << 16) + (bitConv[((unsigned char*)&val)[2]] << 8) + (bitConv[((unsigned char*)&val)[3]] << 0) ); 119 | } 120 | unsigned short _conv16(unsigned short val) { 121 | //return BSWAP16( (bitConv[((char*)val)[0]] << 8) + (bitConv[((char*)val)[1]] << 0) ); 122 | return ( (bitConv[((unsigned char*)&val)[0]] << 8) + (bitConv[((unsigned char*)&val)[1]] << 0) ); 123 | } 124 | unsigned char _conv8(unsigned char val) { 125 | return bitConv[(unsigned char)val]; 126 | } 127 | 128 | unsigned int getDataCommand(char *data) { return BSWAP32( ((unsigned int*)data)[1] ); } 129 | unsigned int getDataSize(char *data) { return BSWAP32( ((unsigned int*)data)[0] ); } 130 | unsigned int getDataID(char *data) { return BSWAP32( ((unsigned int*)data)[2] ); } 131 | unsigned int getDataValidity(char *data) { return BSWAP32( ((unsigned int*)data)[3] ); } 132 | int parseProcessIDs(char *data); 133 | int parseProcessName(char *data); 134 | int parseProcessMemory(char *data); 135 | void constructHeader(char *buffer, unsigned int &buffersize, unsigned int size, unsigned int command, unsigned int third=1444, unsigned int fourth=1164476209); 136 | 137 | private: 138 | string ipAddress; 139 | int sock; 140 | struct sockaddr_in destination; 141 | unsigned int attachedPID; 142 | char *dataBuffer; 143 | vector processIDs; 144 | string processName; 145 | bool connected; 146 | bool attached; 147 | int hostVersion; 148 | 149 | }; 150 | 151 | #endif 152 | -------------------------------------------------------------------------------- /CCAPI/CCAPI/CCAPI.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {49636B42-2793-433D-B441-E65E42F3D542} 15 | Win32Proj 16 | CCAPI 17 | 18 | 19 | 20 | StaticLibrary 21 | true 22 | v110 23 | Unicode 24 | 25 | 26 | StaticLibrary 27 | false 28 | v110 29 | true 30 | Unicode 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | true 44 | 45 | 46 | false 47 | 48 | 49 | 50 | 51 | 52 | Level3 53 | Disabled 54 | _HOME;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 55 | 56 | 57 | Console 58 | true 59 | kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;WSock32.Lib;%(AdditionalDependencies) 60 | 61 | 62 | false 63 | 64 | 65 | WSock32.Lib 66 | 67 | 68 | 69 | 70 | Level3 71 | 72 | 73 | MaxSpeed 74 | true 75 | true 76 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 77 | 78 | 79 | Console 80 | true 81 | true 82 | true 83 | kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;WSock32.Lib;%(AdditionalDependencies) 84 | 85 | 86 | WSock32.Lib 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | -------------------------------------------------------------------------------- /CCAPI/CCAPI/CCAPI.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | Source Files 29 | 30 | 31 | Source Files 32 | 33 | 34 | Source Files 35 | 36 | 37 | Source Files 38 | 39 | 40 | Source Files 41 | 42 | 43 | Source Files 44 | 45 | 46 | Source Files 47 | 48 | 49 | Source Files 50 | 51 | 52 | Source Files 53 | 54 | 55 | 56 | 57 | Header Files 58 | 59 | 60 | Header Files 61 | 62 | 63 | Header Files 64 | 65 | 66 | Header Files 67 | 68 | 69 | Header Files 70 | 71 | 72 | Header Files 73 | 74 | 75 | Header Files 76 | 77 | 78 | Header Files 79 | 80 | 81 | Header Files 82 | 83 | 84 | Header Files 85 | 86 | 87 | Header Files 88 | 89 | 90 | Header Files 91 | 92 | 93 | Header Files 94 | 95 | 96 | Header Files 97 | 98 | 99 | -------------------------------------------------------------------------------- /CCAPI/CCAPI/CCAPI.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /CCAPI/CCAPI/ChunkFuzzySearch.h: -------------------------------------------------------------------------------- 1 | #ifndef _CHUNKFUZZYSEARCH_ 2 | #define _CHUNKFUZZYSEARCH_ 3 | 4 | #include 5 | #include "Common.h" 6 | 7 | class ChunkFuzzySearch 8 | { 9 | public: 10 | ChunkFuzzySearch():resultRef(0) { first = true; isFloat = false; prevAddress = 0;} 11 | ~ChunkFuzzySearch() {} 12 | 13 | void setup(char len, char comp); 14 | void digest(char *newMemory, char *prevMemory, unsigned long length, unsigned long address); 15 | bool digestValue(char* memory, AddressItem item, unsigned long section); 16 | void digestValue(char* memory, unsigned long prevVal, unsigned long address, char sign = TEST_SIGN_BOTH); 17 | void clear() { first = true; prevAddress = 0; } 18 | 19 | void setResultReference(ResultList *ref) { resultRef = ref; } 20 | 21 | std::function testFunction_Signed; 22 | std::function testFunction_Unsigned; 23 | std::function testFunction_Float; 24 | 25 | template 26 | bool testEqual(T currentVal, T prevVal) { return currentVal == prevVal; } 27 | 28 | template 29 | bool testNotEqual(T currentVal, T prevVal) { return currentVal != prevVal; } 30 | 31 | template 32 | bool testGreater(T currentVal, T prevVal) { return currentVal > prevVal; } 33 | 34 | template 35 | bool testLess(T currentVal, T prevVal) { return currentVal < prevVal; } 36 | 37 | bool testFloatEqual(float currentVal, float prevVal) { return currentVal == *(float*)&prevVal; } 38 | 39 | bool testFloatNotEqual(float currentVal, float prevVal) { return (long)(currentVal*1000) != (long)((*(float*)&prevVal)*1000); } 40 | 41 | bool testFloatGreater(float currentVal, float prevVal) { return (long)(currentVal*1000) > (long) ((*(float*)&prevVal)*1000); } 42 | 43 | bool testFloatLess(float currentVal, float prevVal) { return (long)(currentVal*1000) < (long)((*(float*)&prevVal)*1000); } 44 | 45 | 46 | private: 47 | template 48 | char test(T currentVal, T prevVal); 49 | 50 | char valueByteLength; 51 | char comparison; 52 | 53 | unsigned long newBytes[6]; 54 | unsigned long prevBytes[6]; 55 | bool first; 56 | bool isFloat; 57 | 58 | ResultList *resultRef; 59 | unsigned long prevAddress; 60 | 61 | }; 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /CCAPI/CCAPI/ChunkValueSearch.h: -------------------------------------------------------------------------------- 1 | #ifndef _CHUNKVALUESEARCH_ 2 | #define _CHUNKVALUESEARCH_ 3 | 4 | #include 5 | #include "Helpers.h" 6 | #include "Common.h" 7 | 8 | using namespace std; 9 | 10 | 11 | class ChunkValueSearch 12 | { 13 | public: 14 | ChunkValueSearch():resultRef(0) { first = true; isFloat = false; prevAddress = 0; isUnsigned = true;} 15 | ~ChunkValueSearch() {} 16 | 17 | void setup(char len, char comp, long long val); 18 | void digest(char *memory, unsigned long length, unsigned long address); 19 | bool digestValue(char* memory, AddressItem item, unsigned long section); 20 | void clear() { first = true; prevAddress = 0;} 21 | void setResultReference(ResultList *ref) { resultRef = ref; } 22 | long long getValue() { return value; } 23 | 24 | std::function testFunction_Signed; 25 | std::function testFunction_Unsigned; 26 | std::function testFunction_Float; 27 | 28 | private: 29 | template 30 | bool test(T val); 31 | 32 | template 33 | bool testEqual(T val) { return val == (T)value; } 34 | 35 | template 36 | bool testNotEqual(T val) { return val != (T)value; } 37 | 38 | template 39 | bool testGreater(T val) { return val > (T)value; } 40 | 41 | template 42 | bool testLess(T val) { return val < (T)value; } 43 | 44 | bool testFloatEqual(float val) { return val == m_variant.convertToFloat((char*)&value); } 45 | 46 | bool testFloatNotEqual(float val) { return val != m_variant.convertToFloat((char*)&value); } 47 | 48 | bool testFloatGreater(float val) { return val > m_variant.convertToFloat((char*)&value); } 49 | 50 | bool testFloatLess(float val) { return val < m_variant.convertToFloat((char*)&value); } 51 | 52 | 53 | 54 | char valueByteLength; 55 | Variant m_variant; 56 | unsigned char comparison; 57 | long long value; 58 | bool isUnsigned; 59 | 60 | unsigned long prev[6]; 61 | bool first; 62 | bool isFloat; 63 | 64 | ResultList *resultRef; 65 | unsigned long prevAddress; 66 | 67 | }; 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /CCAPI/CCAPI/Common.h: -------------------------------------------------------------------------------- 1 | #ifndef _COMMON_ 2 | #define _COMMON_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include "Types.h" 11 | 12 | using namespace std; 13 | 14 | #if defined(_WIN32) || defined(WIN32) 15 | #define BSWAP32(x) _byteswap_ulong(x) 16 | #define BSWAP16(x) _byteswap_ushort(x) 17 | #else 18 | #define BSWAP32(x) __bswap_32(x) 19 | #define BSWAP16(x) __bswap_16(x) 20 | #endif 21 | 22 | #if defined(_WIN32) || defined(WIN32) 23 | #define __attribute__(x) 24 | #endif 25 | 26 | 27 | #define TEST_TYPE_FIND_RANGE 0x00 28 | #define TEST_TYPE_FIND_SEARCH 0x01 29 | 30 | #define TEST_SIGN_YES 0x01 31 | #define TEST_SIGN_NO 0x02 32 | #define TEST_SIGN_BOTH 0x03 33 | #define TEST_SIGN_UNKNOWN 0x08 34 | #define TEST_SIGN_NULL 0x00 35 | 36 | #define SEARCH_TYPE_VALUE 0x00 37 | #define SEARCH_TYPE_FUZZY 0x01 38 | #define SEARCH_TYPE_UNKNOWN 0x02 39 | 40 | #define SEARCH_VALUE_TYPE_1BYTE 0x00 41 | #define SEARCH_VALUE_TYPE_2BYTE 0x01 42 | #define SEARCH_VALUE_TYPE_4BYTE 0x02 43 | #define SEARCH_VALUE_TYPE_FLOAT 0x03 44 | #define SEARCH_VALUE_TYPE_PT_1BYTE 0x04 45 | #define SEARCH_VALUE_TYPE_PT_2BYTE 0x05 46 | #define SEARCH_VALUE_TYPE_PT_4BYTE 0x06 47 | #define SEARCH_VALUE_TYPE_PT_FLOAT 0x07 48 | 49 | #define SEARCH_STATE_INITIAL 0x00 50 | #define SEARCH_STATE_CONTINUE 0x01 51 | 52 | #define SEARCH_FUZZY_EQUAL 0x00 53 | #define SEARCH_FUZZY_NOTEQUAL 0x01 54 | #define SEARCH_FUZZY_GREATER 0x02 55 | #define SEARCH_FUZZY_LESS 0x03 56 | #define SEARCH_VALUE_EXACT 0x04 57 | #define SEARCH_VALUE_NOTEXACT 0x05 58 | #define SEARCH_VALUE_GREATER 0x06 59 | #define SEARCH_VALUE_LESS 0x07 60 | #define SEARCH_FUZZY_INIT 0x08 61 | #define SEARCH_POINTER 0x09 62 | 63 | #define RESULT_FILE_TYPE_DUMP 0x00 64 | #define RESULT_FILE_TYPE_LIST 0x01 65 | 66 | #define MEMORY_COMMAND_READ 0x00 67 | #define MEMORY_COMMAND_WRITE 0x01 68 | #define MEMORY_COMMAND_CONDITIONAL 0x02 69 | 70 | #if 0 71 | struct AddressOffset 72 | { 73 | unsigned long address; 74 | unsigned int offset; 75 | AddressOffset(unsigned long a, unsigned int o) { address = a; offset = o; } 76 | }; 77 | 78 | typedef list PointerOffsets; 79 | typedef list AddressOffsets; 80 | 81 | struct PointerObj 82 | { 83 | AddressOffsets pointers; 84 | 85 | AddressItem m_address; 86 | 87 | unsigned long getBase() { return (pointers.size() > 0) ? pointers.front().address : 0; } 88 | unsigned int updateCount; 89 | void fromPointerOffsets(const unsigned long address, const PointerOffsets &pt) { 90 | pointers.clear(); 91 | for (auto it = pt.begin(); it!= pt.end(); ++ it) 92 | { 93 | pointers.push_back(AddressOffset(0, *it)); 94 | } 95 | if (pointers.size() > 0) pointers.front().address = address; 96 | } 97 | bool equal(PointerObj p) { 98 | auto pstart = p.pointers.begin(); 99 | auto start = pointers.begin(); 100 | if (p.getBase() != getBase()) return false; 101 | if (p.pointers.size() != pointers.size()) return false; 102 | while (start != pointers.end()) 103 | { 104 | if (start->offset != pstart->offset) return false; 105 | ++start; ++pstart; 106 | } 107 | return true; 108 | } 109 | void update() { updateCount++; updateCount %= 0xFFFFFFF; } 110 | PointerObj(AddressOffsets b) { pointers = b; m_address.address = 0; updateCount = 0; m_address.type = SEARCH_VALUE_TYPE_4BYTE; } 111 | PointerObj(const unsigned long address, const PointerOffsets &pt) { fromPointerOffsets(address, pt); updateCount =0; m_address.type = SEARCH_VALUE_TYPE_4BYTE;} 112 | }; 113 | typedef shared_ptr PointerItem; 114 | 115 | /* An AddressItem is either an address that we are focusing on or a base of a pointer that we are focusing on. 116 | The value is the memory at that address or whatever the resolved pointer address is. */ 117 | struct AddressItem 118 | { 119 | unsigned long address; 120 | unsigned long value; 121 | char sign; 122 | char type; 123 | PointerItem pointer; 124 | AddressItem() { address = 0; value = 0; sign = 0; } 125 | AddressItem(unsigned long a, unsigned long v, char t, char s) { address = a; value = v; type = t; sign = s; } //a single address 126 | AddressItem(unsigned long a, unsigned long v, char s) { address = a; value = v; type = SEARCH_VALUE_TYPE_4BYTE; sign = s; } //a single address 127 | AddressItem(unsigned long a, PointerOffsets p, char t, char s) { address = a; value = v; type = t; sign = s; } //a pointer 128 | AddressItem &operator=(AddressItem t) { address = t.address; value = t.value; sign = t.sign; type = t.type; return *this;} 129 | }; 130 | #endif 131 | 132 | struct DumpHeader 133 | { 134 | unsigned long begin, end; 135 | char misc; 136 | DumpHeader(unsigned long b, unsigned long e, char m) { begin = b; end = e; misc = m; } 137 | DumpHeader() { begin = 0; end = 0; misc = 0; } 138 | DumpHeader &operator=(DumpHeader t) { begin = t.begin; end = t.end; misc = t.misc; return *this;} 139 | }; 140 | 141 | struct _DumpData 142 | { 143 | DumpHeader header; 144 | char *data; 145 | _DumpData() { data=0;} 146 | _DumpData(DumpHeader h, char *d) { header = h, data = d;} 147 | _DumpData(_DumpData &s) { data = s.data; header = s.header; } 148 | ~_DumpData() { if (data !=0) delete[] data; data=0; } 149 | }; 150 | typedef shared_ptr<_DumpData> DumpData; 151 | typedef vector DumpDataList; 152 | 153 | #if 0 154 | typedef vector AddressList; 155 | #endif 156 | typedef map ResultList; 157 | 158 | //typedef pair RangePair; 159 | struct RangePair 160 | { 161 | long long m_first, m_second; 162 | RangePair(long long first, long long second) { set(first,second); } 163 | RangePair() { set(-1,-1); } 164 | void set(long long first, long long second) { m_first = first; m_second = second; } 165 | long long first() { return m_first; } 166 | long long second() { return m_second; } 167 | void first(long long v) { m_first = v; } 168 | void second(long long v) { m_second = v; } 169 | RangePair& operator=(RangePair p) { m_first = p.m_first; m_second = p.m_second; return *this;} 170 | }; 171 | typedef vector RangeList; 172 | 173 | struct MemoryReadItem{ 174 | AddressItem item; 175 | bool keep; 176 | MemoryReadItem(AddressItem i, bool k) { item = i; keep = k;} 177 | }; 178 | 179 | struct MemoryChunkReadItem{ 180 | unsigned int address; 181 | unsigned long length; 182 | char *memory; 183 | bool keep; 184 | MemoryChunkReadItem(unsigned int a, unsigned long l, char *m, bool k) { address = a; length = l; memory = m; keep = k;} 185 | }; 186 | 187 | struct PointerReadItem{ 188 | PointerItem pointer; 189 | bool keep; 190 | PointerReadItem(PointerItem p, bool k) { pointer = p; keep = k;} 191 | }; 192 | 193 | 194 | struct MemoryWriteItem{ 195 | AddressItem item; 196 | long long value; 197 | bool freeze; 198 | MemoryWriteItem(AddressItem i, long long v, bool f) { item = i; value = v; freeze = f;} 199 | }; 200 | 201 | typedef list> MemoryReadSet; 202 | typedef list> MemoryWriteSet; 203 | 204 | typedef list> MemoryChunkReadSet; 205 | 206 | typedef list> PointerReadSet; 207 | 208 | 209 | typedef map MemoryReadItemList; 210 | typedef map MemoryChunkReadItemList; 211 | typedef map PointerReadItemList; 212 | 213 | typedef map MemoryWriteItemList; 214 | 215 | struct MemoryConditionalWriteItem{ 216 | AddressItem conditionItem; 217 | char conditionType; 218 | long long conditionValue; 219 | bool hasRead; 220 | AddressList writeItems; 221 | MemoryConditionalWriteItem(AddressItem i, long long condValue, char con, AddressList wItems) { conditionItem = i; conditionType = con, conditionValue = condValue; writeItems = wItems; hasRead = false;} 222 | }; 223 | 224 | typedef list> ConditionalMemoryWriteSet; 225 | typedef map ConditionalMemoryWriteList; 226 | 227 | 228 | #endif 229 | -------------------------------------------------------------------------------- /CCAPI/CCAPI/DumpMemory.cpp: -------------------------------------------------------------------------------- 1 | #include "DumpMemory.h" 2 | #include "Common.h" 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | using namespace std; 9 | 10 | DumpMemory::DumpMemory(string ip, int ccapiVersion, unsigned long long offset, unsigned long long length) 11 | { 12 | m_ip = ip; 13 | m_offset = offset; 14 | m_length = length; 15 | m_threadProgressList.clear(); 16 | m_threadCount = 1; 17 | m_error = TASK_ERROR_NONE; 18 | m_status = "INIT"; 19 | m_running = false; 20 | m_cancel = false; 21 | m_ccapiHostVersion = ccapiVersion; 22 | } 23 | 24 | DumpMemory::~DumpMemory() 25 | { 26 | for (unsigned int i=0; icancel(); 29 | } 30 | for (unsigned int j=0; jjoin(); 32 | m_threadList.clear(); //should remove all the thread pointers! 33 | } 34 | void DumpMemory::calculateThreads() 35 | { 36 | if (m_length >= 0x800000) 37 | m_threadCount = 4; 38 | else if (m_length >= 0x200000) 39 | m_threadCount = 2; 40 | else 41 | m_threadCount = 1; 42 | } 43 | 44 | void DumpMemory::progressCallBack(DumpTask* task, long long current, long long total) 45 | { 46 | bool done = true; 47 | bool found = false; 48 | bool check = false; 49 | for (ProgressList::iterator it = m_threadProgressList.begin(); it != m_threadProgressList.end(); ++it) 50 | { 51 | if (task == it->first) //we have it! 52 | { 53 | found = true; 54 | it->second.first = current; 55 | it->second.second = total; 56 | break; 57 | } 58 | } 59 | if (!found) 60 | m_threadProgressList.push_back(make_pair(task, make_pair(current, total))); 61 | check = task->getState() == Task::COMPLETE; 62 | if (!check) 63 | return; 64 | for (unsigned int i=0; igetState() != Task::COMPLETE) 67 | { 68 | done = false; 69 | break; 70 | } 71 | } 72 | if (done) 73 | { 74 | m_status = "DONE"; 75 | m_running = false; 76 | } 77 | } 78 | 79 | float DumpMemory::getProgress() 80 | { 81 | unsigned long long current=0, total = 0; 82 | if (m_threadProgressList.size() != m_threadList.size()) 83 | return 0.0f; 84 | if (m_status == "INIT") 85 | return 0.0f; 86 | for (ProgressList::iterator it = m_threadProgressList.begin(); it != m_threadProgressList.end(); ++it) 87 | { 88 | current+= it->second.first; 89 | total += it->second.second; 90 | } 91 | return (float) (current / (double)total); 92 | } 93 | 94 | unsigned int DumpMemory::process() 95 | { 96 | shared_ptr dumpTask; 97 | if (m_cancel) 98 | { 99 | m_running = false; 100 | return false; 101 | } 102 | m_status = "CONNECTING"; 103 | m_cancel = false; 104 | m_running = true; 105 | m_threadProgressList.clear(); 106 | if (m_threadList.empty()) 107 | { 108 | calculateThreads(); 109 | unsigned long long minSize = (unsigned long long) (m_length / (double)m_threadCount); 110 | unsigned long long minRemain = (unsigned long long) (m_length % m_threadCount); 111 | for (int i = 0; i(m_ip, m_offset+(i*minSize), minSize+minRemain, i, name); 122 | } 123 | else 124 | dumpTask = make_shared(m_ip, m_offset+(i*minSize), minSize, i, name); 125 | dumpTask->setHostCCAPIVersion(m_ccapiHostVersion); 126 | m_threadList.push_back(dumpTask); 127 | dumpTask->setProgressCallback(bind(&DumpMemory::progressCallBack, this, dumpTask.get(), placeholders::_2, placeholders::_3)); 128 | dumpTask->setErrorCallback(bind(&DumpMemory::getError, this)); 129 | dumpTask->start(); 130 | ::this_thread::sleep_for(::chrono::milliseconds(500)); 131 | } 132 | } 133 | else 134 | { 135 | for (int i = 0; ijoin(); 138 | } 139 | for (int i = 0; istart(); 142 | ::this_thread::sleep_for(::chrono::milliseconds(500)); 143 | } 144 | } 145 | while (true) 146 | { 147 | bool ready = true; 148 | for (unsigned int i=0; igetStatus() != "CONNECTED") 151 | { 152 | if (m_threadList.at(i)->getStatus() == "ERROR") 153 | { 154 | switch (m_threadList.at(i)->getError()) 155 | { 156 | case TASK_ERROR_NO_ATTACH: m_error = TASK_ERROR_NO_ATTACH; break; 157 | case TASK_ERROR_NO_CONNECT: m_error = TASK_ERROR_NO_CONNECT; break; 158 | case TASK_ERROR_CANCEL: m_error = TASK_ERROR_CANCEL; break; 159 | default: break; 160 | } 161 | for (unsigned int j=0; jjoin(); 163 | m_threadList.clear(); 164 | m_running = false; 165 | return m_error; 166 | } 167 | ready = false; 168 | break; 169 | } 170 | } 171 | if (ready) break; 172 | ::this_thread::sleep_for(::chrono::milliseconds(100)); 173 | } 174 | if (m_status != "DONE") 175 | m_status = "DUMPMEMORY"; 176 | for (unsigned int i=0; ifire(); 188 | } 189 | return TASK_ERROR_NONE; 190 | } 191 | 192 | void DumpMemory::cancel() 193 | { 194 | cancelLock.lock(); 195 | m_cancel = true; 196 | cancelLock.unlock(); 197 | cout << "CANCELED!" << endl; 198 | for (unsigned int i=0; icancel(); 201 | } 202 | for (unsigned int j=0; jjoin(); 204 | m_threadList.clear(); 205 | m_status = "CANCEL"; 206 | } 207 | 208 | 209 | DumpData DumpMemory::consolideDump() 210 | { 211 | unsigned long totalSize = 0; 212 | unsigned long pos=0; 213 | for (int i = 0; igetLength(); 215 | DumpData dd = DumpData(new _DumpData); 216 | 217 | dd->data = new char[totalSize]; 218 | for (int i = 0; igetBuffer(); 221 | memcpy(&dd->data[pos], b, (unsigned long)m_threadList.at(i)->getLength()); 222 | pos+=(unsigned long)m_threadList.at(i)->getLength(); 223 | } 224 | dd->header.begin=(unsigned long)m_offset; 225 | dd->header.end=(unsigned long)(m_offset+m_length); 226 | return dd; 227 | } 228 | -------------------------------------------------------------------------------- /CCAPI/CCAPI/DumpMemory.h: -------------------------------------------------------------------------------- 1 | #ifndef _DUMPMEMORY_ 2 | #define _DUMPMEMORY_ 3 | 4 | #include "DumpTask.h" 5 | #include 6 | 7 | using namespace std; 8 | 9 | typedef vector>> ProgressList; 10 | 11 | class DumpMemory 12 | { 13 | public: 14 | DumpMemory(string ip, int ccapiVersion, unsigned long long offset, unsigned long long length); 15 | ~DumpMemory(); 16 | unsigned int process(); 17 | void cancel(); 18 | void progressCallBack(DumpTask* task, long long current, long long total); 19 | float getProgress(); 20 | string getStatus() { return m_status; } 21 | void resetStatus() { m_status = "INIT"; } 22 | unsigned int getError() { return m_error; } 23 | void stopThreads() { for (unsigned int i=0; ijoin(); } } 24 | bool isRunning() { return m_running; } 25 | DumpData consolideDump(); 26 | 27 | private: 28 | 29 | void calculateThreads(); 30 | 31 | unsigned long long m_offset, m_length; 32 | string m_ip; 33 | string m_status; 34 | unsigned int m_error; 35 | 36 | int m_threadCount; 37 | ProgressList m_threadProgressList; 38 | vector> m_threadList; 39 | 40 | bool m_cancel; 41 | bool m_running; 42 | mutex cancelLock; 43 | mutex statusLock; 44 | 45 | int m_ccapiHostVersion; 46 | 47 | }; 48 | #endif -------------------------------------------------------------------------------- /CCAPI/CCAPI/DumpTask.cpp: -------------------------------------------------------------------------------- 1 | #include "DumpTask.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "Helpers.h" 7 | 8 | 9 | using namespace std; 10 | 11 | DumpTask::DumpTask(string ip, unsigned long long offset, unsigned long long length, unsigned int id, string name) : Task(id, name) 12 | { 13 | char buf[255]; 14 | m_offset = offset; 15 | m_length = length; 16 | m_ip = ip; 17 | m_connected = false; 18 | char *pt __attribute__((unused)); 19 | pt = GetCurrentDir(buf, 255); 20 | m_buffer = 0; 21 | } 22 | 23 | DumpTask::~DumpTask() 24 | { 25 | if (m_buffer) 26 | delete [] m_buffer; 27 | if (m_ccapi != nullptr && m_ccapi->isAttached()) 28 | m_ccapi->disconnect(); 29 | } 30 | 31 | 32 | void DumpTask::run() 33 | { 34 | unsigned int res; 35 | if (m_cancel) 36 | return; 37 | m_taskState = Task::WAIT; 38 | res = connectAndAttach(); 39 | if (res == TASK_ERROR_NONE) 40 | { 41 | res = waitForFire(); 42 | if (res == TASK_ERROR_NONE) 43 | { 44 | m_taskState = Task::WORKING; 45 | doDump(); 46 | } 47 | } 48 | } 49 | 50 | int DumpTask::connect(int loops) 51 | { 52 | m_ccapi->setHostVersion(m_ccapiHostVersion); 53 | if (m_ccapi->connect() == 0) 54 | { 55 | for (int i=0; idisconnect(); 60 | return TASK_ERROR_CANCEL; 61 | } 62 | this_thread::sleep_for(chrono::milliseconds(50)); 63 | } 64 | } 65 | else 66 | return TASK_ERROR_NO_CONNECT; 67 | return TASK_ERROR_NONE; 68 | } 69 | 70 | int DumpTask::attach() 71 | { 72 | int res; 73 | res = m_ccapi->attach(); 74 | if (res == 0) 75 | { 76 | m_ccapi->disconnect(); 77 | m_status = "ERROR"; 78 | m_error = TASK_ERROR_NO_ATTACH; 79 | m_connected = false; 80 | return m_error; 81 | } 82 | else if (res == -1) //disconnected! 83 | { 84 | if (m_cancel) 85 | return TASK_ERROR_CANCEL; 86 | m_status = "ERROR"; 87 | m_error = TASK_ERROR_NO_ATTACH; 88 | m_connected = false; 89 | return m_error; 90 | } 91 | return TASK_ERROR_NONE; 92 | } 93 | 94 | int DumpTask::connectAndAttach(int retry) 95 | { 96 | m_status = "CONNECT"; 97 | int res = 0; 98 | if (m_ccapi == nullptr || !m_ccapi->isConnected()) 99 | { 100 | for (int i=0; i(m_ip); 103 | res = connect(); 104 | if (res == TASK_ERROR_NONE) 105 | break; 106 | } 107 | if (!m_ccapi->isConnected()) 108 | { 109 | m_status = "ERROR"; 110 | m_connected = false; 111 | return TASK_ERROR_NO_CONNECT; 112 | } 113 | } 114 | if (!m_ccapi->isAttached()) 115 | { 116 | res = attach(); 117 | if (!m_ccapi->isAttached()) 118 | { 119 | m_status = "ERROR"; 120 | m_connected = false; 121 | return TASK_ERROR_NO_ATTACH; 122 | } 123 | } 124 | m_status = "CONNECTED"; 125 | m_connected = true; 126 | return TASK_ERROR_NONE; 127 | } 128 | 129 | unsigned int DumpTask::waitForFire() 130 | { 131 | while (m_fire != true) 132 | { 133 | if (m_cancel) 134 | { 135 | m_ccapi->disconnect(); 136 | return TASK_ERROR_CANCEL; 137 | } 138 | this_thread::sleep_for(chrono::milliseconds(50)); 139 | if (m_errorCallback != nullptr) 140 | { 141 | unsigned int error = m_errorCallback(); 142 | if (error != TASK_ERROR_NONE) 143 | { 144 | m_ccapi->disconnect(); 145 | return error; 146 | } 147 | } 148 | } 149 | return TASK_ERROR_NONE; 150 | 151 | } 152 | int DumpTask::doDump() 153 | { 154 | unsigned long rounds, remains, bufferPos; 155 | if (m_buffer) 156 | delete [] m_buffer; 157 | m_buffer = new char[(unsigned long)m_length]; 158 | char *data; 159 | unsigned int readSize; 160 | calculateReads(RANGE_INTERVAL, rounds, remains); 161 | bufferPos = 0; 162 | for (unsigned long long i=0; ireadMemory((unsigned long)(m_offset+(i*RANGE_INTERVAL)), RANGE_INTERVAL) == 0) 171 | { 172 | data = m_ccapi->getData(readSize); 173 | memcpy(&m_buffer[bufferPos], data, readSize); 174 | bufferPos += readSize; 175 | progressCallback(this, bufferPos, m_length); 176 | } 177 | } 178 | if (remains > 0) 179 | { 180 | if (m_ccapi->readMemory((unsigned long)(m_offset+m_length-remains), remains) == 0) 181 | { 182 | data = m_ccapi->getData(readSize); 183 | memcpy(&m_buffer[bufferPos], data, readSize); 184 | bufferPos += readSize; 185 | } 186 | } 187 | if (m_cancel) 188 | { 189 | delete [] m_buffer; 190 | m_buffer = 0; 191 | return TASK_ERROR_CANCEL; 192 | } 193 | m_fire = false; 194 | disconnect(); 195 | m_taskState = Task::COMPLETE; 196 | progressCallback(this, m_length, m_length); 197 | return TASK_ERROR_NONE; 198 | } 199 | 200 | void DumpTask::calculateReads(unsigned long interval, unsigned long &rounds, unsigned long &remain) 201 | { 202 | unsigned long long minSize = m_length / interval; 203 | unsigned long long minRemain = m_length % interval; 204 | 205 | rounds = (unsigned long) minSize; 206 | remain = (unsigned long) minRemain; 207 | } 208 | 209 | 210 | void DumpTask::disconnect() 211 | { 212 | if (m_connected) 213 | { 214 | m_ccapi->disconnect(); 215 | m_connected = false; 216 | } 217 | } 218 | 219 | -------------------------------------------------------------------------------- /CCAPI/CCAPI/DumpTask.h: -------------------------------------------------------------------------------- 1 | #ifndef _DUMPTASK_ 2 | #define _DUMPTASK_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include "Task.h" 8 | 9 | #ifdef _WIN32 10 | #include 11 | #define GetCurrentDir _getcwd 12 | #else 13 | #include 14 | #define GetCurrentDir getcwd 15 | #endif 16 | 17 | 18 | using namespace std; 19 | 20 | class DumpTask: public Task 21 | { 22 | public: 23 | DumpTask(string ip, unsigned long long offset, unsigned long long length, unsigned int id, string name); 24 | ~DumpTask(); 25 | 26 | virtual void run(void); 27 | 28 | int connectAndAttach(int retry=3); 29 | 30 | int connect(int loops=10); 31 | int attach(); 32 | 33 | 34 | 35 | void setProgressCallback(function cb) { m_progressCallback = cb; } 36 | void setErrorCallback(function cb) { m_errorCallback = cb; } 37 | 38 | long long getLastOffset() { return m_length+m_offset; } 39 | long long getFirstOffset() { return m_offset; } 40 | long long getLength() { return m_length; } 41 | char *getBuffer() {return m_buffer;} 42 | 43 | 44 | 45 | 46 | protected: 47 | function m_progressCallback; 48 | function m_errorCallback; 49 | 50 | private: 51 | void disconnect(); 52 | 53 | int doDump(); 54 | 55 | void calculateReads(unsigned long interval, unsigned long &rounds, unsigned long &remain); 56 | unsigned int waitForFire(); 57 | 58 | void progressCallback(DumpTask* task, long long c, long long t) { if (m_progressCallback != nullptr) { m_progressCallback(task,c,t); } } 59 | 60 | bool m_connected; 61 | char *m_buffer; 62 | }; 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /CCAPI/CCAPI/Helpers.h: -------------------------------------------------------------------------------- 1 | #ifndef _HELPERS_ 2 | #define _HELPERS_ 3 | #include 4 | #include 5 | #include 6 | #include "Common.h" 7 | 8 | using namespace std; 9 | 10 | 11 | template 12 | string NumberToString ( T Number ) 13 | { 14 | stringstream ss; 15 | ss << Number; 16 | return ss.str(); 17 | } 18 | 19 | 20 | class Helpers 21 | { 22 | public: 23 | static int getTypeLength(char type) 24 | { 25 | switch (type) 26 | { 27 | case SEARCH_VALUE_TYPE_1BYTE: 28 | return 1; 29 | case SEARCH_VALUE_TYPE_2BYTE: 30 | return 2; 31 | default: 32 | return 4; 33 | } 34 | } 35 | 36 | static bool isSigned(char type, long long value) 37 | { 38 | if (value < 0) 39 | return true; 40 | int len = getTypeLength(type) * 8; 41 | if ( (unsigned long)value < (unsigned long)((1 << (len-1))) ) 42 | return true; 43 | return false; 44 | } 45 | 46 | static long long convert4BytesToType(long long value, char type) 47 | { 48 | switch (type) 49 | { 50 | case SEARCH_VALUE_TYPE_2BYTE: 51 | return (long long) ((short*) (&value))[1]; 52 | break; 53 | case SEARCH_VALUE_TYPE_4BYTE: 54 | return value; 55 | break; 56 | case SEARCH_VALUE_TYPE_1BYTE: 57 | return (long long) ((char*) (&value))[3]; 58 | break; 59 | default: 60 | return value; 61 | break; 62 | } 63 | } 64 | 65 | static long long convertValueType(long long value, char newType, char oldType, bool sign) 66 | { 67 | Variant variant(value); 68 | switch (oldType) 69 | { 70 | case SEARCH_VALUE_TYPE_1BYTE: 71 | if (newType == SEARCH_VALUE_TYPE_2BYTE) 72 | return (long) value; 73 | if (newType == SEARCH_VALUE_TYPE_4BYTE) 74 | return (long) value; 75 | if (newType == SEARCH_VALUE_TYPE_FLOAT) 76 | return variant.asLong(); 77 | break; 78 | case SEARCH_VALUE_TYPE_2BYTE: 79 | if (newType == SEARCH_VALUE_TYPE_1BYTE) //2 to 1 80 | { 81 | if (sign) 82 | return (char) value; 83 | else 84 | return (unsigned char) value; 85 | } 86 | if (newType == SEARCH_VALUE_TYPE_4BYTE) 87 | return (long) value; 88 | if (newType == SEARCH_VALUE_TYPE_FLOAT) 89 | return variant.asLong(); 90 | break; 91 | case SEARCH_VALUE_TYPE_4BYTE: 92 | if (newType == SEARCH_VALUE_TYPE_1BYTE) //4 to 1 93 | { 94 | if (sign) 95 | return (char) value; 96 | else 97 | return (unsigned char) value; 98 | } 99 | if (newType == SEARCH_VALUE_TYPE_2BYTE) //4 to 2 100 | { 101 | if (sign) 102 | return (short) value; 103 | else 104 | return (unsigned short) value; 105 | } 106 | if (newType == SEARCH_VALUE_TYPE_FLOAT) 107 | return variant.asLong(); 108 | break; 109 | default: 110 | if (newType == SEARCH_VALUE_TYPE_1BYTE) //float to 1 111 | return *(char*)&value; 112 | if (newType == SEARCH_VALUE_TYPE_2BYTE) //float to 2 113 | return variant.asShort(); 114 | if (newType == SEARCH_VALUE_TYPE_4BYTE) //float to 4 115 | return variant.asLong(); 116 | break; 117 | } 118 | return 0; 119 | } 120 | }; 121 | 122 | #endif 123 | -------------------------------------------------------------------------------- /CCAPI/CCAPI/Makefile: -------------------------------------------------------------------------------- 1 | include ../../Makefile.common 2 | objects = $(src:.cpp=.o) 3 | src := $(wildcard *.cpp) 4 | 5 | libccapi.a : $(objects) 6 | \mkdir -p ./lib 7 | ar rcs ./lib/libccapi.a $(objects) 8 | # \rm *.o 9 | 10 | %.o: %.cpp 11 | $(CC) $(CFLAGS) -c $< -o $@ 12 | 13 | clean: 14 | \rm -f *.o 15 | \rm -rf lib 16 | 17 | -------------------------------------------------------------------------------- /CCAPI/CCAPI/MemoryOperator.h: -------------------------------------------------------------------------------- 1 | #ifndef _MEMORYOPERATOR_ 2 | #define _MEMORYOPERATOR_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "Types.h" 10 | #include "Helpers.h" 11 | #include "Common.h" 12 | #include "CCAPI.h" 13 | 14 | class MemoryOperator 15 | { 16 | public: 17 | MemoryOperator(string ip) { m_ip = ip; m_exit = false; } 18 | ~MemoryOperator() {exit(); join(); } 19 | 20 | void start(); 21 | void join() { 22 | if (m_thread.joinable()) 23 | { 24 | m_thread.join(); 25 | } 26 | } 27 | void exit() { m_exit = true; } 28 | string getStatus() { return m_status; } 29 | 30 | void setWriteMemoryOperation(AddressItem item, long long value, bool freeze); 31 | void setReadMemoryOperation(AddressItem item, bool keep); 32 | void setChunkReadMemoryOperation(unsigned long start, unsigned long size, char *memory, bool keep); 33 | 34 | void setConditionalWriteMemoryOperation(AddressItem item, char conditionType, long long conditionValue, AddressList writeItems); 35 | 36 | void removeMemoryOperation(char command, AddressItem item); 37 | void removePointerOperation(char command, PointerItem p); 38 | void removeChunkReadOperation(unsigned long address); 39 | 40 | void setHostCCAPIVersion(int ver) { m_ccapiHostVersion = ver; } 41 | 42 | private: 43 | MemoryOperator() {} 44 | void run(); 45 | void process(); 46 | int processRead(); 47 | int processPointers(); 48 | int processChunkRead(); 49 | int processWrite(); 50 | int processConditional(); 51 | 52 | unsigned int getLength(char type) { return Helpers::getTypeLength(type); } 53 | long long readAddress(unsigned long address, char type); 54 | int writeAddress(unsigned long address, char type, Variant value); 55 | 56 | int doWrite(AddressItem, long long value); 57 | 58 | int connect(); 59 | 60 | thread m_thread; 61 | shared_ptr m_ccapi; 62 | string m_ip; 63 | MemoryReadItemList memoryReadOperationList; 64 | MemoryChunkReadItemList memoryChunkReadOperationList; 65 | MemoryWriteItemList memoryWriteOperationList; 66 | ConditionalMemoryWriteList memoryConditionalWriteOperationList; 67 | bool m_exit; 68 | string m_status; 69 | mutex m_mutex; 70 | int m_ccapiHostVersion; 71 | 72 | 73 | 74 | }; 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /CCAPI/CCAPI/NumberInput.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/primetime00/CCCheat/827fcfb0f06946ed9cde5a10dd489b4a677209ff/CCAPI/CCAPI/NumberInput.h -------------------------------------------------------------------------------- /CCAPI/CCAPI/RangeMemory.cpp: -------------------------------------------------------------------------------- 1 | #include "RangeMemory.h" 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | RangeMemory::RangeMemory(string ip, int ccapiVersion, unsigned long long offset, unsigned long long length) 8 | { 9 | m_ip = ip; 10 | m_offset = offset; 11 | m_length = length; 12 | memset(m_totals, 0, sizeof(long long)*MAX_THREADS); 13 | m_threadCount = 1; 14 | m_error = RANGEMEMORY_ERROR_NONE; 15 | m_ccapiHostVersion = ccapiVersion; 16 | 17 | } 18 | 19 | void RangeMemory::calculateThreads() 20 | { 21 | if (m_length >= 0x800000) 22 | m_threadCount = 8; 23 | else if (m_length >= 0x200000) 24 | m_threadCount = 4; 25 | else 26 | m_threadCount = 1; 27 | /* 28 | #ifdef _HOME 29 | m_threadCount = 1; 30 | #endif*/ 31 | } 32 | 33 | void RangeMemory::cancel() 34 | { 35 | m_cancel = true; 36 | cout << "CANCELED!" << endl; 37 | for (unsigned int i=0; icancel(); 40 | } 41 | for (unsigned int j=0; jjoin(); 43 | m_threadList.clear(); 44 | m_status = "CANCEL"; 45 | 46 | } 47 | void RangeMemory::callBack(RangeTask* task, long long current, long long size) 48 | { 49 | bool done = true; 50 | for (unsigned int i=0; igetLength()) 57 | done = false; 58 | } 59 | if (done) 60 | m_status = "DONE"; 61 | } 62 | 63 | float RangeMemory::getProgress() 64 | { 65 | long long total = 0; 66 | for (int i=0; igetIntervals(); 78 | int last = m_ranges.size()-1; 79 | if (m_ranges.at(last).second() == -1) 80 | m_ranges.at(last).second(m_threadList.at(0)->getLastOffset()); 81 | if (m_ranges.at(last).first() == -1) 82 | m_ranges.at(0).first(m_threadList.at(0)->getFirstOffset()); 83 | return m_ranges; 84 | } 85 | for (int i = m_threadList.size()-1; i>0; i--) 86 | { 87 | RangeTask *cur = m_threadList.at(i).get(); 88 | if (cur->getIntervals().size() == 0) 89 | continue; 90 | for (int j = i-1; j>=0; j--) 91 | { 92 | RangeTask *prev = m_threadList.at(j).get(); 93 | if (prev->getIntervals().size() == 0) 94 | continue; 95 | int last = prev->getIntervals().size()-1; 96 | if (prev->getIntervals().at(last).second() == -1 && cur->getFirstOffset() == cur->getIntervals().at(0).first()) //this is a continuation! 97 | { 98 | prev->setInterval(last, RangePair(prev->getIntervals().at(last).first(), cur->getIntervals().at(0).second())); 99 | cur->getIntervals().erase(cur->getIntervals().begin()); 100 | } 101 | else if (prev->getIntervals().at(last).second() == -1) 102 | { 103 | prev->setInterval(last, RangePair(prev->getIntervals().at(last).first(), cur->getFirstOffset())); 104 | //cur->getIntervals().erase(cur->getIntervals().begin()); 105 | } 106 | else //do we even need to check anymore 107 | break; 108 | } 109 | } 110 | m_ranges.clear(); 111 | for (unsigned int i = 0; i < m_threadList.size(); i++) 112 | { 113 | for (unsigned int j = 0; j < m_threadList.at(i)->getIntervals().size(); j++) 114 | { 115 | m_ranges.push_back(m_threadList.at(i)->getIntervals().at(j)); 116 | } 117 | } 118 | return m_ranges; 119 | } 120 | 121 | unsigned int RangeMemory::process() 122 | { 123 | shared_ptr rangeTask; 124 | calculateThreads(); 125 | unsigned long long minSize = (unsigned long long) (m_length / (double)m_threadCount); 126 | unsigned long long minRemain = (unsigned long long) (m_length % m_threadCount); 127 | m_cancel = false; 128 | m_status = "CONNECTING"; 129 | for (int i = 0; i(m_ip, m_offset+(i*minSize), minSize+minRemain, i, name); 136 | else 137 | rangeTask = make_shared(m_ip, m_offset+(i*minSize), minSize, i, name); 138 | m_threadList.push_back(rangeTask); 139 | rangeTask->setHostCCAPIVersion(m_ccapiHostVersion); 140 | rangeTask->setCallback(bind(&RangeMemory::callBack, this, rangeTask.get(), placeholders::_2, placeholders::_3)); 141 | rangeTask->setErrorCallback(bind(&RangeMemory::getError, this)); 142 | rangeTask->start(); 143 | ::this_thread::sleep_for(::chrono::milliseconds(500)); 144 | } 145 | while (true) 146 | { 147 | bool ready = true; 148 | for (unsigned int i=0; igetStatus() != "CONNECTED") 151 | { 152 | if (m_threadList.at(i)->getStatus() == "ERROR") 153 | { 154 | switch (m_threadList.at(i)->getError()) 155 | { 156 | case TASK_ERROR_NO_ATTACH: m_error = RANGEMEMORY_ERROR_NO_ATTACH; break; 157 | case TASK_ERROR_NO_CONNECT: m_error = RANGEMEMORY_ERROR_NO_CONNECT; break; 158 | default: break; 159 | } 160 | for (unsigned int j=0; jjoin(); 162 | m_threadList.clear(); 163 | return m_error; 164 | } 165 | ready = false; 166 | break; 167 | } 168 | } 169 | if (ready) break; 170 | ::this_thread::sleep_for(::chrono::milliseconds(100)); 171 | } 172 | m_status = "FINDRANGE"; 173 | for (unsigned int i=0; ifire(); 176 | ::this_thread::sleep_for(::chrono::milliseconds(100)); 177 | } 178 | return RANGEMEMORY_ERROR_NONE; 179 | } 180 | 181 | #if 0 182 | int sample_main() 183 | { 184 | unsigned int status; 185 | RangeMemory rm("127.0.0.1", 20, 0, 0x100000000); 186 | status = rm.process(); 187 | switch (status) 188 | { 189 | case RANGEMEMORY_ERROR_NO_CONNECT: 190 | cout << "Could not connect all threads!" << endl; 191 | return -1; 192 | break; 193 | case RANGEMEMORY_ERROR_NO_ATTACH: 194 | cout << "Could not attach all threads!" << endl; 195 | return -1; 196 | break; 197 | default: break; 198 | } 199 | int sec = 0; 200 | while (1) 201 | { 202 | ::this_thread::sleep_for(::chrono::milliseconds(1000)); 203 | cout << "PROGRESS: " << sec++ << " " << rm.getProgress() << endl; 204 | if (rm.getStatus() == "DONE") 205 | break; 206 | } 207 | //vector> z = rm.getRanges(); 208 | cout << "ALL DONE" << endl; 209 | } 210 | #endif 211 | -------------------------------------------------------------------------------- /CCAPI/CCAPI/RangeMemory.h: -------------------------------------------------------------------------------- 1 | #ifndef _RANGEMEMORY_ 2 | #define _RANGEMEMORY_ 3 | 4 | #include "RangeTask.h" 5 | 6 | using namespace std; 7 | 8 | #define RANGEMEMORY_ERROR_NONE 0x00 9 | #define RANGEMEMORY_ERROR_NO_CONNECT 0x01 10 | #define RANGEMEMORY_ERROR_NO_ATTACH 0x02 11 | 12 | class RangeMemory 13 | { 14 | public: 15 | RangeMemory(string ip, int ccapiVersion, unsigned long long offset, unsigned long long length); 16 | ~RangeMemory() {} 17 | 18 | unsigned int process(); 19 | void cancel(); 20 | void callBack(RangeTask* task, long long current, long long size); 21 | float getProgress(); 22 | string getStatus() { return m_status; } 23 | RangeList getRanges(); 24 | unsigned int getError() { return m_error; } 25 | 26 | 27 | private: 28 | 29 | void calculateThreads(); 30 | 31 | unsigned long long m_offset, m_length; 32 | string m_ip; 33 | string m_status; 34 | unsigned int m_error; 35 | bool m_cancel; 36 | 37 | int m_threadCount; 38 | long long m_totals[MAX_THREADS]; 39 | //vector> m_ranges; 40 | vector m_ranges; 41 | vector> m_threadList; 42 | int m_ccapiHostVersion; 43 | 44 | }; 45 | #endif -------------------------------------------------------------------------------- /CCAPI/CCAPI/RangeTask.cpp: -------------------------------------------------------------------------------- 1 | #include "RangeTask.h" 2 | #include "RangeMemory.h" 3 | #include 4 | #include 5 | 6 | 7 | using namespace std; 8 | 9 | RangeTask::RangeTask(string ip, unsigned long long offset, unsigned long long length, unsigned int id, string name) : Task(id, name) 10 | { 11 | m_offset = offset; 12 | m_length = length; 13 | m_ip = ip; 14 | m_lastGoodCheck = false; 15 | } 16 | 17 | void RangeTask::run() 18 | { 19 | m_pair = RangePair(-1,-1);//make_pair(-1,-1); 20 | m_firstValidOffset = -1; 21 | m_status = "CONNECT"; 22 | m_ccapi = make_shared(m_ip); 23 | m_ccapi->setHostVersion(m_ccapiHostVersion); 24 | if (m_ccapi->connect() == 0) 25 | { 26 | for (int i=0; i<10; i++) 27 | { 28 | if (m_cancel) 29 | { 30 | m_ccapi->disconnect(); 31 | return; 32 | } 33 | this_thread::sleep_for(chrono::milliseconds(50)); 34 | } 35 | if (m_ccapi->attach() == 0) 36 | { 37 | m_ccapi->disconnect(); 38 | m_status = "ERROR"; 39 | m_error = TASK_ERROR_NO_ATTACH; 40 | return; 41 | } 42 | m_status = "CONNECTED"; 43 | } 44 | else 45 | { 46 | m_status = "ERROR"; 47 | m_error = TASK_ERROR_NO_CONNECT; 48 | return; 49 | } 50 | while (m_fire != true) 51 | { 52 | if (m_cancel) 53 | { 54 | m_ccapi->disconnect(); 55 | return; 56 | } 57 | this_thread::sleep_for(chrono::milliseconds(50)); 58 | if (m_errorCallback != nullptr) 59 | { 60 | if (m_errorCallback() != RANGEMEMORY_ERROR_NONE) 61 | { 62 | m_ccapi->disconnect(); 63 | return; 64 | } 65 | } 66 | } 67 | m_status = "FINDRANGE"; 68 | 69 | for (unsigned long long i=m_offset; ivalidateMemory((unsigned long)i); 74 | if (check) 75 | { 76 | if (!m_lastGoodCheck) 77 | { 78 | m_pair.first(i); 79 | m_lastGoodCheck = true; 80 | } 81 | } 82 | else 83 | { 84 | if (m_lastGoodCheck) 85 | { 86 | m_pair.second(i); 87 | m_lastGoodCheck = false; 88 | m_intervals.push_back(RangePair(m_pair.first(), m_pair.second())); 89 | m_pair.first(-1); 90 | m_pair.second(-1); 91 | } 92 | } 93 | if (m_callback != nullptr) 94 | { 95 | m_callback(this, i-m_offset, m_length); 96 | } 97 | } 98 | if (m_pair.first() != -1 && m_pair.second() == -1) //we have a continuing pair 99 | m_intervals.push_back(RangePair(m_pair.first(), m_pair.second())); 100 | if (m_callback != nullptr) 101 | { 102 | m_callback(this, m_length, m_length); 103 | } 104 | m_ccapi->disconnect(); 105 | m_status = "DONE"; 106 | } 107 | -------------------------------------------------------------------------------- /CCAPI/CCAPI/RangeTask.h: -------------------------------------------------------------------------------- 1 | #ifndef _RANGETASK_ 2 | #define _RANGETASK_ 3 | 4 | #include 5 | #include 6 | #include "Common.h" 7 | #include "Task.h" 8 | 9 | 10 | using namespace std; 11 | 12 | class RangeTask: public Task 13 | { 14 | public: 15 | RangeTask(string ip, unsigned long long offset, unsigned long long length, unsigned int id, string name); 16 | ~RangeTask() {} 17 | 18 | virtual void run(void); 19 | 20 | 21 | void setCallback(function cb) { m_callback = cb; } 22 | void setErrorCallback(function cb) { m_errorCallback = cb; } 23 | //vector> getIntervals() { return m_intervals; } 24 | vector &getIntervals() { return m_intervals; } 25 | void setInterval(int pos, const RangePair &val) { m_intervals[pos] = val; } 26 | //pair getCurrentPair() { return m_pair; } 27 | RangePair getCurrentPair() { return m_pair; } 28 | 29 | long long getLastOffset() { return m_length+m_offset; } 30 | long long getFirstOffset() { return m_offset; } 31 | long long getLength() { return m_length; } 32 | 33 | 34 | 35 | protected: 36 | function m_callback; 37 | function m_errorCallback; 38 | 39 | private: 40 | //vector> m_intervals; 41 | vector m_intervals; 42 | //pair m_pair; 43 | RangePair m_pair; 44 | bool m_lastGoodCheck; 45 | long long m_firstValidOffset; 46 | 47 | }; 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /CCAPI/CCAPI/SearchMemory.h: -------------------------------------------------------------------------------- 1 | #ifndef _SEARCHMEMORY_ 2 | #define _SEARCHMEMORY_ 3 | 4 | #include "SearchTask.h" 5 | #include 6 | 7 | using namespace std; 8 | 9 | typedef vector>> ProgressList; 10 | 11 | class SearchMemory 12 | { 13 | public: 14 | SearchMemory(string ip, int ccapiVersion, unsigned long long offset, unsigned long long length); 15 | ~SearchMemory() {} 16 | 17 | unsigned int process(); 18 | void cancel(); 19 | void progressCallBack(SearchTask* task, long long current, long long total); 20 | float getProgress(); 21 | string getStatus() { return m_status; } 22 | void resetStatus() { m_status = "INIT"; } 23 | unsigned int getError() { return m_error; } 24 | void stopThreads() { for (unsigned int i=0; ijoin(); } } 25 | 26 | void setSearchType(char type) { m_searchType = type; } 27 | void setSearchValueType(char type) { m_searchValueType = type; } 28 | void setSearchCompareType(char type) { m_compareType = type; } 29 | void setSearchValue(long long val) { m_searchValue = val; } 30 | 31 | char getSearchType() { return m_searchType; } 32 | char getSearchValueType() { return m_searchValueType; } 33 | long long getSearchValue() { return m_searchValue; } 34 | vector *getResults() { return &m_threadResults; } 35 | bool isDump() { return m_dump; } 36 | bool isRunning() { return m_running; } 37 | unsigned long getNumberOfResults(); 38 | void reOrganizeResults(); 39 | 40 | private: 41 | 42 | void calculateThreads(); 43 | 44 | unsigned long long m_offset, m_length; 45 | string m_ip; 46 | string m_status; 47 | unsigned int m_error; 48 | 49 | int m_threadCount; 50 | ProgressList m_threadProgressList; 51 | vector> m_threadList; 52 | vector m_threadResults; 53 | 54 | char m_searchType; 55 | char m_searchValueType; 56 | char m_compareType; 57 | long long m_searchValue; 58 | unsigned int m_searchCount; 59 | bool m_dump; 60 | bool m_cancel; 61 | bool m_running; 62 | bool m_reorganize; 63 | mutex cancelLock; 64 | 65 | int m_ccapiHostVersion; 66 | 67 | }; 68 | #endif -------------------------------------------------------------------------------- /CCAPI/CCAPI/SearchTask.h: -------------------------------------------------------------------------------- 1 | #ifndef _SEARCHTASK_ 2 | #define _SEARCHTASK_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include "Task.h" 8 | #include "ChunkValueSearch.h" 9 | #include "ChunkFuzzySearch.h" 10 | 11 | #ifdef _WIN32 12 | #include 13 | #define GetCurrentDir _getcwd 14 | #else 15 | #include 16 | #define GetCurrentDir getcwd 17 | #endif 18 | 19 | 20 | using namespace std; 21 | 22 | class SearchTask: public Task 23 | { 24 | public: 25 | SearchTask(string ip, unsigned long long offset, unsigned long long length, unsigned int id, string name); 26 | ~SearchTask(); 27 | 28 | virtual void run(void); 29 | 30 | void setSearchType(unsigned char type) { m_searchType = type; } 31 | void setSearchValueType(unsigned char type) { m_searchValueType = type; } 32 | void setSearchValue(long long val) { m_searchValue = val; } 33 | void setSearchCompareType(unsigned char type) { m_compareType = type; } 34 | void setResultList(ResultList *r) { m_results = r; } 35 | int connectAndAttach(int retry=3); 36 | int doFuzzySearch(); 37 | int doValueSearch(); 38 | void setLastThread(bool v) { m_isLastThread = v; } 39 | 40 | int connect(int loops=10); 41 | int attach(); 42 | 43 | 44 | 45 | void setProgressCallback(function cb) { m_progressCallback = cb; } 46 | void setErrorCallback(function cb) { m_errorCallback = cb; } 47 | 48 | long long getLastOffset() { return m_length+m_offset; } 49 | long long getFirstOffset() { return m_offset; } 50 | long long getLength() { return m_length; } 51 | string getDumpFilename() { return m_dumpFile; } 52 | 53 | static unsigned long getNumberOfResults(ResultList resList); 54 | 55 | 56 | 57 | protected: 58 | function m_progressCallback; 59 | function m_errorCallback; 60 | 61 | private: 62 | int initialFuzzySearch(); 63 | int continueFuzzySearch(); 64 | int fuzzySearchDumpFile(ifstream &resFile); 65 | int fuzzySearchResults(); 66 | 67 | int initialValueSearch(); 68 | int continueValueSearch(); 69 | int valueSearchResults(); 70 | void disconnect(); 71 | 72 | void calculateReads(unsigned long interval, unsigned long &rounds, unsigned long &remain); 73 | unsigned int waitForFire(); 74 | 75 | void progressCallback(SearchTask* task, long long c, long long t) { if (m_progressCallback != nullptr) { m_progressCallback(task,c,t); } } 76 | 77 | void dumpDataToFile(ostream &dumpFile, unsigned long location, unsigned long length); 78 | 79 | string m_dumpFile; 80 | string m_dumpDir; 81 | ResultList *m_results; 82 | unsigned char m_searchType; 83 | unsigned char m_compareType; 84 | long long m_searchValue; 85 | unsigned char m_searchState; 86 | unsigned char m_searchValueType; 87 | bool m_isLastThread; 88 | ChunkValueSearch m_valueSearcher; 89 | ChunkFuzzySearch m_fuzzySearcher; 90 | bool m_connected; 91 | bool m_isFuzzy; 92 | }; 93 | 94 | #endif 95 | -------------------------------------------------------------------------------- /CCAPI/CCAPI/Task.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Task.h" 3 | 4 | Task::Task(unsigned int id, string name) 5 | { 6 | m_id = id; 7 | m_name = name; 8 | m_fire = false; 9 | m_error = TASK_ERROR_NONE; 10 | m_taskState = WAIT; 11 | m_cancel = false; 12 | } 13 | 14 | void Task::start() 15 | { 16 | m_thread = thread(&Task::run, this); 17 | } 18 | 19 | void Task::run(void) 20 | { 21 | } 22 | 23 | -------------------------------------------------------------------------------- /CCAPI/CCAPI/Task.h: -------------------------------------------------------------------------------- 1 | #ifndef _TASK_ 2 | #define _TASK_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "Common.h" 9 | #include "Types.h" 10 | #include "CCAPI.h" 11 | 12 | #define RANGE_INTERVAL 0x10000 13 | 14 | #define MAX_MEMORY_INTERVAL 0x10000 15 | #define MAX_THREADS 16 16 | 17 | #define TASK_ERROR_NONE 0x0 18 | #define TASK_ERROR_NO_CONNECT CCAPI_ERROR_NO_CONNECT 19 | #define TASK_ERROR_NO_ATTACH CCAPI_ERROR_NO_ATTACH 20 | #define TASK_ERROR_CANCEL CCAPI_ERROR_CANCEL 21 | #define TASK_ERROR_FILE_FAIL CCAPI_ERROR_FILE_FAIL 22 | 23 | using namespace std; 24 | class Task 25 | { 26 | public: 27 | Task(unsigned int id, string name); 28 | ~Task() { if (m_thread.joinable()) m_thread.join(); }; 29 | 30 | void start(); 31 | void join() { 32 | if (m_thread.joinable()) 33 | m_thread.join(); 34 | } 35 | void cancel() { m_cancel = true; m_ccapi->disconnect();} 36 | 37 | void fire() { m_fire = true; } 38 | 39 | string getStatus() { return m_status; } 40 | 41 | unsigned int getError() { return m_error; } 42 | void setHostCCAPIVersion(int ver) { m_ccapiHostVersion =ver; } 43 | 44 | //void setCallback(taskCallback c) { m_callback = c; } 45 | 46 | 47 | virtual void run(void); 48 | 49 | enum TaskState{ 50 | WAIT, 51 | WORKING, 52 | COMPLETE, 53 | } m_taskState; 54 | 55 | TaskState getState() { return m_taskState; } 56 | 57 | protected: 58 | 59 | unsigned int m_id; 60 | string m_name; 61 | thread m_thread; 62 | shared_ptr m_ccapi; 63 | 64 | unsigned long long m_offset; 65 | unsigned long long m_length; 66 | 67 | string m_ip; 68 | bool m_fire; 69 | bool m_cancel; 70 | 71 | unsigned int m_error; 72 | 73 | 74 | string m_status; 75 | int m_ccapiHostVersion; 76 | 77 | private: 78 | Task(); 79 | }; 80 | 81 | #endif -------------------------------------------------------------------------------- /CCAPI/CCAPI/Types.cpp: -------------------------------------------------------------------------------- 1 | #include "Common.h" 2 | #include "Types.h" 3 | #include 4 | 5 | using namespace std; 6 | 7 | PointerObj::PointerObj(AddressOffsets b) 8 | { 9 | pointers = b; updateCount = 0; 10 | resolved = 0; 11 | } 12 | 13 | PointerObj::PointerObj(const unsigned long address, const PointerOffsets &pt) 14 | { 15 | fromPointerOffsets(address, pt); updateCount =0; 16 | resolved = 0; 17 | } 18 | 19 | PointerOffsets PointerObj::getOffsets() 20 | { 21 | PointerOffsets po; 22 | for (auto it = pointers.begin(); it != pointers.end(); ++it) 23 | { 24 | po.push_back(it->offset); 25 | } 26 | return po; 27 | } 28 | void PointerObj::fromPointerOffsets(const unsigned long address, const PointerOffsets &pt) 29 | { 30 | pointers.clear(); 31 | for (auto it = pt.begin(); it!= pt.end(); ++ it) 32 | { 33 | pointers.push_back(AddressOffset(0, *it)); 34 | } 35 | if (pointers.size() > 0) pointers.front().address = address; 36 | } 37 | 38 | bool PointerObj::equal(PointerObj p) { 39 | auto pstart = p.pointers.begin(); 40 | auto start = pointers.begin(); 41 | //if (p.getBase() != getBase()) return false; 42 | if (p.pointers.size() != pointers.size()) return false; 43 | while (start != pointers.end()) 44 | { 45 | if (start->offset != pstart->offset) return false; 46 | ++start; ++pstart; 47 | } 48 | return true; 49 | } 50 | void PointerObj::update() 51 | { 52 | updateCount++; updateCount %= 0xFFFFFFF; 53 | } 54 | 55 | AddressObj::AddressObj(unsigned long a, unsigned long v, char s) 56 | { 57 | init(a, v, SEARCH_VALUE_TYPE_4BYTE, s); 58 | } 59 | 60 | AddressObj::AddressObj() 61 | { 62 | init(0,0,SEARCH_VALUE_TYPE_4BYTE,0); 63 | } 64 | 65 | AddressObj::AddressObj(unsigned long a, unsigned long v, char t, char s) 66 | { 67 | init(a,v,t,s); 68 | } 69 | AddressObj::AddressObj(unsigned long a, PointerOffsets p, char t, char s) 70 | { 71 | address = a; type = t; sign = s; 72 | pointer = make_shared(a, p); 73 | } 74 | 75 | AddressObj::AddressObj(unsigned long a, PointerOffsets p, unsigned long v, char t, char s) 76 | { 77 | address = a; type = t; sign = s; 78 | pointer = make_shared(a, p); 79 | value = store = v; 80 | } 81 | 82 | AddressObj::AddressObj(unsigned long a, PointerItem p, char t, char s) 83 | { 84 | address = a; type = t; sign = s; 85 | if (p) 86 | pointer = make_shared(a, p->getOffsets()); 87 | else 88 | pointer = nullptr; 89 | } 90 | 91 | 92 | AddressObj::AddressObj(AddressObj &item) 93 | { 94 | address = 0; 95 | pointer = nullptr; 96 | sign = false; 97 | type = 0; 98 | value = 0; 99 | *this = item; 100 | } 101 | 102 | void AddressObj::init(unsigned long a, unsigned long v, char t, char s) 103 | { 104 | address = a; value = v; type = t; sign = s; store = v; 105 | } 106 | AddressObj & AddressObj::operator=(const AddressObj& t) 107 | { 108 | address = t.address; value = t.value; sign = t.sign; type = t.type; store = t.store; 109 | if (t.pointer != nullptr) 110 | { 111 | pointer = make_shared(address, t.pointer->getOffsets()); 112 | } 113 | return *this; 114 | } 115 | 116 | bool AddressObj::operator==(const AddressObj &t) 117 | { 118 | if (t.address == address) 119 | { 120 | if ( t.pointer && pointer ) 121 | { 122 | auto toff = t.pointer->getOffsets(); 123 | auto off = pointer->getOffsets(); 124 | if (toff.size() != off.size()) 125 | return false; 126 | auto j = off.begin(); 127 | for (auto i=toff.begin(); i != toff.end(); ++i, ++j) 128 | { 129 | if (*i != *j) 130 | return false; 131 | } 132 | return true; 133 | } 134 | else if (!t.pointer && !pointer) 135 | return true; 136 | } 137 | return false; 138 | } 139 | 140 | bool AddressObj::operator!=(const AddressObj &t) 141 | { 142 | return !(*this == t); 143 | } 144 | 145 | 146 | int AddressObj::read(char *buf) 147 | { 148 | int pos = 0; 149 | unsigned int offset; 150 | memcpy(&address, &buf[pos], sizeof(unsigned long)); pos += sizeof(unsigned long); 151 | memcpy(&value, &buf[pos], sizeof(long long)); pos += sizeof(long long); 152 | store = value; 153 | type = buf[pos]; pos += 1; 154 | sign = 0; 155 | int NumOfPointers = buf[pos]; pos += 1; 156 | if (NumOfPointers > 0) 157 | { 158 | PointerOffsets pt; 159 | for (int i=0; i < NumOfPointers; ++i) 160 | { 161 | memcpy(&offset, &buf[pos], sizeof(unsigned int)); pos += sizeof(unsigned int); 162 | pt.push_back(offset); 163 | } 164 | pointer = make_shared(address, pt); 165 | } 166 | return pos; 167 | } 168 | 169 | int AddressObj::write(char *buf) 170 | { 171 | int pos = 0; 172 | unsigned int offset; 173 | memcpy(&buf[pos], &address, sizeof(unsigned long)); pos += sizeof(unsigned long); 174 | memcpy(&buf[pos], &store, sizeof(long long)); pos += sizeof(long long); 175 | buf[pos] = type; pos += 1; 176 | buf[pos] = pointer ? pointer->getOffsets().size() : 0; pos += 1; 177 | if (pointer && pointer->getOffsets().size() > 0) 178 | { 179 | PointerOffsets pt = pointer->getOffsets(); 180 | for (auto i = pt.begin(); i != pt.end(); ++i) 181 | { 182 | unsigned int v = *i; 183 | memcpy(&buf[pos], &v, sizeof(unsigned int)); pos += sizeof(unsigned int); 184 | } 185 | } 186 | return pos; 187 | } 188 | 189 | void AddressObj::debug() 190 | { 191 | cout << "Address Obj Info:" << endl; 192 | cout << "Base Address: " << hex << address << endl; 193 | cout << "Value: " << dec << value << endl; 194 | cout << "Store: " << dec << store << endl; 195 | cout << "Type: " << dec << (int)type <getOffsets(); 200 | int p = 0; 201 | for (auto i = pt.begin(); i != pt.end(); ++i, ++p) 202 | { 203 | cout << "Pointer Offset ["< 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | class Variant 12 | { 13 | public: 14 | Variant(float v); 15 | Variant(short v); 16 | Variant(char v); 17 | Variant(long v); 18 | Variant(long long v); 19 | Variant() { pt_obj.cPt = (char*)&value;} 20 | 21 | 22 | float asFloat() { return *pt_obj.fPt; } 23 | long asLong() { return *pt_obj.lPt; } 24 | short asShort() { return *pt_obj.sPt; } 25 | char asChar() { return *pt_obj.cPt; } 26 | long long asLongLong() { return *pt_obj.llPt; } 27 | char * asPointer() { return pt_obj.cPt; } 28 | 29 | short *convertToShortPointer(char *pt) { pt_obj.cPt = pt; return pt_obj.sPt; } 30 | long *convertToLongPointer(char *pt) { pt_obj.cPt = pt; return pt_obj.lPt; } 31 | long long *convertToLongLongPointer(char *pt) { pt_obj.cPt = pt; return pt_obj.llPt; } 32 | float *convertToFloatPointer(char *pt) { pt_obj.cPt = pt; return pt_obj.fPt; } 33 | 34 | short convertToShort(char *pt) { pt_obj.cPt = pt; return *pt_obj.sPt; } 35 | long convertToLong(char *pt) { pt_obj.cPt = pt; return *pt_obj.lPt; } 36 | long long convertToLongLong(char *pt) { pt_obj.cPt = pt; return *pt_obj.llPt; } 37 | float convertToFloat(char *pt) { pt_obj.cPt = pt; return *pt_obj.fPt; } 38 | 39 | private: 40 | union pointer 41 | { 42 | char *cPt; 43 | short *sPt; 44 | long *lPt; 45 | long long *llPt; 46 | float *fPt; 47 | } pt_obj; 48 | char value[8]; 49 | }; 50 | 51 | struct AddressOffset //this is a pointer helper that contains an address and an offset 52 | { 53 | unsigned long address; 54 | unsigned int offset; 55 | AddressOffset(unsigned long a, unsigned int o) { address = a; offset = o; } 56 | }; 57 | 58 | typedef list PointerOffsets; //this is a list of offsets for a pointer 59 | typedef list AddressOffsets; //this is a list of address and offset items 60 | 61 | 62 | class PointerObj 63 | { 64 | public: 65 | PointerObj(AddressOffsets b); 66 | PointerObj(const unsigned long address, const PointerOffsets &pt); 67 | 68 | AddressOffsets pointers; 69 | unsigned long resolved; //this is our resolved address 70 | 71 | unsigned int updateCount; 72 | void fromPointerOffsets(const unsigned long address, const PointerOffsets &pt); 73 | bool equal(PointerObj p); 74 | void update(); 75 | PointerOffsets getOffsets(); 76 | }; 77 | typedef shared_ptr PointerItem; 78 | 79 | /* An AddressItem is either an address that we are focusing on or a base of a pointer that we are focusing on. 80 | The value is the memory at that address or whatever the resolved pointer address is. */ 81 | class AddressObj 82 | { 83 | public: 84 | unsigned long address; //this is our base address 85 | long long value; //this is the memory from either our base address or our resolved address 86 | long long store; //this is the value we will write to memory 87 | char sign; //signed or unsigned 88 | char type; //1-4byte, float 89 | PointerItem pointer; //our pointer info if we are using one 90 | AddressObj(); 91 | AddressObj(AddressObj &item); 92 | AddressObj(unsigned long a, unsigned long v, char t, char s); //a single address 93 | AddressObj(unsigned long a, unsigned long v, char s); //a single address 94 | AddressObj(unsigned long a, PointerOffsets p, char t, char s); //a pointer 95 | AddressObj(unsigned long a, PointerOffsets p, unsigned long v, char t, char s); //a pointer and value 96 | AddressObj(unsigned long a, PointerItem p, char t, char s); //a pointer 97 | void init(unsigned long a, unsigned long v, char t, char s); 98 | AddressObj &operator=(const AddressObj& t); 99 | bool operator==(const AddressObj &t); 100 | bool operator!=(const AddressObj &t); 101 | bool isPointer() { return pointer != nullptr; } 102 | int read(char *buf); 103 | int write(char *buf); 104 | void debug(); 105 | }; 106 | typedef shared_ptr AddressItem; 107 | 108 | typedef vector AddressList; 109 | #endif 110 | -------------------------------------------------------------------------------- /CCAPI/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | $(MAKE) -C CCAPI 3 | #all: 4 | # cd UI; make 5 | 6 | clean: 7 | $(MAKE) -C CCAPI clean 8 | 9 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | export TOP_DIR = $(shell pwd) 2 | include Makefile.common 3 | all: ccapi trainer ui 4 | # $(MAKE) -C CCAPI 5 | # $(MAKE) -C UI 6 | 7 | trainer: 8 | $(MAKE) -C Trainer 9 | 10 | ui: 11 | $(MAKE) -C UI 12 | \mkdir -p bin 13 | \mv $(UI_DIR)/UI/$(TARGET) ./bin 14 | 15 | ccapi: 16 | $(MAKE) -C CCAPI 17 | 18 | clean: 19 | $(MAKE) -C CCAPI clean 20 | $(MAKE) -C UI clean 21 | \rm -f $(TARGET) 22 | -------------------------------------------------------------------------------- /Makefile.common: -------------------------------------------------------------------------------- 1 | CCAPI_DIR := $(TOP_DIR)/CCAPI 2 | TRAINER_DIR := $(TOP_DIR)/Trainer 3 | UI_DIR := $(TOP_DIR)/UI 4 | FLTK_DIR := $(TOP_DIR)/../../fltk/fltk 5 | TARGET := CCCheat 6 | 7 | INCLUDES := -I. -I$(CCAPI_DIR) -I$(TRAINER_DIR) -I$(FLTK_DIR) 8 | LIBS := -L$(TOP_DIR)/FLTK -L$(CCAPI_DIR)/CCAPI/lib -lccapi -lfltk -lGLU -lXrandr -lXinerama -lXext -lX11 -lXft -lfontconfig -ldl -lpthread 9 | 10 | CC = g++ 11 | #DEBUG = -O3 -g -rdynamic 12 | DEBUG = -O3 -s 13 | CFLAGS = -Wall -std=c++11 $(DEBUG) $(INCLUDES) 14 | #CFLAGS = -Wall -std=c++11 $(DEBUG) $(INCLUDES) -Wno-sign-compare -Wno-int-to-pointer-cast -Wno-parentheses -Wno-format 15 | #LFLAGS = -Wall $(DEBUG) 16 | #LFLAGS = -Wall $(DEBUG) $(LIBS) 17 | #INCLUDES = -I. -I../../CCAPI -I../../../../fltk/fltk 18 | #LIBS = -L../../FLTK -L../../CCAPI/CCAPI/lib -lccapi -lfltk -lGL -lGLU -lXrandr -lXinerama -lXext -lX11 -lXft -lfontconfig -ldl 19 | LFLAGS = -Wall $(DEBUG) $(LIBS) 20 | -------------------------------------------------------------------------------- /Manual/Manual.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/primetime00/CCCheat/827fcfb0f06946ed9cde5a10dd489b4a677209ff/Manual/Manual.docx -------------------------------------------------------------------------------- /Manual/cccheat.css: -------------------------------------------------------------------------------- 1 | /* MLP Design (http://www.mlpDesign.net). All Rights Reserved */ 2 | 3 | /* Global Style Settings */ 4 | 5 | body { background:#000; color:#ccc; text-align:left; font:normal 90% "Trebuchet MS",sans-serif; margin-left:5px;font-size: 1.0em;} 6 | img { border:0;} 7 | h1 { background:#000; color:#9c3; font-weight:bold; font-size: 3.4em; margin:0; padding-top: 6px; border-bottom:4px solid #9c3; padding-bottom:3px;} 8 | .top { padding-top:3em;} 9 | h2 { background:#000; color:#9c6; font-weight:bold; font-size:1.5em; margin:0; padding-top:4px;} 10 | h3 { border-bottom:#ccc 1px solid; padding-bottom:10px; font-size: 1em; font-weight: lighter; letter-spacing:.1em; clear:both;} 11 | a:link, a:visited, a:active { background-color:inherit; text-decoration: none; color:#9c3;} 12 | a:hover { background-color:inherit; text-decoration: none; color:#9f3;} 13 | form ul { list-style:none; margin-left:75px; padding:1px;} 14 | strong { background:#000; text-decoration: none; color:#9c6; font-weight:normal;} 15 | .button { text-align:center; padding:10px 0;} 16 | .spacer { height:2px; clear:both;} 17 | ul li{ padding-left:15px; color:inherit; text-align:left; padding-top:5px; padding-bottom:5px;} 18 | /* End of Global Settings */ 19 | 20 | 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | CCCheat 2 | ======= 3 | 4 | PS3 CCAPI Memory Modifier 5 | -------------------------------------------------------------------------------- /Trainer/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | $(MAKE) -C Trainer 3 | #all: 4 | # cd UI; make 5 | 6 | clean: 7 | $(MAKE) -C Trainer clean 8 | 9 | -------------------------------------------------------------------------------- /Trainer/Trainer/Interface.cpp: -------------------------------------------------------------------------------- 1 | #include "Interface.h" 2 | #include "ui_trainer.h" 3 | #include "CCAPI/Common.h" 4 | #include "FL/Fl.H" 5 | #include 6 | 7 | #if defined(_WIN32) || defined(WIN32) 8 | #pragma warning(disable:4503) 9 | #endif 10 | 11 | Interface *Interface::instance = 0; 12 | 13 | 14 | void Interface::connect(string ip) 15 | { 16 | m_ip = ip; 17 | ConnectionManager::startUp(); 18 | connection = make_shared(); 19 | memoryOperator = new MemoryOperator(ip); 20 | int ver = get_user_data(int, TrainerClass::uiInstance->ui_ccapiChoice->mvalue()->user_data()); 21 | memoryOperator->setHostCCAPIVersion(ver); 22 | memoryOperator->start(); 23 | Fl::add_timeout(0.2, Interface::connectCheck); 24 | } 25 | 26 | void Interface::_connectCheck() 27 | { 28 | if (memoryOperator != 0) 29 | { 30 | string stat = memoryOperator->getStatus(); 31 | if (stat == "CONNECT") //we are connecting still 32 | { 33 | Fl::repeat_timeout(0.2, Interface::connectCheck); 34 | TrainerClass::uiInstance->ui_trainerTable->deactivate(); 35 | } 36 | else if (stat == "ERROR") //we failed! 37 | { 38 | Fl::remove_timeout(Interface::connectCheck); 39 | TrainerClass::uiInstance->setConnectStatus(INTERFACE_CONNECT_FAIL); 40 | TrainerClass::uiInstance->ui_trainerTable->deactivate(); 41 | disconnect(); 42 | } 43 | else 44 | { 45 | Fl::remove_timeout(Interface::connectCheck); 46 | TrainerClass::uiInstance->setConnectStatus(INTERFACE_CONNECT_SUCCESS); 47 | TrainerClass::uiInstance->ui_trainerTable->activate(); 48 | } 49 | } 50 | } 51 | 52 | void Interface::disconnect() 53 | { 54 | TrainerClass::uiInstance->ui_trainerTable->deactivate(); 55 | if (memoryOperator != 0) 56 | { 57 | delete memoryOperator; 58 | } 59 | memoryOperator = 0; 60 | connection = nullptr; 61 | } 62 | 63 | void Interface::disable(rkTrainerCodeObj *item) 64 | { 65 | if (!item) return; 66 | if (item->m_conditionAddress) 67 | memoryOperator->removeMemoryOperation(MEMORY_COMMAND_CONDITIONAL, item->m_conditionAddress); 68 | else 69 | { 70 | for (auto i = item->m_addresses.begin(); i != item->m_addresses.end(); ++i) 71 | memoryOperator->removeMemoryOperation(MEMORY_COMMAND_WRITE, (*i)); 72 | } 73 | } 74 | 75 | void Interface::enable(rkTrainerCodeObj *item) 76 | { 77 | if (!item) return; 78 | if (item->m_conditionAddress) 79 | { 80 | memoryOperator->setConditionalWriteMemoryOperation(item->m_conditionAddress, item->conditionType, item->conditionValue, item->m_addresses); 81 | } 82 | else 83 | { 84 | for (auto i = item->m_addresses.begin(); i != item->m_addresses.end(); ++i) 85 | { 86 | if ((*i)->isPointer()) 87 | memoryOperator->setReadMemoryOperation((*i), true); 88 | memoryOperator->setWriteMemoryOperation((*i), (*i)->value, true); 89 | } 90 | } 91 | } -------------------------------------------------------------------------------- /Trainer/Trainer/Interface.h: -------------------------------------------------------------------------------- 1 | #ifndef _TRAINERINTERFACE_ 2 | #define _TRAINERINTERFACE_ 3 | 4 | #include 5 | #include "CCAPI/CCAPI.h" 6 | #include "CCAPI/Common.h" 7 | #include "CCAPI/MemoryOperator.h" 8 | #include "UI/Common.h" 9 | #include "Trainer.h" 10 | 11 | #ifndef _HOME 12 | #define PS3_IP "127.0.0.1" 13 | #else 14 | #define PS3_IP "192.168.137.2" 15 | #endif 16 | 17 | #define INTERFACE_CONNECT_SUCCESS 0x00 18 | #define INTERFACE_CONNECT_FAIL 0x01 19 | #define INTERFACE_DISCONNECT 0x02 20 | #define INTERFACE_CONNECTING 0x03 21 | 22 | 23 | #ifdef _WIN32 24 | #include 25 | #define GetCurrentDir _getcwd 26 | #else 27 | #include 28 | #define GetCurrentDir getcwd 29 | #endif 30 | 31 | #define get_user_data(type, data) (type)((unsigned long)data) 32 | 33 | class TrainerClass; 34 | 35 | class Interface { 36 | public: 37 | Interface(CCAPI *ccapi, TrainerClass *ui) { 38 | m_ccapi = ccapi; m_ui = ui; instance = this; memoryOperator = 0; 39 | } 40 | 41 | static void connectCheck(void *v) { if (instance != 0) { instance->_connectCheck(); } } 42 | void _connectCheck(); 43 | void connect(string ip); 44 | void disconnect(); 45 | 46 | void disable(rkTrainerCodeObj *item); 47 | void enable(rkTrainerCodeObj *item); 48 | 49 | static Interface *instance; 50 | 51 | private: 52 | 53 | TrainerClass *m_ui; 54 | CCAPI *m_ccapi; 55 | 56 | thread m_launcher; 57 | MemoryOperator *memoryOperator; 58 | shared_ptr connection; 59 | 60 | string m_ip; 61 | 62 | 63 | }; 64 | #endif -------------------------------------------------------------------------------- /Trainer/Trainer/Makefile: -------------------------------------------------------------------------------- 1 | include ../../Makefile.common 2 | 3 | TRAIN_TARGET="Trainer" 4 | objects = $(src:.cpp=.o) 5 | src := $(wildcard *.cpp *.cxx) 6 | INCLUDES += -I$(UI_DIR) 7 | #objects += $(UI_DIR)/UI/IPInput.o $(UI_DIR)/UI/NumberInput.o 8 | objects += IPInput.o NumberInput.o 9 | 10 | Trainer : $(objects) ui_trainer.o 11 | $(CC) $(DEBUG) $(INCLUDES) $(CFLAGS) $(objects) -o $(TRAIN_TARGET) $(LFLAGS) 12 | \mkdir -p dump 13 | \xxd -i Trainer > dump/TrainerSrc.cpp 14 | \sed -i 's/Trainer/trainSrc/g' dump/TrainerSrc.cpp 15 | 16 | %.o: %.cpp 17 | $(CC) $(DEBUG) $(INCLUDES) $(CFLAGS) -c $< -o $@ 18 | 19 | IPInput.o: $(UI_DIR)/UI/IPInput.cpp 20 | $(CC) $(DEBUG) $(INCLUDES) $(CFLAGS) -c $< -o $@ 21 | 22 | NumberInput.o: $(UI_DIR)/UI/NumberInput.cpp 23 | $(CC) $(DEBUG) $(INCLUDES) $(CFLAGS) -c $< -o $@ 24 | 25 | ui_trainer.o: ui_trainer.cxx 26 | $(CC) $(DEBUG) $(INCLUDES) $(CFLAGS) -c $< -o $@ 27 | 28 | clean: 29 | \rm -f *.o $(TRAIN_TARGET) 30 | \rm -rf dump 31 | 32 | -------------------------------------------------------------------------------- /Trainer/Trainer/Trainer.cpp: -------------------------------------------------------------------------------- 1 | // Trainer.cpp : Defines the entry point for the console application. 2 | // 3 | 4 | //#include "stdafx.h" 5 | #include "Trainer.h" 6 | #include "Interface.h" 7 | #include "ui_trainer.h" 8 | 9 | void windowCallback(Fl_Widget*, void*) { 10 | if (Fl::event()==FL_SHORTCUT && Fl::event_key()==FL_Escape) 11 | return; // ignore Escape 12 | exit(0); 13 | } 14 | 15 | char trainerTitle[TITLELEN] = {TITLE_TXT}; 16 | char trainerAuthor[AUTHORLEN] = {AUTHOR_TXT}; 17 | char trainerInfo[INFOLEN] = {INFO_TXT}; 18 | char trainerCodeDesc[CODESLEN] = {CODES_TXT}; 19 | char trainerGameTitle[GAMETITLELEN] = {GAME_TITLE_TXT}; 20 | char trainerGameVersion[VERSIONLEN] = {VERSION_TXT}; 21 | char trainerGameRegion[REGIONLEN] = {REGION_TXT}; 22 | 23 | stringstream info; 24 | void SetInfo() 25 | { 26 | info << "Trainer: " << trainerTitle << "\n"; 27 | info << "By: " << trainerAuthor << "\n"; 28 | info << "Game: " << trainerGameTitle << " " << trainerGameVersion << " [" << trainerGameRegion << "]\n\n"; 29 | info << trainerInfo; 30 | } 31 | 32 | int main(int argc, char* argv[]) 33 | { 34 | CCAPI ccapi("127.0.0.1"); 35 | TrainerClass ui; 36 | ui.make_window(); 37 | Interface iface(&ccapi, &ui); 38 | ui.setConnectStatus(INTERFACE_DISCONNECT); 39 | ui.mainWindow->label(trainerTitle); 40 | SetInfo(); 41 | ui.ui_infoBuffer.append(info.str().c_str()); 42 | ui.ui_trainerTable->setCodes(trainerCodeDesc); 43 | ui.ui_trainerTable->deactivate(); 44 | ui.mainWindow->callback(windowCallback); 45 | ui.mainWindow->show(); 46 | return Fl::run(); 47 | 48 | } 49 | 50 | -------------------------------------------------------------------------------- /Trainer/Trainer/Trainer.h: -------------------------------------------------------------------------------- 1 | #ifndef __TRAINER__ 2 | #define __TRAINER__ 3 | 4 | #include 5 | #include 6 | #include "CCAPI/Types.h" 7 | 8 | using namespace std; 9 | 10 | #define TITLELEN 256 11 | #define AUTHORLEN 128 12 | #define INFOLEN 4096 13 | #define CODESLEN 32768 14 | #define GAMETITLELEN 256 15 | #define VERSIONLEN 32 16 | #define REGIONLEN 32 17 | 18 | #define TITLE_TXT "TRAIN_TITLE" 19 | #define AUTHOR_TXT "TRAIN_AUTHOR" 20 | #define INFO_TXT "TRAIN_INFO" 21 | #define CODES_TXT "TRAIN_CODES" 22 | #define GAME_TITLE_TXT "TRAIN_GAME_TITLE" 23 | #define VERSION_TXT "TRAIN_GAME_VERSION" 24 | #define REGION_TXT "TRAIN_GAME_REGION" 25 | 26 | extern char trainerTitle[TITLELEN]; 27 | extern char trainerAuthor[AUTHORLEN]; 28 | extern char trainerInfo[INFOLEN]; 29 | extern char trainerCodeDesc[CODESLEN]; 30 | extern char trainerGameTitle[GAMETITLELEN]; 31 | extern char trainerGameVersion[VERSIONLEN]; 32 | extern char trainerGameRegion[REGIONLEN]; 33 | 34 | #if 0 35 | struct codeFmt 36 | { 37 | string name; 38 | char condition; 39 | char conditionType; 40 | long long conditionValue; 41 | AddressItem conditionItem; 42 | AddressList codeItems; 43 | codeFmt() { name = ""; conditionItem = nullptr; codeItems.clear(); } 44 | ~codeFmt() { conditionItem = nullptr; codeItems.clear(); } 45 | 46 | int write(char *buf) 47 | { 48 | int pos = 0; 49 | buf[pos] = name.length(); pos+=1; 50 | memcpy(&buf[pos], name.c_str(), (int)name.length()); pos += (int)name.length(); 51 | buf[pos] = condition; pos+=1; 52 | if (condition) 53 | { 54 | buf[pos] = conditionType; pos+=1; 55 | conditionItem->value = conditionValue; 56 | pos += conditionItem->write(&buf[pos]); 57 | } 58 | buf[pos] = codeItems.size(); pos+=1; 59 | for (auto i=codeItems.begin(); i != codeItems.end(); ++i) 60 | { 61 | pos += (*i)->write(&buf[pos]); 62 | } 63 | return pos; 64 | } 65 | 66 | int read(char *buf) 67 | { 68 | int pos = 0; 69 | int nameLen = buf[pos]; pos+=1; 70 | name = string(&buf[pos], nameLen); pos += (int)nameLen; 71 | condition = buf[pos]; pos+=1; 72 | if (condition) 73 | { 74 | conditionType = buf[pos]; pos+=1; 75 | conditionItem = make_shared(); 76 | pos += conditionItem->read(&buf[pos]); 77 | } 78 | int numOfCodes = buf[pos]; pos+=1; 79 | for (int i=0; i< numOfCodes; ++i) 80 | { 81 | auto code = make_shared(); 82 | pos += code->read(&buf[pos]); 83 | codeItems.push_back(code); 84 | } 85 | return pos; 86 | } 87 | 88 | }; 89 | 90 | typedef shared_ptr codeFmtItem; 91 | #endif 92 | 93 | #endif -------------------------------------------------------------------------------- /Trainer/Trainer/Trainer.v11.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/primetime00/CCCheat/827fcfb0f06946ed9cde5a10dd489b4a677209ff/Trainer/Trainer/Trainer.v11.suo -------------------------------------------------------------------------------- /Trainer/Trainer/Trainer.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {C65F4D93-1242-444D-A29A-399CD5C37671} 15 | Trainer 16 | 17 | 18 | 19 | Application 20 | true 21 | v110 22 | MultiByte 23 | 24 | 25 | Application 26 | false 27 | v110 28 | true 29 | MultiByte 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | Level3 45 | Disabled 46 | $(ProjectDir)\..\..\..\fltk;$(ProjectDir)\..\..\CCAPI;$(ProjectDir)\..\..\UI 47 | _MBCS;%(PreprocessorDefinitions);WIN32 48 | 49 | 50 | true 51 | kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);WSock32.Lib;CCAPI.lib;fltkd.lib 52 | $(ProjectDirectory)..\..\UI\$(IntDir)\;$(ProjectDirectory)..\..\..\fltk\lib 53 | 54 | 55 | 56 | 57 | Level3 58 | MaxSpeed 59 | true 60 | true 61 | $(ProjectDir)\..\..\..\fltk;$(ProjectDir)\..\..\CCAPI;$(ProjectDir)\..\..\UI 62 | _MBCS;%(PreprocessorDefinitions);WIN32 63 | 64 | 65 | true 66 | true 67 | true 68 | $(ProjectDirectory)..\..\UI\$(IntDir)\;$(ProjectDirectory)..\..\..\fltk\lib 69 | kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);WSock32.Lib;CCAPI.lib;fltk.lib 70 | Windows 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /Trainer/Trainer/Trainer.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | Header Files 29 | 30 | 31 | 32 | 33 | Source Files 34 | 35 | 36 | Source Files 37 | 38 | 39 | Source Files 40 | 41 | 42 | Source Files 43 | 44 | 45 | Source Files 46 | 47 | 48 | Source Files 49 | 50 | 51 | -------------------------------------------------------------------------------- /Trainer/Trainer/Trainer.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Trainer/Trainer/TrainerTable.h: -------------------------------------------------------------------------------- 1 | #ifndef _TRAINERTABLE_ 2 | #define _TRAINERTABLE_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include "UI/Common.h" 13 | #include 14 | #include 15 | #include 16 | #include "Trainer.h" 17 | 18 | using namespace std; 19 | 20 | 21 | 22 | class TrainerTable : public Fl_Table_Row { 23 | public: 24 | TrainerTable(int X, int Y, int W, int H, const char *l=0); 25 | ~TrainerTable() { Fl::remove_timeout(redraw); } 26 | 27 | void setCodes (char *codes); 28 | 29 | struct TrainObj 30 | { 31 | Fl_Text_Display *tDisplay; 32 | Fl_Text_Buffer *tBuffer; 33 | Fl_Light_Button *cButton; 34 | Fl_Group *cBox; 35 | rkTrainerCode cCode; 36 | friend class TrainerTable; 37 | TrainObj(rkTrainerCode &code); 38 | ~TrainObj() { 39 | if (tDisplay) delete tDisplay; if (tBuffer) delete tBuffer; if (cButton) delete cButton; if (cBox) delete cBox; 40 | tDisplay = 0; tBuffer = 0; cButton = 0; cCode = nullptr; cBox = 0; 41 | } 42 | void place(int row, TrainerTable *t); 43 | }; 44 | typedef shared_ptr TrainItem; 45 | typedef list TrainList; 46 | 47 | // static void codeFreezeChangedCB(Fl_Widget *w, void *item) { 48 | // ((TrainerTable *)w->parent()->parent())->onCodeFreezeChanged((rkCheat_Code*)item, ((Fl_Check_Button*)w)->value()); 49 | // } 50 | 51 | static void redraw(void*); 52 | 53 | protected: 54 | void draw_cell(TableContext context, int ROW=0, int COL=0, int X=0, int Y=0, int W=0, int H=0); 55 | int handle(int evt); 56 | 57 | private: 58 | void DrawHeader(const char *s, int X, int Y, int W, int H); 59 | void DrawData(const char *s, int X, int Y, int W, int H); 60 | void DrawCheckbox(int X, int Y, int W, int H); 61 | 62 | private: 63 | TrainList m_list; 64 | }; 65 | 66 | #endif -------------------------------------------------------------------------------- /Trainer/Trainer/ui_trainer.cxx: -------------------------------------------------------------------------------- 1 | // generated by Fast Light User Interface Designer (fluid) version 1.0302 2 | 3 | #include "ui_trainer.h" 4 | TrainerClass *TrainerClass::uiInstance=0; 5 | 6 | Fl_Menu_Item TrainerClass::menu_ui_ccapiChoice[] = { 7 | {"2.50", 0, 0, (void*)(25), 0, FL_NORMAL_LABEL, 0, 14, 0}, 8 | {"2.00", 0, 0, (void*)(20), 0, FL_NORMAL_LABEL, 0, 14, 0}, 9 | {0,0,0,0,0,0,0,0,0} 10 | }; 11 | Fl_Menu_Item* TrainerClass::ui_ccapiVersion25Item = TrainerClass::menu_ui_ccapiChoice + 0; 12 | Fl_Menu_Item* TrainerClass::ui_ccapiVersion20Item = TrainerClass::menu_ui_ccapiChoice + 1; 13 | 14 | TrainerClass::TrainerClass() { 15 | uiInstance = this; 16 | } 17 | 18 | Fl_Double_Window* TrainerClass::make_window() { 19 | { mainWindow = new Fl_Double_Window(728, 728, "Trainer Title"); 20 | mainWindow->user_data((void*)(this)); 21 | { ui_trainerTable = new TrainerTable(5, 245, 685, 400); 22 | ui_trainerTable->box(FL_THIN_DOWN_FRAME); 23 | ui_trainerTable->color(FL_BACKGROUND_COLOR); 24 | ui_trainerTable->selection_color(FL_BACKGROUND_COLOR); 25 | ui_trainerTable->labeltype(FL_NORMAL_LABEL); 26 | ui_trainerTable->labelfont(0); 27 | ui_trainerTable->labelsize(14); 28 | ui_trainerTable->labelcolor(FL_FOREGROUND_COLOR); 29 | ui_trainerTable->align(Fl_Align(FL_ALIGN_TOP)); 30 | ui_trainerTable->when(FL_WHEN_RELEASE); 31 | center(ui_trainerTable); 32 | ui_trainerTable->end(); 33 | } // TrainerTable* ui_trainerTable 34 | { ui_ipInput = new IPInput(140, 25, 255, 30); 35 | ui_ipInput->box(FL_NO_BOX); 36 | ui_ipInput->color(FL_BACKGROUND_COLOR); 37 | ui_ipInput->selection_color(FL_BACKGROUND_COLOR); 38 | ui_ipInput->labeltype(FL_NORMAL_LABEL); 39 | ui_ipInput->labelfont(0); 40 | ui_ipInput->labelsize(14); 41 | ui_ipInput->labelcolor(FL_FOREGROUND_COLOR); 42 | ui_ipInput->callback((Fl_Callback*)CanConnectCB); 43 | ui_ipInput->align(Fl_Align(FL_ALIGN_TOP)); 44 | ui_ipInput->when(FL_WHEN_CHANGED); 45 | readIP(); 46 | ui_ipInput->end(); 47 | } // IPInput* ui_ipInput 48 | { ui_connectButton = new Fl_Light_Button(30, 25, 100, 30, "Connect"); 49 | ui_connectButton->callback((Fl_Callback*)ConnectButtonCB); 50 | } // Fl_Light_Button* ui_connectButton 51 | { ui_ccapiChoice = new Fl_Choice(524, 34, 66, 21, "CCAPI Version:"); 52 | ui_ccapiChoice->down_box(FL_BORDER_BOX); 53 | ui_ccapiChoice->menu(menu_ui_ccapiChoice); 54 | } // Fl_Choice* ui_ccapiChoice 55 | { ui_opStatus = new Fl_Box(5, 655, 135, 16, "Ready"); 56 | } // Fl_Box* ui_opStatus 57 | { ui_infoBox = new Fl_Text_Display(10, 65, 685, 160); 58 | ui_infoBox->buffer(&ui_infoBuffer); 59 | center(ui_infoBox); 60 | } // Fl_Text_Display* ui_infoBox 61 | mainWindow->end(); 62 | } // Fl_Double_Window* mainWindow 63 | return mainWindow; 64 | } 65 | 66 | void TrainerClass::CanConnectCB(Fl_Widget *w, void *data) { 67 | bool valid = data ? true : false; 68 | if (valid && uiInstance) 69 | uiInstance->ui_connectButton->activate(); 70 | else if (!valid && uiInstance) 71 | uiInstance->ui_connectButton->deactivate(); 72 | } 73 | 74 | void TrainerClass::ConnectButtonCB(Fl_Widget *w, void *data) { 75 | if (Interface::instance) 76 | { 77 | if ( ((Fl_Button*)w)->value() == 0 ) //disconnect 78 | { 79 | Interface::instance->disconnect(); 80 | uiInstance->setConnectStatus(INTERFACE_DISCONNECT); 81 | } 82 | else 83 | { 84 | string ip = uiInstance->ui_ipInput->getIP(); 85 | uiInstance->ui_ipInput->deactivate(); 86 | Interface::instance->connect(ip); 87 | uiInstance->setConnectStatus(INTERFACE_CONNECTING); 88 | } 89 | } 90 | } 91 | 92 | void TrainerClass::readIP() { 93 | char buf[255]; 94 | if (GetCurrentDir(buf, 255) != 0) //we can store the IP 95 | { 96 | string dir = buf; 97 | ifstream ipFile; 98 | ipFile.open (dir+"/"+"ip.cfg"); 99 | if (ipFile) 100 | { 101 | string ip; 102 | ipFile >> ip; 103 | ui_ipInput->setIP(ip); 104 | ipFile.close(); 105 | } 106 | } 107 | } 108 | 109 | void TrainerClass::storeIP() { 110 | char buf[255]; 111 | if (GetCurrentDir(buf, 255) != 0) //we can store the IP 112 | { 113 | string dir = buf; 114 | ofstream ipFile; 115 | ipFile.open (dir+"/"+"ip.cfg"); 116 | ipFile << ui_ipInput->getIP(); 117 | ipFile.close(); 118 | } 119 | } 120 | 121 | void TrainerClass::setConnectStatus(char status) { 122 | static char stat[50]; 123 | if (status == INTERFACE_CONNECT_FAIL) 124 | { 125 | sprintf(stat, "Cannot Connect!"); 126 | ui_opStatus->labelcolor(FL_RED); 127 | ui_opStatus->label(stat); 128 | ui_connectButton->clear(); 129 | ui_ipInput->activate(); 130 | ui_ccapiChoice->activate(); 131 | } 132 | else if (status == INTERFACE_CONNECT_SUCCESS) 133 | { 134 | sprintf(stat, "Ready"); 135 | ui_opStatus->labelcolor(FL_BLACK); 136 | ui_opStatus->label(stat); 137 | ui_ipInput->deactivate(); 138 | ui_ccapiChoice->deactivate(); 139 | ui_connectButton->selection_color(FL_GREEN); 140 | ui_connectButton->damage(FL_DAMAGE_ALL); 141 | storeIP(); 142 | } 143 | else if (status == INTERFACE_DISCONNECT) 144 | { 145 | sprintf(stat, "Disconnected"); 146 | ui_opStatus->labelcolor(FL_BLACK); 147 | ui_opStatus->label(stat); 148 | ui_connectButton->clear(); 149 | ui_ipInput->activate(); 150 | ui_ccapiChoice->activate(); 151 | ui_ipInput->checkValid(); 152 | } 153 | else if (status == INTERFACE_CONNECTING) 154 | { 155 | sprintf(stat, "Connecting"); 156 | ui_opStatus->labelcolor(FL_BLACK); 157 | ui_opStatus->label(stat); 158 | ui_ipInput->deactivate(); 159 | ui_ccapiChoice->deactivate(); 160 | ui_connectButton->selection_color(FL_YELLOW); 161 | ui_connectButton->damage(FL_DAMAGE_ALL); 162 | } 163 | } 164 | 165 | void TrainerClass::TrainButtonCB(Fl_Widget *w, void *data) { 166 | rkTrainerCodeObj *item = (rkTrainerCodeObj*)data; 167 | if (Interface::instance) 168 | { 169 | if ( ((Fl_Button*)w)->value() == 0 ) //off 170 | { 171 | Interface::instance->disable(item); 172 | } 173 | else //on 174 | { 175 | Interface::instance->enable(item); 176 | } 177 | } 178 | } 179 | 180 | void TrainerClass::center(Fl_Widget *w) { 181 | w->position( (mainWindow->w() - w->w())/2, w->y()); 182 | } 183 | -------------------------------------------------------------------------------- /Trainer/Trainer/ui_trainer.h: -------------------------------------------------------------------------------- 1 | // generated by Fast Light User Interface Designer (fluid) version 1.0302 2 | 3 | #ifndef ui_trainer_h 4 | #define ui_trainer_h 5 | #include 6 | #include 7 | #include "Interface.h" 8 | #include "UI/IPInput.h" 9 | #include "UI/Common.h" 10 | #include "TrainerTable.h" 11 | class Interface; 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | class TrainerClass { 19 | public: 20 | static TrainerClass *uiInstance; 21 | Fl_Text_Buffer ui_infoBuffer; 22 | TrainerClass(); 23 | Fl_Double_Window* make_window(); 24 | Fl_Double_Window *mainWindow; 25 | TrainerTable *ui_trainerTable; 26 | IPInput *ui_ipInput; 27 | Fl_Light_Button *ui_connectButton; 28 | Fl_Choice *ui_ccapiChoice; 29 | static Fl_Menu_Item menu_ui_ccapiChoice[]; 30 | static Fl_Menu_Item *ui_ccapiVersion25Item; 31 | static Fl_Menu_Item *ui_ccapiVersion20Item; 32 | Fl_Box *ui_opStatus; 33 | Fl_Text_Display *ui_infoBox; 34 | static void CanConnectCB(Fl_Widget *w, void *data); 35 | static void ConnectButtonCB(Fl_Widget *w, void *data); 36 | void readIP(); 37 | void storeIP(); 38 | void setConnectStatus(char status); 39 | static void TrainButtonCB(Fl_Widget *w, void *data); 40 | void center(Fl_Widget *w); 41 | }; 42 | #endif 43 | -------------------------------------------------------------------------------- /Trainer/ui_trainer.cxx: -------------------------------------------------------------------------------- 1 | // generated by Fast Light User Interface Designer (fluid) version 1.0302 2 | 3 | #include "ui_trainer.h" 4 | 5 | Fl_Double_Window* TrainerClass::make_window() { 6 | Fl_Double_Window* w; 7 | { Fl_Double_Window* o = new Fl_Double_Window(696, 655, "Trainer Title"); 8 | w = o; 9 | o->user_data((void*)(this)); 10 | { Fl_Table* o = new Fl_Table(5, 245, 685, 400); 11 | o->end(); 12 | } // Fl_Table* o 13 | { new Fl_Box(10, 74, 675, 157, "Trainer Info"); 14 | } // Fl_Box* o 15 | o->end(); 16 | } // Fl_Double_Window* o 17 | return w; 18 | } 19 | -------------------------------------------------------------------------------- /Trainer/ui_trainer.h: -------------------------------------------------------------------------------- 1 | // generated by Fast Light User Interface Designer (fluid) version 1.0302 2 | 3 | #ifndef ui_trainer_h 4 | #define ui_trainer_h 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | class TrainerClass { 11 | public: 12 | Fl_Double_Window* make_window(); 13 | }; 14 | #endif 15 | -------------------------------------------------------------------------------- /UI/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | $(MAKE) -C UI 3 | #all: 4 | # cd UI; make 5 | 6 | clean: 7 | $(MAKE) -C UI clean 8 | 9 | -------------------------------------------------------------------------------- /UI/UI.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Express 2012 for Windows Desktop 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fltk", "..\..\fltk\ide\VisualC2010\fltk.lib.vcxproj", "{E070AAFC-9D03-41A3-BC7D-30887EA0D50F}" 5 | EndProject 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CCAPI", "..\CCAPI\CCAPI\CCAPI.vcxproj", "{49636B42-2793-433D-B441-E65E42F3D542}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UI", "UI\UI.vcxproj", "{6D2D5ACC-8EF2-46DD-8859-52DDDD47908B}" 9 | ProjectSection(ProjectDependencies) = postProject 10 | {49636B42-2793-433D-B441-E65E42F3D542} = {49636B42-2793-433D-B441-E65E42F3D542} 11 | {E070AAFC-9D03-41A3-BC7D-30887EA0D50F} = {E070AAFC-9D03-41A3-BC7D-30887EA0D50F} 12 | EndProjectSection 13 | EndProject 14 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Trainer", "..\Trainer\Trainer\Trainer.vcxproj", "{C65F4D93-1242-444D-A29A-399CD5C37671}" 15 | EndProject 16 | Global 17 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 18 | Debug Cairo|Win32 = Debug Cairo|Win32 19 | Debug|Win32 = Debug|Win32 20 | Release Cairo|Win32 = Release Cairo|Win32 21 | Release|Win32 = Release|Win32 22 | EndGlobalSection 23 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 24 | {E070AAFC-9D03-41A3-BC7D-30887EA0D50F}.Debug Cairo|Win32.ActiveCfg = Debug Cairo|Win32 25 | {E070AAFC-9D03-41A3-BC7D-30887EA0D50F}.Debug Cairo|Win32.Build.0 = Debug Cairo|Win32 26 | {E070AAFC-9D03-41A3-BC7D-30887EA0D50F}.Debug|Win32.ActiveCfg = Debug|Win32 27 | {E070AAFC-9D03-41A3-BC7D-30887EA0D50F}.Debug|Win32.Build.0 = Debug|Win32 28 | {E070AAFC-9D03-41A3-BC7D-30887EA0D50F}.Release Cairo|Win32.ActiveCfg = Release Cairo|Win32 29 | {E070AAFC-9D03-41A3-BC7D-30887EA0D50F}.Release Cairo|Win32.Build.0 = Release Cairo|Win32 30 | {E070AAFC-9D03-41A3-BC7D-30887EA0D50F}.Release|Win32.ActiveCfg = Release|Win32 31 | {E070AAFC-9D03-41A3-BC7D-30887EA0D50F}.Release|Win32.Build.0 = Release|Win32 32 | {49636B42-2793-433D-B441-E65E42F3D542}.Debug Cairo|Win32.ActiveCfg = Debug|Win32 33 | {49636B42-2793-433D-B441-E65E42F3D542}.Debug Cairo|Win32.Build.0 = Debug|Win32 34 | {49636B42-2793-433D-B441-E65E42F3D542}.Debug|Win32.ActiveCfg = Debug|Win32 35 | {49636B42-2793-433D-B441-E65E42F3D542}.Debug|Win32.Build.0 = Debug|Win32 36 | {49636B42-2793-433D-B441-E65E42F3D542}.Release Cairo|Win32.ActiveCfg = Release|Win32 37 | {49636B42-2793-433D-B441-E65E42F3D542}.Release Cairo|Win32.Build.0 = Release|Win32 38 | {49636B42-2793-433D-B441-E65E42F3D542}.Release|Win32.ActiveCfg = Release|Win32 39 | {49636B42-2793-433D-B441-E65E42F3D542}.Release|Win32.Build.0 = Release|Win32 40 | {6D2D5ACC-8EF2-46DD-8859-52DDDD47908B}.Debug Cairo|Win32.ActiveCfg = Debug|Win32 41 | {6D2D5ACC-8EF2-46DD-8859-52DDDD47908B}.Debug Cairo|Win32.Build.0 = Debug|Win32 42 | {6D2D5ACC-8EF2-46DD-8859-52DDDD47908B}.Debug|Win32.ActiveCfg = Debug|Win32 43 | {6D2D5ACC-8EF2-46DD-8859-52DDDD47908B}.Debug|Win32.Build.0 = Debug|Win32 44 | {6D2D5ACC-8EF2-46DD-8859-52DDDD47908B}.Release Cairo|Win32.ActiveCfg = Release|Win32 45 | {6D2D5ACC-8EF2-46DD-8859-52DDDD47908B}.Release Cairo|Win32.Build.0 = Release|Win32 46 | {6D2D5ACC-8EF2-46DD-8859-52DDDD47908B}.Release|Win32.ActiveCfg = Release|Win32 47 | {6D2D5ACC-8EF2-46DD-8859-52DDDD47908B}.Release|Win32.Build.0 = Release|Win32 48 | {C65F4D93-1242-444D-A29A-399CD5C37671}.Debug Cairo|Win32.ActiveCfg = Debug|Win32 49 | {C65F4D93-1242-444D-A29A-399CD5C37671}.Debug Cairo|Win32.Build.0 = Debug|Win32 50 | {C65F4D93-1242-444D-A29A-399CD5C37671}.Debug|Win32.ActiveCfg = Debug|Win32 51 | {C65F4D93-1242-444D-A29A-399CD5C37671}.Debug|Win32.Build.0 = Debug|Win32 52 | {C65F4D93-1242-444D-A29A-399CD5C37671}.Release Cairo|Win32.ActiveCfg = Release|Win32 53 | {C65F4D93-1242-444D-A29A-399CD5C37671}.Release Cairo|Win32.Build.0 = Release|Win32 54 | {C65F4D93-1242-444D-A29A-399CD5C37671}.Release|Win32.ActiveCfg = Release|Win32 55 | {C65F4D93-1242-444D-A29A-399CD5C37671}.Release|Win32.Build.0 = Release|Win32 56 | EndGlobalSection 57 | GlobalSection(SolutionProperties) = preSolution 58 | HideSolutionNode = FALSE 59 | EndGlobalSection 60 | EndGlobal 61 | -------------------------------------------------------------------------------- /UI/UI.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/primetime00/CCCheat/827fcfb0f06946ed9cde5a10dd489b4a677209ff/UI/UI.suo -------------------------------------------------------------------------------- /UI/UI.v11.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/primetime00/CCCheat/827fcfb0f06946ed9cde5a10dd489b4a677209ff/UI/UI.v11.suo -------------------------------------------------------------------------------- /UI/UI/AddressOffsetGroup.cpp: -------------------------------------------------------------------------------- 1 | #include "AddressOffsetGroup.h" 2 | #include 3 | 4 | using namespace std; 5 | 6 | 7 | AddressOffsetGroup::AddressOffsetGroup(int X, int Y, int W, int H, const char *l) : Fl_Group(X,Y,W,H,l) 8 | { 9 | const int pad = 10; 10 | const int space = 60; 11 | const int labelSpace = 50; 12 | int addressX = X+pad+labelSpace; 13 | float addresBoxWidth = (W - pad*2 - space - labelSpace*2) * 0.6f; 14 | int offsetX = (int)(addressX + addresBoxWidth + space + labelSpace); 15 | float offsetBoxWidth = (W - pad*2 - space - labelSpace*2) * 0.4f; 16 | const int regHeight = 25; 17 | const int regY = Y+(int)((H - regHeight)/2.0f); 18 | 19 | begin(); 20 | m_address = new ValueInput(addressX, regY, (int)addresBoxWidth, regHeight, "Address:"); 21 | m_offset = new ValueInput(offsetX, regY, (int)offsetBoxWidth, regHeight, "Offset:"); 22 | end(); 23 | m_address->setHex(true); 24 | m_offset->setHex(true); 25 | m_address->setValType(SEARCH_VALUE_TYPE_4BYTE); 26 | m_offset->setValType(SEARCH_VALUE_TYPE_2BYTE); 27 | reset(); 28 | } 29 | 30 | void AddressOffsetGroup::set(unsigned long address, unsigned int offset) 31 | { 32 | m_address->setValue(address); 33 | m_offset->setValue((unsigned long)offset); 34 | show(); 35 | } 36 | 37 | void AddressOffsetGroup::setOffsetOnly(unsigned int offset) 38 | { 39 | setRefresh(true); 40 | m_address->deactivate(); 41 | m_offset->setValue((unsigned long)offset); 42 | show(); 43 | } 44 | 45 | void AddressOffsetGroup::reset() 46 | { 47 | m_address->setValue((unsigned long)0); 48 | m_offset->setValue((unsigned long)0); 49 | m_address->value(""); 50 | m_offset->value(""); 51 | m_address->activate(); 52 | m_addressEditable = false; 53 | setRefresh(true); 54 | hide(); 55 | } 56 | 57 | void AddressOffsetGroup::draw() 58 | { 59 | if (!m_addressEditable && !m_needsRefresh) 60 | { 61 | m_address->setValue((unsigned long)m_address->getULValue()); 62 | } 63 | else if (!m_addressEditable) 64 | { 65 | m_address->setValue((unsigned long)0); 66 | m_address->value("Refresh"); 67 | } 68 | Fl_Group::draw(); 69 | } 70 | 71 | void AddressOffsetGroup::setRefresh(bool refresh) 72 | { 73 | m_needsRefresh = refresh; 74 | } -------------------------------------------------------------------------------- /UI/UI/AddressOffsetGroup.h: -------------------------------------------------------------------------------- 1 | #ifndef _ADDRESSOFFSETGROUP_ 2 | #define _ADDRESSOFFSETGROUP_ 3 | 4 | #include 5 | #include 6 | #include "Common.h" 7 | #include "ValueInput.h" 8 | 9 | using namespace std; 10 | 11 | 12 | class AddressOffsetGroup : public Fl_Group { 13 | public: 14 | AddressOffsetGroup(int X, int Y, int W, int H, const char *l=0); 15 | ~AddressOffsetGroup() { } 16 | 17 | void set(unsigned long address, unsigned int offset); 18 | void setOffsetOnly(unsigned int offset); 19 | void reset(); 20 | void setAddressEditable(bool edit) { m_addressEditable = edit; } 21 | 22 | void setRefresh(bool refresh); 23 | 24 | unsigned long getAddress() { return m_address->getULValue(); } 25 | unsigned int getOffset() { return (unsigned int)m_offset->getULValue(); } 26 | 27 | protected: 28 | void draw(); 29 | 30 | private: 31 | ValueInput *m_address; 32 | ValueInput *m_offset; 33 | bool m_addressEditable; 34 | bool m_needsRefresh; 35 | }; 36 | 37 | #endif -------------------------------------------------------------------------------- /UI/UI/CodeTable.h: -------------------------------------------------------------------------------- 1 | #ifndef _CODETABLE_ 2 | #define _CODETABLE_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include "Common.h" 12 | #include "IDeactivate.h" 13 | #include 14 | #include 15 | #include 16 | 17 | #define CODE_TABLE_NEW 0x00 18 | #define CODE_TABLE_DELETE 0x01 19 | #define CODE_TABLE_SAVE 0x02 20 | #define CODE_TABLE_LOAD 0x03 21 | #define CODE_TABLE_TRAIN 0x04 22 | 23 | using namespace std; 24 | 25 | 26 | class CodeTable : public Fl_Table_Row, public IDeactivate { 27 | public: 28 | CodeTable(int X, int Y, int W, int H, const char *l=0); 29 | ~CodeTable() { Fl::remove_timeout(redraw); } 30 | 31 | void addEntry(string desc, AddressItem item, bool freeze=false); 32 | void deleteEntry(unsigned int row); 33 | void deleteEntry(vector &indexRows); 34 | 35 | void saveData(string filename); 36 | bool loadData(string filename); 37 | void clearTable(); 38 | bool hasSelection(); 39 | void clearSelection() { select_all_rows(0); set_selection(-1,-1,-1,-1); } 40 | void newCode(); 41 | void deleteCodes(); 42 | void addResults(vector &items, char type); 43 | void setMemoryOperator(MemoryOperator *op); 44 | void setViewer(Fl_Callback *cb) { viewer = cb; } 45 | void unFreezeAll(); 46 | void launchTrain(); 47 | void writeMemoryOnce(); 48 | 49 | rkCheat_CodeList getCodes() { return data; } 50 | 51 | static void tableClickedCB(Fl_Widget *w, void *data) { 52 | if (((Fl_Table*)w)->callback_context() == CONTEXT_CELL) 53 | { 54 | if (Fl::event_clicks()) 55 | ((CodeTable*)w)->onCellDoubleClicked(((Fl_Table*)w)->callback_row(), ((Fl_Table*)w)->callback_col()); 56 | else if (Fl::event_button() == FL_RIGHT_MOUSE) 57 | ((CodeTable*)w)->onCellRightClicked(((Fl_Table*)w)->callback_row(), ((Fl_Table*)w)->callback_col()); 58 | } 59 | else 60 | { 61 | ((CodeTable*)w)->onTableClicked(); 62 | } 63 | } 64 | static void codeDescriptionChangedCB(Fl_Widget *w, void *item) { ((CodeTable *)w->parent()->parent())->onDescriptionChanged((rkCheat_Code*)item, ((Fl_Input*)w)->value()); } 65 | static void codeAddressChangedCB(Fl_Widget *w, void *item) { ((CodeTable *)w->parent()->parent())->onAddressChanged((rkCheat_Code*)item, ((ValueInput*)w)->getULValue()); } 66 | static void codeValueChangedCB(Fl_Widget *w, void *item) { ((CodeTable *)w->parent()->parent())->onValueChanged((rkCheat_Code*)item, ((ValueInput*)w)->getLLValue()); } 67 | static void codeTypeChangedCB(Fl_Widget *w, void *item) { ((CodeTable *)w->parent()->parent())->onCodeTypeChanged((rkCheat_Code*)item, ((Fl_Choice*)w)->value()); } 68 | static void codeFreezeChangedCB(Fl_Widget *w, void *item) { 69 | ((CodeTable *)w->parent()->parent())->onCodeFreezeChanged((rkCheat_Code*)item, ((Fl_Check_Button*)w)->value()); 70 | } 71 | 72 | static void redraw(void*); 73 | 74 | 75 | 76 | protected: 77 | void draw_cell(TableContext context, int ROW=0, int COL=0, int X=0, int Y=0, int W=0, int H=0); 78 | void table_scrolled() { cout << "YAY" << endl;} 79 | int handle(int evt); 80 | 81 | private: 82 | void DrawHeader(const char *s, int X, int Y, int W, int H); 83 | void DrawData(const char *s, int X, int Y, int W, int H); 84 | void DrawCheckbox(int X, int Y, int W, int H); 85 | 86 | void rebuildTable(); 87 | void reInsert(); 88 | 89 | void onDescriptionChanged(rkCheat_Code *data, string desc); 90 | void onAddressChanged(rkCheat_Code *data, unsigned long value); 91 | void onValueChanged(rkCheat_Code *data, long long value); 92 | void onCodeTypeChanged(rkCheat_Code *data, int value); 93 | void onCodeFreezeChanged(rkCheat_Code *data, int value); 94 | void onCellDoubleClicked(int row, int col); 95 | void onCellRightClicked(int row, int col); 96 | void onTableClicked(); 97 | 98 | void doDeactivate(); 99 | Fl_Widget *getWidget() { return this; } 100 | 101 | vector getSelectedRows(); 102 | MemoryOperator *m_operator; 103 | Fl_Callback *viewer; 104 | 105 | 106 | 107 | private: 108 | rkCheat_CodeList data; 109 | Fl_Widget *last_cell_widget; 110 | Fl_Widget *current_cell_widget; 111 | 112 | }; 113 | 114 | #endif -------------------------------------------------------------------------------- /UI/UI/Common.h: -------------------------------------------------------------------------------- 1 | #ifndef _COMMON_RKCHEAT_ 2 | #define _COMMON_RKCHEAT_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include "ValueInput.h" 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #define CCCHEAT_VERSION "1.20" 19 | 20 | #define SEARCH_STOPPED_CANCEL 0x00 21 | #define SEARCH_STOPPED_PROPER 0x01 22 | #define SEARCH_STOPPED_RESET 0x02 23 | #define SEARCH_STOPPED_NO_RESULTS 0x03 24 | 25 | #define get_user_data(type, data) (type)((unsigned long)data) 26 | 27 | using namespace std; 28 | 29 | class rkCheatUI; 30 | extern rkCheatUI *uiInstance; 31 | 32 | struct WidgetField 33 | { 34 | Fl_Input *description; 35 | ValueInput *address_input; 36 | ValueInput *value_input; 37 | Fl_Check_Button *freeze; 38 | Fl_Choice *type; 39 | WidgetField(Fl_Input *d, ValueInput *a, ValueInput *v, Fl_Choice *c, Fl_Check_Button *f) { description = d; address_input = a; value_input = v; freeze = f; type = c; } 40 | WidgetField() { freeze = 0; type = 0; value_input = 0; description = 0;} 41 | ~WidgetField() { 42 | delete value_input; 43 | delete address_input; 44 | delete freeze; delete type; 45 | delete description; 46 | address_input = 0; 47 | freeze = 0; 48 | type = 0; 49 | value_input = 0; 50 | description = 0; 51 | } 52 | }; 53 | 54 | struct rkCheat_Code 55 | { 56 | string description; 57 | AddressItem m_address; 58 | char type; 59 | bool freeze; 60 | char _delete; 61 | WidgetField *widget; 62 | rkCheat_Code(){ 63 | m_address->address = 0; 64 | m_address->value = 0; 65 | m_address->sign = 1; 66 | type = 0; 67 | freeze = false; 68 | widget = 0; 69 | description = ""; 70 | _delete = 0; 71 | } 72 | rkCheat_Code(string d, unsigned long address, PointerItem p, bool f, WidgetField *w){ 73 | m_address->address = address; 74 | m_address->pointer = p; 75 | m_address->sign = 1; 76 | freeze = f; 77 | widget = w; 78 | description = d; 79 | _delete = 0; 80 | } 81 | rkCheat_Code(string d, AddressItem i, bool f, WidgetField *w){ 82 | m_address = i; 83 | freeze = f; 84 | widget = w; 85 | description = d; 86 | _delete = 0; 87 | } 88 | rkCheat_Code(string d, unsigned long add, long long val, char t, bool f, WidgetField *w){ 89 | m_address->address = add; 90 | m_address->value = val; 91 | m_address->sign = 1; 92 | type = t; 93 | freeze = f; 94 | widget = w; 95 | description = d; 96 | _delete = 0; 97 | } 98 | rkCheat_Code(rkCheat_Code &item){ 99 | *this = item; 100 | } 101 | ~rkCheat_Code() { 102 | if (widget) 103 | { 104 | delete widget; 105 | widget = 0; 106 | } 107 | } 108 | void operator=(rkCheat_Code &item) { 109 | description = item.description; 110 | if (m_address == nullptr) 111 | m_address = make_shared(); 112 | m_address->address = item.m_address->address; 113 | m_address->value = item.m_address->value; 114 | if (item.m_address->pointer != nullptr) 115 | m_address->pointer = make_shared(item.m_address->address, item.m_address->pointer->getOffsets()); 116 | type = item.type; 117 | freeze = item.freeze; 118 | widget = item.widget; 119 | m_address->sign = item.m_address->sign; 120 | m_address->type = item.m_address->type; 121 | _delete = item._delete; 122 | } 123 | void setSign(bool s) { m_address->sign = s; } 124 | }; 125 | 126 | struct ResultRow { 127 | AddressItem item; 128 | unsigned long section; 129 | unsigned long thread; 130 | unsigned long searchID; 131 | ResultRow(AddressItem i, unsigned long s, unsigned long t, unsigned long sid) { item = i; section = s; thread = t; searchID = sid;} 132 | }; 133 | 134 | typedef vector Results; 135 | 136 | struct rkTrainerCodeObj 137 | { 138 | string name; 139 | bool condition; 140 | int conditionType; 141 | long long conditionValue; 142 | AddressItem m_conditionAddress; 143 | AddressList m_addresses; 144 | 145 | rkTrainerCodeObj(rkTrainerCodeObj &item) { 146 | *this = item; 147 | } 148 | 149 | ~rkTrainerCodeObj() { } 150 | rkTrainerCodeObj() { 151 | name = ""; 152 | conditionType = 0; 153 | condition = false; 154 | conditionValue = 0; 155 | m_addresses.clear(); 156 | } 157 | 158 | void operator=(rkTrainerCodeObj &item) { 159 | name = item.name; 160 | condition = item.condition; 161 | conditionType = item.conditionType; 162 | conditionValue = item.conditionValue; 163 | m_conditionAddress = make_shared(item.m_conditionAddress->address, item.m_conditionAddress->pointer, item.m_conditionAddress->type, item.m_conditionAddress->sign); 164 | m_addresses.clear(); 165 | for (auto i = item.m_addresses.begin(); i != item.m_addresses.end(); ++i) 166 | m_addresses.push_back(make_shared((*i)->address, (*i)->pointer, (*i)->type, (*i)->sign)); 167 | } 168 | 169 | int write(char *buf) { 170 | int pos = 0; 171 | buf[pos] = name.length(); pos+=1; 172 | memcpy(&buf[pos], name.c_str(), (int)name.length()); pos += (int)name.length(); 173 | buf[pos] = condition; pos+=1; 174 | if (condition) 175 | { 176 | buf[pos] = conditionType; pos+=1; 177 | m_conditionAddress->value = m_conditionAddress->store = conditionValue; 178 | pos += m_conditionAddress->write(&buf[pos]); 179 | } 180 | buf[pos] = m_addresses.size(); pos+=1; 181 | for (auto i=m_addresses.begin(); i != m_addresses.end(); ++i) 182 | { 183 | pos += (*i)->write(&buf[pos]); 184 | } 185 | return pos; 186 | } 187 | 188 | int read(char *buf) { 189 | int pos = 0; 190 | int nameLen = buf[pos]; pos+=1; 191 | name = string(&buf[pos], nameLen); pos += (int)nameLen; 192 | condition = buf[pos] > 0 ? true : false; pos+=1; 193 | if (condition) 194 | { 195 | conditionType = buf[pos]; pos+=1; 196 | m_conditionAddress = make_shared(); 197 | pos += m_conditionAddress->read(&buf[pos]); 198 | conditionValue = m_conditionAddress->value; 199 | } 200 | int numOfCodes = buf[pos]; pos+=1; 201 | for (int i=0; i< numOfCodes; ++i) 202 | { 203 | auto code = make_shared(); 204 | pos += code->read(&buf[pos]); 205 | m_addresses.push_back(code); 206 | } 207 | return pos; 208 | } 209 | 210 | void debug() { 211 | cout << "Code Info: " << endl; 212 | cout << "Name: " << name << endl; 213 | cout << "Condition? " << (condition ? "true" : "false") << endl; 214 | if (condition) 215 | { 216 | cout << "Condition Type: " << conditionType << endl; 217 | cout << "Condition Value: " << conditionValue << endl; 218 | m_conditionAddress->debug(); 219 | } 220 | cout << "Number of inside codes: " << m_addresses.size() << endl << endl; 221 | for (auto i = m_addresses.begin(); i!=m_addresses.end(); ++i) 222 | (*i)->debug(); 223 | } 224 | }; 225 | 226 | typedef shared_ptr rkTrainerCode; 227 | 228 | 229 | #ifdef _WIN32 230 | #include 231 | #define GetCurrentDir _getcwd 232 | #else 233 | #include 234 | #define GetCurrentDir getcwd 235 | #endif 236 | 237 | typedef map *> rkCheat_Results; 238 | 239 | typedef pair rkCheat_RangeItem; 240 | typedef vector rkCheat_RangeList; 241 | 242 | typedef pair rkCheat_ResultItem; 243 | typedef vector rkCheat_ResultList; 244 | 245 | typedef shared_ptr rkCheat_CodeItem; 246 | typedef deque rkCheat_CodeList; 247 | 248 | 249 | static bool isNotHex(int c) __attribute__ ((unused)); 250 | static bool isNotHex(int c) { return !isxdigit(c); } 251 | static bool isNotDigit(int c) __attribute__ ((unused)); 252 | static bool isNotDigit(int c) { return !isdigit(c); } 253 | 254 | 255 | #endif 256 | -------------------------------------------------------------------------------- /UI/UI/DumpManager.cpp: -------------------------------------------------------------------------------- 1 | #include "DumpManager.h" 2 | #include "Common.h" 3 | #include "FL/Fl.H" 4 | #include 5 | 6 | DumpManager::DumpManager(unsigned long address, unsigned int maxOffset, unsigned int depth, DumpDataList &dumps, PointerOffsets &offsets, string filename) : m_outFile(filename, ofstream::out) 7 | { 8 | m_continue = false; 9 | m_address = address; 10 | m_dumps = dumps; 11 | m_offsets = offsets; 12 | m_maxOffset = maxOffset; 13 | m_depth = depth; 14 | m_cancel = false; 15 | m_status = DATAMANAGER_STATUS_IDLE; 16 | unsigned int tmp[] = { 6, 3, 2, 1, 1 }; 17 | maxResList = vector(tmp, tmp+5); 18 | } 19 | DumpManager::DumpManager(unsigned long address, DumpDataList &dumps, string inputFname, string scanFname) : m_inFile(inputFname, ifstream::in), m_outFile(scanFname, ofstream::out) 20 | { 21 | m_continue = true; 22 | m_address = address; 23 | m_dumps = dumps; 24 | m_cancel = false; 25 | m_status = DATAMANAGER_STATUS_IDLE; 26 | } 27 | 28 | DumpManager::~DumpManager() 29 | { 30 | m_dumps.clear(); 31 | m_offsets.clear(); 32 | } 33 | 34 | 35 | void DumpManager::start() 36 | { 37 | m_status = DATAMANAGER_STATUS_WORKING; 38 | if (m_outFile) //we didn't create the file 39 | m_outFile << CCCHEAT_VERSION << '\n'; 40 | m_thread = thread(&DumpManager::run, this); 41 | } 42 | 43 | void DumpManager::readInFile() 44 | { 45 | string version; 46 | ScanResultList ls; 47 | m_inFile.seekg(0); 48 | m_inFile >> version; 49 | while (1) 50 | { 51 | unsigned long address; 52 | unsigned int offset; 53 | unsigned int depth; 54 | PointerOffsets po; 55 | if (m_cancel) return; 56 | m_inFile >> hex >> address >> depth; 57 | if (m_inFile.eof()) 58 | break; 59 | for (unsigned int i=0; i> hex >> offset; 62 | po.push_back(offset); 63 | } 64 | unsigned long val = refreshAddress(address, po); //lets check the current value of the pointer 65 | if (val != 0 && val == m_address) //this pointer still points to where we expect, lets add it to the list 66 | { 67 | ls.push_back(ScanResult(address, po)); 68 | if (ls.size() == 4) 69 | { 70 | addResults(ls); 71 | ls.clear(); 72 | } 73 | } 74 | } 75 | if (ls.size() > 0) 76 | { 77 | addResults(ls); 78 | ls.clear(); 79 | } 80 | } 81 | 82 | unsigned long DumpManager::refreshAddress(unsigned long address, PointerOffsets offsets) 83 | { 84 | unsigned int currentOffset = offsets.back(); 85 | offsets.pop_back(); 86 | for (DumpDataList::const_iterator it = m_dumps.begin(); it != m_dumps.end(); ++it) 87 | { 88 | if (address >= (*it)->header.begin && address <= (*it)->header.end) 89 | { 90 | if (m_cancel) return 0; 91 | char *data = (*it)->data; 92 | unsigned long newAddress = BSWAP32(*(unsigned long*) (&data[address - (*it)->header.begin])); 93 | newAddress += currentOffset; 94 | if (offsets.size() == 0) 95 | return newAddress; 96 | return refreshAddress(newAddress, offsets); 97 | } 98 | } 99 | return 0; 100 | } 101 | 102 | void DumpManager::run() 103 | { 104 | int res = 1; 105 | if (m_continue) //read in file info 106 | { 107 | readInFile(); 108 | } 109 | else 110 | { 111 | while (res && !m_cancel) 112 | { 113 | res = process(); 114 | } 115 | } 116 | if (m_outFile) 117 | m_outFile.close(); 118 | if (m_cancel) 119 | m_status = DATAMANAGER_STATUS_CANCELED; 120 | else 121 | m_status = DATAMANAGER_STATUS_COMPLETE; 122 | } 123 | 124 | void DumpManager::cancel() 125 | { 126 | lock_guard lock(m_addDumpScanLock); 127 | m_cancel = true; 128 | for (auto it = m_scannerList.begin(); it!= m_scannerList.end(); ++it) 129 | { 130 | (*it)->cancel(); 131 | } 132 | } 133 | 134 | void DumpManager::addResults(ScanResultList &ls) 135 | { 136 | lock_guard lock(m_totalResultLock); 137 | //m_totalResults.insert(m_totalResults.end(), ls.begin(), ls.end()); 138 | for (ScanResultList::const_iterator it = ls.begin(); it != ls.end(); ++it) 139 | { 140 | m_totalResults.push_back(*it); 141 | if (m_outFile) 142 | { 143 | m_outFile << hex << it->address << " " << it->offsets.size() << " "; 144 | for (PointerOffsets::const_iterator pt = it->offsets.begin(); pt != it->offsets.end(); ++pt) 145 | m_outFile << hex << *pt << " "; 146 | m_outFile << '\n'; 147 | } 148 | } 149 | } 150 | 151 | int DumpManager::process() 152 | { 153 | int res; 154 | shared_ptr s; 155 | ScanResultList sr; 156 | unsigned int depth=0; 157 | lock_guard lock(m_addDumpScanLock); 158 | if (m_cancel) 159 | { 160 | m_scannerList.clear(); 161 | return 0; 162 | } 163 | if (m_scannerList.size() == 0) 164 | { 165 | s = make_shared(m_address, m_maxOffset, m_dumps, m_offsets, maxResList[depth]); 166 | res = s->startProcess(); 167 | switch (res) 168 | { 169 | case DUMP_SCAN_STATUS_CONTINUE: //we must continue this one 170 | sr = s->getResults(); 171 | addResults(sr); 172 | pushScanDump(s); //add ourself 173 | if (s->getDepth() < m_depth) 174 | { 175 | depth = s->getDepth(); 176 | for (ScanResultList::iterator it = sr.begin(); it != sr.end(); ++it) 177 | { 178 | s = make_shared( it->address, m_maxOffset, m_dumps, it->offsets, maxResList[depth] ); 179 | pushScanDump(s); 180 | } 181 | } 182 | m_currentScanner = m_scannerList.begin(); 183 | break; 184 | case DUMP_SCAN_STATUS_DONE: //this one is done! 185 | sr = s->getResults(); 186 | addResults(sr); 187 | if (s->getDepth() < m_depth) 188 | { 189 | depth = s->getDepth(); 190 | for (ScanResultList::iterator it = sr.begin(); it != sr.end(); ++it) 191 | { 192 | s = make_shared( it->address, m_maxOffset, m_dumps, it->offsets, maxResList[depth] ); 193 | pushScanDump(s); 194 | } 195 | } 196 | m_currentScanner = m_scannerList.begin(); 197 | break; 198 | case DUMP_SCAN_STATUS_CANCEL: //this one is canceled 199 | //m_scannerList.clear(); 200 | return 0; 201 | break; 202 | } 203 | } 204 | else //we have some scanner objects! 205 | { 206 | s = *m_currentScanner; 207 | DumpScanList::iterator tmp = m_currentScanner; 208 | bool isLastDepth = false; 209 | //if (++tmp != m_scannerList.end()) 210 | if (++tmp == m_scannerList.end()) 211 | { 212 | //if (s->getDepth() != (*tmp)->getDepth()) //we are at the last scanner of this depth 213 | isLastDepth = true; 214 | } 215 | 216 | if (s->getResults().size() == 0) 217 | res = s->startProcess(); 218 | else 219 | res = s->continueProcess(); 220 | switch (res) 221 | { 222 | case DUMP_SCAN_STATUS_CONTINUE: //we must continue this one 223 | sr = s->getResults(); 224 | addResults(sr); 225 | if (s->getDepth() < m_depth) 226 | { 227 | depth = s->getDepth(); 228 | for (ScanResultList::iterator it = sr.begin(); it != sr.end(); ++it) 229 | { 230 | s = make_shared( it->address, m_maxOffset, m_dumps, it->offsets, maxResList[depth] ); 231 | pushScanDump(s); 232 | } 233 | if (isLastDepth) 234 | m_currentScanner = m_scannerList.begin(); 235 | else 236 | { 237 | m_currentScanner++; 238 | if (m_currentScanner == m_scannerList.end()) 239 | { 240 | m_currentScanner = m_scannerList.begin(); 241 | } 242 | } 243 | } 244 | else 245 | { 246 | m_currentScanner++; 247 | if (m_currentScanner == m_scannerList.end()) 248 | { 249 | m_currentScanner = m_scannerList.begin(); 250 | } 251 | } 252 | break; 253 | case DUMP_SCAN_STATUS_DONE: //this one is done! 254 | sr = s->getResults(); 255 | addResults(sr); 256 | 257 | m_currentScanner = m_scannerList.erase(m_currentScanner); 258 | 259 | #if 0 260 | //make sure we aren't cancelling our scan 261 | m_addDumpScanLock.lock(); 262 | if (!m_cancel) 263 | m_currentScanner = m_scannerList.erase(m_currentScanner); 264 | m_addDumpScanLock.unlock(); 265 | #endif 266 | if (s->getDepth() < m_depth) 267 | { 268 | depth = s->getDepth(); 269 | for (ScanResultList::iterator it = sr.begin(); it != sr.end(); ++it) 270 | { 271 | s = make_shared( it->address, m_maxOffset, m_dumps, it->offsets, maxResList[depth] ); 272 | pushScanDump(s); 273 | } 274 | if (isLastDepth) 275 | m_currentScanner = m_scannerList.begin(); 276 | else 277 | { 278 | m_currentScanner++; 279 | if (m_currentScanner == m_scannerList.end()) 280 | { 281 | m_currentScanner = m_scannerList.begin(); 282 | } 283 | } 284 | } 285 | else 286 | { 287 | if (m_currentScanner == m_scannerList.end()) 288 | m_currentScanner = m_scannerList.begin(); 289 | } 290 | break; 291 | case DUMP_SCAN_STATUS_CANCEL: //this one is canceled 292 | m_scannerList.clear(); 293 | return 0; 294 | break; 295 | } 296 | } 297 | return m_scannerList.size(); 298 | } -------------------------------------------------------------------------------- /UI/UI/DumpManager.h: -------------------------------------------------------------------------------- 1 | #ifndef __DUMPMAN__ 2 | #define __DUMPMAN__ 3 | 4 | #include "CCAPI/Common.h" 5 | #include "DumpScan.h" 6 | #include 7 | #include 8 | #include 9 | 10 | using namespace std; 11 | 12 | #define DATAMANAGER_STATUS_COMPLETE 0 13 | #define DATAMANAGER_STATUS_WORKING 1 14 | #define DATAMANAGER_STATUS_CANCELED 2 15 | #define DATAMANAGER_STATUS_IDLE 3 16 | 17 | 18 | typedef list> DumpScanList; 19 | 20 | using namespace std; 21 | 22 | class DumpManager 23 | { 24 | public: 25 | DumpManager(unsigned long address, unsigned int maxOffset, unsigned int depth, DumpDataList &dumps, PointerOffsets &offsets, string filename); 26 | DumpManager(unsigned long address, DumpDataList &dumps, string inputFname, string scanFname); 27 | ~DumpManager(); 28 | 29 | int process(); 30 | void run(); 31 | void start(); 32 | void join() { if (m_thread.joinable()) m_thread.join();} 33 | void cancel(); 34 | 35 | 36 | ScanResultList &getResults() { return m_totalResults; } 37 | mutex &getLock() { return m_totalResultLock; } 38 | 39 | void pushScanDump(shared_ptr d) { 40 | // lock_guard lock(m_addDumpScanLock); 41 | // if (!m_cancel) 42 | m_scannerList.push_front(d); 43 | } 44 | char getStatus() { return m_status; } 45 | 46 | private: 47 | void addResults(ScanResultList &ls); 48 | void readInFile(); 49 | unsigned long refreshAddress(unsigned long address, PointerOffsets offsets); 50 | 51 | thread m_thread; 52 | mutex m_totalResultLock; 53 | mutex m_addDumpScanLock; 54 | 55 | vector maxResList; 56 | 57 | char m_status; 58 | bool m_cancel; 59 | 60 | unsigned long m_address; 61 | DumpDataList m_dumps; 62 | PointerOffsets m_offsets; 63 | unsigned int m_maxOffset; 64 | unsigned int m_depth; 65 | 66 | DumpScanList m_scannerList; 67 | ScanResultList m_totalResults; 68 | 69 | DumpScanList::iterator m_currentScanner; 70 | 71 | bool m_continue; 72 | 73 | ifstream m_inFile; 74 | ofstream m_outFile; 75 | }; 76 | 77 | #endif -------------------------------------------------------------------------------- /UI/UI/DumpScan.cpp: -------------------------------------------------------------------------------- 1 | #include "DumpScan.h" 2 | 3 | #define CHECK_CANCEL if (m_cancel) return DUMP_SCAN_STATUS_CANCEL 4 | DumpScan::DumpScan(unsigned long address, unsigned int maxOffset, DumpDataList &dumps, PointerOffsets &offsets, unsigned int maxResults) 5 | { 6 | m_address = address; 7 | m_dumps = dumps; 8 | m_offsets = offsets; 9 | m_maxOffset = maxOffset; 10 | m_maxResults = maxResults; 11 | m_cancel = false; 12 | } 13 | 14 | DumpScan::~DumpScan() 15 | { 16 | m_results.clear(); 17 | } 18 | 19 | int DumpScan::startProcess() 20 | { 21 | return process(m_dumps.begin(), 0); 22 | } 23 | int DumpScan::continueProcess() 24 | { 25 | m_results.clear(); 26 | return process(m_currentDump, m_currentByte); 27 | } 28 | int DumpScan::process(DumpDataList::iterator startDump, unsigned long startByte) 29 | { 30 | unsigned long min = m_address - m_maxOffset; 31 | unsigned long max = m_address; 32 | if (m_maxOffset > m_address) 33 | min = 0; 34 | m_counter = 0; 35 | for (DumpDataList::iterator it = startDump; it!= m_dumps.end(); ++it) 36 | { 37 | char *data = (*it)->data; 38 | CHECK_CANCEL; 39 | for (unsigned long i=startByte; i<((*it)->header.end - (*it)->header.begin)-3; ++i) 40 | { 41 | unsigned long currentAddress = BSWAP32(*(unsigned long*)(&data[i])); 42 | CHECK_CANCEL; 43 | if ( currentAddress >= min && currentAddress <= max) //we want this 44 | { 45 | PointerOffsets po = m_offsets; 46 | po.push_front(m_address - currentAddress); 47 | m_results.push_back(ScanResult(i+(*it)->header.begin, po)); 48 | if (++m_counter >= m_maxResults) 49 | { 50 | m_counter = 0; 51 | m_currentDump = it; 52 | m_currentByte = i+1; 53 | return DUMP_SCAN_STATUS_CONTINUE; 54 | } 55 | } 56 | } 57 | } 58 | return DUMP_SCAN_STATUS_DONE; 59 | } -------------------------------------------------------------------------------- /UI/UI/DumpScan.h: -------------------------------------------------------------------------------- 1 | #ifndef __DUMPSCAN__ 2 | #define __DUMPSCAN__ 3 | 4 | #include "CCAPI/Common.h" 5 | 6 | #define DUMP_SCAN_STATUS_DONE 0 7 | #define DUMP_SCAN_STATUS_CONTINUE 1 8 | #define DUMP_SCAN_STATUS_CANCEL 2 9 | 10 | using namespace std; 11 | 12 | #define MAX_SCAN 4 13 | 14 | struct ScanResult 15 | { 16 | unsigned long address; 17 | PointerOffsets offsets; 18 | ScanResult(unsigned long a, PointerOffsets po) { address = a; offsets = po; } 19 | ScanResult &operator=(ScanResult t) { address = t.address; offsets = t.offsets; return *this;} 20 | }; 21 | typedef list ScanResultList; 22 | 23 | class DumpScan 24 | { 25 | public: 26 | DumpScan(unsigned long address, unsigned int maxOffset, DumpDataList &dumps, PointerOffsets &offsets, unsigned int maxReults); 27 | ~DumpScan(); 28 | 29 | int process(DumpDataList::iterator startDump, unsigned long startByte); 30 | int startProcess(); 31 | int continueProcess(); 32 | unsigned int getDepth() { return m_offsets.size()+1; } 33 | ScanResultList getResults() { return m_results; } 34 | void cancel() { m_cancel = true; } 35 | 36 | private: 37 | unsigned long m_address; 38 | DumpDataList m_dumps; 39 | PointerOffsets m_offsets; 40 | unsigned int m_maxOffset; 41 | DumpDataList::iterator m_currentDump; 42 | unsigned long m_currentByte; 43 | 44 | unsigned int m_counter; 45 | 46 | ScanResultList m_results; 47 | unsigned int m_maxResults; 48 | bool m_cancel; 49 | }; 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /UI/UI/IDeactivate.h: -------------------------------------------------------------------------------- 1 | #ifndef _RKWIDGET_ 2 | #define _RKWIDGET_ 3 | 4 | #include 5 | 6 | class IDeactivate 7 | { 8 | public: 9 | ~IDeactivate() {} 10 | virtual void doDeactivate() = 0; 11 | virtual Fl_Widget *getWidget() = 0; 12 | 13 | }; 14 | #endif -------------------------------------------------------------------------------- /UI/UI/IPInput.cpp: -------------------------------------------------------------------------------- 1 | #include "IPInput.h" 2 | #include 3 | #include 4 | #include 5 | 6 | using namespace std; 7 | 8 | IPInput::IPInput(int X, int Y, int W, int H, const char *l) : Fl_Group(X,Y,W,H,l) 9 | { 10 | const int gap = 5; 11 | const int bWidth = (int)((W/4.0f) - (gap*3)); 12 | const int inc = bWidth + gap; 13 | begin(); 14 | inp_box[0] = new NumberInput(X,Y,bWidth,H,0); X+=inc; 15 | inp_box[1] = new NumberInput(X,Y,bWidth,H,0); X+=inc; 16 | inp_box[2] = new NumberInput(X,Y,bWidth,H,0); X+=inc; 17 | inp_box[3] = new NumberInput(X,Y,bWidth,H,0); 18 | end(); 19 | inp_box[0]->callback(boxInputCB, this); 20 | inp_box[1]->callback(boxInputCB, this); 21 | inp_box[2]->callback(boxInputCB, this); 22 | inp_box[3]->callback(boxInputCB, this); 23 | 24 | inp_box[0]->when(FL_WHEN_CHANGED); 25 | inp_box[1]->when(FL_WHEN_CHANGED); 26 | inp_box[2]->when(FL_WHEN_CHANGED); 27 | inp_box[3]->when(FL_WHEN_CHANGED); 28 | 29 | inp_box[0]->setMaxNumber(255); 30 | inp_box[1]->setMaxNumber(255); 31 | inp_box[2]->setMaxNumber(255); 32 | inp_box[3]->setMaxNumber(255); 33 | 34 | inp_box[0]->setMinNumber(0); 35 | inp_box[1]->setMinNumber(0); 36 | inp_box[2]->setMinNumber(0); 37 | inp_box[3]->setMinNumber(0); 38 | 39 | inp_box[0]->maximum_size(3); 40 | inp_box[1]->maximum_size(3); 41 | inp_box[2]->maximum_size(3); 42 | inp_box[3]->maximum_size(3); 43 | 44 | inp_box[0]->align(FL_ALIGN_CENTER); 45 | inp_box[1]->align(FL_ALIGN_CENTER); 46 | inp_box[2]->align(FL_ALIGN_CENTER); 47 | inp_box[3]->align(FL_ALIGN_CENTER); 48 | 49 | setIP("192.168.255.1"); 50 | } 51 | 52 | IPInput::~IPInput() 53 | { 54 | clear(); 55 | } 56 | 57 | void IPInput::boxInputCB(Fl_Widget *w, void *p) 58 | { 59 | IPInput *m_IPInput = (IPInput*)p; 60 | if (((NumberInput*)w)->size() >= 3) 61 | { 62 | NumberInput *next = m_IPInput->getNextBox((NumberInput*)w); 63 | next->take_focus(); 64 | next->position(0); 65 | next->mark(3); 66 | } 67 | m_IPInput->checkValid(); 68 | } 69 | 70 | void IPInput::checkValid() 71 | { 72 | bool valid = true; 73 | for (int i=0; i<4; ++i) 74 | { 75 | if (inp_box[i]->size() == 0) 76 | { 77 | valid = false; 78 | break; 79 | } 80 | } 81 | do_callback(this, valid); 82 | /* if (validFunc != nullptr) 83 | validFunc(valid);*/ 84 | } 85 | 86 | NumberInput *IPInput::getNextBox(NumberInput *n) 87 | { 88 | if (n == inp_box[0]) 89 | return inp_box[1]; 90 | if (n == inp_box[1]) 91 | return inp_box[2]; 92 | if (n == inp_box[2]) 93 | return inp_box[3]; 94 | if (n == inp_box[3]) 95 | return inp_box[0]; 96 | return 0; 97 | } 98 | 99 | string IPInput::getIP() 100 | { 101 | stringstream ip; 102 | ip << inp_box[0]->value() << "." << inp_box[1]->value() << "." << inp_box[2]->value() << "." << inp_box[3]->value(); 103 | return ip.str(); 104 | } 105 | void IPInput::setIP(string ip) 106 | { 107 | int sip[4]; 108 | for (string::iterator it= ip.begin(); it!= ip.end();) 109 | { 110 | if (*it == '.') 111 | { 112 | *it = ' '; ++it; 113 | } 114 | else if (!isdigit(*it)) 115 | { 116 | it = ip.erase(it); 117 | } 118 | else 119 | ++it; 120 | } 121 | stringstream inp(ip); 122 | inp >> sip[0] >> sip[1] >> sip[2] >> sip[3]; 123 | for (int i=0; i<4; i++) 124 | if (sip[i] > 255 || sip[i] < 0) 125 | sip[i] = 0; 126 | inp_box[0]->value(to_string(sip[0]).c_str()); 127 | inp_box[1]->value(to_string(sip[1]).c_str()); 128 | inp_box[2]->value(to_string(sip[2]).c_str()); 129 | inp_box[3]->value(to_string(sip[3]).c_str()); 130 | } 131 | -------------------------------------------------------------------------------- /UI/UI/IPInput.h: -------------------------------------------------------------------------------- 1 | #ifndef __IPINPUT__ 2 | #define __IPINPUT__ 3 | 4 | #include 5 | #include 6 | #include "NumberInput.h" 7 | 8 | using namespace std; 9 | 10 | class IPInput : public Fl_Group 11 | { 12 | public: 13 | IPInput(int X, int Y, int W, int H, const char *l=0); 14 | ~IPInput(); 15 | 16 | string getIP(); 17 | void setIP(string ip); 18 | 19 | static void boxInputCB(Fl_Widget *w, void *p); 20 | NumberInput *getNextBox(NumberInput *n); 21 | void checkValid(); 22 | 23 | private: 24 | NumberInput *inp_box[4]; 25 | }; 26 | #endif -------------------------------------------------------------------------------- /UI/UI/InfoWindow.cpp: -------------------------------------------------------------------------------- 1 | #include "Common.h" 2 | #include "InfoWindow.h" 3 | 4 | #include 5 | using namespace std; 6 | 7 | #define INFO_MARGIN 10 8 | #define NL "\n" 9 | char InfoWindow::info[] = 10 | "CCCheat " CCCHEAT_VERSION " was written by Primetime00." NL 11 | "This version may still have several bugs!" NL NL 12 | "NOTE: Right click on an address in the code table to view nearby addresses." NL 13 | "Special Thanks to:" NL 14 | "FM|T Enstone for CCAPI." NL 15 | "Dnawrkshp for NetCheat PS3"; 16 | 17 | InfoWindow::InfoWindow(int X, int Y, int W, int H, const char *l) : rkWindow(X,Y,W,H,l) 18 | { 19 | begin(); 20 | display = new Fl_Text_Display(INFO_MARGIN,INFO_MARGIN,W-INFO_MARGIN*3,H-INFO_MARGIN*3,0); 21 | display->wrap_mode(3,0); 22 | Fl_Text_Buffer *b = new Fl_Text_Buffer(); 23 | b->insert(0, InfoWindow::info); 24 | display->buffer(b); 25 | end(); 26 | } 27 | 28 | InfoWindow::InfoWindow(int W, int H, const char *l) : rkWindow(W,H,l) 29 | { 30 | begin(); 31 | display = new Fl_Text_Display(INFO_MARGIN,INFO_MARGIN,W-(INFO_MARGIN*3),H-INFO_MARGIN*3,0); 32 | display->wrap_mode(3,0); 33 | Fl_Text_Buffer *b = new Fl_Text_Buffer(); 34 | b->insert(0, InfoWindow::info); 35 | display->buffer(b); 36 | end(); 37 | } 38 | -------------------------------------------------------------------------------- /UI/UI/InfoWindow.h: -------------------------------------------------------------------------------- 1 | #ifndef _INFOWINDOW_ 2 | #define _INFOWINDOW_ 3 | 4 | #include "rkWindow.h" 5 | #include 6 | #include "Common.h" 7 | 8 | using namespace std; 9 | 10 | 11 | class InfoWindow : public rkWindow 12 | { 13 | public: 14 | InfoWindow(int X, int Y, int W, int H, const char *l=0); 15 | InfoWindow(int W, int H, const char *l=0); 16 | 17 | static char info[]; 18 | 19 | private: 20 | Fl_Text_Display *display; 21 | 22 | 23 | 24 | }; 25 | 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /UI/UI/InterfaceCCAPI.h: -------------------------------------------------------------------------------- 1 | #ifndef _INTERFACECCAPI_ 2 | #define _INTERFACECCAPI_ 3 | #include 4 | #include "CCAPI/CCAPI.h" 5 | #include "CCAPI/Common.h" 6 | #include "Common.h" 7 | #include "CCAPI/RangeMemory.h" 8 | #include "CCAPI/SearchMemory.h" 9 | #include "CCAPI/DumpMemory.h" 10 | #include "CCAPI/MemoryOperator.h" 11 | #include "ui_main.h" 12 | 13 | #ifndef _HOME 14 | #define PS3_IP "127.0.0.1" 15 | #else 16 | #define PS3_IP "192.168.137.2" 17 | #endif 18 | 19 | #define INTERFACE_CONNECT_SUCCESS 0x00 20 | #define INTERFACE_CONNECT_FAIL 0x01 21 | #define INTERFACE_DISCONNECT 0x02 22 | #define INTERFACE_CONNECTING 0x03 23 | 24 | class rkCheatUI; 25 | 26 | class InterfaceCCAPI { 27 | public: 28 | typedef shared_ptr DumpMemoryItem; 29 | 30 | InterfaceCCAPI(CCAPI *ccapi, rkCheatUI *ui) { m_ccapi = ccapi; m_ui = ui; instance = this; lastSearchType = SEARCH_TYPE_UNKNOWN; currentSearchIndex = 0; memoryOperator = 0; ranger = 0;} 31 | 32 | static void findAddresses(); 33 | void _findAddresses(); 34 | 35 | static void cancelFindAddresses(); 36 | void _cancelFindAddresses(); 37 | 38 | static void findAddressProgress(void *); 39 | bool _findAddressProgress(); 40 | 41 | static void searchProgress(void *); 42 | bool _searchProgress(SearchMemory *); 43 | 44 | static void dumpProgress(void *); 45 | bool _dumpProgress(DumpMemory *); 46 | 47 | 48 | void _launchFindAddress(); 49 | void _processAddresses(); 50 | 51 | bool _searchInProgress() { return searchList.size() > 0; } 52 | void _resetSearch(); 53 | 54 | void _launchSearch(); 55 | void _processSearchResults(SearchMemory *); 56 | 57 | void _launchDump(); 58 | 59 | static void startNewSearch(); 60 | void _startNewSearch(); 61 | 62 | static void dumpMemory(); 63 | void _dumpMemory(); 64 | 65 | static void cancelDumpMemory(); 66 | void _cancelDumpMemory(); 67 | 68 | static void continueSearch(); 69 | void _continueSearch(); 70 | 71 | void _cycleSearch(); 72 | 73 | bool _isSearching() { if (searcher) return searcher->isRunning(); else return false; } 74 | 75 | void _cancelSearch(); 76 | 77 | static void connectCheck(void *v) { if (instance != 0) { instance->_connectCheck(); } } 78 | void _connectCheck(); 79 | void connect(string ip); 80 | void disconnect(); 81 | 82 | static InterfaceCCAPI *instance; 83 | 84 | bool searchInProgress() { return searchList.size() > 0; } 85 | 86 | char getSearchValueType() { return searcher ? searcher->getSearchValueType() : 0; } 87 | 88 | unsigned long getNumberOfResults(); 89 | private: 90 | bool isSearchFinished(); 91 | DumpMemoryItem getDumpMemoryItem(DumpMemory *); 92 | SearchMemory *getCurrentSearch(); 93 | DumpMemoryItem getCurrentDump(); 94 | 95 | rkCheatUI *m_ui; 96 | CCAPI *m_ccapi; 97 | 98 | thread m_launcher; 99 | RangeMemory *ranger; 100 | SearchMemory *searcher; 101 | MemoryOperator *memoryOperator; 102 | shared_ptr connection; 103 | 104 | vector searchList; 105 | 106 | 107 | vector dumpList; 108 | 109 | rkCheat_Results searchResults; 110 | 111 | char lastSearchType; 112 | int currentSearchIndex; 113 | string m_ip; 114 | 115 | 116 | }; 117 | #endif -------------------------------------------------------------------------------- /UI/UI/Makefile: -------------------------------------------------------------------------------- 1 | include ../../Makefile.common 2 | #INCLUDES = -I. -I../../CCAPI -I../../../../fltk/fltk 3 | #LIBS = -L../../FLTK -L../../CCAPI/CCAPI/lib -lccapi -lfltk -lGL -lGLU -lXrandr -lXinerama -lXext -lX11 -lXft -lfontconfig -ldl 4 | #LFLAGS = -Wall $(DEBUG) $(LIBS) 5 | 6 | objects = $(src:.cpp=.o) 7 | src := $(wildcard *.cpp *.cxx) 8 | #CCCheat : $(OBJS) 9 | # $(CC) $(INCLUDES) $(OBJS) -o $(TARGET) $(LFLAGS) 10 | # \rm *.o 11 | 12 | CCCheat : $(objects) ui_main.o 13 | $(CC) $(INCLUDES) $(CFLAGS) $(objects) -o $(TARGET) $(LFLAGS) 14 | 15 | %.o: %.cpp 16 | $(CC) $(INCLUDES) $(CFLAGS) -c $< -o $@ 17 | 18 | ui_main.o: ui_main.cxx 19 | $(CC) $(INCLUDES) $(CFLAGS) -c $< -o $@ 20 | 21 | clean: 22 | \rm -f *.o $(TARGET) 23 | 24 | -------------------------------------------------------------------------------- /UI/UI/NumberInput.cpp: -------------------------------------------------------------------------------- 1 | #include "NumberInput.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "Common.h" 7 | 8 | 9 | using namespace std; 10 | 11 | NumberInput::NumberInput(int x, int y, int w, int h, const char *l) : Fl_Input(x,y,w,h,l) 12 | { 13 | m_max = LONG_MAX; 14 | m_min = LONG_MIN; 15 | } 16 | 17 | int NumberInput::handle(int e) 18 | { 19 | string val, current; 20 | string txt = value(); 21 | switch ( e ) 22 | { 23 | case FL_PASTE: 24 | val = Fl::event_text(); 25 | std::transform(val.begin(), val.end(), val.begin(), ::toupper); 26 | val.erase( remove_if(val.begin(), val.end(), isNotDigit), val.end() ); 27 | if (stol(val, nullptr, 10) > m_max || stol(val) < m_min) 28 | { 29 | value(""); 30 | return 1; 31 | } 32 | value(val.c_str()); 33 | return 1; 34 | break; 35 | case FL_KEYUP: 36 | break; 37 | case FL_KEYDOWN: { 38 | cut(); 39 | current = value(); 40 | val = Fl::event_text(); 41 | if (val.empty()) 42 | return(Fl_Input::handle(e)); 43 | std::transform(val.begin(), val.end(), val.begin(), ::tolower); 44 | if (isdigit(val[0])) 45 | { 46 | long v = stol(current+val[0], nullptr, 10); 47 | if (v > m_max || v < m_min) 48 | return 1; 49 | return(Fl_Input::handle(e)); 50 | } 51 | else if (val == "-" && txt.size() == 0 && m_min < 0) 52 | return(Fl_Input::handle(e)); 53 | else if (isprint(val[0])) 54 | return 1; 55 | return(Fl_Input::handle(e)); 56 | break; 57 | } 58 | default: return(Fl_Input::handle(e)); break; 59 | } 60 | return 1; 61 | } 62 | 63 | long long NumberInput::getLLValue() 64 | { 65 | string v = value(); 66 | if (v.empty()) 67 | return 0; 68 | return stoll(value(), nullptr, 10); 69 | } 70 | 71 | 72 | NumberInput::~NumberInput(void) 73 | { 74 | } 75 | -------------------------------------------------------------------------------- /UI/UI/NumberInput.h: -------------------------------------------------------------------------------- 1 | #ifndef _NUMBERINPUT_ 2 | #define _NUMBERINPUT_ 3 | #include 4 | #include 5 | 6 | class NumberInput : 7 | public Fl_Input 8 | { 9 | public: 10 | NumberInput(int x, int y, int w, int h, const char *l=0); 11 | ~NumberInput(void); 12 | int handle(int); 13 | 14 | void setMaxNumber(long number) { m_max = number; } 15 | void setMinNumber(long number) { m_min = number; } 16 | long long getLLValue(); 17 | 18 | 19 | 20 | private: 21 | long m_max, m_min; 22 | 23 | }; 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /UI/UI/PointerEditorWindow.cpp: -------------------------------------------------------------------------------- 1 | #include "PointerEditorWindow.h" 2 | #include "PointerScannerTable.h" 3 | #include "DumpManager.h" 4 | #include "ui_main.h" 5 | #include 6 | using namespace std; 7 | 8 | void PointerEditorWindow::OnOKCB(Fl_Widget *w) 9 | { 10 | readPointers(); 11 | hide(); 12 | } 13 | 14 | void PointerEditorWindow::OnCancelCB(Fl_Widget *w) 15 | { 16 | currentPointer = nullptr; 17 | hide(); 18 | 19 | } 20 | 21 | void PointerEditorWindow::OnAddCB(Fl_Widget *w) 22 | { 23 | bool found = false; 24 | for (auto it = groups.begin(); it != groups.end(); ++it) 25 | { 26 | if (!(*it)->visible()) 27 | { 28 | found = true; 29 | (*it)->setOffsetOnly(0); 30 | (*it)->show(); 31 | if ((*it) == groups.back()) 32 | uiInstance->m_peAddPointerButton->deactivate(); 33 | break; 34 | } 35 | } 36 | if (!found) 37 | uiInstance->m_peAddPointerButton->deactivate(); 38 | uiInstance->m_peDeletePointerButton->activate(); 39 | uiInstance->m_peResolvedAddress->setValue((unsigned long)0); 40 | uiInstance->m_peResolvedAddress->value("Refresh"); 41 | uiInstance->m_peResolvedValue->setValue((unsigned long)0); 42 | uiInstance->m_peResolvedValue->value("Refresh"); 43 | 44 | } 45 | 46 | void PointerEditorWindow::OnDeleteCB(Fl_Widget *w) 47 | { 48 | bool found = false; 49 | for (int i=groups.size()-1; i>=1; --i) 50 | { 51 | if (groups[i]->visible()) 52 | { 53 | found = true; 54 | groups[i]->setOffsetOnly(0); 55 | groups[i]->hide(); 56 | if (i == 1) 57 | uiInstance->m_peDeletePointerButton->deactivate(); 58 | break; 59 | } 60 | } 61 | if (!found) //we've deleted all we can 62 | uiInstance->m_peDeletePointerButton->deactivate(); 63 | uiInstance->m_peAddPointerButton->activate(); 64 | uiInstance->m_peResolvedAddress->setValue((unsigned long)0); 65 | uiInstance->m_peResolvedAddress->value("Refresh"); 66 | uiInstance->m_peResolvedValue->setValue((unsigned long)0); 67 | uiInstance->m_peResolvedValue->value("Refresh"); 68 | 69 | } 70 | 71 | void PointerEditorWindow::OnRefreshCB(Fl_Widget *w) 72 | { 73 | readPointers(); 74 | if (m_operator != 0 && currentPointer != nullptr) 75 | { 76 | uiInstance->m_peRefreshButton->deactivate(); 77 | m_operator->setReadMemoryOperation(currentPointer, false); 78 | Fl::add_timeout(0.5, refreshTimeout, this); 79 | } 80 | } 81 | 82 | void PointerEditorWindow::refreshTimeout() 83 | { 84 | if (currentPointer != nullptr && currentPointer->isPointer() && currentPointer->pointer->updateCount != pointerUpdateCounter) 85 | { 86 | unsigned int i=0; 87 | Fl::remove_timeout(refreshTimeout, this); 88 | pointerUpdateCounter = currentPointer->pointer->updateCount; 89 | for (auto it = currentPointer->pointer->pointers.begin(); it != currentPointer->pointer->pointers.end(); ++it, ++i) 90 | { 91 | if (i >= groups.size()) 92 | break; 93 | groups[i]->set(it->address, it->offset); 94 | groups[i]->setRefresh(false); 95 | } 96 | uiInstance->m_peResolvedAddress->setValue(currentPointer->pointer->resolved); 97 | uiInstance->m_peResolvedValue->setValueType(-1); 98 | uiInstance->m_peResolvedValue->setLiteral(currentPointer->type != SEARCH_VALUE_TYPE_FLOAT); 99 | long long nval = Helpers::convert4BytesToType(currentPointer->value, currentPointer->type); 100 | uiInstance->m_peResolvedValue->setValue(nval); 101 | uiInstance->m_peResolvedValue->setValueType(currentPointer->type); 102 | 103 | uiInstance->m_peRefreshButton->activate(); 104 | damage(FL_DAMAGE_ALL); 105 | } 106 | else if (currentPointer == nullptr) 107 | { 108 | Fl::remove_timeout(refreshTimeout, this); 109 | uiInstance->m_peRefreshButton->activate(); 110 | } 111 | else 112 | Fl::repeat_timeout(0.5, refreshTimeout, this); 113 | } 114 | 115 | void PointerEditorWindow::readPointers() 116 | { 117 | unsigned long address; 118 | PointerOffsets po; 119 | address = uiInstance->m_peAddressSet0->getAddress(); 120 | po.push_back(uiInstance->m_peAddressSet0->getOffset()); 121 | for (unsigned int i=1; ivisible()) 124 | break; 125 | po.push_back(groups[i]->getOffset()); 126 | } 127 | PointerItem p = make_shared(address, po); 128 | currentPointer = make_shared(); 129 | currentPointer->address = address; 130 | currentPointer->pointer = p; 131 | currentPointer->type = uiInstance->m_peValueType->getValue(); 132 | pointerUpdateCounter = 0; 133 | } 134 | 135 | void PointerEditorWindow::reset() 136 | { 137 | createGroup(); 138 | for (auto it = groups.begin(); it != groups.end(); ++it) 139 | { 140 | (*it)->reset(); 141 | (*it)->setAddressEditable(false); 142 | } 143 | groups[0]->setAddressEditable(true); 144 | uiInstance->m_peResolvedAddress->setHex(true); 145 | uiInstance->m_peResolvedAddress->setValue((unsigned long)0); 146 | uiInstance->m_peResolvedAddress->value(""); 147 | uiInstance->m_peResolvedAddress->deactivate(); 148 | uiInstance->m_peValueType->reset(); 149 | uiInstance->m_peResolvedValue->setValueType(uiInstance->m_peValueType->getValue()); 150 | uiInstance->m_peResolvedValue->setHex(false); 151 | uiInstance->m_peResolvedValue->setValue((unsigned long)0); 152 | uiInstance->m_peResolvedValue->value("Refresh"); 153 | uiInstance->m_peResolvedValue->setLiteral(false); 154 | uiInstance->m_peResolvedValue->deactivate(); 155 | currentPointer = nullptr; 156 | m_resAddress = 0; 157 | } 158 | 159 | void PointerEditorWindow::OnTypeChangedCB(Fl_Widget *w) 160 | { 161 | char type = uiInstance->m_peValueType->getValue(); 162 | if (currentPointer != nullptr && currentPointer->type != type) 163 | { 164 | uiInstance->m_peResolvedValue->setLiteral(type != SEARCH_VALUE_TYPE_FLOAT); 165 | long long nval = Helpers::convert4BytesToType(currentPointer->value, type); 166 | uiInstance->m_peResolvedValue->setValue(nval); 167 | uiInstance->m_peResolvedValue->setValueType(type); 168 | currentPointer->type = type; 169 | } 170 | } 171 | 172 | void PointerEditorWindow::show() 173 | { 174 | rkWindow::show(); 175 | } 176 | 177 | AddressItem PointerEditorWindow::popup(unsigned long address, PointerOffsets offsets) 178 | { 179 | reset(); 180 | setPointer(address, offsets); 181 | show(); 182 | while (shown()) Fl::wait(); 183 | return currentPointer; 184 | } 185 | 186 | AddressItem PointerEditorWindow::popup(AddressItem p) 187 | { 188 | reset(); 189 | setPointer(p); 190 | show(); 191 | while (shown()) Fl::wait(); 192 | return currentPointer; 193 | } 194 | void PointerEditorWindow::hide() 195 | { 196 | //if (visible()) 197 | // uiInstance->m_valueTable->stopMemoryRead(); 198 | rkWindow::hide(); 199 | } 200 | 201 | void PointerEditorWindow::setPointer(unsigned long address, PointerOffsets offsets) 202 | { 203 | unsigned int i=0; 204 | for (auto it = offsets.begin(); it!=offsets.end(); ++it, ++i) 205 | { 206 | if (i == 0) 207 | groups[i]->set(address, *it); 208 | else if (isetOffsetOnly(*it); 211 | } 212 | } 213 | if (m_resAddress == 0) 214 | uiInstance->m_peResolvedAddress->value("Refresh"); 215 | else 216 | uiInstance->m_peResolvedAddress->setValue(m_resAddress); 217 | currentPointer = make_shared(address, offsets, SEARCH_VALUE_TYPE_4BYTE, 0); 218 | } 219 | 220 | void PointerEditorWindow::setPointer(AddressItem p) 221 | { 222 | PointerOffsets po = p->pointer->getOffsets(); 223 | setPointer(p->address, po); 224 | } 225 | 226 | void PointerEditorWindow::createGroup() 227 | { 228 | groups.clear(); 229 | groups.push_back(uiInstance->m_peAddressSet0); 230 | groups.push_back(uiInstance->m_peAddressSet1); 231 | groups.push_back(uiInstance->m_peAddressSet2); 232 | groups.push_back(uiInstance->m_peAddressSet3); 233 | groups.push_back(uiInstance->m_peAddressSet4); 234 | } 235 | 236 | void PointerEditorWindow::capture() 237 | { 238 | rkWindow::capture(); 239 | createdW = uiInstance->m_peValueType->x() + uiInstance->m_peValueType->w() + 10; 240 | createdH = uiInstance->m_peOKButton->y() + uiInstance->m_peOKButton->h() + 20; 241 | int btnX = (createdW - uiInstance->m_peOKButton->w())/2; 242 | uiInstance->m_peOKButton->position( btnX - ( (uiInstance->m_peOKButton->w()/2) + 10) , uiInstance->m_peOKButton->y()); 243 | uiInstance->m_peCancelButton->position( btnX + ((uiInstance->m_peCancelButton->w()/2) + 10) , uiInstance->m_peCancelButton->y()); 244 | } -------------------------------------------------------------------------------- /UI/UI/PointerEditorWindow.h: -------------------------------------------------------------------------------- 1 | #ifndef _PEWINDOW_ 2 | #define _PEWINDOW_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include "AddressOffsetGroup.h" 8 | #include "rkWindow.h" 9 | #include "Common.h" 10 | #include "CCAPI/Common.h" 11 | #include "CCAPI/MemoryOperator.h" 12 | #include "FL/Fl.H" 13 | 14 | using namespace std; 15 | 16 | class PointerEditorWindow : public rkWindow 17 | { 18 | public: 19 | PointerEditorWindow(int X, int Y, int W, int H, const char *l=0) : rkWindow(X,Y,W,H,l) 20 | { 21 | m_resAddress = 0; 22 | m_operator = 0; 23 | pointerUpdateCounter = 0; 24 | } 25 | PointerEditorWindow(int W, int H, const char *l=0) : rkWindow(W,H,l) 26 | { 27 | m_resAddress = 0; 28 | m_operator = 0; 29 | pointerUpdateCounter = 0; 30 | } 31 | 32 | void reset(); 33 | void OnOKCB(Fl_Widget *w); 34 | void OnCancelCB(Fl_Widget *w); 35 | void OnRefreshCB(Fl_Widget *w); 36 | void OnAddCB(Fl_Widget *w); 37 | void OnDeleteCB(Fl_Widget *w); 38 | void OnTypeChangedCB(Fl_Widget *w); 39 | 40 | static void refreshTimeout(void *t) { ((PointerEditorWindow*)t)->refreshTimeout(); } 41 | void refreshTimeout(); 42 | 43 | 44 | void show(); 45 | void hide(); 46 | AddressItem popup(unsigned long address, PointerOffsets offsets); 47 | AddressItem popup(AddressItem p); 48 | 49 | void setPointer(unsigned long address, PointerOffsets offsets); 50 | void setPointer(AddressItem p); 51 | void setResolvedAddress(unsigned long address) { m_resAddress = address; } 52 | void setMemoryOperator(MemoryOperator *op) { m_operator = op; } 53 | 54 | void capture(); 55 | 56 | private: 57 | void readPointers(); 58 | void createGroup(); 59 | 60 | unsigned long m_resAddress; 61 | MemoryOperator *m_operator; 62 | AddressItem currentPointer; 63 | unsigned int pointerUpdateCounter; 64 | 65 | vector groups; 66 | 67 | }; 68 | 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /UI/UI/PointerScannerTable.h: -------------------------------------------------------------------------------- 1 | #ifndef _POINTERTABLE_ 2 | #define _POINTERTABLE_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include "Common.h" 13 | #include "IDeactivate.h" 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | using namespace std; 20 | 21 | #define DEFAULT_PT_ROWS 200 22 | 23 | class PointerScannerTable : public Fl_Table_Row, public IDeactivate { 24 | public: 25 | PointerScannerTable(int X, int Y, int W, int H, const char *l=0); 26 | ~PointerScannerTable() { } 27 | 28 | bool hasSelection(); 29 | void clearSelection() { select_all_rows(0); set_selection(-1,-1,-1,-1); } 30 | void addRow(unsigned long address, PointerOffsets offsets); 31 | void reset() { m_pointerList.clear(); } 32 | void setResultAddress(unsigned long a) { m_resultAddress = a; } 33 | 34 | AddressItem getSelectedPointer(); 35 | 36 | static void tableClickedCB(Fl_Widget *w, void *data) { 37 | if (((Fl_Table*)w)->callback_context() == CONTEXT_CELL) 38 | { 39 | if (Fl::event_clicks()) 40 | ((PointerScannerTable*)w)->onCellDoubleClicked(((Fl_Table*)w)->callback_row(), ((Fl_Table*)w)->callback_col()); 41 | else if (Fl::event_button() == FL_RIGHT_MOUSE) 42 | { 43 | //((PointerScannerTable*)w)->onCellRightClicked(((Fl_Table*)w)->callback_row(), ((Fl_Table*)w)->callback_col()); 44 | } 45 | } 46 | else 47 | { 48 | ((PointerScannerTable*)w)->onTableClicked(); 49 | } 50 | } 51 | #if 0 52 | void startMemoryRead(); 53 | void stopMemoryRead(); 54 | static void redraw(void*); 55 | #endif 56 | 57 | protected: 58 | void draw_cell(TableContext context, int ROW=0, int COL=0, int X=0, int Y=0, int W=0, int H=0); 59 | int handle(int evt); 60 | 61 | private: 62 | void DrawHeader(const char *s, int X, int Y, int W, int H); 63 | void DrawData(const char *s, int X, int Y, int W, int H); 64 | 65 | void onCellDoubleClicked(int row, int col); 66 | void onCellRightClicked(int row, int col); 67 | void onTableClicked(); 68 | 69 | void doDeactivate(); 70 | Fl_Widget *getWidget() { return this; } 71 | 72 | 73 | private: 74 | vector m_pointerList; 75 | unsigned long m_focusAddress, m_startAddress; 76 | unsigned long m_resultAddress; 77 | 78 | }; 79 | 80 | #endif -------------------------------------------------------------------------------- /UI/UI/PointerScannerWindow.h: -------------------------------------------------------------------------------- 1 | #ifndef _PSWINDOW_ 2 | #define _PSWINDOW_ 3 | 4 | #include 5 | #include 6 | #include "DumpManager.h" 7 | #include "rkWindow.h" 8 | #include "Common.h" 9 | #include "CodeTable.h" 10 | #include "CCAPI/Common.h" 11 | #include "FL/Fl.H" 12 | 13 | using namespace std; 14 | 15 | #define PS_STATE_NEWLOAD 0 16 | #define PS_STATE_NEW 1 17 | #define PS_STATE_LOAD 2 18 | #define PS_STATE_DUMPING 3 19 | #define PS_STATE_SCANNING 4 20 | #define PS_STATE_COMPLETE 5 21 | #define PS_STATE_CANCEL 6 22 | 23 | class PointerScannerWindow : public rkWindow 24 | { 25 | public: 26 | PointerScannerWindow(int X, int Y, int W, int H, const char *l=0) : rkWindow(X,Y,W,H,l) 27 | { 28 | m_codeTable = 0; 29 | } 30 | PointerScannerWindow(int W, int H, const char *l=0) : rkWindow(W,H,l) 31 | { 32 | m_codeTable = 0; 33 | } 34 | 35 | void reset(); 36 | void NewScanCB(Fl_Widget *w); 37 | void LoadScanCB(Fl_Widget *w); 38 | void AddressChangeCB(Fl_Widget *w); 39 | void StartNewScanCB(Fl_Widget *w); 40 | void AddPointerToListCB(Fl_Widget *w); 41 | 42 | void progressTimeout(); 43 | static void progressTimeout(void *instance) { ((PointerScannerWindow*)instance)->progressTimeout(); } 44 | 45 | 46 | static void StartScanning(void *w) 47 | { 48 | Fl::remove_timeout(PointerScannerWindow::StartScanning, w); 49 | ((PointerScannerWindow*)w)->startScanning(); 50 | } 51 | void setDumpList(DumpDataList dl) { dumpList = dl; } 52 | 53 | void setDumpProgress(string s, float percent); 54 | 55 | void show(); 56 | void hide(); 57 | void setCodeTable(CodeTable *t) { m_codeTable = t; } 58 | 59 | private: 60 | void setScanState(char v); 61 | void setNumberOfResults(unsigned long res); 62 | void startScanning(); 63 | int doNewLoadDialog(bool load); 64 | 65 | string m_scanFile; 66 | string m_inputFile; 67 | char m_psState; 68 | DumpDataList dumpList; 69 | bool m_isLoading; 70 | shared_ptr dumpManager; 71 | 72 | CodeTable *m_codeTable; 73 | 74 | }; 75 | 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /UI/UI/RangeTable.cpp: -------------------------------------------------------------------------------- 1 | #include "RangeTable.h" 2 | #include 3 | #include 4 | #include 5 | 6 | using namespace std; 7 | 8 | RangeTable::RangeTable(int X, int Y, int W, int H, const char *l) : Fl_Table_Row(X,Y,W,H,l) { 9 | 10 | addEntry(0, 0xFFFFFFFF); 11 | //rows(RANGE_ROWS); 12 | row_header(0); 13 | row_height_all(20); 14 | row_resize(0); 15 | 16 | cols(RANGE_COLS); 17 | col_header(1); 18 | col_width_all(110); 19 | col_resize(1); 20 | 21 | type(SELECT_MULTI); 22 | end(); 23 | } 24 | 25 | void RangeTable::addEntry(unsigned long start, unsigned long end) 26 | { 27 | bool found = false; 28 | for (unsigned int i=0; i -1 && b > -1); 61 | } 62 | 63 | void RangeTable::draw_cell(TableContext context, int ROW, int COL, int X, int Y, int W, int H){ 64 | static char s[40]; 65 | fl_font(FL_HELVETICA, 14); // set the font for our drawing operations 66 | switch ( context ) { 67 | case CONTEXT_STARTPAGE: // before page is drawn.. 68 | return; 69 | case CONTEXT_COL_HEADER: // Draw column headers 70 | if (COL == 0) 71 | DrawHeader("Begin",X,Y,W,H); 72 | else 73 | DrawHeader("End",X,Y,W,H); 74 | return; 75 | case CONTEXT_ROW_HEADER: // Draw row headers 76 | sprintf(s,"%03d:",COL); // "001:", "002:", etc 77 | DrawHeader(s,X,Y,W,H); 78 | return; 79 | case CONTEXT_CELL: // Draw data in cells 80 | fl_push_clip(X, Y, W, H); 81 | { 82 | // BG COLOR 83 | fl_color( row_selected(ROW) ? selection_color() : FL_WHITE); 84 | fl_rectf(X, Y, W, H); 85 | 86 | // TEXT 87 | fl_color(FL_BLACK); 88 | if ((unsigned int)ROW < data.size()) 89 | { 90 | if (COL == 0) 91 | sprintf(s,"0x%08lX",data[ROW].first); 92 | else 93 | sprintf(s,"0x%08lX",data[ROW].second); 94 | DrawData(s,X,Y,W,H); 95 | } 96 | // BORDER 97 | fl_color(FL_LIGHT2); 98 | fl_rect(X, Y, W, H); 99 | } 100 | fl_pop_clip(); 101 | return; 102 | default: 103 | return; 104 | } 105 | } 106 | 107 | void RangeTable::DrawData(const char *s, int X, int Y, int W, int H) { 108 | fl_push_clip(X,Y,W,H); 109 | // Draw cell bg 110 | //fl_color(FL_WHITE); fl_rectf(X,Y,W,H); 111 | // Draw cell data 112 | fl_color(FL_GRAY0); fl_draw(s, X,Y,W,H, FL_ALIGN_CENTER); 113 | // Draw box border 114 | fl_color(color()); fl_rect(X,Y,W,H); 115 | fl_pop_clip(); 116 | } 117 | 118 | void RangeTable::saveData(string filename) 119 | { 120 | fstream f(filename, ios_base::out | ios_base::trunc); 121 | for (rkCheat_RangeList::iterator it = data.begin(); it != data.end(); ++it) 122 | { 123 | f << it->first << " " << it->second << endl; 124 | } 125 | f.close(); 126 | } 127 | 128 | bool RangeTable::loadData(string filename) 129 | { 130 | rkCheat_RangeList rList; 131 | rkCheat_RangeItem rItem; 132 | fstream f(filename, ios_base::in); 133 | if (!f) 134 | return false; 135 | while (true) 136 | { 137 | unsigned long val1, val2; 138 | f >> val1 >> val2; 139 | if( f.eof() ) break; 140 | rItem.first = val1; 141 | rItem.second = val2; 142 | rList.push_back(rItem); 143 | } 144 | f.close(); 145 | rows(0); 146 | data = rList; 147 | rows(data.size()); 148 | return true; 149 | } 150 | 151 | void RangeTable::clear() 152 | { 153 | rows(0); 154 | data.clear(); 155 | } 156 | 157 | void RangeTable::DrawHeader(const char *s, int X, int Y, int W, int H) { 158 | fl_push_clip(X,Y,W,H); 159 | fl_draw_box(FL_THIN_UP_BOX, X,Y,W,H, row_header_color()); 160 | fl_color(FL_BLACK); 161 | fl_draw(s, X,Y,W,H, FL_ALIGN_CENTER); 162 | fl_pop_clip(); 163 | } 164 | 165 | rkCheat_RangeList RangeTable::getSelectedRanges() 166 | { 167 | rkCheat_RangeList rList; 168 | for (int i = 0; i 5 | #include 6 | #include 7 | #include "Common.h" 8 | #include 9 | 10 | using namespace std; 11 | 12 | #define RANGE_ROWS 50 13 | #define RANGE_COLS 2 14 | class RangeTable : public Fl_Table_Row { 15 | public: 16 | RangeTable(int X, int Y, int W, int H, const char *l=0); 17 | 18 | void addEntry(unsigned long start, unsigned long end); 19 | void deleteEntry(unsigned int row); 20 | 21 | void saveData(string filename); 22 | bool loadData(string filename); 23 | void clear(); 24 | bool hasSelection(); 25 | void clearSelection() { select_all_rows(0); set_selection(-1,-1,-1,-1); } 26 | 27 | rkCheat_RangeList getSelectedRanges(); 28 | 29 | protected: 30 | void draw_cell(TableContext context, int ROW=0, int COL=0, int X=0, int Y=0, int W=0, int H=0); 31 | 32 | private: 33 | void DrawHeader(const char *s, int X, int Y, int W, int H); 34 | void DrawData(const char *s, int X, int Y, int W, int H); 35 | 36 | 37 | private: 38 | rkCheat_RangeList data; 39 | }; 40 | 41 | #endif -------------------------------------------------------------------------------- /UI/UI/ResultTable.h: -------------------------------------------------------------------------------- 1 | #ifndef _RESULTTABLE_ 2 | #define _RESULTTABLE_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "Common.h" 10 | #include 11 | 12 | #define RESULT_TABLE_ADD 0x00 13 | #define RESULT_TABLE_DELETE 0x01 14 | #define RESULT_TABLE_REFRESH 0x02 15 | 16 | 17 | using namespace std; 18 | 19 | 20 | class ResultTable : public Fl_Table_Row { 21 | public: 22 | ResultTable(int X, int Y, int W, int H, const char *l=0); 23 | 24 | void setResults(rkCheat_Results &r); 25 | void addEntry(unsigned long address, unsigned long value, char sign); 26 | void deleteEntry(unsigned int row); 27 | 28 | void saveData(string filename); 29 | bool loadData(string filename); 30 | void clear(); 31 | bool hasSelection(); 32 | void clearSelection() { select_all_rows(0); set_selection(-1,-1,-1,-1); } 33 | void setResultType(char type) { resultType = type; } 34 | void setMemoryOperator(MemoryOperator *op) { m_operator = op; } 35 | vector getSelectedResults(); 36 | vector getSelectedRows(); 37 | void deleteResults(); 38 | void refreshResults(); 39 | 40 | //rkCheat_ResultList getSelectedRanges(); 41 | static void redraw(void*); 42 | 43 | protected: 44 | void draw_cell(TableContext context, int ROW=0, int COL=0, int X=0, int Y=0, int W=0, int H=0); 45 | 46 | private: 47 | void DrawHeader(const char *s, int X, int Y, int W, int H); 48 | void DrawData(const char *s, int X, int Y, int W, int H); 49 | 50 | 51 | private: 52 | //rkCheat_ResultList data; 53 | //AddressList data; 54 | MemoryOperator *m_operator; 55 | rkCheat_Results *resList; 56 | Results data; 57 | char resultType; 58 | }; 59 | 60 | #endif -------------------------------------------------------------------------------- /UI/UI/SearchOperationChoice.cpp: -------------------------------------------------------------------------------- 1 | #include "CCAPI/Common.h" 2 | #include "Common.h" 3 | #include "SearchOperationChoice.h" 4 | #include 5 | 6 | using namespace std; 7 | 8 | Fl_Menu_Item SearchOperationChoice::items[] = { 9 | {"EXACT VALUE", 0, 0, (void*)(SEARCH_VALUE_EXACT), 0, FL_NORMAL_LABEL, 0, 14, 0}, 10 | {"LESS THAN VALUE", 0, 0, (void*)(SEARCH_VALUE_LESS), 0, FL_NORMAL_LABEL, 0, 14, 0}, 11 | {"GREATER THAN VALUE", 0, 0, (void*)(SEARCH_VALUE_GREATER), 0, FL_NORMAL_LABEL, 0, 14, 0}, 12 | {"NOT EQUAL TO VALUE", 0, 0, (void*)(SEARCH_VALUE_NOTEXACT), 0, FL_NORMAL_LABEL, 0, 14, 0}, 13 | {"FUZZY", 0, 0, (void*)(SEARCH_FUZZY_INIT), 0, FL_NORMAL_LABEL, 0, 14, 0}, 14 | {"DECREASED", 0, 0, (void*)(SEARCH_FUZZY_LESS), 16, FL_NORMAL_LABEL, 0, 14, 0}, 15 | {"INCREASED", 0, 0, (void*)(SEARCH_FUZZY_GREATER), 16, FL_NORMAL_LABEL, 0, 14, 0}, 16 | {"CHANGED", 0, 0, (void*)(SEARCH_FUZZY_NOTEQUAL), 16, FL_NORMAL_LABEL, 0, 14, 0}, 17 | {"UNCHANGED", 0, 0, (void*)(SEARCH_FUZZY_EQUAL), 16, FL_NORMAL_LABEL, 0, 14, 0}, 18 | {"POINTER", 0, 0, (void*)(SEARCH_POINTER), 16, FL_NORMAL_LABEL, 0, 14, 0}, 19 | {0,0,0,0,0,0,0,0,0} 20 | }; 21 | 22 | SearchOperationChoice::SearchOperationChoice(int X, int Y, int W, int H, const char *l) : Fl_Choice(X,Y,W,H,l) 23 | { 24 | Fl_Menu_Item *it = &items[0]; 25 | while (it->label() != 0) 26 | { 27 | menuMap[get_user_data(int, it->user_data())] = it; 28 | it++; 29 | } 30 | menu(items); 31 | reset(); 32 | } 33 | 34 | 35 | SearchOperationChoice::~SearchOperationChoice(void) 36 | { 37 | } 38 | 39 | 40 | void SearchOperationChoice::reset() 41 | { 42 | menuMap[SEARCH_VALUE_EXACT]->show(); 43 | menuMap[SEARCH_VALUE_LESS]->show(); 44 | menuMap[SEARCH_VALUE_GREATER]->show(); 45 | menuMap[SEARCH_VALUE_NOTEXACT]->show(); 46 | menuMap[SEARCH_FUZZY_INIT]->show(); 47 | menuMap[SEARCH_FUZZY_LESS]->hide(); 48 | menuMap[SEARCH_FUZZY_GREATER]->hide(); 49 | menuMap[SEARCH_FUZZY_NOTEQUAL]->hide(); 50 | menuMap[SEARCH_FUZZY_EQUAL]->hide(); 51 | menuMap[SEARCH_POINTER]->show(); 52 | if (isFuzzy()) 53 | value(menuMap[SEARCH_FUZZY_INIT]); 54 | } 55 | 56 | void SearchOperationChoice::firstValue() 57 | { 58 | menuMap[SEARCH_VALUE_EXACT]->show(); 59 | menuMap[SEARCH_VALUE_LESS]->show(); 60 | menuMap[SEARCH_VALUE_GREATER]->show(); 61 | menuMap[SEARCH_VALUE_NOTEXACT]->show(); 62 | menuMap[SEARCH_FUZZY_INIT]->hide(); 63 | menuMap[SEARCH_FUZZY_LESS]->show(); 64 | menuMap[SEARCH_FUZZY_GREATER]->show(); 65 | menuMap[SEARCH_FUZZY_NOTEQUAL]->show(); 66 | menuMap[SEARCH_FUZZY_EQUAL]->show(); 67 | menuMap[SEARCH_POINTER]->hide(); 68 | if (isFuzzy() && getValue() == SEARCH_FUZZY_INIT) 69 | value(menuMap[SEARCH_FUZZY_GREATER]); 70 | 71 | } 72 | 73 | void SearchOperationChoice::firstFuzzy() 74 | { 75 | firstValue(); 76 | } 77 | 78 | bool SearchOperationChoice::isFuzzy() 79 | { 80 | char v = get_user_data(char, mvalue()->user_data()); 81 | if (v == SEARCH_FUZZY_INIT || v == SEARCH_FUZZY_LESS || v == SEARCH_FUZZY_GREATER || v == SEARCH_FUZZY_NOTEQUAL || v == SEARCH_FUZZY_EQUAL) 82 | return true; 83 | return false; 84 | } 85 | 86 | bool SearchOperationChoice::isPointer() 87 | { 88 | char v = get_user_data(char, mvalue()->user_data()); 89 | if (v == SEARCH_POINTER) 90 | return true; 91 | return false; 92 | } 93 | 94 | char SearchOperationChoice::getValue() 95 | { 96 | return get_user_data(char, mvalue()->user_data()); 97 | } 98 | -------------------------------------------------------------------------------- /UI/UI/SearchOperationChoice.h: -------------------------------------------------------------------------------- 1 | #ifndef _SEARCHCHOICE_ 2 | #define _SEARCHCHOICE_ 3 | 4 | #include "FL/Fl_Choice.H" 5 | #include 6 | 7 | using namespace std; 8 | 9 | 10 | class SearchOperationChoice : public Fl_Choice 11 | { 12 | public: 13 | SearchOperationChoice(int X, int Y, int W, int H, const char *l = 0); 14 | ~SearchOperationChoice(void); 15 | 16 | void reset(); 17 | void firstValue(); 18 | void firstFuzzy(); 19 | bool isFuzzy(); 20 | bool isPointer(); 21 | char getValue(); 22 | 23 | private: 24 | static Fl_Menu_Item items[]; 25 | map menuMap; 26 | }; 27 | 28 | #endif 29 | 30 | -------------------------------------------------------------------------------- /UI/UI/TrainerCreator.cpp: -------------------------------------------------------------------------------- 1 | #include "TrainerCreator.h" 2 | #include "Trainer/Trainer.h" 3 | #include "TrainerSrc.h" 4 | #include 5 | #include 6 | #include 7 | #if !defined(_WIN32) && !defined(WIN32) 8 | #include 9 | #endif 10 | using namespace std; 11 | 12 | TrainerCreator::TrainerCreator() 13 | { 14 | m_title = ""; 15 | m_region = ""; 16 | m_gameTitle = ""; 17 | m_author = ""; 18 | m_info = ""; 19 | totalCodeSize = 0; 20 | 21 | //lets find the locations 22 | vector s; 23 | s.assign(trainSrc, trainSrc+sizeof(trainSrc)); 24 | auto it = search(s.begin(), s.end(), TITLE_TXT, TITLE_TXT+strlen(TITLE_TXT)); m_locationMap[TITLE_TXT] = rkPair(it - s.begin(), TITLELEN); 25 | it = search(s.begin(), s.end(), AUTHOR_TXT, AUTHOR_TXT+strlen(AUTHOR_TXT)); m_locationMap[AUTHOR_TXT] = rkPair(it - s.begin(), AUTHORLEN); 26 | it = search(s.begin(), s.end(), INFO_TXT, INFO_TXT+strlen(INFO_TXT)); m_locationMap[INFO_TXT] = rkPair(it - s.begin(), INFOLEN); 27 | it = search(s.begin(), s.end(), CODES_TXT, CODES_TXT+strlen(CODES_TXT)); m_locationMap[CODES_TXT] = rkPair(it - s.begin(), CODESLEN); 28 | it = search(s.begin(), s.end(), GAME_TITLE_TXT, GAME_TITLE_TXT+strlen(GAME_TITLE_TXT)); m_locationMap[GAME_TITLE_TXT] = rkPair(it - s.begin(), GAMETITLELEN); 29 | it = search(s.begin(), s.end(), VERSION_TXT, VERSION_TXT+strlen(VERSION_TXT)); m_locationMap[VERSION_TXT] = rkPair(it - s.begin(), VERSIONLEN); 30 | it = search(s.begin(), s.end(), REGION_TXT, REGION_TXT+strlen(REGION_TXT)); m_locationMap[REGION_TXT] = rkPair(it - s.begin(), REGIONLEN); 31 | } 32 | 33 | TrainerCreator::~TrainerCreator() 34 | { 35 | } 36 | 37 | void TrainerCreator::setCodes(vector &codes) 38 | { 39 | int pos = 1; 40 | codeBuffer[0] = codes.size(); 41 | for (auto it = codes.begin(); it != codes.end(); ++it) 42 | { 43 | pos += (*it)->write(&codeBuffer[pos]); 44 | } 45 | totalCodeSize = pos; 46 | } 47 | 48 | void TrainerCreator::inject(string findValue, string replaceValue) 49 | { 50 | if (m_locationMap.count(findValue) == 0) 51 | return; 52 | unsigned char *pt = &trainSrc[m_locationMap[findValue].location]; 53 | int size = m_locationMap[findValue].length; 54 | memset(pt, 0, size); 55 | memcpy(pt, replaceValue.c_str(), replaceValue.length()); 56 | } 57 | 58 | void TrainerCreator::injectCode(char *buffer) 59 | { 60 | if (m_locationMap.count(CODES_TXT) == 0) 61 | return; 62 | unsigned char *pt = &trainSrc[m_locationMap[CODES_TXT].location]; 63 | int size = m_locationMap[CODES_TXT].length; 64 | memset(pt, 0, size); 65 | memcpy(pt, (unsigned char*)codeBuffer, totalCodeSize); 66 | } 67 | 68 | void TrainerCreator::exportTrainer(bool debug) 69 | { 70 | if (codeBuffer[0] == 0) 71 | return; 72 | #if defined(_WIN32) || defined(WIN32) 73 | string fname = m_title + "-" + m_gameTitle + ".exe"; 74 | #else 75 | string fname = m_title + "-" + m_gameTitle; 76 | #endif 77 | inject(TITLE_TXT, m_title); 78 | inject(AUTHOR_TXT, m_author); 79 | inject(INFO_TXT, m_info); 80 | inject(GAME_TITLE_TXT, m_gameTitle); 81 | inject(VERSION_TXT, m_version); 82 | inject(REGION_TXT, m_region); 83 | injectCode(codeBuffer); 84 | ofstream outFile(fname.c_str(), ofstream::binary); 85 | outFile.write((char*)trainSrc, sizeof(trainSrc)); 86 | outFile.close(); 87 | #if !defined(_WIN32) && !defined(WIN32) 88 | chmod(fname.c_str(),755); 89 | #endif 90 | if (debug) 91 | { 92 | ofstream outDebugFile("dbg.dat", ofstream::binary); 93 | outDebugFile.write((char*)codeBuffer, totalCodeSize); 94 | outDebugFile.close(); 95 | 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /UI/UI/TrainerCreator.h: -------------------------------------------------------------------------------- 1 | #ifndef __TRAINERCREATOR__ 2 | #define __TRAINERCREATOR__ 3 | 4 | #include 5 | #include 6 | #include "Common.h" 7 | #include "Trainer/Trainer.h" 8 | 9 | using namespace std; 10 | 11 | class TrainerCreator 12 | { 13 | public: 14 | TrainerCreator(); 15 | ~TrainerCreator(); 16 | 17 | void setTitle(string title) { m_title = title; } 18 | void setAuthor(string author) { m_author = author; } 19 | void setRegion(string region) { m_region = region; } 20 | void setGameTitle(string title) { m_gameTitle = title; } 21 | void setInformation(string info) {m_info = info; } 22 | void setVersion(string version) { m_version = version; } 23 | 24 | void setCodes(vector &codes); 25 | 26 | void exportTrainer(bool debug = false); 27 | 28 | struct rkPair 29 | { 30 | long long location; 31 | int length; 32 | rkPair() { location = 0; length = 0; } 33 | rkPair(long long loc, int len) { location = loc; length = len; } 34 | rkPair& operator=(const rkPair &t) { location = t.location; length = t.length; return *this; }; 35 | }; 36 | 37 | private: 38 | void inject(string findValue, string replaceValue); 39 | void injectCode(char *buffer); 40 | 41 | map m_locationMap; 42 | 43 | string m_title; 44 | string m_author; 45 | string m_region; 46 | string m_gameTitle; 47 | string m_info; 48 | string m_version; 49 | char codeBuffer[CODESLEN]; 50 | int totalCodeSize; 51 | }; 52 | 53 | #endif -------------------------------------------------------------------------------- /UI/UI/TrainerItemCodeTable.h: -------------------------------------------------------------------------------- 1 | #ifndef _TRAINCODETABLE_ 2 | #define _TRAINCODETABLE_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include "Common.h" 12 | #include "IDeactivate.h" 13 | #include 14 | #include 15 | #include 16 | 17 | using namespace std; 18 | #define MAX_CODE_MENU 1024 19 | 20 | class TrainerItemWindow; 21 | struct ItemField 22 | { 23 | AddressItem data; 24 | Fl_Choice *choice; 25 | ValueInput *value_input; 26 | Fl_Menu_Item *menu; 27 | char _delete; 28 | ItemField(Fl_Choice *c, ValueInput *v, Fl_Menu_Item *m) { choice = c; value_input = v; menu = m; _delete = 0;} 29 | ItemField() { value_input = 0; choice = 0; menu = 0; _delete = 0;} 30 | ~ItemField() { 31 | choice->menu(0); 32 | delete []menu; 33 | delete value_input; 34 | delete choice; 35 | value_input = 0; 36 | choice = 0; 37 | } 38 | 39 | }; 40 | 41 | typedef shared_ptr CodeItem; 42 | typedef vector CodeItems; 43 | 44 | class TrainerItemCodeTable : public Fl_Table_Row, public IDeactivate { 45 | public: 46 | TrainerItemCodeTable(int X, int Y, int W, int H, const char *l=0); 47 | ~TrainerItemCodeTable() { if (m_menu) { delete [] m_menu; } } 48 | 49 | void init(); 50 | void createEntry(); 51 | void deleteEntry(unsigned int row); 52 | void deleteEntry(vector &indexRows); 53 | 54 | void addCode() { createEntry(); } 55 | void addCodes(AddressList codes); 56 | void deleteCode(); 57 | 58 | bool hasSelection(); 59 | void clearSelection() { select_all_rows(0); set_selection(-1,-1,-1,-1); } 60 | 61 | CodeItems getCodes() { return trainList; } 62 | 63 | void setCodeList(const rkCheat_CodeList &list); 64 | 65 | void clearTable(); 66 | 67 | static void tableClickedCB(Fl_Widget *w, void *data); 68 | 69 | static void codeDescriptionChangedCB(Fl_Widget *w, void *item) { 70 | ((TrainerItemCodeTable *)w->parent()->parent())->onDescriptionChanged((ItemField*)((Fl_Choice*)w)->user_data(), (AddressObj*)((Fl_Choice*)w)->mvalue()->user_data(), ((Fl_Choice*)w)->value()); 71 | } 72 | //static void codeValueChangedCB(Fl_Widget *w, void *item) { ((TrainerItemCodeTable *)w->parent())->onValueChanged((CodeItem*)item, ((ValueInput*)w)->getLLValue()); } 73 | static void codeValueChangedCB(Fl_Widget *w, void *item) { 74 | ((TrainerItemCodeTable *)w->parent()->parent())->onValueChanged((ItemField*)((Fl_Input*)w)->user_data(), 75 | (AddressObj*)((ItemField*)((Fl_Input*)w)->user_data())->choice->mvalue()->user_data(), 76 | ((ValueInput*)w)->getLLValue()); 77 | } 78 | bool isEmpty(); 79 | bool canAdd(); 80 | void setParent(TrainerItemWindow *w) { parentWindow = w; } 81 | 82 | static void selectionTimeout(void *); 83 | 84 | protected: 85 | void draw_cell(TableContext context, int ROW=0, int COL=0, int X=0, int Y=0, int W=0, int H=0); 86 | int handle(int evt); 87 | 88 | private: 89 | void DrawHeader(const char *s, int X, int Y, int W, int H); 90 | void DrawData(const char *s, int X, int Y, int W, int H); 91 | void DrawCheckbox(int X, int Y, int W, int H); 92 | 93 | void rebuildTable(); 94 | void reInsert(); 95 | 96 | void onDescriptionChanged(ItemField *item, AddressObj *addr, int sel); 97 | void onValueChanged(ItemField *item, AddressObj *addr, long long value); 98 | void onCellDoubleClicked(int row, int col); 99 | void onCellRightClicked(int row, int col); 100 | void onTableClicked(); 101 | Fl_Menu_Item *copyMenu(Fl_Menu_Item *m); 102 | void selectRow(int row); 103 | int getSelectedRow() { return selectedRow; } 104 | 105 | 106 | void doDeactivate(); 107 | Fl_Widget *getWidget() { return this; } 108 | 109 | vector getSelectedRows(); 110 | rkCheat_CodeList codeList; 111 | CodeItems trainList; 112 | Fl_Menu_Item *m_menu; 113 | TrainerItemWindow *parentWindow; 114 | 115 | int selectedRow; 116 | 117 | private: 118 | Fl_Widget *last_cell_widget; 119 | Fl_Widget *current_cell_widget; 120 | 121 | }; 122 | 123 | #endif -------------------------------------------------------------------------------- /UI/UI/TrainerItemWindow.h: -------------------------------------------------------------------------------- 1 | #ifndef __TRAINERITEMWINDOW__ 2 | #define __TRAINERITEMWINDOW__ 3 | #include "rkWindow.h" 4 | #include "CodeTable.h" 5 | #include "Trainer/Trainer.h" 6 | #include "TrainerItemCodeTable.h" 7 | 8 | class TrainerItemWindow : public rkWindow 9 | { 10 | public: 11 | TrainerItemWindow(int X, int Y, int W, int H, const char *l=0) : rkWindow(X,Y,W,H, l) { } 12 | TrainerItemWindow(int W, int H, const char *l=0) : rkWindow(W,H, l) { } 13 | 14 | void init(); 15 | void show(); 16 | 17 | void popup(CodeTable *t, rkTrainerCodeObj *code = 0); 18 | 19 | void onConditionChanged(); 20 | void onConditionCodeChanged(AddressObj *addr = 0); 21 | void onNameChanged(); 22 | void onAddCode(); 23 | void onDeleteCode(); 24 | void onCancel(); 25 | void onOK(); 26 | 27 | rkTrainerCode getCode() { return m_code; } 28 | 29 | static void OnCodeTableUpdate(TrainerItemCodeTable *ct, bool timeout=false); 30 | static void UpdateTimeout(void *); 31 | 32 | static string getDescriptionOrCode(const rkCheat_CodeItem &item); 33 | 34 | void capture(); 35 | 36 | private: 37 | void checkButtonStatus(); 38 | void setupCodes(CodeTable *t, rkTrainerCodeObj *code); 39 | rkCheat_CodeList m_cl; 40 | rkTrainerCode m_code; 41 | }; 42 | 43 | #endif -------------------------------------------------------------------------------- /UI/UI/TrainerMakerWindow.cpp: -------------------------------------------------------------------------------- 1 | #include "TrainerMakerWindow.h" 2 | #include "TrainerCreator.h" 3 | #include "ui_main.h" 4 | 5 | using namespace std; 6 | void TrainerMakerWindow::init() 7 | { 8 | uiInstance->m_tcTrainerTitle->maximum_size(TITLELEN); 9 | uiInstance->m_tcAuthorName->maximum_size(AUTHORLEN); 10 | uiInstance->m_tcGameTitle->maximum_size(GAMETITLELEN); 11 | uiInstance->m_tcGameRegion->maximum_size(REGIONLEN); 12 | uiInstance->m_tcInformation->buffer(infoBuffer); 13 | 14 | checkButtonStatus(); 15 | } 16 | 17 | void TrainerMakerWindow::show() 18 | { 19 | init(); 20 | rkWindow::show(); 21 | } 22 | 23 | void TrainerMakerWindow::checkButtonStatus() 24 | { 25 | bool createPass = true; 26 | bool editPass = true; 27 | if (uiInstance->m_tcCodeBrowser->size() == 0) 28 | { 29 | createPass = false; 30 | editPass = false; 31 | } 32 | if (uiInstance->m_tcCodeBrowser->value() == 0) 33 | editPass = false; 34 | if (uiInstance->m_tcTrainerTitle->size() == 0 || uiInstance->m_tcGameRegion->size() == 0 || uiInstance->m_tcGameTitle->size() == 0) 35 | { 36 | createPass = false; 37 | } 38 | if (createPass) uiInstance->m_tcCreateButton->activate(); else uiInstance->m_tcCreateButton->deactivate(); 39 | if (editPass) uiInstance->m_tcEditCodeButton->activate(); else uiInstance->m_tcEditCodeButton->deactivate(); 40 | 41 | } 42 | 43 | void TrainerMakerWindow::popup() 44 | { 45 | m_codes.clear(); 46 | uiInstance->m_tcCodeBrowser->clear(); 47 | show(); 48 | while (shown()) Fl::wait(); 49 | } 50 | void TrainerMakerWindow::createNewCode() 51 | { 52 | uiInstance->m_trainerItem->popup(uiInstance->ui_codeTable); 53 | auto code = uiInstance->m_trainerItem->getCode(); 54 | if (code == nullptr) 55 | return; 56 | m_codes.push_back(code); 57 | uiInstance->m_tcCodeBrowser->add(code->name.c_str(), code.get()); 58 | checkButtonStatus(); 59 | 60 | } 61 | 62 | void TrainerMakerWindow::onSelectCode() 63 | { 64 | checkButtonStatus(); 65 | } 66 | 67 | void TrainerMakerWindow::onEdit() 68 | { 69 | auto v = uiInstance->m_tcCodeBrowser->value(); 70 | auto data = uiInstance->m_tcCodeBrowser->data(v); 71 | uiInstance->m_trainerItem->popup(uiInstance->ui_codeTable, (rkTrainerCodeObj*) data); 72 | auto code = uiInstance->m_trainerItem->getCode(); 73 | if (code == nullptr) 74 | return; 75 | for (auto ci = m_codes.begin(); ci != m_codes.end();) 76 | { 77 | if ((*ci).get() == (rkTrainerCodeObj*) data) 78 | ci = m_codes.erase(ci); 79 | else 80 | ++ci; 81 | } 82 | uiInstance->m_tcCodeBrowser->remove(v); 83 | uiInstance->m_tcCodeBrowser->insert(v, code->name.c_str(), code.get()); 84 | m_codes.push_back(code); 85 | onSelectCode(); 86 | damage(FL_DAMAGE_ALL); 87 | } 88 | 89 | void TrainerMakerWindow::onCreate() 90 | { 91 | TrainerCreator creator; 92 | creator.setTitle(uiInstance->m_tcTrainerTitle->value()); 93 | creator.setAuthor(uiInstance->m_tcAuthorName->value()); 94 | creator.setGameTitle(uiInstance->m_tcGameTitle->value()); 95 | creator.setInformation(uiInstance->m_tcInformation->buffer()->text()); 96 | creator.setRegion(uiInstance->m_tcGameRegion->value()); 97 | creator.setVersion("1.0"); 98 | creator.setCodes(m_codes); 99 | creator.exportTrainer(); 100 | fl_message("The trainer was successfully created!"); 101 | hide(); 102 | } 103 | 104 | void TrainerMakerWindow::capture() 105 | { 106 | rkWindow::capture(); 107 | createdW = uiInstance->m_tcCodeGroup->x() + uiInstance->m_tcCodeGroup->w() + 10; 108 | createdH = uiInstance->m_tcCreateButton->y() + uiInstance->m_tcCreateButton->h() + 20; 109 | 110 | } 111 | 112 | -------------------------------------------------------------------------------- /UI/UI/TrainerMakerWindow.h: -------------------------------------------------------------------------------- 1 | #ifndef __TRAINERWINDOW__ 2 | #define __TRAINERWINDOW__ 3 | #include "FL/Fl_Text_Buffer.H" 4 | #include "rkWindow.h" 5 | #include "Common.h" 6 | #include "Trainer/Trainer.h" 7 | 8 | class TrainerMakerWindow : public rkWindow 9 | { 10 | public: 11 | TrainerMakerWindow(int X, int Y, int W, int H, const char *l=0) : rkWindow(X,Y,W,H, l) { infoBuffer = new Fl_Text_Buffer(); } 12 | TrainerMakerWindow(int W, int H, const char *l=0) : rkWindow(W,H, l) { infoBuffer = new Fl_Text_Buffer(); } 13 | 14 | void init(); 15 | void show(); 16 | 17 | void createNewCode(); 18 | void onSelectCode(); 19 | void onEdit(); 20 | void checkButtonStatus(); 21 | void onCreate(); 22 | 23 | void popup(); 24 | void capture(); 25 | 26 | private: 27 | vector m_codes; 28 | Fl_Text_Buffer *infoBuffer; 29 | }; 30 | 31 | #endif -------------------------------------------------------------------------------- /UI/UI/TrainerSrc.h: -------------------------------------------------------------------------------- 1 | #ifndef __TRAINSRC__ 2 | #define __TRAINSRC__ 3 | #if defined(_WIN32) || defined(WIN32) 4 | extern unsigned char trainSrc[567808]; 5 | #else 6 | extern unsigned char trainSrc[584592]; 7 | #endif 8 | #endif 9 | -------------------------------------------------------------------------------- /UI/UI/UI.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | Source Files 29 | 30 | 31 | Source Files 32 | 33 | 34 | Source Files 35 | 36 | 37 | Source Files 38 | 39 | 40 | Source Files 41 | 42 | 43 | Source Files 44 | 45 | 46 | Source Files 47 | 48 | 49 | Source Files 50 | 51 | 52 | 53 | 54 | Header Files 55 | 56 | 57 | Header Files 58 | 59 | 60 | Header Files 61 | 62 | 63 | Header Files 64 | 65 | 66 | Header Files 67 | 68 | 69 | Header Files 70 | 71 | 72 | Header Files 73 | 74 | 75 | Header Files 76 | 77 | 78 | Header Files 79 | 80 | 81 | Header Files 82 | 83 | 84 | Header Files 85 | 86 | 87 | Header Files 88 | 89 | 90 | -------------------------------------------------------------------------------- /UI/UI/UI.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /UI/UI/UI.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {6D2D5ACC-8EF2-46DD-8859-52DDDD47908B} 15 | Win32Proj 16 | UI 17 | UI 18 | 19 | 20 | 21 | Application 22 | true 23 | v110 24 | Unicode 25 | 26 | 27 | Application 28 | false 29 | v110 30 | true 31 | Unicode 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | true 45 | CCCheat 46 | 47 | 48 | false 49 | CCCheat 50 | 51 | 52 | 53 | 54 | 55 | Level3 56 | Disabled 57 | _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;_VARIADIC_MAX=6;%(PreprocessorDefinitions);_VARIADIC_MAX=6;_CRT_SECURE_NO_WARNINGS 58 | $(ProjectDir)\..\..\..\fltk;$(ProjectDir)\..\..\CCAPI;$(ProjectDir)\..\..\Trainer;%(AdditionalIncludeDirectories) 59 | 60 | 61 | Console 62 | true 63 | fltkd.lib;CCAPI.lib;%(AdditionalDependencies) 64 | $(ProjectDir)\..\..\..\fltk\lib;$(ProjectDir)\..\$(IntDir);%(AdditionalLibraryDirectories) 65 | 66 | 67 | 68 | 69 | Level3 70 | 71 | 72 | MaxSpeed 73 | true 74 | true 75 | WIN32;NDEBUG;%(PreprocessorDefinitions);_VARIADIC_MAX=6;_CRT_SECURE_NO_WARNINGS 76 | $(ProjectDir)\..\..\..\fltk;$(ProjectDir)\..\..\CCAPI;$(ProjectDir)\..\..\Trainer;%(AdditionalIncludeDirectories) 77 | 78 | 79 | Windows 80 | true 81 | true 82 | true 83 | $(ProjectDir)\..\..\..\fltk\lib;$(ProjectDir)\..\$(IntDir);%(AdditionalLibraryDirectories) 84 | fltk.lib;CCAPI.lib;%(AdditionalDependencies) 85 | 86 | 87 | mkdir "$(SolutionDir)\..\bin"; 88 | copy "$(TargetPath)" "$(SolutionDir)\..\bin" 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | -------------------------------------------------------------------------------- /UI/UI/ValueInput.h: -------------------------------------------------------------------------------- 1 | #ifndef _VALUEINPUT_ 2 | #define _VALUEINPUT_ 3 | #include 4 | #include 5 | 6 | #define VAL_TYPE_DESC 0 7 | #define VAL_TYPE_ADDRESS 1 8 | #define VAL_TYPE_VALUE 2 9 | #define VAL_TYPE_MISC 3 10 | 11 | 12 | 13 | class ValueInput : 14 | public Fl_Input 15 | { 16 | public: 17 | ValueInput(int x, int y, int w, int h, const char *l=0); 18 | ~ValueInput(void); 19 | int handle(int); 20 | 21 | void setCodeType(bool v) {m_codeType = v;} 22 | void setHex(bool hex); 23 | void setValueType(char type); 24 | unsigned long getULValue(); 25 | long long getLLValue(); 26 | void setLiteral(bool v) { m_literal = v; } 27 | void setValType(char type) { m_valType = type; } 28 | char getValType() { return m_valType; } 29 | void setValue(unsigned long ivalue); 30 | void setValue(long long ivalue); 31 | void setValue(float ivalue); 32 | void setValue(long long value, char type, bool lit); 33 | 34 | private: 35 | string convertHexToInt(string hex); 36 | string convertHexToFloat(string hex); 37 | string convertIntToHex(string val); 38 | string convertFloatToHex(string val); 39 | 40 | bool m_hex; 41 | bool m_literal; 42 | char m_type; 43 | bool m_codeType; 44 | char m_valType; 45 | }; 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /UI/UI/ValueTypeChoice.cpp: -------------------------------------------------------------------------------- 1 | #include "CCAPI/Common.h" 2 | #include "Common.h" 3 | #include "ValueTypeChoice.h" 4 | #include 5 | 6 | using namespace std; 7 | 8 | Fl_Menu_Item ValueTypeChoice::items[] = { 9 | {"1 Byte", 0, 0, (void*)(SEARCH_VALUE_TYPE_1BYTE), 0, FL_NORMAL_LABEL, 0, 14, 0}, 10 | {"2 Bytes", 0, 0, (void*)(SEARCH_VALUE_TYPE_2BYTE), 0, FL_NORMAL_LABEL, 0, 14, 0}, 11 | {"4 Bytes", 0, 0, (void*)(SEARCH_VALUE_TYPE_4BYTE), 0, FL_NORMAL_LABEL, 0, 14, 0}, 12 | {"Float", 0, 0, (void*)(SEARCH_VALUE_TYPE_FLOAT), 0, FL_NORMAL_LABEL, 0, 14, 0}, 13 | {0,0,0,0,0,0,0,0,0} 14 | }; 15 | 16 | ValueTypeChoice::ValueTypeChoice(int X, int Y, int W, int H, const char *l) : Fl_Choice(X,Y,W,H,l) 17 | { 18 | Fl_Menu_Item *it = &items[0]; 19 | while (it->label() != 0) 20 | { 21 | menuMap[get_user_data(int, it->user_data())] = it; 22 | it++; 23 | } 24 | menu(items); 25 | reset(); 26 | } 27 | 28 | 29 | ValueTypeChoice::~ValueTypeChoice(void) 30 | { 31 | } 32 | 33 | 34 | void ValueTypeChoice::reset() 35 | { 36 | menuMap[SEARCH_VALUE_TYPE_1BYTE]->show(); 37 | menuMap[SEARCH_VALUE_TYPE_2BYTE]->show(); 38 | menuMap[SEARCH_VALUE_TYPE_4BYTE]->show(); 39 | menuMap[SEARCH_VALUE_TYPE_FLOAT]->show(); 40 | value(menuMap[SEARCH_VALUE_TYPE_4BYTE]); 41 | } 42 | 43 | 44 | char ValueTypeChoice::getValue() 45 | { 46 | return get_user_data(char, mvalue()->user_data()); 47 | } 48 | -------------------------------------------------------------------------------- /UI/UI/ValueTypeChoice.h: -------------------------------------------------------------------------------- 1 | #ifndef _VALUETYPECHOICE_ 2 | #define _VALUETYPECHOICE_ 3 | 4 | #include "FL/Fl_Choice.H" 5 | #include 6 | 7 | using namespace std; 8 | 9 | 10 | class ValueTypeChoice : public Fl_Choice 11 | { 12 | public: 13 | ValueTypeChoice(int X, int Y, int W, int H, const char *l = 0); 14 | ~ValueTypeChoice(void); 15 | 16 | void reset(); 17 | char getValue(); 18 | 19 | private: 20 | static Fl_Menu_Item items[]; 21 | map menuMap; 22 | }; 23 | 24 | #endif 25 | 26 | -------------------------------------------------------------------------------- /UI/UI/ValueViewerTable.h: -------------------------------------------------------------------------------- 1 | #ifndef _VALUETABLE_ 2 | #define _VALUETABLE_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include "Common.h" 12 | #include "IDeactivate.h" 13 | #include "CodeTable.h" 14 | #include 15 | #include 16 | #include 17 | 18 | using namespace std; 19 | 20 | #define DEFAULT_ROWS 200 21 | 22 | class ValueViewerTable : public Fl_Table_Row, public IDeactivate { 23 | public: 24 | ValueViewerTable(int X, int Y, int W, int H, const char *l=0); 25 | ~ValueViewerTable() { Fl::remove_timeout(redraw); } 26 | 27 | bool hasSelection(); 28 | void clearSelection() { select_all_rows(0); set_selection(-1,-1,-1,-1); } 29 | void addSelectedAddresses(); 30 | void setMemoryOperator(MemoryOperator *op); 31 | void setCodeTable(CodeTable *t) { m_codeTable = t; } 32 | void setType(char type) { m_selectedType = type; } 33 | void setAddress(unsigned long address) { m_focusAddress = address; } 34 | unsigned long getAddress() { return m_focusAddress; } 35 | void setSigned(bool s) { m_signed = s; } 36 | 37 | static void tableClickedCB(Fl_Widget *w, void *data) { 38 | if (((Fl_Table*)w)->callback_context() == CONTEXT_CELL) 39 | { 40 | if (Fl::event_clicks()) 41 | ((ValueViewerTable*)w)->onCellDoubleClicked(((Fl_Table*)w)->callback_row(), ((Fl_Table*)w)->callback_col()); 42 | else if (Fl::event_button() == FL_RIGHT_MOUSE) 43 | { 44 | //((ValueViewerTable*)w)->onCellRightClicked(((Fl_Table*)w)->callback_row(), ((Fl_Table*)w)->callback_col()); 45 | } 46 | } 47 | else 48 | { 49 | ((ValueViewerTable*)w)->onTableClicked(); 50 | } 51 | } 52 | void startMemoryRead(); 53 | void stopMemoryRead(); 54 | static void redraw(void*); 55 | 56 | protected: 57 | void draw_cell(TableContext context, int ROW=0, int COL=0, int X=0, int Y=0, int W=0, int H=0); 58 | int handle(int evt); 59 | 60 | private: 61 | void DrawHeader(const char *s, int X, int Y, int W, int H); 62 | void DrawData(const char *s, int X, int Y, int W, int H); 63 | 64 | void onCellDoubleClicked(int row, int col); 65 | void onCellRightClicked(int row, int col); 66 | void onTableClicked(); 67 | 68 | void doDeactivate(); 69 | Fl_Widget *getWidget() { return this; } 70 | 71 | vector getSelectedRows(); 72 | MemoryOperator *m_operator; 73 | Fl_Callback *viewer; 74 | CodeTable *m_codeTable; 75 | 76 | char m_selectedType; 77 | bool m_signed; 78 | char m_memory[DEFAULT_ROWS*2]; 79 | 80 | 81 | 82 | private: 83 | unsigned long m_focusAddress, m_startAddress; 84 | 85 | }; 86 | 87 | #endif -------------------------------------------------------------------------------- /UI/UI/ValueViewerWindow.cpp: -------------------------------------------------------------------------------- 1 | #include "ValueViewerWindow.h" 2 | #include "ValueViewerTable.h" 3 | #include "ui_main.h" 4 | 5 | void ValueViewerWindow::TypeChangedCB(Fl_Widget *w) 6 | { 7 | char type = uiInstance->m_viewerTypeChoice->value(); 8 | uiInstance->m_valueTable->setType(type); 9 | if (uiInstance->m_viewerTypeChoice->value() == SEARCH_VALUE_TYPE_FLOAT) 10 | uiInstance->m_viewerSignedButton->deactivate(); 11 | else 12 | uiInstance->m_viewerSignedButton->activate(); 13 | } 14 | void ValueViewerWindow::SignedChangedCB(Fl_Widget *w) 15 | { 16 | char sign = uiInstance->m_viewerSignedButton->value(); 17 | uiInstance->m_valueTable->setSigned(sign != 0); 18 | } 19 | 20 | void ValueViewerWindow::AddCodeCB(Fl_Widget *w) 21 | { 22 | uiInstance->m_valueTable->addSelectedAddresses(); 23 | } 24 | 25 | void ValueViewerWindow::setCodeData(rkCheat_Code *item) 26 | { 27 | uiInstance->m_viewerTypeChoice->value(item->m_address->type); 28 | auto resolved = item->m_address->isPointer() ? item->m_address->pointer->resolved : item->m_address->address; 29 | if (visible() && uiInstance->m_valueTable->getAddress() != resolved) 30 | hide(); 31 | uiInstance->m_valueTable->setAddress(resolved); 32 | uiInstance->m_valueTable->setType(item->m_address->type); 33 | TypeChangedCB(this); 34 | } 35 | 36 | void ValueViewerWindow::show() 37 | { 38 | if (!visible()) 39 | uiInstance->m_valueTable->startMemoryRead(); 40 | rkWindow::show(); 41 | } 42 | 43 | void ValueViewerWindow::hide() 44 | { 45 | if (visible()) 46 | uiInstance->m_valueTable->stopMemoryRead(); 47 | reset(); 48 | rkWindow::hide(); 49 | } 50 | 51 | void ValueViewerWindow::reset() 52 | { 53 | uiInstance->m_valueTable->clearSelection(); 54 | uiInstance->m_valueTable->setType(SEARCH_VALUE_TYPE_4BYTE); 55 | uiInstance->m_valueTable->setAddress(0); 56 | uiInstance->m_valueTable->setSigned(false); 57 | Fl_Menu_Item *it = &uiInstance->menu_ui_valueType[0]; 58 | while (it->label() != 0) 59 | { 60 | if (get_user_data(int, it->user_data()) == SEARCH_VALUE_TYPE_4BYTE) 61 | { 62 | uiInstance->m_viewerTypeChoice->value(it); 63 | break; 64 | } 65 | it++; 66 | } 67 | uiInstance->m_viewerSignedButton->value(0); 68 | } 69 | 70 | void ValueViewerWindow::capture() 71 | { 72 | Fl_Window::show(); 73 | createdX = x(); 74 | createdY = y(); 75 | createdW = uiInstance->m_valueAddCodeButton->x()+uiInstance->m_valueAddCodeButton->w()+20; 76 | createdH = uiInstance->m_valueTable->y() + uiInstance->m_valueTable->h() + 20; 77 | Fl_Window::hide(); 78 | } -------------------------------------------------------------------------------- /UI/UI/ValueViewerWindow.h: -------------------------------------------------------------------------------- 1 | #ifndef _VVWINDOW_ 2 | #define _VVWINDOW_ 3 | 4 | #include "rkWindow.h" 5 | #include "Common.h" 6 | 7 | using namespace std; 8 | 9 | class ValueViewerWindow : public rkWindow 10 | { 11 | public: 12 | ValueViewerWindow(int X, int Y, int W, int H, const char *l=0) : rkWindow(X,Y,W,H,l) {} 13 | ValueViewerWindow(int W, int H, const char *l=0) : rkWindow(W,H,l) {} 14 | 15 | void TypeChangedCB(Fl_Widget *w); 16 | void SignedChangedCB(Fl_Widget *w); 17 | void AddCodeCB(Fl_Widget *w); 18 | void setCodeData(rkCheat_Code *item); 19 | 20 | void show(); 21 | void hide(); 22 | 23 | void capture(); 24 | 25 | private: 26 | void reset(); 27 | 28 | }; 29 | 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /UI/UI/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ui_main.h" 2 | #include "CCAPI/CCAPI.h" 3 | #include "InterfaceCCAPI.h" 4 | #include "TrainerSrc.h" 5 | 6 | #include 7 | #include 8 | #include 9 | using namespace std; 10 | 11 | 12 | 13 | void windowCallback(Fl_Widget*, void*) { 14 | if (Fl::event()==FL_SHORTCUT && Fl::event_key()==FL_Escape) 15 | return; // ignore Escape 16 | if (InterfaceCCAPI::instance != 0) 17 | InterfaceCCAPI::instance->disconnect(); 18 | exit(0); 19 | } 20 | 21 | void exportTrainer(string name, string filename) 22 | { 23 | vector s; 24 | char cTitle[] = "TRAIN_TITLE"; 25 | s.assign(trainSrc, trainSrc+397312); 26 | auto it = search(s.begin(), s.end(), cTitle, cTitle+strlen(cTitle)); 27 | if (it == s.end()) return; 28 | for (auto nit = name.begin(); nit != name.end(); ++nit) 29 | { 30 | *it = *nit; 31 | ++it; 32 | } 33 | ofstream outFile(filename, ofstream::binary); 34 | outFile.write((char*)s.data(), 397312); 35 | outFile.close(); 36 | } 37 | 38 | int main() { 39 | CCAPI ccapi("127.0.0.1"); 40 | rkCheatUI ui; 41 | InterfaceCCAPI m_interface(&ccapi, &ui); 42 | ui.mainWindow->callback(windowCallback); 43 | ui.m_trainerMakerWindow->callback(windowCallback); 44 | ui.m_pointerScannerWindow->callback(windowCallback); 45 | ui.setVersion(CCCHEAT_VERSION); 46 | ui.setInterface(&m_interface); 47 | ui.setConnectStatus(INTERFACE_DISCONNECT); 48 | ui.mainWindow->show(); 49 | return Fl::run(); 50 | } 51 | -------------------------------------------------------------------------------- /UI/UI/rkWindow.cpp: -------------------------------------------------------------------------------- 1 | #include "rkWindow.h" 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | vector rkWindow::objs; 8 | 9 | rkWindow::rkWindow(int X, int Y, int W, int H, const char *l) : Fl_Double_Window(X,Y,W,H,l), createdX(X), createdY(Y), createdW(W), createdH(H), first(false) 10 | { 11 | } 12 | rkWindow::rkWindow(int W, int H, const char *l) : Fl_Double_Window(W,H,l), createdW(W), createdH(H), first(false) 13 | { 14 | resize(x(), y(), createdW, createdH); 15 | createdX = x(); 16 | createdY = y(); 17 | } 18 | 19 | 20 | int rkWindow::handle(int evt) 21 | { 22 | int res = Fl_Double_Window::handle(evt); 23 | if (evt == FL_PUSH) 24 | { 25 | for (unsigned int i=0; igetWidget()) 28 | objs.at(i)->doDeactivate(); 29 | } 30 | } 31 | return res; 32 | } 33 | 34 | void rkWindow::show() 35 | { 36 | if (visible()) 37 | { 38 | resize(x(), y(), createdW, createdH); 39 | } 40 | else 41 | { 42 | if (!first) 43 | { 44 | first = true; 45 | capture(); 46 | } 47 | Fl_Window::show(); 48 | resize(createdX, createdY, createdW, createdH); 49 | } 50 | Fl_Window::show(); 51 | } 52 | void rkWindow::hide() 53 | { 54 | Fl_Window::hide(); 55 | } 56 | 57 | void rkWindow::capture() 58 | { 59 | Fl_Window::show(); 60 | createdX = x(); 61 | createdY = y(); 62 | createdW = w(); 63 | createdH = h(); 64 | Fl_Window::hide(); 65 | } 66 | 67 | void rkWindow::manual_resize(int w, int h) 68 | { 69 | Fl_Window::hide(); 70 | createdW = w; 71 | createdH = h; 72 | Fl_Window::show(); 73 | resize(x(), y(), w, h); 74 | } 75 | -------------------------------------------------------------------------------- /UI/UI/rkWindow.h: -------------------------------------------------------------------------------- 1 | #ifndef _RKWINDOW_ 2 | #define _RKWINDOW_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include "IDeactivate.h" 8 | 9 | using namespace std; 10 | 11 | class rkWindow : public Fl_Double_Window 12 | { 13 | public: 14 | rkWindow(int X, int Y, int W, int H, const char *l=0); 15 | rkWindow(int W, int H, const char *l=0); 16 | 17 | static void addObject(IDeactivate *d) { objs.push_back(d); } 18 | static vector objs; 19 | 20 | 21 | int handle(int evt); 22 | 23 | void manual_resize(int w, int h); 24 | void show(); 25 | void hide(); 26 | 27 | virtual void capture(); 28 | 29 | protected: 30 | unsigned int createdW, createdH; 31 | int createdX, createdY; 32 | bool first; 33 | }; 34 | 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /UI/ui_main: -------------------------------------------------------------------------------- 1 | # data file for the Fltk User Interface Designer (fluid) 2 | version 1.0302 3 | header_name {.h} 4 | code_name {.cxx} 5 | class rkCheatUI {open 6 | } { 7 | Function {rkCheatUI()} {open 8 | } { 9 | Fl_Window mainWindow {open 10 | xywh {99 126 403 430} type Double visible 11 | } { 12 | Fl_Group searchGroup { 13 | label Search open 14 | xywh {25 25 337 114} box BORDER_BOX color 48 15 | } { 16 | Fl_Choice ui_searchType { 17 | label {Search Type:} open selected 18 | xywh {119 50 138 16} down_box BORDER_BOX 19 | } { 20 | MenuItem {} { 21 | label item 22 | xywh {0 0 30 20} 23 | } 24 | } 25 | } 26 | Fl_Group {} { 27 | label Results open 28 | xywh {21 166 337 232} box BORDER_BOX 29 | } {} 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /bin/CCCheat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/primetime00/CCCheat/827fcfb0f06946ed9cde5a10dd489b4a677209ff/bin/CCCheat -------------------------------------------------------------------------------- /bin/CCCheat.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/primetime00/CCCheat/827fcfb0f06946ed9cde5a10dd489b4a677209ff/bin/CCCheat.exe --------------------------------------------------------------------------------