Skip to content

Instantly share code, notes, and snippets.

@NaniteFactory
Last active May 21, 2025 02:27
Show Gist options
  • Select an option

  • Save NaniteFactory/a4adce05a5cf7b56a584d36d3cce21b6 to your computer and use it in GitHub Desktop.

Select an option

Save NaniteFactory/a4adce05a5cf7b56a584d36d3cce21b6 to your computer and use it in GitHub Desktop.
A way to get 'Windows process module (.exe) handle' of process itself in Golang.
package main
import "syscall"
func main() {
// equivalent to (HANDLE)GetModuleHandle(NULL); in C
handle, _, _ := syscall.Syscall(
syscall.NewLazyDLL("kernel32.dll").NewProc("GetModuleHandleW").Addr(),
1, 0, 0, 0,
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment