public static MiResult ClearElementAt(InstanceHandle handle, int _index) { NativeCimInstance instance = CimNativeApi.MarshalledObject.FromPointer <NativeCimInstance> (handle.DangerousGetHandle()); var properties = NativeCimPropertiesHelper.Deserialize(PropertiesOrSystem(instance)); properties.ElementAt(_index).Value = null; instance.Properties = NativeCimPropertiesHelper.Serialize(properties); handle.DangerousSetHandle((IntPtr)CimNativeApi.MarshalledObject.Create <NativeCimInstance>(instance)); return(MiResult.OK); }
public static MiResult GetElementCount(InstanceHandle handle, out int num) { NativeCimInstance instance = CimNativeApi.MarshalledObject.FromPointer <NativeCimInstance> (handle.DangerousGetHandle()); var properties = NativeCimPropertiesHelper.Deserialize(PropertiesOrSystem(instance)); num = properties.Count; return(MiResult.OK); }
public static MiResult GetElementAt_GetName(InstanceHandle handle, int _index, out string str) { NativeCimInstance instance = CimNativeApi.MarshalledObject.FromPointer <NativeCimInstance> (handle.DangerousGetHandle()); var properties = NativeCimPropertiesHelper.Deserialize(PropertiesOrSystem(instance)); int i = 0; str = null; foreach (var element in properties) { if (i == _index) { str = element.Name; break; } i++; } return(MiResult.OK); }
public static MiResult GetElementAt_GetValue(InstanceHandle handle, int _index, out object obj) { NativeCimInstance instance = CimNativeApi.MarshalledObject.FromPointer <NativeCimInstance> (handle.DangerousGetHandle()); obj = null; if (_index != -1) { var properties = NativeCimPropertiesHelper.Deserialize(PropertiesOrSystem(instance)); var element = properties.ElementAtOrDefault(_index); obj = element.Value; } return(MiResult.OK); }
public static MiResult AddElement(InstanceHandle handle, string name, object obj, object par, MiFlags miFlags) { NativeCimInstance instance = CimNativeApi.MarshalledObject.FromPointer <NativeCimInstance>(handle.DangerousGetHandle()); NativeCimProperties properties = NativeCimPropertiesHelper.Deserialize(instance.Properties); CimType type = CimConverter.GetCimType(obj.GetType()); properties.Add(new NativeCimProperty { Name = name, Type = type, Origin = "client", IsArray = false, IsLocal = false, Value = obj }); instance.Properties = NativeCimPropertiesHelper.Serialize(properties); handle.DangerousSetHandle((IntPtr)CimNativeApi.MarshalledObject.Create <NativeCimInstance>(instance)); return(MiResult.OK); }
public static MiResult GetElementAt_GetType(InstanceHandle handle, int _index, out MiType miType) { NativeCimInstance instance = CimNativeApi.MarshalledObject.FromPointer <NativeCimInstance> (handle.DangerousGetHandle()); var properties = NativeCimPropertiesHelper.Deserialize(PropertiesOrSystem(instance)); int i = 0; miType = MiType.Boolean; foreach (var element in properties) { if (i == _index) { Type type = element.Value.GetType(); miType = CimConverter.GetCimType(type).ToMiType(); break; } i++; } return(MiResult.OK); }
public static MiResult GetElementCount (InstanceHandle handle, out int num) { NativeCimInstance instance = CimNativeApi.MarshalledObject.FromPointer<NativeCimInstance> (handle.DangerousGetHandle ()); var properties = NativeCimPropertiesHelper.Deserialize (PropertiesOrSystem(instance)); num = properties.Count; return MiResult.OK; }
public static MiResult GetElement_GetIndex(InstanceHandle handle, string propertyName, out int num) { NativeCimInstance instance = CimNativeApi.MarshalledObject.FromPointer <NativeCimInstance> (handle.DangerousGetHandle()); var properties = NativeCimPropertiesHelper.Deserialize(PropertiesOrSystem(instance)); num = -1; int i = 0; foreach (var element in properties) { if (element.Name == propertyName) { num = i; break; } i++; } return(MiResult.OK); }
public static MiResult GetElementAt_GetValue (InstanceHandle handle, int _index, out object obj) { NativeCimInstance instance = CimNativeApi.MarshalledObject.FromPointer<NativeCimInstance> (handle.DangerousGetHandle ()); obj = null; if (_index != -1) { var properties = NativeCimPropertiesHelper.Deserialize (PropertiesOrSystem(instance)); var element = properties.ElementAtOrDefault (_index); obj = element.Value; } return MiResult.OK; }
public static MiResult ClearElementAt (InstanceHandle handle, int _index) { NativeCimInstance instance = CimNativeApi.MarshalledObject.FromPointer<NativeCimInstance> (handle.DangerousGetHandle ()); var properties = NativeCimPropertiesHelper.Deserialize (PropertiesOrSystem(instance)); properties.ElementAt(_index).Value = null; instance.Properties = NativeCimPropertiesHelper.Serialize (properties); handle.DangerousSetHandle ((IntPtr)CimNativeApi.MarshalledObject.Create<NativeCimInstance>(instance)); return MiResult.OK; }
public static MiResult GetElementAt_GetName (InstanceHandle handle, int _index, out string str) { NativeCimInstance instance = CimNativeApi.MarshalledObject.FromPointer<NativeCimInstance> (handle.DangerousGetHandle ()); var properties = NativeCimPropertiesHelper.Deserialize (PropertiesOrSystem(instance)); int i = 0; str = null; foreach (var element in properties) { if (i == _index) { str = element.Name; break; } i++; } return MiResult.OK; }
public static MiResult GetElementAt_GetType (InstanceHandle handle, int _index, out MiType miType) { NativeCimInstance instance = CimNativeApi.MarshalledObject.FromPointer<NativeCimInstance> (handle.DangerousGetHandle ()); var properties = NativeCimPropertiesHelper.Deserialize (PropertiesOrSystem(instance)); int i = 0; miType = MiType.Boolean; foreach (var element in properties) { if (i == _index) { Type type = element.Value.GetType (); miType = CimConverter.GetCimType (type).ToMiType(); break; } i++; } return MiResult.OK; }
public static MiResult AddElement (InstanceHandle handle, string name, object obj, object par, MiFlags miFlags) { NativeCimInstance instance = CimNativeApi.MarshalledObject.FromPointer<NativeCimInstance>(handle.DangerousGetHandle ()); NativeCimProperties properties = NativeCimPropertiesHelper.Deserialize (instance.Properties); CimType type = CimConverter.GetCimType (obj.GetType ()); properties.Add (new NativeCimProperty { Name = name, Type = type, Origin = "client", IsArray = false, IsLocal = false, Value = obj }); instance.Properties = NativeCimPropertiesHelper.Serialize (properties); handle.DangerousSetHandle ((IntPtr)CimNativeApi.MarshalledObject.Create<NativeCimInstance>(instance)); return MiResult.OK; }
public static MiResult GetElement_GetIndex (InstanceHandle handle, string propertyName, out int num) { NativeCimInstance instance = CimNativeApi.MarshalledObject.FromPointer<NativeCimInstance> (handle.DangerousGetHandle ()); var properties = NativeCimPropertiesHelper.Deserialize (PropertiesOrSystem(instance)); num = -1; int i = 0; foreach(var element in properties) { if (element.Name == propertyName) { num = i; break; } i++; } return MiResult.OK; }
internal static unsafe void Invoke(SessionHandle sessionHandle, MiOperationFlags operationFlags, OperationOptionsHandle operationOptionsHandle, string namespaceName, string className, string methodName, InstanceHandle instanceHandleForTargetOfInvocation, InstanceHandle instanceHandleForMethodParameters, OperationCallbacks operationCallbacks, out OperationHandle operationHandle) { NativeDestinationOptions options = CimNativeApi.GetDestinationOptions (sessionHandle); operationHandle = new OperationHandle(IntPtr.Zero, true); operationHandle.SetOperationCallback(IntPtr.Zero.ToPointer ()); NativeCimInstance instance = instanceHandleForTargetOfInvocation == null ? new NativeCimInstance() : CimNativeApi.MarshalledObject.FromPointer<NativeCimInstance>(instanceHandleForTargetOfInvocation.DangerousGetHandle ()); NativeCimInstance inSignature = instanceHandleForMethodParameters == null ? new NativeCimInstance() : CimNativeApi.MarshalledObject.FromPointer<NativeCimInstance>(instanceHandleForMethodParameters.DangerousGetHandle ()); NativeCimInstance result = CimNativeApi.InvokeMethod(options, namespaceName, className, methodName, instance, inSignature); IntPtr instancePtr = (IntPtr)CimNativeApi.MarshalledObject.Create<NativeCimInstance>(result); InstanceHandle resultHandle = new InstanceHandle(instancePtr, true); operationCallbacks.InstanceResultCallback.Invoke (new OperationCallbackProcessingContext(operationCallbacks.ManagedOperationContext), operationHandle, resultHandle, false, MiResult.OK, null, null); /* _MI_OperationCallbacks _MIOperationCallback; _MI_OperationCallbacks* _MIOperationCallbacksPointer; DangerousHandleAccessor dangerousHandleAccessor = null; DangerousHandleAccessor dangerousHandleAccessor1 = null; DangerousHandleAccessor dangerousHandleAccessor2 = null; DangerousHandleAccessor dangerousHandleAccessor3 = null; operationHandle = null; DangerousHandleAccessor dangerousHandleAccessor = new DangerousHandleAccessor(sessionHandle); try { dangerousHandleAccessor = dangerousHandleAccessor; DangerousHandleAccessor dangerousHandleAccessor1 = new DangerousHandleAccessor(operationOptionsHandle); try { dangerousHandleAccessor1 = dangerousHandleAccessor1; _MI_OperationOptions* _MIOperationOptionsPointer = (_MI_OperationOptions*)((void*)dangerousHandleAccessor1.DangerousGetHandle()); &_MIOperationCallback; 0; bool flag = operationCallbacks.SetMiOperationCallbacks(ref _MIOperationCallback); IntPtr hGlobalUni = Marshal.StringToHGlobalUni(namespaceName); IntPtr intPtr = hGlobalUni; try { IntPtr hGlobalUni1 = Marshal.StringToHGlobalUni(className); IntPtr intPtr1 = hGlobalUni1; try { IntPtr hGlobalUni2 = Marshal.StringToHGlobalUni(methodName); IntPtr intPtr2 = hGlobalUni2; try { _MI_Operation* _MIOperationPointer = (_MI_Operation*)<Module>.Microsoft.Management.Infrastructure.Native.MI_CLI_malloc_core((long)24); DangerousHandleAccessor dangerousHandleAccessor2 = new DangerousHandleAccessor(instanceHandleForTargetOfInvocation); try { dangerousHandleAccessor2 = dangerousHandleAccessor2; _MI_Instance* _MIInstancePointer = (_MI_Instance*)((void*)dangerousHandleAccessor2.DangerousGetHandle()); DangerousHandleAccessor dangerousHandleAccessor3 = new DangerousHandleAccessor(instanceHandleForMethodParameters); try { dangerousHandleAccessor3 = dangerousHandleAccessor3; _MI_Instance* _MIInstancePointer1 = (_MI_Instance*)((void*)dangerousHandleAccessor3.DangerousGetHandle()); void* voidPointer = (void*)dangerousHandleAccessor.DangerousGetHandle(); if (flag) { _MIOperationCallbacksPointer = &_MIOperationCallback; } else { _MIOperationCallbacksPointer = (_MI_OperationCallbacks*)((long)0); } _MI_OperationCallbacks* _MIOperationCallbacksPointer1 = _MIOperationCallbacksPointer; <Module>.?A0xf16864c4.MI_Session_Invoke((_MI_Session*)voidPointer, operationFlags, _MIOperationOptionsPointer, (void*)hGlobalUni, (void*)hGlobalUni1, (void*)hGlobalUni2, _MIInstancePointer, _MIInstancePointer1, _MIOperationCallbacksPointer1, _MIOperationPointer); OperationHandle operationHandle = new OperationHandle((IntPtr)_MIOperationPointer, true); operationHandle = operationHandle; operationHandle.SetOperationCallback((long)_MIOperationCallback); } dangerousHandleAccessor3.Dispose(); } dangerousHandleAccessor2.Dispose(); } finally { if (intPtr2 != IntPtr.Zero) { Marshal.FreeHGlobal(intPtr2); } } } finally { if (intPtr1 != IntPtr.Zero) { Marshal.FreeHGlobal(intPtr1); } } } finally { if (intPtr != IntPtr.Zero) { Marshal.FreeHGlobal(intPtr); } } } dangerousHandleAccessor1.Dispose(); } dangerousHandleAccessor.Dispose(); */ }