Thursday, February 10, 2005

The DLL problem's solution

The problem was that I use a global buffer that is initialized upon DLL load to a certain string. However, the buffer length I was using was too small to contain the whole string, so it was bombing out with an Access Violation. Of course, for Debug builds, the compiler adds a little extra space for each buffer, so the problem did not occur there. Release builds, trying to get things as tight as possible, does not add any extra buffer, and I ran right into the overflow as soon as my program tried to load the DLL.

The Access Violation should have given me a better clue as to what was going on. Now it works and I have one more thing to think about when something goes wrong.

Monday, February 07, 2005

Windows DLL problem update

I just tried using the Debug version of the DLL, and it works!

So the problem seems to be the DLL itself. What could possibly be different between the Debug and Release DLL versions that is causing this?

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.

Added a new Wifi node at home

At my old apartment I had a single wireless router that allowed PC usage in the living room. The router was in the office, so the main PC was directly connected with a cable. When we moved into our new apartment, the phone jack, living room computer, and office computer all moved far away from each other, so I couldn't use an ethernet cable to hook one of them up (not without a lot of problem, at least).

So finally, after 3 months, I finally went out and got myself a wireless hub for the office computer. After fiddling with it for a couple hours, it connected successfully to the wifi router, and now I am net-enabled at home. Yay!