Implement timed Invisible gadget and shared energy warnings
This commit is contained in:
1 parent
3527d33810
commit
1897dd2b90
44 files changed
+2466
-39
No files matched your search
@@ -0,0 +1,156 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Read-only Bubble gadget contract and bounded source-state projections.
|
||||
|
||||
REA inspected generated EXE copies; these projections are not original execution.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
import argparse
|
||||
from dataclasses import dataclass, replace
|
||||
import hashlib
|
||||
import json
|
||||
import math
|
||||
from pathlib import Path
|
||||
import struct
|
||||
|
||||
from checkpoint_script_state import EXE_SHA256, find_case, read_va
|
||||
from pe_inspect import PE
|
||||
|
||||
BODIES = (
|
||||
('constructor', 0x410840, 0x410a0f, '60f84d3037031e7bdb4eff676c99b8f14337114086812d90f9cdf6cc512e3c52'),
|
||||
('bind', 0x410a80, 0x410ad1, '568468bd5cbd82fe5f4c3d54919b27c3cf6f4c472467102bcd0aae4f97f33f92'),
|
||||
('animate', 0x410ae0, 0x410c9e, '2d2fce6259a34254dec6b9e6a6302150f58c79d19771861fcadb26e8eda38c60'),
|
||||
('start', 0x410ca0, 0x410cf3, '238c7652a9d6237c6897a74e1c9757b15a063abf017f6e5225d25a75798b0fa3'),
|
||||
('stop', 0x410d00, 0x410d16, 'a551ba8c995dfd11db00c5d25f8502101a7bd05928a22781b0fd9f45e0d799c8'),
|
||||
('equip', 0x428f61, 0x4290b7, '0d56551646c616094d7550de24600475b2593160234111bb76fe2a434893862c'),
|
||||
('cleanup', 0x427ff0, 0x4280cc, 'd81b941f45247d8fc3c7652bc64d06e9c503d699d1a1820c5fab4ffad4e56bf9'),
|
||||
('active_input', 0x426264, 0x4263ef, '77de32b45f3808ccd7ec76304d74c82b09cc7ee831a6b7553e3fe68c72296715'),
|
||||
('ordinary_fire_gate', 0x42668f, 0x4266b9, 'd88cb837b49acc11f3a779f71b3f361ed27c634532aa3808081cf4a2438ee6b3'),
|
||||
('effect_callbacks', 0x42a870, 0x42a91a, 'eb20ec6524bf2a54bf45ea781f0cb0d6bc03f3c729f5dbd4097810d5c9b21fa2'),
|
||||
('supported_radius', 0x42469b, 0x4246e9, '40e025e4bdc8bcdbcb24651e3d81908a5b7a9e2cc8de81d733da7490ea76c1d4'),
|
||||
('movement_dispatch', 0x438b1e, 0x438ba4, 'a18e41a473e0975ae79c2d328ec323d7c87d77722a6a43a785bbc3fe92a58743'),
|
||||
)
|
||||
SITES = (
|
||||
('owned_bubble_ctor', 0x42232c, 5), ('owned_bubble_field', 0x42233c, 6),
|
||||
('sprite_archive', 0x410919, 5), ('sprite_canvas1', 0x41094a, 7),
|
||||
('radius160', 0x429049, 13), ('factor0415', 0x429058, 13),
|
||||
('mode0', 0x429065, 7), ('movement2', 0x429072, 9), ('max1350', 0x42907b, 10),
|
||||
('start_effect', 0x429085, 5), ('loop_sound2', 0x429093, 11),
|
||||
('practice_vr01', 0x428fca, 5), ('energy_gate', 0x428fda, 25),
|
||||
('exempt_flag', 0x428fed, 8), ('active_guard', 0x429013, 14),
|
||||
('collapse_guard', 0x429021, 14), ('expand_guard', 0x42902f, 14),
|
||||
('cleanup_mode0', 0x428030, 7), ('cleanup_timer05', 0x428045, 10),
|
||||
('cleanup_movement0', 0x42804f, 7), ('cleanup_max650', 0x428056, 10),
|
||||
('cleanup_stop', 0x428060, 5), ('cleanup_clear_expand', 0x42806b, 6),
|
||||
('cleanup_stop_loop', 0x42807c, 7), ('cleanup_radius60', 0x42809c, 13),
|
||||
('cleanup_factor1265', 0x4280ab, 13), ('cleanup_mode_minus1', 0x4280bb, 9),
|
||||
('input_mode2', 0x426264, 14), ('input_drain', 0x426272, 19),
|
||||
('input_empty_cleanup', 0x426285, 32), ('position_y100', 0x4262f2, 6),
|
||||
('position_distance80', 0x42637a, 6), ('position_y50', 0x426399, 6),
|
||||
('fire_mode0_reject', 0x4266ac, 13), ('effect_pulse30', 0x410b5a, 6),
|
||||
('expand_strict1', 0x410b95, 29), ('collapse_strict0', 0x410c1e, 13),
|
||||
)
|
||||
VTABLES = ((0x4a3bdc, 0x174, 0x428d50), (0x4a3bdc, 0x178, 0x427ff0),
|
||||
(0x49250c, 0x3c4, 0x410ae0), (0x49250c, 0x110, 0x471240),
|
||||
(0x49250c, 0x100, 0x4711e0), (0x4a3bdc, 0x128, 0x439900))
|
||||
|
||||
|
||||
def collect(original: Path | str):
|
||||
pe = PE(find_case(Path(original), 'Neutron.exe'))
|
||||
digest = hashlib.sha256(pe.data).hexdigest()
|
||||
if digest != EXE_SHA256:
|
||||
raise ValueError('Unexpected original EXE identity')
|
||||
bodies = []
|
||||
for name, start, end, expected in BODIES:
|
||||
actual = hashlib.sha256(read_va(pe, start, end-start)).hexdigest()
|
||||
if actual != expected:
|
||||
raise ValueError(f'Changed source span {name}')
|
||||
bodies.append(dict(name=name, va=hex(start), file_offset=hex(pe.offset(start-pe.base)),
|
||||
length=end-start, sha256=actual))
|
||||
sites = [dict(name=name, va=hex(va), file_offset=hex(pe.offset(va-pe.base)),
|
||||
bytes=read_va(pe, va, length).hex()) for name, va, length in SITES]
|
||||
for base, slot, expected in VTABLES:
|
||||
if struct.unpack('<I', read_va(pe,base+slot,4))[0] != expected:
|
||||
raise ValueError(f'Changed virtual {base:x}+{slot:x}')
|
||||
if read_va(pe,0x4ed838,len(b'RetainedSprites.omt\0')) != b'RetainedSprites.omt\0':
|
||||
raise ValueError('Changed Bubble archive identity')
|
||||
return dict(sha256=digest,bodies=bodies,sites=sites,
|
||||
vtables=[dict(table=hex(b),slot=hex(s),target=hex(t)) for b,s,t in VTABLES],
|
||||
archive='RetainedSprites.omt',canvas=1,
|
||||
equip=dict(raw_mode=0,movement_mode=2,radius=160,factor=f32(.415),max_speed=1350,loop_sound=2),
|
||||
cleanup=dict(raw_mode=-1,movement_mode=0,radius=60,factor=f32(1.265),max_speed=650))
|
||||
|
||||
|
||||
def f32(value):
|
||||
return struct.unpack('<f',struct.pack('<f',value))[0]
|
||||
|
||||
|
||||
def equip_result(energy: float, *, exists=True, practice=False, exempt=False,
|
||||
active=False, expanding=False, collapsing=False):
|
||||
"""428F61 branch after the panel's eligibility/cleanup caller, not full equip."""
|
||||
if not math.isfinite(energy):
|
||||
raise ValueError('Finite source energy required')
|
||||
if not exists:
|
||||
return 'no_effect'
|
||||
if practice:
|
||||
return 'practice_VR01'
|
||||
if energy <= 0 and not exempt:
|
||||
return 'mode_minus1'
|
||||
if active or expanding or collapsing:
|
||||
return 'unchanged'
|
||||
return 'equip_mode0_movement2'
|
||||
|
||||
|
||||
def energy_delta(movement_mode: int, seconds: float):
|
||||
"""426264..426280; common42A920 owns VR exemptions/clamp/warning audio."""
|
||||
if not math.isfinite(seconds) or not 0 <= seconds < 1:
|
||||
raise ValueError('Bounded finite timestep required')
|
||||
return f32(f32(seconds) * f32(-.5)) if movement_mode == 2 else 0.0
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class BubbleVisual:
|
||||
timer: float = 0.0
|
||||
scalar: float = 0.0
|
||||
active: bool = False
|
||||
expanding: bool = False
|
||||
collapsing: bool = False
|
||||
hidden: bool = True
|
||||
rgba: tuple = (1.0,1.0,1.0,1.0)
|
||||
width: float = 200.0
|
||||
height: float = 200.0
|
||||
|
||||
|
||||
def start(state: BubbleVisual):
|
||||
#410CA0 does not clear active/collapsing; equip explicitly guards those states.
|
||||
return replace(state,timer=0,expanding=True,hidden=False)
|
||||
|
||||
|
||||
def stop(state: BubbleVisual, *, through_jimmy_cleanup=True):
|
||||
#410D00 alone leaves expanding unchanged;427FF0 separately clears it.
|
||||
return replace(state,timer=0,active=False,collapsing=True,
|
||||
expanding=False if through_jimmy_cleanup else state.expanding)
|
||||
|
||||
|
||||
def visual_step(state: BubbleVisual, seconds: float, *, graphics_alpha=False):
|
||||
"""Bounded410AE0 projection, not x87/fsin bit parity or an original runtime probe."""
|
||||
if not math.isfinite(seconds) or not 0 <= seconds < 1:
|
||||
raise ValueError('Bounded finite timestep required')
|
||||
timer=f32(state.timer+f32(seconds))
|
||||
state=replace(state,timer=timer)
|
||||
if state.active:
|
||||
rgba=(1.,1.,1.,.5) if graphics_alpha else state.rgba
|
||||
return replace(state,width=240.,height=f32(240+math.sin(timer*10)*30),rgba=rgba)
|
||||
if state.expanding:
|
||||
scalar=1. if timer>1. else timer
|
||||
return replace(state,scalar=scalar,active=timer>1.,expanding=timer<=1.,rgba=(scalar,)*4)
|
||||
if state.collapsing:
|
||||
scalar=f32(1.-timer)
|
||||
return replace(state,scalar=max(0.,scalar),collapsing=scalar>=0.,
|
||||
hidden=state.hidden or scalar<0.,rgba=(max(0.,scalar),)*4)
|
||||
return state
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
cli=argparse.ArgumentParser(description=__doc__)
|
||||
cli.add_argument('original',type=Path)
|
||||
print(json.dumps(collect(cli.parse_args().original),indent=2))
|
||||
@@ -0,0 +1,197 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Read-only Invisible gadget source guards and bounded branch projections.
|
||||
|
||||
These projections are independently transcribed static contracts, not execution
|
||||
of original code or a replacement for the port's runtime checks.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
from dataclasses import dataclass, replace
|
||||
import hashlib
|
||||
import json
|
||||
import math
|
||||
from pathlib import Path
|
||||
import struct
|
||||
|
||||
from checkpoint_script_state import EXE_SHA256, find_case, read_va
|
||||
from pe_inspect import PE
|
||||
|
||||
BODIES = (
|
||||
('invisible_tick', 0x424E80, 0x425114, 'b52f6f643c786206fa5a4089d58b311417439a203e0914a8a0243e319c52ebb3'),
|
||||
('invisible_equip', 0x428E51, 0x428F61, '9abaa12fb4625248564818695c6a7e6d27fccf15216c670e5321a3742aa99bc2'),
|
||||
('invisible_cleanup', 0x42810C, 0x4281B3, '92e9ffe9516cca33159b05d3509dc0e34d839e6c8d3deb7e1cd08adbfbfc2851'),
|
||||
('material_alpha', 0x40E4A0, 0x40E5D9, '741d94d5cf14efd99e5380239d7a1b4be7e7fb5f478590604e8bd76b8e5d1ead'),
|
||||
('indexed_blend', 0x40DD40, 0x40DD5D, 'b14a27765254aba1bb2e420019648ee0f05573567c1d1f79c6d8ab09cc59fdc5'),
|
||||
('meter', 0x4036C0, 0x40385B, '46f35e6db8030b96cd6a0bddaf59cf37d36b41f6b568143856db2184b360ca8b'),
|
||||
('enemy_target_flag', 0x409CC0, 0x409CF7, 'cf6e1c52f5801412ab7012465fd41d0278ddb9aef62002535c829f6e03af9252'),
|
||||
)
|
||||
SITES = (
|
||||
('tick_after_movement', 0x424C31, 20),
|
||||
('tick_control_pointer_not_identity', 0x424E80, 30),
|
||||
('tick_mode_two', 0x424E9E, 12),
|
||||
('tick_show_meter', 0x424EB4, 6),
|
||||
('primary_then_not_jump', 0x424EBA, 26),
|
||||
('primary_suppressor_returns', 0x424ED4, 13),
|
||||
('activation_remaining_exact_zero', 0x424EE1, 19),
|
||||
('activation_recharge_exact_seven_bits', 0x424EF4, 12),
|
||||
('activation_energy_strict_two_or_override', 0x424F00, 33),
|
||||
('activation_fixed_cost_minus_two', 0x424F21, 10),
|
||||
('activation_duration_seven', 0x424F32, 10),
|
||||
('activation_blend_source6_dest1', 0x424F3C, 12),
|
||||
('activation_material_alpha_point7', 0x424F48, 15),
|
||||
('activation_target_flag_false', 0x424F57, 7),
|
||||
('activation_recharge_zero', 0x424F5E, 10),
|
||||
('recharge_only_remaining_zero', 0x424F68, 23),
|
||||
('recharge_energy_positive_or_override', 0x424F7F, 29),
|
||||
('recharge_store_before_meter', 0x424F9C, 54),
|
||||
('recharge_seven_clamp_white', 0x424FD2, 47),
|
||||
('active_strict_positive_before_decrement', 0x425001, 23),
|
||||
('active_decrement_before_meter', 0x425018, 28),
|
||||
('active_expiry_less_or_equal_zero', 0x425064, 19),
|
||||
('expiry_material_reset', 0x425077, 38),
|
||||
('expiry_target_true_red_meter', 0x42509D, 25),
|
||||
('flash_last_three', 0x4250BA, 19),
|
||||
('flash_trunc_remaining_times_five', 0x4250CD, 19),
|
||||
('flash_odd_dest7_even_dest1', 0x4250EA, 38),
|
||||
('equip_energy_positive_or_override', 0x428E51, 40),
|
||||
('equip_mode_two_timers_target_flag', 0x428EB4, 36),
|
||||
('equip_display_before_branch', 0x428D95, 9),
|
||||
('cleanup_target_flag_true_recharge_zero', 0x428125, 21),
|
||||
('cleanup_companion_skip_flag', 0x428144, 20),
|
||||
('cleanup_material_opaque_mode_minus_one', 0x428194, 31),
|
||||
('constructor_timer_zero', 0x4227BE, 15),
|
||||
('constructor_override_false', 0x437650, 6),
|
||||
('postload_override_false', 0x4236C0, 7),
|
||||
('postload_vr_range_override_true', 0x423E44, 45),
|
||||
('enemy_chase_target_flag', 0x40847C, 34),
|
||||
('enemy_acquire_target_flag', 0x40877A, 28),
|
||||
('enemy_lost_target_flag', 0x4087F6, 51),
|
||||
('cam_optional_cleanup_flag', 0x4165B7, 43),
|
||||
('mca_optional_cleanup_flag', 0x43129A, 56),
|
||||
('jimmy438_cleanup', 0x42AE08, 18),
|
||||
('cam_interface_complete_plus_c8', 0x415A60, 6),
|
||||
('cam_property_default_one_register', 0x415C09, 5),
|
||||
('cam_property_default_one_store', 0x415CD5, 6),
|
||||
('cam_deactivateinv_property', 0x415F70, 26),
|
||||
('mca_interface_complete_plus_c8', 0x430930, 6),
|
||||
('mca_property_default_one', 0x430AA0, 10),
|
||||
('mca_deactivateinv_property', 0x430D7E, 26),
|
||||
)
|
||||
VTABLES = (
|
||||
(0x4A3BDC, 0x1C8, 0x424E80), (0x4A3BDC, 0x178, 0x427FF0),
|
||||
(0x4A3BDC, 0xFC, 0x40DD40), (0x4A3BDC, 0x114, 0x40E4A0),
|
||||
(0x48D414, 0x484, 0x4036C0), (0x48D414, 0x488, 0x403700),
|
||||
(0x48D414, 0x48C, 0x403730), (0x48D414, 0x490, 0x4037A0),
|
||||
)
|
||||
CONSTANTS = ((0x48D914, 0.0), (0x48D954, 2.0), (0x48D950, 5.0),
|
||||
(0x48E5A0, 3.0), (0x48E5B8, 7.0), (0x4A3E30, 1/7))
|
||||
|
||||
|
||||
def collect(original: Path | str):
|
||||
pe = PE(find_case(Path(original), 'Neutron.exe'))
|
||||
digest = hashlib.sha256(pe.data).hexdigest()
|
||||
if digest != EXE_SHA256:
|
||||
raise ValueError('Unexpected original EXE identity')
|
||||
bodies = []
|
||||
for name, start, end, expected in BODIES:
|
||||
actual = hashlib.sha256(read_va(pe, start, end-start)).hexdigest()
|
||||
if actual != expected:
|
||||
raise ValueError(f'Changed original span {name}')
|
||||
bodies.append(dict(name=name, va=hex(start), file_offset=hex(pe.offset(start-pe.base)),
|
||||
length=end-start, sha256=actual))
|
||||
sites = [dict(name=name, va=hex(va), file_offset=hex(pe.offset(va-pe.base)),
|
||||
bytes=read_va(pe, va, length).hex()) for name, va, length in SITES]
|
||||
tables = []
|
||||
for base, slot, expected in VTABLES:
|
||||
actual = struct.unpack('<I', read_va(pe, base+slot, 4))[0]
|
||||
if actual != expected:
|
||||
raise ValueError('Changed original virtual binding')
|
||||
tables.append(dict(table=hex(base), slot=hex(slot), target=hex(actual)))
|
||||
constants = []
|
||||
for va, expected in CONSTANTS:
|
||||
actual = struct.unpack('<f', read_va(pe, va, 4))[0]
|
||||
if abs(actual-expected) > 1e-7:
|
||||
raise ValueError('Changed original float constant')
|
||||
constants.append(dict(va=hex(va), file_offset=hex(pe.offset(va-pe.base)), value=actual))
|
||||
if read_va(pe, 0x4EDF10, 14) != b'DeactivateInv\0':
|
||||
raise ValueError('Changed cleanup property identity')
|
||||
return dict(sha256=digest, bodies=bodies, sites=sites, vtables=tables, constants=constants)
|
||||
|
||||
|
||||
def f32(value):
|
||||
return struct.unpack('<f', struct.pack('<f', value))[0]
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class State:
|
||||
mode: int = 2
|
||||
remaining: float = 0
|
||||
recharge: float = 0
|
||||
alpha: float = 1
|
||||
blend: str = 'opaque'
|
||||
targetable: bool = True
|
||||
meter_visible: bool = True
|
||||
meter_red: bool = True
|
||||
|
||||
|
||||
def equip(state: State, energy: float, override: bool = False):
|
||||
"""After caller cleanup/UI display2; failed branch changes only raw mode."""
|
||||
if energy <= 0 and not override:
|
||||
return replace(state, mode=-1)
|
||||
return replace(state, mode=2, remaining=0, recharge=0, targetable=True,
|
||||
meter_visible=True, meter_red=True)
|
||||
|
||||
|
||||
def cleanup(state: State):
|
||||
"""Only Jimmy-owned scalar/material/meter leaves; companion cleanup separate."""
|
||||
return replace(state, mode=-1, remaining=7, recharge=0, alpha=1,
|
||||
blend='opaque', targetable=True, meter_visible=False)
|
||||
|
||||
|
||||
def step(state: State, seconds: float, energy: float, *, primary=False,
|
||||
jump=False, suppressed=False, control_present=True, override=False,
|
||||
graphics_alpha=False):
|
||||
"""Source424E80 partial-order projection; return (state, fixed energy delta).
|
||||
|
||||
Uses float stores but does not claim x87 extended-precision equivalence for
|
||||
every bin boundary or reproduce the UI's transient pre-clamp meter sample.
|
||||
"""
|
||||
if not math.isfinite(seconds) or not 0 <= seconds < 1:
|
||||
raise ValueError('seconds must be finite and bounded')
|
||||
if not control_present:
|
||||
return replace(state, meter_visible=False), 0
|
||||
if state.mode != 2:
|
||||
return state, 0
|
||||
state = replace(state, meter_visible=True)
|
||||
delta = 0
|
||||
if primary and not jump:
|
||||
if suppressed:
|
||||
return state, delta
|
||||
if state.remaining == 0 and struct.pack('<f', state.recharge) == b'\0\0\xe0@':
|
||||
if energy <= 2 and not override:
|
||||
return state, delta
|
||||
delta = -2
|
||||
energy = max(0, min(100, f32(energy-2)))
|
||||
state = replace(state, remaining=7, recharge=0, alpha=f32(.7),
|
||||
blend='alpha' if graphics_alpha else 'additive', targetable=False)
|
||||
if state.remaining == 0 and (energy > 0 or override):
|
||||
recharge = f32(state.recharge+seconds)
|
||||
state = replace(state, recharge=min(recharge, 7),
|
||||
meter_red=False if recharge >= 7 else state.meter_red)
|
||||
if state.remaining > 0:
|
||||
remaining = f32(state.remaining-seconds)
|
||||
if remaining <= 0:
|
||||
return replace(state, remaining=0, alpha=1, blend='opaque',
|
||||
targetable=True, meter_red=True), delta
|
||||
blend = state.blend
|
||||
if remaining <= 3:
|
||||
blend = 'alpha' if int(remaining*5) % 2 else 'additive'
|
||||
state = replace(state, remaining=remaining, blend=blend)
|
||||
return state, delta
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
cli = argparse.ArgumentParser(description=__doc__)
|
||||
cli.add_argument('original', type=Path)
|
||||
print(json.dumps(collect(cli.parse_args().original), indent=2))
|
||||
@@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Read-only guards for shared42A920 energy/warning state; REA evidence is reused."""
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
import struct
|
||||
|
||||
from checkpoint_script_state import find_case, read_va
|
||||
from pe_inspect import PE
|
||||
|
||||
EXE_SHA256 = 'f5281076e1a2492f2d61f87aae3f4544b6d0f535ebe33f9fbb6f78710fe1aea8'
|
||||
SITES = (
|
||||
('ctor_zero_register', 0x42217E, '33db'),
|
||||
('ctor_clear_warning', 0x422980, '881ddc834f00'),
|
||||
('tutorial_numeric_range', 0x42A92B, '3d313052567c0b3d383052560f8ed5000000'),
|
||||
('empty_sound_before_scalar', 0x42A967, '6a006a506affe80ee00200'),
|
||||
('scalar_store_before_extended_upper_test', 0x42A975, 'd905d4834f00d8442404d915d4834f00d81d6cd94800'),
|
||||
('upper_clamp_clears_warning', 0x42A992, 'c705d4834f000000c842c605dc834f0000'),
|
||||
('low_sound_before_latch', 0x42A9DF, '6a0068b60000006affe893df020083c40cc605dc834f0001'),
|
||||
('strict_rearm', 0x42A9F8, 'd905d4834f00d81d24534900dfe0f6c4417507c605dc834f0000'),
|
||||
('ray_adjust_caller', 0x426F5A, 'e8c1390000'),
|
||||
('invisible_adjust_caller', 0x424F26, 'e8f5590000'),
|
||||
)
|
||||
|
||||
|
||||
def collect(original):
|
||||
pe = PE(find_case(Path(original), 'Neutron.exe'))
|
||||
if hashlib.sha256(pe.data).hexdigest() != EXE_SHA256:
|
||||
raise ValueError('Original EXE identity changed')
|
||||
body = read_va(pe, 0x42A920, 0xF3)
|
||||
digest = hashlib.sha256(body).hexdigest()
|
||||
if digest != '6d6a880fb1b4e39addc588201b7d5bb86c768dbfa3778b35045fc10380c9c5e4':
|
||||
raise ValueError('Changed energy body')
|
||||
sites = []
|
||||
for name, va, expected in SITES:
|
||||
if read_va(pe, va, len(bytes.fromhex(expected))) != bytes.fromhex(expected):
|
||||
raise ValueError('Changed source site: ' + name)
|
||||
sites.append(dict(name=name, va=hex(va), file_offset=hex(pe.offset(va-pe.base)), bytes=expected))
|
||||
constants = {name: struct.unpack('<f', read_va(pe, va, 4))[0] for name, va in
|
||||
(('zero', 0x48D914), ('maximum', 0x48D96C), ('low', 0x4A3E90), ('rearm', 0x495324))}
|
||||
return dict(sha256=EXE_SHA256, body=dict(va='0x42a920', file_offset=hex(pe.offset(0x2A920)),
|
||||
size=len(body), sha256=digest), sites=sites, constants=constants,
|
||||
globals=dict(value='0x4f83d4', warning='0x4f83dc'),
|
||||
rea_evidence='ev_71897af12f4bfa1de946c6f17f3bbed34764fdc84258ce64516c8f1f904b465d')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('original', type=Path)
|
||||
args = parser.parse_args()
|
||||
print(json.dumps(collect(args.original), indent=2))
|
||||
Reference in new issue
Block a user