-
Notifications
You must be signed in to change notification settings - Fork 7
/
outside_unix.go
58 lines (46 loc) · 973 Bytes
/
outside_unix.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright (c) 2013 Tony Wilson. All rights reserved.
// See LICENCE file for permissions and restrictions.
// +build linux
package outside
import (
"github.com/tHinqa/outside/dl"
"unsafe"
)
const (
lazy = 1 << iota
now
global
)
type sdll struct {
name string
handle unsafe.Pointer
}
type sproc struct {
dll *sdll
Name string
address uintptr
}
func load(n string) (p *sdll, e error) {
h, e := dl.Load(n)
if e != nil {
return
}
return &sdll{n, h}, e
}
func (sd *sdll) mustFindProc(n string) (sp *sproc) {
a := dl.MustFindProc(sd.name, sd.handle, n)
return &sproc{sd, n, a}
}
func (sd *sdll) findProc(n string) (sp *sproc, e error) {
a, e := dl.FindProc(sd.name, sd.handle, n)
if e == nil {
sp = &sproc{sd, n, a}
}
return
}
//TODO(t): add error handling
func (sd *sdll) release() int {
return dl.Release(sd.handle)
}
func (sp *sproc) addr() uintptr { return sp.address }
func newCallback(cb interface{}) (n uintptr) { return }