From 4026d41c16fc1ae7cceefdb4d18ce960ad3f92d6 Mon Sep 17 00:00:00 2001 From: Prcuvu Date: Thu, 3 Oct 2019 09:33:27 +0800 Subject: [PATCH] More Windows API type inconsistency fix --- src/arch/Dialog/DialogDriver_Win32.cpp | 2 +- .../InputHandler/InputHandler_Win32_MIDI.cpp | 8 ++--- .../LoadingWindow/LoadingWindow_Win32.cpp | 2 +- src/archutils/Win32/Crash.cpp | 8 ++--- src/archutils/Win32/CrashHandlerChild.cpp | 34 +++++++++---------- src/archutils/Win32/GotoURL.cpp | 2 +- src/archutils/Win32/GraphicsWindow.cpp | 4 +-- src/archutils/Win32/WindowsDialogBox.h | 2 +- 8 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/arch/Dialog/DialogDriver_Win32.cpp b/src/arch/Dialog/DialogDriver_Win32.cpp index 95995e5f65..865bc712f7 100644 --- a/src/arch/Dialog/DialogDriver_Win32.cpp +++ b/src/arch/Dialog/DialogDriver_Win32.cpp @@ -208,7 +208,7 @@ static INT_PTR CALLBACK ErrorWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM } // TODO: Return a different brush if the default is not desired - return (BOOL)hbr; + return reinterpret_cast(hbr); } } return FALSE; diff --git a/src/arch/InputHandler/InputHandler_Win32_MIDI.cpp b/src/arch/InputHandler/InputHandler_Win32_MIDI.cpp index f2ee13fb82..75578a50d4 100644 --- a/src/arch/InputHandler/InputHandler_Win32_MIDI.cpp +++ b/src/arch/InputHandler/InputHandler_Win32_MIDI.cpp @@ -11,7 +11,7 @@ REGISTER_INPUT_HANDLER_CLASS2( MIDI, Win32_MIDI ); static HMIDIIN g_device; -static void CALLBACK midiCallback(HMIDIIN g_device, UINT status, DWORD instancePtr, DWORD data, DWORD timestamp); +static void CALLBACK midiCallback(HMIDIIN g_device, UINT status, DWORD_PTR instancePtr, DWORD_PTR data, DWORD_PTR timestamp); static RString GetMidiError( MMRESULT result ) { @@ -33,7 +33,7 @@ InputHandler_Win32_MIDI::InputHandler_Win32_MIDI() } m_bFoundDevice = true; - MMRESULT result = midiInOpen( &g_device, device_id, (DWORD) &midiCallback, (DWORD) this, CALLBACK_FUNCTION ); + MMRESULT result = midiInOpen( &g_device, device_id, reinterpret_cast(&midiCallback), reinterpret_cast(this), CALLBACK_FUNCTION ); if( result != MMSYSERR_NOERROR ) { LOG->Warn( "Error opening MIDI device: %s", GetMidiError(result).c_str() ); @@ -75,7 +75,7 @@ void InputHandler_Win32_MIDI::GetDevicesAndDescriptions( vector } } -static void CALLBACK midiCallback( HMIDIIN device, UINT status, DWORD instancePtr, DWORD data, DWORD timestamp ) +static void CALLBACK midiCallback( HMIDIIN device, UINT status, DWORD_PTR instancePtr, DWORD_PTR data, DWORD_PTR timestamp ) { if( status == MIM_DATA ) { @@ -91,7 +91,7 @@ static void CALLBACK midiCallback( HMIDIIN device, UINT status, DWORD instancePt { DeviceInput di = DeviceInput( DEVICE_MIDI, enum_add2(MIDI_FIRST, iChannel), iValue > 0 ); di.ts.Touch(); - ((InputHandler_Win32_MIDI *)instancePtr)->SetDev( di ); + (reinterpret_cast(instancePtr))->SetDev( di ); } } } diff --git a/src/arch/LoadingWindow/LoadingWindow_Win32.cpp b/src/arch/LoadingWindow/LoadingWindow_Win32.cpp index fdc40c0155..aac16e3225 100644 --- a/src/arch/LoadingWindow/LoadingWindow_Win32.cpp +++ b/src/arch/LoadingWindow/LoadingWindow_Win32.cpp @@ -118,7 +118,7 @@ void LoadingWindow_Win32::SetIcon( const RageSurface *pIcon ) m_hIcon = IconFromSurface( pIcon ); if( m_hIcon != nullptr ) - SetClassLongPtrA( hwnd, GCLP_HICON, (LONG) m_hIcon ); + SetClassLongPtrA( hwnd, GCLP_HICON, reinterpret_cast(m_hIcon) ); } void LoadingWindow_Win32::SetSplash( const RageSurface *pSplash ) diff --git a/src/archutils/Win32/Crash.cpp b/src/archutils/Win32/Crash.cpp index f8f11417fe..af77f2e6f1 100644 --- a/src/archutils/Win32/Crash.cpp +++ b/src/archutils/Win32/Crash.cpp @@ -501,7 +501,7 @@ void CrashHandler::do_backtrace( const void **buf, size_t size, return; } - const NT_TIB *tib = (NT_TIB *) ((sel.HighWord.Bits.BaseHi<<24)+(sel.HighWord.Bits.BaseMid<<16)+sel.BaseLow); + const NT_TIB *tib = reinterpret_cast(((static_cast(sel.HighWord.Bits.BaseHi) << 24) + (static_cast(sel.HighWord.Bits.BaseMid) << 16) + sel.BaseLow)); const NT_TIB *pTib = tib->Self; pStackBase = (char *)pTib->StackBase; } @@ -541,9 +541,9 @@ void CrashHandler::do_backtrace( const void **buf, size_t size, fValid = false; #if _WIN64 - if ( data != (void *) pContext->Rip && !PointsToValidCall((unsigned long)data) ) + if ( data != (void *) pContext->Rip && !PointsToValidCall(reinterpret_cast(data)) ) #else - if ( data != (void *) pContext->Eip && !PointsToValidCall((unsigned long)data) ) + if ( data != (void *) pContext->Eip && !PointsToValidCall(reinterpret_cast(data)) ) #endif fValid = false; } @@ -615,7 +615,7 @@ void CrashHandler::ForceDeadlock( RString reason, uint64_t iID ) context.ContextFlags = CONTEXT_FULL; if( !GetThreadContext( hThread, &context ) ) wsprintf( g_CrashInfo.m_CrashReason + strlen(g_CrashInfo.m_CrashReason), - "; GetThreadContext(%x) failed", (int) hThread ); + "; GetThreadContext(%Ix) failed", reinterpret_cast(hThread) ); else { static const void *BacktracePointers[BACKTRACE_MAX_SIZE]; diff --git a/src/archutils/Win32/CrashHandlerChild.cpp b/src/archutils/Win32/CrashHandlerChild.cpp index fe8d8f1bed..558f85356d 100644 --- a/src/archutils/Win32/CrashHandlerChild.cpp +++ b/src/archutils/Win32/CrashHandlerChild.cpp @@ -48,7 +48,7 @@ namespace VDDebugInfo int nBuildNumber; const unsigned char *pRVAHeap; - unsigned nFirstRVA; + uintptr_t nFirstRVA; const char *pFuncNameHeap; const unsigned long (*pSegments)[2]; @@ -176,7 +176,7 @@ namespace VDDebugInfo return heap; } - long VDDebugInfoLookupRVA( const Context *pctx, unsigned rva, char *buf, int buflen ) + uintptr_t VDDebugInfoLookupRVA( const Context *pctx, uintptr_t rva, char *buf, int buflen ) { if( !PointerIsInAnySegment(pctx, rva) ) return -1; @@ -357,12 +357,12 @@ namespace SymbolLookup VirtualQueryEx( g_hParent, ptr, &meminfo, sizeof meminfo ); char tmp[512]; - long iAddress = VDDebugInfo::VDDebugInfoLookupRVA(pctx, (unsigned int)ptr, tmp, sizeof(tmp)); + uintptr_t iAddress = VDDebugInfo::VDDebugInfoLookupRVA(pctx, reinterpret_cast(ptr), tmp, sizeof(tmp)); if( iAddress >= 0 ) { - wsprintf( buf, "%08x: %s [%08lx+%lx+%lx]", ptr, Demangle(tmp), - pctx->nFirstRVA, - ((unsigned int) ptr) - pctx->nFirstRVA - iAddress, + wsprintf( buf, "%p: %s [%p+%Ix+%Ix]", ptr, Demangle(tmp), + reinterpret_cast(pctx->nFirstRVA), + reinterpret_cast(ptr) - pctx->nFirstRVA - iAddress, iAddress ); return; } @@ -374,17 +374,17 @@ namespace SymbolLookup if( pSymbol ) { - wsprintf( buf, "%08lx: %s!%s [%08lx+%lx+%lx]", - (unsigned long) ptr, sName.c_str(), pSymbol->Name, - (unsigned long) meminfo.AllocationBase, - (unsigned long) (pSymbol->Address) - (unsigned long) (meminfo.AllocationBase), - (unsigned long) disp); + wsprintf( buf, "%p: %s!%s [%p+%Ix+%Ix]", + ptr, sName.c_str(), pSymbol->Name, + meminfo.AllocationBase, + reinterpret_cast(pSymbol->Address) - reinterpret_cast(meminfo.AllocationBase), + static_cast(disp)); return; } - wsprintf( buf, "%08lx: %s!%08lx", - (unsigned long) ptr, sName.c_str(), - (unsigned long) meminfo.AllocationBase ); + wsprintf( buf, "%p: %s!%p", + ptr, sName.c_str(), + meminfo.AllocationBase ); } } @@ -643,7 +643,7 @@ public: ~CrashDialog(); protected: - virtual BOOL HandleMessage( UINT msg, WPARAM wParam, LPARAM lParam ); + virtual INT_PTR HandleMessage( UINT msg, WPARAM wParam, LPARAM lParam ); private: void SetDialogInitial(); @@ -677,7 +677,7 @@ void CrashDialog::SetDialogInitial() ShowWindow( GetDlgItem(hDlg, IDC_BUTTON_AUTO_REPORT), true ); } -BOOL CrashDialog::HandleMessage( UINT msg, WPARAM wParam, LPARAM lParam ) +INT_PTR CrashDialog::HandleMessage( UINT msg, WPARAM wParam, LPARAM lParam ) { HWND hDlg = GetHwnd(); @@ -706,7 +706,7 @@ BOOL CrashDialog::HandleMessage( UINT msg, WPARAM wParam, LPARAM lParam ) } // TODO: Return a different brush if the default is not desired - return (BOOL)hbr; + return reinterpret_cast(hbr); } case WM_COMMAND: diff --git a/src/archutils/Win32/GotoURL.cpp b/src/archutils/Win32/GotoURL.cpp index 93092f0b12..1208d57824 100644 --- a/src/archutils/Win32/GotoURL.cpp +++ b/src/archutils/Win32/GotoURL.cpp @@ -25,7 +25,7 @@ static LONG GetRegKey( HKEY key, RString subkey, LPTSTR retdata ) bool GotoURL( RString sUrl ) { // First try ShellExecute() - int iRet = (int) ShellExecute( nullptr, "open", sUrl, nullptr, nullptr, SW_SHOWDEFAULT ); + intptr_t iRet = reinterpret_cast(ShellExecute( nullptr, "open", sUrl, nullptr, nullptr, SW_SHOWDEFAULT )); // If it failed, get the .htm regkey and lookup the program if( iRet > 32 ) diff --git a/src/archutils/Win32/GraphicsWindow.cpp b/src/archutils/Win32/GraphicsWindow.cpp index b370c8b0f6..8838171bec 100644 --- a/src/archutils/Win32/GraphicsWindow.cpp +++ b/src/archutils/Win32/GraphicsWindow.cpp @@ -321,13 +321,13 @@ void GraphicsWindow::CreateGraphicsWindow( const VideoModeParams &p, bool bForce // Update the window icon. if( g_hIcon != nullptr ) { - SetClassLongPtrA( g_hWndMain, GCLP_HICON, (LONG) LoadIcon(nullptr,IDI_APPLICATION) ); + SetClassLongPtrA( g_hWndMain, GCLP_HICON, reinterpret_cast(LoadIcon(nullptr,IDI_APPLICATION)) ); DestroyIcon( g_hIcon ); g_hIcon = nullptr; } g_hIcon = IconFromFile( p.sIconFile ); if( g_hIcon != nullptr ) - SetClassLongPtrA( g_hWndMain, GCLP_HICON, (LONG) g_hIcon ); + SetClassLongPtrA( g_hWndMain, GCLP_HICON, reinterpret_cast(g_hIcon) ); /* The window style may change as a result of switching to or from fullscreen; * apply it. Don't change the WS_VISIBLE bit. */ diff --git a/src/archutils/Win32/WindowsDialogBox.h b/src/archutils/Win32/WindowsDialogBox.h index d8cd860735..efa52cba32 100644 --- a/src/archutils/Win32/WindowsDialogBox.h +++ b/src/archutils/Win32/WindowsDialogBox.h @@ -15,7 +15,7 @@ public: HWND GetHwnd() { return m_hWnd; } protected: - virtual BOOL HandleMessage( UINT msg, WPARAM wParam, LPARAM lParam ) { return false; } + virtual INT_PTR HandleMessage( UINT msg, WPARAM wParam, LPARAM lParam ) { return false; } private: static INT_PTR APIENTRY DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);