Esempio n. 1
0
        public ProcessDetail(int pid)
        {
            // Initialize everything to null in case something fails.
              this.processId = pid;
              this.processHandleFlags = LowLevelTypes.ProcessAccessFlags.NONE;
              this.cachedProcessBasicInfo = null;
              this.machineTypeIsLoaded = false;
              this.machineType = LowLevelTypes.MachineType.UNKNOWN;
              this.cachedPeb = null;
              this.cachedProcessParams = null;
              this.cachedCommandLine = null;
              this.processHandle = IntPtr.Zero;

              OpenAndCacheProcessHandle();
        }
Esempio n. 2
0
 private void OpenAndCacheProcessHandle()
 {
     // Try to open a handle to the process with the highest level of privilege, but if we can't
       // do that then fallback to requesting access with a lower privilege level.
       processHandleFlags = LowLevelTypes.ProcessAccessFlags.QUERY_INFORMATION
                  | LowLevelTypes.ProcessAccessFlags.VM_READ;
       processHandle = NativeMethods.OpenProcess(processHandleFlags, false, processId);
       if (processHandle == IntPtr.Zero) {
     processHandleFlags = LowLevelTypes.ProcessAccessFlags.QUERY_LIMITED_INFORMATION;
     processHandle = NativeMethods.OpenProcess(processHandleFlags, false, processId);
     if (processHandle == IntPtr.Zero) {
       processHandleFlags = LowLevelTypes.ProcessAccessFlags.NONE;
       throw new Win32Exception();
     }
       }
 }
Esempio n. 3
0
 public static extern IntPtr OpenProcess(
     LowLevelTypes.ProcessAccessFlags dwDesiredAccess,
     [MarshalAs(UnmanagedType.Bool)] bool bInheritHandle,
     int dwProcessId);