aboutsummaryrefslogtreecommitdiffstats
path: root/tun/wintun/memmod/memmod_windows.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2020-11-27 13:13:45 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2020-11-27 13:13:45 +0100
commitb6303091fc8c11cf86b92e9c4287c0ba74e77e87 (patch)
tree349499c7c01fd63e80e4bc01b2f196c67f567abc /tun/wintun/memmod/memmod_windows.go
parentwintun: log when reboot is suggested by Windows (diff)
downloadwireguard-go-b6303091fc8c11cf86b92e9c4287c0ba74e77e87.tar.xz
wireguard-go-b6303091fc8c11cf86b92e9c4287c0ba74e77e87.zip
memmod: fix import loading function usage
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'tun/wintun/memmod/memmod_windows.go')
-rw-r--r--tun/wintun/memmod/memmod_windows.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/tun/wintun/memmod/memmod_windows.go b/tun/wintun/memmod/memmod_windows.go
index 13f28ef..b9d7783 100644
--- a/tun/wintun/memmod/memmod_windows.go
+++ b/tun/wintun/memmod/memmod_windows.go
@@ -313,7 +313,7 @@ func (module *Module) buildImportTable() error {
module.modules = make([]windows.Handle, 0, 16)
importDesc := (*IMAGE_IMPORT_DESCRIPTOR)(a2p(module.codeBase + uintptr(directory.VirtualAddress)))
for !isBadReadPtr(uintptr(unsafe.Pointer(importDesc)), unsafe.Sizeof(*importDesc)) && importDesc.Name != 0 {
- handle, err := loadLibraryA((*byte)(a2p(module.codeBase + uintptr(importDesc.Name))))
+ handle, err := windows.LoadLibraryEx(windows.BytePtrToString((*byte)(a2p(module.codeBase + uintptr(importDesc.Name)))), 0, windows.LOAD_LIBRARY_SEARCH_SYSTEM32)
if err != nil {
return fmt.Errorf("Error loading module: %w", err)
}
@@ -328,10 +328,10 @@ func (module *Module) buildImportTable() error {
}
for *thunkRef != 0 {
if IMAGE_SNAP_BY_ORDINAL(*thunkRef) {
- *funcRef, err = getProcAddress(handle, (*byte)(a2p(IMAGE_ORDINAL(*thunkRef))))
+ *funcRef, err = windows.GetProcAddressByOrdinal(handle, IMAGE_ORDINAL(*thunkRef))
} else {
thunkData := (*IMAGE_IMPORT_BY_NAME)(a2p(module.codeBase + *thunkRef))
- *funcRef, err = getProcAddress(handle, &thunkData.Name[0])
+ *funcRef, err = windows.GetProcAddress(handle, windows.BytePtrToString(&thunkData.Name[0]))
}
if err != nil {
windows.FreeLibrary(handle)