mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-11-24 12:52:07 +00:00
1525c66de7
subrepo: subdir: "emummc" merged: "24bdbec8" upstream: origin: "https://github.com/m4xw/emummc" branch: "develop" commit: "24bdbec8" git-subrepo: version: "0.4.1" origin: "???" commit: "???"
53 lines
1.2 KiB
Python
Vendored
53 lines
1.2 KiB
Python
Vendored
# Modified kip1 conversion script, originally by jakibaki
|
|
# Used for dev purposes, will be replaced in the future
|
|
|
|
from struct import pack, unpack
|
|
from sys import argv
|
|
|
|
f = open(argv[1], "rb")
|
|
|
|
header_start = f.read(0x20)
|
|
|
|
section_names = [".text", ".rodata", ".data", ".bss"]
|
|
|
|
sections = []
|
|
for i in range(6):
|
|
section_bytes = f.read(0x10)
|
|
section = {}
|
|
|
|
if i < len(section_names):
|
|
section["Name"] = section_names[i]
|
|
|
|
section["OutOffset"], section["DecompressedSize"], section["CompressedSize"], section["Attribute"] = unpack("IIII", section_bytes)
|
|
sections.append(section)
|
|
print(section)
|
|
|
|
assert (sections[3]["OutOffset"] + sections[3]["DecompressedSize"]) % 0x1000 == 0
|
|
|
|
kernel_caps = []
|
|
for i in range(0x20):
|
|
val, = unpack("I", f.read(4))
|
|
kernel_caps.append(val)
|
|
|
|
f.seek(0x100)
|
|
|
|
for i in range(3):
|
|
section = sections[i]
|
|
section["Buffer"] = f.read(section["DecompressedSize"])
|
|
print(f.read())
|
|
|
|
f.close()
|
|
|
|
f = open(argv[2], "wb")
|
|
|
|
for i in range(3):
|
|
section = sections[i]
|
|
f.seek(section["OutOffset"])
|
|
f.write(section["Buffer"])
|
|
|
|
f.seek(sections[3]["OutOffset"])
|
|
f.write(b'\0' * sections[3]["DecompressedSize"])
|
|
|
|
caps = open("emummc.caps", "wb")
|
|
for i in range(0x20):
|
|
caps.write(pack("I", kernel_caps[i]))
|