Vista String bug … it’s done!
Posted on: October 27th, 2007I am glad to inform you, that I finally managed to solve the Vista string bug of the Irrlicht.NET CP wrapper (See the posting in the forum)
The problem was based on the fact that .NET marshalling does an implicit freeing of memory allocated in the unmanaged wrapper part and being returned as a function return value. Rewriting the code in Irrlicht.NET lib so this freeing is not done implicitly by the managed code, but by calling a special, newly introduced method for memory freeing in the unmanaged wrapper (freeUMMemory(…)) helped resolving the crashes.
string value;
try
{
//New way for string marshalling according to
// http://www.mono-project/Interop_With_Native_Libraries
ptr_value = GUIListBox_GetListItem(_raw, id);
value = Marshal.PtrToStringAnsi(ptr_value);
}
And the new code for memory release in unmanaged memory areas:
{
//New method used to free memory allocated in C++ wrapper
freeUMMemory(ptr_value, true);
}
The security issue with requirement of admin rights to run the app remains.
The new code needs testing with unicode chars, to see if all works correct.
Furthermore testing on Windows XP and Linux is required, but as I sticked to code examples from the mono project I am quite optimistic for it to work at least under Linux.
Edit: As a further remark I just tested the code on WindowsXP and it worked. So let’s hope lester can get it to work under Linux.
Good night all.
Thoran
Start Blogging…
Posted on: October 25th, 2007Hi there!
I am Thoran and I want to start with a short introdcution:
I am working on the Windows port of Irrlicht.NET CP. I have a background of several programming languages mostly on Windows. These include C++,C VB, VB.NET, C#. I am dedicated to hobby game development which is my motivation for getting Irrlicht.NETCP running as I want to use it to create platform independent game programs.
As lester already mentioned I am currently working on fixing this nasty Vista string bug. What I can say so far is one pitfall in running Irrlicht.NET CP on Vista:
- Use Administrator rights for running your Irrlicht.NET CP application.
You may ask why? The reason is that you need certain privileges to allow the DLLImport of Irrlicht.NET CP to work. It might be a more safer option to add these special privileges to your group you belong to, however I am not deep enough into Vista to tell you how. So the easy, unsecure approach is to use admin privileges to run your application.
Considering the strings bug, I hope to finally have found the solution, but it still needs testing and keep you updated on the progress.
So long
Thoran
The damn ATI again blowed
Posted on: October 25th, 2007Shit that’s gonna be a bad practice.
Everytime ATI releases a new driver the life becames harder and harder, despite the official release notes.
Look, the phoronix guys say they managed to bring compiz to life on it, but whatever I tried - nothing helped. It just doesn’t work.
Besides the 3d seems to be very unstable. Applications I’ve launched worked for about 10 minutes and then hung.
I’ll better downgrade to the stable opensource driver.
Trying to fix Vista string issues
Posted on: October 18th, 2007Today Thoran tried to fix strings conversion from managed to unmanaged code and back.
Here is what he wrote:
errValue = wcstombs_s(&size, str, (b.length()+1) * sizeof(wchar_t), b.c_str(),sizeof(wchar_t)*b.length());
if (errValue == 42) //returned value for char that could not be converted
str = "Unknown wide-char!";
I guess it’s working now, despite the unclear synopsis of the windows function. I’m wondering do the ms ppl allways create such functions with sometimes ridiculous syntax?
