Integrate C++11 branch into 5_1-new

This commit is contained in:
teejusb
2019-06-22 12:35:38 -07:00
444 changed files with 19503 additions and 21007 deletions
+2 -2
View File
@@ -5,9 +5,9 @@ AppInstance::AppInstance()
{
// Little trick to get an HINSTANCE of ourself without having access to the hwnd.
TCHAR szFullAppPath[MAX_PATH];
GetModuleFileName(NULL, szFullAppPath, MAX_PATH);
GetModuleFileName(nullptr, szFullAppPath, MAX_PATH);
h = LoadLibrary(szFullAppPath);
/* h will be NULL if this fails. Most operations that take an HINSTANCE
/* h will be nullptr if this fails. Most operations that take an HINSTANCE
* will still work without one (but may be missing graphics); that's OK. */
}
+1 -1
View File
@@ -9,7 +9,7 @@ int GetWin32CmdLine( char** &argv )
{
char *pCmdLine = GetCommandLine();
int argc = 0;
argv = NULL;
argv = nullptr;
int i = 0;
while( pCmdLine[i] )
+30 -31
View File
@@ -23,7 +23,7 @@ static void SpliceProgramPath(char *buf, int bufsiz, const char *fn) {
char tbuf[MAX_PATH];
char *pszFile;
GetModuleFileName(NULL, tbuf, sizeof tbuf);
GetModuleFileName(nullptr, tbuf, sizeof tbuf);
GetFullPathName(tbuf, bufsiz, buf, &pszFile);
strcpy(pszFile, fn);
}
@@ -50,7 +50,7 @@ static const struct ExceptionLookup {
{ EXCEPTION_INVALID_HANDLE, "Invalid handle" },
{ EXCEPTION_STACK_OVERFLOW, "Stack overflow" },
{ 0xe06d7363, "Unhandled Microsoft C++ Exception", },
{ NULL },
{ nullptr },
};
static const char *LookupException( DWORD code )
@@ -59,7 +59,7 @@ static const char *LookupException( DWORD code )
if( exceptions[i].code == code )
return exceptions[i].name;
return NULL;
return nullptr;
}
static CrashInfo g_CrashInfo;
@@ -68,13 +68,13 @@ static void GetReason( const EXCEPTION_RECORD *pRecord, CrashInfo *crash )
// fill out bomb reason
const char *reason = LookupException( pRecord->ExceptionCode );
if( reason == NULL )
if( reason == nullptr )
wsprintf( crash->m_CrashReason, "unknown exception 0x%08lx", pRecord->ExceptionCode );
else
strcpy( crash->m_CrashReason, reason );
}
static HWND g_hForegroundWnd = NULL;
static HWND g_hForegroundWnd = nullptr;
void CrashHandler::SetForegroundWindow( HWND hWnd )
{
g_hForegroundWnd = hWnd;
@@ -85,7 +85,7 @@ void WriteToChild( HANDLE hPipe, const void *pData, size_t iSize )
while( iSize )
{
DWORD iActual;
if( !WriteFile(hPipe, pData, iSize, &iActual, NULL) )
if( !WriteFile(hPipe, pData, iSize, &iActual, nullptr) )
return;
iSize -= iActual;
}
@@ -106,7 +106,7 @@ bool StartChild( HANDLE &hProcess, HANDLE &hToStdin, HANDLE &hFromStdout )
SECURITY_ATTRIBUTES sa;
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
sa.bInheritHandle = true;
sa.lpSecurityDescriptor = NULL;
sa.lpSecurityDescriptor = nullptr;
CreatePipe( &si.hStdInput, &hToStdin, &sa, 0 );
CreatePipe( &hFromStdout, &si.hStdOutput, &sa, 0 );
@@ -115,19 +115,19 @@ bool StartChild( HANDLE &hProcess, HANDLE &hToStdin, HANDLE &hFromStdout )
}
char szBuf[256] = "";
GetModuleFileName( NULL, szBuf, MAX_PATH );
GetModuleFileName( nullptr, szBuf, MAX_PATH );
strcat( szBuf, " " );
strcat( szBuf, CHILD_MAGIC_PARAMETER );
PROCESS_INFORMATION pi;
int iRet = CreateProcess(
NULL, // pointer to name of executable module
nullptr, // pointer to name of executable module
szBuf, // pointer to command line string
NULL, // process security attributes
NULL, // thread security attributes
nullptr, // process security attributes
nullptr, // thread security attributes
true, // handle inheritance flag
0, // creation flags
NULL, // pointer to new environment block
nullptr, // pointer to new environment block
cwd, // pointer to current directory name
&si, // pointer to STARTUPINFO
&pi // pointer to PROCESS_INFORMATION
@@ -156,19 +156,19 @@ static const char *CrashGetModuleBaseName(HMODULE hmod, char *pszBaseName)
// XXX: It looks like nothing in here COULD throw an exception. Need to verify that.
// __try {
if( !GetModuleFileName(hmod, szPath1, sizeof(szPath1)) )
return NULL;
return nullptr;
char *pszFile;
DWORD dw = GetFullPathName( szPath1, sizeof(szPath2), szPath2, &pszFile );
if( !dw || dw > sizeof(szPath2) )
return NULL;
return nullptr;
strcpy( pszBaseName, pszFile );
pszFile = pszBaseName;
char *period = NULL;
char *period = nullptr;
while( *pszFile++ )
if( pszFile[-1]=='.' )
period = pszFile-1;
@@ -176,7 +176,7 @@ static const char *CrashGetModuleBaseName(HMODULE hmod, char *pszBaseName)
if( period )
*period = 0;
// } __except(1) {
// return NULL;
// return nullptr;
// }
return pszBaseName;
@@ -222,7 +222,7 @@ void RunChild()
// 4. Write RecentLogs.
int cnt = 0;
const TCHAR *ps[1024];
while( cnt < 1024 && (ps[cnt] = RageLog::GetRecentLog( cnt )) != NULL )
while( cnt < 1024 && (ps[cnt] = RageLog::GetRecentLog( cnt )) != nullptr )
++cnt;
WriteToChild(hToStdin, &cnt, sizeof(cnt));
@@ -254,7 +254,7 @@ void RunChild()
* since GetModuleFileNameEx might not be available. Run the requests here. */
HMODULE hMod;
DWORD iActual;
if( !ReadFile( hFromStdout, &hMod, sizeof(hMod), &iActual, NULL) )
if( !ReadFile( hFromStdout, &hMod, sizeof(hMod), &iActual, nullptr) )
break;
TCHAR szName[MAX_PATH];
@@ -301,8 +301,8 @@ static long MainExceptionHandler( EXCEPTION_POINTERS *pExc )
/* If we get here, then we've been called recursively, which means we
* crashed. If InHere is greater than 1, then we crashed after writing
* the crash dump; say so. */
SetUnhandledExceptionFilter(NULL);
MessageBox( NULL,
SetUnhandledExceptionFilter(nullptr);
MessageBox( nullptr,
InHere == 1?
"The error reporting interface has crashed.\n":
"The error reporting interface has crashed. However, crashinfo.txt was"
@@ -333,7 +333,7 @@ static long MainExceptionHandler( EXCEPTION_POINTERS *pExc )
/* Now things get more risky. If we're fullscreen, the window will obscure
* the crash dialog. Try to hide the window. Things might blow up here; do
* this after DoSave, so we always write a crash dump. */
if( GetWindowThreadProcessId( g_hForegroundWnd, NULL ) == GetCurrentThreadId() )
if( GetWindowThreadProcessId( g_hForegroundWnd, nullptr ) == GetCurrentThreadId() )
{
/* The thread that crashed was the thread that created the main window.
* Hide the window. This will also restore the video mode, if necessary. */
@@ -342,12 +342,12 @@ static long MainExceptionHandler( EXCEPTION_POINTERS *pExc )
/* A different thread crashed. Simply kill all other windows. We can't
* safely call ShowWindow; the main thread might be deadlocked. */
RageThread::HaltAllThreads( true );
ChangeDisplaySettings( NULL, 0 );
ChangeDisplaySettings( nullptr, 0 );
}
InHere = false;
SetUnhandledExceptionFilter( NULL );
SetUnhandledExceptionFilter(nullptr);
/* Forcibly terminate; if we keep going, we'll try to shut down threads and
* do other things that may deadlock, which is confusing for users. */
@@ -362,7 +362,7 @@ long __stdcall CrashHandler::ExceptionHandler( EXCEPTION_POINTERS *pExc )
* Allocate a new stack, and run the exception handler in it, to increase
* the chances of success. */
int iSize = 1024*32;
char *pStack = (char *) VirtualAlloc( NULL, iSize, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE );
char *pStack = (char *) VirtualAlloc( nullptr, iSize, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE );
pStack += iSize;
// FIXME: This will probably explode on x86-64
#if defined(_MSC_VER)
@@ -456,7 +456,7 @@ static bool PointsToValidCall( unsigned long ptr )
memset( buf, 0, sizeof(buf) );
while(len > 0 && !ReadProcessMemory(GetCurrentProcess(), (void *)(ptr-len), buf+7-len, len, NULL))
while(len > 0 && !ReadProcessMemory(GetCurrentProcess(), (void *)(ptr-len), buf+7-len, len, nullptr))
--len;
return IsValidCall(buf+7, len);
@@ -473,7 +473,7 @@ void CrashHandler::do_backtrace( const void **buf, size_t size,
* due to stack corruption, we might not be able to get any frames from the
* stack. Pull it out of pContext->Eip, which is always valid, and then
* discard the first stack frame if it's the same. */
if( buf+1 != pLast && pContext->Eip != NULL )
if( buf+1 != pLast && pContext->Eip != 0 )
{
*buf = (void *) pContext->Eip;
++buf;
@@ -485,7 +485,7 @@ void CrashHandler::do_backtrace( const void **buf, size_t size,
LDT_ENTRY sel;
if( !GetThreadSelectorEntry( hThread, pContext->SegFs, &sel ) )
{
*buf = NULL;
*buf = nullptr;
return;
}
@@ -532,16 +532,15 @@ void CrashHandler::do_backtrace( const void **buf, size_t size,
break;
lpAddr += 4;
} while( ReadProcessMemory(hProcess, lpAddr-4, &data, 4, NULL));
} while( ReadProcessMemory(hProcess, lpAddr-4, &data, 4, nullptr));
*buf = NULL;
*buf = nullptr;
}
// Trigger the crash handler. This works even in the debugger.
static void NORETURN debug_crash()
{
// __try {
#if defined(__MSC_VER)
__try {
__asm xor ebx,ebx
__asm mov eax,dword ptr [ebx]
// __asm mov dword ptr [ebx],eax
+21 -21
View File
@@ -41,8 +41,8 @@ namespace VDDebugInfo
{
struct Context
{
Context() { pRVAHeap=NULL; }
bool Loaded() const { return pRVAHeap != NULL; }
Context() { pRVAHeap=nullptr; }
bool Loaded() const { return pRVAHeap != nullptr; }
RString sRawBlock;
int nBuildNumber;
@@ -59,7 +59,7 @@ namespace VDDebugInfo
static void GetVDIPath( char *buf, int bufsiz )
{
GetModuleFileName( NULL, buf, bufsiz );
GetModuleFileName( nullptr, buf, bufsiz );
buf[bufsiz-5] = 0;
char *p = strrchr( buf, '.' );
if( p )
@@ -86,7 +86,7 @@ namespace VDDebugInfo
const unsigned char *src = (const unsigned char *) pctx->sRawBlock.data();
pctx->pRVAHeap = NULL;
pctx->pRVAHeap = nullptr;
static const char *header = "symbolic debug information";
if( memcmp(src, header, strlen(header)) )
@@ -121,11 +121,11 @@ namespace VDDebugInfo
return true;
pctx->sRawBlock = RString();
pctx->pRVAHeap = NULL;
pctx->pRVAHeap = nullptr;
GetVDIPath( pctx->sFilename, ARRAYLEN(pctx->sFilename) );
pctx->sError = RString();
HANDLE h = CreateFile( pctx->sFilename, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
HANDLE h = CreateFile( pctx->sFilename, GENERIC_READ, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr );
if( h == INVALID_HANDLE_VALUE )
{
pctx->sError = werr_ssprintf( GetLastError(), "CreateFile failed" );
@@ -133,7 +133,7 @@ namespace VDDebugInfo
}
do {
DWORD dwFileSize = GetFileSize( h, NULL );
DWORD dwFileSize = GetFileSize( h, nullptr );
if( dwFileSize == INVALID_FILE_SIZE )
break;
@@ -141,7 +141,7 @@ namespace VDDebugInfo
std::fill(buffer, buffer + dwFileSize + 1, '\0' );
DWORD dwActual;
int iRet = ReadFile(h, buffer, dwFileSize, &dwActual, NULL);
int iRet = ReadFile(h, buffer, dwFileSize, &dwActual, nullptr);
CloseHandle(h);
pctx->sRawBlock = buffer;
delete[] buffer;
@@ -268,7 +268,7 @@ namespace SymbolLookup
{
SymSetOptions( SYMOPT_UNDNAME | SYMOPT_DEFERRED_LOADS );
if( !SymInitialize(g_hParent, NULL, TRUE) )
if( !SymInitialize(g_hParent, nullptr, TRUE) )
return false;
bInitted = true;
@@ -288,7 +288,7 @@ namespace SymbolLookup
pSymbol->MaxNameLen = sizeof(buffer) - sizeof(SYMBOL_INFO) + 1;
if( !SymFromAddr(g_hParent, ptr, &disp, pSymbol) )
return NULL;
return nullptr;
return pSymbol;
}
@@ -394,7 +394,7 @@ namespace
RString SpliceProgramPath( RString fn )
{
char szBuf[MAX_PATH];
GetModuleFileName( NULL, szBuf, sizeof(szBuf) );
GetModuleFileName( nullptr, szBuf, sizeof(szBuf) );
char szModName[MAX_PATH];
char *pszFile;
@@ -491,7 +491,7 @@ static void DoSave( const RString &sReport )
SetFileAttributes( sName, FILE_ATTRIBUTE_NORMAL );
FILE *pFile = fopen( sName, "w+" );
if( pFile == NULL )
if( pFile == nullptr )
return;
fprintf( pFile, "%s", sReport.c_str() );
@@ -659,7 +659,7 @@ CrashDialog::CrashDialog( const RString &sCrashReport, const CompleteCrashData &
m_CrashData( CrashData )
{
LoadLocalizedStrings();
m_pPost = NULL;
m_pPost = nullptr;
}
CrashDialog::~CrashDialog()
@@ -692,7 +692,7 @@ BOOL CrashDialog::HandleMessage( UINT msg, WPARAM wParam, LPARAM lParam )
{
HDC hdc = (HDC)wParam;
HWND hwndStatic = (HWND)lParam;
HBRUSH hbr = NULL;
HBRUSH hbr = nullptr;
// TODO: Change any attributes of the DC here
switch( GetDlgCtrlID(hwndStatic) )
@@ -713,7 +713,7 @@ BOOL CrashDialog::HandleMessage( UINT msg, WPARAM wParam, LPARAM lParam )
switch(LOWORD(wParam))
{
case IDC_BUTTON_CLOSE:
if( m_pPost != NULL )
if( m_pPost != nullptr )
{
// Cancel reporting, and revert the dialog as if "report" had not been pressed.
m_pPost->Cancel();
@@ -734,7 +734,7 @@ BOOL CrashDialog::HandleMessage( UINT msg, WPARAM wParam, LPARAM lParam )
{
RString sLogPath;
FILE *pFile = fopen( SpliceProgramPath("../Portable.ini"), "r" );
if(pFile != NULL)
if(pFile != nullptr)
{
sLogPath = SpliceProgramPath("../Logs/log.txt");
fclose( pFile );
@@ -742,11 +742,11 @@ BOOL CrashDialog::HandleMessage( UINT msg, WPARAM wParam, LPARAM lParam )
else
sLogPath = SpecialDirs::GetAppDataDir() + PRODUCT_ID +"/Logs/log.txt";
ShellExecute( NULL, "open", sLogPath, "", "", SW_SHOWNORMAL );
ShellExecute( nullptr, "open", sLogPath, "", "", SW_SHOWNORMAL );
}
break;
case IDC_CRASH_SAVE:
ShellExecute( NULL, "open", SpliceProgramPath("../crashinfo.txt"), "", "", SW_SHOWNORMAL );
ShellExecute( nullptr, "open", SpliceProgramPath("../crashinfo.txt"), "", "", SW_SHOWNORMAL );
return TRUE;
case IDC_BUTTON_RESTART:
Win32RestartProgram();
@@ -781,13 +781,13 @@ BOOL CrashDialog::HandleMessage( UINT msg, WPARAM wParam, LPARAM lParam )
m_pPost->Start( CRASH_REPORT_HOST, CRASH_REPORT_PORT, CRASH_REPORT_PATH );
SetTimer( hDlg, 0, 100, NULL );
SetTimer( hDlg, 0, 100, nullptr );
break;
}
break;
case WM_TIMER:
{
if( m_pPost == NULL )
if( m_pPost == nullptr )
break;
float fProgress = m_pPost->GetProgress();
@@ -875,7 +875,7 @@ void ChildProcess()
// Now that we've done that, the process is gone. Don't use g_hParent.
CloseHandle( SymbolLookup::g_hParent );
SymbolLookup::g_hParent = NULL;
SymbolLookup::g_hParent = nullptr;
CrashDialog cd( sCrashReport, Data );
#if defined(AUTOMATED_CRASH_REPORTS)
+1 -1
View File
@@ -18,7 +18,7 @@ struct CrashInfo
m_CrashReason[0] = 0;
memset( m_AlternateThreadBacktrace, 0, sizeof(m_AlternateThreadBacktrace) );
memset( m_AlternateThreadName, 0, sizeof(m_AlternateThreadName) );
m_BacktracePointers[0] = NULL;
m_BacktracePointers[0] = nullptr;
}
};
+15 -15
View File
@@ -5,7 +5,7 @@
#include "RageThreads.h"
#include "RageTimer.h"
#include "RageUtil.h"
#include "Foreach.h"
#if defined(WINDOWS)
#include <windows.h>
@@ -158,7 +158,7 @@ NetworkStream *CreateNetworkStream()
WSADATA WSAData;
WORD iVersionRequested = MAKEWORD(2,0);
if( WSAStartup(iVersionRequested, &WSAData) != 0 )
return NULL;
return nullptr;
}
return new NetworkStream_Win32;
@@ -170,11 +170,11 @@ NetworkStream_Win32::NetworkStream_Win32():
{
m_iPort = -1;
m_State = STATE_IDLE;
m_Socket = NULL;
m_Socket = nullptr;
#if defined(WINDOWS)
m_hResolve = NULL;
m_hResolveHwnd = NULL;
m_hCompletionEvent = CreateEvent( NULL, true, false, NULL );
m_hResolve = nullptr;
m_hResolveHwnd = nullptr;
m_hCompletionEvent = CreateEvent( nullptr, true, false, nullptr );
#endif
}
@@ -355,7 +355,7 @@ void NetworkStream_Win32::Open( const RString &sHost, int iPort, ConnectionType
m_iPort = iPort;
// Look up the hostname.
hostent *pHost = NULL;
hostent *pHost = nullptr;
char pBuf[MAXGETHOSTSTRUCT];
{
pHost = (hostent *) pBuf;
@@ -374,8 +374,8 @@ void NetworkStream_Win32::Open( const RString &sHost, int iPort, ConnectionType
mw.Run();
m_Mutex.Lock();
m_hResolve = NULL;
m_hResolveHwnd = NULL;
m_hResolve = nullptr;
m_hResolveHwnd = nullptr;
if( m_State == STATE_CANCELLED )
{
m_Mutex.Unlock();
@@ -475,7 +475,7 @@ void NetworkStream_Win32::Cancel()
m_State = STATE_CANCELLED;
// If resolving, abort the resolve.
if( m_hResolve != NULL )
if( m_hResolve != nullptr )
{
/* When we cancel the request, no message at all will be sent to the window,
* so we need to do it ourself to inform it that it was cancelled. Be sure
@@ -588,18 +588,18 @@ void NetworkPostData::CreateMimeData( const map<RString,RString> &mapNameToData,
while(1)
{
sMimeBoundaryOut = ssprintf( "--%08i", rand() );
FOREACHM_CONST( RString, RString, mapNameToData, d )
if( d->second.find(sMimeBoundaryOut) != RString::npos )
for (auto const &d : mapNameToData)
if( d.second.find(sMimeBoundaryOut) != RString::npos )
continue;
break;
}
FOREACHM_CONST( RString, RString, mapNameToData, d )
for (auto const &d : mapNameToData)
{
sOut += "--" + sMimeBoundaryOut + "\r\n";
sOut += ssprintf( "Content-Disposition: form-data; name=\"%s\"\r\n", d->first.c_str() );
sOut += ssprintf( "Content-Disposition: form-data; name=\"%s\"\r\n", d.first.c_str() );
sOut += "\r\n";
sOut += d->second;
sOut += d.second;
sOut += "\r\n";
}
if( sOut.size() )
+108 -108
View File
@@ -1,108 +1,108 @@
#include "global.h"
#include "DialogUtil.h"
#include "RageUtil.h"
#include "ThemeManager.h"
#include "archutils/Win32/ErrorStrings.h"
// Create*Font copied from MFC's CFont
// pLogFont->nHeight is interpreted as PointSize * 10
static HFONT CreatePointFontIndirect(const LOGFONT* lpLogFont)
{
HDC hDC = ::GetDC(NULL);
// convert nPointSize to logical units based on pDC
LOGFONT logFont = *lpLogFont;
POINT pt;
pt.y = ::GetDeviceCaps(hDC, LOGPIXELSY) * logFont.lfHeight;
pt.y /= 720; // 72 points/inch * 10 decipoints/point
pt.x = 0;
::DPtoLP(hDC, &pt, 1);
POINT ptOrg = { 0, 0 };
::DPtoLP(hDC, &ptOrg, 1);
logFont.lfHeight = -abs(pt.y - ptOrg.y);
ReleaseDC(NULL, hDC);
return ::CreateFontIndirect(&logFont);
}
// nPointSize is actually scaled 10x
static HFONT CreatePointFont(int nPointSize, LPCTSTR lpszFaceName)
{
ASSERT(lpszFaceName != NULL);
LOGFONT logFont;
memset(&logFont, 0, sizeof(LOGFONT));
logFont.lfCharSet = DEFAULT_CHARSET;
logFont.lfHeight = nPointSize;
lstrcpyn(logFont.lfFaceName, lpszFaceName, strlen(logFont.lfFaceName));
return ::CreatePointFontIndirect(&logFont);
}
void DialogUtil::SetHeaderFont( HWND hdlg, int nID )
{
ASSERT( hdlg != NULL );
HWND hControl = ::GetDlgItem( hdlg, nID );
ASSERT( hControl != NULL );
// TODO: Fix font leak
const int FONT_POINTS = 16;
HFONT hfont = CreatePointFont( FONT_POINTS*10, "Arial Black" );
::SendMessage( hControl, WM_SETFONT, (WPARAM)hfont, TRUE );
}
void DialogUtil::LocalizeDialogAndContents( HWND hdlg )
{
ASSERT( THEME != NULL );
const int LARGE_STRING = 256;
char szTemp[LARGE_STRING] = "";
RString sGroup;
{
::GetWindowText( hdlg, szTemp, ARRAYLEN(szTemp) );
RString s = szTemp;
sGroup = "Dialog-"+s;
s = THEME->GetString( sGroup, s );
::SetWindowText( hdlg, ConvertUTF8ToACP(s).c_str() );
}
for( HWND hwndChild = ::GetTopWindow(hdlg); hwndChild != NULL; hwndChild = ::GetNextWindow(hwndChild,GW_HWNDNEXT) )
{
::GetWindowText( hwndChild, szTemp, ARRAYLEN(szTemp) );
RString s = szTemp;
if( s.empty() )
continue;
s = THEME->GetString( sGroup, s );
::SetWindowText( hwndChild, ConvertUTF8ToACP(s).c_str() );
}
}
/*
* (c) 2002-2004 Chris Danford
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, and/or sell copies of the Software, and to permit persons to
* whom the Software is furnished to do so, provided that the above
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#include "global.h"
#include "DialogUtil.h"
#include "RageUtil.h"
#include "ThemeManager.h"
#include "archutils/Win32/ErrorStrings.h"
// Create*Font copied from MFC's CFont
// pLogFont->nHeight is interpreted as PointSize * 10
static HFONT CreatePointFontIndirect(const LOGFONT* lpLogFont)
{
HDC hDC = ::GetDC(nullptr);
// convert nPointSize to logical units based on pDC
LOGFONT logFont = *lpLogFont;
POINT pt;
pt.y = ::GetDeviceCaps(hDC, LOGPIXELSY) * logFont.lfHeight;
pt.y /= 720; // 72 points/inch * 10 decipoints/point
pt.x = 0;
::DPtoLP(hDC, &pt, 1);
POINT ptOrg = { 0, 0 };
::DPtoLP(hDC, &ptOrg, 1);
logFont.lfHeight = -abs(pt.y - ptOrg.y);
ReleaseDC(nullptr, hDC);
return ::CreateFontIndirect(&logFont);
}
// nPointSize is actually scaled 10x
static HFONT CreatePointFont(int nPointSize, LPCTSTR lpszFaceName)
{
ASSERT(lpszFaceName != nullptr);
LOGFONT logFont;
memset(&logFont, 0, sizeof(LOGFONT));
logFont.lfCharSet = DEFAULT_CHARSET;
logFont.lfHeight = nPointSize;
lstrcpyn(logFont.lfFaceName, lpszFaceName, strlen(logFont.lfFaceName));
return ::CreatePointFontIndirect(&logFont);
}
void DialogUtil::SetHeaderFont( HWND hdlg, int nID )
{
ASSERT( hdlg != nullptr );
HWND hControl = ::GetDlgItem( hdlg, nID );
ASSERT( hControl != nullptr );
// TODO: Fix font leak
const int FONT_POINTS = 16;
HFONT hfont = CreatePointFont( FONT_POINTS*10, "Arial Black" );
::SendMessage( hControl, WM_SETFONT, (WPARAM)hfont, TRUE );
}
void DialogUtil::LocalizeDialogAndContents( HWND hdlg )
{
ASSERT( THEME != nullptr );
const int LARGE_STRING = 256;
char szTemp[LARGE_STRING] = "";
RString sGroup;
{
::GetWindowText( hdlg, szTemp, ARRAYLEN(szTemp) );
RString s = szTemp;
sGroup = "Dialog-"+s;
s = THEME->GetString( sGroup, s );
::SetWindowText( hdlg, ConvertUTF8ToACP(s).c_str() );
}
for( HWND hwndChild = ::GetTopWindow(hdlg); hwndChild != nullptr; hwndChild = ::GetNextWindow(hwndChild,GW_HWNDNEXT) )
{
::GetWindowText( hwndChild, szTemp, ARRAYLEN(szTemp) );
RString s = szTemp;
if( s.empty() )
continue;
s = THEME->GetString( sGroup, s );
::SetWindowText( hwndChild, ConvertUTF8ToACP(s).c_str() );
}
}
/*
* (c) 2002-2004 Chris Danford
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, and/or sell copies of the Software, and to permit persons to
* whom the Software is furnished to do so, provided that the above
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
+4 -4
View File
@@ -8,7 +8,7 @@ RString werr_ssprintf( int err, const char *fmt, ... )
{
char buf[1024] = "";
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
0, err, 0, buf, sizeof(buf), NULL);
0, err, 0, buf, sizeof(buf), nullptr);
// Why is FormatMessage returning text ending with \r\n? (who? -aj)
// Perhaps it's because you're on Windows, where newlines are \r\n. -aj
@@ -31,13 +31,13 @@ RString ConvertWstringToCodepage( wstring s, int iCodePage )
return RString();
int iBytes = WideCharToMultiByte( iCodePage, 0, s.data(), s.size(),
NULL, 0, NULL, FALSE );
nullptr, 0, nullptr, FALSE );
ASSERT_M( iBytes > 0, werr_ssprintf( GetLastError(), "WideCharToMultiByte" ).c_str() );
char * buf = new char[iBytes + 1];
std::fill(buf, buf + iBytes + 1, '\0');
WideCharToMultiByte( CP_ACP, 0, s.data(), s.size(),
buf, iBytes, NULL, FALSE );
buf, iBytes, nullptr, FALSE );
RString ret( buf );
delete[] buf;
return ret;
@@ -53,7 +53,7 @@ wstring ConvertCodepageToWString( RString s, int iCodePage )
if( s.empty() )
return wstring();
int iBytes = MultiByteToWideChar( iCodePage, 0, s.data(), s.size(), NULL, 0 );
int iBytes = MultiByteToWideChar( iCodePage, 0, s.data(), s.size(), nullptr, 0 );
ASSERT_M( iBytes > 0, werr_ssprintf( GetLastError(), "MultiByteToWideChar" ).c_str() );
wchar_t *pTemp = new wchar_t[iBytes];
+10 -10
View File
@@ -22,7 +22,7 @@ bool GetFileVersion( RString sFile, RString &sOut )
RString VersionBuffer( iSize, ' ' );
// Also VC6:
if( !GetFileVersionInfo( const_cast<char *>(sFile.c_str()), NULL, iSize, const_cast<char *>(VersionBuffer.c_str()) ) )
if( !GetFileVersionInfo( const_cast<char *>(sFile.c_str()), nullptr, iSize, const_cast<char *>(VersionBuffer.c_str()) ) )
break;
WORD *iTrans;
@@ -73,7 +73,7 @@ RString FindSystemFile( RString sFile )
"/system/",
"/system/drivers/",
"/",
NULL
nullptr
};
for( int i = 0; szPaths[i]; ++i )
@@ -95,7 +95,7 @@ bool GetProcessFileName( uint32_t iProcessID, RString &sName )
* kernel32.lib functions. */
do {
HANDLE hSnap = CreateToolhelp32Snapshot( TH32CS_SNAPMODULE, iProcessID );
if( hSnap == NULL )
if( hSnap == nullptr )
{
sName = werr_ssprintf( GetLastError(), "CreateToolhelp32Snapshot" );
break;
@@ -118,9 +118,9 @@ bool GetProcessFileName( uint32_t iProcessID, RString &sName )
// This method only works in NT/2K/XP.
do {
static HINSTANCE hPSApi = NULL;
static HINSTANCE hPSApi = nullptr;
typedef DWORD (WINAPI* pfnGetProcessImageFileNameA)(HANDLE hProcess, LPSTR lpImageFileName, DWORD nSize);
static pfnGetProcessImageFileNameA pGetProcessImageFileName = NULL;
static pfnGetProcessImageFileNameA pGetProcessImageFileName = nullptr;
static bool bTried = false;
if( !bTried )
@@ -128,7 +128,7 @@ bool GetProcessFileName( uint32_t iProcessID, RString &sName )
bTried = true;
hPSApi = LoadLibrary("psapi.dll");
if( hPSApi == NULL )
if( hPSApi == nullptr )
{
sName = werr_ssprintf( GetLastError(), "LoadLibrary" );
break;
@@ -136,7 +136,7 @@ bool GetProcessFileName( uint32_t iProcessID, RString &sName )
else
{
pGetProcessImageFileName = (pfnGetProcessImageFileNameA) GetProcAddress( hPSApi, "GetProcessImageFileNameA" );
if( pGetProcessImageFileName == NULL )
if( pGetProcessImageFileName == nullptr )
{
sName = werr_ssprintf( GetLastError(), "GetProcAddress" );
break;
@@ -144,10 +144,10 @@ bool GetProcessFileName( uint32_t iProcessID, RString &sName )
}
}
if( pGetProcessImageFileName != NULL )
if( pGetProcessImageFileName != nullptr )
{
HANDLE hProc = OpenProcess( PROCESS_VM_READ|PROCESS_QUERY_INFORMATION, NULL, iProcessID );
if( hProc == NULL )
HANDLE hProc = OpenProcess( PROCESS_VM_READ|PROCESS_QUERY_INFORMATION, nullptr, iProcessID );
if( hProc == nullptr )
{
sName = werr_ssprintf( GetLastError(), "OpenProcess" );
break;
+3 -3
View File
@@ -25,7 +25,7 @@ static LONG GetRegKey( HKEY key, RString subkey, LPTSTR retdata )
bool GotoURL( RString sUrl )
{
// First try ShellExecute()
int iRet = (int) ShellExecute( NULL, "open", sUrl, NULL, NULL, SW_SHOWDEFAULT );
int iRet = (int) ShellExecute( nullptr, "open", sUrl, nullptr, nullptr, SW_SHOWDEFAULT );
// If it failed, get the .htm regkey and lookup the program
if( iRet > 32 )
@@ -41,11 +41,11 @@ bool GotoURL( RString sUrl )
return false;
char *szPos = strstr( key, "\"%1\"" );
if( szPos == NULL )
if( szPos == nullptr )
{
// No quotes found. Check for %1 without quotes
szPos = strstr( key, "%1" );
if( szPos == NULL )
if( szPos == nullptr )
szPos = key+lstrlen(key)-1; // No parameter.
else
*szPos = '\0'; // Remove the parameter
+51 -51
View File
@@ -23,7 +23,7 @@ static HDC g_HDC;
static VideoModeParams g_CurrentParams;
static bool g_bResolutionChanged = false;
static bool g_bHasFocus = true;
static HICON g_hIcon = NULL;
static HICON g_hIcon = nullptr;
static bool m_bWideWindowClass;
static bool g_bD3D = false;
@@ -36,8 +36,8 @@ static UINT g_iQueryCancelAutoPlayMessage = 0;
static RString GetNewWindow()
{
HWND h = GetForegroundWindow();
if( h == NULL )
return "(NULL)";
if( h == nullptr )
return "(nullptr)";
DWORD iProcessID;
GetWindowThreadProcessId( h, &iProcessID );
@@ -92,7 +92,7 @@ static LRESULT CALLBACK GraphicsWindow_WndProc( HWND hWnd, UINT msg, WPARAM wPar
}
else if( !g_bHasFocus && bHadFocus )
{
ChangeDisplaySettings( NULL, 0 );
ChangeDisplaySettings( nullptr, 0 );
}
}
@@ -111,7 +111,7 @@ static LRESULT CALLBACK GraphicsWindow_WndProc( HWND hWnd, UINT msg, WPARAM wPar
case WM_SETCURSOR:
if( !g_CurrentParams.windowed )
{
SetCursor( NULL );
SetCursor(nullptr);
return 1;
}
break;
@@ -190,7 +190,7 @@ static void AdjustVideoModeParams( VideoModeParams &p )
DEVMODE dm;
ZERO( dm );
dm.dmSize = sizeof(dm);
if( !EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dm) )
if( !EnumDisplaySettings(nullptr, ENUM_CURRENT_SETTINGS, &dm) )
{
p.rate = 60;
LOG->Warn( "%s", werr_ssprintf(GetLastError(), "EnumDisplaySettings failed").c_str() );
@@ -226,7 +226,7 @@ RString GraphicsWindow::SetScreenMode( const VideoModeParams &p )
if( p.windowed )
{
// We're going windowed. If we were previously fullscreen, reset.
ChangeDisplaySettings( NULL, 0 );
ChangeDisplaySettings( nullptr, 0 );
return RString();
}
@@ -244,7 +244,7 @@ RString GraphicsWindow::SetScreenMode( const VideoModeParams &p )
DevMode.dmDisplayFrequency = p.rate;
DevMode.dmFields |= DM_DISPLAYFREQUENCY;
}
ChangeDisplaySettings( NULL, 0 );
ChangeDisplaySettings( nullptr, 0 );
int ret = ChangeDisplaySettings( &DevMode, CDS_FULLSCREEN );
if( ret != DISP_CHANGE_SUCCESSFUL && (DevMode.dmFields & DM_DISPLAYFREQUENCY) )
@@ -278,20 +278,20 @@ void GraphicsWindow::CreateGraphicsWindow( const VideoModeParams &p, bool bForce
// Adjust g_CurrentParams to reflect the actual display settings.
AdjustVideoModeParams( g_CurrentParams );
if( g_hWndMain == NULL || bForceRecreateWindow )
if( g_hWndMain == nullptr || bForceRecreateWindow )
{
int iWindowStyle = GetWindowStyle( p.windowed );
AppInstance inst;
HWND hWnd = CreateWindow( g_sClassName, "app", iWindowStyle,
0, 0, 0, 0, NULL, NULL, inst, NULL );
if( hWnd == NULL )
0, 0, 0, 0, nullptr, nullptr, inst, nullptr );
if( hWnd == nullptr )
RageException::Throw( "%s", werr_ssprintf( GetLastError(), "CreateWindow" ).c_str() );
/* If an old window exists, transfer focus to the new window before
* deleting it, or some other window may temporarily get focus, which
* can cause it to be resized. */
if( g_hWndMain != NULL )
if( g_hWndMain != nullptr )
{
// While we change to the new window, don't do ChangeDisplaySettings in WM_ACTIVATE.
g_bRecreatingVideoMode = true;
@@ -319,14 +319,14 @@ void GraphicsWindow::CreateGraphicsWindow( const VideoModeParams &p, bool bForce
} while(0);
// Update the window icon.
if( g_hIcon != NULL )
if( g_hIcon != nullptr )
{
SetClassLong( g_hWndMain, GCL_HICON, (LONG) LoadIcon(NULL,IDI_APPLICATION) );
SetClassLong( g_hWndMain, GCL_HICON, (LONG) LoadIcon(nullptr,IDI_APPLICATION) );
DestroyIcon( g_hIcon );
g_hIcon = NULL;
g_hIcon = nullptr;
}
g_hIcon = IconFromFile( p.sIconFile );
if( g_hIcon != NULL )
if( g_hIcon != nullptr )
SetClassLong( g_hWndMain, GCL_HICON, (LONG) g_hIcon );
/* The window style may change as a result of switching to or from fullscreen;
@@ -364,9 +364,9 @@ void GraphicsWindow::CreateGraphicsWindow( const VideoModeParams &p, bool bForce
* If we don't do this, then starting up in a D3D fullscreen window may
* cause all other windows on the system to be resized. */
MSG msg;
while( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) )
while( PeekMessage( &msg, nullptr, 0, 0, PM_NOREMOVE ) )
{
GetMessage( &msg, NULL, 0, 0 );
GetMessage( &msg, nullptr, 0, 0 );
DispatchMessage( &msg );
}
}
@@ -374,36 +374,36 @@ void GraphicsWindow::CreateGraphicsWindow( const VideoModeParams &p, bool bForce
/** @brief Shut down the window, but don't reset the video mode. */
void GraphicsWindow::DestroyGraphicsWindow()
{
if( g_HDC != NULL )
if( g_HDC != nullptr )
{
ReleaseDC( g_hWndMain, g_HDC );
g_HDC = NULL;
g_HDC = nullptr;
}
CHECKPOINT;
if( g_hWndMain != NULL )
if( g_hWndMain != nullptr )
{
DestroyWindow( g_hWndMain );
g_hWndMain = NULL;
g_hWndMain = nullptr;
CrashHandler::SetForegroundWindow( g_hWndMain );
}
CHECKPOINT;
if( g_hIcon != NULL )
if( g_hIcon != nullptr )
{
DestroyIcon( g_hIcon );
g_hIcon = NULL;
g_hIcon = nullptr;
}
CHECKPOINT;
MSG msg;
while( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) )
while( PeekMessage( &msg, nullptr, 0, 0, PM_NOREMOVE ) )
{
CHECKPOINT;
GetMessage( &msg, NULL, 0, 0 );
GetMessage( &msg, nullptr, 0, 0 );
CHECKPOINT;
DispatchMessage( &msg );
}
@@ -423,10 +423,10 @@ void GraphicsWindow::Initialize( bool bD3D )
}
//if we have dwm, get function pointers to the dll functions
if( hInstanceDwmapi != NULL )
{
PFN_DwmFlush = (HRESULT (WINAPI *)(VOID))GetProcAddress( hInstanceDwmapi, "DwmFlush" );
PFN_DwmIsCompositionEnabled = (HRESULT (WINAPI *)(BOOL*))GetProcAddress( hInstanceDwmapi, "DwmIsCompositionEnabled" );
if( hInstanceDwmapi != nullptr )
{
PFN_DwmFlush = (HRESULT (WINAPI *)(VOID))GetProcAddress( hInstanceDwmapi, "DwmFlush" );
PFN_DwmIsCompositionEnabled = (HRESULT (WINAPI *)(BOOL*))GetProcAddress( hInstanceDwmapi, "DwmIsCompositionEnabled" );
}
AppInstance inst;
@@ -440,10 +440,10 @@ void GraphicsWindow::Initialize( bool bD3D )
0, /* cbClsExtra */
0, /* cbWndExtra */
inst, /* hInstance */
NULL, /* set icon later */
LoadCursor( NULL, IDC_ARROW ), /* default cursor */
NULL, /* hbrBackground */
NULL, /* lpszMenuName */
nullptr, /* set icon later */
LoadCursor( nullptr, IDC_ARROW ), /* default cursor */
nullptr, /* hbrBackground */
nullptr, /* lpszMenuName */
wsClassName.c_str() /* lpszClassName */
};
@@ -458,10 +458,10 @@ void GraphicsWindow::Initialize( bool bD3D )
0, /* cbClsExtra */
0, /* cbWndExtra */
inst, /* hInstance */
NULL, /* set icon later */
LoadCursor( NULL, IDC_ARROW ), /* default cursor */
NULL, /* hbrBackground */
NULL, /* lpszMenuName */
nullptr, /* set icon later */
LoadCursor( nullptr, IDC_ARROW ), /* default cursor */
nullptr, /* hbrBackground */
nullptr, /* lpszMenuName */
g_sClassName /* lpszClassName */
};
@@ -481,7 +481,7 @@ void GraphicsWindow::Shutdown()
* It'd be nice to not do this: Windows will do it when we quit, and if
* we're shutting down OpenGL to try D3D, this will cause extra mode
* switches. However, we need to do this before displaying dialogs. */
ChangeDisplaySettings( NULL, 0 );
ChangeDisplaySettings( nullptr, 0 );
AppInstance inst;
UnregisterClass( g_sClassName, inst );
@@ -489,7 +489,7 @@ void GraphicsWindow::Shutdown()
HDC GraphicsWindow::GetHDC()
{
ASSERT( g_HDC != NULL );
ASSERT( g_HDC != nullptr );
return g_HDC;
}
@@ -501,29 +501,29 @@ const VideoModeParams &GraphicsWindow::GetParams()
void GraphicsWindow::Update()
{
MSG msg;
while( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) )
while( PeekMessage( &msg, nullptr, 0, 0, PM_NOREMOVE ) )
{
GetMessage( &msg, NULL, 0, 0 );
GetMessage( &msg, nullptr, 0, 0 );
DispatchMessage( &msg );
}
HOOKS->SetHasFocus( g_bHasFocus );
if (g_CurrentParams.vsync)
{
//if we can use DWM
if( hInstanceDwmapi != NULL )
{
BOOL compositeEnabled = true;
PFN_DwmIsCompositionEnabled(&compositeEnabled);
if (compositeEnabled)
{
{
//if we can use DWM
if( hInstanceDwmapi != nullptr )
{
BOOL compositeEnabled = true;
PFN_DwmIsCompositionEnabled(&compositeEnabled);
if (compositeEnabled)
{
PFN_DwmFlush();
}
}
}
if( g_bResolutionChanged && DISPLAY != NULL )
if( g_bResolutionChanged && DISPLAY != nullptr )
{
//LOG->Warn( "Changing resolution" );
+1 -1
View File
@@ -37,7 +37,7 @@ namespace GraphicsWindow
HWND GetHwnd();
//dwm functions for vista+
static HINSTANCE hInstanceDwmapi = NULL;
static HINSTANCE hInstanceDwmapi = nullptr;
static HRESULT(WINAPI* PFN_DwmIsCompositionEnabled)(BOOL*);
static HRESULT (WINAPI* PFN_DwmFlush)(VOID);
};
+7 -7
View File
@@ -14,10 +14,10 @@ MessageWindow::MessageWindow( const RString &sClassName )
0, /* cbClsExtra */
0, /* cbWndExtra */
inst, /* hInstance */
NULL, /* set icon later */
LoadCursor( NULL, IDC_ARROW ), /* default cursor */
NULL, /* hbrBackground */
NULL, /* lpszMenuName */
nullptr, /* set icon later */
LoadCursor( nullptr, IDC_ARROW ), /* default cursor */
nullptr, /* hbrBackground */
nullptr, /* lpszMenuName */
sClassName /* lpszClassName */
};
@@ -25,8 +25,8 @@ MessageWindow::MessageWindow( const RString &sClassName )
RageException::Throw( "%s", werr_ssprintf( GetLastError(), "RegisterClass" ).c_str() );
// XXX: on 2k/XP, use HWND_MESSAGE as parent
m_hWnd = CreateWindow( sClassName, sClassName, WS_DISABLED, 0, 0, 0, 0, NULL, NULL, inst, NULL );
ASSERT( m_hWnd != NULL );
m_hWnd = CreateWindow( sClassName, sClassName, WS_DISABLED, 0, 0, 0, 0, nullptr, nullptr, inst, nullptr );
ASSERT( m_hWnd != nullptr );
SetProp( m_hWnd, "MessageWindow", this );
}
@@ -60,7 +60,7 @@ void MessageWindow::StopRunning()
LRESULT CALLBACK MessageWindow::WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
MessageWindow *pThis = (MessageWindow *) GetProp( hWnd, "MessageWindow" );
if( pThis != NULL && pThis->HandleMessage(msg, wParam, lParam) )
if( pThis != nullptr && pThis->HandleMessage(msg, wParam, lParam) )
return 0;
return DefWindowProc( hWnd, msg, wParam, lParam );
+14 -14
View File
@@ -36,14 +36,14 @@ static bool GetRegKeyType( const RString &sIn, RString &sOut, HKEY &key )
}
/* Given a full key, eg. "HKEY_LOCAL_MACHINE\hardware\foo", open it and return it.
* On error, return NULL. */
* On error, return nullptr. */
enum RegKeyMode { READ, WRITE };
static HKEY OpenRegKey( const RString &sKey, RegKeyMode mode, bool bWarnOnError = true )
{
RString sSubkey;
HKEY hType;
if( !GetRegKeyType(sKey, sSubkey, hType) )
return NULL;
return nullptr;
HKEY hRetKey;
LONG retval = RegOpenKeyEx( hType, sSubkey, 0, (mode==READ) ? KEY_READ:KEY_WRITE, &hRetKey );
@@ -51,7 +51,7 @@ static HKEY OpenRegKey( const RString &sKey, RegKeyMode mode, bool bWarnOnError
{
if( bWarnOnError )
LOG->Warn( werr_ssprintf(retval, "RegOpenKeyEx(%x,%s) error", hType, sSubkey.c_str()) );
return NULL;
return nullptr;
}
return hRetKey;
@@ -60,13 +60,13 @@ static HKEY OpenRegKey( const RString &sKey, RegKeyMode mode, bool bWarnOnError
bool RegistryAccess::GetRegValue( const RString &sKey, const RString &sName, RString &sVal )
{
HKEY hKey = OpenRegKey( sKey, READ );
if( hKey == NULL )
if( hKey == nullptr )
return false;
char sBuffer[MAX_PATH];
DWORD iSize = sizeof(sBuffer);
DWORD iType;
LONG iRet = RegQueryValueEx( hKey, sName, NULL, &iType, (LPBYTE)sBuffer, &iSize );
LONG iRet = RegQueryValueEx( hKey, sName, nullptr, &iType, (LPBYTE)sBuffer, &iSize );
RegCloseKey( hKey );
if( iRet != ERROR_SUCCESS )
return false;
@@ -86,13 +86,13 @@ bool RegistryAccess::GetRegValue( const RString &sKey, const RString &sName, RSt
bool RegistryAccess::GetRegValue( const RString &sKey, const RString &sName, int &iVal, bool bWarnOnError )
{
HKEY hKey = OpenRegKey( sKey, READ, bWarnOnError );
if( hKey == NULL )
if( hKey == nullptr )
return false;
DWORD iValue;
DWORD iSize = sizeof(iValue);
DWORD iType;
LONG iRet = RegQueryValueEx( hKey, sName, NULL, &iType, (LPBYTE) &iValue, &iSize );
LONG iRet = RegQueryValueEx( hKey, sName, nullptr, &iType, (LPBYTE) &iValue, &iSize );
RegCloseKey( hKey );
if( iRet != ERROR_SUCCESS )
return false;
@@ -115,7 +115,7 @@ bool RegistryAccess::GetRegValue( const RString &sKey, const RString &sName, boo
bool RegistryAccess::GetRegSubKeys( const RString &sKey, vector<RString> &lst, const RString &regex, bool bReturnPathToo )
{
HKEY hKey = OpenRegKey( sKey, READ );
if( hKey == NULL )
if( hKey == nullptr )
return false;
Regex re(regex);
@@ -126,7 +126,7 @@ bool RegistryAccess::GetRegSubKeys( const RString &sKey, vector<RString> &lst, c
FILETIME ft;
char szBuffer[MAX_PATH];
DWORD iSize = sizeof(szBuffer);
LONG iRet = RegEnumKeyEx( hKey, index, szBuffer, &iSize, NULL, NULL, NULL, &ft);
LONG iRet = RegEnumKeyEx( hKey, index, szBuffer, &iSize, nullptr, nullptr, nullptr, &ft);
if( iRet == ERROR_NO_MORE_ITEMS )
break;
@@ -155,7 +155,7 @@ bool RegistryAccess::GetRegSubKeys( const RString &sKey, vector<RString> &lst, c
bool RegistryAccess::SetRegValue( const RString &sKey, const RString &sName, const RString &sVal )
{
HKEY hKey = OpenRegKey( sKey, WRITE );
if( hKey == NULL )
if( hKey == nullptr )
return false;
bool bSuccess = true;
@@ -177,7 +177,7 @@ bool RegistryAccess::SetRegValue( const RString &sKey, const RString &sName, con
bool RegistryAccess::SetRegValue( const RString &sKey, const RString &sName, bool bVal )
{
HKEY hKey = OpenRegKey( sKey, WRITE );
if( hKey == NULL )
if( hKey == nullptr )
return false;
bool bSuccess = true;
@@ -196,7 +196,7 @@ bool RegistryAccess::CreateKey( const RString &sKey )
RString sSubkey;
HKEY hType;
if( !GetRegKeyType(sKey, sSubkey, hType) )
return NULL;
return nullptr;
HKEY hKey;
DWORD dwDisposition = 0;
@@ -204,10 +204,10 @@ bool RegistryAccess::CreateKey( const RString &sKey )
hType,
sSubkey,
0,
NULL,
nullptr,
REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS,
NULL,
nullptr,
&hKey,
&dwDisposition ) != ERROR_SUCCESS )
{
+6 -6
View File
@@ -5,21 +5,21 @@
void Win32RestartProgram()
{
TCHAR szFullAppPath[MAX_PATH];
GetModuleFileName(NULL, szFullAppPath, MAX_PATH);
GetModuleFileName(nullptr, szFullAppPath, MAX_PATH);
// Relaunch
PROCESS_INFORMATION pi;
STARTUPINFO si;
ZeroMemory( &si, sizeof(si) );
CreateProcess(
NULL, // pointer to name of executable module
nullptr, // pointer to name of executable module
szFullAppPath, // pointer to command line string
NULL, // process security attributes
NULL, // thread security attributes
nullptr, // process security attributes
nullptr, // thread security attributes
false, // handle inheritance flag
0, // creation flags
NULL, // pointer to new environment block
NULL, // pointer to current directory name
nullptr, // pointer to new environment block
nullptr, // pointer to current directory name
&si, // pointer to STARTUPINFO
&pi // pointer to PROCESS_INFORMATION
);
+1 -1
View File
@@ -6,7 +6,7 @@ static RString GetSpecialFolderPath( int csidl )
{
RString sDir;
TCHAR szDir[MAX_PATH] = "";
HRESULT hResult = SHGetFolderPath( NULL, csidl, NULL, SHGFP_TYPE_CURRENT, szDir );
HRESULT hResult = SHGetFolderPath( nullptr, csidl, nullptr, SHGFP_TYPE_CURRENT, szDir );
ASSERT( hResult == S_OK );
sDir = szDir;
sDir += "/";
+7 -7
View File
@@ -20,27 +20,27 @@ static RString GetUSBDevicePath( int iNum )
GUID guid;
HidD_GetHidGuid( &guid );
HDEVINFO DeviceInfo = SetupDiGetClassDevs( &guid, NULL, NULL, (DIGCF_PRESENT | DIGCF_DEVICEINTERFACE) );
HDEVINFO DeviceInfo = SetupDiGetClassDevs( &guid, nullptr, nullptr, (DIGCF_PRESENT | DIGCF_DEVICEINTERFACE) );
SP_DEVICE_INTERFACE_DATA DeviceInterface;
DeviceInterface.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
if( !SetupDiEnumDeviceInterfaces (DeviceInfo,
NULL, &guid, iNum, &DeviceInterface) )
nullptr, &guid, iNum, &DeviceInterface) )
{
SetupDiDestroyDeviceInfoList( DeviceInfo );
return RString();
}
unsigned long iSize;
SetupDiGetDeviceInterfaceDetail( DeviceInfo, &DeviceInterface, NULL, 0, &iSize, 0 );
SetupDiGetDeviceInterfaceDetail( DeviceInfo, &DeviceInterface, nullptr, 0, &iSize, 0 );
PSP_INTERFACE_DEVICE_DETAIL_DATA DeviceDetail = (PSP_INTERFACE_DEVICE_DETAIL_DATA) malloc( iSize );
DeviceDetail->cbSize = sizeof(SP_INTERFACE_DEVICE_DETAIL_DATA);
RString sRet;
if( SetupDiGetDeviceInterfaceDetail(DeviceInfo, &DeviceInterface,
DeviceDetail, iSize, &iSize, NULL) )
DeviceDetail, iSize, &iSize, nullptr) )
sRet = DeviceDetail->DevicePath;
free( DeviceDetail );
@@ -56,7 +56,7 @@ bool USBDevice::Open( int iVID, int iPID, int iBlockSize, int iNum, void (*pfnIn
while( (path = GetUSBDevicePath(iIndex++)) != "" )
{
HANDLE h = CreateFile( path, GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL );
FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, 0, nullptr );
if( h == INVALID_HANDLE_VALUE )
continue;
@@ -115,7 +115,7 @@ WindowsFileIO::WindowsFileIO()
{
ZeroMemory( &m_Overlapped, sizeof(m_Overlapped) );
m_Handle = INVALID_HANDLE_VALUE;
m_pBuffer = NULL;
m_pBuffer = nullptr;
}
WindowsFileIO::~WindowsFileIO()
@@ -138,7 +138,7 @@ bool WindowsFileIO::Open( RString path, int iBlockSize )
CloseHandle( m_Handle );
m_Handle = CreateFile( path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL );
nullptr, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, nullptr );
if( m_Handle == INVALID_HANDLE_VALUE )
return false;
+2 -2
View File
@@ -18,7 +18,7 @@ RString GetPrimaryVideoName()
// VC6 don't have a stub to static link with, so link dynamically.
EnumDisplayDevices = (pfnEnumDisplayDevices)GetProcAddress(hInstUser32,"EnumDisplayDevicesA");
if( EnumDisplayDevices == NULL )
if( EnumDisplayDevices == nullptr )
{
FreeLibrary(hInstUser32);
return RString();
@@ -30,7 +30,7 @@ RString GetPrimaryVideoName()
DISPLAY_DEVICE dd;
ZERO( dd );
dd.cb = sizeof(dd);
if( !EnumDisplayDevices(NULL, i, &dd, 0) )
if( !EnumDisplayDevices(nullptr, i, &dd, 0) )
break;
if( dd.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE )
{
+5 -5
View File
@@ -77,13 +77,13 @@ HICON IconFromSurface( const RageSurface *pSrcImg )
HICON icon = CreateIconFromResourceEx( (BYTE *) pBitmap, iSize + iSizeImage, TRUE, 0x00030000, pImg->w, pImg->h, LR_DEFAULTCOLOR );
delete pImg;
pImg = NULL;
pImg = nullptr;
free( pBitmap );
if( icon == NULL )
if( icon == nullptr )
{
LOG->Trace( "%s", werr_ssprintf( GetLastError(), "CreateIconFromResourceEx" ).c_str() );
return NULL;
return nullptr;
}
return icon;
@@ -93,10 +93,10 @@ HICON IconFromFile( const RString &sIconFile )
{
RString sError;
RageSurface *pImg = RageSurfaceUtils::LoadFile( sIconFile, sError );
if( pImg == NULL )
if( pImg == nullptr )
{
LOG->Warn( "Couldn't open icon \"%s\": %s", sIconFile.c_str(), sError.c_str() );
return NULL;
return nullptr;
}
HICON icon = IconFromSurface( pImg );
+5 -5
View File
@@ -3,16 +3,16 @@
WindowsDialogBox::WindowsDialogBox()
{
m_hWnd = NULL;
m_hWnd = nullptr;
}
void WindowsDialogBox::Run( int iDialog )
{
char szFullAppPath[MAX_PATH];
GetModuleFileName( NULL, szFullAppPath, MAX_PATH );
GetModuleFileName( nullptr, szFullAppPath, MAX_PATH );
HINSTANCE hHandle = LoadLibrary( szFullAppPath );
DialogBoxParam( hHandle, MAKEINTRESOURCE(iDialog), NULL, DlgProc, (LPARAM) this );
DialogBoxParam( hHandle, MAKEINTRESOURCE(iDialog), nullptr, DlgProc, (LPARAM) this );
}
BOOL APIENTRY WindowsDialogBox::DlgProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam )
@@ -21,10 +21,10 @@ BOOL APIENTRY WindowsDialogBox::DlgProc( HWND hDlg, UINT msg, WPARAM wParam, LPA
SetProp( hDlg, "WindowsDialogBox", (HANDLE) lParam );
WindowsDialogBox *pThis = (WindowsDialogBox *) GetProp( hDlg, "WindowsDialogBox" );
if( pThis == NULL )
if( pThis == nullptr )
return FALSE;
if( pThis->m_hWnd == NULL )
if( pThis->m_hWnd == nullptr )
pThis->m_hWnd = hDlg;
return pThis->HandleMessage( msg, wParam, lParam );
+1 -1
View File
@@ -36,7 +36,7 @@ char *strtack(char *s, const char *t, const char *s_max) {
++s, ++t;
if (s == s_max)
return NULL;
return nullptr;
return s+1;
}