-
Notifications
You must be signed in to change notification settings - Fork 1
/
process.go
35 lines (27 loc) · 851 Bytes
/
process.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
package vmmgo
import "unsafe"
func (inst *VMM) ProcessGetAll() (pid []int32, err error) {
var pcPIDs uintptr
result, _, _ := call("VMMDLL_PidList", initializeResult, 0, uintptr(unsafe.Pointer(&pcPIDs)))
if result == 0 {
// error
return nil, ERR_CALL
}
pids := make([]int32, pcPIDs)
result, _, _ = call("VMMDLL_PidList", initializeResult, uintptr(unsafe.Pointer(&pids[0])), uintptr(unsafe.Pointer(&pcPIDs)))
if result == 0 {
// error
return nil, ERR_CALL
}
return pids, nil
}
func (inst *VMM) PidGetFromName(processName string) (pid int32, err error) {
szProcName := bytePtrFromString(processName)
var pdwPID uint32
result, _, _ := call("VMMDLL_PidGetFromName", initializeResult, uintptr(unsafe.Pointer(szProcName)),
uintptr(unsafe.Pointer(&pdwPID)))
if result == 0 {
return 0, ERR_CALL
}
return int32(pdwPID), nil
}