当前位置: 首页>>代码示例>>C#>>正文


C# SECURITY_ATTRIBUTES类代码示例

本文整理汇总了C#中SECURITY_ATTRIBUTES的典型用法代码示例。如果您正苦于以下问题:C# SECURITY_ATTRIBUTES类的具体用法?C# SECURITY_ATTRIBUTES怎么用?C# SECURITY_ATTRIBUTES使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SECURITY_ATTRIBUTES类属于命名空间,在下文中一共展示了SECURITY_ATTRIBUTES类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateFileMapping

 internal static extern SafeMemoryMappedFileHandle CreateFileMapping(
     IntPtr hFile,
     ref SECURITY_ATTRIBUTES lpFileMappingAttributes,
     int flProtect,
     int dwMaximumSizeHigh,
     int dwMaximumSizeLow,
     string lpName);
开发者ID:noahfalk,项目名称:corefx,代码行数:7,代码来源:Interop.CreateFileMapping.cs

示例2: DuplicateTokenEx

		extern static bool DuplicateTokenEx(
			IntPtr hExistingToken,
			uint dwDesiredAccess,
			ref SECURITY_ATTRIBUTES lpTokenAttributes,
			SECURITY_IMPERSONATION_LEVEL ImpersonationLevel,
			TOKEN_TYPE TokenType,
			out IntPtr phNewToken);
开发者ID:gsbastian,项目名称:Sriracha.Deploy,代码行数:7,代码来源:ProcessRunner.cs

示例3: Run

 /// <summary>
 /// Runs the 
 /// </summary>
 public static void Run()
 {
     const uint NORMAL_PRIORITY_CLASS = 0x0020;
     string Path = Environment.CurrentDirectory + @"\" + (Program.projectName.ToString() == "Ultimatium" ? "BlackOpsMP.exe" : "iw5mp.exe");
     string Arguments = Program.Arguments;
     PROCESS_INFORMATION pInfo = new PROCESS_INFORMATION();
     STARTUPINFO sInfo = new STARTUPINFO();
     SECURITY_ATTRIBUTES pSec = new SECURITY_ATTRIBUTES();
     SECURITY_ATTRIBUTES tSec = new SECURITY_ATTRIBUTES();
     pSec.nLength = Marshal.SizeOf(pSec);
     tSec.nLength = Marshal.SizeOf(tSec);
     bool Initialized = CreateProcess(Path, Arguments,
     ref pSec, ref tSec, false, NORMAL_PRIORITY_CLASS,
     IntPtr.Zero, null, ref sInfo, out pInfo);
     if (Initialized)
     {
         Log.Write("Launching " + Program.projectName + "...");
         Log.Write("Successful launch. PID: " + pInfo.dwProcessId);
         Log.Write("Happy gaming!");
         Environment.Exit(0x0);
     }
     else
     {
         Log.Write("ERROR: Could not launch " + Program.projectName + ". Press any key to exit.");
         Console.ReadKey();
         Environment.Exit(0x3);
     }
 }
开发者ID:GammaForce,项目名称:Updater,代码行数:31,代码来源:Launcher.cs

示例4: CreatePipe

        public static PythonTuple CreatePipe(
            CodeContext context,
            object pSec /*Python passes None*/,
            int bufferSize) {
            IntPtr hReadPipe;
            IntPtr hWritePipe;
            
            SECURITY_ATTRIBUTES pSecA = new SECURITY_ATTRIBUTES();
            pSecA.nLength = Marshal.SizeOf(pSecA);
            if (pSec != null) {
                /* If pSec paseed in from Python is not NULL 
                 * there needs to be some conversion done here...*/
            }

            // TODO: handle failures
            CreatePipePI(
                out hReadPipe,
                out hWritePipe,
                ref pSecA,
                (uint)bufferSize);
            
            return PythonTuple.MakeTuple(
                new PythonSubprocessHandle(hReadPipe),
                new PythonSubprocessHandle(hWritePipe)
            );
        }
开发者ID:jschementi,项目名称:iron,代码行数:26,代码来源:_subprocess.cs

示例5: LaunchProcess

        /// <summary>
        /// Helper method to launch a completely detached process. (.NET Process object is not working well in our case)
        /// </summary>
        /// <param name="executablePath">Path of the executable to launch</param>
        /// <param name="arguments">Arguments of the executable</param>
        /// <param name="processId">The process id returned if launch was successfull</param>
        public static bool LaunchProcess(string executablePath, string arguments, out IntPtr processHandle, out int processId)
        {
            //var startInfo = new ProcessStartInfo
            //{
            //    FileName = executablePath,
            //    Arguments = arguments,
            //    WorkingDirectory = Path.GetDirectoryName(executablePath),
            //    CreateNoWindow = false,
            //    UseShellExecute = false,
            //};

            //var process = new Process { StartInfo = startInfo };
            //return process.Start();

            PROCESS_INFORMATION pInfo;
            var lpStartupInfo = new STARTUPINFOEX { StartupInfo = { dwFlags = 0x01 } }; // Flags to enable no new window for child-process
            lpStartupInfo.StartupInfo.cb = Marshal.SizeOf<STARTUPINFO>();
            //lpStartupInfo.StartupInfo.wShowWindow
            var pSec = new SECURITY_ATTRIBUTES();
            var tSec = new SECURITY_ATTRIBUTES();
            pSec.nLength = Marshal.SizeOf(pSec);
            tSec.nLength = Marshal.SizeOf(tSec);
            var result =  CreateProcessW(executablePath, "\"" + executablePath + "\" " + arguments, ref pSec, ref tSec, false, CREATE_DEFAULT_ERROR_MODE | CREATE_NO_WINDOW | DETACHED_PROCESS, IntPtr.Zero, Path.GetDirectoryName(executablePath), ref lpStartupInfo, out pInfo);

            processHandle = IntPtr.Zero;
            processId = 0;
            if (result)
            {
                processHandle = pInfo.hProcess;
                processId = pInfo.dwProcessId;
            }
            return result;
        }
开发者ID:cg123,项目名称:xenko,代码行数:39,代码来源:ProcessHelper.cs

示例6: CreateProcessAsUser

        //private WindowsImpersonationContext m_CurrentImpersonationContext;
        public string CreateProcessAsUser(string appPath, bool currentUser = false)
        {
            IntPtr Token = new IntPtr(0);
            IntPtr DupedToken = new IntPtr(0);
            bool ret;
            string text = WindowsIdentity.GetCurrent().Name.ToString();

            SECURITY_ATTRIBUTES sa = new SECURITY_ATTRIBUTES();
            sa.bInheritHandle = false;
            sa.Length = Marshal.SizeOf(sa);
            sa.lpSecurityDescriptor = (IntPtr)0;

            //Token = WindowsIdentity.GetCurrent().Token;

            Token = Domas.DAP.ADF.Cookie.CookieManger.GetCurrentUserToken();
            using (WindowsImpersonationContext impersonatedUser = WindowsIdentity.Impersonate(Token))
            {
                text += "<br/>" + WindowsIdentity.GetCurrent().Name + "<br/>";
            }
            const uint GENERIC_ALL = 0x10000000;

            const int SecurityImpersonation = 2;
            const int TokenType = 1;

            ret = DuplicateTokenEx(Token, GENERIC_ALL, ref sa, SecurityImpersonation, TokenType, ref DupedToken);

            if (ret == false)
                text += "DuplicateTokenEx failed with " + Marshal.GetLastWin32Error();

            else
                text += "DuplicateTokenEx SUCCESS";

            STARTUPINFO si = new STARTUPINFO();
            si.cb = Marshal.SizeOf(si);
            si.lpDesktop = "";

            string commandLinePath;
            commandLinePath = appPath;

            PROCESS_INFORMATION pi = new PROCESS_INFORMATION();
            ret = CreateProcessAsUser(DupedToken, null, commandLinePath, ref sa, ref sa, false, 0, (IntPtr)0, "c:\\", ref si, out pi);

            if (ret == false)
                text += "CreateProcessAsUser failed with " + Marshal.GetLastWin32Error();
            else
            {
                text += "CreateProcessAsUser SUCCESS.  The child PID is" + pi.dwProcessId;

                CloseHandle(pi.hProcess);
                CloseHandle(pi.hThread);
            }

            ret = CloseHandle(DupedToken);
            if (ret == false)
                text += Marshal.GetLastWin32Error();
            else
                text += "CloseHandle SUCCESS";
            return text;
        }
开发者ID:CuneytKukrer,项目名称:TestProject,代码行数:60,代码来源:SecurityManager.cs

示例7: GetSECURITY_ATTRIBUTES

 //
 // Only called from the custom marshaler
 //
 internal SECURITY_ATTRIBUTES GetSECURITY_ATTRIBUTES()
 {
     SECURITY_ATTRIBUTES attrs = new SECURITY_ATTRIBUTES() ;
     attrs.nLength = (uint)SECURITY_ATTRIBUTES.SizeOf;;
     attrs.bInheritHandle = (_inheritHandles ? Win32.TRUE : Win32.FALSE);
     attrs.lpSecurityDescriptor = (_secDesc == null ? IntPtr.Zero : _secDesc.Ptr);
     return attrs;
 }
开发者ID:nuxleus,项目名称:flexwikicore,代码行数:11,代码来源:SecurityAttributes.cs

示例8: CreateNamedPipeClient

 internal static extern SafePipeHandle CreateNamedPipeClient(
     string lpFileName,
     int dwDesiredAccess,
     System.IO.FileShare dwShareMode,
     ref SECURITY_ATTRIBUTES secAttrs,
     FileMode dwCreationDisposition,
     int dwFlagsAndAttributes,
     IntPtr hTemplateFile);
开发者ID:Czapek83,项目名称:corefx,代码行数:8,代码来源:Interop.CreateNamedPipeClient.cs

示例9: CreateNamedPipe

 internal static extern SafePipeHandle CreateNamedPipe(
     string pipeName,
     int openMode,
     int pipeMode,
     int maxInstances,
     int outBufferSize,
     int inBufferSize,
     int defaultTimeout,
     ref SECURITY_ATTRIBUTES securityAttributes);
开发者ID:Czapek83,项目名称:corefx,代码行数:9,代码来源:Interop.CreateNamedPipe.cs

示例10: createEvent

        static HANDLE createEvent()
        {
            SECURITY_ATTRIBUTES securityAttrib = new SECURITY_ATTRIBUTES();

            securityAttrib.bInheritHandle = 1;
            securityAttrib.lpSecurityDescriptor = IntPtr.Zero;
            securityAttrib.nLength = Marshal.SizeOf(typeof(SECURITY_ATTRIBUTES));

            return CreateEvent(ref securityAttrib, false, false, String.Empty);
        }
开发者ID:glandu2,项目名称:RappelzCmdLauncher,代码行数:10,代码来源:RappelzCmdLauncher.cs

示例11: RegCreateKeyEx

 internal static extern int RegCreateKeyEx(
     SafeRegistryHandle hKey,
     String lpSubKey,
     int Reserved,
     String lpClass,
     int dwOptions,
     int samDesired,
     ref SECURITY_ATTRIBUTES secAttrs,
     out SafeRegistryHandle hkResult,
     out int lpdwDisposition);
开发者ID:ChuangYang,项目名称:corefx,代码行数:10,代码来源:Interop.RegCreateKeyEx.cs

示例12: CreateProcess

 public static extern bool CreateProcess(StringBuilder lpApplicationName, StringBuilder lpCommandLine,
     SECURITY_ATTRIBUTES lpProcessAttributes,
     SECURITY_ATTRIBUTES lpThreadAttributes,
     bool bInheritHandles,
     int dwCreationFlags,
     StringBuilder lpEnvironment,
     StringBuilder lpCurrentDirectory,
     ref STARTUPINFO lpStartupInfo,
     ref PROCESS_INFORMATION lpProcessInformation
     );
开发者ID:EdgarEDT,项目名称:myitoppsp,代码行数:10,代码来源:FrmLayoutContents.cs

示例13: LaunchProcessAsConsoleUser

 public static bool LaunchProcessAsConsoleUser(string path)
 {
     bool ret = false;
     if (htoken != IntPtr.Zero)
     {
         CloseHandle(htoken);
         htoken = IntPtr.Zero;
     }
     if (htoken2 != IntPtr.Zero)
     {
         CloseHandle(htoken2);
         htoken = IntPtr.Zero;
     }
     List<WTS_SESSION_INFO> sessions = ListSessions();
     foreach (WTS_SESSION_INFO session in sessions)
     {
         UInt32 sessionId = (UInt32)session.SessionID;
         if (sessionId != 0 && sessionId != 0xFFFFFFFF)
         {
             bool result = WTSQueryUserToken(sessionId, out htoken);
             if (result)
             {
                 const uint MAXIMUM_ALLOWED = 0x02000000;
                 SECURITY_ATTRIBUTES sa = new SECURITY_ATTRIBUTES();
                 result = DuplicateTokenEx(htoken, MAXIMUM_ALLOWED, ref sa, SECURITY_IMPERSONATION_LEVEL.SecurityIdentification, TOKEN_TYPE.TokenPrimary, out htoken2);
                 if (result)
                 {
                     STARTUPINFO si = new STARTUPINFO();
                     si.cb = Marshal.SizeOf(si);
                     PROCESS_INFORMATION pi = new PROCESS_INFORMATION();
                     result = CreateProcessAsUser(htoken2, null, path, ref sa, ref sa, false, 0, (IntPtr)0, null, ref si, out pi);
                     if (result)
                     {
                         CloseHandle(pi.hProcess);
                         CloseHandle(pi.hThread);
                         ret = true;
                         ActiveAuthenticationService.LOG.WriteEntry("Application Started in session: " + session.SessionID.ToString());
                     }
                 }
                 if (htoken2 != IntPtr.Zero)
                 {
                     CloseHandle(htoken2);
                     htoken2 = IntPtr.Zero;
                 }
             }
             if (htoken != IntPtr.Zero)
             {
                 CloseHandle(htoken);
                 htoken = IntPtr.Zero;
             }
         }
     }
     return ret;
 }
开发者ID:ActiveAuthentication,项目名称:ActiveAuthentication,代码行数:54,代码来源:InteractiveProcessLauncher.cs

示例14: CreateProcessAsUser

 public extern static bool CreateProcessAsUser(IntPtr TokenHandle, 
     String lpApplicationName, 
     String lpCommandLine, 
     ref SECURITY_ATTRIBUTES lpProcessAttributes,
     ref SECURITY_ATTRIBUTES lpThreadAttributes, 
     bool bInheritHandle, 
     int dwCreationFlags, 
     IntPtr lpEnvironment,
     String lpCurrentDirectory, 
     ref STARTUPINFO lpStartupInfo, 
     out PROCESS_INFORMATION lpProcessInformation);
开发者ID:Wiladams,项目名称:NewTOAPIA,代码行数:11,代码来源:AdvApi32_Methods.cs

示例15: CreateProcess

 static extern bool CreateProcess(
     string lpApplicationName,
     string lpCommandLine, 
     ref SECURITY_ATTRIBUTES lpProcessAttributes,
     ref SECURITY_ATTRIBUTES lpThreadAttributes, 
     bool bInheritHandles,
     uint dwCreationFlags, 
     IntPtr lpEnvironment, 
     string lpCurrentDirectory,
     [In] ref StartupInfo lpStartupInfo,
     out ProcessInfo lpProcessInformation);
开发者ID:stevehjohn,项目名称:Hub,代码行数:11,代码来源:EmbeddedProcessOLD.cs


注:本文中的SECURITY_ATTRIBUTES类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。