Skip to content

Commit afdda78

Browse files
committed
calling a lower-down-the stack mcc function for forcing refresh, fixes crash with overly-stringent filters
1 parent bf475be commit afdda78

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

mcc-cgb-dumper/CustomGameRefresher.h

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,27 @@ class CustomGameRefresher
3535
}
3636

3737

38-
const multilevel_pointer mlp_OrigCallRefreshFunction{ { 0xA92EA8 } }; // Pointer to OrigCallRefresh
38+
//const multilevel_pointer mlp_OrigCallRefreshFunction{ { 0xA92EA8 } }; // Pointer to OrigCallRefresh
39+
const multilevel_pointer mlp_OrigCallRefreshFunction{ { 0xA785A4 } }; // Pointer to OrigCallRefresh
3940
//const multilevel_pointer mlp_OrigCallRefreshParameter{ { 0x03B227C8, 0x90, 0xB0 } }; // Parameter that needs to be passed to OrigCallRefresh
40-
const multilevel_pointer mlp_OrigCallRefreshParameter{ { 0x0401C130, 0x18, 0x830, 0x820 } }; // Parameter that needs to be passed to OrigCallRefresh
41+
//const multilevel_pointer mlp_OrigCallRefreshParameter{ { 0x0401C130, 0x18, 0x830, 0x820 } }; // Parameter that needs to be passed to OrigCallRefresh
42+
const multilevel_pointer mlp_OrigCallRefreshParameter{ { 0x03D0B6A0, 0x28, 0xE90, 0x0 } }; // Parameter that needs to be passed to OrigCallRefresh
4143
MCC_CallRefreshFunction mOrigCallRefreshFunction; // We'll resolve this in constructor
42-
uint64_t* mpCallRefreshFunctionParameter = nullptr;
4344

4445
public:
4546
void forceRefresh() const // Calls the games CallRefreshFunction
4647
{
47-
if (IsBadReadPtr(mpCallRefreshFunctionParameter, sizeof(uint64_t)))
48+
void* parameter;
49+
if (!mlp_OrigCallRefreshParameter.resolve(&parameter))
4850
{
4951
PLOG_ERROR << "forceRefresh failed, couldn't read parameter";
5052
return;
5153
}
5254

53-
PLOG_VERBOSE << "Performing CallRefreshFunction: parameter: " << std::hex << *mpCallRefreshFunctionParameter;
54-
mOrigCallRefreshFunction(*mpCallRefreshFunctionParameter);
55+
56+
57+
PLOG_VERBOSE << "Performing CallRefreshFunction: parameter: " << std::hex << parameter;
58+
mOrigCallRefreshFunction((uint64_t)parameter);
5559
PLOG_VERBOSE << "CallRefreshFunction didn't crash!";
5660

5761
}
@@ -68,12 +72,6 @@ class CustomGameRefresher
6872
}
6973
mOrigCallRefreshFunction = (MCC_CallRefreshFunction)pCallRefresh;
7074

71-
void* pCallFunctionParameter; // We'll resolve the pointer but won't read off the value of the parameter until forceRefresh, since it isn't correct until you go to the CGB screen
72-
if (!mlp_OrigCallRefreshParameter.resolve(&pCallFunctionParameter))
73-
{
74-
throw std::runtime_error(std::format("Couldn't resolve pointer to refresh function parameter : {}", multilevel_pointer::GetLastError()));
75-
}
76-
mpCallRefreshFunctionParameter = (uint64_t*)pCallFunctionParameter;
7775

7876
mAutoRefreshThread = std::thread([this] { this->autoRefreshThreadTask(); }); // Thread is born when this class is constructed, only AFTER possible throws
7977

mcc-cgb-dumper/dumper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ void AutoDumper::dump()
205205
{
206206
// This is what ends the do-while loop; we iterate through all the valid CustomGames,
207207
// and stop once we reach an invalid one (luckily all the valid ones are grouped together at the start of the array)
208-
PLOG_DEBUG << "Found end of CustomGameInfoArray struct, total custom games: " << (CustomGameInfo_ElementIndex + 1) << ", validFlag value: " << validFlag;
208+
PLOG_DEBUG << "Found end of CustomGameInfoArray struct, total custom games: " << (CustomGameInfo_ElementIndex - 1) << ", validFlag value: " << validFlag;
209209

210210
break;
211211
}

0 commit comments

Comments
 (0)