vecchio56
2009-05-07 19:25:19 UTC
Hello,
I've got a program which browses resources contained in a dll chosen by
the program user.
I'm using LoadLibrary/FreeLibrary, and I have a strange behavior when
the dll I browse is a copy of kernel32.dll :
For example (aaa.dll is a copy of kernel32.dll) :
int main()
{
HMODULE hMod;
BOOL bRet;
hMod = LoadLibrary(TEXT("C:\\test\\aaa.dll")); // OK
bRet = FreeLibrary(hMod); // OK
hMod = LoadLibrary(TEXT("C:\\test\\aaa.dll")); // First chance
exception -> hMod = 0
// starting here, I can't load aaa.dll anymore
bRet = FreeLibrary(hMod);
// but it still works on the system kernel32.dll
hMod = LoadLibrary(TEXT("kernel32.dll")); // OK
bRet = FreeLibrary(hMod); // OK
hMod = LoadLibrary(TEXT("kernel32.dll")); // OK
bRet = FreeLibrary(hMod); // OK
}
I don't have the problem with other dll like shell32.dll.
LoadLibrary and FreeLibrary are defined in kernel32.dll but it doesn't
explain this problem.
Please help!
Thanks
I've got a program which browses resources contained in a dll chosen by
the program user.
I'm using LoadLibrary/FreeLibrary, and I have a strange behavior when
the dll I browse is a copy of kernel32.dll :
For example (aaa.dll is a copy of kernel32.dll) :
int main()
{
HMODULE hMod;
BOOL bRet;
hMod = LoadLibrary(TEXT("C:\\test\\aaa.dll")); // OK
bRet = FreeLibrary(hMod); // OK
hMod = LoadLibrary(TEXT("C:\\test\\aaa.dll")); // First chance
exception -> hMod = 0
// starting here, I can't load aaa.dll anymore
bRet = FreeLibrary(hMod);
// but it still works on the system kernel32.dll
hMod = LoadLibrary(TEXT("kernel32.dll")); // OK
bRet = FreeLibrary(hMod); // OK
hMod = LoadLibrary(TEXT("kernel32.dll")); // OK
bRet = FreeLibrary(hMod); // OK
}
I don't have the problem with other dll like shell32.dll.
LoadLibrary and FreeLibrary are defined in kernel32.dll but it doesn't
explain this problem.
Please help!
Thanks