Microsoft KB Archive/231226

{|
 * width="100%"|

FIX: WinMgmt Halts If You Get a WMI Object from One Namespace and Put it in Another Namespace

 * }

Q231226

-

The information in this article applies to:


 * Windows Management Instrumentation, version 1.1

-

SYMPTOMS
In WMI version 1.1, if you get an object from one namespace by using GetObject and put the object into a different namespace by using PutObject, Windows Management will halt.

CAUSE
This is a confirmed bug in WMI 1.1.

RESOLUTION
If you are using WMI 1.5, this problem will not occur. If you are using WMI 1.1, upgrade to 1.5; otherwise, you must spawn a new instance of the class in the second namespace, and manually copy the property values from the object retrieved from the first namespace.

STATUS
This problem has been fixed in WMI version 1.5.

Steps to Reproduce Behavior
  Compile the following mof. This mof creates two namespaces, "namespace1" and "namespace2". Namespace2 is a child of namespace1. Both classes have an identical class named "test". An instance of test is created in namespace1: #pragma namespace("\\\\.\\ROOT")

instance of __namespace {   name = "namespace1"; };


 * 1) pragma namespace("\\\\.\\ROOT\\namespace1")

class test {   [key] string mykey; };

instance of test {   mykey = "a"; };

instance of __namespace {   name = "namespace2"; };


 * 1) pragma namespace("\\\\.\\ROOT\\namespace1\\namespace2")

class test {   [key] string mykey;

};   Run the following code in a C++ WMI client program. Error checking has been omitted for brevity: BSTR pNamespace1 = SysAllocString(L"root\\namespace1"); BSTR pNamespace2 = SysAllocString(L"namespace2"); IWbemServices *pIWbemServices1 = NULL; IWbemServices *pIWbemServices2 = NULL; IWbemLocator *pIWbemLocator = NULL;

CoCreateInstance(CLSID_WbemLocator,NULL,CLSCTX_INPROC_SERVER,IID_IWbemLocator,(LPVOID *) &pIWbemLocator);

// Connect to the first namespace pIWbemLocator->ConnectServer(pNamespace1,NULL,NULL,0L,0L,NULL,NULL,&pIWbemServices1); // Connect to the second namespace pIWbemServices1->OpenNamespace(pNamespace2,0,0,&pIWbemServices2,0);

// Retrieve the object from the first namespace IWbemClassObject *pObject = NULL; BSTR pObjectName = SysAllocString(L"test.mykey=\"a\""); pIWbemServices1->GetObject(pObjectName,0L,NULL,&pObject,NULL);  // Put the object into the second namespace. This will cause WMI 1.1 WinMgmt to crash pIWbemServices2->PutInstance(pObject,0,0,0); 

Additional query words: prodsms wmi wbem GetObject PutObject namespace crash WinMgmt

Keywords : kbsms200 kbsms200bug _IK kbWMI110bug kbWMI150fix

Issue type : kbbug

Technology : kbWMISearch kbAudDeveloper kbWMI110