Jump to content

C DLL Question


matwachich
 Share

Recommended Posts

Hi! I have a question:

- Why the hell would an application crash when I launch it from windows explorer, and works all fine when I launch it from command prompt?????

More details:

- It's an app that uses a DLL written in pure C of mine

- The app also runs well when launched from SciTE (think it's a problem with the stdout...)

- The module concerned in the crash is msvcrt.dll

- All parts of the dll (event external libraries) are compiled using the same GCC (no any .NET sh*t)

- Not only with AutoIt, even if I try to use this DLL with FreeBasic, I have the same crash

- Befor, the DLL was not crashing this way, but I made many changes (and I didn't tracked them) since the last good version, so I have no idea where it comes from

Big thanks! :)

Link to comment
Share on other sites

I cannot see what's wrong without code, but once I had the same problem with an app not a DLL ritten in C. Problem was that the command line was different when starting the app from windows than starting the app from console. I parsed the app for first command line parameter (the path) and on console it was only 'app.exe' and in windows it was 'C:app.exe'. Something like that.

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Link to comment
Share on other sites

Thanks!

But I don't think the problem is here, because I don't make any use of cmd line params in the dll nor in the app using the dll.

The code... first It's verry huge! (a total of 11370 lines with 6470 lines of code), and secondly, I don't yet know if I will release the code...

It's a DLL in pure C, using as external libs: GLFW, SOIL and inih

It's Object Oriented Syntax but with C. I mean all data structures are in opaque structs (only the dll know the members) and they are handled by the user with functions like: Sprite_Create (allocation), Sprite_Destroy (free), Sprite_SetPos, Sprite_GetPos ...

Gonna fill the functions with printf and test!

Link to comment
Share on other sites

Problem solved! Thanks to the printf function!

It was a not-completly initialized struct:

- I allocate a sort of global and internal struct that contains many internal informations. One of these informations is a flag (0/1) to say if a Render Window is opened. This flag was not initialized to 0 when creating th structure.

- When I call the OpenWindow function, this function checks the flag to see if it should open a window or not. And here was the problem (the flag wasn't initialized)

What I don't understand yet (although my problem was solved by initializing the flag to 0) is why this caused problem only when launching the application from Windows Explorer???

Thanks for who readed me!

Link to comment
Share on other sites

But by doing this, it will not be usable with AutoIt, which my first goal!

And I don't know why (perhaps because I don't master it) but I don't like C++

I'm also doing a FreeBasic wrapper to my engin, and It uses Classes

I'm near to release this engin, I just want to make a proper errors handling for it, and also (and this is the boringest thing ever!) a proper documentation (about 300 function!!!)

Link to comment
Share on other sites

How can AutoIt use C++ classes???

And if it is just for making simple, standard functions, I prefer staying with C :)

Every virtual class method/function is accessible by DllCallAddress() or ObjCreateInterface() for example. Number of other "ways" exist.

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...