Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add generics helpers for nt calls args
- Loading branch information
Showing
2 changed files
with
116 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package loader | ||
|
||
import ( | ||
"unsafe" | ||
|
||
"golang.org/x/sys/windows" | ||
) | ||
|
||
const ( | ||
nullptr = uintptr(0) | ||
) | ||
|
||
type ToPtr interface { | ||
int | uint | uint32 | uint16 | uint8 | uintptr | ||
} | ||
|
||
type WinTypesPtr interface { | ||
windows.Handle | | ||
windows.SecurityAttributes | | ||
windows.StartupInfo | | ||
windows.ProcessInformation | ||
} | ||
|
||
func ptr[T ToPtr](v T) uintptr { | ||
return uintptr(v) | ||
} | ||
|
||
func ptr2ptr[T ToPtr | WinTypesPtr](v *T) uintptr { | ||
if v == nil { | ||
return nullptr | ||
} | ||
return uintptr(unsafe.Pointer(v)) | ||
} |