Esempio n. 1
0
 public static string GetApplicationPathFromProcess(Process proc)
 {
     try
     {
         if (!SystemUtils.IsOSWinXP())
         {
             return(GetProcessExecutionPath.GetExecutablePathAboveVista(new UIntPtr((uint)proc?.Id.Value)));
         }
         if (SystemUtils.IsAdministrator())
         {
             return(proc?.MainModule.FileName.ToString((IFormatProvider)CultureInfo.InvariantCulture));
         }
     }
     catch
     {
     }
     return(string.Empty);
 }
Esempio n. 2
0
 public static RegistryKey InitKeyWithSecurityCheck(string keyName)
 {
     return(!SystemUtils.IsAdministrator() ? Registry.LocalMachine.OpenSubKey(keyName) : Registry.LocalMachine.CreateSubKey(keyName));
 }
 public static void LogProcessContextDetails()
 {
     Logger.Info("PID {0}, CLR version {0}", (object)Process.GetCurrentProcess().Id, (object)Environment.Version);
     Logger.Info("IsAdministrator: {0}", (object)SystemUtils.IsAdministrator());
 }