Skip to content

Commit e61c142

Browse files
committed
Added: GitModuleHandleEx
1 parent fc13c4a commit e61c142

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

kernel32/kernel32.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5+
//go:build windows
56
// +build windows
67

78
package kernel32
@@ -25,6 +26,7 @@ var (
2526
getLocaleInfo *windows.LazyProc
2627
getLogicalDriveStrings *windows.LazyProc
2728
getModuleHandle *windows.LazyProc
29+
getModuleHandleExW *windows.LazyProc
2830
getNumberFormat *windows.LazyProc
2931
getPhysicallyInstalledSystemMemory *windows.LazyProc
3032
getProfileString *windows.LazyProc
@@ -61,6 +63,7 @@ func init() {
6163
getLocaleInfo = libkernel32.NewProc("GetLocaleInfoW")
6264
getLogicalDriveStrings = libkernel32.NewProc("GetLogicalDriveStringsW")
6365
getModuleHandle = libkernel32.NewProc("GetModuleHandleW")
66+
getModuleHandleExW = libkernel32.NewProc("GetModuleHandleExW")
6467
getNumberFormat = libkernel32.NewProc("GetNumberFormatW")
6568
getPhysicallyInstalledSystemMemory = libkernel32.NewProc("GetPhysicallyInstalledSystemMemory")
6669
getProfileString = libkernel32.NewProc("GetProfileStringW")

kernel32/kernel32_func.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5+
//go:build windows
56
// +build windows
67

78
package kernel32
@@ -128,6 +129,14 @@ func GetModuleHandle(lpModuleName *uint16) HINSTANCE {
128129
return HINSTANCE(ret)
129130
}
130131

132+
func GetModuleHandleEx(flags uint32, moduleName *uint16, module *handle.HWND) (err error) {
133+
r1, _, e1 := syscall.Syscall(getModuleHandleExW.Addr(), 3, uintptr(flags), uintptr(unsafe.Pointer(moduleName)), uintptr(unsafe.Pointer(module)))
134+
if r1 == 0 {
135+
err = e1
136+
}
137+
return
138+
}
139+
131140
func GetNumberFormat(Locale LCID, dwFlags uint32, lpValue *uint16, lpFormat *NUMBERFMT, lpNumberStr *uint16, cchNumber int32) int32 {
132141
ret, _, _ := syscall.Syscall6(getNumberFormat.Addr(), 6,
133142
uintptr(Locale),

0 commit comments

Comments
 (0)