memory

package module
v0.0.0-...-81e971c Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2018 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetBase

func GetBase() uintptr

GetBase () of our main module.

func GetHandleProcess

func GetHandleProcess() uintptr

GetHandleProcess () returns hProcess.

func GetPtrUnsafe

func GetPtrUnsafe(_base uintptr, _offsets ...uintptr) (ptr uintptr)

GetPtrUnsafe () returns a ptr. Params must be in order.

This function can cause a fatal for accessing a fault address, which just terminates the entire program and can't be handled any way.

e.g. ``` unexpected fault address 0xdd7ae08 fatal error: fault ```

There are other types of panic that can be handeled though. To catch and handle the other kinds of thrown exceptions, such as "runtime error: invalid memory address or nil pointer dereference", you might want to do something like this below:

defer func() {
	r := recover()
	if r != nil {
		err = r.(error)
	}
}()

In a nutshell, you just can't recover from the invalid memory access error (unexpected fault address), while the nil ptr exception can be handled at runtime.

func GetValUnsafe

func GetValUnsafe(base uintptr, offsets ...uintptr) (val uintptr)

GetValUnsafe () returns a ptr. Params must be in order.

This function can cause a fatal for accessing a fault address, which just terminates the entire program and can't be handled any way.

e.g. ``` unexpected fault address 0xdd7ae08 fatal error: fault ```

There are other types of panic that can be handled though. To catch and handle the other kinds of thrown exceptions, such as "runtime error: invalid memory address or nil pointer dereference", you might want to do something like this below:

defer func() {
	r := recover()
	if r != nil {
		err = r.(error)
	}
}()

In summary, you just can't recover from the invalid memory access error (unexpected fault address), while the nil ptr exception can be handled at runtime.

func Unprotect

func Unprotect(whereFrom, nSize uintptr) (protectBack func() error, err error)

Unprotect a virtual memory region in order to get a permission to read/write there and get a way to protect it back after that. nSize: Integer, the length in bytes.

func WriteProcessMemory

func WriteProcessMemory(whereFrom uintptr, writeWhat []byte) error

WriteProcessMemory is probably the safest way to write something to memory.

Another way to write something unsafely to a memory region is as in,

arr := (*[6]byte)(unsafe.Pointer(uintptr(0x004014D0))) // Where to write. *arr = [6]byte{0x90, 0x90, 0x90, 0x90, 0x90, 0x90} // AOB what to write.

Types

This section is empty.

Jump to

Keyboard shortcuts

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