Skip to content

AccessViolationException trying to get token privileges #9

@sommafa

Description

@sommafa

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions