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

Method Call

loader_darwin.go:367–391  ·  view source on GitHub ↗

Call - call a function in a loaded library

(functionName string, args ...uintptr)

Source from the content-addressed store, hash-verified

365
366// Call - call a function in a loaded library
367func (l *Library) Call(functionName string, args ...uintptr) (uintptr, error) {
368 var (
369 proc uintptr
370 funcPtr uint64
371 ok bool
372 )
373 if len(functionName) > 0 && functionName[0] != '_' {
374 functionName = "_" + functionName
375 } // OSX has underscore-prefixed exports
376
377 if !isSierra() {
378 proc, ok = l.FindProc(functionName)
379 } else {
380 // Can't rely on FindProc for Sierra and up since
381 // the BaseAddress is a pseudo handle to the lib,
382 // not the actual address.
383 funcPtr, ok = l.Exports[functionName]
384 proc = uintptr(funcPtr)
385 }
386 if !ok {
387 return 0, errors.New("Call did not find export " + functionName)
388 }
389 val, err := cdecl.Call(proc, args...)
390 return val, err
391}

Callers 2

LoadLibraryImplFunction · 0.45
LoadLibraryDlopenFunction · 0.45

Calls 2

FindProcMethod · 0.95
isSierraFunction · 0.85

Tested by

no test coverage detected