@@ -125,10 +125,10 @@ func (p *process) init() error {
125125 var args []string
126126 var cwd string
127127 var ppid int
128- pbi , err := getProcessBasicInformation (handle )
128+ pbi , err := getProcessBasicInformation (syswin . Handle ( handle ) )
129129 if err == nil {
130130 ppid = int (pbi .InheritedFromUniqueProcessID )
131- userProcParams , err := getUserProcessParams (handle , pbi )
131+ userProcParams , err := getUserProcessParams (syswin . Handle ( handle ) , pbi )
132132 if err == nil {
133133 if argsW , err := readProcessUnicodeString (handle , & userProcParams .CommandLine ); err == nil {
134134 args , err = splitCommandline (argsW )
@@ -159,15 +159,16 @@ func (p *process) init() error {
159159 return nil
160160}
161161
162- func getProcessBasicInformation (handle syscall.Handle ) (pbi windows.ProcessBasicInformationStruct , err error ) {
163- actualSize , err := windows .NtQueryInformationProcess (handle , windows .ProcessBasicInformation , unsafe .Pointer (& pbi ), uint32 (windows .SizeOfProcessBasicInformationStruct ))
162+ func getProcessBasicInformation (handle syswin.Handle ) (pbi windows.ProcessBasicInformationStruct , err error ) {
163+ var actualSize uint32
164+ err = syswin .NtQueryInformationProcess (handle , syswin .ProcessBasicInformation , unsafe .Pointer (& pbi ), uint32 (windows .SizeOfProcessBasicInformationStruct ), & actualSize )
164165 if actualSize < uint32 (windows .SizeOfProcessBasicInformationStruct ) {
165166 return pbi , errors .New ("bad size for PROCESS_BASIC_INFORMATION" )
166167 }
167168 return pbi , err
168169}
169170
170- func getUserProcessParams (handle syscall .Handle , pbi windows.ProcessBasicInformationStruct ) (params windows.RtlUserProcessParameters , err error ) {
171+ func getUserProcessParams (handle syswin .Handle , pbi windows.ProcessBasicInformationStruct ) (params windows.RtlUserProcessParameters , err error ) {
171172 const is32bitProc = unsafe .Sizeof (uintptr (0 )) == 4
172173
173174 // Offset of params field within PEB structure.
@@ -180,7 +181,8 @@ func getUserProcessParams(handle syscall.Handle, pbi windows.ProcessBasicInforma
180181 // Read the PEB from the target process memory
181182 pebSize := paramsOffset + 8
182183 peb := make ([]byte , pebSize )
183- nRead , err := windows .ReadProcessMemory (handle , pbi .PebBaseAddress , peb )
184+ var nRead uintptr
185+ err = syswin .ReadProcessMemory (handle , pbi .PebBaseAddress , & peb [0 ], uintptr (pebSize ), & nRead )
184186 if err != nil {
185187 return params , err
186188 }
@@ -193,7 +195,7 @@ func getUserProcessParams(handle syscall.Handle, pbi windows.ProcessBasicInforma
193195
194196 // Read the RTL_USER_PROCESS_PARAMETERS from the target process memory
195197 paramsBuf := make ([]byte , windows .SizeOfRtlUserProcessParameters )
196- nRead , err = windows .ReadProcessMemory (handle , paramsAddr , paramsBuf )
198+ err = syswin .ReadProcessMemory (handle , paramsAddr , & paramsBuf [ 0 ], uintptr ( windows . SizeOfRtlUserProcessParameters ), & nRead )
197199 if err != nil {
198200 return params , err
199201 }
0 commit comments