Skip to content

Commit

Permalink
Start updating to newest version (1.0.12478)
Browse files Browse the repository at this point in the history
  • Loading branch information
Darxoon committed Aug 20, 2024
1 parent b2261dd commit e63e6ac
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 30 deletions.
2 changes: 1 addition & 1 deletion patch/main.s
Original file line number Diff line number Diff line change
Expand Up @@ -195,5 +195,5 @@ baseGooballCount equ 39
loadingText db "Using FistyLoader v1.0", 00h

; in order to pad the file to the correct size (0x3000)
section .ignoreme start=0x2ffc
section .ignoreme start=0x2cbfc
dd 0
43 changes: 14 additions & 29 deletions patcher/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,23 @@

def add_section_header(pe: PE, section_size: int):
print(f"Increasing image size by 0x{section_size:x}...")
pe.OPTIONAL_HEADER.SizeOfImage += section_size

prev_section: SectionStructure = pe.sections[-1]

print("Creating section .fisty...")
section = SectionStructure(PE.__IMAGE_SECTION_HEADER_format__, pe=pe)
section: SectionStructure = pe.sections[-1]
section.Name = ".fisty".encode()
section.Misc = section_size
section.Misc_PhysicalAddress = section_size
section.Misc_VirtualSize = section_size
section.VirtualAddress = prev_section.VirtualAddress + prev_section.SizeOfRawData
section.Misc = section_size - 0x104
section.Misc_PhysicalAddress = section_size - 0x104
section.Misc_VirtualSize = section_size - 0x104
# section.VirtualAddress = prev_section.VirtualAddress + prev_section.SizeOfRawData
section.SizeOfRawData = section_size
section.PointerToRawData = prev_section.PointerToRawData + prev_section.SizeOfRawData
# section.PointerToRawData = prev_section.PointerToRawData + prev_section.SizeOfRawData
section.PointerToRelocations = 0
section.PointerToLinenumbers = 0
section.NumberOfRelocations = 0
section.NumberOfLinenumbers = 0
section.Characteristics = 0xE0000000 # rwx permissions

print(f"Virtual address of new section: 0x{prev_section.VirtualAddress + prev_section.SizeOfRawData:x}")

section.set_file_offset(0x3d0)

pe.FILE_HEADER.NumberOfSections += 1
pe.sections.append(section)
pe.__structures__.append(section)

def add_section_content(filename: str, content: bytes):
with open(filename, 'ab') as f:
f.write(content)
print(f"Virtual address of new section: 0x{section.VirtualAddress:x}")

def main():
custom_code_path = join(dirname(realpath(argv[0])), 'custom_code.bin')
Expand All @@ -50,19 +37,17 @@ def main():

print("Writing out.exe...")
pe.write("out.exe")
add_section_content("out.exe", section_content)
else:
print('out.exe exists already, only applying changes...')

with open('out.exe', 'rb+') as f:
executable = f.read()
fisty_section_offset = int.from_bytes(executable[0x3e4:0x3e8], byteorder='little')
f.seek(fisty_section_offset)
f.write(section_content)
f.truncate(f.tell())

with open('out.exe', 'rb+') as f:
patch_game(f)
executable = f.read()
fisty_section_offset = int.from_bytes(executable[0x3dc:0x3e0], byteorder='little')
f.seek(fisty_section_offset)
f.write(section_content)

# with open('out.exe', 'rb+') as f:
# patch_game(f)

if __name__ == '__main__':
main()

0 comments on commit e63e6ac

Please sign in to comment.