MCPcopy Create free account
hub / github.com/Binject/universal / findMachoPtr

Function findMachoPtr

loader_darwin.go:343–364  ·  view source on GitHub ↗
(addr uintptr)

Source from the content-addressed store, hash-verified

341}
342
343func findMachoPtr(addr uintptr) (uintptr, error) {
344 var (
345 base uintptr
346 header uint32
347 err error = fmt.Errorf("could not find macho")
348 )
349 idx := addr
350 ptr := uintptr(*(*uint64)(unsafe.Pointer(idx)))
351 for {
352 if isPtrValid(ptr) {
353 header = *(*uint32)(unsafe.Pointer(ptr))
354 if header == macho.Magic64 {
355 base = ptr
356 err = nil
357 break
358 }
359 }
360 idx += 8
361 ptr = uintptr(*(*uint64)(unsafe.Pointer(idx)))
362 }
363 return base, err
364}
365
366// Call - call a function in a loaded library
367func (l *Library) Call(functionName string, args ...uintptr) (uintptr, error) {

Callers 1

LoadLibraryImplFunction · 0.85

Calls 1

isPtrValidFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…