So, I am working on a driver for hooking the keyboard to replace certain keystrokes with another set of keystrokes. Anyways, I have a console version that works fine. When I close the console window, the driver unloads as normal.
The problem is, when I make a GUI to load the driver, it does not unload when I exit the program (which technically never exits). So here is where the lock occurs (please ignore the MessageBox calls, I was just testing something)...
Code:
MessageBox(NULL, "Gate 6", "Info", MB_OK);
fclose(fp);
Settings.Driver = LoadLibrary(GDODGE_DRIVER_NAME);
MessageBox(NULL, "Gate 7", "Info", MB_OK);
I searched Google for some answers, but the only things I could find are really long winded, and complex, answers to how Windows handles and why it handles load locking for drivers. None of them actually answered my question. There was one project in C++ which showed a driver loaded via a GUI app, but it is using a completely different method, and the sample app doesn't even work as expected.
I have attached the source code.