registry access cleanup

log system drives and whether DMA is enabled (for skip diagnostics)
This commit is contained in:
Glenn Maynard
2004-04-25 03:49:05 +00:00
parent a2a7ae6e8e
commit 18167e013e
3 changed files with 125 additions and 57 deletions
+112 -1
View File
@@ -3,6 +3,7 @@
#include "RageLog.h"
#include "RageUtil.h"
#include "VideoDriverInfo.h"
#include "RegistryAccess.h"
#include "windows.h"
#include <mmsystem.h>
@@ -38,7 +39,7 @@ static void GetDisplayDriverDebugInfo()
VideoDriverInfo info;
if( !GetVideoDriverInfo(i, info) )
break;
if( sPrimaryDeviceName == "" ) // failed to get primary display name (NT4)
{
LogVideoDriverInfo( info );
@@ -80,6 +81,115 @@ static CString wo_ssprintf( MMRESULT err, const char *fmt, ...)
return s += ssprintf( "(%s)", buf );
}
static void GetDriveDebugInfo9x()
{
/*
* HKEY_LOCAL_MACHINE\Enum\ESDI
* *\ (disk id)
* *\ (eg. MF&CHILD0000&PCI&VEN_8086&DEV_7111&SUBSYS_197615AD&REV_01&BUS_00&DEV_07&FUNC_0100)
* DMACurrentlyUsed 0 or 1
* DeviceDesc "GENERIC IDE DISK TYPE01"
*/
vector<CString> Drives;
if( !GetRegSubKeys( "HKEY_LOCAL_MACHINE\\Enum\\ESDI", Drives ) )
return;
for( unsigned drive = 0; drive < Drives.size(); ++drive )
{
vector<CString> IDs;
if( !GetRegSubKeys( Drives[drive], IDs ) )
continue;
for( unsigned id = 0; id < IDs.size(); ++id )
{
CString DeviceDesc;
GetRegValue( IDs[id], "DeviceDesc", DeviceDesc );
TrimRight( DeviceDesc );
int DMACurrentlyUsed = -1;
GetRegValue( IDs[id], "DMACurrentlyUsed", DMACurrentlyUsed );
LOG->Info( "Drive: \"%s\" DMA: %s",
DeviceDesc.c_str(), DMACurrentlyUsed? "yes":"NO" );
}
}
}
static void GetDriveDebugInfoNT()
{
/*
* HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\Scsi\
* Scsi Port *\
* DMAEnabled 0 or 1
* Driver "Ultra", "atapi", etc
* Scsi Bus *\
* Target Id *\
* Logical Unit Id *\
* Identifier "WDC WD1200JB-75CRA0"
* Type "DiskPeripheral"
*/
vector<CString> Ports;
if( !GetRegSubKeys( "HKEY_LOCAL_MACHINE\\HARDWARE\\DEVICEMAP\\Scsi", Ports ) )
return;
for( unsigned i = 0; i < Ports.size(); ++i )
{
int DMAEnabled = -1;
GetRegValue( Ports[i], "DMAEnabled", DMAEnabled );
CString Driver;
GetRegValue( Ports[i], "Driver", Driver );
vector<CString> Busses;
if( !GetRegSubKeys( Ports[i], Busses, "Scsi Bus .*" ) )
continue;
for( unsigned bus = 0; bus < Busses.size(); ++bus )
{
vector<CString> TargetIDs;
if( !GetRegSubKeys( Busses[bus], TargetIDs, "Target Id .*" ) )
continue;
for( unsigned tid = 0; tid < TargetIDs.size(); ++tid )
{
vector<CString> LUIDs;
if( !GetRegSubKeys( TargetIDs[tid], LUIDs, "Logical Unit Id .*" ) )
continue;
for( unsigned luid = 0; luid < LUIDs.size(); ++luid )
{
CString Identifier;
GetRegValue( LUIDs[luid], "Identifier", Identifier );
TrimRight( Identifier );
LOG->Info( "Drive: \"%s\" Driver: %s DMA: %s",
Identifier.c_str(), Driver.c_str(), DMAEnabled == 1? "yes":DMAEnabled == -1? "N/A":"NO" );
}
}
}
}
}
static void GetDriveDebugInfo()
{
OSVERSIONINFO ovi;
ovi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
if( !GetVersionEx(&ovi) )
{
LOG->Info("GetVersionEx failed!");
return;
}
switch( ovi.dwPlatformId )
{
case VER_PLATFORM_WIN32_WINDOWS:
GetDriveDebugInfo9x(); break;
case VER_PLATFORM_WIN32_NT:
GetDriveDebugInfoNT(); break;
}
}
static void GetWindowsVersionDebugInfo()
{
/* Detect operating system. */
@@ -147,6 +257,7 @@ void SearchForDebugInfo()
GetWindowsVersionDebugInfo();
GetMemoryDebugInfo();
GetDisplayDriverDebugInfo();
GetDriveDebugInfo();
GetSoundDriverDebugInfo();
}
+3 -1
View File
@@ -3,7 +3,9 @@
#include "windows.h"
#include "shellapi.h"
LONG GetRegKey(HKEY key, CString subkey, LPTSTR retdata)
/* This is called from the crash handler; don't use RegistryAccess, since it's
* not crash-conditions safe. */
static LONG GetRegKey(HKEY key, CString subkey, LPTSTR retdata)
{
HKEY hkey;
LONG retval = RegOpenKeyEx(key, subkey, 0, KEY_QUERY_VALUE, &hkey);
@@ -3,39 +3,7 @@
#include "RageUtil.h"
#include "RageLog.h"
#include "windows.h"
static void GetRegSubKeys( HKEY hKey, vector<CString> &lst )
{
char szBuffer[MAX_PATH];
FILETIME ft;
for( int index = 0; ; ++index )
{
DWORD nSize = sizeof(szBuffer)-1;
LONG ret = RegEnumKeyEx( hKey, index, szBuffer, &nSize, NULL, NULL, NULL, &ft);
if( ret == ERROR_NO_MORE_ITEMS )
return;
if( ret != ERROR_SUCCESS && ret != ERROR_MORE_DATA )
{
LOG->Warn( werr_ssprintf(ret, "GetRegSubKeys(%p,%i) error", hKey, index) );
return;
}
lst.push_back( szBuffer );
}
}
static CString GetRegValue( HKEY hKey, CString sName )
{
char szBuffer[MAX_PATH];
DWORD nSize = sizeof(szBuffer)-1;
if( RegQueryValueEx(hKey, sName, NULL, NULL, (LPBYTE)szBuffer, &nSize) == ERROR_SUCCESS )
return szBuffer;
else
return "";
}
#include "RegistryAccess.h"
// this will not work on 95 and NT b/c of EnumDisplayDevices
CString GetPrimaryVideoName()
@@ -105,19 +73,10 @@ bool GetVideoDriverInfo(int cardno, VideoDriverInfo &info)
Initialized = true;
const CString TopKey = bIsWin9x?
"SYSTEM\\CurrentControlSet\\Services\\Class\\Display":
"SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E968-E325-11CE-BFC1-08002BE10318}";
"HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\Class\\Display":
"HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E968-E325-11CE-BFC1-08002BE10318}";
HKEY hkey;
int ret = RegOpenKey(HKEY_LOCAL_MACHINE, TopKey, &hkey);
if ( ret != ERROR_SUCCESS )
{
LOG->Warn( werr_ssprintf(ret, "RegOpenKey(%s) error", TopKey.c_str()) );
return false;
}
GetRegSubKeys( hkey, lst );
RegCloseKey( hkey );
GetRegSubKeys( TopKey, lst, ".*", false );
for( int i = lst.size()-1; i >= 0; --i )
{
@@ -141,23 +100,19 @@ bool GetVideoDriverInfo(int cardno, VideoDriverInfo &info)
while( cardno < (int)lst.size() )
{
const CString sKey = lst[cardno];
HKEY hkey;
int ret = RegOpenKey(HKEY_LOCAL_MACHINE, sKey, &hkey);
if ( ret != ERROR_SUCCESS )
if( !GetRegValue( sKey, "DriverDesc", info.sDescription ) )
{
/* Remove this one from the list and ignore it, */
LOG->Warn( werr_ssprintf(ret, "RegOpenKey(%s) error", sKey.c_str()) );
lst.erase( lst.begin()+cardno );
continue;
}
info.sDate = GetRegValue( hkey, "DriverDate");
info.sDescription = GetRegValue( hkey, "DriverDesc");
info.sDeviceID = GetRegValue( hkey, "MatchingDeviceId");
info.sProvider = GetRegValue( hkey, "ProviderName");
info.sVersion = GetRegValue( hkey, bIsWin9x? "Ver":"DriverVersion");
GetRegValue( sKey, "DriverDate", info.sDate );
GetRegValue( sKey, "MatchingDeviceId", info.sDeviceID );
GetRegValue( sKey, "ProviderName", info.sProvider );
GetRegValue( sKey, bIsWin9x? "Ver":"DriverVersion", info.sVersion );
RegCloseKey(hkey);
return true;
}