예제 #1
0
 internal static System.Security.Cryptography.SafeCertStoreHandle CertOpenStore([In] IntPtr lpszStoreProvider, [In] uint dwMsgAndCertEncodingType, [In] IntPtr hCryptProv, [In] uint dwFlags, [In] string pvPara)
 {
     if ((lpszStoreProvider != new IntPtr(2L)) && (lpszStoreProvider != new IntPtr(10L)))
     {
         throw new ArgumentException(SR.GetString("Security_InvalidValue"), "lpszStoreProvider");
     }
     if (((((dwFlags & 0x20000) == 0x20000) || ((dwFlags & 0x80000) == 0x80000)) || ((dwFlags & 0x90000) == 0x90000)) && ((pvPara != null) && pvPara.StartsWith(@"\\", StringComparison.Ordinal)))
     {
         new PermissionSet(PermissionState.Unrestricted).Demand();
     }
     if ((dwFlags & 0x10) == 0x10)
     {
         new StorePermission(StorePermissionFlags.DeleteStore).Demand();
     }
     else
     {
         new StorePermission(StorePermissionFlags.OpenStore).Demand();
     }
     if ((dwFlags & 0x2000) == 0x2000)
     {
         new StorePermission(StorePermissionFlags.CreateStore).Demand();
     }
     if ((dwFlags & 0x4000) == 0)
     {
         new StorePermission(StorePermissionFlags.CreateStore).Demand();
     }
     return(CAPIUnsafe.CertOpenStore(lpszStoreProvider, dwMsgAndCertEncodingType, hCryptProv, dwFlags | 4, pvPara));
 }