#include "stdafx.h"
#include "dllpstub.h"
-#include <shlwapi.h>
#include <afxdisp.h>
#include <afxinet.h>
/**
* @brief Throw DLLPSTUB related exception.
*/
-void DLLPSTUB::Throw(LPCSTR name, HMODULE handle, DWORD dwError, BOOL bFreeLibrary)
+void DLLPSTUB::Throw(LPCSTR name, HMODULE handle, DWORD dwError, bool bFreeLibrary)
{
CString strError = name;
- if (handle)
+ if (handle != nullptr)
{
TCHAR module[4096];
module[0] = '@';
szError[1] = '\n';
strError += szError;
}
- if (bFreeLibrary)
+ if (bFreeLibrary && handle != nullptr)
{
FreeLibrary(handle);
}
// followed by a char array of the DLL name to load
// so it access the char array via *(this + 1)
LPCSTR *proxy = (LPCSTR *) (this + 1);
- HMODULE handle = NULL;
+ HMODULE handle = nullptr;
if (LPCSTR name = *proxy)
{
- if (proxy[1] && proxy[1] != name)
+ if (proxy[1] != nullptr && proxy[1] != name)
{
handle = LoadLibraryA(name);
- if (handle)
+ if (handle != nullptr)
{
// If any of the version members are non-zero
// then we require that DLL export "DllGetVersion"
DLLGETVERSIONPROC DllGetVersion = (DLLGETVERSIONPROC)GetProcAddress(handle, "DllGetVersion");
if
(
- DllGetVersion == NULL
+ DllGetVersion == nullptr
|| FAILED(DllGetVersion(&dvi))
|| (
dwMajorVersion && dvi.dwMajorVersion != dwMajorVersion
// Well, that's the most appropriate canned system
// message I came across: If DLL is outdated, it may
// actually lack some interface we need...
- Throw(0, handle, CO_S_NOTALLINTERFACES, TRUE);
+ Throw(0, handle, CO_S_NOTALLINTERFACES, true);
}
}
LPCSTR *pszExport = proxy;
- *proxy = NULL;
- while ((name = *++pszExport) != NULL)
+ *proxy = nullptr;
+ while ((name = *++pszExport) != nullptr)
{
*pszExport = (LPCSTR)GetProcAddress(handle, name);
- if (*pszExport == NULL)
+ if (*pszExport == nullptr)
{
*proxy = proxy[1] = name;
pszExport = proxy + 2;
*pszExport = (LPCSTR)handle;
}
}
- if ((name = *proxy) != NULL)
+ if ((name = *proxy) != nullptr)
{
DWORD dwError = ERROR_MOD_NOT_FOUND;
- HMODULE handle = 0;
+ HMODULE handle1 = 0;
if (proxy[1] == name)
{
dwError = ERROR_PROC_NOT_FOUND;
- handle = (HMODULE)proxy[2];
+ handle1 = (HMODULE)proxy[2];
}
- Throw(name, handle, dwError, FALSE);
+ Throw(name, handle1, dwError, false);
}
}
return handle;