Monday, February 07, 2005

Problem with Windows DLLs

I am trying to get a grip on some simple Windows programming. I've been out of it for too long, doing things that are really incidental to programming. Before my skills rust away completely, I want to get back on the wagon and try to get these squeaky developer wheels spinning smoothly again.

My current project is to work with DLLs. I have a simple DLL that exports two functions and nothing else. The DLL has a global variable. The DLL provides a NULL-terminated string back to the client, and provides a facility to free that memory as well (the client will crash if it tries to free the DLL's memory).

The client test program loads the DLL implicitly, calls the exported function, prints the returned string, then calls the other exported function to free the memory.

In Debug build, this works fine. However, when I run it in a Release build, it crashes with a 0xC0000005 Access violation error. The code between the two is identical, of course.

The problem seems to be in the loading of the DLL, because it doesn't even get as far as the first executable line in the test client. I must be missing something here.

One thing I have tried is to load the DLL explicitly, but that does not change the behavior at all. The access violation still occurs. Hopefully I can figure this out. I'd hate to have to release all my programs as Debug builds.

0 Comments:

Post a Comment

<< Home