allow to start new memory process from specific PID
This commit is contained in:
@@ -3,6 +3,7 @@ package memory
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
|
"errors"
|
||||||
"golang.org/x/sys/windows"
|
"golang.org/x/sys/windows"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
@@ -37,6 +38,25 @@ func NewProcess() (Process, error) {
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewProcessForPID(pid uint32) (Process, error) {
|
||||||
|
module, found := getMainModule(pid)
|
||||||
|
if found {
|
||||||
|
return Process{}, errors.New("no module found for the specified PID")
|
||||||
|
}
|
||||||
|
|
||||||
|
h, err := windows.OpenProcess(0x0010, false, module.ProcessID)
|
||||||
|
if err != nil {
|
||||||
|
return Process{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return Process{
|
||||||
|
handler: h,
|
||||||
|
pid: module.ProcessID,
|
||||||
|
moduleBaseAddressPtr: module.ModuleBaseAddress,
|
||||||
|
moduleBaseSize: module.ModuleBaseSize,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
func getGameModule() (ModuleInfo, error) {
|
func getGameModule() (ModuleInfo, error) {
|
||||||
processes := make([]uint32, 2048)
|
processes := make([]uint32, 2048)
|
||||||
length := uint32(0)
|
length := uint32(0)
|
||||||
|
|||||||
Reference in New Issue
Block a user