Example #1
0
 private static extern bool DuplicateTokenEx(
     Kernel32.SafeObjectHandle hExistingToken,
     Kernel32.ACCESS_MASK dwDesiredAccess,
     ref Kernel32.SECURITY_ATTRIBUTES lpTokenAttributes,
     Kernel32.SECURITY_IMPERSONATION_LEVEL impersonationLevel,
     TOKEN_TYPE tokenType,
     out Kernel32.SafeObjectHandle phNewToken);
Example #2
0
 public static SafeMemoryMappedFileHandle CreateFileMapping(
     IntPtr hFile,
     ref Kernel32.SECURITY_ATTRIBUTES securityAttributes,
     int pageProtection,
     long maximumSize,
     string name)
 {
     return(Interop.Kernel32.CreateFileMappingFromApp(hFile, ref securityAttributes, pageProtection, maximumSize, name));
 }
Example #3
0
 internal static extern int RegCreateKeyEx(
     SafeRegistryHandle hKey,
     String lpSubKey,
     int Reserved,
     String lpClass,
     int dwOptions,
     int samDesired,
     ref Kernel32.SECURITY_ATTRIBUTES secAttrs,
     out SafeRegistryHandle hkResult,
     out int lpdwDisposition);
Example #4
0
 private static extern bool CreateProcessAsUser(
     IntPtr hToken,
     string lpApplicationName,
     string lpCommandLine,
     ref Kernel32.SECURITY_ATTRIBUTES lpProcessAttributes,
     ref Kernel32.SECURITY_ATTRIBUTES lpThreadAttributes,
     bool bInheritHandle,
     Kernel32.CreateProcessFlags dwCreationFlags,
     IntPtr lpEnvironment,
     string lpCurrentDirectory,
     ref STARTUPINFO lpStartupInfo,
     out Kernel32.PROCESS_INFORMATION lpProcessInformation);
Example #5
0
    public static SafeMemoryMappedFileHandle CreateFileMapping(
        IntPtr hFile,
        ref Kernel32.SECURITY_ATTRIBUTES securityAttributes,
        int pageProtection,
        long maximumSize,
        string?name)
    {
        // split the long into two ints
        int capacityHigh, capacityLow;

        SplitLong(maximumSize, out capacityHigh, out capacityLow);

        return(Interop.Kernel32.CreateFileMapping(hFile, ref securityAttributes, pageProtection, capacityHigh, capacityLow, name));
    }
Example #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="message"></param>
        private void ExecuteFile(ExecuteFileMessage message)
        {
            ExecuteSimpleOperation(message.WindowId, -1, "File execution",
                                   () =>
            {
                var si  = new Kernel32.STARTUPINFO();
                var pi  = new Kernel32.PROCESS_INFORMATION();
                var sap = new Kernel32.SECURITY_ATTRIBUTES();
                var sat = new Kernel32.SECURITY_ATTRIBUTES();
                const uint CreateNoWindow = 0x08000000;

                var directory = Path.GetDirectoryName(message.FilePath);
                Kernel32.CreateProcess(message.FilePath, "", ref sap, ref sat, false,
                                       CreateNoWindow, IntPtr.Zero, directory, ref si, out pi);
            }, message.FilePath);
        }