More Windows API type inconsistency fix

This commit is contained in:
Prcuvu
2019-10-03 09:33:27 +08:00
parent 54c067f48d
commit 4026d41c16
8 changed files with 31 additions and 31 deletions
+1 -1
View File
@@ -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<INT_PTR>(hbr);
}
}
return FALSE;
@@ -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<DWORD_PTR>(&midiCallback), reinterpret_cast<DWORD_PTR>(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<InputDeviceInfo>
}
}
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<InputHandler_Win32_MIDI*>(instancePtr))->SetDev( di );
}
}
}
@@ -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<LONG_PTR>(m_hIcon) );
}
void LoadingWindow_Win32::SetSplash( const RageSurface *pSplash )
+4 -4
View File
@@ -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<NT_TIB *>(((static_cast<DWORD_PTR>(sel.HighWord.Bits.BaseHi) << 24) + (static_cast<DWORD_PTR>(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<ULONG_PTR>(data)) )
#else
if ( data != (void *) pContext->Eip && !PointsToValidCall((unsigned long)data) )
if ( data != (void *) pContext->Eip && !PointsToValidCall(reinterpret_cast<ULONG_PTR>(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<uintptr_t>(hThread) );
else
{
static const void *BacktracePointers[BACKTRACE_MAX_SIZE];
+17 -17
View File
@@ -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<uintptr_t>(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<void *>(pctx->nFirstRVA),
reinterpret_cast<uintptr_t>(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<uintptr_t>(pSymbol->Address) - reinterpret_cast<uintptr_t>(meminfo.AllocationBase),
static_cast<ULONG_PTR>(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<INT_PTR>(hbr);
}
case WM_COMMAND:
+1 -1
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( nullptr, "open", sUrl, nullptr, nullptr, SW_SHOWDEFAULT );
intptr_t iRet = reinterpret_cast<intptr_t>(ShellExecute( nullptr, "open", sUrl, nullptr, nullptr, SW_SHOWDEFAULT ));
// If it failed, get the .htm regkey and lookup the program
if( iRet > 32 )
+2 -2
View File
@@ -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<LONG_PTR>(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<LONG_PTR>(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. */
+1 -1
View File
@@ -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);