Improved code quality
This commit is contained in:
@ -24,7 +24,7 @@ func (c *compiler) call(x asm.Instruction) {
|
||||
}
|
||||
|
||||
distance := destination - (pointer.Position + Address(pointer.Size))
|
||||
return Address(distance)
|
||||
return distance
|
||||
}
|
||||
|
||||
c.codePointers = append(c.codePointers, pointer)
|
||||
|
@ -40,7 +40,7 @@ func (c *compiler) jump(x asm.Instruction) {
|
||||
}
|
||||
|
||||
distance := destination - (pointer.Position + Address(pointer.Size))
|
||||
return Address(distance)
|
||||
return distance
|
||||
}
|
||||
|
||||
c.codePointers = append(c.codePointers, pointer)
|
||||
|
@ -40,7 +40,7 @@ restart:
|
||||
case 0xEB: // JMP
|
||||
jump = []byte{0xE9}
|
||||
default:
|
||||
panic(fmt.Errorf("failed to increase pointer size for instruction 0x%x", opCode))
|
||||
panic(fmt.Sprintf("failed to increase pointer size for instruction 0x%x", opCode))
|
||||
}
|
||||
|
||||
pointer.Position += Address(len(jump) - int(pointer.OpSize))
|
||||
@ -90,9 +90,10 @@ restart:
|
||||
|
||||
for _, pointer := range c.dllPointers {
|
||||
destination := importsStart + pointer.Resolve()
|
||||
delta := destination - Address(c.codeStart+pointer.Position+Address(pointer.Size))
|
||||
from := c.codeStart + pointer.Position + Address(pointer.Size)
|
||||
offset := destination - from
|
||||
slice := c.code[pointer.Position : pointer.Position+4]
|
||||
binary.LittleEndian.PutUint32(slice, uint32(delta))
|
||||
binary.LittleEndian.PutUint32(slice, uint32(offset))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user