We have a DLL which is produced in house, and for which we have the associated static LIB of stubs.
We also have an EXE which uses this DLL using the simple method o
Is your customer drunk? Of all the crazy requirements in all the world ...
Back in my glory days as a syphilitic madman midnight C++ programmer I used to add my DLLs to my .exe file as resources. Then at startup I'd unpack them and write them to the exe's directory. Your program can decide on the DLL filename at this point. Really go for the obfuscation thing - start with a random number, concatenate some Edward Lear poetry and xor it with your favourite German double-barrelled noun; should do for starters anyway. Then load the DLL using LoadLibrary().
enum ukOverwrite {dontOverwriteAnything = 0, overwriteWhateverPresent = 1};
void unpackResource (ukOverwrite param1, int resourceID, const char* basePath,
const char* endFilename)
{
char* lpName = 0;
lpName += resourceID;
HRSRC MrResource = FindResource (0, lpName, "file");
if (MrResource)
{
HGLOBAL loadedResource = LoadResource (0, MrResource);
if (loadedResource)
{
void* lockedResource = LockResource (loadedResource);
if (lockedResource)
{
DWORD size = SizeofResource (0, MrResource);
if (size)
{
unsigned long creationDisposition = CREATE_NEW;
if (param1 == overwriteWhateverPresent)
creationDisposition = CREATE_ALWAYS;
char filepath [MAX_PATH];
strcpy (filepath, basePath);
strcat (filepath, endFilename);
HANDLE rabbit = CreateFile (filepath, GENERIC_WRITE, 0, 0,
creationDisposition, 0, 0);
if (rabbit != INVALID_HANDLE_VALUE)
{
DWORD numBytesWritten = 0;
int wf = WriteFile (rabbit, lockedResource, size, &numBytesWritten,
0);
CloseHandle (rabbit);
}
}
}
FreeResource (loadedResource);
}
}
}