APM3 Separate Backup from APM3.h
APM3 Separate Backup from APM3.h
This commit is contained in:
parent
33a1472137
commit
e39158d7ef
@ -5,6 +5,7 @@
|
||||
#include "Functions\Global.h"
|
||||
#include "APM3.h"
|
||||
#include "Aime.h"
|
||||
#include "Backup.h"
|
||||
|
||||
static uint8_t g_APM3IOValues[256];
|
||||
|
||||
@ -191,103 +192,6 @@ char __fastcall ApmSystemSetting_getUiSetting(__int64 a1)
|
||||
return ApmSystemSetting_getUiSettingReturnValue;
|
||||
}
|
||||
|
||||
char* SaveFileName = "save";
|
||||
char fileBuffer[256];
|
||||
|
||||
struct BackupRecord
|
||||
{
|
||||
void* Address;
|
||||
unsigned long Size;
|
||||
};
|
||||
|
||||
BackupRecord *internal_Records;
|
||||
unsigned int internal_recordCount;
|
||||
|
||||
enum class BackupRecordStatus
|
||||
{
|
||||
BackupRecordStatus_InvalidCall = -1, // 0xFFFFFFFF
|
||||
BackupRecordStatus_Valid = 0,
|
||||
BackupRecordStatus_DiffApp = 1,
|
||||
BackupRecordStatus_BrokenData = 2,
|
||||
};
|
||||
|
||||
BackupRecordStatus __fastcall Backup_getRecordStatus(__int64 recordIndex)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
info(true, "Backup_getRecordStatus %llx", recordIndex);
|
||||
#endif
|
||||
return BackupRecordStatus::BackupRecordStatus_Valid;
|
||||
}
|
||||
|
||||
bool Backup_isSetupSucceeded()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
info(true, "Backup_isSetupSucceeded");
|
||||
#endif
|
||||
return Backup_isSetupSucceededReturnValue;
|
||||
}
|
||||
|
||||
bool __fastcall Backup_saveRecord(unsigned long recordIndex)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
info(true, "Backup_saveRecord recordIndex: %llx", recordIndex);
|
||||
#endif
|
||||
memset(fileBuffer, 0, sizeof(fileBuffer));
|
||||
sprintf(fileBuffer, "%s%02d.bin", SaveFileName, recordIndex);
|
||||
auto file = fopen(fileBuffer, "wb+");
|
||||
if (file)
|
||||
{
|
||||
fwrite(internal_Records[recordIndex].Address, 1, internal_Records[recordIndex].Size, file);
|
||||
fclose(file);
|
||||
}
|
||||
return Backup_saveRecordReturnValue;
|
||||
}
|
||||
|
||||
__int64 __fastcall Backup_saveRecordByAddress(__int64 recordAddress)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
info(true, "Backup_saveRecordByAddress %llx", recordAddress);
|
||||
#endif
|
||||
return Backup_saveRecordByAddressReturnValue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//__int64 __fastcall Backup_setupRecords(__int128* a1, unsigned int a2)
|
||||
bool __fastcall Backup_setupRecords(BackupRecord *records, unsigned int recordCount)
|
||||
{
|
||||
for (int i = 0; i < recordCount; i++)
|
||||
{
|
||||
memset(fileBuffer, 0, sizeof(fileBuffer));
|
||||
sprintf(fileBuffer, "%s%02d.bin", SaveFileName, i);
|
||||
FILE* fsave = fopen(fileBuffer, "r");
|
||||
internal_Records = records;
|
||||
internal_recordCount = recordCount;
|
||||
if (fsave != NULL)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
info(true, "Backup setuprecords %02d of %02d, loading file %s", i, recordCount, fileBuffer);
|
||||
#endif
|
||||
fread(records[i].Address, 1, records[i].Size, fsave); // add file size check noob
|
||||
fclose(fsave);
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
info(true, "Backup setuprecords %02d of %02d, saving file %s", i, recordCount, fileBuffer);
|
||||
#endif
|
||||
auto file = fopen(fileBuffer, "wb+");
|
||||
if (file)
|
||||
{
|
||||
fwrite(records[i].Address, 1, records[i].Size, file);
|
||||
fclose(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void Core_execute()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
@ -1081,7 +985,7 @@ static InitFunction initVF5Func([]()
|
||||
strcpy(APM3GameId, "SDHF");
|
||||
__int64 mainModuleBase = (__int64)GetModuleHandle(0);
|
||||
|
||||
SaveFileName = ".\\vf5fs\\save";
|
||||
BackupSaveFileName = ".\\vf5fs\\save";
|
||||
|
||||
}, GameID::VF5Esports);
|
||||
|
||||
|
@ -42,14 +42,6 @@ static char ApmSystemSetting_getTimeToClosingTimeReturnValue = 0;
|
||||
|
||||
static char ApmSystemSetting_getUiSettingReturnValue = 0;
|
||||
|
||||
static bool Backup_isSetupSucceededReturnValue = true;
|
||||
|
||||
static __int64 Backup_saveRecordReturnValue = 0;
|
||||
|
||||
static __int64 Backup_saveRecordByAddressReturnValue = 0;
|
||||
|
||||
static __int64 Backup_setupRecordsReturnValue = 0;
|
||||
|
||||
static bool Core_exitGameReturnValue = 0;
|
||||
|
||||
static __int64 Core_hookExceptionReturnValue = 0;
|
||||
|
89
OpenParrot/src/Functions/Games/APM3/Backup.cpp
Normal file
89
OpenParrot/src/Functions/Games/APM3/Backup.cpp
Normal file
@ -0,0 +1,89 @@
|
||||
#include <Utility/InitFunction.h>
|
||||
#include <StdInc.h>
|
||||
#include <thread>
|
||||
#ifdef _M_AMD64
|
||||
#include "Functions\Global.h"
|
||||
#include "Backup.h"
|
||||
|
||||
char* BackupSaveFileName = "save";
|
||||
char fileBuffer[256];
|
||||
BackupRecord* internal_Records;
|
||||
unsigned int internal_recordCount;
|
||||
|
||||
BackupRecordStatus __fastcall Backup_getRecordStatus(__int64 recordIndex)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
info(true, "Backup_getRecordStatus %llx", recordIndex);
|
||||
#endif
|
||||
return BackupRecordStatus::BackupRecordStatus_Valid;
|
||||
}
|
||||
|
||||
bool Backup_isSetupSucceeded()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
info(true, "Backup_isSetupSucceeded");
|
||||
#endif
|
||||
return Backup_isSetupSucceededReturnValue;
|
||||
}
|
||||
|
||||
bool __fastcall Backup_saveRecord(unsigned long recordIndex)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
info(true, "Backup_saveRecord recordIndex: %llx", recordIndex);
|
||||
#endif
|
||||
memset(fileBuffer, 0, sizeof(fileBuffer));
|
||||
sprintf(fileBuffer, "%s%02d.bin", BackupSaveFileName, recordIndex);
|
||||
auto file = fopen(fileBuffer, "wb+");
|
||||
if (file)
|
||||
{
|
||||
fwrite(internal_Records[recordIndex].Address, 1, internal_Records[recordIndex].Size, file);
|
||||
fclose(file);
|
||||
}
|
||||
return Backup_saveRecordReturnValue;
|
||||
}
|
||||
|
||||
__int64 __fastcall Backup_saveRecordByAddress(__int64 recordAddress)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
info(true, "Backup_saveRecordByAddress %llx", recordAddress);
|
||||
#endif
|
||||
return Backup_saveRecordByAddressReturnValue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//__int64 __fastcall Backup_setupRecords(__int128* a1, unsigned int a2)
|
||||
bool __fastcall Backup_setupRecords(BackupRecord* records, unsigned int recordCount)
|
||||
{
|
||||
for (int i = 0; i < recordCount; i++)
|
||||
{
|
||||
memset(fileBuffer, 0, sizeof(fileBuffer));
|
||||
sprintf(fileBuffer, "%s%02d.bin", BackupSaveFileName, i);
|
||||
FILE* fsave = fopen(fileBuffer, "r");
|
||||
internal_Records = records;
|
||||
internal_recordCount = recordCount;
|
||||
if (fsave != NULL)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
info(true, "Backup setuprecords %02d of %02d, loading file %s", i, recordCount, fileBuffer);
|
||||
#endif
|
||||
fread(records[i].Address, 1, records[i].Size, fsave); // add file size check noob
|
||||
fclose(fsave);
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
info(true, "Backup setuprecords %02d of %02d, saving file %s", i, recordCount, fileBuffer);
|
||||
#endif
|
||||
auto file = fopen(fileBuffer, "wb+");
|
||||
if (file)
|
||||
{
|
||||
fwrite(records[i].Address, 1, records[i].Size, file);
|
||||
fclose(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endif
|
37
OpenParrot/src/Functions/Games/APM3/Backup.h
Normal file
37
OpenParrot/src/Functions/Games/APM3/Backup.h
Normal file
@ -0,0 +1,37 @@
|
||||
#ifdef _M_AMD64
|
||||
#pragma once
|
||||
extern char* BackupSaveFileName;
|
||||
extern char fileBuffer[256];
|
||||
|
||||
struct BackupRecord
|
||||
{
|
||||
void* Address;
|
||||
unsigned long Size;
|
||||
};
|
||||
|
||||
extern BackupRecord* internal_Records;
|
||||
extern unsigned int internal_recordCount;
|
||||
|
||||
enum class BackupRecordStatus
|
||||
{
|
||||
BackupRecordStatus_InvalidCall = -1, // 0xFFFFFFFF
|
||||
BackupRecordStatus_Valid = 0,
|
||||
BackupRecordStatus_DiffApp = 1,
|
||||
BackupRecordStatus_BrokenData = 2,
|
||||
};
|
||||
|
||||
static bool Backup_isSetupSucceededReturnValue = true;
|
||||
|
||||
static __int64 Backup_saveRecordReturnValue = 0;
|
||||
|
||||
static __int64 Backup_saveRecordByAddressReturnValue = 0;
|
||||
|
||||
static __int64 Backup_setupRecordsReturnValue = 0;
|
||||
|
||||
BackupRecordStatus __fastcall Backup_getRecordStatus(__int64 recordIndex);
|
||||
bool Backup_isSetupSucceeded();
|
||||
bool __fastcall Backup_saveRecord(unsigned long recordIndex);
|
||||
__int64 __fastcall Backup_saveRecordByAddress(__int64 recordAddress);
|
||||
bool __fastcall Backup_setupRecords(BackupRecord* records, unsigned int recordCount);
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user