2019-09-11 07:28:59 +08:00
|
|
|
#include "main.h"
|
|
|
|
#include <iostream>
|
|
|
|
#include <windows.h>
|
|
|
|
#include <vector>
|
|
|
|
#include "Process.h"
|
|
|
|
#include "crc.h"
|
|
|
|
|
|
|
|
#define CUBE_VERSION "1.0.0-0"
|
2019-09-12 09:45:36 +08:00
|
|
|
#define CUBE_CRC 0xDC91320A
|
2019-09-11 07:28:59 +08:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
bool FileExists(const char* fileName) {
|
|
|
|
DWORD dwAttrib = GetFileAttributes(fileName);
|
|
|
|
return (dwAttrib != INVALID_FILE_ATTRIBUTES && !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY));
|
|
|
|
}
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
vector <std::string> modDLLs;
|
|
|
|
//Cube world is obviously required
|
|
|
|
if (!FileExists("Cube.exe")){
|
|
|
|
printf("Cube World not found.\n");
|
|
|
|
Sleep(1000);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int checksum = crc32_file("Cube.exe");
|
|
|
|
if (checksum != CUBE_CRC){
|
|
|
|
printf("Cube World was found, but it is not version %s.\n"
|
|
|
|
"(Found CRC %08X, expected %08X)\n"
|
|
|
|
"Please update your game.\n",
|
|
|
|
CUBE_VERSION, checksum, CUBE_CRC);
|
|
|
|
printf("Press enter to exit.\n");
|
|
|
|
cin.ignore();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
//The callback manager is required.
|
2019-09-12 07:55:52 +08:00
|
|
|
/*if ( !FileExists("CallbackManager.dll") ){
|
2019-09-11 07:28:59 +08:00
|
|
|
printf("Callback manager not found.\n");
|
|
|
|
Sleep(1000);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
modDLLs.push_back( std::string("CallbackManager.dll") );
|
2019-09-12 07:55:52 +08:00
|
|
|
*/
|
2019-09-11 07:28:59 +08:00
|
|
|
|
|
|
|
Process process("Cube.exe");
|
|
|
|
|
|
|
|
//Create game in suspended state
|
|
|
|
printf("Starting Cube.exe...\n\n");
|
|
|
|
if (!process.Create())
|
|
|
|
{
|
|
|
|
printf("Failed to create process: %lu", GetLastError());
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
printf("Cube.exe was successfully started.\n\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
//Find mods
|
|
|
|
HANDLE hFind;
|
|
|
|
WIN32_FIND_DATA data;
|
|
|
|
|
|
|
|
CreateDirectory("Mods", NULL);
|
|
|
|
hFind = FindFirstFile("Mods\\*.dll", &data);
|
|
|
|
if (hFind != INVALID_HANDLE_VALUE) {
|
|
|
|
do {
|
|
|
|
modDLLs.push_back( std::string("Mods\\") + data.cFileName);
|
|
|
|
} while (FindNextFile(hFind, &data));
|
|
|
|
FindClose(hFind);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//Inject DLLs
|
|
|
|
for (string S_DLLName : modDLLs){
|
|
|
|
printf("Loading %s\n", S_DLLName.c_str());
|
|
|
|
process.InjectDLL(S_DLLName);
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("\nAll available mods have been loaded.\n");
|
|
|
|
Sleep(1500);
|
2019-09-12 09:45:36 +08:00
|
|
|
process.Run();
|
|
|
|
Sleep(3000);
|
2019-09-11 07:28:59 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|