-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdwc_auth_interface.cpp
65 lines (52 loc) · 1.78 KB
/
dwc_auth_interface.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <common/Common.hpp>
#include <dwc/dwc_report.h>
#include <platform/string.h>
#include <revolution/sc.h>
#include <revolutionex/nhttp/NHTTP.h>
#include <wiimmfi/Auth.hpp>
#include <wiimmfi/Challenge.hpp>
#include <DolphinDevice.hpp>
////////////////////////////
// Wiimmfi Authentication //
////////////////////////////
// DWCi_Auth_SendRequest() patch
// Insert custom authentication parameters
// Credits: Wiimmfi
kmCallDefCpp(0x800EDEE8, void, NHTTPReq* req, const char* key, const char* val) {
// Original call
NHTTPAddPostDataAscii(req, key, val);
// Send the required extra data
Wiimmfi::Auth::AppendAuthParameters(req);
}
// DWCi_Auth_SendRequest() patch
// Report the product code from the imported NAND on Dolphin
// Credits: Wiimmfi
kmCallDefCpp(0x800EE098, const char*) {
// Check if we're on Dolphin and use the dedicated IOCTL if so
if (DolphinDevice::Open()) {
const char* prodCode = DolphinDevice::GetRealProductCode();
return (prodCode != nullptr) ? prodCode : SCGetProductCode();
}
// Else just call the original function
return SCGetProductCode();
}
// DWCi_Auth_HandleResponse() patch
// Parse the custom response data
// Credits: Wiimmfi
kmCallDefCpp(0x800EEA08, void, DWCReportFlag level, const char* fmt, const char* arg) {
// Original call
DWC_Printf(level, fmt, arg);
// Parse the extra response data
Wiimmfi::Auth::ParseAuthResponse(arg);
}
/////////////////////////////
// Wiimmfi Challenge Check //
/////////////////////////////
// DWCi_Auth_HandleResponse() patch
// Save the login challenge
// Credits: Wiimmfi
kmCallDefCpp(0x800EE74C, void, char* dest, const char* src) {
// Save the challenge both to the stack and the Wiimmfi buffers
strcpy(dest, src);
Wiimmfi::Challenge::Save(src);
}