Skip to content

Commit 4b7c180

Browse files
committed
memmod: do not use IsBadReadPtr
It should be enough to check for the trailing zero name. Signed-off-by: Jason A. Donenfeld <[email protected]>
1 parent 1bc997d commit 4b7c180

File tree

4 files changed

+1
-61
lines changed

4 files changed

+1
-61
lines changed

tun/wintun/memmod/memmod_windows.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ func (module *Module) buildImportTable() error {
312312

313313
module.modules = make([]windows.Handle, 0, 16)
314314
importDesc := (*IMAGE_IMPORT_DESCRIPTOR)(a2p(module.codeBase + uintptr(directory.VirtualAddress)))
315-
for !isBadReadPtr(uintptr(unsafe.Pointer(importDesc)), unsafe.Sizeof(*importDesc)) && importDesc.Name != 0 {
315+
for importDesc.Name != 0 {
316316
handle, err := windows.LoadLibraryEx(windows.BytePtrToString((*byte)(a2p(module.codeBase+uintptr(importDesc.Name)))), 0, windows.LOAD_LIBRARY_SEARCH_SYSTEM32)
317317
if err != nil {
318318
return fmt.Errorf("Error loading module: %w", err)

tun/wintun/memmod/mksyscall.go

Lines changed: 0 additions & 8 deletions
This file was deleted.

tun/wintun/memmod/syscall_windows.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,6 @@ const (
324324
DLL_PROCESS_DETACH = 0
325325
)
326326

327-
//sys isBadReadPtr(addr uintptr, ucb uintptr) (ret bool) = kernel32.IsBadReadPtr
328-
329327
type SYSTEM_INFO struct {
330328
ProcessorArchitecture uint16
331329
Reserved uint16

tun/wintun/memmod/zsyscall_windows.go

Lines changed: 0 additions & 50 deletions
This file was deleted.

0 commit comments

Comments
 (0)