MCPcopy Create free account
hub / github.com/NYPDK/cs2go / getModuleBaseAddress

Function getModuleBaseAddress

memory.go:41–65  ·  view source on GitHub ↗
(pid int, moduleName string)

Source from the content-addressed store, hash-verified

39}
40
41func getModuleBaseAddress(pid int, moduleName string) (uintptr, error) {
42 snapshot, err := windows.CreateToolhelp32Snapshot(windows.TH32CS_SNAPMODULE, uint32(pid))
43 if err != nil {
44 return 0, err
45 }
46 defer windows.CloseHandle(snapshot)
47
48 var me32 windows.ModuleEntry32
49 me32.Size = uint32(unsafe.Sizeof(me32))
50
51 if windows.Module32First(snapshot, &me32) != nil {
52 return 0, fmt.Errorf("Module32First failed")
53 }
54
55 for {
56 if strings.EqualFold(windows.UTF16ToString(me32.Module[:]), moduleName) {
57 return uintptr(me32.ModBaseAddr), nil
58 }
59 if windows.Module32Next(snapshot, &me32) != nil {
60 break
61 }
62 }
63
64 return 0, fmt.Errorf("module not found")
65}
66
67func read(process windows.Handle, address uintptr, value interface{}) error {
68 var buffer []byte

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected