procmem

package module
v0.0.0-...-95229f0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 20, 2023 License: MIT Imports: 5 Imported by: 0

README

Process Memory Read-Writer on Unix and Windows

Usage

package main

import (
	"github.com/avelex/procmem"
)

func main() {
    pid := 164433
    address := 0xc00012c008
    proc := procmem.NewProcess(pid) 

    want := "Hello"

    got, err := proc.ReadString(uintptr(address), len(want))
    if err != nil {
        ...
    }

    fmt.Println(want == got) // true

    newString := "World"

    if err := proc.WriteString(uintptr(ptr), newString); err != nil {
        ...
    }

    got, err = proc.ReadString(uintptr(address), len(newString))
    if err != nil {
        ...
    }

    fmt.Println(newString == got) // true
}

Documentation

Index

Constants

View Source
const (
	BYTE_LEN    = 1
	UINT32_LEN  = 4
	UINT64_LEN  = 8
	FLOAT32_LEN = 4
	FLOAT64_LEN = 8
)

Variables

This section is empty.

Functions

func BytesToFloat32

func BytesToFloat32(bytes []byte) float32

func BytesToFloat64

func BytesToFloat64(bytes []byte) float64

func Float32ToBytes

func Float32ToBytes(v float32) []byte

func Float64ToBytes

func Float64ToBytes(v float64) []byte

func Read

func Read(pid int, dst []byte, address uintptr, size uint64) (n int, err error)

func ReadFloat32

func ReadFloat32(pid int, addres uintptr) (float32, error)

func ReadFloat64

func ReadFloat64(pid int, addres uintptr) (float64, error)

func ReadGoString

func ReadGoString(pid int, address uintptr, size uint64) (string, error)

func ReadString

func ReadString(pid int, address uintptr, size uint64) (string, error)

func ReadUint32

func ReadUint32(pid int, address uintptr) (uint32, error)

func ReadUint64

func ReadUint64(pid int, address uintptr) (uint64, error)

func Write

func Write(pid int, address uintptr, data []byte) error

func WriteFloat32

func WriteFloat32(pid int, addres uintptr, value float32) error

func WriteFloat64

func WriteFloat64(pid int, addres uintptr, value float64) error

func WriteString

func WriteString(pid int, address uintptr, value string) error

if your dist is golang program, it will be work if string it's array of char

func WriteUint32

func WriteUint32(pid int, address uintptr, value uint32) error

func WriteUint64

func WriteUint64(pid int, address uintptr, value uint64) error

Types

type Process

type Process interface {
	Read(dst []byte, address uintptr, size uint64) (n int, err error)
	ReadUint32(address uintptr) (uint32, error)
	ReadUint64(address uintptr) (uint64, error)
	ReadFloat32(addres uintptr) (float32, error)
	ReadFloat64(addres uintptr) (float64, error)
	ReadString(address uintptr, size uint64) (string, error)
	ReadGoString(address uintptr, size uint64) (string, error)
	Write(address uintptr, data []byte) error
	WriteUint32(address uintptr, value uint32) error
	WriteUint64(address uintptr, value uint64) error
	WriteString(address uintptr, value string) error
	WriteFloat32(addres uintptr, value float32) error
	WriteFloat64(addres uintptr, value float64) error
	// Do not close the certain process
	Close() error
}

func NewProcess

func NewProcess(pid int) Process

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL