Hi!
While trying to get Anarchy Online working with Wine, I discovered that dynamically getting symbols from the running program does not work properly in Wine.
The attached example code shows the problem; when running in Windows, I get this output
The mangled name is "?Instantiate@MyTestClass@@SAPAV1@PAVObjectArchive_c@fun@@@Z" Searching in "ntdll.dll" Searching in "kernel32.dll" Searching in "Factory.dll" Searching in "MSVCP60D.dll" Searching in "MSVCRTD.dll" Searching in "Test.dll" Found the function at 00321023 Creating a new object! The returned text is "Found the right one!"
whereas when running this in Wine, this is the output
[andrej@rivendell tst]$ PATH=$PATH:$PWD wine tst The mangled name is "?Instantiate@MyTestClass@@SAPAV1@PAVObjectArchive_c@fun@@@Z" Searching in "" Searching in "" Searching in "" Searching in "" Searching in "" Searching in "" Searching in "" Searching in "" The returned text is "<function for "MyTestClass" not found>"
If the test for a ".dll" ending is removed (as can be seen in the output, the name returned is empty, so it will always fail), this is the output
[andrej@rivendell tst]$ PATH=$PATH:$PWD wine tst The mangled name is "?Instantiate@MyTestClass@@SAPAV1@PAVObjectArchive_c@fun@@@Z" Searching in "" Searching in "" Found the function at 0x408a9023 Creating a new object! The returned text is "Found the right one!"
(If anybody needs the compiled code, and/or MSDS project files, please contact me directly.)
André Johansen a écrit :
Hi!
While trying to get Anarchy Online working with Wine, I discovered that dynamically getting symbols from the running program does not work properly in Wine.
what doesn't work is that toolhelp (in wine) doesn't properly set the szModule of the MODULEENTRY structure. But, since the rest of the fields are correctly set, this explains why your test work when you remove the test on the module ending with ".dll". If you'd use szExePath field instead of the szModule one, it'd work too.
I'll a fix later on for setting the szModule field.
A+
* Eric Pouech (Sun, 16 May 2004 08:20:01 +0200) wrote: | André Johansen a écrit : | > Hi! | > While trying to get Anarchy Online working with Wine, I discovered | > that dynamically getting symbols from the running program does not | > work properly in Wine. | what doesn't work is that toolhelp (in wine) doesn't properly set the | szModule of the MODULEENTRY structure. But, since the rest of the | fields are correctly set, this explains why your test work when you | remove the test on the module ending with ".dll". If you'd use | szExePath field instead of the szModule one, it'd work too. | | I'll a fix later on for setting the szModule field.
I've implemented a solution for the problem, please review carefully as I don't know Wine nor Win32 too well!
It might be overly complex, but I don't quite know the constant sizes or whether or not the executable path always has to contain a delimiter, so I've played the safe game.
I've also changed some of the other fields; according to MSDN: * th32ModuleID should be 1 * GlblcntUsage and ProccntUsage should be 0xFFFF http://msdn.microsoft.com/library/default.asp?url=/library/en-us/perfmon/base/moduleentry32_str.asp
I've implemented a solution for the problem, please review carefully as I don't know Wine nor Win32 too well!
sounds quite ok. I've attached my version of (basically same stuff, written a bit differently). Note: - the info from MSDN are likely to be for latest versions of toolhelp. Anyway, when we run Wine in Win9x mode, the th32ModuleID, GlblcntUsage, ProccntUsage have real meaning, so they still require a FIXME (even if the values from MSDN make more sense than the ones in place). - don't use const int, it will create unncessary variables A+