MCPcopy Create free account
hub / github.com/rabbitstack/fibratus / Decode

Function Decode

pkg/util/threadcontext/context.go:74–88  ·  view source on GitHub ↗

Decode reads the thread context structure from the given process memory and at the specified base address. Returns the decoded Context struct or nil if the data cannot be read from the remote process address space.

(pid uint32, addr va.Address)

Source from the content-addressed store, hash-verified

72// or nil if the data cannot be read from the remote
73// process address space.
74func Decode(pid uint32, addr va.Address) *Context {
75 proc, err := windows.OpenProcess(windows.PROCESS_QUERY_INFORMATION|windows.PROCESS_VM_READ, false, pid)
76 if err != nil {
77 return nil
78 }
79 defer windows.Close(proc)
80
81 size := uint(unsafe.Sizeof(Context{}))
82 ctx := va.ReadArea(proc, addr.Uintptr(), size, size, false)
83 if !va.Zeroed(ctx) {
84 return (*Context)(unsafe.Pointer(&ctx[0]))
85 }
86
87 return nil
88}
89
90// Rip returns the address stored in the instruction pointer register.
91func Rip(pid uint32, addr va.Address) va.Address {

Callers 2

TestDecodeFunction · 0.70
RipFunction · 0.70

Calls 4

ReadAreaFunction · 0.92
ZeroedFunction · 0.92
UintptrMethod · 0.80
CloseMethod · 0.65

Tested by 1

TestDecodeFunction · 0.56