-
Notifications
You must be signed in to change notification settings - Fork 3
/
patch_base_domain.go
71 lines (59 loc) · 1.62 KB
/
patch_base_domain.go
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
66
67
68
69
70
71
package main
import (
"strings"
. "github.com/wii-tools/powerpc"
)
const (
NintendoBaseDomain = "shop.wii.com"
ShowManualURL = "https://oss-auth.shop.wii.com/startup?initpage=showManual&titleId="
GetLogURL = "https://oss-auth.shop.wii.com/oss/getLog"
TrustedDomain = ".shop.wii.com"
ECommerceBaseURL = "https://ecs.shop.wii.com/ecs/services/ECommerceSOAP"
)
// PatchBaseDomain replaces all Nintendo domains to be the user's
// specified base domain.
// See docs/patch_base_domain.md for more information.
func PatchBaseDomain() PatchSet {
return PatchSet{
Name: "Change Base Domain",
Patches: []Patch{
{
Name: "Modify /startup domain",
Before: []byte(ShowManualURL),
After: padReplace(ShowManualURL),
},
{
Name: "Modify oss-auth URL",
AtOffset: 3180692,
Before: []byte(GetLogURL),
After: padReplace(GetLogURL),
},
{
Name: "Modify trusted base domain prefix",
AtOffset: 3323432,
Before: []byte(TrustedDomain),
After: padReplace(TrustedDomain),
},
{
Name: "Modify ECS SOAP endpoint URL",
AtOffset: 3268896,
Before: []byte(ECommerceBaseURL),
After: padReplace(ECommerceBaseURL),
},
{
Name: "Wildcard replace other instances",
Before: []byte(NintendoBaseDomain),
After: padReplace(baseDomain),
},
},
}
}
func padReplace(url string) []byte {
replaced := strings.ReplaceAll(url, NintendoBaseDomain, baseDomain)
// See if we truly need to pad.
if len(url) == len(replaced) {
return []byte(replaced)
}
padding := len(url) - len(replaced)
return append([]byte(replaced), EmptyBytes(padding)...)
}