about summary refs log tree commit diff stats
path: root/Source
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2021-09-24 18:54:22 -0400
committerStar Rauchenberger <fefferburbia@gmail.com>2021-09-24 18:54:22 -0400
commitbad7b20434cebca369c6bf71fdbae9ed5a157119 (patch)
tree54adb230d60ee38ecfa4ef4b447c4ec366f291dc /Source
parent92461067047993a828b43afe4eb79208aaae4862 (diff)
downloadwitness-tutorializer-bad7b20434cebca369c6bf71fdbae9ed5a157119.tar.gz
witness-tutorializer-bad7b20434cebca369c6bf71fdbae9ed5a157119.tar.bz2
witness-tutorializer-bad7b20434cebca369c6bf71fdbae9ed5a157119.zip
Reverted the Sigma backport memory stuff
Diffstat (limited to 'Source')
-rw-r--r--Source/Memory.cpp168
-rw-r--r--Source/Memory.h5
-rw-r--r--Source/PuzzleSerializer.cpp1
-rw-r--r--Source/Randomizer.cpp4
-rw-r--r--Source/Randomizer.h68
5 files changed, 162 insertions, 84 deletions
diff --git a/Source/Memory.cpp b/Source/Memory.cpp index 8e755dd..8802add 100644 --- a/Source/Memory.cpp +++ b/Source/Memory.cpp
@@ -6,7 +6,7 @@
6#undef PROCESSENTRY32 6#undef PROCESSENTRY32
7#undef Process32Next 7#undef Process32Next
8 8
9Memory::Memory(const std::wstring& processName) : _processName(processName) { Initialize(); } 9Memory::Memory(const std::wstring& processName) : _processName(processName) {}
10 10
11Memory::~Memory() { 11Memory::~Memory() {
12 if (_threadActive) { 12 if (_threadActive) {
@@ -33,7 +33,7 @@ void Memory::StartHeartbeat(HWND window, WPARAM wParam, std::chrono::millisecond
33} 33}
34 34
35void Memory::Heartbeat(HWND window, WPARAM wParam) { 35void Memory::Heartbeat(HWND window, WPARAM wParam) {
36 if (!_handle) { 36 if (!_handle && !Initialize()) {
37 // Couldn't initialize, definitely not running 37 // Couldn't initialize, definitely not running
38 PostMessage(window, WM_COMMAND, wParam, (LPARAM)ProcStatus::NotRunning); 38 PostMessage(window, WM_COMMAND, wParam, (LPARAM)ProcStatus::NotRunning);
39 return; 39 return;
@@ -110,8 +110,7 @@ bool Memory::Initialize() {
110 return false; 110 return false;
111 } 111 }
112 112
113 ExecuteSigScans(); 113 LoadPanelOffsets();
114
115 return true; 114 return true;
116} 115}
117 116
@@ -188,9 +187,158 @@ void* Memory::ComputeOffset(std::vector<int> offsets) {
188 return reinterpret_cast<void*>(cumulativeAddress + final_offset); 187 return reinterpret_cast<void*>(cumulativeAddress + final_offset);
189} 188}
190 189
191int Memory::GLOBALS = 0; 190int GLOBALS, POSITION, ORIENTATION, PATH_COLOR, REFLECTION_PATH_COLOR, DOT_COLOR, ACTIVE_COLOR, BACKGROUND_REGION_COLOR, SUCCESS_COLOR_A, SUCCESS_COLOR_B, STROBE_COLOR_A, STROBE_COLOR_B, ERROR_COLOR, PATTERN_POINT_COLOR, PATTERN_POINT_COLOR_A, PATTERN_POINT_COLOR_B, SYMBOL_A, SYMBOL_B, SYMBOL_C, SYMBOL_D, SYMBOL_E, PUSH_SYMBOL_COLORS, OUTER_BACKGROUND, OUTER_BACKGROUND_MODE, TRACED_EDGES, AUDIO_PREFIX, POWER, TARGET, POWER_OFF_ON_FAIL, IS_CYLINDER, CYLINDER_Z0, CYLINDER_Z1, CYLINDER_RADIUS, CURSOR_SPEED_SCALE, NEEDS_REDRAW, SPECULAR_ADD, SPECULAR_POWER, PATH_WIDTH_SCALE, STARTPOINT_SCALE, NUM_DOTS, NUM_CONNECTIONS, MAX_BROADCAST_DISTANCE, DOT_POSITIONS, DOT_FLAGS, DOT_CONNECTION_A, DOT_CONNECTION_B, DECORATIONS, DECORATION_FLAGS, DECORATION_COLORS, NUM_DECORATIONS, REFLECTION_DATA, GRID_SIZE_X, GRID_SIZE_Y, STYLE_FLAGS, SEQUENCE_LEN, SEQUENCE, DOT_SEQUENCE_LEN, DOT_SEQUENCE, DOT_SEQUENCE_LEN_REFLECTION, DOT_SEQUENCE_REFLECTION, NUM_COLORED_REGIONS, COLORED_REGIONS, PANEL_TARGET, SPECULAR_TEXTURE, CABLE_TARGET_2, AUDIO_LOG_NAME, OPEN_RATE, METADATA, HOTEL_EP_NAME, RANDOMISE_ON_POWER_ON;
192int Memory::globalsTests[3] = { 191
193 0x62D0A0, //Steam and Epic Games 192void Memory::LoadPanelOffsets() {
194 0x62B0A0, //Good Old Games 193 AddSigScan({0x74, 0x41, 0x48, 0x85, 0xC0, 0x74, 0x04, 0x48, 0x8B, 0x48, 0x10}, [sharedThis = shared_from_this()](int index){
195 0x5B28C0 //Noclip version 194 // (address of next line) + (value at index)
196}; \ No newline at end of file 195 GLOBALS = index + 0x14 + 0x4 + sharedThis->ReadData<int>({index+0x14}, 1)[0];
196 });
197 ExecuteSigScans();
198
199 if (GLOBALS == 0x5B28C0) {
200 POSITION = 0x24;
201 ORIENTATION = 0x34;
202 PATH_COLOR = 0xC8;
203 REFLECTION_PATH_COLOR = 0xD8;
204 DOT_COLOR = 0xF8;
205 ACTIVE_COLOR = 0x108;
206 BACKGROUND_REGION_COLOR = 0x118;
207 SUCCESS_COLOR_A = 0x128;
208 SUCCESS_COLOR_B = 0x138;
209 STROBE_COLOR_A = 0x148;
210 STROBE_COLOR_B = 0x158;
211 ERROR_COLOR = 0x168;
212 PATTERN_POINT_COLOR = 0x188;
213 PATTERN_POINT_COLOR_A = 0x198;
214 PATTERN_POINT_COLOR_B = 0x1A8;
215 SYMBOL_A = 0x1B8;
216 SYMBOL_B = 0x1C8;
217 SYMBOL_C = 0x1D8;
218 SYMBOL_D = 0x1E8;
219 SYMBOL_E = 0x1F8;
220 PUSH_SYMBOL_COLORS = 0x208;
221 OUTER_BACKGROUND = 0x20C;
222 OUTER_BACKGROUND_MODE = 0x21C;
223 TRACED_EDGES = 0x230;
224 AUDIO_PREFIX = 0x278;
225 POWER = 0x2A8;
226 TARGET = 0x2BC;
227 POWER_OFF_ON_FAIL = 0x2C0;
228 IS_CYLINDER = 0x2FC;
229 CYLINDER_Z0 = 0x300;
230 CYLINDER_Z1 = 0x304;
231 CYLINDER_RADIUS = 0x308;
232 CURSOR_SPEED_SCALE = 0x358;
233 NEEDS_REDRAW = 0x384;
234 SPECULAR_ADD = 0x398;
235 SPECULAR_POWER = 0x39C;
236 PATH_WIDTH_SCALE = 0x3A4;
237 STARTPOINT_SCALE = 0x3A8;
238 NUM_DOTS = 0x3B8;
239 NUM_CONNECTIONS = 0x3BC;
240 MAX_BROADCAST_DISTANCE = 0x3C0;
241 DOT_POSITIONS = 0x3C8;
242 DOT_FLAGS = 0x3D0;
243 DOT_CONNECTION_A = 0x3D8;
244 DOT_CONNECTION_B = 0x3E0;
245 DECORATIONS = 0x420;
246 DECORATION_FLAGS = 0x428;
247 DECORATION_COLORS = 0x430;
248 NUM_DECORATIONS = 0x438;
249 REFLECTION_DATA = 0x440;
250 GRID_SIZE_X = 0x448;
251 GRID_SIZE_Y = 0x44C;
252 STYLE_FLAGS = 0x450;
253 SEQUENCE_LEN = 0x45C;
254 SEQUENCE = 0x460;
255 DOT_SEQUENCE_LEN = 0x468;
256 DOT_SEQUENCE = 0x470;
257 DOT_SEQUENCE_LEN_REFLECTION = 0x478;
258 DOT_SEQUENCE_REFLECTION = 0x480;
259 NUM_COLORED_REGIONS = 0x4A0;
260 COLORED_REGIONS = 0x4A8;
261 PANEL_TARGET = 0x4B0;
262 SPECULAR_TEXTURE = 0x4D8;
263 CABLE_TARGET_2 = 0xD8;
264 AUDIO_LOG_NAME = 0xC8;
265 OPEN_RATE = 0xE8;
266 METADATA = 0xF2; // sizeof(short)
267 HOTEL_EP_NAME = 0x4BC640;
268 } else if (GLOBALS == 0x62B0A0) {
269 // TODO:
270 } else if (GLOBALS == 0x62D0A0) {
271 POSITION = 0x24;
272 ORIENTATION = 0x34;
273 PATH_COLOR = 0xC0;
274 REFLECTION_PATH_COLOR = 0xD0;
275 DOT_COLOR = 0xF0;
276 ACTIVE_COLOR = 0x100;
277 BACKGROUND_REGION_COLOR = 0x110;
278 SUCCESS_COLOR_A = 0x120;
279 SUCCESS_COLOR_B = 0x130;
280 STROBE_COLOR_A = 0x140;
281 STROBE_COLOR_B = 0x150;
282 ERROR_COLOR = 0x160;
283 PATTERN_POINT_COLOR = 0x180;
284 PATTERN_POINT_COLOR_A = 0x190;
285 PATTERN_POINT_COLOR_B = 0x1A0;
286 SYMBOL_A = 0x1B0;
287 SYMBOL_B = 0x1C0;
288 SYMBOL_C = 0x1D0;
289 SYMBOL_D = 0x1E0;
290 SYMBOL_E = 0x1F0;
291 PUSH_SYMBOL_COLORS = 0x200;
292 OUTER_BACKGROUND = 0x204;
293 OUTER_BACKGROUND_MODE = 0x214;
294 TRACED_EDGES = 0x228;
295 AUDIO_PREFIX = 0x270;
296 POWER = 0x2A0;
297 TARGET = 0x2B4;
298 POWER_OFF_ON_FAIL = 0x2B8;
299 IS_CYLINDER = 0x2F4;
300 CYLINDER_Z0 = 0x2F8;
301 CYLINDER_Z1 = 0x2FC;
302 CYLINDER_RADIUS = 0x300;
303 CURSOR_SPEED_SCALE = 0x350;
304 NEEDS_REDRAW = 0x37C;
305 SPECULAR_ADD = 0x38C;
306 SPECULAR_POWER = 0x390;
307 PATH_WIDTH_SCALE = 0x39C;
308 STARTPOINT_SCALE = 0x3A0;
309 NUM_DOTS = 0x3B4;
310 NUM_CONNECTIONS = 0x3B8;
311 MAX_BROADCAST_DISTANCE = 0x3BC;
312 DOT_POSITIONS = 0x3C0;
313 DOT_FLAGS = 0x3C8;
314 DOT_CONNECTION_A = 0x3D0;
315 DOT_CONNECTION_B = 0x3D8;
316 RANDOMISE_ON_POWER_ON = 0x3E0;
317 DECORATIONS = 0x418;
318 DECORATION_FLAGS = 0x420;
319 DECORATION_COLORS = 0x428;
320 NUM_DECORATIONS = 0x430;
321 REFLECTION_DATA = 0x438;
322 GRID_SIZE_X = 0x440;
323 GRID_SIZE_Y = 0x444;
324 STYLE_FLAGS = 0x448;
325 SEQUENCE_LEN = 0x454;
326 SEQUENCE = 0x458;
327 DOT_SEQUENCE_LEN = 0x460;
328 DOT_SEQUENCE = 0x468;
329 DOT_SEQUENCE_LEN_REFLECTION = 0x470;
330 DOT_SEQUENCE_REFLECTION = 0x478;
331 NUM_COLORED_REGIONS = 0x498;
332 COLORED_REGIONS = 0x4A0;
333 PANEL_TARGET = 0x4A8;
334 SPECULAR_TEXTURE = 0x4D0;
335 CABLE_TARGET_2 = 0xD0;
336 AUDIO_LOG_NAME = 0x0;
337 OPEN_RATE = 0xE0;
338 METADATA = 0x13A; // sizeof(short)
339 HOTEL_EP_NAME = 0x51E340;
340 } else {
341 assert(false);
342 return;
343 }
344} \ No newline at end of file
diff --git a/Source/Memory.h b/Source/Memory.h index fc67b4f..601b233 100644 --- a/Source/Memory.h +++ b/Source/Memory.h
@@ -1,6 +1,6 @@
1#pragma once 1#pragma once
2 2
3//extern int GLOBALS, POSITION, ORIENTATION, PATH_COLOR, REFLECTION_PATH_COLOR, DOT_COLOR, ACTIVE_COLOR, BACKGROUND_REGION_COLOR, SUCCESS_COLOR_A, SUCCESS_COLOR_B, STROBE_COLOR_A, STROBE_COLOR_B, ERROR_COLOR, PATTERN_POINT_COLOR, PATTERN_POINT_COLOR_A, PATTERN_POINT_COLOR_B, SYMBOL_A, SYMBOL_B, SYMBOL_C, SYMBOL_D, SYMBOL_E, PUSH_SYMBOL_COLORS, OUTER_BACKGROUND, OUTER_BACKGROUND_MODE, TRACED_EDGES, AUDIO_PREFIX, POWER, TARGET, POWER_OFF_ON_FAIL, IS_CYLINDER, CYLINDER_Z0, CYLINDER_Z1, CYLINDER_RADIUS, CURSOR_SPEED_SCALE, NEEDS_REDRAW, SPECULAR_ADD, SPECULAR_POWER, PATH_WIDTH_SCALE, STARTPOINT_SCALE, NUM_DOTS, NUM_CONNECTIONS, MAX_BROADCAST_DISTANCE, DOT_POSITIONS, DOT_FLAGS, DOT_CONNECTION_A, DOT_CONNECTION_B, DECORATIONS, DECORATION_FLAGS, DECORATION_COLORS, NUM_DECORATIONS, REFLECTION_DATA, GRID_SIZE_X, GRID_SIZE_Y, STYLE_FLAGS, SEQUENCE_LEN, SEQUENCE, DOT_SEQUENCE_LEN, DOT_SEQUENCE, DOT_SEQUENCE_LEN_REFLECTION, DOT_SEQUENCE_REFLECTION, NUM_COLORED_REGIONS, COLORED_REGIONS, PANEL_TARGET, SPECULAR_TEXTURE, CABLE_TARGET_2, AUDIO_LOG_NAME, OPEN_RATE, METADATA, HOTEL_EP_NAME; 3extern int GLOBALS, POSITION, ORIENTATION, PATH_COLOR, REFLECTION_PATH_COLOR, DOT_COLOR, ACTIVE_COLOR, BACKGROUND_REGION_COLOR, SUCCESS_COLOR_A, SUCCESS_COLOR_B, STROBE_COLOR_A, STROBE_COLOR_B, ERROR_COLOR, PATTERN_POINT_COLOR, PATTERN_POINT_COLOR_A, PATTERN_POINT_COLOR_B, SYMBOL_A, SYMBOL_B, SYMBOL_C, SYMBOL_D, SYMBOL_E, PUSH_SYMBOL_COLORS, OUTER_BACKGROUND, OUTER_BACKGROUND_MODE, TRACED_EDGES, AUDIO_PREFIX, POWER, TARGET, POWER_OFF_ON_FAIL, IS_CYLINDER, CYLINDER_Z0, CYLINDER_Z1, CYLINDER_RADIUS, CURSOR_SPEED_SCALE, NEEDS_REDRAW, SPECULAR_ADD, SPECULAR_POWER, PATH_WIDTH_SCALE, STARTPOINT_SCALE, NUM_DOTS, NUM_CONNECTIONS, MAX_BROADCAST_DISTANCE, DOT_POSITIONS, DOT_FLAGS, DOT_CONNECTION_A, DOT_CONNECTION_B, DECORATIONS, DECORATION_FLAGS, DECORATION_COLORS, NUM_DECORATIONS, REFLECTION_DATA, GRID_SIZE_X, GRID_SIZE_Y, STYLE_FLAGS, SEQUENCE_LEN, SEQUENCE, DOT_SEQUENCE_LEN, DOT_SEQUENCE, DOT_SEQUENCE_LEN_REFLECTION, DOT_SEQUENCE_REFLECTION, NUM_COLORED_REGIONS, COLORED_REGIONS, PANEL_TARGET, SPECULAR_TEXTURE, CABLE_TARGET_2, AUDIO_LOG_NAME, OPEN_RATE, METADATA, HOTEL_EP_NAME, RANDOMISE_ON_POWER_ON;
4 4
5enum class ProcStatus { 5enum class ProcStatus {
6 NotRunning, 6 NotRunning,
@@ -92,8 +92,6 @@ public:
92 } 92 }
93 93
94 static int GLOBALS; 94 static int GLOBALS;
95 static int globalsTests[3];
96
97private: 95private:
98 template<class T> 96 template<class T>
99 std::vector<T> ReadData(const std::vector<int>& offsets, size_t numItems) { 97 std::vector<T> ReadData(const std::vector<int>& offsets, size_t numItems) {
@@ -117,6 +115,7 @@ private:
117 void Heartbeat(HWND window, WPARAM wParam); 115 void Heartbeat(HWND window, WPARAM wParam);
118 bool Initialize(); 116 bool Initialize();
119 void* ComputeOffset(std::vector<int> offsets); 117 void* ComputeOffset(std::vector<int> offsets);
118 void LoadPanelOffsets();
120 119
121 int _previousFrame = 0; 120 int _previousFrame = 0;
122 bool _threadActive = false; 121 bool _threadActive = false;
diff --git a/Source/PuzzleSerializer.cpp b/Source/PuzzleSerializer.cpp index 4a57313..e316216 100644 --- a/Source/PuzzleSerializer.cpp +++ b/Source/PuzzleSerializer.cpp
@@ -1,6 +1,5 @@
1#include "pch.h" 1#include "pch.h"
2#include "PuzzleSerializer.h" 2#include "PuzzleSerializer.h"
3#include "Randomizer.h"
4 3
5PuzzleSerializer::PuzzleSerializer(const std::shared_ptr<Memory>& memory) : _memory(memory) {} 4PuzzleSerializer::PuzzleSerializer(const std::shared_ptr<Memory>& memory) : _memory(memory) {}
6 5
diff --git a/Source/Randomizer.cpp b/Source/Randomizer.cpp index 2ef184c..6e6fabf 100644 --- a/Source/Randomizer.cpp +++ b/Source/Randomizer.cpp
@@ -116,9 +116,9 @@ void Randomizer::Randomize() {
116 116
117 // begin_endgame_1 - Prevent actually ending the game (Wonkavator) 117 // begin_endgame_1 - Prevent actually ending the game (Wonkavator)
118 _memory->AddSigScan({0x83, 0x7C, 0x01, 0xD0, 0x04}, [&](int index){ 118 _memory->AddSigScan({0x83, 0x7C, 0x01, 0xD0, 0x04}, [&](int index){
119 if (Memory::GLOBALS == 0x5B28C0) { // Version differences. 119 if (GLOBALS == 0x5B28C0) { // Version differences.
120 index += 0x75; 120 index += 0x75;
121 } else if (Memory::GLOBALS == 0x62D0A0) { 121 } else if (GLOBALS == 0x62D0A0) {
122 index += 0x86; 122 index += 0x86;
123 } 123 }
124 _memory->WriteData<byte>({index}, {0xEB}); // jz -> jmp 124 _memory->WriteData<byte>({index}, {0xEB}); // jz -> jmp
diff --git a/Source/Randomizer.h b/Source/Randomizer.h index 15465f4..625dcc0 100644 --- a/Source/Randomizer.h +++ b/Source/Randomizer.h
@@ -15,71 +15,3 @@ private:
15 friend class SwapTests_Shipwreck_Test; 15 friend class SwapTests_Shipwreck_Test;
16}; 16};
17 17
18#define PATH_COLOR 0xC0
19#define REFLECTION_PATH_COLOR 0xD0
20#define DOT_COLOR 0xF0
21#define ACTIVE_COLOR 0x100
22#define BACKGROUND_REGION_COLOR 0x110
23#define SUCCESS_COLOR_A 0x120
24#define SUCCESS_COLOR_B 0x130
25#define STROBE_COLOR_A 0x140
26#define STROBE_COLOR_B 0x150
27#define ERROR_COLOR 0x160
28#define PATTERN_POINT_COLOR 0x180
29#define PATTERN_POINT_COLOR_A 0x190
30#define PATTERN_POINT_COLOR_B 0x1A0
31#define SYMBOL_A 0x1B0
32#define SYMBOL_B 0x1C0
33#define SYMBOL_C 0x1D0
34#define SYMBOL_D 0x1E0
35#define SYMBOL_E 0x1F0
36#define PUSH_SYMBOL_COLORS 0x200
37#define OUTER_BACKGROUND 0x204
38#define OUTER_BACKGROUND_MODE 0x214
39#define TRACED_EDGES 0x228
40#define TRACED_EDGE_DATA 0x230
41#define AUDIO_PREFIX 0x270
42#define POWER 0x2A0
43#define TARGET 0x2B4
44#define POWER_OFF_ON_FAIL 0x2B8
45#define IS_CYLINDER 0x2F4
46#define CYLINDER_Z0 0x2F8
47#define CYLINDER_Z1 0x2FC
48#define CYLINDER_RADIUS 0x300
49#define CURSOR_SPEED_SCALE 0x350
50#define NEEDS_REDRAW 0x37C
51#define SPECULAR_ADD 0x38C
52#define SPECULAR_POWER 0x390
53#define PATH_WIDTH_SCALE 0x39C
54#define STARTPOINT_SCALE 0x3A0
55#define NUM_DOTS 0x3B4
56#define NUM_CONNECTIONS 0x3B8
57#define MAX_BROADCAST_DISTANCE 0x3BC
58#define DOT_POSITIONS 0x3C0
59#define DOT_FLAGS 0x3C8
60#define DOT_CONNECTION_A 0x3D0
61#define DOT_CONNECTION_B 0x3D8
62#define RANDOMISE_ON_POWER_ON 0x3E0
63#define DECORATIONS 0x418
64#define DECORATION_FLAGS 0x420
65#define DECORATION_COLORS 0x428
66#define NUM_DECORATIONS 0x430
67#define REFLECTION_DATA 0x438
68#define GRID_SIZE_X 0x440
69#define GRID_SIZE_Y 0x444
70#define STYLE_FLAGS 0x448
71#define SEQUENCE_LEN 0x454
72#define SEQUENCE 0x458
73#define DOT_SEQUENCE_LEN 0x460
74#define DOT_SEQUENCE 0x468
75#define DOT_SEQUENCE_LEN_REFLECTION 0x470
76#define DOT_SEQUENCE_REFLECTION 0x478
77#define NUM_COLORED_REGIONS 0x498
78#define COLORED_REGIONS 0x4A0
79#define PANEL_TARGET 0x4A8
80#define SPECULAR_TEXTURE 0x4D0
81#define CABLE_TARGET_2 0xD0
82#define AUDIO_LOG_NAME 0x0
83#define OPEN_RATE 0xE0
84#define METADATA 0x13A // sizeof(short)
85#define HOTEL_EP_NAME 0x51E340