public static NativeStructs.WINTRUST_BLOB_INFO InitWintrustBlobInfoStruct(string fileName, string content) { NativeStructs.WINTRUST_BLOB_INFO wintrustBlobInfo = new NativeStructs.WINTRUST_BLOB_INFO(); byte[] bytes = Encoding.Unicode.GetBytes(content); wintrustBlobInfo.gSubject.Data1 = 1614531615U; wintrustBlobInfo.gSubject.Data2 = (ushort)19289; wintrustBlobInfo.gSubject.Data3 = (ushort)19976; wintrustBlobInfo.gSubject.Data4 = new byte[8] { (byte)183, (byte)36, (byte)210, (byte)198, (byte)41, (byte)126, (byte)243, (byte)81 }; wintrustBlobInfo.cbStruct = (uint)Marshal.SizeOf((object)wintrustBlobInfo); wintrustBlobInfo.pcwszDisplayName = fileName; wintrustBlobInfo.cbMemObject = (uint)bytes.Length; wintrustBlobInfo.pbMemObject = Marshal.AllocCoTaskMem(bytes.Length); Marshal.Copy(bytes, 0, wintrustBlobInfo.pbMemObject, bytes.Length); return(wintrustBlobInfo); }
public static NativeStructs.WINTRUST_DATA InitWintrustDataStructFromBlob(NativeStructs.WINTRUST_BLOB_INFO wbi) { NativeStructs.WINTRUST_DATA wintrustData = new NativeStructs.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); }