// Token: 0x06000B7A RID: 2938 RVA: 0x00032C30 File Offset: 0x00030E30 private static RegistryKey OpenRemoteKey(string machineName, string registryKey) { RegistryKey result = null; if (!string.IsNullOrEmpty(machineName)) { using (RemoteRegistryBaseKey remoteRegistryBaseKey = new RemoteRegistryBaseKey()) { remoteRegistryBaseKey.Open(RegistryHive.LocalMachine, machineName); try { result = remoteRegistryBaseKey.Key.CreateSubKey(registryKey); RegistryStateIO.trace.TraceDebug <string, string>(0L, "remote RegistryStateIO created, key = {0}, machine = {1}", registryKey, machineName); } catch (SecurityException) { result = remoteRegistryBaseKey.Key.OpenSubKey(registryKey, RegistryKeyPermissionCheck.ReadSubTree); RegistryStateIO.trace.TraceDebug <string, string>(0L, "remote RegistryStateIO opened read subtree, key = {0}, machine = {1}", registryKey, machineName); } catch (UnauthorizedAccessException) { result = remoteRegistryBaseKey.Key.OpenSubKey(registryKey, RegistryKeyPermissionCheck.ReadSubTree); RegistryStateIO.trace.TraceDebug <string, string>(0L, "remote RegistryStateIO opened read subtree, key = {0}, machine = {1}", registryKey, machineName); } return(result); } } try { result = Registry.LocalMachine.CreateSubKey(registryKey); RegistryStateIO.trace.TraceDebug <string, string>(0L, "local RegistryStateIO created, key = {0}, machine = {1}", registryKey, machineName); } catch (SecurityException) { result = Registry.LocalMachine.OpenSubKey(registryKey, RegistryKeyPermissionCheck.ReadSubTree); RegistryStateIO.trace.TraceDebug <string, string>(0L, "local RegistryStateIO opened read subtree, key = {0}, machine = {1}", registryKey, machineName); } catch (UnauthorizedAccessException) { result = Registry.LocalMachine.OpenSubKey(registryKey, RegistryKeyPermissionCheck.ReadSubTree); RegistryStateIO.trace.TraceDebug <string, string>(0L, "local RegistryStateIO opened read subtree, key = {0}, machine = {1}", registryKey, machineName); } return(result); }
private static void OpenCompletion(IAsyncResult ar) { RemoteRegistryBaseKey.AsyncOpenTask asyncOpenTask = (RemoteRegistryBaseKey.AsyncOpenTask)ar.AsyncState; RemoteRegistryBaseKey remoteRegistryBaseKey = (RemoteRegistryBaseKey)asyncOpenTask.Target; if (Interlocked.Decrement(ref remoteRegistryBaseKey.m_asyncRefCount) > 0) { return; } Exception ex = null; try { asyncOpenTask.EndInvoke(ar); } catch (IOException ex2) { ex = ex2; } catch (SecurityException ex3) { ex = ex3; } catch (UnauthorizedAccessException ex4) { ex = ex4; } finally { if (ex != null) { ExTraceGlobals.StateTracer.TraceDebug <string>((long)remoteRegistryBaseKey.GetHashCode(), "RemoteRegistryBaseKey hit exception after being abandoned: {0}", ex.Message); } remoteRegistryBaseKey.Dispose(); } }