http://bugs.winehq.org/show_bug.cgi?id=31087
Bug #: 31087 Summary: WMI class property retrieval: some CIM data type to OLE variant (VT) mappings are incorrect (CIM_UINT32, CIM_UINT16 ...) Product: Wine Version: 1.5.7 Platform: x86 OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: wmi&wbemprox AssignedTo: wine-bugs@winehq.org ReportedBy: focht@gmx.net Classification: Unclassified
Hello,
another problem from app in bug 24875 which deserves an extra bug.
The app still fails with wine-1.5.7-252-g1f01355
The problems seems to be a WMI -> .NET type conversion problem of "ProcessId" property value.
"InvalidCastException" is thrown
--- snip --- 006ee1e8 7b83953f [HelperMethodFrame: 006ee1e8] 006ee258 040347f6 System.Management.PropertyData.MapWmiValueToValue(System.Object, System.Management.CimType, Boolean) 006ee2d0 04034204 System.Management.PropertyData.get_Value() 006ee2dc 04033aa6 System.Management.ManagementBaseObject.GetPropertyValue(System.String) 006ee2e8 04033a35 System.Management.ManagementBaseObject.get_Item(System.String) 006ee2ec 04034f70 SSCustomInstaller.SSInstaller.GetSongsmithSetupPathAndCopyMSI() 006ee31c 04034c0f SSCustomInstaller.SSInstaller.Install(System.Collections.IDictionary) 006ee350 649e3fc6 System.Configuration.Install.Installer.Install(System.Collections.IDictionary) 006ee398 649e5d38 System.Configuration.Install.AssemblyInstaller.Install(System.Collections.IDictionary) 006ee3d0 649e7f6e System.Configuration.Install.ManagedInstallerClass.InstallHelper(System.String[]) 006ee494 649e7734 System.Configuration.Install.ManagedInstallerClass.System.Configuration.Install.IManagedInstaller.ManagedInstall(System.String, Int32) --- snip ---
MapWmiValueToValue converts WMI values (wrapped in object) to native .NET value (wrapped in object) with type conversion if necessary.
MSDN claims "ProcessId" is CIM_UINT32/uint32.
The following link shows example "ProcessId" property dump with 'wbemdump' tool:
http://nukz.net/reference/wmi/hh/wmisdk/wbemdump_8wft.htm
--- snip --- wbemdump /Q /wy root\cimv2 WQL "SELECT ProcessId FROM Win32_process WHERE Name = 'Winmgmt.exe'"
This command produces the following output:
(WQL) SELECT ProcessId FROM Win32_Process WHERE Name = 'Winmgmt.exe'
ProcessId (CIM_UINT32/uint32) = 644 (0x284) --- snip ---
For CIM_UINT32 type there seems to be 'unboxing' taking place:
net_value = (uint)((int)(wmi_value))
I extracted a small C# snippet from the app .NET assembly which can be used for easy reproduction of the problem.
Save the following snippet to a text file (ex: "test.cs"):
--- snip test.cs --- using System; using System.Collections; using System.Management;
class TestProgram { [STAThread] static void Main(string[] args) { using (ManagementObjectSearcher searcher = new ManagementObjectSearcher("Select * from Win32_Process")) { new ManagementScope(@"root\CIMV2"); foreach (ManagementObject obj2 in searcher.Get()) { string str = obj2["ProcessId"].ToString(); } } } } --- snip test.cs ---
Compile it with C# compiler which is present if you installed .NET 2.0 Framework (winetricks).
--- snip --- $ wine "C:\windows\Microsoft.NET\Framework\v2.0.50727\csc.exe" /debug+ test.cs --- snip ---
Run and get the same backtrace as with installer.
The problem is CIMTYPE -> OLE Variant type conversion.
Source: http://source.winehq.org/git/wine.git/blob/d2661b802556e073760af5d70869fb55a...
--- snip --- 665 HRESULT get_propval( const struct view *view, UINT index, const WCHAR *name, VARIANT *ret, 666 CIMTYPE *type, LONG *flavor ) 667 { ... 681 switch (view->table->columns[column].type & COL_TYPE_MASK) 682 { 683 case CIM_STRING: 684 case CIM_DATETIME: 685 V_VT( ret ) = VT_BSTR; 686 V_BSTR( ret ) = SysAllocString( (const WCHAR *)(INT_PTR)val ); 687 break; 688 case CIM_SINT16: 689 V_VT( ret ) = VT_I2; 690 V_I2( ret ) = val; 691 break; 692 case CIM_UINT16: 693 V_VT( ret ) = VT_UI2; 694 V_UI2( ret ) = val; 695 break; 696 case CIM_SINT32: 697 V_VT( ret ) = VT_I4; 698 V_I4( ret ) = val; 699 break; 700 case CIM_UINT32: 701 V_VT( ret ) = VT_UI4; 702 V_UI4( ret ) = val; 703 break; 704 case CIM_SINT64: 705 V_VT( ret ) = VT_BSTR; 706 V_BSTR( ret ) = get_value_bstr( view->table, row, column ); 707 break; 708 case CIM_UINT64: 709 V_VT( ret ) = VT_BSTR; 710 V_BSTR( ret ) = get_value_bstr( view->table, row, column ); 711 break; ... --- snip ---
The unbox failure let me guess that CIM_UINT32 doesn't map to VT_UI4 but to VT_I4. Google "CIM_UINT32 VT_I4" and hit the first link -> book "Developing Wmi Solutions: A Guide to Windows Management ..." Bingo! There is a table which shows the type mapping (BTW good WMI resource to read...)
uint32 - VT_I4 - CIM_UINT32
While you're at it you might want to fix other type conversions (CIM_UINT16 ...) according to the table.
Regards
http://bugs.winehq.org/show_bug.cgi?id=31087
Anastasius Focht focht@gmx.net changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |dotnet, download, Installer URL| |http://research.microsoft.c | |om/en-us/um/redmond/project | |s/songsmith/download.html
http://bugs.winehq.org/show_bug.cgi?id=31087
Anastasius Focht focht@gmx.net changed:
What |Removed |Added ---------------------------------------------------------------------------- Blocks| |31088
http://bugs.winehq.org/show_bug.cgi?id=31087
Austin English austinenglish@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |austinenglish@gmail.com
http://bugs.winehq.org/show_bug.cgi?id=31087
--- Comment #1 from Hans Leidekker hans@meelstraat.net 2012-07-01 04:11:32 CDT --- (In reply to comment #0)
The unbox failure let me guess that CIM_UINT32 doesn't map to VT_UI4 but to VT_I4. Google "CIM_UINT32 VT_I4" and hit the first link -> book "Developing Wmi Solutions: A Guide to Windows Management ..." Bingo! There is a table which shows the type mapping (BTW good WMI resource to read...)
uint32 - VT_I4 - CIM_UINT32
Guess what's the first hit in Google now ;) And the book is wrong, according to my tests, some CIM_UINT32 properties map to VT_UI4, others map to VT_I4.
http://bugs.winehq.org/show_bug.cgi?id=31087
Anastasius Focht focht@gmx.net changed:
What |Removed |Added ---------------------------------------------------------------------------- Summary|WMI class property |WMI class property |retrieval: some CIM data |retrieval: support custom |type to OLE variant (VT) |CIM data type to OLE |mappings are incorrect |variant (VT) mapping for |(CIM_UINT32, CIM_UINT16 |properties (ProcessId |...) |CIM_UINT32 maps to VT_I4)
--- Comment #2 from Anastasius Focht focht@gmx.net 2012-07-01 05:32:21 CDT --- Hello Hans,
--- quote --- Guess what's the first hit in Google now ;) And the book is wrong, according to my tests, some CIM_UINT32 properties map to VT_UI4, others map to VT_I4. --- quote ---
Yeah, don't be evil ;-)
So your tests reveal there is a per-property CIM to OLE variant type mapping. That's so ... Microsoftish.
Additional per-property variant type field?
Adjusting summary for big brother.
Regards
http://bugs.winehq.org/show_bug.cgi?id=31087
Anastasius Focht focht@gmx.net changed:
What |Removed |Added ---------------------------------------------------------------------------- Fixed by SHA1| |8fc1c948c7caebb48c5bb78347e | |e45f719382b9d Status|NEW |RESOLVED Resolution| |FIXED
--- Comment #3 from Anastasius Focht focht@gmx.net 2012-07-02 13:55:46 CDT --- Hello,
this is fixed by commits
http://source.winehq.org/git/wine.git/commitdiff/cd340ac87f1c785bfab9c29df11...
http://source.winehq.org/git/wine.git/commitdiff/8fc1c948c7caebb48c5bb78347e...
Thanks Hans.
Regards
http://bugs.winehq.org/show_bug.cgi?id=31087
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #4 from Alexandre Julliard julliard@winehq.org 2012-07-03 14:15:58 CDT --- Closing bugs fixed in 1.5.8.
https://bugs.winehq.org/show_bug.cgi?id=31087
Anastasius Focht focht@gmx.net changed:
What |Removed |Added ---------------------------------------------------------------------------- URL|http://research.microsoft.c |https://web.archive.org/web |om/en-us/um/redmond/project |/20120713144250/http://down |s/songsmith/download.html |load.microsoft.com/download | |/C/8/4/C84204D1-16E2-4F50-8 | |964-E87FBE9B51B4/SongsmithS | |etup.1.02.msi