diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/ChallengeRandomizer.cpp | 37 | ||||
-rw-r--r-- | Source/ChallengeRandomizer.h | 2 |
2 files changed, 20 insertions, 19 deletions
diff --git a/Source/ChallengeRandomizer.cpp b/Source/ChallengeRandomizer.cpp index 1ecfdd3..fa9a234 100644 --- a/Source/ChallengeRandomizer.cpp +++ b/Source/ChallengeRandomizer.cpp | |||
@@ -20,11 +20,13 @@ ChallengeRandomizer::ChallengeRandomizer(const std::shared_ptr<Memory>& memory, | |||
20 | 20 | ||
21 | // do_success_side_effects | 21 | // do_success_side_effects |
22 | _memory->AddSigScan({0xFF, 0xC8, 0x99, 0x2B, 0xC2, 0xD1, 0xF8, 0x8B, 0xD0}, [&](int index) { | 22 | _memory->AddSigScan({0xFF, 0xC8, 0x99, 0x2B, 0xC2, 0xD1, 0xF8, 0x8B, 0xD0}, [&](int index) { |
23 | if (GLOBALS == 0x5B28C0) { // Version differences | 23 | if (GLOBALS == 0x5B28C0) { // Version differences. |
24 | index += 0x3E; | 24 | index += 0x3E; |
25 | } else if (GLOBALS == 0x62A080) { | 25 | } else if (GLOBALS == 0x62D0A0) { |
26 | index += 0x42; | 26 | index += 0x42; |
27 | } | 27 | } |
28 | // Overwritten bytes start just after the movsxd rax, dword ptr ds:[rdi + 0x230] | ||
29 | // aka test eax, eax; jle 2C; imul rcx, rax, 34 | ||
28 | _memory->WriteData<byte>({index}, { | 30 | _memory->WriteData<byte>({index}, { |
29 | 0x8B, 0x0D, 0x00, 0x00, 0x00, 0x00, // mov ecx, [0x00000000] ;This is going to be the address of the custom RNG | 31 | 0x8B, 0x0D, 0x00, 0x00, 0x00, 0x00, // mov ecx, [0x00000000] ;This is going to be the address of the custom RNG |
30 | 0x67, 0xC7, 0x01, 0x00, 0x00, 0x00, 0x00, // mov dword ptr ds:[ecx], 0x00000000 ;This is going to be the seed value | 32 | 0x67, 0xC7, 0x01, 0x00, 0x00, 0x00, 0x00, // mov dword ptr ds:[ecx], 0x00000000 ;This is going to be the seed value |
@@ -33,25 +35,26 @@ ChallengeRandomizer::ChallengeRandomizer(const std::shared_ptr<Memory>& memory, | |||
33 | }); | 35 | }); |
34 | int target = (GLOBALS + 0x30) - (index + 0x6); // +6 is for the length of the line | 36 | int target = (GLOBALS + 0x30) - (index + 0x6); // +6 is for the length of the line |
35 | _memory->WriteData<int>({index + 0x2}, {target}); | 37 | _memory->WriteData<int>({index + 0x2}, {target}); |
36 | _memory->WriteData<int>({index + 0x9}, {seed}); | 38 | _memory->WriteData<int>({index + 0x9}, {seed}); // Because we're resetting seed every challenge, we need to run this injection every time. |
37 | }); | 39 | }); |
38 | 40 | ||
39 | // reveal_exit_hall | 41 | if (!alreadyInjected) { |
40 | _memory->AddSigScan({0x45, 0x8B, 0xF7, 0x48, 0x8B, 0x4D}, [&](int index){ | 42 | // reveal_exit_hall |
41 | _memory->WriteData<byte>({index + 0x15}, {0xEB}); | 43 | _memory->AddSigScan({0x45, 0x8B, 0xF7, 0x48, 0x8B, 0x4D}, [&](int index){ |
42 | }); | 44 | _memory->WriteData<byte>({index + 0x15}, {0xEB}); |
45 | }); | ||
43 | 46 | ||
44 | // begin_endgame_1 | 47 | // begin_endgame_1 |
45 | _memory->AddSigScan({0x83, 0x7C, 0x01, 0xD0, 0x04}, [&](int index){ | 48 | _memory->AddSigScan({0x83, 0x7C, 0x01, 0xD0, 0x04}, [&](int index){ |
46 | if (GLOBALS == 0x5B28C0) { // Version differences | 49 | if (GLOBALS == 0x5B28C0) { // Version differences. |
47 | index += 0x75; | 50 | index += 0x75; |
48 | } else if (GLOBALS == 0x62A080) { | 51 | } else if (GLOBALS == 0x62D0A0) { |
49 | index += 0x86; | 52 | index += 0x86; |
50 | } | 53 | } |
51 | _memory->WriteData<byte>({index}, {0xEB}); | 54 | // Overwriting a 74 12 opcode |
52 | }); | 55 | _memory->WriteData<byte>({index}, {0xEB}); |
56 | }); | ||
53 | 57 | ||
54 | if (!alreadyInjected) { | ||
55 | // shuffle_integers | 58 | // shuffle_integers |
56 | _memory->AddSigScan({0x48, 0x89, 0x5C, 0x24, 0x10, 0x56, 0x48, 0x83, 0xEC, 0x20, 0x48, 0x63, 0xDA, 0x48, 0x8B, 0xF1, 0x83, 0xFB, 0x01}, [&](int index) { | 59 | _memory->AddSigScan({0x48, 0x89, 0x5C, 0x24, 0x10, 0x56, 0x48, 0x83, 0xEC, 0x20, 0x48, 0x63, 0xDA, 0x48, 0x8B, 0xF1, 0x83, 0xFB, 0x01}, [&](int index) { |
57 | AdjustRng(index + 0x23); | 60 | AdjustRng(index + 0x23); |
diff --git a/Source/ChallengeRandomizer.h b/Source/ChallengeRandomizer.h index 0a43b4a..10944cd 100644 --- a/Source/ChallengeRandomizer.h +++ b/Source/ChallengeRandomizer.h | |||
@@ -7,8 +7,6 @@ public: | |||
7 | ChallengeRandomizer(const std::shared_ptr<Memory>& memory, int seed); | 7 | ChallengeRandomizer(const std::shared_ptr<Memory>& memory, int seed); |
8 | 8 | ||
9 | private: | 9 | private: |
10 | void HandleSigScans(); | ||
11 | |||
12 | void AdjustRng(int offset); | 10 | void AdjustRng(int offset); |
13 | std::shared_ptr<Memory> _memory; | 11 | std::shared_ptr<Memory> _memory; |
14 | 12 | ||