Пример #1
0
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
	}

	//Open a process handle for reading
	handle, err := w32.OpenProcess(w32.PROCESS_VM_READ, 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)
	}
}
Пример #2
0
//This is an example to show how to read process memory and convert it to a struct
func main() {
	for {
		processAddr, err := w32.HexToUint32("00BEF28")
		if err != nil {
			fmt.Println("Error with process address:", err.Error())
			return
		}

		handle, err := w32.OpenProcess(w32.PROCESS_VM_READ, false, processAddr)
		if err != nil {
			fmt.Println("Error opening process:", err.Error())
			return
		}
		player := GetPlayerMemory(handle, "37F7E868")
		fmt.Println("State:", player.SitState, "Name:", player.GetFirstName(), "LastName:", player.GetLastName(), "HP:", player.CurHP, "/", player.MaxHP, "SP:", player.CurSP, "/", player.MaxSP)
		time.Sleep(1 * time.Second)
	}
}
Пример #3
0
func GetPlayerMemory(handle w32.HANDLE, addr string) (player Player) {
	memoryAddr, err := w32.HexToUint32(addr)
	if err != nil {
		fmt.Println("Error with memory address:", err.Error())
		return
	}

	//fmt.Println("Grabbing size:", unsafe.Sizeof(player))
	data, err := w32.ReadProcessMemory(handle, memoryAddr, uint(unsafe.Sizeof(player)))
	if err != nil {
		fmt.Println("Error Reading memory:", err.Error())
		return
	} else {
		fmt.Println("Success! Read memory:", data)
	}

	buffer := bytes.NewBuffer(data)
	binary.Read(buffer, binary.LittleEndian, &player)
	return
}