@@ -671,11 +671,29 @@ bool CVideoModeManager::GetRequiredDisplayResolution(int& iOutWidth, int& iOutHe
671671// /////////////////////////////////////////////////////////////
672672bool CVideoModeManager::GetCurrentAdapterRect (LPRECT pOutRect)
673673{
674- MONITORINFOEX monitorInfo;
674+ if (!pOutRect)
675+ return false ;
676+
677+ // Initialize to safe defaults
678+ pOutRect->left = 0 ;
679+ pOutRect->top = 0 ;
680+ pOutRect->right = 1024 ;
681+ pOutRect->bottom = 768 ;
682+
683+ if (!m_hCurrentMonitor)
684+ return false ;
685+
686+ MONITORINFOEX monitorInfo{};
675687 monitorInfo.cbSize = sizeof (MONITORINFOEX);
676- BOOL bResult = GetMonitorInfo (m_hCurrentMonitor, &monitorInfo);
677- *pOutRect = monitorInfo.rcMonitor ;
678- return bResult != 0 ;
688+
689+ BOOL bResult = GetMonitorInfoA (m_hCurrentMonitor, &monitorInfo);
690+ if (bResult)
691+ {
692+ *pOutRect = monitorInfo.rcMonitor ;
693+ return true ;
694+ }
695+
696+ return false ;
679697}
680698
681699// /////////////////////////////////////////////////////////////
@@ -687,9 +705,18 @@ bool CVideoModeManager::GetCurrentAdapterRect(LPRECT pOutRect)
687705// /////////////////////////////////////////////////////////////
688706SString CVideoModeManager::GetCurrentAdapterDeviceName ()
689707{
690- MONITORINFOEX monitorInfo;
708+ if (!m_hCurrentMonitor)
709+ return " " ;
710+
711+ MONITORINFOEX monitorInfo{};
691712 monitorInfo.cbSize = sizeof (MONITORINFOEX);
692- if (GetMonitorInfo (m_hCurrentMonitor, &monitorInfo))
693- return monitorInfo.szDevice ;
713+
714+ if (GetMonitorInfoA (m_hCurrentMonitor, &monitorInfo))
715+ {
716+ // Ensure null termination for x86 safety
717+ monitorInfo.szDevice [sizeof (monitorInfo.szDevice ) - 1 ] = ' \0 ' ;
718+ return std::string (monitorInfo.szDevice );
719+ }
720+
694721 return " " ;
695722}
0 commit comments