Skip to content

Commit

Permalink
Allow for non-Base64 encoded data to be reported to the server
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeIsAStar authored and MikeIsAStar committed Jan 24, 2024
1 parent 3d316fb commit 00ea318
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 19 deletions.
40 changes: 25 additions & 15 deletions payload/wwfcGPReport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace wwfc::GPReport

#if RMC

void ReportUser(mkw::Net::UserHandler::Packet* packet)
void Report(const char* key, const char* string)
{
auto connection = DWC::stpMatchCnt->connection;
if (connection == nullptr) {
Expand All @@ -17,30 +17,40 @@ void ReportUser(mkw::Net::UserHandler::Packet* packet)

auto iconnection = reinterpret_cast<GameSpy::GPIConnection*>(*connection);

char b64UserPacket[0x400];
s32 b64Len = DWC::DWC_Base64Encode(
packet, sizeof(mkw::Net::UserHandler::Packet), b64UserPacket,
sizeof(b64UserPacket)
GameSpy::gpiAppendStringToBuffer(
connection, &iconnection->outputBuffer, "\\wwfc_report\\\\"
);
GameSpy::gpiAppendStringToBuffer(
connection, &iconnection->outputBuffer, key
);
if (b64Len < 0 || b64Len >= 0x400) {
LOG_ERROR("Could not base64 encode the User packet");
return;
}

// Add null terminator
b64UserPacket[b64Len] = '\0';

GameSpy::gpiAppendStringToBuffer(
connection, &iconnection->outputBuffer, "\\wwfc_report\\\\mkw_user\\"
connection, &iconnection->outputBuffer, "\\"
);
GameSpy::gpiAppendStringToBuffer(
connection, &iconnection->outputBuffer, b64UserPacket
connection, &iconnection->outputBuffer, string
);
GameSpy::gpiAppendStringToBuffer(
connection, &iconnection->outputBuffer, "\\final\\"
);
}

void ReportB64Encode(const char* key, const void* data, size_t dataSize)
{
char b64Data[0x400];

s32 b64Size =
DWC::DWC_Base64Encode(data, dataSize, b64Data, sizeof(b64Data));
if (b64Size == -1 || b64Size == sizeof(b64Data)) {
LOG_ERROR(
"Could not fit the base64-encoded data into the provided buffer!"
);
return;
}
b64Data[b64Size] = '\0';

Report(key, b64Data);
}

#endif

} // namespace wwfc::GPReport
3 changes: 2 additions & 1 deletion payload/wwfcGPReport.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ namespace wwfc::GPReport

#if RMC

void ReportUser(mkw::Net::UserHandler::Packet* packet);
void Report(const char* key, const char* string);
void ReportB64Encode(const char* key, const void* data, size_t dataSize);

#endif

Expand Down
5 changes: 3 additions & 2 deletions payload/wwfcLogin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,9 @@ static void SendAuthTokenSignature(
s32 b64Len = DWC::DWC_Base64Encode(
&authSig, sizeof(authSig), b64AuthSig, sizeof(b64AuthSig)
);
if (b64Len < 0 || b64Len >= 0x400) {
LOG_ERROR("Could not base64 encode the signature");
if (b64Len == -1 || b64Len == sizeof(b64AuthSig)) {
LOG_ERROR("Could not fit the base64-encoded signature into the "
"provided buffer!");
return;
}

Expand Down
4 changes: 3 additions & 1 deletion payload/wwfcMii.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ void ClearUserMiiInfo(mkw::Net::UserHandler::Packet* packet)
}

// Send Mii data to the server
wwfc::GPReport::ReportUser(packet);
wwfc::GPReport::ReportB64Encode(
"mkw_user", packet, sizeof(mkw::Net::UserHandler::Packet)
);
}

#endif
Expand Down

0 comments on commit 00ea318

Please sign in to comment.