Windows get current process token




















The OpenProcessToken function opens the access token associated with a process. A handle to the process whose access token is opened. Specifies an access mask that specifies the requested types of access to the access token. These requested access types are compared with the discretionary access control list DACL of the token to determine which accesses are granted or denied.

If the function fails, the return value is zero. To get extended error information, call GetLastError. Returns a WindowsIdentity object that represents the Windows identity for either the thread or the process, depending on the value of the ifImpersonating parameter.

The desiredAccess parameter specifies an access mask that identifies the requested types of access to the access token.

These requested access types are compared with the token's discretionary access control list DACL to determine which types of access are granted or denied.

If ifImpersonating is true and the thread is not impersonating, the returned WindowsIdentity object has no value. If ifImpersonating is false and the thread is impersonating, the WindowsIdentity for the thread is returned. If ifImpersonating is false and the thread is not impersonating, the WindowsIdentity for the process is returned. The following code shows the use of the GetCurrent method to return a WindowsIdentity object that represents the current Windows user.

This code example is part of a larger example provided for the WindowsIdentity class. Skip to main content. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters Show hidden characters. Copy link.

What else could be causing the leak? Excellent gits!!! Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment. You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window.

String "service" , "" , "Control the service". Name : "RunAsUserTest" ,. Description : "Service to test launching programs as user from service" ,. New svc , svcConfig. Fatal err.



0コメント

  • 1000 / 1000