package main
import (
"fmt"
"syscall"
"unsafe"
)
func main() {
ShareMemName,_ := syscall.BytePtrFromString("ShareMemory")
var sharememname = uintptr(unsafe.Pointer(ShareMemName))
kernet32 := syscall.NewLazyDLL("kernel32.dll")
OpenFileMapping := kernet32.NewProc("OpenFileMappingA")
ptr,_,err := OpenFileMapping.Call(0x0004, 0,sharememname)
if err.Error() != "The operation completed successfully." {
fmt.Println("This:",err)
return
}
ptr,err = syscall.MapViewOfFile(syscall.Handle(ptr), 0x0004, 0)
if err != nil {
fmt.Println("There:",err)
return
}
buf := *(*[60]byte)(unsafe.Pointer(ptr))
fmt.Println(string(buf[:]))
err = syscall.UnmapViewOfFile(ptr)
fmt.Println(err)
}