Documentation
¶
Index ¶
- func GetBase() uintptr
- func GetHandleProcess() uintptr
- func GetPtrUnsafe(_base uintptr, _offsets ...uintptr) (ptr uintptr)
- func GetValUnsafe(base uintptr, offsets ...uintptr) (val uintptr)
- func Unprotect(whereFrom, nSize uintptr) (protectBack func() error, err error)
- func WriteProcessMemory(whereFrom uintptr, writeWhat []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetPtrUnsafe ¶
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 ¶
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 ¶
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 ¶
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.