Debugging C++ DLL

Posted By: VeT

Debugging C++ DLL - 10/24/09 08:31

Jcl, please, look there:
http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=295297
Posted By: jcl

Re: Debugging C++ DLL - 10/26/09 07:22

I just noticed that your code looks buggy:

dFloat* globalFrame[16] = {0,1,0,0, 1,0,0,0, 0,0,-1,0, 0,0,0,1};

You probably meant to define an array of floats and not of pointers, that's why it won't work.

As to your first question, the engine loads all API(...) DLLs at the time when you see the message "compiling..." or "loading..." in the startup window.
Posted By: VeT

Re: Debugging C++ DLL - 10/31/09 23:18

Okay, thanks for answers... but how i can get this:

I get crash if i use action
Code:
action box_newt()
{
	newton_addentity(me, 75, NEWTON_BOX, onforceandtorque);
}



But everything works fine with
Code:
action box_newt()
{
	wait(3);
	newton_addentity(me, 75, NEWTON_BOX, onforceandtorque);
}



newton_addentity() calls some functions from DLL... at the first look, they are not loaded while calling them, without "wait"
Posted By: DJBMASTER

Re: Debugging C++ DLL - 11/01/09 07:25

I may be talking rubbish here, but bare with me as i have little experience with DLLs.

Is it possible to send a windows message from the DLL to the engine window. When the DLL is loaded, the entry point function is called, where you can handle 'DLL_PROCESS_ATTACH'. Would it be possible to use SendMessage to send a custom window's message to the engine, saying "i'm loaded!". You could then just handle that in the engine WndProc, and set a variable like 'dll_loaded = 1;'. Then you know the action will work properly.

This might not be possible, I don't know, it's just a little theory i had. Maybe something like this...
Code:
BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpReserved ) 
{
    switch( fdwReason ) 
    { 
        case DLL_PROCESS_ATTACH: // Dll is loaded

         // Get handle to caller window
         // Send a custom message using SendMessage
            break;
}
}



The only problem I can see from this is that the message is sent before the WndProc starts.

LoadLibrary is probably still the best solution for you if you want to know if your DLL is loaded.


Posted By: VeT

Re: Debugging C++ DLL - 11/01/09 13:11

And if i dont have access to DLLs source?
Well, i can ask Julio to add function like that, but i dont think that its the best variant...
Posted By: jcl

Re: Debugging C++ DLL - 11/02/09 16:10

Has the Newton DLL no open or init function? I would expect that a DLL does not crash when it was properly initialized.
Posted By: VeT

Re: Debugging C++ DLL - 11/03/09 12:25

I'll upload light version of wrapper for you, so you could see.
No, it doesnt crash while init, also it doesnt have init-function.
Posted By: VeT

Re: Debugging C++ DLL - 11/03/09 12:48

Here you are: http://depositfiles.com/files/ixp3badea

If you would launch main.c, everything must work fine: items (ball, capsule and so on) must collide with blocks and models.

Now, open map10.c and comment any line with "wait(3);".. then launch main.c again and you would get crash.

I cant find another explanation, except of "DLL didnt had enough time to load"
Posted By: FBL

Re: Debugging C++ DLL - 11/03/09 15:40

I had this problem too and this wass the reason:

I create the newtonworld in my main function, but I think it is not guaranteed that entity actions run AFTER the main function. so there are crashes because the newtonworld is not created yet.

wait (1) should do in this case.
Posted By: jcl

Re: Debugging C++ DLL - 11/03/09 16:28

That's right. Entity actions start just when the level is loaded. I'm not this familiar with Newton, but apparently it crashes when you call physics functions before creating the world.
Posted By: VeT

Re: Debugging C++ DLL - 11/03/09 20:11

wait(1);
Is not enough.. even wait(3); on different computers is not enough... Well, then i have a suggestion, what to do..
Thanks, it was important to me to make certain that it isnt because of DLL laugh
Posted By: VeT

Re: Debugging C++ DLL - 11/03/09 20:33

Yes, thats it, i fixed this. Thanks, guys.
© 2024 lite-C Forums