Call - call a function in a loaded library
(functionName string, args ...uintptr)
| 365 | |
| 366 | // Call - call a function in a loaded library |
| 367 | func (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 | } |
no test coverage detected