本文整理汇总了Golang中syscall.DLL.MustFindProc方法的典型用法代码示例。如果您正苦于以下问题:Golang DLL.MustFindProc方法的具体用法?Golang DLL.MustFindProc怎么用?Golang DLL.MustFindProc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类syscall.DLL
的用法示例。
在下文中一共展示了DLL.MustFindProc方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: runOne
func (test *cbTest) runOne(t *testing.T, dll *syscall.DLL, proc string, cb uintptr) {
defer func() {
if r := recover(); r != nil {
t.Errorf("dll call %v(..., %d) failed: %v", proc, test.param, r)
}
}()
dll.MustFindProc(proc).Call(cb, test.param)
}
示例2: resumeChildThread
func resumeChildThread(kernel32 *syscall.DLL, childpid int) error {
_OpenThread := kernel32.MustFindProc("OpenThread")
_ResumeThread := kernel32.MustFindProc("ResumeThread")
_Thread32First := kernel32.MustFindProc("Thread32First")
_Thread32Next := kernel32.MustFindProc("Thread32Next")
snapshot, err := syscall.CreateToolhelp32Snapshot(syscall.TH32CS_SNAPTHREAD, 0)
if err != nil {
return err
}
defer syscall.CloseHandle(snapshot)
const _THREAD_SUSPEND_RESUME = 0x0002
type ThreadEntry32 struct {
Size uint32
tUsage uint32
ThreadID uint32
OwnerProcessID uint32
BasePri int32
DeltaPri int32
Flags uint32
}
var te ThreadEntry32
te.Size = uint32(unsafe.Sizeof(te))
ret, _, err := _Thread32First.Call(uintptr(snapshot), uintptr(unsafe.Pointer(&te)))
if ret == 0 {
return err
}
for te.OwnerProcessID != uint32(childpid) {
ret, _, err = _Thread32Next.Call(uintptr(snapshot), uintptr(unsafe.Pointer(&te)))
if ret == 0 {
return err
}
}
h, _, err := _OpenThread.Call(_THREAD_SUSPEND_RESUME, 1, uintptr(te.ThreadID))
if h == 0 {
return err
}
defer syscall.Close(syscall.Handle(h))
ret, _, err = _ResumeThread.Call(h)
if ret == 0xffffffff {
return err
}
return nil
}