mirror of
https://github.com/rwinkhart/sys.git
synced 2026-09-03 23:57:32 -04:00
windows: add ModuleEntry32 type and Module32{First,Next} wrappers
Reference: https://docs.microsoft.com/en-us/windows/win32/api/tlhelp32/ns-tlhelp32-moduleentry32w https://docs.microsoft.com/en-us/windows/win32/api/tlhelp32/nf-tlhelp32-module32firstw https://docs.microsoft.com/en-us/windows/win32/api/tlhelp32/nf-tlhelp32-module32nextw Change-Id: I5455cabdbaa8e7e25490f869ca349e3c6f67a0cf Reviewed-on: https://go-review.googlesource.com/c/sys/+/369174 Trust: Tobias Klauser <tobias.klauser@gmail.com> Trust: Patrik Nyblom <pnyb@google.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Patrik Nyblom <pnyb@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Patrik Nyblom <pnyb@google.com>
This commit is contained in:
committed by
Tobias Klauser
parent
fe61309f88
commit
94396e4217
@@ -323,6 +323,8 @@ func NewCallbackCDecl(fn interface{}) uintptr {
|
|||||||
//sys WriteConsole(console Handle, buf *uint16, towrite uint32, written *uint32, reserved *byte) (err error) = kernel32.WriteConsoleW
|
//sys WriteConsole(console Handle, buf *uint16, towrite uint32, written *uint32, reserved *byte) (err error) = kernel32.WriteConsoleW
|
||||||
//sys ReadConsole(console Handle, buf *uint16, toread uint32, read *uint32, inputControl *byte) (err error) = kernel32.ReadConsoleW
|
//sys ReadConsole(console Handle, buf *uint16, toread uint32, read *uint32, inputControl *byte) (err error) = kernel32.ReadConsoleW
|
||||||
//sys CreateToolhelp32Snapshot(flags uint32, processId uint32) (handle Handle, err error) [failretval==InvalidHandle] = kernel32.CreateToolhelp32Snapshot
|
//sys CreateToolhelp32Snapshot(flags uint32, processId uint32) (handle Handle, err error) [failretval==InvalidHandle] = kernel32.CreateToolhelp32Snapshot
|
||||||
|
//sys Module32First(snapshot Handle, moduleEntry *ModuleEntry32) (err error) = kernel32.Module32FirstW
|
||||||
|
//sys Module32Next(snapshot Handle, moduleEntry *ModuleEntry32) (err error) = kernel32.Module32NextW
|
||||||
//sys Process32First(snapshot Handle, procEntry *ProcessEntry32) (err error) = kernel32.Process32FirstW
|
//sys Process32First(snapshot Handle, procEntry *ProcessEntry32) (err error) = kernel32.Process32FirstW
|
||||||
//sys Process32Next(snapshot Handle, procEntry *ProcessEntry32) (err error) = kernel32.Process32NextW
|
//sys Process32Next(snapshot Handle, procEntry *ProcessEntry32) (err error) = kernel32.Process32NextW
|
||||||
//sys Thread32First(snapshot Handle, threadEntry *ThreadEntry32) (err error)
|
//sys Thread32First(snapshot Handle, threadEntry *ThreadEntry32) (err error)
|
||||||
|
|||||||
@@ -156,6 +156,8 @@ const (
|
|||||||
MAX_PATH = 260
|
MAX_PATH = 260
|
||||||
MAX_LONG_PATH = 32768
|
MAX_LONG_PATH = 32768
|
||||||
|
|
||||||
|
MAX_MODULE_NAME32 = 255
|
||||||
|
|
||||||
MAX_COMPUTERNAME_LENGTH = 15
|
MAX_COMPUTERNAME_LENGTH = 15
|
||||||
|
|
||||||
TIME_ZONE_ID_UNKNOWN = 0
|
TIME_ZONE_ID_UNKNOWN = 0
|
||||||
@@ -970,6 +972,21 @@ type ThreadEntry32 struct {
|
|||||||
Flags uint32
|
Flags uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ModuleEntry32 struct {
|
||||||
|
Size uint32
|
||||||
|
ModuleID uint32
|
||||||
|
ProcessID uint32
|
||||||
|
GlblcntUsage uint32
|
||||||
|
ProccntUsage uint32
|
||||||
|
ModBaseAddr uintptr
|
||||||
|
ModBaseSize uint32
|
||||||
|
ModuleHandle Handle
|
||||||
|
Module [MAX_MODULE_NAME32 + 1]uint16
|
||||||
|
ExePath [MAX_PATH]uint16
|
||||||
|
}
|
||||||
|
|
||||||
|
const SizeofModuleEntry32 = unsafe.Sizeof(ModuleEntry32{})
|
||||||
|
|
||||||
type Systemtime struct {
|
type Systemtime struct {
|
||||||
Year uint16
|
Year uint16
|
||||||
Month uint16
|
Month uint16
|
||||||
|
|||||||
@@ -295,6 +295,8 @@ var (
|
|||||||
procLockFileEx = modkernel32.NewProc("LockFileEx")
|
procLockFileEx = modkernel32.NewProc("LockFileEx")
|
||||||
procLockResource = modkernel32.NewProc("LockResource")
|
procLockResource = modkernel32.NewProc("LockResource")
|
||||||
procMapViewOfFile = modkernel32.NewProc("MapViewOfFile")
|
procMapViewOfFile = modkernel32.NewProc("MapViewOfFile")
|
||||||
|
procModule32FirstW = modkernel32.NewProc("Module32FirstW")
|
||||||
|
procModule32NextW = modkernel32.NewProc("Module32NextW")
|
||||||
procMoveFileExW = modkernel32.NewProc("MoveFileExW")
|
procMoveFileExW = modkernel32.NewProc("MoveFileExW")
|
||||||
procMoveFileW = modkernel32.NewProc("MoveFileW")
|
procMoveFileW = modkernel32.NewProc("MoveFileW")
|
||||||
procMultiByteToWideChar = modkernel32.NewProc("MultiByteToWideChar")
|
procMultiByteToWideChar = modkernel32.NewProc("MultiByteToWideChar")
|
||||||
@@ -2567,6 +2569,22 @@ func MapViewOfFile(handle Handle, access uint32, offsetHigh uint32, offsetLow ui
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Module32First(snapshot Handle, moduleEntry *ModuleEntry32) (err error) {
|
||||||
|
r1, _, e1 := syscall.Syscall(procModule32FirstW.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(moduleEntry)), 0)
|
||||||
|
if r1 == 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func Module32Next(snapshot Handle, moduleEntry *ModuleEntry32) (err error) {
|
||||||
|
r1, _, e1 := syscall.Syscall(procModule32NextW.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(moduleEntry)), 0)
|
||||||
|
if r1 == 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func MoveFileEx(from *uint16, to *uint16, flags uint32) (err error) {
|
func MoveFileEx(from *uint16, to *uint16, flags uint32) (err error) {
|
||||||
r1, _, e1 := syscall.Syscall(procMoveFileExW.Addr(), 3, uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(to)), uintptr(flags))
|
r1, _, e1 := syscall.Syscall(procMoveFileExW.Addr(), 3, uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(to)), uintptr(flags))
|
||||||
if r1 == 0 {
|
if r1 == 0 {
|
||||||
|
|||||||
Reference in New Issue
Block a user