Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion amd64/amd64_defs.M1
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

DEFINE add_rax, 4805
DEFINE add_rbp, 4881C5
DEFINE add_rsp, 4881C4
DEFINE add_rax,rbx 4801D8
DEFINE add_rax,rbp 4801E8
DEFINE add_rbx,rax 4801C3
Expand All @@ -32,10 +33,14 @@ DEFINE je 0F84
DEFINE jne 0F85
DEFINE lea_rax,[rbp+DWORD] 488D85
DEFINE lea_rax,[rip+DWORD] 488D05
DEFINE lea_rax,[rsp+DWORD] 488D8424
DEFINE lea_rcx,[rbp+DWORD] 488D8D
DEFINE lea_rdi,[rsp+DWORD] 488DBC24
DEFINE lea_rdx,[rip+DWORD] 488D15
DEFINE lea_rdx,[rsp+DWORD] 488D9424
DEFINE lea_rdx,[rbp+DWORD] 488D95
DEFINE lea_rsi,[rsp+DWORD] 488DB424
DEFINE lea_r8,[rbp+DWORD] 4C8D85
DEFINE lea_r9,[rbp+DWORD] 4C8D8D
DEFINE mov_rax, 48C7C0
DEFINE mov_rbx, 48C7C3
DEFINE mov_rdi, 48C7C7
Expand All @@ -51,14 +56,27 @@ DEFINE mov_rcx,rax 4889C1
DEFINE mov_rdi,rax 4889C7
DEFINE mov_rdi,rbx 4889DF
DEFINE mov_rdi,rsp 4889E7
DEFINE mov_rdx,rsp 4889E2
DEFINE mov_r8,rsp 4989E0
DEFINE mov_[rbx],al 8803
DEFINE mov_[rbx],rax 488903
DEFINE mov_[rip+DWORD],rax 488905
DEFINE mov_[rip+DWORD],rbp 48892D
DEFINE mov_[rip+DWORD],rcx 48890D
DEFINE mov_[rip+DWORD],rdx 488915
DEFINE mov_[rip+DWORD],rsp 488925
DEFINE mov_rax,[rax] 488B00
DEFINE mov_rbx,[rbx] 488B1B
DEFINE mov_rcx,[rcx] 488B09
DEFINE mov_rdi,[rdi] 488B3F
DEFINE mov_rdx,[rdx] 488B12
DEFINE mov_rsi,[rsi] 488B36
DEFINE mov_rax,[rsp+DWORD] 488B8424
DEFINE mov_rax,[rip+DWORD] 488B05
DEFINE mov_rbp,[rip+DWORD] 488B2D
DEFINE mov_rsp,[rip+DWORD] 488B25
DEFINE mov_r8,[r8] 4D8B00
DEFINE mov_r9,[r9] 4D8B09
DEFINE movzx_rax,al 480FB6C0
DEFINE movsxd_rax,eax 4863C0
DEFINE movsx_rax,BYTE_PTR_[rax] 480FBE00
Expand All @@ -72,6 +90,7 @@ DEFINE pop_rax 58
DEFINE pop_rbp 5D
DEFINE pop_rbx 5B
DEFINE pop_rdi 5F
DEFINE push 6A
DEFINE push_rax 50
DEFINE push_rbp 55
DEFINE push_rbx 53
Expand All @@ -92,6 +111,7 @@ DEFINE setge_al 0F9DC0
DEFINE setl_al 0F9CC0
DEFINE setle_al 0F9EC0
DEFINE setne_al 0F95C0
DEFINE sub_rsp, 4881EC
DEFINE sub_rbx,rax 4829C3
DEFINE syscall 0F05
DEFINE test_rax,rax 4885C0
Expand Down
137 changes: 137 additions & 0 deletions amd64/uefi/PE32-amd64.hex2
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
# SPDX-FileCopyrightText: 2022 Jeremiah Orians
#
# SPDX-License-Identifier: GPL-3.0-or-later

:PE32_base
# DOS MZ header
4D 5A # Signature
00 00 # Number of bytes in the last page.
00 00 # Number of whole/partial pages
00 00 # Number of entries in the relocation table.
00 00 # Header size
00 00 # Minimum allocation
00 00 # Maximum allocation
00 00 # Relocatable segment address for SS
00 00 # Initial value for SP
00 00 # Checksum (I don't think is looked at)
00 00 # Initial value for IP (Seems ignored)
00 00 # Relocatable segment address for CS (Seems ignored)
00 00 # The (absolute) offset to the relocation table.
00 00 # Value used for overlay management. If zero, this is the main executable
00 00 00 00 00 00 00 00 # Reserved in PE
00 00 # OEM identifier
00 00 # OEM info
00 00 00 00 00 00 00 00 00 00 # The required reserved 20 bytes of NULLS
00 00 00 00 00 00 00 00 00 00
40 00 00 00 # Starting address of the PE header

# [0x40]
:PE_header
50 45 00 00 # Signature "PE"
64 86 # Machine
01 00 # number of sections
00 00 00 00 # Timestamp supposedly
00 00 00 00 # PointerToSymbolTable
00 00 00 00 # number of symbols
@OptionalHeader_end>PE_header # SizeOfOptionalHeader
00 00 # 'Characteristics'

# [0x58]
# COFF header bits
0B 02 # Magic PE32+ (64 bit)
00 00 # Linker version
00 00 00 00 # size of code
00 00 00 00 # sizeOfInitializedData
00 00 00 00 # SizeOfUninitializedData
00 10 00 00 # AddressOfEntryPoint
00 00 00 00 # BaseOfCode
00 00 00 00 00 00 00 00 # ImageBase
01 00 00 00 # SectionAlignment
01 00 00 00 # FileAlignment
00 00 00 00 # OperatingSystemVersion
00 00 00 00 # ImageVersion
00 00 00 00 # SubsystemVersion
00 00 00 00 # Win32VersionValue
00 00 10 00 # SizeOfImage
%PE32_text>PE32_base # SizeOfHeaders
00 00 00 00 # CheckSum (isn't used at all)
0A 00 # Subsystem
00 00 # DllCharacteristics
00 00 00 00 # SizeOfStackReserve
00 00 00 00 # SizeOfStackCommit
00 00 00 00 # SizeOfHeapReserve
00 00 00 00 # SizeOfHeapCommit
00 00 00 00 # LoaderFlags
00 00 00 00 # NumberOfRvaAndSizes

# [0xB8]
# Data directories (has to be 16 entries always 16bytes per entry)
00 00 00 00 # Export Table
00 00 00 00 # Size of Export Table

00 00 00 00 # Import Table
10 00 00 00 # Size of Import Table

00 00 00 00 # Resource Table
00 00 00 00 # Size of Resource Table

00 00 00 00 # Exception Table
00 00 00 00 # Size of Exception Table

00 00 00 00 # Certificate Table
00 00 00 00 # Size of Certificate Table

00 00 00 00 # Base Relocation Table
00 00 00 00 # Size of Base Relocation Table

00 00 00 00 # Debug Table
00 00 00 00 # Size of Debug Table

00 00 00 00 # Architecture Data Table
00 00 00 00 # Size of Architecture Data Table

00 00 00 00 # Global Pointer
00 00 00 00 # NULL

00 00 00 00 # TLS Table
00 00 00 00 # Size of TLS Table

00 00 00 00 # Load Config Table
00 00 00 00 # Size of Load Config Table

00 00 00 00 # Bound Import Table
00 00 00 00 # Size of Bound Import Table

00 00 00 00 # Import Address Table
00 00 00 00 # Size of Import Address Table

00 00 00 00 # Delay Import Descriptor Table
00 00 00 00 # Size of Delay Import Descriptor Table

00 00 00 00 # CLR Runtime header table
00 00 00 00 # Size of CLR Runtime Header table

# [0x130]
:OptionalHeader_end

00 00 00 00 00 00 00 00 # MUST BE NULL

# no idea what it is yet
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00

# [0x148]
# Start of section headers
2E 74 65 78 74 00 00 00 ; Name of the section: ".text"
%ELF_end>PE32_text ; VirtualSize
00 10 00 00 ; VirtualAddress
%ELF_end>PE32_text ; SizeOfRawData
70 01 00 00 ; PointerToRawData
00 00 00 00 ; PointerToRelocations
00 00 00 00 ; PointerToLinenumbers
00 00 ; NumberOfRelocations
00 00 ; NumberOfLinenumbers
00 00 00 00 ; 'Characteristics'

# [0x170]
:PE32_text
Loading