clang-cl loplugin: setup_native

Change-Id: I424164d19ba59697d39b3a3888ec2f743a3a832c
Reviewed-on: https://gerrit.libreoffice.org/29853
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
This commit is contained in:
Stephan Bergmann
2016-10-14 16:53:32 +02:00
parent 918d85a82d
commit 83d6099b7d
13 changed files with 97 additions and 94 deletions

View File

@@ -47,12 +47,12 @@ typedef SC_HANDLE (__stdcall * OpenService_t)(SC_HANDLE, LPCSTR, DWORD);
typedef BOOL (__stdcall * QueryServiceStatus_t)(SC_HANDLE, LPSERVICE_STATUS); typedef BOOL (__stdcall * QueryServiceStatus_t)(SC_HANDLE, LPSERVICE_STATUS);
typedef BOOL (__stdcall * StartService_t)(SC_HANDLE, DWORD, LPCSTR*); typedef BOOL (__stdcall * StartService_t)(SC_HANDLE, DWORD, LPCSTR*);
CloseServiceHandle_t CloseServiceHandle_ = NULL; CloseServiceHandle_t CloseServiceHandle_ = nullptr;
ControlService_t ControlService_ = NULL; ControlService_t ControlService_ = nullptr;
OpenSCManager_t OpenSCManager_ = NULL; OpenSCManager_t OpenSCManager_ = nullptr;
OpenService_t OpenService_ = NULL; OpenService_t OpenService_ = nullptr;
QueryServiceStatus_t QueryServiceStatus_ = NULL; QueryServiceStatus_t QueryServiceStatus_ = nullptr;
StartService_t StartService_ = NULL; StartService_t StartService_ = nullptr;
const char * const INDEXING_SERVICE_NAME = "cisvc"; const char * const INDEXING_SERVICE_NAME = "cisvc";
@@ -104,7 +104,7 @@ bool StopIndexingService(SC_HANDLE hService)
void StartIndexingService(SC_HANDLE hService) void StartIndexingService(SC_HANDLE hService)
{ {
if (StartService_(hService, 0, NULL)) if (StartService_(hService, 0, nullptr))
{ {
SERVICE_STATUS status; SERVICE_STATUS status;
@@ -171,11 +171,11 @@ extern "C" UINT __stdcall RestartIndexingService(MSIHANDLE)
return ERROR_SUCCESS; return ERROR_SUCCESS;
SC_HANDLE hSCManager = OpenSCManager_( SC_HANDLE hSCManager = OpenSCManager_(
NULL, // local machine nullptr, // local machine
NULL, // ServicesActive database nullptr, // ServicesActive database
SC_MANAGER_ALL_ACCESS); SC_MANAGER_ALL_ACCESS);
if (hSCManager != NULL) if (hSCManager != nullptr)
{ {
SC_HANDLE hIndexingService = OpenService_( SC_HANDLE hIndexingService = OpenService_(
hSCManager, INDEXING_SERVICE_NAME, SERVICE_QUERY_STATUS | SERVICE_START | SERVICE_STOP); hSCManager, INDEXING_SERVICE_NAME, SERVICE_QUERY_STATUS | SERVICE_START | SERVICE_STOP);

View File

@@ -39,7 +39,7 @@ std::wstring GetOfficeInstallationPathW(MSIHANDLE handle)
{ {
sz++; // space for the final '\0' sz++; // space for the final '\0'
DWORD nbytes = sz * sizeof(WCHAR); DWORD nbytes = sz * sizeof(WCHAR);
PWSTR buff = reinterpret_cast<PWSTR>(_alloca(nbytes)); PWSTR buff = static_cast<PWSTR>(_alloca(nbytes));
ZeroMemory(buff, nbytes); ZeroMemory(buff, nbytes);
MsiGetPropertyW(handle, L"INSTALLLOCATION", buff, &sz); MsiGetPropertyW(handle, L"INSTALLLOCATION", buff, &sz);
progpath = buff; progpath = buff;
@@ -57,7 +57,7 @@ std::wstring GetOfficeProductNameW(MSIHANDLE handle)
{ {
sz++; // space for the final '\0' sz++; // space for the final '\0'
DWORD nbytes = sz * sizeof(WCHAR); DWORD nbytes = sz * sizeof(WCHAR);
PWSTR buff = reinterpret_cast<PWSTR>(_alloca(nbytes)); PWSTR buff = static_cast<PWSTR>(_alloca(nbytes));
ZeroMemory(buff, nbytes); ZeroMemory(buff, nbytes);
MsiGetPropertyW(handle, L"ProductName", buff, &sz); MsiGetPropertyW(handle, L"ProductName", buff, &sz);
productname = buff; productname = buff;
@@ -75,7 +75,7 @@ std::wstring GetQuickstarterLinkNameW(MSIHANDLE handle)
{ {
sz++; // space for the final '\0' sz++; // space for the final '\0'
DWORD nbytes = sz * sizeof(WCHAR); DWORD nbytes = sz * sizeof(WCHAR);
PWSTR buff = reinterpret_cast<PWSTR>(_alloca(nbytes)); PWSTR buff = static_cast<PWSTR>(_alloca(nbytes));
ZeroMemory(buff, nbytes); ZeroMemory(buff, nbytes);
MsiGetPropertyW(handle, L"Quickstarterlinkname", buff, &sz); MsiGetPropertyW(handle, L"Quickstarterlinkname", buff, &sz);
quickstarterlinkname = buff; quickstarterlinkname = buff;
@@ -84,7 +84,7 @@ std::wstring GetQuickstarterLinkNameW(MSIHANDLE handle)
{ {
sz++; // space for the final '\0' sz++; // space for the final '\0'
DWORD nbytes = sz * sizeof(WCHAR); DWORD nbytes = sz * sizeof(WCHAR);
PWSTR buff = reinterpret_cast<PWSTR>(_alloca(nbytes)); PWSTR buff = static_cast<PWSTR>(_alloca(nbytes));
ZeroMemory(buff, nbytes); ZeroMemory(buff, nbytes);
MsiGetPropertyW(handle, L"ProductName", buff, &sz); MsiGetPropertyW(handle, L"ProductName", buff, &sz);
quickstarterlinkname = buff; quickstarterlinkname = buff;
@@ -94,14 +94,14 @@ std::wstring GetQuickstarterLinkNameW(MSIHANDLE handle)
inline bool IsValidHandle( HANDLE handle ) inline bool IsValidHandle( HANDLE handle )
{ {
return NULL != handle && INVALID_HANDLE_VALUE != handle; return nullptr != handle && INVALID_HANDLE_VALUE != handle;
} }
static DWORD WINAPI _GetModuleFileNameExW( HANDLE hProcess, HMODULE hModule, PWSTR lpFileName, DWORD nSize ) static DWORD WINAPI GetModuleFileNameExW_( HANDLE hProcess, HMODULE hModule, PWSTR lpFileName, DWORD nSize )
{ {
typedef DWORD (WINAPI *FN_PROC)( HANDLE hProcess, HMODULE hModule, LPWSTR lpFileName, DWORD nSize ); typedef DWORD (WINAPI *FN_PROC)( HANDLE hProcess, HMODULE hModule, LPWSTR lpFileName, DWORD nSize );
static FN_PROC lpProc = NULL; static FN_PROC lpProc = nullptr;
if ( !lpProc ) if ( !lpProc )
{ {
@@ -128,7 +128,7 @@ std::wstring GetProcessImagePathW( DWORD dwProcessId )
{ {
WCHAR szPathBuffer[MAX_PATH] = L""; WCHAR szPathBuffer[MAX_PATH] = L"";
if ( _GetModuleFileNameExW( hProcess, NULL, szPathBuffer, sizeof(szPathBuffer)/sizeof(szPathBuffer[0]) ) ) if ( GetModuleFileNameExW_( hProcess, nullptr, szPathBuffer, sizeof(szPathBuffer)/sizeof(szPathBuffer[0]) ) )
sImagePath = szPathBuffer; sImagePath = szPathBuffer;
CloseHandle( hProcess ); CloseHandle( hProcess );

View File

@@ -32,7 +32,7 @@ extern "C" UINT __stdcall RemoveQuickstarterLink( MSIHANDLE hMSI )
{ {
WCHAR szStartupPath[MAX_PATH]; WCHAR szStartupPath[MAX_PATH];
if ( SHGetSpecialFolderPathW( NULL, szStartupPath, CSIDL_STARTUP, FALSE ) ) if ( SHGetSpecialFolderPathW( nullptr, szStartupPath, CSIDL_STARTUP, FALSE ) )
{ {
std::wstring sQuickstartLinkPath = szStartupPath; std::wstring sQuickstartLinkPath = szStartupPath;

View File

@@ -64,7 +64,7 @@ static const CHAR* g_Extensions[] =
".dpt", // Kingsoft Presentation Template ".dpt", // Kingsoft Presentation Template
".vsd", // Visio 2000/XP/2003 document ".vsd", // Visio 2000/XP/2003 document
".vst", // Visio 2000/XP/2003 template ".vst", // Visio 2000/XP/2003 template
0 nullptr
}; };
static const int WORD_START = 0; static const int WORD_START = 0;
@@ -97,7 +97,7 @@ static inline void OutputDebugStringFormatA( LPCSTR, ... )
static BOOL CheckExtensionInRegistry( LPCSTR lpSubKey ) static BOOL CheckExtensionInRegistry( LPCSTR lpSubKey )
{ {
BOOL bRet = false; BOOL bRet = false;
HKEY hKey = NULL; HKEY hKey = nullptr;
LONG lResult = RegOpenKeyExA( HKEY_CLASSES_ROOT, lpSubKey, 0, KEY_QUERY_VALUE, &hKey ); LONG lResult = RegOpenKeyExA( HKEY_CLASSES_ROOT, lpSubKey, 0, KEY_QUERY_VALUE, &hKey );
if ( ERROR_SUCCESS == lResult ) if ( ERROR_SUCCESS == lResult )
@@ -105,7 +105,7 @@ static BOOL CheckExtensionInRegistry( LPCSTR lpSubKey )
CHAR szBuffer[1024]; CHAR szBuffer[1024];
DWORD nSize = sizeof( szBuffer ); DWORD nSize = sizeof( szBuffer );
lResult = RegQueryValueExA( hKey, "", NULL, NULL, (LPBYTE)szBuffer, &nSize ); lResult = RegQueryValueExA( hKey, "", nullptr, nullptr, reinterpret_cast<LPBYTE>(szBuffer), &nSize );
if ( ERROR_SUCCESS == lResult && nSize > 0 ) if ( ERROR_SUCCESS == lResult && nSize > 0 )
{ {
szBuffer[nSize] = '\0'; szBuffer[nSize] = '\0';
@@ -145,7 +145,7 @@ bool GetMsiPropA( MSIHANDLE handle, LPCSTR name, /*out*/std::string& value )
{ {
sz++; sz++;
DWORD nbytes = sz * sizeof(CHAR); DWORD nbytes = sz * sizeof(CHAR);
LPSTR buff = reinterpret_cast<LPSTR>(_alloca(nbytes)); LPSTR buff = static_cast<LPSTR>(_alloca(nbytes));
ZeroMemory(buff, nbytes); ZeroMemory(buff, nbytes);
MsiGetPropertyA(handle, name, buff, &sz); MsiGetPropertyA(handle, name, buff, &sz);
value = buff; value = buff;
@@ -179,7 +179,7 @@ static void registerForExtension( MSIHANDLE handle, const int nIndex, bool bRegi
static void saveOldRegistration( LPCSTR lpSubKey ) static void saveOldRegistration( LPCSTR lpSubKey )
{ {
HKEY hKey = NULL; HKEY hKey = nullptr;
LONG lResult = RegOpenKeyExA( HKEY_CLASSES_ROOT, lpSubKey, 0, LONG lResult = RegOpenKeyExA( HKEY_CLASSES_ROOT, lpSubKey, 0,
KEY_QUERY_VALUE|KEY_SET_VALUE, &hKey ); KEY_QUERY_VALUE|KEY_SET_VALUE, &hKey );
@@ -188,7 +188,7 @@ static void saveOldRegistration( LPCSTR lpSubKey )
CHAR szBuffer[1024]; CHAR szBuffer[1024];
DWORD nSize = sizeof( szBuffer ); DWORD nSize = sizeof( szBuffer );
lResult = RegQueryValueExA( hKey, "", NULL, NULL, (LPBYTE)szBuffer, &nSize ); lResult = RegQueryValueExA( hKey, "", nullptr, nullptr, reinterpret_cast<LPBYTE>(szBuffer), &nSize );
if ( ERROR_SUCCESS == lResult ) if ( ERROR_SUCCESS == lResult )
{ {
szBuffer[nSize] = '\0'; szBuffer[nSize] = '\0';
@@ -198,20 +198,20 @@ static void saveOldRegistration( LPCSTR lpSubKey )
{ {
// Save the old association // Save the old association
RegSetValueExA( hKey, "LOBackupAssociation", 0, RegSetValueExA( hKey, "LOBackupAssociation", 0,
REG_SZ, (LPBYTE)szBuffer, nSize ); REG_SZ, reinterpret_cast<LPBYTE>(szBuffer), nSize );
// Also save what the old association means, just so we can try to verify // Also save what the old association means, just so we can try to verify
// if/when restoring it that the old application still exists // if/when restoring it that the old application still exists
HKEY hKey2 = NULL; HKEY hKey2 = nullptr;
lResult = RegOpenKeyExA( HKEY_CLASSES_ROOT, szBuffer, 0, lResult = RegOpenKeyExA( HKEY_CLASSES_ROOT, szBuffer, 0,
KEY_QUERY_VALUE, &hKey2 ); KEY_QUERY_VALUE, &hKey2 );
if ( ERROR_SUCCESS == lResult ) if ( ERROR_SUCCESS == lResult )
{ {
nSize = sizeof( szBuffer ); nSize = sizeof( szBuffer );
lResult = RegQueryValueExA( hKey2, "", NULL, NULL, (LPBYTE)szBuffer, &nSize ); lResult = RegQueryValueExA( hKey2, "", nullptr, nullptr, reinterpret_cast<LPBYTE>(szBuffer), &nSize );
if ( ERROR_SUCCESS == lResult ) if ( ERROR_SUCCESS == lResult )
{ {
RegSetValueExA( hKey, "LOBackupAssociationDeref", 0, RegSetValueExA( hKey, "LOBackupAssociationDeref", 0,
REG_SZ, (LPBYTE)szBuffer, nSize ); REG_SZ, reinterpret_cast<LPBYTE>(szBuffer), nSize );
} }
RegCloseKey( hKey2 ); RegCloseKey( hKey2 );
} }
@@ -224,7 +224,7 @@ static void saveOldRegistration( LPCSTR lpSubKey )
static void registerForExtensions( MSIHANDLE handle, BOOL bRegisterAll ) static void registerForExtensions( MSIHANDLE handle, BOOL bRegisterAll )
{ // Check all file extensions { // Check all file extensions
int nIndex = 0; int nIndex = 0;
while ( g_Extensions[nIndex] != 0 ) while ( g_Extensions[nIndex] != nullptr )
{ {
saveOldRegistration( g_Extensions[nIndex] ); saveOldRegistration( g_Extensions[nIndex] );
@@ -240,7 +240,7 @@ static bool checkSomeExtensionInRegistry( const int nStart, const int nEnd )
int nIndex = nStart; int nIndex = nStart;
bool bFound = false; bool bFound = false;
while ( !bFound && (nIndex < nEnd) && (g_Extensions[nIndex] != 0) ) while ( !bFound && (nIndex < nEnd) && (g_Extensions[nIndex] != nullptr) )
{ {
bFound = ! CheckExtensionInRegistry( g_Extensions[nIndex] ); bFound = ! CheckExtensionInRegistry( g_Extensions[nIndex] );
@@ -256,7 +256,7 @@ static void registerSomeExtensions( MSIHANDLE handle, const int nStart, const in
{ // Check all file extensions { // Check all file extensions
int nIndex = nStart; int nIndex = nStart;
while ( (nIndex < nEnd) && (g_Extensions[nIndex] != 0) ) while ( (nIndex < nEnd) && (g_Extensions[nIndex] != nullptr) )
{ {
registerForExtension( handle, nIndex++, bRegister ); registerForExtension( handle, nIndex++, bRegister );
} }
@@ -457,7 +457,7 @@ extern "C" UINT __stdcall FindRegisteredExtensions( MSIHANDLE handle )
static void restoreOldRegistration( LPCSTR lpSubKey ) static void restoreOldRegistration( LPCSTR lpSubKey )
{ {
HKEY hKey = NULL; HKEY hKey = nullptr;
LONG lResult = RegOpenKeyExA( HKEY_CLASSES_ROOT, lpSubKey, 0, LONG lResult = RegOpenKeyExA( HKEY_CLASSES_ROOT, lpSubKey, 0,
KEY_QUERY_VALUE|KEY_SET_VALUE, &hKey ); KEY_QUERY_VALUE|KEY_SET_VALUE, &hKey );
@@ -466,11 +466,11 @@ static void restoreOldRegistration( LPCSTR lpSubKey )
CHAR szBuffer[1024]; CHAR szBuffer[1024];
DWORD nSize = sizeof( szBuffer ); DWORD nSize = sizeof( szBuffer );
lResult = RegQueryValueExA( hKey, "LOBackupAssociation", NULL, NULL, lResult = RegQueryValueExA( hKey, "LOBackupAssociation", nullptr, nullptr,
(LPBYTE)szBuffer, &nSize ); reinterpret_cast<LPBYTE>(szBuffer), &nSize );
if ( ERROR_SUCCESS == lResult ) if ( ERROR_SUCCESS == lResult )
{ {
HKEY hKey2 = NULL; HKEY hKey2 = nullptr;
lResult = RegOpenKeyExA( HKEY_CLASSES_ROOT, szBuffer, 0, lResult = RegOpenKeyExA( HKEY_CLASSES_ROOT, szBuffer, 0,
KEY_QUERY_VALUE, &hKey2 ); KEY_QUERY_VALUE, &hKey2 );
if ( ERROR_SUCCESS == lResult ) if ( ERROR_SUCCESS == lResult )
@@ -478,21 +478,21 @@ static void restoreOldRegistration( LPCSTR lpSubKey )
CHAR szBuffer2[1024]; CHAR szBuffer2[1024];
DWORD nSize2 = sizeof( szBuffer2 ); DWORD nSize2 = sizeof( szBuffer2 );
lResult = RegQueryValueExA( hKey2, "", NULL, NULL, (LPBYTE)szBuffer2, &nSize2 ); lResult = RegQueryValueExA( hKey2, "", nullptr, nullptr, reinterpret_cast<LPBYTE>(szBuffer2), &nSize2 );
if ( ERROR_SUCCESS == lResult ) if ( ERROR_SUCCESS == lResult )
{ {
CHAR szBuffer3[1024]; CHAR szBuffer3[1024];
DWORD nSize3 = sizeof( szBuffer3 ); DWORD nSize3 = sizeof( szBuffer3 );
// Try to verify that the old association is OK to restore // Try to verify that the old association is OK to restore
lResult = RegQueryValueExA( hKey, "LOBackupAssociationDeref", NULL, NULL, lResult = RegQueryValueExA( hKey, "LOBackupAssociationDeref", nullptr, nullptr,
(LPBYTE)szBuffer3, &nSize3 ); reinterpret_cast<LPBYTE>(szBuffer3), &nSize3 );
if ( ERROR_SUCCESS == lResult ) if ( ERROR_SUCCESS == lResult )
{ {
if ( nSize2 == nSize3 && strcmp (szBuffer2, szBuffer3) == 0) if ( nSize2 == nSize3 && strcmp (szBuffer2, szBuffer3) == 0)
{ {
// Yep. So restore it // Yep. So restore it
RegSetValueExA( hKey, "", 0, REG_SZ, (LPBYTE)szBuffer, nSize ); RegSetValueExA( hKey, "", 0, REG_SZ, reinterpret_cast<LPBYTE>(szBuffer), nSize );
} }
} }
} }
@@ -510,7 +510,7 @@ extern "C" UINT __stdcall RestoreRegAllMSDoc( MSIHANDLE /*handle*/ )
OutputDebugStringFormatA( "RestoreRegAllMSDoc\n" ); OutputDebugStringFormatA( "RestoreRegAllMSDoc\n" );
int nIndex = 0; int nIndex = 0;
while ( g_Extensions[nIndex] != 0 ) while ( g_Extensions[nIndex] != nullptr )
{ {
restoreOldRegistration( g_Extensions[nIndex] ); restoreOldRegistration( g_Extensions[nIndex] );
++nIndex; ++nIndex;

View File

@@ -43,13 +43,16 @@ typedef int ( __stdcall * DllNativeUnregProc ) ( int, BOOL, BOOL );
BOOL UnicodeEquals( wchar_t const * pStr1, wchar_t const * pStr2 ) BOOL UnicodeEquals( wchar_t const * pStr1, wchar_t const * pStr2 )
{ {
if ( pStr1 == NULL && pStr2 == NULL ) if ( pStr1 == nullptr && pStr2 == nullptr )
return TRUE; return TRUE;
else if ( pStr1 == NULL || pStr2 == NULL ) else if ( pStr1 == nullptr || pStr2 == nullptr )
return FALSE; return FALSE;
while( *pStr1 == *pStr2 && *pStr1 && *pStr2 ) while( *pStr1 == *pStr2 && *pStr1 && *pStr2 )
pStr1++, pStr2++; {
pStr1++;
pStr2++;
}
return ( *pStr1 == 0 && *pStr2 == 0 ); return ( *pStr1 == 0 && *pStr2 == 0 );
} }
@@ -58,12 +61,12 @@ BOOL UnicodeEquals( wchar_t const * pStr1, wchar_t const * pStr2 )
char* UnicodeToAnsiString( wchar_t* pUniString ) char* UnicodeToAnsiString( wchar_t* pUniString )
{ {
int len = WideCharToMultiByte( int len = WideCharToMultiByte(
CP_ACP, 0, pUniString, -1, 0, 0, 0, 0 ); CP_ACP, 0, pUniString, -1, nullptr, 0, nullptr, nullptr );
char* buff = reinterpret_cast<char*>( malloc( len ) ); char* buff = static_cast<char*>( malloc( len ) );
WideCharToMultiByte( WideCharToMultiByte(
CP_ACP, 0, pUniString, -1, buff, len, 0, 0 ); CP_ACP, 0, pUniString, -1, buff, len, nullptr, nullptr );
return buff; return buff;
} }
@@ -71,17 +74,17 @@ char* UnicodeToAnsiString( wchar_t* pUniString )
void RegisterActiveXNative( const char* pActiveXPath, int nMode, BOOL InstallForAllUser, BOOL InstallFor64Bit ) void RegisterActiveXNative( const char* pActiveXPath, int nMode, BOOL InstallForAllUser, BOOL InstallFor64Bit )
{ {
HINSTANCE hModule = LoadLibraryExA( pActiveXPath, NULL, LOAD_WITH_ALTERED_SEARCH_PATH ); HINSTANCE hModule = LoadLibraryExA( pActiveXPath, nullptr, LOAD_WITH_ALTERED_SEARCH_PATH );
if( hModule ) if( hModule )
{ {
DllNativeRegProc pNativeProc = ( DllNativeRegProc )GetProcAddress( hModule, "DllRegisterServerNative" ); DllNativeRegProc pNativeProc = reinterpret_cast<DllNativeRegProc>(GetProcAddress( hModule, "DllRegisterServerNative" ));
if( pNativeProc!=NULL ) if( pNativeProc!=nullptr )
{ {
int nLen = strlen( pActiveXPath ); int nLen = strlen( pActiveXPath );
int nRemoveLen = strlen( "\\so_activex.dll" ); int nRemoveLen = strlen( "\\so_activex.dll" );
if ( nLen > nRemoveLen ) if ( nLen > nRemoveLen )
{ {
char* pProgramPath = reinterpret_cast<char*>( malloc( nLen - nRemoveLen + 1 ) ); char* pProgramPath = static_cast<char*>( malloc( nLen - nRemoveLen + 1 ) );
strncpy( pProgramPath, pActiveXPath, nLen - nRemoveLen ); strncpy( pProgramPath, pActiveXPath, nLen - nRemoveLen );
pProgramPath[ nLen - nRemoveLen ] = 0; pProgramPath[ nLen - nRemoveLen ] = 0;
@@ -98,11 +101,11 @@ void RegisterActiveXNative( const char* pActiveXPath, int nMode, BOOL InstallFor
void UnregisterActiveXNative( const char* pActiveXPath, int nMode, BOOL InstallForAllUser, BOOL InstallFor64Bit ) void UnregisterActiveXNative( const char* pActiveXPath, int nMode, BOOL InstallForAllUser, BOOL InstallFor64Bit )
{ {
HINSTANCE hModule = LoadLibraryExA( pActiveXPath, NULL, LOAD_WITH_ALTERED_SEARCH_PATH ); HINSTANCE hModule = LoadLibraryExA( pActiveXPath, nullptr, LOAD_WITH_ALTERED_SEARCH_PATH );
if( hModule ) if( hModule )
{ {
DllNativeUnregProc pNativeProc = ( DllNativeUnregProc )GetProcAddress( hModule, "DllUnregisterServerNative" ); DllNativeUnregProc pNativeProc = reinterpret_cast<DllNativeUnregProc>(GetProcAddress( hModule, "DllUnregisterServerNative" ));
if( pNativeProc!=NULL ) if( pNativeProc!=nullptr )
( *pNativeProc )( nMode, InstallForAllUser, InstallFor64Bit ); ( *pNativeProc )( nMode, InstallForAllUser, InstallFor64Bit );
FreeLibrary( hModule ); FreeLibrary( hModule );
@@ -117,7 +120,7 @@ BOOL GetMsiPropW( MSIHANDLE hMSI, const wchar_t* pPropName, wchar_t** ppValue )
{ {
sz++; sz++;
DWORD nbytes = sz * sizeof( wchar_t ); DWORD nbytes = sz * sizeof( wchar_t );
wchar_t* buff = reinterpret_cast<wchar_t*>( malloc( nbytes ) ); wchar_t* buff = static_cast<wchar_t*>( malloc( nbytes ) );
ZeroMemory( buff, nbytes ); ZeroMemory( buff, nbytes );
MsiGetPropertyW( hMSI, pPropName, buff, &sz ); MsiGetPropertyW( hMSI, pPropName, buff, &sz );
*ppValue = buff; *ppValue = buff;
@@ -131,7 +134,7 @@ BOOL GetMsiPropW( MSIHANDLE hMSI, const wchar_t* pPropName, wchar_t** ppValue )
BOOL GetActiveXControlPath( MSIHANDLE hMSI, char** ppActiveXPath ) BOOL GetActiveXControlPath( MSIHANDLE hMSI, char** ppActiveXPath )
{ {
wchar_t* pProgPath = NULL; wchar_t* pProgPath = nullptr;
if ( GetMsiPropW( hMSI, L"INSTALLLOCATION", &pProgPath ) && pProgPath ) if ( GetMsiPropW( hMSI, L"INSTALLLOCATION", &pProgPath ) && pProgPath )
{ {
char* pCharProgPath = UnicodeToAnsiString( pProgPath ); char* pCharProgPath = UnicodeToAnsiString( pProgPath );
@@ -139,7 +142,7 @@ BOOL GetActiveXControlPath( MSIHANDLE hMSI, char** ppActiveXPath )
if ( pCharProgPath ) if ( pCharProgPath )
{ {
int nLen = strlen( pCharProgPath ); int nLen = strlen( pCharProgPath );
*ppActiveXPath = reinterpret_cast<char*>( malloc( nLen + 23 ) ); *ppActiveXPath = static_cast<char*>( malloc( nLen + 23 ) );
strncpy( *ppActiveXPath, pCharProgPath, nLen ); strncpy( *ppActiveXPath, pCharProgPath, nLen );
strncpy( (*ppActiveXPath) + nLen, "program\\so_activex.dll", 22 ); strncpy( (*ppActiveXPath) + nLen, "program\\so_activex.dll", 22 );
(*ppActiveXPath)[nLen+22] = 0; (*ppActiveXPath)[nLen+22] = 0;
@@ -258,7 +261,7 @@ BOOL GetDelta( MSIHANDLE hMSI, int& nOldInstallMode, int& nInstallMode, int& nDe
BOOL MakeInstallForAllUsers( MSIHANDLE hMSI ) BOOL MakeInstallForAllUsers( MSIHANDLE hMSI )
{ {
BOOL bResult = FALSE; BOOL bResult = FALSE;
wchar_t* pVal = NULL; wchar_t* pVal = nullptr;
if ( GetMsiPropW( hMSI, L"ALLUSERS", &pVal ) && pVal ) if ( GetMsiPropW( hMSI, L"ALLUSERS", &pVal ) && pVal )
{ {
bResult = UnicodeEquals( pVal , L"1" ); bResult = UnicodeEquals( pVal , L"1" );
@@ -272,7 +275,7 @@ BOOL MakeInstallForAllUsers( MSIHANDLE hMSI )
BOOL MakeInstallFor64Bit( MSIHANDLE hMSI ) BOOL MakeInstallFor64Bit( MSIHANDLE hMSI )
{ {
BOOL bResult = FALSE; BOOL bResult = FALSE;
wchar_t* pVal = NULL; wchar_t* pVal = nullptr;
if ( GetMsiPropW( hMSI, L"VersionNT64", &pVal ) && pVal ) if ( GetMsiPropW( hMSI, L"VersionNT64", &pVal ) && pVal )
{ {
bResult = TRUE; bResult = TRUE;
@@ -295,7 +298,7 @@ extern "C" UINT __stdcall InstallActiveXControl( MSIHANDLE hMSI )
BOOL bInstallForAllUser = MakeInstallForAllUsers( hMSI ); BOOL bInstallForAllUser = MakeInstallForAllUsers( hMSI );
BOOL bInstallFor64Bit = MakeInstallFor64Bit( hMSI ); BOOL bInstallFor64Bit = MakeInstallFor64Bit( hMSI );
char* pActiveXPath = NULL; char* pActiveXPath = nullptr;
if ( GetActiveXControlPath( hMSI, &pActiveXPath ) && pActiveXPath if ( GetActiveXControlPath( hMSI, &pActiveXPath ) && pActiveXPath
&& GetDelta( hMSI, nOldInstallMode, nInstallMode, nDeinstallMode ) ) && GetDelta( hMSI, nOldInstallMode, nInstallMode, nDeinstallMode ) )
{ {
@@ -336,7 +339,7 @@ extern "C" UINT __stdcall DeinstallActiveXControl( MSIHANDLE hMSI )
if ( ERROR_SUCCESS == MsiGetFeatureState( hMSI, L"gm_o_Activexcontrol", &current_state, &future_state ) ) if ( ERROR_SUCCESS == MsiGetFeatureState( hMSI, L"gm_o_Activexcontrol", &current_state, &future_state ) )
{ {
char* pActiveXPath = NULL; char* pActiveXPath = nullptr;
if ( current_state == INSTALLSTATE_LOCAL && GetActiveXControlPath( hMSI, &pActiveXPath ) && pActiveXPath ) if ( current_state == INSTALLSTATE_LOCAL && GetActiveXControlPath( hMSI, &pActiveXPath ) && pActiveXPath )
{ {
BOOL bInstallForAllUser = MakeInstallForAllUsers( hMSI ); BOOL bInstallForAllUser = MakeInstallForAllUsers( hMSI );

View File

@@ -43,7 +43,7 @@ BOOL GetMsiPropA( MSIHANDLE hMSI, const char* pPropName, char** ppValue )
if ( MsiGetPropertyA( hMSI, pPropName, const_cast<char *>(""), &sz ) == ERROR_MORE_DATA ) { if ( MsiGetPropertyA( hMSI, pPropName, const_cast<char *>(""), &sz ) == ERROR_MORE_DATA ) {
sz++; sz++;
DWORD nbytes = sz * sizeof( char ); DWORD nbytes = sz * sizeof( char );
char* buff = reinterpret_cast<char*>( malloc( nbytes ) ); char* buff = static_cast<char*>( malloc( nbytes ) );
ZeroMemory( buff, nbytes ); ZeroMemory( buff, nbytes );
MsiGetPropertyA( hMSI, pPropName, buff, &sz ); MsiGetPropertyA( hMSI, pPropName, buff, &sz );
*ppValue = buff; *ppValue = buff;
@@ -151,7 +151,7 @@ langid_to_string( LANGID langid )
case MAKELANGID(LANG_NORWEGIAN, SUBLANG_NORWEGIAN_NYNORSK): return "nn"; case MAKELANGID(LANG_NORWEGIAN, SUBLANG_NORWEGIAN_NYNORSK): return "nn";
case MAKELANGID(LANG_SERBIAN, SUBLANG_SERBIAN_LATIN): return "sh"; case MAKELANGID(LANG_SERBIAN, SUBLANG_SERBIAN_LATIN): return "sh";
case MAKELANGID(LANG_SERBIAN, SUBLANG_SERBIAN_CYRILLIC): return "sr"; case MAKELANGID(LANG_SERBIAN, SUBLANG_SERBIAN_CYRILLIC): return "sr";
default: return 0; default: return nullptr;
} }
} }
} }
@@ -164,7 +164,7 @@ static int num_ui_langs = 0;
void add_ui_lang(char const * lang) void add_ui_lang(char const * lang)
{ {
if (lang != 0 && num_ui_langs != SAL_N_ELEMENTS(ui_langs)) { if (lang != nullptr && num_ui_langs != SAL_N_ELEMENTS(ui_langs)) {
ui_langs[num_ui_langs++] = lang; ui_langs[num_ui_langs++] = lang;
} }
} }
@@ -172,7 +172,7 @@ void add_ui_lang(char const * lang)
BOOL CALLBACK BOOL CALLBACK
enum_ui_lang_proc (LPTSTR language, LONG_PTR /* unused_lParam */) enum_ui_lang_proc (LPTSTR language, LONG_PTR /* unused_lParam */)
{ {
long langid = strtol(language, NULL, 16); long langid = strtol(language, nullptr, 16);
if (langid > 0xFFFF) if (langid > 0xFFFF)
return TRUE; return TRUE;
add_ui_lang(langid_to_string((LANGID) langid)); add_ui_lang(langid_to_string((LANGID) langid));
@@ -186,7 +186,7 @@ present_in_ui_langs(const char *lang)
{ {
for (int i = 0; i < num_ui_langs; i++) for (int i = 0; i < num_ui_langs; i++)
{ {
if (strchr (lang, '_') != NULL) if (strchr (lang, '_') != nullptr)
if (memcmp (ui_langs[i], lang, std::min(strlen(ui_langs[i]), strlen(lang))) == 0) if (memcmp (ui_langs[i], lang, std::min(strlen(ui_langs[i]), strlen(lang))) == 0)
return TRUE; return TRUE;
if (strcmp (ui_langs[i], lang) == 0) if (strcmp (ui_langs[i], lang) == 0)
@@ -215,7 +215,7 @@ void addMatchingDictionaries(
if (strcmp(lang, setup_native::languageDictionaries[i].language) == 0) { if (strcmp(lang, setup_native::languageDictionaries[i].language) == 0) {
for (char const * const * p = setup_native::languageDictionaries[i]. for (char const * const * p = setup_native::languageDictionaries[i].
dictionaries; dictionaries;
*p != NULL; ++p) *p != nullptr; ++p)
{ {
for (int j = 0; j != ndicts; ++j) { for (int j = 0; j != ndicts; ++j) {
if (_stricmp(*p, dicts[j].lang) == 0) { if (_stricmp(*p, dicts[j].lang) == 0) {
@@ -313,13 +313,13 @@ extern "C" UINT __stdcall SelectLanguage( MSIHANDLE handle )
/* Keep track of what UI languages are relevant, either the ones explicitly /* Keep track of what UI languages are relevant, either the ones explicitly
* requested with the UI_LANGS property, or all available on the system: * requested with the UI_LANGS property, or all available on the system:
*/ */
char* pVal = NULL; char* pVal = nullptr;
if ( (GetMsiPropA( handle, "UI_LANGS", &pVal )) && pVal ) { if ( (GetMsiPropA( handle, "UI_LANGS", &pVal )) && pVal ) {
char *str_ptr; char *str_ptr;
str_ptr = strtok(pVal, ","); str_ptr = strtok(pVal, ",");
for(; str_ptr != NULL ;) { for(; str_ptr != nullptr ;) {
add_ui_lang(str_ptr); add_ui_lang(str_ptr);
str_ptr = strtok(NULL, ","); str_ptr = strtok(nullptr, ",");
} }
} else { } else {
add_ui_lang(langid_to_string(GetSystemDefaultUILanguage())); add_ui_lang(langid_to_string(GetSystemDefaultUILanguage()));

View File

@@ -22,33 +22,33 @@ extern "C" UINT __stdcall SortTree(MSIHANDLE)
{ {
// Sort items (languages) in SelectionTree control, fdo#46355 // Sort items (languages) in SelectionTree control, fdo#46355
HWND hwndMSI = FindWindowW(L"MsiDialogCloseClass", NULL); HWND hwndMSI = FindWindowW(L"MsiDialogCloseClass", nullptr);
if (hwndMSI == NULL) if (hwndMSI == nullptr)
{ {
OutputDebugStringA("SortTree: MsiDialogCloseClass not found\n"); OutputDebugStringA("SortTree: MsiDialogCloseClass not found\n");
return ERROR_SUCCESS; return ERROR_SUCCESS;
} }
HWND hwndTV = FindWindowExW(hwndMSI, NULL, L"SysTreeView32", NULL); HWND hwndTV = FindWindowExW(hwndMSI, nullptr, L"SysTreeView32", nullptr);
if (hwndTV == NULL) if (hwndTV == nullptr)
{ {
OutputDebugStringA("SortTree: SysTreeView32 not found\n"); OutputDebugStringA("SortTree: SysTreeView32 not found\n");
return ERROR_SUCCESS; return ERROR_SUCCESS;
} }
HTREEITEM optional = TreeView_GetRoot(hwndTV); HTREEITEM optional = TreeView_GetRoot(hwndTV);
if (optional == NULL) if (optional == nullptr)
{ {
OutputDebugStringA("SortTree: Optional Components branch not found\n"); OutputDebugStringA("SortTree: Optional Components branch not found\n");
return ERROR_SUCCESS; return ERROR_SUCCESS;
} }
HTREEITEM dicts = TreeView_GetChild(hwndTV, optional); HTREEITEM dicts = TreeView_GetChild(hwndTV, optional);
if (dicts == NULL) if (dicts == nullptr)
{ {
OutputDebugStringA("SortTree: Dictionaries branch not found\n"); OutputDebugStringA("SortTree: Dictionaries branch not found\n");
return ERROR_SUCCESS; return ERROR_SUCCESS;
} }
TreeView_SortChildren(hwndTV, dicts, TRUE); TreeView_SortChildren(hwndTV, dicts, TRUE);
HTREEITEM langs = TreeView_GetNextSibling(hwndTV, optional); HTREEITEM langs = TreeView_GetNextSibling(hwndTV, optional);
if (langs == NULL) if (langs == nullptr)
{ {
OutputDebugStringA("SortTree: Additional UI Languages branch not found\n"); OutputDebugStringA("SortTree: Additional UI Languages branch not found\n");
return ERROR_SUCCESS; return ERROR_SUCCESS;

View File

@@ -38,7 +38,7 @@ extern "C" UINT __stdcall MigrateInstallPath( MSIHANDLE handle )
if ( ERROR_SUCCESS == RegOpenKeyW( HKEY_CURRENT_USER, sProductKey.c_str(), &hKey ) ) if ( ERROR_SUCCESS == RegOpenKeyW( HKEY_CURRENT_USER, sProductKey.c_str(), &hKey ) )
{ {
if ( ERROR_SUCCESS == RegQueryValueExW( hKey, L"INSTALLLOCATION", NULL, NULL, (LPBYTE)szValue, &nValueSize ) ) if ( ERROR_SUCCESS == RegQueryValueExW( hKey, L"INSTALLLOCATION", nullptr, nullptr, reinterpret_cast<LPBYTE>(szValue), &nValueSize ) )
{ {
sInstDir = szValue; sInstDir = szValue;
MsiSetPropertyW(handle, L"INSTALLLOCATION", sInstDir.c_str()); MsiSetPropertyW(handle, L"INSTALLLOCATION", sInstDir.c_str());
@@ -49,7 +49,7 @@ extern "C" UINT __stdcall MigrateInstallPath( MSIHANDLE handle )
} }
else if ( ERROR_SUCCESS == RegOpenKeyW( HKEY_LOCAL_MACHINE, sProductKey.c_str(), &hKey ) ) else if ( ERROR_SUCCESS == RegOpenKeyW( HKEY_LOCAL_MACHINE, sProductKey.c_str(), &hKey ) )
{ {
if ( ERROR_SUCCESS == RegQueryValueExW( hKey, L"INSTALLLOCATION", NULL, NULL, (LPBYTE)szValue, &nValueSize ) ) if ( ERROR_SUCCESS == RegQueryValueExW( hKey, L"INSTALLLOCATION", nullptr, nullptr, reinterpret_cast<LPBYTE>(szValue), &nValueSize ) )
{ {
sInstDir = szValue; sInstDir = szValue;
MsiSetPropertyW(handle, L"INSTALLLOCATION", sInstDir.c_str()); MsiSetPropertyW(handle, L"INSTALLLOCATION", sInstDir.c_str());

View File

@@ -44,7 +44,7 @@ static inline std::wstring GetMsiPropertyW( MSIHANDLE handle, const std::wstring
if ( MsiGetPropertyW( handle, sProperty.c_str(), szDummy, &nChars ) == ERROR_MORE_DATA ) if ( MsiGetPropertyW( handle, sProperty.c_str(), szDummy, &nChars ) == ERROR_MORE_DATA )
{ {
DWORD nBytes = ++nChars * sizeof(WCHAR); DWORD nBytes = ++nChars * sizeof(WCHAR);
PWSTR buffer = reinterpret_cast<PWSTR>(_alloca(nBytes)); PWSTR buffer = static_cast<PWSTR>(_alloca(nBytes));
ZeroMemory( buffer, nBytes ); ZeroMemory( buffer, nBytes );
MsiGetPropertyW( handle, sProperty.c_str(), buffer, &nChars ); MsiGetPropertyW( handle, sProperty.c_str(), buffer, &nChars );
result = buffer; result = buffer;
@@ -60,7 +60,7 @@ static inline void SetMsiPropertyW( MSIHANDLE handle, const std::wstring& sPrope
static inline void UnsetMsiPropertyW( MSIHANDLE handle, const std::wstring& sProperty ) static inline void UnsetMsiPropertyW( MSIHANDLE handle, const std::wstring& sProperty )
{ {
MsiSetPropertyW( handle, sProperty.c_str(), NULL ); MsiSetPropertyW( handle, sProperty.c_str(), nullptr );
} }
#endif // INCLUDED_SETUP_NATIVE_SOURCE_WIN32_CUSTOMACTIONS_SHELLEXTENSIONS_SHLXTMSI_HXX #endif // INCLUDED_SETUP_NATIVE_SOURCE_WIN32_CUSTOMACTIONS_SHELLEXTENSIONS_SHLXTMSI_HXX

View File

@@ -33,7 +33,7 @@ extern "C" UINT __stdcall InstallStartmenuFolderIcon( MSIHANDLE handle )
// the Win32 SDK 8.1 deprecates GetVersionEx() // the Win32 SDK 8.1 deprecates GetVersionEx()
#ifdef _WIN32_WINNT_WINBLUE #ifdef _WIN32_WINNT_WINBLUE
bool const bIsVistaOrLater = IsWindowsVistaOrGreater() ? true : false; bool const bIsVistaOrLater = IsWindowsVistaOrGreater();
#else #else
OSVERSIONINFO osverinfo; OSVERSIONINFO osverinfo;
osverinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); osverinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);

View File

@@ -54,7 +54,7 @@ namespace
string Invert(const string& str) string Invert(const string& str)
{ {
char* buff = reinterpret_cast<char*>(_alloca(str.length())); char* buff = static_cast<char*>(_alloca(str.length()));
strncpy(buff, str.c_str(), str.length()); strncpy(buff, str.c_str(), str.length());
char* front = buff; char* front = buff;
@@ -108,7 +108,7 @@ namespace
if (MsiGetPropertyA(handle, sProperty.c_str(), szDummy, &nChars) == ERROR_MORE_DATA) if (MsiGetPropertyA(handle, sProperty.c_str(), szDummy, &nChars) == ERROR_MORE_DATA)
{ {
DWORD nBytes = ++nChars * sizeof(CHAR); DWORD nBytes = ++nChars * sizeof(CHAR);
LPSTR buffer = reinterpret_cast<LPSTR>(_alloca(nBytes)); LPSTR buffer = static_cast<LPSTR>(_alloca(nBytes));
ZeroMemory( buffer, nBytes ); ZeroMemory( buffer, nBytes );
MsiGetPropertyA( handle, sProperty.c_str(), buffer, &nChars ); MsiGetPropertyA( handle, sProperty.c_str(), buffer, &nChars );
result = buffer; result = buffer;
@@ -123,7 +123,7 @@ namespace
inline void UnsetMsiPropertyA(MSIHANDLE handle, const string& sProperty) inline void UnsetMsiPropertyA(MSIHANDLE handle, const string& sProperty)
{ {
MsiSetPropertyA(handle, sProperty.c_str(), NULL); MsiSetPropertyA(handle, sProperty.c_str(), nullptr);
} }
inline void SetMsiPropertyA(MSIHANDLE handle, const string& sProperty) inline void SetMsiPropertyA(MSIHANDLE handle, const string& sProperty)
@@ -141,9 +141,9 @@ namespace
DWORD lLongestSubKey; DWORD lLongestSubKey;
if (RegQueryInfoKeyA( if (RegQueryInfoKeyA(
hKey, NULL, NULL, NULL, &nSubKeys, &lLongestSubKey, NULL, NULL, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) hKey, nullptr, nullptr, nullptr, &nSubKeys, &lLongestSubKey, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr) == ERROR_SUCCESS)
{ {
LPSTR buffer = reinterpret_cast<LPSTR>(_alloca(lLongestSubKey + 1)); LPSTR buffer = static_cast<LPSTR>(_alloca(lLongestSubKey + 1));
for (DWORD i = 0; i < nSubKeys; i++) for (DWORD i = 0; i < nSubKeys; i++)
{ {

View File

@@ -43,7 +43,7 @@ BOOL GetMsiPropW( MSIHANDLE hMSI, const wchar_t* pPropName, wchar_t** ppValue )
{ {
sz++; sz++;
DWORD nbytes = sz * sizeof( wchar_t ); DWORD nbytes = sz * sizeof( wchar_t );
wchar_t* buff = reinterpret_cast<wchar_t*>( malloc( nbytes ) ); wchar_t* buff = static_cast<wchar_t*>( malloc( nbytes ) );
ZeroMemory( buff, nbytes ); ZeroMemory( buff, nbytes );
MsiGetPropertyW( hMSI, pPropName, buff, &sz ); MsiGetPropertyW( hMSI, pPropName, buff, &sz );
*ppValue = buff; *ppValue = buff;
@@ -77,7 +77,7 @@ extern "C" UINT __stdcall CheckVersions( MSIHANDLE hMSI )
{ {
// MessageBoxW(NULL, L"CheckVersions", L"Information", MB_OK | MB_ICONINFORMATION); // MessageBoxW(NULL, L"CheckVersions", L"Information", MB_OK | MB_ICONINFORMATION);
wchar_t* pVal = NULL; wchar_t* pVal = nullptr;
if ( GetMsiPropW( hMSI, L"NEWPRODUCTS", &pVal ) && pVal ) if ( GetMsiPropW( hMSI, L"NEWPRODUCTS", &pVal ) && pVal )
{ {
@@ -86,7 +86,7 @@ extern "C" UINT __stdcall CheckVersions( MSIHANDLE hMSI )
SetMsiErrorCode( MSI_ERROR_NEW_VERSION_FOUND ); SetMsiErrorCode( MSI_ERROR_NEW_VERSION_FOUND );
free( pVal ); free( pVal );
} }
pVal = NULL; pVal = nullptr;
if ( GetMsiPropW( hMSI, L"OLDPRODUCTS", &pVal ) && pVal ) if ( GetMsiPropW( hMSI, L"OLDPRODUCTS", &pVal ) && pVal )
{ {
OutputDebugStringFormatW( L"DEBUG: OLDPRODUCTS found [%s]", pVal ); OutputDebugStringFormatW( L"DEBUG: OLDPRODUCTS found [%s]", pVal );
@@ -94,7 +94,7 @@ extern "C" UINT __stdcall CheckVersions( MSIHANDLE hMSI )
SetMsiErrorCode( MSI_ERROR_OLD_VERSION_FOUND ); SetMsiErrorCode( MSI_ERROR_OLD_VERSION_FOUND );
free( pVal ); free( pVal );
} }
pVal = NULL; pVal = nullptr;
return ERROR_SUCCESS; return ERROR_SUCCESS;
} }

View File

@@ -65,17 +65,17 @@ void SetMsiErrorCode( int nErrorCode )
FALSE, // do not inherit the name FALSE, // do not inherit the name
sMemMapName ); // name of mapping object sMemMapName ); // name of mapping object
if ( hMapFile == NULL ) // can not set error code if ( hMapFile == nullptr ) // can not set error code
{ {
OutputDebugStringFormatW( L"Could not open map file (%d).\n", GetLastError() ); OutputDebugStringFormatW( L"Could not open map file (%d).\n", GetLastError() );
return; return;
} }
pBuf = (int*) MapViewOfFile( hMapFile, // handle to map object pBuf = static_cast<int*>(MapViewOfFile( hMapFile, // handle to map object
FILE_MAP_ALL_ACCESS, // read/write permission FILE_MAP_ALL_ACCESS, // read/write permission
0, 0,
0, 0,
sizeof( int ) ); sizeof( int ) ));
if ( pBuf ) if ( pBuf )
{ {
*pBuf = nErrorCode; *pBuf = nErrorCode;