예제 #1
0
        internal static NativeMethods.WINTRUST_DATA InitWintrustDataStructFromBlob(
            NativeMethods.WINTRUST_BLOB_INFO wbi)
        {
            NativeMethods.WINTRUST_DATA wintrustData = new NativeMethods.WINTRUST_DATA();
            wintrustData.cbStruct            = (uint)Marshal.SizeOf((object)wbi);
            wintrustData.pPolicyCallbackData = IntPtr.Zero;
            wintrustData.pSIPClientData      = IntPtr.Zero;
            wintrustData.dwUIChoice          = 2U;
            wintrustData.fdwRevocationChecks = 0U;
            wintrustData.dwUnionChoice       = 3U;
            IntPtr ptr = Marshal.AllocCoTaskMem(Marshal.SizeOf((object)wbi));

            Marshal.StructureToPtr((object)wbi, ptr, false);
            wintrustData.Choice.pBlob     = ptr;
            wintrustData.dwStateAction    = 1U;
            wintrustData.hWVTStateData    = IntPtr.Zero;
            wintrustData.pwszURLReference = (string)null;
            wintrustData.dwProvFlags      = 0U;
            return(wintrustData);
        }
예제 #2
0
        internal static uint DestroyWintrustDataStruct(NativeMethods.WINTRUST_DATA wtd)
        {
            uint   num1 = 2147500037;
            IntPtr num2 = IntPtr.Zero;
            IntPtr num3 = IntPtr.Zero;
            Guid   guid = new Guid("00AAC56B-CD44-11d0-8CC2-00C04FC295EE");

            try
            {
                num2 = Marshal.AllocCoTaskMem(Marshal.SizeOf((object)guid));
                Marshal.StructureToPtr((object)guid, num2, false);
                wtd.dwStateAction = 2U;
                num3 = Marshal.AllocCoTaskMem(Marshal.SizeOf((object)wtd));
                Marshal.StructureToPtr((object)wtd, num3, false);
                num1 = NativeMethods.WinVerifyTrust(IntPtr.Zero, num2, num3);
                wtd  = (NativeMethods.WINTRUST_DATA)Marshal.PtrToStructure(num3, typeof(NativeMethods.WINTRUST_DATA));
            }
            finally
            {
                Marshal.DestroyStructure(num3, typeof(NativeMethods.WINTRUST_DATA));
                Marshal.FreeCoTaskMem(num3);
                Marshal.DestroyStructure(num2, typeof(Guid));
                Marshal.FreeCoTaskMem(num2);
            }
            if (wtd.dwUnionChoice == 3U)
            {
                Marshal.FreeCoTaskMem(((NativeMethods.WINTRUST_BLOB_INFO)Marshal.PtrToStructure(wtd.Choice.pBlob, typeof(NativeMethods.WINTRUST_BLOB_INFO))).pbMemObject);
                Marshal.DestroyStructure(wtd.Choice.pBlob, typeof(NativeMethods.WINTRUST_BLOB_INFO));
                Marshal.FreeCoTaskMem(wtd.Choice.pBlob);
            }
            else
            {
                Marshal.DestroyStructure(wtd.Choice.pFile, typeof(NativeMethods.WINTRUST_FILE_INFO));
                Marshal.FreeCoTaskMem(wtd.Choice.pFile);
            }
            return(num1);
        }