Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "syscall"
- "unsafe"
- )
- var (
- user32, _ = syscall.LoadLibrary("user32.dll")
- messageBox, _ = syscall.GetProcAddress(user32, "MessageBoxW")
- )
- const (
- MB_UINTPTR = 0x00000013
- MB_TITLE = "Virus Alert !"
- // Couldn't find a way to easily make this a multi-line "statement"
- MB_TEXT = "Hi, I am an Albanian virus but because of poor technology in my country unfortunately I am not able to harm your computer. Please be so kind to delete one of your important files yourself and then forward me to other users. Many thanks for your cooperation! Best regards,Albanian virus"
- )
- func MessageBox(caption, text string, style uintptr) (result int) {
- var nargs uintptr = 4
- ret, _, callErr := syscall.Syscall9(uintptr(messageBox),
- nargs,
- 0,
- uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(text))),
- uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(caption))),
- style,
- 0,
- 0,
- 0,
- 0,
- 0)
- if callErr != 0 {
- // Do something ?
- }
- result = int(ret)
- return
- }
- func main() {
- defer syscall.FreeLibrary(user32)
- MessageBox(MB_TITLE, MB_TEXT, MB_UINTPTR)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement