You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-- initially 12 but we have 64-bit architecture + pointer alignment.
33
33
-- when intercept overflow is emulated, the size of 12 is still used internally
34
34
-- to corrupt the same target values as in vanilla
35
-
INTERCEPT_SIZE=16
35
+
INTERCEPT_SIZE=16
36
+
INTERCEPT_SIZE_VANILLA=12
36
37
37
38
--#endregion
38
39
@@ -129,6 +130,20 @@ end
129
130
---@fieldnamestring Full name of the vanilla variable we're corrupting
130
131
---@fieldvalueinteger Value that the vanilla variable has at the moment
131
132
133
+
---@class (exact) intercept_overrun_info
134
+
---@fieldoffsetstring
135
+
---@fieldvaluestring
136
+
---@fieldvariablestring
137
+
138
+
--- `intercept_t` plus some extra info for the user.
139
+
---@classintercept_info
140
+
---@fieldfracstring `frac` is the most complicated part of `intercept_t` struct. When an intercept is checked, traceline length is normalized to [0, 1], and the point where it crosses something denotes the fraction of that length, meaning how soon the traceline hits it. Negative value means behind the origin, and more than 1 means outside the trace range. Then for all the intercepts in the list, those fractions are compared and the shortest one wins. So to manipulate what value is used for memory corruption, we just need to adjust the distance between trace origin and something it hits, keeping in mind intercept at which index/offset matches our target address. Internally represented as 32-bit integer, basically means percentage of traceline length if we multiply the value by 100.
141
+
---@fieldisalinestring Whether intercept is with a line or a thing. Internally represented as 32-bit integer.
142
+
---@fieldoffsetstring How far into corrupted memory we are. Informational addition.
143
+
---@fieldpointerinteger `d` field of `intercept_t`. Not super relevant outside vanilla executable. Current codebase makes it a 64-bit integer and when intercept overruns are emulated it's just truncated to 32 bits.
144
+
---@fieldblockinteger Blockmap block where the intercept happened.
145
+
---@fieldidinteger `iLineID` or `index`, depending on `isaline`.
146
+
132
147
--- Used for specific things like point coordinates, but also for anything that can have x/y values
133
148
---@class (exact) vertex
134
149
---@fieldxnumber
@@ -217,8 +232,6 @@ LastBMEnd = nil
217
232
CurrentPrompt=nil
218
233
---@typeconfirmation
219
234
Confirmation=nil
220
-
---@typeintercept_overrun[]
221
-
InterceptOverrun= {}
222
235
---@typeintercepts_state
223
236
InterceptsInfo=InterceptsState.NONE
224
237
---@typeline_log_type
@@ -256,9 +269,13 @@ Config = {}
256
269
PRandomInfo= {}
257
270
DivLines= {}
258
271
MapBlocks= {}
259
-
Intercepts= {}
260
-
InterceptsOverruns= {}
261
272
GUITexts= {}
273
+
274
+
--- Intercept objects per block
275
+
---@typetable<number, intercept_info[]>
276
+
Intercepts= {}
277
+
---@typetable<number, intercept_overrun_info[]>
278
+
InterceptsOverruns= {}
262
279
-- map object positions bounds
263
280
OB= {
264
281
top=math.maxinteger,
@@ -328,9 +345,10 @@ end
328
345
329
346
--- After intercept overflow, shows which variables got corrupted and their resulting values. The list is consctructed on the fly so we could read from memory directly.
330
347
---@paramlimitinteger
331
-
---@returnintercept_overrun[] # Table index indicates offset, usable for comparing with offsets of individual intercepts after overflow
348
+
---@returnintercept_overrun_info[] # Table index indicates offset, usable for comparing with offsets of individual intercepts after overflow
@@ -382,7 +399,84 @@ local function fetch_intercept_overruns(limit)
382
399
returnret
383
400
end
384
401
385
-
--- Very complicated thing that handles tracelines display and intercepts display and logging. Installs the hook while anything is enabled. When an intercept is added by the game, we read `trace` from memory which is the thing creating intercepts, and we add all those tracelines to a table that we then display once per frame. When the amount of intercepts per block exceeds user defined value, or if the overflow has happened, we print that. Upon overflow we also let the user dump all their contents and info to console.
402
+
--- When the amount of intercepts per block exceeds user defined value, or if the overflow has happened, we print that. Upon overflow we also let the user dump all their contents and info to console.
-- we insert the same interecepts over and over for every new call,
467
+
-- because we can't know when they'll end,
468
+
-- and we may be asked to do this before it actually overflows.
469
+
-- so we can't just sit and wait for an overflow and only
470
+
-- then build the list. there won't be thousands of them anyway.
471
+
Intercepts[math.abs(block)][i] =object
472
+
473
+
i=i+1
474
+
end
475
+
end
476
+
end
477
+
end
478
+
479
+
--- Very complicated thing that handles tracelines display and intercepts display and logging. Installs the hook while anything is enabled. When an intercept is added by the game, we read `trace` from memory which is the thing creating intercepts, and we add all those tracelines to a table that we then display once per frame.
386
480
localfunctionhook_intercepts()
387
481
localname="Intercepts"
388
482
@@ -405,86 +499,8 @@ local function hook_intercepts()
0 commit comments