Skip to content

Instantly share code, notes, and snippets.

@potetisensei
Created December 25, 2014 20:41
Show Gist options
  • Save potetisensei/0a2a7e1e4619340a23b0 to your computer and use it in GitHub Desktop.
Save potetisensei/0a2a7e1e4619340a23b0 to your computer and use it in GitHub Desktop.
FB_MAGIC = 0x4246
OV_MAGIC = 0x564F
SI_COD = 0x0001
SI_OVR = 0x0002
SI_DAT = 0x0004
STUBUNK_SIZE = (0x20-0x10)
ovr_noexe = 0
ovr_pascal = 1
ovr_cpp = 2
ovr_ms = 3
def fbov_t(
fb=0, # unsigned short int
ov=0, # unsigned short int
ovrsize=0, # unsigned int
exeinfo=0, # unsigned int
segnum=0, # int
):
ret = ""
ret += pack("H", fb)
ret += pack("H", ov)
ret += pack("I", ovrsize)
ret += pack("I", exeinfo)
ret += pack("i", segnum)
return ret
def stub_t(
CDh=0, # unsigned char
intnum=0, # unsigned char
memswap=0, # unsigned short int
fileoff=0, # int
codesize=0, # unsigned short int
relsize=0, # unsigned short int
nentries=0, # unsigned short int
prevstub=0, # unsigned short int
unknown=0, # unsigned char
):
ret = ""
ret += pack("B", CDh)
ret += pack("B", intnum)
ret += pack("H", memswap)
ret += pack("i", fileoff)
ret += pack("H", codesize)
ret += pack("H", relsize)
ret += pack("H", nentries)
ret += pack("H", prevstub)
ret += pack("B", unknown)
return ret
def ms_entry(
CDh=0, # unsigned char
intnum=0, # unsigned char
ovr_index=0, # unsigned short int
entry_off=0, # unsigned short int
):
ret = ""
ret += pack("B", CDh)
ret += pack("B", intnum)
ret += pack("H", ovr_index)
ret += pack("H", entry_off)
return ret
def ovrentry_t(
int3f=0, # unsigned short int
off=0, # unsigned short int
segc=0, # char
):
ret = ""
ret += pack("H", int3f)
ret += pack("H", off)
ret += pack("b", segc)
return ret
def seginfo_t(
seg=0, # unsigned short int
maxoff=0, # unsigned short int
flags=0, # unsigned short int
minoff=0, # unsigned short int
):
ret = ""
ret += pack("H", seg)
ret += pack("H", maxoff)
ret += pack("H", flags)
ret += pack("H", minoff)
return ret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment