Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AccessViolationException trying to get token privileges #9

Open
sommafa opened this issue Oct 12, 2023 · 1 comment
Open

AccessViolationException trying to get token privileges #9

sommafa opened this issue Oct 12, 2023 · 1 comment

Comments

@sommafa
Copy link

sommafa commented Oct 12, 2023

Hello,
It often happens to me, when the function AccessToken.GetTokenPrivileges is called, that I receive an AccessViolation Exception

Description: The process was terminated due to an unhandled exception.
Exception Info: System.AccessViolationException
   at System.Runtime.InteropServices.Marshal.PtrToStructureHelper(IntPtr, System.Object, Boolean)
   at System.Runtime.InteropServices.Marshal.PtrToStructure(IntPtr, System.Type)
   at AccessToken.GetTokenPrivileges(IntPtr)

It refers to this line of code:

TOKEN_PRIVILEGES TokenPrivileges = (TOKEN_PRIVILEGES)Marshal.PtrToStructure( TokenInformation , typeof( TOKEN_PRIVILEGES ) ) ;

Is MAYBE present a difference between size of managed and native structure?

thank you
Fabio

@antonioCoco
Copy link
Owner

Hi,

please include more information to troubleshoot and reproduce the issue.

What OS version are you running on? What is the commandline of RunasCs.exe you are using that is causing the exception? In which context are you using the tool?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants