forked from JamesHovious/w32
-
Notifications
You must be signed in to change notification settings - Fork 0
/
writeprocessmemory.go
55 lines (46 loc) · 1.25 KB
/
writeprocessmemory.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
package main
import (
"fmt"
"github.com/wraken/w32"
)
func main() {
//To make this work, you need to find a process ID and a memory address to grab from
processHex := "006B0E0"
memoryHex := "00287B08"
//Convert hex address to uint32
processAddr, err := w32.HexToUint32(processHex)
if err != nil {
fmt.Println("Error with process address:", err.Error())
return
}
//&w32.PROCESS_VM_WRITE&w32.PROCESS_VM_OPERATION&w32.PROCESS_VM_READ
//Open a process handle for reading
handle, err := w32.OpenProcess(w32.PROCESS_ALL_ACCESS, false, processAddr)
if err != nil {
fmt.Println("Error opening process:", err.Error())
return
}
//Convert hex address to uint32
memoryAddr, err := w32.HexToUint32(memoryHex)
if err != nil {
fmt.Println("Error with memory address:", err.Error())
return
}
//Read memory and place into data
data, err := w32.ReadProcessMemoryAsUint32(handle, memoryAddr)
if err != nil {
fmt.Println("Error Reading memory:", err.Error())
return
} else {
fmt.Println("Success! Read memory:", data)
}
//Change value +50
data += 50
err = w32.WriteProcessMemoryAsUint32(handle, memoryAddr, data)
if err != nil {
fmt.Println("Error Writing memory:", err.Error())
return
} else {
fmt.Println("Success! Write memory:", data)
}
}