// Token: 0x06000225 RID: 549 RVA: 0x0000A09C File Offset: 0x0000829C
        internal static string[] ReadValueNames(AmClusterRegkeyHandle handle)
        {
            List <string> list          = new List <string>();
            int           num           = 1024;
            StringBuilder stringBuilder = new StringBuilder(num);
            int           num2          = 0;
            int           num6;

            for (;;)
            {
                int num3 = num;
                int num4 = 0;
                int num5 = 0;
                num6 = ClusapiMethods.ClusterRegEnumValue(handle, num2, stringBuilder, ref num3, ref num4, IntPtr.Zero, ref num5);
                if (num6 != 0)
                {
                    break;
                }
                string item = stringBuilder.ToString();
                list.Add(item);
                num2++;
            }
            if (num6 != 259)
            {
                throw AmExceptionHelper.ConstructClusterApiException(num6, "ClusterRegEnumValue()", new object[0]);
            }
            return(list.ToArray());
        }
Exemple #2
0
        public IAmClusterResource CreateResource(string resName, string resType)
        {
            try
            {
                using (this.OwningCluster.OpenResource(resName))
                {
                    throw new ClusResourceAlreadyExistsException(resName);
                }
            }
            catch (ClusterApiException ex)
            {
                Win32Exception ex2 = ex.InnerException as Win32Exception;
                if (ex2 != null && (long)ex2.NativeErrorCode != 5007L)
                {
                    throw;
                }
            }
            AmClusterResourceHandle amClusterResourceHandle = ClusapiMethods.CreateClusterResource(this.Handle, resName, resType, ClusterResourceCreateFlags.CLUSTER_RESOURCE_DEFAULT_MONITOR);

            if (amClusterResourceHandle.IsInvalid)
            {
                int lastWin32Error = Marshal.GetLastWin32Error();
                throw AmExceptionHelper.ConstructClusterApiException(lastWin32Error, "CreateClusterResource(name={0},type={1})", new object[]
                {
                    resName,
                    resType
                });
            }
            return(new AmClusterResource(resName, this.OwningCluster, amClusterResourceHandle));
        }
Exemple #3
0
        internal int CommitAndClose()
        {
            int num;
            int result = ClusapiMethods.ClusterRegCloseBatch(this.handle, true, out num);

            base.SetHandle(IntPtr.Zero);
            return(result);
        }
        // Token: 0x06000224 RID: 548 RVA: 0x0000A060 File Offset: 0x00008260
        internal static void Delete(string valueName, AmClusterRegkeyHandle handle)
        {
            int num = ClusapiMethods.ClusterRegDeleteValue(handle, valueName);

            if (num != 2 && num != 3 && num != 1018 && num != 0)
            {
                throw AmExceptionHelper.ConstructClusterApiException(num, "ClusterRegDeleteValue()", new object[0]);
            }
        }
Exemple #5
0
        // Token: 0x060002F9 RID: 761 RVA: 0x0000D33C File Offset: 0x0000B53C
        internal static int ClusterRegCloseKey(IntPtr RegKeyHandle, string name)
        {
            int retCode = ClusApiHook.CallBackDriver(ClusApiHooks.ClusterRegCloseKey, string.Format("KeyName = {0}, Handle = {1}", name, RegKeyHandle), delegate
            {
                retCode = ClusapiMethods.ClusterRegCloseKeyInternal(RegKeyHandle);
                return(retCode);
            });

            return(retCode);
        }
Exemple #6
0
        // Token: 0x06000239 RID: 569 RVA: 0x0000A550 File Offset: 0x00008750
        public uint OfflineResource()
        {
            uint num = ClusapiMethods.OfflineClusterResource(this.Handle);

            if (num != 0U)
            {
                ExTraceGlobals.ClusterTracer.TraceDebug <string, uint>((long)this.GetHashCode(), "OfflineClusterResource( '{0}' ) failed with 0x{1:x}", this.Name, num);
            }
            return(num);
        }
Exemple #7
0
        // Token: 0x0600023A RID: 570 RVA: 0x0000A58C File Offset: 0x0000878C
        public void DeleteResource()
        {
            string name = this.Name;
            uint   num  = ClusapiMethods.DeleteClusterResource(this.Handle);

            if (num != 0U)
            {
                throw AmExceptionHelper.ConstructClusterApiException((int)num, "DeleteClusterResource()", new object[0]);
            }
        }
Exemple #8
0
        // Token: 0x060002FD RID: 765 RVA: 0x0000D450 File Offset: 0x0000B650
        internal static int ClusterRegBatchAddCommand([In] AmClusterBatchHandle hBatch, [In] CLUSTER_REG_COMMAND dwCommand, [MarshalAs(UnmanagedType.LPWStr)][In] string wzName, [In] RegistryValueKind dwOptions, [In] IntPtr lpData, [In] int cbData)
        {
            int retCode = ClusApiHook.CallBackDriver(ClusApiHooks.ClusterRegBatchAddCommand, string.Format("hBatch = {0} dwCommand = {1} wsName = {2}", hBatch, dwCommand, wzName), delegate
            {
                retCode = ClusapiMethods.ClusterRegBatchAddCommandInternal(hBatch, dwCommand, wzName, dwOptions, lpData, cbData);
                return(retCode);
            });

            return(retCode);
        }
Exemple #9
0
        // Token: 0x060002AD RID: 685 RVA: 0x0000CCE8 File Offset: 0x0000AEE8
        internal static bool CloseCluster([In] IntPtr hCluster)
        {
            bool isSuccess = false;

            ClusApiHook.CallBackDriver(ClusApiHooks.CloseCluster, string.Format("hCluster = {0}", hCluster), delegate
            {
                int result = 0;
                isSuccess  = ClusapiMethods.CloseClusterInternal(hCluster);
                return(result);
            });
            return(isSuccess);
        }
Exemple #10
0
        private void GetStateAndOwningNode(out AmGroupState state, out AmServerName nodeName)
        {
            int           capacity      = 260;
            StringBuilder stringBuilder = new StringBuilder(capacity);

            state = ClusapiMethods.GetClusterGroupState(this.m_handle, stringBuilder, ref capacity);
            if (state == AmGroupState.Unknown)
            {
                throw new ClusterApiException("GetClusterGroupState() failed. State returned is Unknown.", new Win32Exception());
            }
            nodeName = new AmServerName(stringBuilder.ToString());
        }
Exemple #11
0
        // Token: 0x060002FB RID: 763 RVA: 0x0000D3B4 File Offset: 0x0000B5B4
        internal static int ClusterRegCreateBatch([In] AmClusterRegkeyHandle hKey, out AmClusterBatchHandle hBatch)
        {
            AmClusterBatchHandle hBatchTmp = null;
            int retCode = ClusApiHook.CallBackDriver(ClusApiHooks.ClusterRegCreateBatch, string.Format("KeyName = {0}", hKey.Name), delegate
            {
                retCode = ClusapiMethods.ClusterRegCreateBatchInternal(hKey, out hBatchTmp);
                return(retCode);
            });

            hBatch = hBatchTmp;
            return(retCode);
        }
Exemple #12
0
        // Token: 0x060002FF RID: 767 RVA: 0x0000D4FC File Offset: 0x0000B6FC
        internal static int ClusterRegCloseBatch([In] IntPtr hBatch, [MarshalAs(UnmanagedType.Bool)][In] bool bCommit, [Optional] out int failedCommandNumber)
        {
            int failedCommandNumberTmp = 0;
            int retCode = ClusApiHook.CallBackDriver(ClusApiHooks.ClusterRegCloseBatch, string.Format("hBatch = {0} bCommit = {1}", hBatch, bCommit), delegate
            {
                retCode = ClusapiMethods.ClusterRegCloseBatchInternal(hBatch, bCommit, out failedCommandNumberTmp);
                return(retCode);
            });

            failedCommandNumber = failedCommandNumberTmp;
            return(retCode);
        }
Exemple #13
0
        // Token: 0x0600023C RID: 572 RVA: 0x0000A644 File Offset: 0x00008844
        public uint SetDependencyExpression(string expression)
        {
            uint num = ClusapiMethods.SetClusterResourceDependencyExpression(this.Handle, expression);

            if (num != 0U)
            {
                throw AmExceptionHelper.ConstructClusterApiException((int)num, "SetClusterResourceDependencyExpression({0})", new object[]
                {
                    expression
                });
            }
            return(num);
        }
Exemple #14
0
        // Token: 0x060002F3 RID: 755 RVA: 0x0000D114 File Offset: 0x0000B314
        internal static int ClusterRegQueryValue(AmClusterRegkeyHandle RegKeyHandle, string lpszValueName, out RegistryValueKind valueType, IntPtr lpbData, ref int lpcbData)
        {
            int lpcbDataTmp  = lpcbData;
            int valueTypeInt = 0;
            int retCode      = ClusApiHook.CallBackDriver(ClusApiHooks.ClusterRegQueryValue, string.Format("KeyName = {0} lpszValueName = {1}", RegKeyHandle.Name, lpszValueName), delegate
            {
                retCode = ClusapiMethods.ClusterRegQueryValueInternal(RegKeyHandle, lpszValueName, out valueTypeInt, lpbData, ref lpcbDataTmp);
                return(retCode);
            });

            valueType = (RegistryValueKind)valueTypeInt;
            lpcbData  = lpcbDataTmp;
            return(retCode);
        }
        internal void RegisterObject(SafeHandle clusObject, ClusterNotifyFlags eventMask, IntPtr context)
        {
            AmTrace.Debug("Registering additional cluster objects for notification", new object[0]);
            int num = ClusapiMethods.RegisterClusterNotify(this.m_hChange, eventMask, clusObject, context);

            if (num != 0)
            {
                AmTrace.Error("RegisterClusterNotify for group state returned error 0x{0:X8}", new object[]
                {
                    num
                });
                throw AmExceptionHelper.ConstructClusterApiException(num, "RegisterClusterNotify(CLUSTER_CHANGE_GROUP_STATE)", new object[0]);
            }
        }
Exemple #16
0
        // Token: 0x06000215 RID: 533 RVA: 0x00009920 File Offset: 0x00007B20
        public string ParseStringFromPropList(string propName)
        {
            string empty;
            uint   num = ClusapiMethods.ResUtilFindSzProperty(this.RawBuffer, this.BufferSize, propName, out empty);

            if (num == 2U)
            {
                empty = string.Empty;
            }
            else if (num != 0U)
            {
                throw AmExceptionHelper.ConstructClusterApiException((int)num, "ResUtilFindSzProperty()", new object[0]);
            }
            return(empty);
        }
Exemple #17
0
        // Token: 0x060001BE RID: 446 RVA: 0x00008438 File Offset: 0x00006638
        private void SetNetworkControlData(AmClusterNetworkControlCode code, IntPtr buffer, uint bufferSize)
        {
            uint num  = 0U;
            int  num2 = ClusapiMethods.ClusterNetworkControl(this.Handle, IntPtr.Zero, code, buffer, bufferSize, IntPtr.Zero, 0U, out num);

            if (num2 != 0)
            {
                ClusterApiException ex = AmExceptionHelper.ConstructClusterApiException(num2, "ClusterNetworkControl(controlcode={0})", new object[]
                {
                    code
                });
                AmClusterNetwork.Tracer.TraceDebug((long)this.GetHashCode(), ex.Message);
                throw ex;
            }
        }
Exemple #18
0
        // Token: 0x06000214 RID: 532 RVA: 0x000098E0 File Offset: 0x00007AE0
        public int ParseIntFromPropList(string propName)
        {
            uint result;
            uint num = ClusapiMethods.ResUtilFindDwordProperty(this.RawBuffer, this.BufferSize, propName, out result);

            if (num == 2U)
            {
                result = 0U;
            }
            else if (num != 0U)
            {
                throw AmExceptionHelper.ConstructClusterApiException((int)num, "ResUtilFindDwordProperty()", new object[0]);
            }
            return((int)result);
        }
Exemple #19
0
 // Token: 0x06000244 RID: 580 RVA: 0x0000AAA4 File Offset: 0x00008CA4
 private static IEnumerable <string> EnumerateObjects(AmClusterResourceHandle handle, AmClusterResourceEnum objectType)
 {
     new List <string>(16);
     using (AmClusResourceEnumHandle enumHandle = ClusapiMethods.ClusterResourceOpenEnum(handle, objectType))
     {
         if (enumHandle.IsInvalid)
         {
             int lastWin32Error = Marshal.GetLastWin32Error();
             throw AmExceptionHelper.ConstructClusterApiException(lastWin32Error, "ClusterOpenResourceEnum(objecttype={0})", new object[]
             {
                 objectType
             });
         }
         int           entryIndex       = 0;
         int           objectNameLen    = 256;
         StringBuilder objectNameBuffer = new StringBuilder(objectNameLen);
         int           errorCode;
         for (;;)
         {
             objectNameLen = objectNameBuffer.Capacity;
             AmClusterResourceEnum objectTypeRetrived;
             errorCode = ClusapiMethods.ClusterResourceEnum(enumHandle, entryIndex, out objectTypeRetrived, objectNameBuffer, ref objectNameLen);
             if (errorCode == 259)
             {
                 goto IL_171;
             }
             if (errorCode == 234)
             {
                 objectNameBuffer.EnsureCapacity(objectNameLen);
             }
             else
             {
                 if (errorCode != 0)
                 {
                     break;
                 }
                 if (objectTypeRetrived == objectType)
                 {
                     yield return(objectNameBuffer.ToString());
                 }
                 entryIndex++;
             }
         }
         throw AmExceptionHelper.ConstructClusterApiException(errorCode, "ClusterResourceEnum()", new object[0]);
         IL_171 :;
     }
     yield break;
 }
Exemple #20
0
        // Token: 0x06000233 RID: 563 RVA: 0x0000A480 File Offset: 0x00008680
        public AmResourceState GetState()
        {
            uint            num  = 0U;
            uint            num2 = 0U;
            AmResourceState clusterResourceState = ClusapiMethods.GetClusterResourceState(this.Handle, null, ref num, null, ref num2);

            if (clusterResourceState == AmResourceState.Unknown)
            {
                int lastWin32Error = Marshal.GetLastWin32Error();
                throw AmExceptionHelper.ConstructClusterApiException(lastWin32Error, "GetClusterResourceState({0})", new object[]
                {
                    this.Name
                });
            }
            return(clusterResourceState);
        }
Exemple #21
0
        // Token: 0x060002AB RID: 683 RVA: 0x0000CC70 File Offset: 0x0000AE70
        internal static AmClusterHandle OpenCluster([In] string clusterName)
        {
            AmClusterHandle handle = null;

            ClusApiHook.CallBackDriver(ClusApiHooks.OpenCluster, string.Format("clusterName = {0}", clusterName), delegate
            {
                int result = 0;
                handle     = ClusapiMethods.OpenClusterInternal(clusterName);
                if (handle == null || handle.IsInvalid)
                {
                    result = Marshal.GetLastWin32Error();
                }
                return(result);
            });
            return(handle);
        }
Exemple #22
0
        // Token: 0x060002A4 RID: 676 RVA: 0x0000CB9C File Offset: 0x0000AD9C
        public static int ClusterRegDeleteKey(AmClusterRegkeyHandle RegKeyHandle, string lpszSubKey)
        {
            AmClusterRegkeyHandle amClusterRegkeyHandle = null;
            int retCode = ClusapiMethods.ClusterRegOpenKey(RegKeyHandle, lpszSubKey, RegSAM.Read, out amClusterRegkeyHandle);

            if (retCode == 0)
            {
                amClusterRegkeyHandle.Dispose();
                retCode = ClusApiHook.CallBackDriver(ClusApiHooks.ClusterRegDeleteKey, string.Format("RootKey = {0} Subkey = {1}", RegKeyHandle.Name, lpszSubKey), delegate
                {
                    retCode = ClusapiMethods.ClusterRegDeleteKeyUnsafe(RegKeyHandle, lpszSubKey);
                    return(retCode);
                });
            }
            return(retCode);
        }
Exemple #23
0
        // Token: 0x060002F7 RID: 759 RVA: 0x0000D28C File Offset: 0x0000B48C
        internal static int ClusterRegDeleteValue(AmClusterRegkeyHandle RegKeyHandle, string lpszValueName)
        {
            int num = 0;
            RegistryValueKind registryValueKind;
            int retCode = ClusapiMethods.ClusterRegQueryValue(RegKeyHandle, lpszValueName, out registryValueKind, IntPtr.Zero, ref num);

            if (retCode == 0)
            {
                retCode = ClusApiHook.CallBackDriver(ClusApiHooks.ClusterRegDeleteValue, string.Format("KeyName = {0} lpszValueName = {1}", RegKeyHandle.Name, lpszValueName), delegate
                {
                    retCode = ClusapiMethods.ClusterRegDeleteValueUnsafe(RegKeyHandle, lpszValueName);
                    return(retCode);
                });
            }
            return(retCode);
        }
Exemple #24
0
        // Token: 0x060002F5 RID: 757 RVA: 0x0000D1D0 File Offset: 0x0000B3D0
        internal static int ClusterRegSetValue(AmClusterRegkeyHandle RegKeyHandle, string lpszValueName, RegistryValueKind dwType, IntPtr lpbData, int cbData)
        {
            string text    = "ClusterRegSetValue";
            string text2   = string.Format("KeyName = {0} lpszValueName = {1}", RegKeyHandle.Name, lpszValueName);
            int    retCode = ClusApiHook.CallBackDriver(ClusApiHooks.ClusterRegSetValue, text2, delegate
            {
                retCode = ClusapiMethods.ClusterRegSetValueInternal(RegKeyHandle, lpszValueName, dwType, lpbData, cbData);
                return(retCode);
            });

            if (retCode != 0)
            {
                ReplayCrimsonEvents.CriticalClusterApiFailed.Log <string, string, int>(text, text2, retCode);
            }
            return(retCode);
        }
Exemple #25
0
        // Token: 0x060002EF RID: 751 RVA: 0x0000CF50 File Offset: 0x0000B150
        internal static int ClusterRegOpenKey(AmClusterRegkeyHandle RegKeyHandle, string lpszSubKey, RegSAM samDesired, out AmClusterRegkeyHandle phkResult)
        {
            AmClusterRegkeyHandle phkResultTmp = null;
            int retCode = ClusApiHook.CallBackDriver(ClusApiHooks.ClusterRegOpenKey, string.Format("RootKeyName = {0} SubKey = {1}", RegKeyHandle.Name, lpszSubKey), delegate
            {
                retCode = ClusapiMethods.ClusterRegOpenKeyInternal(RegKeyHandle, lpszSubKey, samDesired, out phkResultTmp);
                if (retCode == 0 && phkResultTmp != null)
                {
                    phkResultTmp.Name = RegKeyHandle.Name + "\\" + lpszSubKey;
                }
                return(retCode);
            });

            phkResult = phkResultTmp;
            return(retCode);
        }
 internal void Initialize(ClusterNotifyFlags eventMask, IntPtr context)
 {
     if (this.m_hChange == null || this.m_hChange.IsInvalid)
     {
         AmTrace.Debug("Creating cluster notification port", new object[0]);
         this.m_hChange = ClusapiMethods.CreateClusterNotifyPort(AmClusterNotifyHandle.InvalidHandle, this.m_hCluster, eventMask, context);
         if (this.m_hChange == null || this.m_hChange.IsInvalid)
         {
             int lastWin32Error = Marshal.GetLastWin32Error();
             AmTrace.Error("CreateClusterNotifyPort failed. Error code 0x{0:X8}", new object[]
             {
                 lastWin32Error
             });
             throw AmExceptionHelper.ConstructClusterApiException(lastWin32Error, "CreateClusterNotifyPort()", new object[0]);
         }
     }
 }
Exemple #27
0
        private bool CloseNotifyPort()
        {
            bool result = true;

            lock (this)
            {
                if (!this.m_isClosed)
                {
                    this.m_isClosed = true;
                    if (!this.IsInvalid)
                    {
                        AmTrace.Debug("Calling CloseClusterNotifyPort() (handle=0x{0:x})", new object[]
                        {
                            this.handle
                        });
                        try
                        {
                            result = ClusapiMethods.CloseClusterNotifyPort(this.handle);
                            goto IL_BD;
                        }
                        catch (AccessViolationException ex)
                        {
                            AmTrace.Error("Ignoring AccessViolationException exception while Closing cluster notify port (error={0})", new object[]
                            {
                                ex
                            });
                            goto IL_BD;
                        }
                    }
                    AmTrace.Debug("Skipped CloseClusterNotifyPort() since handle is invalid (handle=0x{0:x})", new object[]
                    {
                        this.handle
                    });
                }
                else
                {
                    AmTrace.Debug("Skipped CloseClusterNotifyPort() the handle was closed already (handle=0x{0:x})", new object[]
                    {
                        this.handle
                    });
                }
                IL_BD :;
            }
            return(result);
        }
        // Token: 0x06000222 RID: 546 RVA: 0x00009ED0 File Offset: 0x000080D0
        internal static object GetRaw(string valueName, AmClusterRegkeyHandle hKey, out bool doesValueExist)
        {
            IntPtr intPtr = IntPtr.Zero;
            int    num    = 1024;
            object result;

            try
            {
                intPtr = Marshal.AllocHGlobal(num);
                RegistryValueKind valueType;
                int num2 = ClusapiMethods.ClusterRegQueryValue(hKey, valueName, out valueType, intPtr, ref num);
                if (num2 == 234)
                {
                    int num3 = 0;
                    do
                    {
                        Marshal.FreeHGlobal(intPtr);
                        intPtr = Marshal.AllocHGlobal(num);
                        num2   = ClusapiMethods.ClusterRegQueryValue(hKey, valueName, out valueType, intPtr, ref num);
                    }while (num2 == 234 && num3++ < 3);
                }
                if (num2 == 2 || num2 == 1018)
                {
                    doesValueExist = false;
                    result         = null;
                }
                else
                {
                    if (num2 != 0)
                    {
                        throw AmExceptionHelper.ConstructClusterApiException(num2, "ClusterRegQueryValue()", new object[0]);
                    }
                    doesValueExist = true;
                    result         = AmClusterRegProperty.ParseRegistryValue(valueType, intPtr, num);
                }
            }
            finally
            {
                if (intPtr != IntPtr.Zero)
                {
                    Marshal.FreeHGlobal(intPtr);
                }
            }
            return(result);
        }
Exemple #29
0
        public static AmClusterPropListDisposable CreatePropListString(string name, string value, out int bufferSize)
        {
            int num  = 4 + AmClusPropListMaker.ClusPropValueSize(name) + AmClusPropListMaker.ClusPropValueSize(value) + 4;
            int num2 = AmClusPropListMaker.PaddingSize(num, 4);

            bufferSize = num + num2;
            IntPtr intPtr = Marshal.AllocHGlobal(bufferSize);

            string.Format("buffer is alloc'ed 0x{0:x} at 0x{1:x}", bufferSize, intPtr.ToInt64());
            int num3 = 0;

            num3 += AmClusPropListMaker.WriteHeader(intPtr, num3, 1);
            num3 += AmClusPropListMaker.WriteStringValue(intPtr, num3, 262147, name);
            num3 += AmClusPropListMaker.WriteStringValue(intPtr, num3, 65539, value);
            num3 += AmClusPropListMaker.WriteTerminator(intPtr, num3);
            ClusapiMethods.ResUtilVerifyPrivatePropertyList(intPtr, bufferSize);
            return(new AmClusterPropListDisposable(new SafeHGlobalHandle(intPtr), (uint)bufferSize));
        }
Exemple #30
0
        // Token: 0x060002F1 RID: 753 RVA: 0x0000D048 File Offset: 0x0000B248
        internal static int ClusterRegCreateKey(AmClusterRegkeyHandle RegKeyHandle, string lpszSubKey, uint options, RegSAM samDesired, IntPtr securityAttributes, out AmClusterRegkeyHandle phkResult, out uint disposition)
        {
            AmClusterRegkeyHandle phkResultTmp = null;
            uint dispositionTmp = 0U;
            int  retCode        = ClusApiHook.CallBackDriver(ClusApiHooks.ClusterRegCreateKey, string.Format("RootKeyName = {0} SubKey = {1}", RegKeyHandle.Name, lpszSubKey), delegate
            {
                retCode = ClusapiMethods.ClusterRegCreateKeyInternal(RegKeyHandle, lpszSubKey, options, samDesired, securityAttributes, out phkResultTmp, out dispositionTmp);
                if (retCode == 0 && phkResultTmp != null)
                {
                    phkResultTmp.Name = RegKeyHandle.Name + "\\" + lpszSubKey;
                }
                return(retCode);
            });

            phkResult   = phkResultTmp;
            disposition = dispositionTmp;
            return(retCode);
        }