-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmessage.go
More file actions
37 lines (29 loc) · 1.05 KB
/
message.go
File metadata and controls
37 lines (29 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package main
import (
dll "goShellcodeRunner/DLL"
"syscall"
"unsafe"
"golang.org/x/sys/windows"
)
func ShowMessageBoxes() {
// In Win32, a window object is identified by a value known as a window handle.
// And the type of a window handle is an HWND
// https://learn.microsoft.com/en-us/windows/apps/develop/ui-input/retrieve-hwnd
hWnd := uintptr(0)
windows.MessageBox(
windows.HWND(hWnd),
windows.StringToUTF16Ptr("Windows package!!"),
windows.StringToUTF16Ptr("MessageBoxx"),
windows.MB_OKCANCEL)
// https://pkg.go.dev/syscall?GOOS=windows#LazyDLL
// A LazyDLL implements access to a single DLL.
// It will delay the load of the DLL until the first call to its LazyDLL.Handle method or to one of its LazyProc's Addr method.
procMsgBox := dll.Use32dll.NewProc("MessageBoxW")
lpText, _ := syscall.UTF16PtrFromString("Used Syscall Package")
lpCaption, _ := syscall.UTF16PtrFromString("DLL Imported Message")
uType := uint(2)
procMsgBox.Call(hWnd,
uintptr(unsafe.Pointer(lpText)),
uintptr(unsafe.Pointer(lpCaption)),
uintptr(uType))
}