Esempio n. 1
0
        ////////////////////////////////////////////////////////////////////////////////
        // Private function to query a token with an enumeration result
        ////////////////////////////////////////////////////////////////////////////////
        private static bool _QueryTokenInformation(IntPtr hToken, Winnt._TOKEN_INFORMATION_CLASS informationClass, ref int dwTokenInformation)
        {
            uint   tokenInformationLength = (uint)Marshal.SizeOf(typeof(uint));
            IntPtr lpTokenInformation     = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(uint)));

            try
            {
                uint returnLength = 0;
                if (!advapi32.GetTokenInformation(hToken, informationClass, lpTokenInformation, tokenInformationLength, out returnLength))
                {
                    Misc.GetWin32Error("GetTokenInformation");
                    return(false);
                }
                dwTokenInformation = Marshal.ReadInt32(lpTokenInformation);
            }
            catch (Exception ex)
            {
                Misc.GetWin32Error("GetTokenInformation");
                Console.WriteLine("[-] {0}", ex.Message);
                return(false);
            }
            finally
            {
                Marshal.FreeHGlobal(lpTokenInformation);
            }
            return(true);
        }
Esempio n. 2
0
 public static extern bool GetTokenInformation(IntPtr TokenHandle, Winnt._TOKEN_INFORMATION_CLASS TokenInformationClass, ref Winnt._TOKEN_DEFAULT_DACL_ACL TokenInformation, uint TokenInformationLength, out uint ReturnLength);
Esempio n. 3
0
 public static extern bool SetTokenInformation(
     IntPtr TokenHandle,
     Winnt._TOKEN_INFORMATION_CLASS TokenInformationClass,
     IntPtr TokenInformation,
     int TokenInformationLength
     );
Esempio n. 4
0
 public static extern Boolean GetTokenInformation(IntPtr TokenHandle, Winnt._TOKEN_INFORMATION_CLASS TokenInformationClass, ref Winnt._TOKEN_STATISTICS TokenInformation, UInt32 TokenInformationLength, out UInt32 ReturnLength);