def test_analyze_moves_series_abs_ref_simple(): result = analyze_moves_series(test_data_abs_ref_simple, 6) assert result == MovesSeriesAnalysisResult( deleted_relocs={1, 8, 14, 19, 26, 32}, dest=AbsoluteMemoryReference(0xAE19178), length=36, )
def test_get_length(): result = analyze_moves_series(test_data_1, 7) assert result == MovesSeriesAnalysisResult( deleted_relocs={2, 9}, dest=RelativeMemoryReference(base_reg=Reg.esp, disp=0x20), length=21, saved_mach=b"\x8b\xf0", # mov esi, eax )
def test_get_length_select_item(): result = analyze_moves_series(test_data_select_item, len(" Select Item: "), 0x00EAF944) assert result == MovesSeriesAnalysisResult( length=len(test_data_select_item), deleted_relocs={3}, dest=RelativeMemoryReference(base_reg=Reg.ebx, disp=0x52C), )
def test_analyze_moves_series_abs_ref(): result = analyze_moves_series(test_data_abs_ref, 13) assert result == MovesSeriesAnalysisResult( deleted_relocs={2, 7, 13, 19, 25, 30, 36, 42, 48}, added_relocs={2}, dest=AbsoluteMemoryReference(0x617990), length=52, saved_mach=bytes.fromhex("2B 0D E0 82 D6 0A "), # sub ecx, [0ad682e0h] )
def test_analyze_moves_series_linen_apron(): result = analyze_moves_series(test_data_linen_apron, len("Linen apron"), 0x550B18) assert result == MovesSeriesAnalysisResult( deleted_relocs={2, 8, 13, 19, 25, 47}, dest=AbsoluteMemoryReference(0x6702DC9), length=29, nops={46: 5}, )
def test_dnwwap(): result = analyze_moves_series( test_data_dnwwap, len("Design New World with Advanced Parameters"), 0x0EBDD44) assert result == MovesSeriesAnalysisResult( length=len(test_data_dnwwap), dest=RelativeMemoryReference(base_reg=Reg.edx), deleted_relocs={3, 21, 33, 44}, saved_mach=bytes.fromhex("8d9610010000 8bca"), )
def test_get_length_tribesman_peasant_intersection(): result = analyze_moves_series(test_data_tribesman_peasant_intersection, len("tribesman"), 0x54BFDC) assert result == MovesSeriesAnalysisResult( deleted_relocs={2, 8, 14}, dest=RelativeMemoryReference(base_reg=Reg.ebp, disp=-0x70), # [ebp-0x70] length=22, pokes={23: 0x0C + 6}, )
def test_analyze_moves_series_whimper_gnaw_intersection(): saved = bytes.fromhex("85 C0 " "0F 95 C2 ") # test eax, eax # setnz dl result = analyze_moves_series(test_data_whimper_gnaw_intersection, len("whimper"), 0x541F00) assert result == MovesSeriesAnalysisResult( deleted_relocs={2, 9, 17, 35}, dest=AbsoluteMemoryReference(0x68FF258), length=21, saved_mach=saved, nops={33: 6}, )
def test_analyze_moves_series_smoked(): result = analyze_moves_series(test_data_smoked, len("smoked %s"), 0x545B60) assert result == MovesSeriesAnalysisResult( deleted_relocs={2, 7, 14, 60, 65, 72}, dest=AbsoluteMemoryReference(0x189A325), length=18, nops={ 58: 6, 64: 5, 69: 7 }, )
def test_get_length_push(): result = analyze_moves_series(test_data_push, 15) assert result == MovesSeriesAnalysisResult( deleted_relocs={2, 7, 13, 30}, dest=RelativeMemoryReference(base_reg=Reg.ecx), length=40, saved_mach=bytes.fromhex( "8D 8D 90 FB FF FF"), # lea ecx, [ebp-470h] ; push ecx nops={ 41: 6, 47: 6 }, )
def test_analyze_moves_series_tanning_tan_intersection(): result = analyze_moves_series(test_data_tanning_tan_intersection, len("Tanning"), 0x55ABB8) assert result == MovesSeriesAnalysisResult( deleted_relocs={2, 13}, dest=RelativeMemoryReference(base_reg=Reg.esp, disp=+0xD40), length=6, nops={ 11: 6, 36: 7, 54: 7 }, )
def test_analyze_moves_series_nausea(): saved = bytes.fromhex("B9 0A 00 00 00 ") # mov ecx, 0Ah result = analyze_moves_series(test_data_nausea, len("nausea")) assert result == MovesSeriesAnalysisResult( deleted_relocs={3, 45, 52, 59, 65, 72}, dest=AbsoluteMemoryReference(0x62BC5C), length=12, saved_mach=saved, nops={ 43: 6, 50: 6, 56: 7, 63: 6, 69: 7 }, )
def test_analyze_moves_series_mild_low_pressure(): result = analyze_moves_series(test_data_mild_low_pressure, len("mild low pressure"), 0x57AC80) assert result == MovesSeriesAnalysisResult( deleted_relocs={2, 8, 14, 33, 39, 58, 64, 83, 90, 288}, dest=AbsoluteMemoryReference(0xAE1AABE), length=18, nops={ 31: 6, 37: 6, 56: 6, 62: 6, 81: 6, 87: 7, 285: 7 }, )
def test_get_length_has_arrived(): result = analyze_moves_series(test_data_has_arrived, len(" has arrived."), 0x00F12F00) assert result == MovesSeriesAnalysisResult( length=5, dest=RelativeMemoryReference(base_reg=Reg.ecx), nops={ 12: 2, 14: 5, 19: 3, 22: 5, 27: 3, 30: 6, 36: 4 }, deleted_relocs={1, 15, 23, 32}, )
def test_analyze_moves_series_stimulant(): saved = bytes.fromhex("B9 0A 00 00 00") # mov ecx, 0Ah result = analyze_moves_series(test_data_stimulant, len("stimulant"), 0x54645C) assert result == MovesSeriesAnalysisResult( deleted_relocs={2, 25, 31, 38, 44, 51}, dest=AbsoluteMemoryReference(0x62C927), length=11, saved_mach=saved, nops={ 23: 6, 29: 6, 35: 7, 42: 6, 48: 7 }, )
def test_create_new_world(): original_string_address = 0xF2A8B8 result = analyze_moves_series(test_data_create_new_world, len("Create New World!"), original_string_address) new_len = len("Создать новый мир!") assert result == MovesSeriesAnalysisResult( length=67, dest=RelativeMemoryReference(base_reg=Reg.ecx), deleted_relocs={2, 14, 25, 37, 50}, saved_mach=bytes.fromhex( "8d 8b 10 01 00 00"), # lea ecx,[ebx+0x110] ) meta = Metadata() fix = get_fix_for_moves(result, new_len, original_string_address, meta) assert len(fix.pokes[0]) == result.length
def test_get_length_tribesman(): saved = bytes.fromhex( "8d 0c ff" # lea ecx, [edi*9] "8b 0c 8d c0 ee d0 0a" # mov ecx, [ecx*4+0ad0eec0] "2b 0d e0 82 d6 0a" # sub ecx, [0ad682e0] ) result = analyze_moves_series(test_data_tribesman, len("for some time"), 0x543D74) assert result == MovesSeriesAnalysisResult( deleted_relocs={2, 7, 17, 23, 31, 40}, added_relocs={6, 12}, dest=RelativeMemoryReference(base_reg=Reg.esi), length=44, saved_mach=saved, nops={ 47: 3, 50: 4 }, )