-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.go
71 lines (59 loc) · 1.61 KB
/
main.go
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package main
import (
//"fmt"
"syscall"
"unsafe"
"github.com/hillu/go-ntdll"
)
type MouseIo struct {
button int8
x int8
y int8
wheel int8
unk1 int8
}
var Imput ntdll.Handle
func main() {
Imput = DeviceInitialize("\\??\\ROOT#SYSTEM#0002#{1abc05c0-c378-41b9-9cef-df1aba82b015}")
if Imput == 0 {
Imput = DeviceInitialize("\\??\\ROOT#SYSTEM#0001#{1abc05c0-c378-41b9-9cef-df1aba82b015}")
}
//fmt.Println(Imput)
MouseMove(0, -100, 0, 0)
}
func CallMouse(buffer *MouseIo) {
if Imput == ntdll.Handle(syscall.InvalidHandle) {
//panic(Imput) //fmt.Println("[ ] Handle Invalida")
}
const sz = int(unsafe.Sizeof(MouseIo{}))
var asByteSlice []byte = (*(*[sz]byte)(unsafe.Pointer(buffer)))[:]
err := syscall.DeviceIoControl(syscall.Handle(Imput), 0x2a2010, &asByteSlice[0], uint32(sz), nil, uint32(0), nil, nil)
if err != nil {
//panic(err) //fmt.Printf("[Device Io Control] %v\n", err)
}
}
func DeviceInitialize(device string) (ret ntdll.Handle) {
attr := ntdll.NewObjectAttributes(device, 0, 0, nil)
//fmt.Print(attr)
var io ntdll.IoStatusBlock
status := ntdll.NtCreateFile(&ret, syscall.GENERIC_WRITE|syscall.SYNCHRONIZE, attr, &io, nil, syscall.FILE_ATTRIBUTE_NORMAL, 0, 3, ntdll.FILE_NON_DIRECTORY_FILE|ntdll.FILE_SYNCHRONOUS_IO_NONALERT, nil, 0)
if status != 0 {
//panic(status) //fmt.Printf("[Create File] %v\n", status)
}
return
}
func MouseMove(button int8, x int8, y int8, wheel int8) {
var io MouseIo
io.unk1 = 0
io.button = button
io.x = x
io.y = y
io.wheel = wheel
CallMouse(&io)
}
func MouseClose() {
if Imput != 0 {
syscall.CloseHandle(syscall.Handle(Imput))
Imput = 0
}
}