1
0
mirror of synced 2025-01-20 01:32:51 +01:00

Fix APM3 test menu saves in some games

Fix APM3 test menu saves in some games
This commit is contained in:
Nico Giansanti 2021-09-03 01:44:44 +03:00
parent 5a0c8ce903
commit a2f9e9bac1
2 changed files with 13 additions and 11 deletions

View File

@ -6,9 +6,11 @@
//#define _LOGAPM3BACKUP 1
char* BackupSaveFileName = "save";
char fileBuffer[256];
BackupRecord* internal_Records;
unsigned int internal_recordCount;
// Prefill some memory for save pointers, only 2-3 are used typically. Can be made dynamic, but this is for testing and seeing live data rn.
static auto backups = new BackupRecord[64];
BackupRecordStatus CALLPLEB Backup_getRecordStatus(DWORD_PTR recordIndex)
{
#ifdef _LOGAPM3BACKUP
@ -35,7 +37,7 @@ bool CALLPLEB Backup_saveRecord(unsigned long recordIndex)
auto file = fopen(fileBuffer, "wb+");
if (file)
{
fwrite(internal_Records[recordIndex].Address, 1, internal_Records[recordIndex].Size, file);
fwrite(backups[recordIndex].Address, 1, backups[recordIndex].Size, file);
fclose(file);
}
return Backup_saveRecordReturnValue;
@ -49,19 +51,22 @@ DWORD_PTR CALLPLEB Backup_saveRecordByAddress(DWORD_PTR recordAddress)
return Backup_saveRecordByAddressReturnValue;
}
//__int64 __fastcall Backup_setupRecords(__int128* a1, unsigned int a2)
bool CALLPLEB Backup_setupRecords(BackupRecord* records, unsigned int recordCount)
{
for (int i = 0; i < recordCount; i++)
{
backups[i].Address = records[i].Address;
backups[i].Size = records[i].Size;
}
internal_recordCount = 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 _LOGAPM3BACKUP

View File

@ -9,13 +9,10 @@ extern char fileBuffer[256];
struct BackupRecord
{
void* Address;
void *Address;
unsigned long Size;
};
extern BackupRecord* internal_Records;
extern unsigned int internal_recordCount;
enum class BackupRecordStatus
{
BackupRecordStatus_InvalidCall = -1, // 0xFFFFFFFF