Exemplo n.º 1
0
Arquivo: Main.cs Projeto: sotaria/gsf
        // Determines whether the given OID is already registered.
        private bool IsRegistered(string oid)
        {
            IntPtr info;

            WindowsApi.CRYPT_OID_INFO oidInfo;

            info = WindowsApi.CryptFindOIDInfo(WindowsApi.CRYPT_OID_INFO_OID_KEY, oid, WindowsApi.CRYPT_OID_DISABLE_SEARCH_DS_FLAG);

            if (!info.Equals(IntPtr.Zero))
            {
                oidInfo = new WindowsApi.CRYPT_OID_INFO();
                Marshal.PtrToStructure(info, oidInfo);

                using (RegistryKey oidKey = Registry.LocalMachine.OpenSubKey(string.Format(@"Software\Microsoft\Cryptography\OID\EncodingType 0\CryptDllFindOIDInfo\{0}!{1}", oidInfo.pszOID, oidInfo.dwGroupId)))
                {
                    if ((object)oidKey != null)
                    {
                        return(true);
                    }
                }

                using (RegistryKey oidKey = Registry.LocalMachine.OpenSubKey(string.Format(@"Software\Wow6432Node\Microsoft\Cryptography\OID\EncodingType 0\CryptDllFindOIDInfo\{0}!{1}", oidInfo.pszOID, oidInfo.dwGroupId)))
                {
                    if ((object)oidKey != null)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Exemplo n.º 2
0
Arquivo: Main.cs Projeto: sotaria/gsf
        // Registers the given OID.
        private void RegisterOID(string oid)
        {
            IntPtr info;

            WindowsApi.CRYPT_OID_INFO oidInfo;

            // Look up the OID
            info = WindowsApi.CryptFindOIDInfo(WindowsApi.CRYPT_OID_INFO_OID_KEY, oid, WindowsApi.CRYPT_OID_DISABLE_SEARCH_DS_FLAG);

            if (!info.Equals(IntPtr.Zero))
            {
                // Register the OID
                oidInfo = new WindowsApi.CRYPT_OID_INFO();
                Marshal.PtrToStructure(info, oidInfo);
                WindowsApi.CryptRegisterOIDInfo(info, WindowsApi.CRYPT_INSTALL_OID_INFO_BEFORE_FLAG);

                // Add the name of the OID to the registry since the .NET libraries lookup by name
                using (RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(string.Format(@"Software\Wow6432Node\Microsoft\Cryptography\OID\EncodingType 0\CryptDllFindOIDInfo\{0}!{1}", oidInfo.pszOID, oidInfo.dwGroupId), true))
                {
                    if ((object)registryKey != null)
                    {
                        registryKey.SetValue("Name", oidInfo.pszOID);
                    }
                }

                using (RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(string.Format(@"Software\Microsoft\Cryptography\OID\EncodingType 0\CryptDllFindOIDInfo\{0}!{1}", oidInfo.pszOID, oidInfo.dwGroupId), true))
                {
                    if ((object)registryKey != null)
                    {
                        registryKey.SetValue("Name", oidInfo.pszOID);
                    }
                }
            }
        }
Exemplo n.º 3
0
Arquivo: Main.cs Projeto: rmc00/gsf
        // Determines whether the given OID is already registered.
        private bool IsRegistered(string oid)
        {
            IntPtr info;
            WindowsApi.CRYPT_OID_INFO oidInfo;

            info = WindowsApi.CryptFindOIDInfo(WindowsApi.CRYPT_OID_INFO_OID_KEY, oid, WindowsApi.CRYPT_OID_DISABLE_SEARCH_DS_FLAG);

            if (!info.Equals(IntPtr.Zero))
            {
                oidInfo = new WindowsApi.CRYPT_OID_INFO();
                Marshal.PtrToStructure(info, oidInfo);

                using (RegistryKey oidKey = Registry.LocalMachine.OpenSubKey(string.Format(@"Software\Microsoft\Cryptography\OID\EncodingType 0\CryptDllFindOIDInfo\{0}!{1}", oidInfo.pszOID, oidInfo.dwGroupId)))
                {
                    if ((object)oidKey != null)
                        return true;
                }

                using (RegistryKey oidKey = Registry.LocalMachine.OpenSubKey(string.Format(@"Software\Wow6432Node\Microsoft\Cryptography\OID\EncodingType 0\CryptDllFindOIDInfo\{0}!{1}", oidInfo.pszOID, oidInfo.dwGroupId)))
                {
                    if ((object)oidKey != null)
                        return true;
                }
            }

            return false;
        }
Exemplo n.º 4
0
Arquivo: Main.cs Projeto: rmc00/gsf
        // Registers the given OID.
        private void RegisterOID(string oid)
        {
            IntPtr info;
            WindowsApi.CRYPT_OID_INFO oidInfo;

            // Look up the OID
            info = WindowsApi.CryptFindOIDInfo(WindowsApi.CRYPT_OID_INFO_OID_KEY, oid, WindowsApi.CRYPT_OID_DISABLE_SEARCH_DS_FLAG);

            if (!info.Equals(IntPtr.Zero))
            {
                // Register the OID
                oidInfo = new WindowsApi.CRYPT_OID_INFO();
                Marshal.PtrToStructure(info, oidInfo);
                WindowsApi.CryptRegisterOIDInfo(info, WindowsApi.CRYPT_INSTALL_OID_INFO_BEFORE_FLAG);

                // Add the name of the OID to the registry since the .NET libraries lookup by name
                using (RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(string.Format(@"Software\Wow6432Node\Microsoft\Cryptography\OID\EncodingType 0\CryptDllFindOIDInfo\{0}!{1}", oidInfo.pszOID, oidInfo.dwGroupId), true))
                {
                    if ((object)registryKey != null)
                        registryKey.SetValue("Name", oidInfo.pszOID);
                }

                using (RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(string.Format(@"Software\Microsoft\Cryptography\OID\EncodingType 0\CryptDllFindOIDInfo\{0}!{1}", oidInfo.pszOID, oidInfo.dwGroupId), true))
                {
                    if ((object)registryKey != null)
                        registryKey.SetValue("Name", oidInfo.pszOID);
                }
            }
        }