public RegBlobWebProxyDataBuilder(string connectoid, SafeRegistryHandle registry) { Debug.Assert(registry != null); m_Registry = registry; m_Connectoid = connectoid; }
private void ListenForRegistryHelper(ref SafeRegistryHandle key, ref AutoResetEvent changeEvent, IntPtr baseKey, string subKey) { uint errorCode = 0; // First time through? if (key == null || key.IsInvalid) { if (baseKey == IntPtr.Zero) { // Impersonation requires extra effort. GlobalLog.Print("AutoWebProxyScriptEngine#" + ValidationHelper.HashString(this) + "::ListenForRegistry() RegOpenCurrentUser() using hkcu:" + hkcu.DangerousGetHandle().ToString("x")); if (hkcu != null) { errorCode = hkcu.RegOpenKeyEx(subKey, 0, UnsafeNclNativeMethods.RegistryHelper.KEY_READ, out key); GlobalLog.Print("AutoWebProxyScriptEngine#" + ValidationHelper.HashString(this) + "::ListenForRegistry() RegOpenKeyEx() returned errorCode:" + errorCode + " key:" + key.DangerousGetHandle().ToString("x")); } else { errorCode = UnsafeNclNativeMethods.ErrorCodes.ERROR_NOT_FOUND; } } else { errorCode = SafeRegistryHandle.RegOpenKeyEx(baseKey, subKey, 0, UnsafeNclNativeMethods.RegistryHelper.KEY_READ, out key); //GlobalLog.Print("AutoWebProxyScriptEngine#" + ValidationHelper.HashString(this) + "::ListenForRegistry() RegOpenKeyEx() returned errorCode:" + errorCode + " key:" + key.DangerousGetHandle().ToString("x")); } if (errorCode == 0) { changeEvent = new AutoResetEvent(false); } } if (errorCode == 0) { // accessing Handle is protected by a link demand, OK for System.dll errorCode = key.RegNotifyChangeKeyValue(true, UnsafeNclNativeMethods.RegistryHelper.REG_NOTIFY_CHANGE_LAST_SET, changeEvent.SafeWaitHandle, true); GlobalLog.Print("AutoWebProxyScriptEngine#" + ValidationHelper.HashString(this) + "::ListenForRegistry() RegNotifyChangeKeyValue() returned errorCode:" + errorCode); } if (errorCode != 0) { if (key != null && !key.IsInvalid) { try { errorCode = key.RegCloseKey(); } catch (Exception exception) { if (NclUtilities.IsFatal(exception)) throw; } GlobalLog.Print("AutoWebProxyScriptEngine#" + ValidationHelper.HashString(this) + "::ListenForRegistry() RegCloseKey() returned errorCode:" + errorCode); } key = null; if (changeEvent != null) { changeEvent.Close(); changeEvent = null; } } }
internal void Close() { #if !FEATURE_PAL // m_AutoDetector is always set up in the constructor, use it to lock if (m_AutoDetector != null) { int syncStatus = SyncStatus.Unlocked; try { EnterLock(ref syncStatus); GlobalLog.Assert(syncStatus == SyncStatus.LockOwner, "AutoWebProxyScriptEngine#{0}::Close()|Failed to acquire lock.", ValidationHelper.HashString(this)); if (m_AutoDetector != null) { registrySuppress = true; if (registryChangeEventPolicy != null) { registryChangeEventPolicy.Close(); registryChangeEventPolicy = null; } if (registryChangeEventLM != null) { registryChangeEventLM.Close(); registryChangeEventLM = null; } if (registryChangeEvent != null) { registryChangeEvent.Close(); registryChangeEvent = null; } if (regKeyPolicy != null && !regKeyPolicy.IsInvalid) { regKeyPolicy.Close(); } if (regKeyLM != null && !regKeyLM.IsInvalid) { regKeyLM.Close(); } if (regKey != null && !regKey.IsInvalid) { regKey.Close(); } if (hkcu != null) { hkcu.RegCloseKey(); hkcu = null; } if (m_Identity != null) { m_Identity.Dispose(); m_Identity = null; } webProxyFinder.Dispose(); m_AutoDetector = null; } } finally { ExitLock(ref syncStatus); } } #endif // !FEATURE_PAL }
public RegBlobWebProxyDataBuilder(string connectoid, SafeRegistryHandle registry) { this.m_Registry = registry; this.m_Connectoid = connectoid; }