Documentation
¶
Index ¶
- Constants
- func PackUint(order binary.ByteOrder, size int, buf []byte, n uint64) ([]byte, error)
- func UnpackUint(order binary.ByteOrder, size int, buf []byte) (uint64, error)
- type Builder
- type CodeHook
- type Cpu
- func (u *Cpu) Backend() interface{}
- func (u *Cpu) ContextRestore(ctx interface{}) error
- func (u *Cpu) ContextSave(reuse interface{}) (interface{}, error)
- func (u *Cpu) HookAllMemErr(cb MemErrHook, start, end uint64) (uc.Hook, error)
- func (u *Cpu) HookBlock(cb CodeHook, start, end uint64) (uc.Hook, error)
- func (u *Cpu) HookCode(cb CodeHook, start, end uint64) (uc.Hook, error)
- func (u *Cpu) HookInstruction(cb InstructionHook, start, end uint64, instruction int) (uc.Hook, error)
- func (u *Cpu) HookInterrupt(cb InterruptHook, start, end uint64) (uc.Hook, error)
- func (u *Cpu) HookMem(kind int, cb MemHook, start, end uint64) (uc.Hook, error)
- func (u *Cpu) HookMemErr(kind int, cb MemErrHook, start, end uint64) (uc.Hook, error)
- func (c *Cpu) Mem() io.ReadWriteSeeker
- func (u *Cpu) MemMap(addr, size uint64, prot int) error
- func (u *Cpu) MemProt(addr, size uint64, prot int) error
- func (u *Cpu) MemRegions() ([]*uc.MemRegion, error)
- type FileDesc
- type InstructionHook
- type InterruptHook
- type MemErrHook
- type MemError
- type MemHook
- type MemSim
- func (m *MemSim) Map(addr, size uint64, prot int, zero bool) *Page
- func (m *MemSim) Prot(addr, size uint64, prot int)
- func (m *MemSim) RangeValid(addr, size uint64, prot int) (mapGood bool, protGood bool)
- func (m *MemSim) Read(addr uint64, p []byte, prot int) error
- func (m *MemSim) Unmap(addr, size uint64)
- func (m *MemSim) Write(addr uint64, p []byte, prot int) error
- type Page
- func (p *Page) Contains(addr uint64) bool
- func (p *Page) Intersect(addr, size uint64) (uint64, uint64, bool)
- func (p *Page) Overlaps(addr, size uint64) bool
- func (p *Page) Slice(addr, size uint64) *Page
- func (p *Page) Split(addr, size uint64) (left, right *Page)
- func (p *Page) String() string
- func (pg *Page) Write(addr uint64, p []byte)
- type Pages
- type Regs
Constants ¶
const ( MEM_WRITE_UNMAPPED = uc.MEM_WRITE_UNMAPPED MEM_READ_UNMAPPED = uc.MEM_READ_UNMAPPED MEM_FETCH_UNMAPPED = uc.MEM_FETCH_UNMAPPED MEM_WRITE_PROT = uc.MEM_WRITE_PROT MEM_READ_PROT = uc.MEM_READ_PROT MEM_FETCH_PROT = uc.MEM_FETCH_PROT MEM_PROT = MEM_WRITE_PROT | MEM_READ_PROT | MEM_FETCH_PROT MEM_UNMAPPED = MEM_READ_UNMAPPED | MEM_WRITE_UNMAPPED | MEM_FETCH_UNMAPPED )
these errors are used for HOOK_MEM_ERR
const ( PROT_NONE = uc.PROT_NONE PROT_READ = uc.PROT_READ PROT_WRITE = uc.PROT_WRITE PROT_EXEC = uc.PROT_EXEC PROT_ALL = uc.PROT_ALL )
these constants are used for memory protections
these constants are used in a hook to specify the type of memory access
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cpu ¶
func (*Cpu) ContextRestore ¶
func (*Cpu) ContextSave ¶
func (*Cpu) HookAllMemErr ¶
HookAllMemErr TODO figure out what it does
func (*Cpu) HookInstruction ¶
func (u *Cpu) HookInstruction(cb InstructionHook, start, end uint64, instruction int) (uc.Hook, error)
HookInstruction TODO figure out what it does
func (*Cpu) HookInterrupt ¶
HookInterrupt TODO figure out what it does
func (*Cpu) HookMemErr ¶
HookMemErr TODO figure out what it does
func (*Cpu) Mem ¶
func (c *Cpu) Mem() io.ReadWriteSeeker
Mem gives access to the memory of the process.
type MemErrHook ¶
MemErrHook is used to hook memory access errors
type MemSim ¶
type MemSim struct {
Mem Pages
}
func (*MemSim) Map ¶
Maps <addr> - <addr>+<size> and protects with prot. If zero is false, it first copies any existing data in this range to the new mapping. Any overlapping regions will be unmapped, then then the mapping list will be sorted by address to allow binary search and simpler reads / bound checks.
func (*MemSim) Prot ¶
this is *exactly* unmap, but the "middle" pages of each split are re-protected
func (*MemSim) RangeValid ¶
Checks whether the address range exists in the currently-mapped memory. If prot > 0, ensures that each region has the entire protection mask provided.
type Page ¶
func (*Page) Slice ¶
// how to slice a page off1 len1 addr1 | size1 | | | [ page ] [ ] [ [ slice ] ]
| | addr2 size2 off2 len2
delta = addr2 - addr1
if delta < len1 { len2 = len1 - delta off2 = off1 + delta }
func (*Page) Split ¶
// how to split a page, simple edition // laddr rsize | lsize raddr | [------|----page---|-------] [-left-][---mid---][-right-] | | | | | addr size | paddr psize
laddr = paddr lsize = addr - paddr
raddr = addr + size rsize = (paddr + psize) - raddr
// how to split a page, overlap edition // addr size | | [--------mid---------]
[--page--] | | paddr psize
pad(addr, paddr - addr, 0) pend = paddr + psize pad(pend, size - pend, 0)
type Regs ¶
type Regs struct {
// contains filtered or unexported fields
}
implements register and context methods conforming to cpu.Cpu TODO: maps are slow. []uint64 would be faster, but enum lookups would require a second []bool (to check if an enum is valid) and the array size could become very large if someone uses a large enum another option would be to switch between map and array based on max enum and yet another would be to reject too-large enums (force uint16 in initialization?)
func (*Regs) ContextRestore ¶
func (*Regs) ContextSave ¶
handling ContextSave in the register file either requires you to store important cpu state (like flags) in registers or wrap ContextSave/ContextRestore with your own functions