Example #1
0
		public static MiResult GetNamespace (Microsoft.Management.Infrastructure.Native.InstanceHandle instanceHandle, out string str2)
		{
			IntPtr ptr = instanceHandle.DangerousGetHandle ();
			NativeCimInstance instance = CimNativeApi.MarshalledObject.FromPointer<NativeCimInstance>(ptr);
			str2 = instance.Namespace;
			return MiResult.OK;
		}
Example #2
0
		public static MiResult SetServerName (Microsoft.Management.Infrastructure.Native.InstanceHandle handle, string serverName)
		{
			IntPtr ptr = handle.DangerousGetHandle ();
			NativeCimInstance instance = CimNativeApi.MarshalledObject.FromPointer<NativeCimInstance>(ptr);
			instance.ServerName = serverName;
			return MiResult.OK;
		}
Example #3
0
		public static MiResult GetClass (Microsoft.Management.Infrastructure.Native.InstanceHandle instanceHandle, out ClassHandle classHandle)
		{
			MiResult result = MiResult.OK;
			IntPtr ptr = instanceHandle.DangerousGetHandle ();
			NativeCimInstance instance = CimNativeApi.MarshalledObject.FromPointer<NativeCimInstance> (ptr);
			classHandle = null;
			if (!string.IsNullOrEmpty (instance.ClassName)) {
				var options = CimNativeApi.GetDestinationOptions (new SessionHandle(instance.SessionHandle));
				var classObj = CimNativeApi.QueryClasses (options, instance.Namespace, CimNativeApi.WQLNamespace, "SELECT * FROM Meta_Class WHERE ClassName = '" + instance.ClassName + "'").FirstOrDefault ();
				classObj.SessionHandle = instance.SessionHandle;
				IntPtr classPtr = CimNativeApi.MarshalledObject.Create<NativeCimClass>(classObj);
				classHandle = new ClassHandle (classPtr, true);
			}
			return result;
		}
Example #4
0
 internal void SetHandleInternal(Microsoft.Win32.SafeHandles.SafeWaitHandle handle)
 {
     this.safeWaitHandle = handle;
     this.waitHandle = handle.DangerousGetHandle();
 }
 internal void SetParentCsp(Microsoft.Win32.SafeHandles.SafeCspHandle parentCsp) {
     bool addedRef = false;
     RuntimeHelpers.PrepareConstrainedRegions();
     try {
         parentCsp.DangerousAddRef(ref addedRef);
         IntPtr rawParentHandle = parentCsp.DangerousGetHandle();
         ParentCsp = rawParentHandle;
     }
     finally {
         if (addedRef) {
             parentCsp.DangerousRelease();
         }
     }
 }