Improved Windows support
This commit is contained in:
parent
3dffa69f37
commit
33da0cc315
16 changed files with 142 additions and 57 deletions
|
@ -25,7 +25,7 @@ func New(code []byte, data []byte) *MachO {
|
|||
MicroArchitecture: 3 | 0x80000000,
|
||||
Type: TypeExecute,
|
||||
NumCommands: 4,
|
||||
SizeCommands: 0x48*3 + 184,
|
||||
SizeCommands: 72*3 + 184,
|
||||
Flags: FlagNoUndefs,
|
||||
Reserved: 0,
|
||||
},
|
||||
|
@ -40,7 +40,7 @@ func (m *MachO) Write(writer io.Writer) {
|
|||
|
||||
binary.Write(writer, binary.LittleEndian, &Segment64{
|
||||
LoadCommand: LcSegment64,
|
||||
Length: 0x48,
|
||||
Length: 72,
|
||||
Name: [16]byte{'_', '_', 'P', 'A', 'G', 'E', 'Z', 'E', 'R', 'O'},
|
||||
Address: 0,
|
||||
SizeInMemory: config.BaseAddress,
|
||||
|
@ -55,12 +55,12 @@ func (m *MachO) Write(writer io.Writer) {
|
|||
codeStart := uint64(32 + m.Header.SizeCommands)
|
||||
codeLength := uint64(len(m.Code))
|
||||
codeEnd := codeStart + codeLength
|
||||
dataPadding := common.Padding(codeEnd, config.Align)
|
||||
dataPadding := common.Padding(codeEnd, Align)
|
||||
dataStart := codeEnd + dataPadding
|
||||
|
||||
binary.Write(writer, binary.LittleEndian, &Segment64{
|
||||
LoadCommand: LcSegment64,
|
||||
Length: 0x48,
|
||||
Length: 72,
|
||||
Name: [16]byte{'_', '_', 'T', 'E', 'X', 'T'},
|
||||
Address: config.BaseAddress + codeStart,
|
||||
SizeInMemory: codeLength,
|
||||
|
@ -74,7 +74,7 @@ func (m *MachO) Write(writer io.Writer) {
|
|||
|
||||
binary.Write(writer, binary.LittleEndian, &Segment64{
|
||||
LoadCommand: LcSegment64,
|
||||
Length: 0x48,
|
||||
Length: 72,
|
||||
Name: [16]byte{'_', '_', 'D', 'A', 'T', 'A'},
|
||||
Address: config.BaseAddress + dataStart,
|
||||
SizeInMemory: uint64(len(m.Data)),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue