internal ParameterContext(string className, WbemNative.IWbemServices wbemServices, WbemNative.IWbemContext wbemContext, WbemNative.IWbemObjectSink wbemSink)
 {
     this.className    = className;
     this.wbemServices = wbemServices;
     this.wbemContext  = wbemContext;
     this.wbemSink     = wbemSink;
 }
 int WbemNative.IWbemServices.DeleteClass(
     string className,
     Int32 flags,
     WbemNative.IWbemContext wbemContext,
     IntPtr wbemCallResult)
 {
     return((int)WbemNative.WbemStatus.WBEM_E_NOT_SUPPORTED);
 }
 int WbemNative.IWbemServices.PutInstance(
     WbemNative.IWbemClassObject pInst,
     Int32 lFlags,
     WbemNative.IWbemContext wbemContext,
     IntPtr wbemCallResult)
 {
     return((int)WbemNative.WbemStatus.WBEM_E_NOT_SUPPORTED);
 }
 int WbemNative.IWbemServices.DeleteClassAsync(
     string className,
     Int32 lFlags,
     WbemNative.IWbemContext wbemContext,
     WbemNative.IWbemObjectSink wbemSink)
 {
     return((int)WbemNative.WbemStatus.WBEM_E_NOT_SUPPORTED);
 }
 int WbemNative.IWbemServices.CreateClassEnumAsync(
     string superClassName,
     Int32 flags,
     WbemNative.IWbemContext wbemContext,
     WbemNative.IWbemObjectSink wbemSink)
 {
     return((int)WbemNative.WbemStatus.WBEM_E_NOT_SUPPORTED);
 }
 int WbemNative.IWbemServices.DeleteInstance(
     string objectPath,
     Int32 flags,
     WbemNative.IWbemContext wbemContext,
     IntPtr wbemCallResult)
 {
     return((int)WbemNative.WbemStatus.WBEM_E_NOT_SUPPORTED);
 }
 int WbemNative.IWbemServices.PutClassAsync(
     WbemNative.IWbemClassObject wbemObject,
     Int32 flags,
     WbemNative.IWbemContext wbemContext,
     WbemNative.IWbemObjectSink wbemSink)
 {
     return((int)WbemNative.WbemStatus.WBEM_E_NOT_SUPPORTED);
 }
        int WbemNative.IWbemServices.PutInstanceAsync(
            WbemNative.IWbemClassObject wbemObject,
            Int32 lFlags,
            WbemNative.IWbemContext wbemContext,
            WbemNative.IWbemObjectSink wbemSink
            )
        {
            if (wbemObject == null || wbemContext == null || wbemSink == null || this.wbemServices == null)
            {
                return((int)WbemNative.WbemStatus.WBEM_E_INVALID_PARAMETER);
            }

            using (ServiceModelActivity activity = DiagnosticUtility.ShouldUseActivity ? ServiceModelActivity.CreateBoundedActivity() : null)
            {
                try
                {
                    object val   = null;
                    int    type  = 0;
                    int    favor = 0;
                    WbemException.ThrowIfFail(wbemObject.Get("__CLASS", 0, ref val, ref type, ref favor));
                    string className = (string)val;
                    ServiceModelActivity.Start(activity, SR.GetString(SR.WmiPutInstance, string.IsNullOrEmpty(className) ? string.Empty : className), ActivityType.WmiPutInstance);

                    ParameterContext parms        = new ParameterContext(className, this.wbemServices, wbemContext, wbemSink);
                    WbemInstance     wbemInstance = new WbemInstance(parms, wbemObject);
                    IWmiProvider     wmiProvider  = this.GetProvider(parms.ClassName);
                    if (wmiProvider.PutInstance(new InstanceContext(wbemInstance)))
                    {
                        wbemInstance.Indicate();
                    }

                    WbemException.ThrowIfFail(wbemSink.SetStatus((int)WbemNative.tag_WBEM_STATUS_TYPE.WBEM_STATUS_COMPLETE,
                                                                 (int)WbemNative.WbemStatus.WBEM_S_NO_ERROR, null, null));
                }
                catch (WbemException e)
                {
                    DiagnosticUtility.EventLog.LogEvent(TraceEventType.Error, (ushort)System.Runtime.Diagnostics.EventLogCategory.Wmi, (uint)System.Runtime.Diagnostics.EventLogEventId.WmiPutInstanceFailed,
                                                        TraceUtility.CreateSourceString(this), e.ToString());
                    wbemSink.SetStatus((int)WbemNative.tag_WBEM_STATUS_TYPE.WBEM_STATUS_COMPLETE,
                                       e.ErrorCode, null, null);
                    return(e.ErrorCode);
                }
#pragma warning suppress 56500 // covered by FxCOP
                catch (Exception e)
                {
                    DiagnosticUtility.EventLog.LogEvent(TraceEventType.Error, (ushort)System.Runtime.Diagnostics.EventLogCategory.Wmi, (uint)System.Runtime.Diagnostics.EventLogEventId.WmiPutInstanceFailed,
                                                        TraceUtility.CreateSourceString(this), e.ToString());
                    wbemSink.SetStatus((int)WbemNative.tag_WBEM_STATUS_TYPE.WBEM_STATUS_COMPLETE,
                                       (int)WbemNative.WbemStatus.WBEM_E_FAILED, null, null);
                    return((int)WbemNative.WbemStatus.WBEM_E_FAILED);
                }
                finally
                {
                    Marshal.ReleaseComObject(wbemSink);
                }
            }
            return((int)WbemNative.WbemStatus.WBEM_S_NO_ERROR);
        }
 int WbemNative.IWbemServices.CreateClassEnum(
     string superClassName,
     Int32 flags,
     WbemNative.IWbemContext wbemContext,
     out WbemNative.IEnumWbemClassObject wbemEnum)
 {
     wbemEnum = null;
     return((int)WbemNative.WbemStatus.WBEM_E_NOT_SUPPORTED);
 }
 int WbemNative.IWbemServices.ExecNotificationQueryAsync(
     string queryLanguage,
     string query,
     Int32 flags,
     WbemNative.IWbemContext wbemContext,
     WbemNative.IWbemObjectSink wbemSink)
 {
     return((int)WbemNative.WbemStatus.WBEM_E_NOT_SUPPORTED);
 }
 int WbemNative.IWbemServices.OpenNamespace(
     string nameSpace,
     Int32 flags,
     WbemNative.IWbemContext wbemContext,
     ref WbemNative.IWbemServices wbemServices,
     IntPtr wbemCallResult
     )
 {
     return((int)WbemNative.WbemStatus.WBEM_E_NOT_SUPPORTED);
 }
 int WbemNative.IWbemServices.CreateInstanceEnum(
     string filter,
     Int32 flags,
     WbemNative.IWbemContext wbemContext,
     out WbemNative.IEnumWbemClassObject wbemEnum
     )
 {
     wbemEnum = null;
     return((int)WbemNative.WbemStatus.WBEM_E_NOT_SUPPORTED);
 }
 int WbemNative.IWbemServices.ExecNotificationQuery(
     string queryLanguage,
     string query,
     Int32 flags,
     WbemNative.IWbemContext wbemContext,
     out WbemNative.IEnumWbemClassObject wbemEnum)
 {
     wbemEnum = null;
     return((int)WbemNative.WbemStatus.WBEM_E_NOT_SUPPORTED);
 }
 int WbemNative.IWbemServices.GetObject(
     string objectPath,
     Int32 flags,
     WbemNative.IWbemContext wbemContext,
     ref WbemNative.IWbemClassObject wbemObject,
     IntPtr wbemResult
     )
 {
     return((int)WbemNative.WbemStatus.WBEM_E_NOT_SUPPORTED);
 }
        int WbemNative.IWbemServices.GetObjectAsync(
            string objectPath,
            Int32 flags,
            WbemNative.IWbemContext wbemContext,
            WbemNative.IWbemObjectSink wbemSink)
        {
            if (wbemContext == null || wbemSink == null || this.wbemServices == null)
            {
                return((int)WbemNative.WbemStatus.WBEM_E_INVALID_PARAMETER);
            }

            using (ServiceModelActivity activity = DiagnosticUtility.ShouldUseActivity ?
                                                   ServiceModelActivity.CreateActivity(true, SR.GetString(SR.WmiGetObject, string.IsNullOrEmpty(objectPath) ? string.Empty : objectPath), ActivityType.WmiGetObject) : null)
            {
                try
                {
                    ObjectPathRegex  objPathRegex = new ObjectPathRegex(objectPath);
                    ParameterContext parms        = new ParameterContext(objPathRegex.ClassName, this.wbemServices, wbemContext, wbemSink);
                    WbemInstance     wbemInstance = new WbemInstance(parms, objPathRegex);
                    IWmiProvider     wmiProvider  = this.GetProvider(parms.ClassName);
                    if (wmiProvider.GetInstance(new InstanceContext(wbemInstance)))
                    {
                        wbemInstance.Indicate();
                    }

                    WbemException.ThrowIfFail(wbemSink.SetStatus(
                                                  (int)WbemNative.tag_WBEM_STATUS_TYPE.WBEM_STATUS_COMPLETE,
                                                  (int)WbemNative.WbemStatus.WBEM_S_NO_ERROR,
                                                  null,
                                                  null));
                }
                catch (WbemException e)
                {
                    DiagnosticUtility.EventLog.LogEvent(TraceEventType.Error, (ushort)System.Runtime.Diagnostics.EventLogCategory.Wmi, (uint)System.Runtime.Diagnostics.EventLogEventId.WmiGetObjectFailed,
                                                        TraceUtility.CreateSourceString(this), e.ToString());
                    wbemSink.SetStatus((int)WbemNative.tag_WBEM_STATUS_TYPE.WBEM_STATUS_COMPLETE,
                                       e.ErrorCode, null, null);
                    return(e.ErrorCode);
                }
#pragma warning suppress 56500 // covered by FxCOP
                catch (Exception e)
                {
                    DiagnosticUtility.EventLog.LogEvent(TraceEventType.Error, (ushort)System.Runtime.Diagnostics.EventLogCategory.Wmi, (uint)System.Runtime.Diagnostics.EventLogEventId.WmiGetObjectFailed,
                                                        TraceUtility.CreateSourceString(this), e.ToString());
                    wbemSink.SetStatus((int)WbemNative.tag_WBEM_STATUS_TYPE.WBEM_STATUS_COMPLETE,
                                       (int)WbemNative.WbemStatus.WBEM_E_FAILED, null, null);
                    return((int)WbemNative.WbemStatus.WBEM_E_FAILED);
                }
                finally
                {
                    Marshal.ReleaseComObject(wbemSink);
                }
            }
            return((int)WbemNative.WbemStatus.WBEM_S_NO_ERROR);
        }
 int WbemNative.IWbemServices.ExecMethod(
     string objectPath,
     string methodName,
     Int32 flags,
     WbemNative.IWbemContext wbemContext,
     WbemNative.IWbemClassObject wbemInParams,
     ref WbemNative.IWbemClassObject wbemOutParams,
     IntPtr wbemCallResult)
 {
     return((int)WbemNative.WbemStatus.WBEM_E_NOT_SUPPORTED);
 }
        int WbemNative.IWbemServices.CreateInstanceEnumAsync(
            string className,
            Int32 flags,
            WbemNative.IWbemContext wbemContext,
            WbemNative.IWbemObjectSink wbemSink)
        {
            if (wbemContext == null || wbemSink == null || this.wbemServices == null)
            {
                return((int)WbemNative.WbemStatus.WBEM_E_INVALID_PARAMETER);
            }

            try
            {
                ParameterContext parms       = new ParameterContext(className, this.wbemServices, wbemContext, wbemSink);
                IWmiProvider     wmiProvider = this.GetProvider(parms.ClassName);
                wmiProvider.EnumInstances(new InstancesContext(parms));

                WbemException.ThrowIfFail(wbemSink.SetStatus(
                                              (int)WbemNative.tag_WBEM_STATUS_TYPE.WBEM_STATUS_COMPLETE,
                                              (int)WbemNative.WbemStatus.WBEM_S_NO_ERROR,
                                              null,
                                              null));
            }
            catch (WbemException e)
            {
                wbemSink.SetStatus((int)WbemNative.tag_WBEM_STATUS_TYPE.WBEM_STATUS_COMPLETE,
                                   e.ErrorCode, null, null);
                DiagnosticUtility.EventLog.LogEvent(TraceEventType.Error,
                                                    (ushort)System.Runtime.Diagnostics.EventLogCategory.Wmi,
                                                    (uint)System.Runtime.Diagnostics.EventLogEventId.WmiCreateInstanceFailed,
                                                    className,
                                                    e.ToString());
                return(e.ErrorCode);
            }
#pragma warning suppress 56500 // covered by FxCOP
            catch (Exception e)
            {
                DiagnosticUtility.EventLog.LogEvent(TraceEventType.Error,
                                                    (ushort)System.Runtime.Diagnostics.EventLogCategory.Wmi,
                                                    (uint)System.Runtime.Diagnostics.EventLogEventId.WmiCreateInstanceFailed,
                                                    className,
                                                    e.ToString());
                wbemSink.SetStatus((int)WbemNative.tag_WBEM_STATUS_TYPE.WBEM_STATUS_COMPLETE,
                                   (int)WbemNative.WbemStatus.WBEM_E_FAILED, null, null);
                return((int)WbemNative.WbemStatus.WBEM_E_FAILED);
            }
            finally
            {
                Marshal.ReleaseComObject(wbemSink);
            }
            return((int)WbemNative.WbemStatus.WBEM_S_NO_ERROR);
        }
        int WbemNative.IWbemProviderInit.Initialize(
            string wszUser,
            Int32 lFlags,
            string wszNamespace,
            string wszLocale,
            WbemNative.IWbemServices wbemServices,
            WbemNative.IWbemContext wbemContext,
            WbemNative.IWbemProviderInitSink wbemSink
            )
        {
            if (wbemServices == null || wbemContext == null || wbemSink == null)
            {
                return((int)WbemNative.WbemStatus.WBEM_E_INVALID_PARAMETER);
            }

            try
            {
                MTAExecute(new WaitCallback(this.RelocateWbemServicesRCWToMTA), wbemServices);
                wbemSink.SetStatus((int)WbemNative.tag_WBEM_EXTRA_RETURN_CODES.WBEM_S_INITIALIZED, 0);
            }
            catch (WbemException e)
            {
                wbemSink.SetStatus(e.ErrorCode, 0);
                return(e.ErrorCode);
            }
#pragma warning suppress 56500 // covered by FxCOP
            catch (Exception)
            {
                wbemSink.SetStatus((int)WbemNative.WbemStatus.WBEM_E_FAILED, 0);
                return((int)WbemNative.WbemStatus.WBEM_E_FAILED);
            }
            finally
            {
                // WMI relies on destructor of this interface to perform certain task
                // explicitly release this so that the GC won't hold on to the ref of
                // this after the function
                Marshal.ReleaseComObject(wbemSink);
            }

            return((int)WbemNative.WbemStatus.WBEM_S_NO_ERROR);
        }
 int WbemNative.IWbemServices.GetObjectAsync(string objectPath, int flags, WbemNative.IWbemContext wbemContext, WbemNative.IWbemObjectSink wbemSink)
 {
     if (((wbemContext == null) || (wbemSink == null)) || (this.wbemServices == null))
     {
         return(-2147217400);
     }
     using (DiagnosticUtility.ShouldUseActivity ? ServiceModelActivity.CreateActivity(true, System.ServiceModel.SR.GetString("WmiGetObject", new object[] { string.IsNullOrEmpty(objectPath) ? string.Empty : objectPath }), ActivityType.WmiGetObject) : null)
     {
         try
         {
             ObjectPathRegex  objPathRegex = new ObjectPathRegex(objectPath);
             ParameterContext parms        = new ParameterContext(objPathRegex.ClassName, this.wbemServices, wbemContext, wbemSink);
             WbemInstance     wbemInstance = new WbemInstance(parms, objPathRegex);
             if (this.GetProvider(parms.ClassName).GetInstance(new InstanceContext(wbemInstance)))
             {
                 wbemInstance.Indicate();
             }
             WbemException.ThrowIfFail(wbemSink.SetStatus(0, 0, null, null));
         }
         catch (WbemException exception)
         {
             DiagnosticUtility.EventLog.LogEvent(TraceEventType.Error, EventLogCategory.Wmi, (EventLogEventId)(-1073610740), new string[] { TraceUtility.CreateSourceString(this), exception.ToString() });
             wbemSink.SetStatus(0, exception.ErrorCode, null, null);
             return(exception.ErrorCode);
         }
         catch (Exception exception2)
         {
             DiagnosticUtility.EventLog.LogEvent(TraceEventType.Error, EventLogCategory.Wmi, (EventLogEventId)(-1073610740), new string[] { TraceUtility.CreateSourceString(this), exception2.ToString() });
             wbemSink.SetStatus(0, -2147217407, null, null);
             return(-2147217407);
         }
         finally
         {
             Marshal.ReleaseComObject(wbemSink);
         }
     }
     return(0);
 }
 int WbemNative.IWbemServices.ExecQuery(string queryLanguage, string query, int flags, WbemNative.IWbemContext wbemContext, out WbemNative.IEnumWbemClassObject wbemEnum)
 {
     wbemEnum = null;
     return(-2147217396);
 }
 int WbemNative.IWbemServices.ExecQueryAsync(string queryLanguage, string query, int flags, WbemNative.IWbemContext wbemContext, WbemNative.IWbemObjectSink wbemSink)
 {
     if (((wbemContext == null) || (wbemSink == null)) || (this.wbemServices == null))
     {
         return(-2147217400);
     }
     try
     {
         QueryRegex       regex = new QueryRegex(query);
         ParameterContext parms = new ParameterContext(regex.ClassName, this.wbemServices, wbemContext, wbemSink);
         this.GetProvider(parms.ClassName).EnumInstances(new InstancesContext(parms));
         WbemException.ThrowIfFail(wbemSink.SetStatus(0, 0, null, null));
     }
     catch (WbemException exception)
     {
         DiagnosticUtility.EventLog.LogEvent(TraceEventType.Error, EventLogCategory.Wmi, (EventLogEventId)(-1073610736), new string[] { exception.ToString() });
         wbemSink.SetStatus(0, exception.ErrorCode, null, null);
         return(exception.ErrorCode);
     }
     catch (Exception exception2)
     {
         DiagnosticUtility.EventLog.LogEvent(TraceEventType.Error, EventLogCategory.Wmi, (EventLogEventId)(-1073610736), new string[] { exception2.ToString() });
         wbemSink.SetStatus(0, -2147217407, null, null);
         return(-2147217407);
     }
     finally
     {
         Marshal.ReleaseComObject(wbemSink);
     }
     return(0);
 }
 int WbemNative.IWbemServices.GetObject(string objectPath, int flags, WbemNative.IWbemContext wbemContext, ref WbemNative.IWbemClassObject wbemObject, IntPtr wbemResult)
 {
     return(-2147217396);
 }
 int WbemNative.IWbemServices.OpenNamespace(string nameSpace, int flags, WbemNative.IWbemContext wbemContext, ref WbemNative.IWbemServices wbemServices, IntPtr wbemCallResult)
 {
     return(-2147217396);
 }
 int WbemNative.IWbemServices.PutClass(WbemNative.IWbemClassObject wbemObject, int flags, WbemNative.IWbemContext wbemContext, IntPtr wbemCallResult)
 {
     return(-2147217396);
 }
 int WbemNative.IWbemServices.PutClassAsync(WbemNative.IWbemClassObject wbemObject, int flags, WbemNative.IWbemContext wbemContext, WbemNative.IWbemObjectSink wbemSink)
 {
     return(-2147217396);
 }
 int WbemNative.IWbemServices.PutInstance(WbemNative.IWbemClassObject pInst, int lFlags, WbemNative.IWbemContext wbemContext, IntPtr wbemCallResult)
 {
     return(-2147217396);
 }
 int WbemNative.IWbemServices.PutInstanceAsync(WbemNative.IWbemClassObject wbemObject, int lFlags, WbemNative.IWbemContext wbemContext, WbemNative.IWbemObjectSink wbemSink)
 {
     if (((wbemObject == null) || (wbemContext == null)) || ((wbemSink == null) || (this.wbemServices == null)))
     {
         return(-2147217400);
     }
     using (ServiceModelActivity activity = DiagnosticUtility.ShouldUseActivity ? ServiceModelActivity.CreateBoundedActivity() : null)
     {
         try
         {
             WbemException.ThrowIfFail(wbemObject.Get("__CLASS", 0, null, 0, 0));
             string str = (string)pVal;
             ServiceModelActivity.Start(activity, System.ServiceModel.SR.GetString("WmiPutInstance", new object[] { string.IsNullOrEmpty(str) ? string.Empty : str }), ActivityType.WmiPutInstance);
             ParameterContext parms        = new ParameterContext(str, this.wbemServices, wbemContext, wbemSink);
             WbemInstance     wbemInstance = new WbemInstance(parms, wbemObject);
             if (this.GetProvider(parms.ClassName).PutInstance(new InstanceContext(wbemInstance)))
             {
                 wbemInstance.Indicate();
             }
             WbemException.ThrowIfFail(wbemSink.SetStatus(0, 0, null, null));
         }
         catch (WbemException exception)
         {
             DiagnosticUtility.EventLog.LogEvent(TraceEventType.Error, EventLogCategory.Wmi, (EventLogEventId)(-1073610739), new string[] { TraceUtility.CreateSourceString(this), exception.ToString() });
             wbemSink.SetStatus(0, exception.ErrorCode, null, null);
             return(exception.ErrorCode);
         }
         catch (Exception exception2)
         {
             DiagnosticUtility.EventLog.LogEvent(TraceEventType.Error, EventLogCategory.Wmi, (EventLogEventId)(-1073610739), new string[] { TraceUtility.CreateSourceString(this), exception2.ToString() });
             wbemSink.SetStatus(0, -2147217407, null, null);
             return(-2147217407);
         }
         finally
         {
             Marshal.ReleaseComObject(wbemSink);
         }
     }
     return(0);
 }
        int WbemNative.IWbemServices.ExecMethodAsync(
            string objectPath,
            string methodName,
            Int32 flags,
            WbemNative.IWbemContext wbemContext,
            WbemNative.IWbemClassObject wbemInParams,
            WbemNative.IWbemObjectSink wbemSink)
        {
            if (wbemContext == null || wbemInParams == null || wbemSink == null || this.wbemServices == null)
            {
                return((int)WbemNative.WbemStatus.WBEM_E_INVALID_PARAMETER);
            }

            int result = (int)WbemNative.WbemStatus.WBEM_S_NO_ERROR;

            try
            {
                ObjectPathRegex  objPathRegex = new ObjectPathRegex(objectPath);
                ParameterContext parms        = new ParameterContext(objPathRegex.ClassName, this.wbemServices, wbemContext, wbemSink);
                WbemInstance     wbemInstance = new WbemInstance(parms, objPathRegex);

                MethodContext methodContext = new MethodContext(parms, methodName, wbemInParams, wbemInstance);
                IWmiProvider  wmiProvider   = this.GetProvider(parms.ClassName);
                if (!wmiProvider.InvokeMethod(methodContext))
                {
                    result = (int)WbemNative.WbemStatus.WBEM_E_NOT_FOUND;
                }

                WbemException.ThrowIfFail(wbemSink.SetStatus(
                                              (int)WbemNative.tag_WBEM_STATUS_TYPE.WBEM_STATUS_COMPLETE,
                                              (int)result,
                                              null,
                                              null));
            }
            catch (WbemException e)
            {
                DiagnosticUtility.EventLog.LogEvent(TraceEventType.Error,
                                                    (ushort)System.Runtime.Diagnostics.EventLogCategory.Wmi,
                                                    (uint)System.Runtime.Diagnostics.EventLogEventId.WmiExecMethodFailed,
                                                    e.ToString());
                result = e.ErrorCode;
                wbemSink.SetStatus((int)WbemNative.tag_WBEM_STATUS_TYPE.WBEM_STATUS_COMPLETE,
                                   result, null, null);
            }
#pragma warning suppress 56500 // covered by FxCOP
            catch (Exception e)
            {
                DiagnosticUtility.EventLog.LogEvent(TraceEventType.Error,
                                                    (ushort)System.Runtime.Diagnostics.EventLogCategory.Wmi,
                                                    (uint)System.Runtime.Diagnostics.EventLogEventId.WmiExecMethodFailed,
                                                    e.ToString());
                result = (int)WbemNative.WbemStatus.WBEM_E_FAILED;
                wbemSink.SetStatus((int)WbemNative.tag_WBEM_STATUS_TYPE.WBEM_STATUS_COMPLETE,
                                   (int)result, null, null);
            }
            finally
            {
                Marshal.ReleaseComObject(wbemSink);
            }
            return(result);
        }
 int WbemNative.IWbemServices.ExecNotificationQueryAsync(string queryLanguage, string query, int flags, WbemNative.IWbemContext wbemContext, WbemNative.IWbemObjectSink wbemSink)
 {
     return(-2147217396);
 }
 internal ParameterContext(string className, WbemNative.IWbemServices wbemServices, WbemNative.IWbemContext wbemContext, WbemNative.IWbemObjectSink wbemSink)
 {
     this.className = className;
     this.wbemServices = wbemServices;
     this.wbemContext = wbemContext;
     this.wbemSink = wbemSink;
 }
        int WbemNative.IWbemServices.ExecMethodAsync(string objectPath, string methodName, int flags, WbemNative.IWbemContext wbemContext, WbemNative.IWbemClassObject wbemInParams, WbemNative.IWbemObjectSink wbemSink)
        {
            if (((wbemContext == null) || (wbemInParams == null)) || ((wbemSink == null) || (this.wbemServices == null)))
            {
                return(-2147217400);
            }
            int hResult = 0;

            try
            {
                ObjectPathRegex  objPathRegex = new ObjectPathRegex(objectPath);
                ParameterContext parms        = new ParameterContext(objPathRegex.ClassName, this.wbemServices, wbemContext, wbemSink);
                WbemInstance     wbemInstance = new WbemInstance(parms, objPathRegex);
                MethodContext    method       = new MethodContext(parms, methodName, wbemInParams, wbemInstance);
                if (!this.GetProvider(parms.ClassName).InvokeMethod(method))
                {
                    hResult = -2147217406;
                }
                WbemException.ThrowIfFail(wbemSink.SetStatus(0, hResult, null, null));
            }
            catch (WbemException exception)
            {
                DiagnosticUtility.EventLog.LogEvent(TraceEventType.Error, EventLogCategory.Wmi, (EventLogEventId)(-1073610735), new string[] { exception.ToString() });
                hResult = exception.ErrorCode;
                wbemSink.SetStatus(0, hResult, null, null);
            }
            catch (Exception exception2)
            {
                DiagnosticUtility.EventLog.LogEvent(TraceEventType.Error, EventLogCategory.Wmi, (EventLogEventId)(-1073610735), new string[] { exception2.ToString() });
                hResult = -2147217407;
                wbemSink.SetStatus(0, hResult, null, null);
            }
            finally
            {
                Marshal.ReleaseComObject(wbemSink);
            }
            return(hResult);
        }