antonioCoco / RunasCs

RunasCs - Csharp and open version of windows builtin runas.exe
GNU General Public License v3.0
1.01k stars 131 forks source link

AccessViolationException trying to get token privileges #9

Open sommafa opened 1 year ago

sommafa commented 1 year ago

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: https://github.com/antonioCoco/RunasCs/blob/a1e47b55952fadd46bf097be74a6efbcbe846c2b/RunasCs.cs#L1526

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

thank you Fabio

antonioCoco commented 11 months ago

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?