Skip to content

Commit

Permalink
HardwareDevices: Fix incorrect drive letters; Added incomplete detail…
Browse files Browse the repository at this point in the history
…s window;
  • Loading branch information
dmex committed Feb 29, 2016
1 parent d01d02e commit cae14cf
Show file tree
Hide file tree
Showing 11 changed files with 1,284 additions and 297 deletions.
71 changes: 56 additions & 15 deletions plugins/HardwareDevices/HardwareDevices.rc
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_AUS
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,3,0,0
PRODUCTVERSION 1,3,0,0
FILEVERSION 1,4,0,0
PRODUCTVERSION 1,4,0,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -42,12 +42,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "dmex"
VALUE "FileDescription", "Hardware Devices plugin for Process Hacker"
VALUE "FileVersion", "1.3"
VALUE "FileVersion", "1.4"
VALUE "InternalName", "HardwareDevices"
VALUE "LegalCopyright", "Licensed under the GNU GPL, v3."
VALUE "OriginalFilename", "HardwareDevices.dll"
VALUE "ProductName", "Hardware Devices plugin for Process Hacker"
VALUE "ProductVersion", "1.3"
VALUE "ProductVersion", "1.4"
END
END
BLOCK "VarFileInfo"
Expand Down Expand Up @@ -149,7 +149,7 @@ CAPTION "Dialog"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
LTEXT "",IDC_GRAPH_LAYOUT,0,21,314,60,NOT WS_VISIBLE | WS_BORDER
LTEXT "Disk",IDC_ADAPTERNAME,0,0,105,21
LTEXT "Disk",IDC_DISKMOUNTPATH,0,0,105,21
LTEXT "Panel layout",IDC_LAYOUT,0,98,268,36,NOT WS_VISIBLE
RTEXT "Disk name",IDC_DISKNAME,107,4,207,16,SS_WORDELLIPSIS
END
Expand All @@ -175,16 +175,31 @@ BEGIN
RTEXT "Static",IDC_STAT_QUEUELENGTH,65,33,62,8,SS_ENDELLIPSIS
END

IDD_DISKDRIVE_DETAILS DIALOGEX 0, 0, 309, 265
STYLE DS_SETFONT | DS_FIXEDSYS | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
CAPTION "Disk Details"
IDD_DISKDRIVE_DETAILS_SMART DIALOGEX 0, 0, 309, 265
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "SMART"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
CONTROL "",IDC_DETAILS_LIST,"SysListView32",LVS_REPORT | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,7,7,295,182
EDITTEXT IDC_EDIT1,7,200,295,58,ES_MULTILINE | ES_READONLY | WS_VSCROLL
LTEXT "Description:",IDC_DESCRIPTION,7,190,39,8
END

IDD_DISKDRIVE_DETAILS_FILESYSTEM DIALOGEX 0, 0, 309, 265
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "File System"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
CONTROL "",IDC_DETAILS_LIST,"SysListView32",LVS_REPORT | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,7,7,295,182
EDITTEXT IDC_EDIT1,7,200,295,58,ES_MULTILINE | ES_READONLY | WS_VSCROLL
LTEXT "Description:",IDC_DESCRIPTION,7,190,39,8
END

IDD_DISKDRIVE_DETAILS_GENERAL DIALOGEX 0, 0, 275, 262
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Dialog"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
PUSHBUTTON "Close",IDOK,253,244,50,14
CONTROL "",IDC_DETAILS_LIST,"SysListView32",LVS_REPORT | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,7,7,295,164
EDITTEXT IDC_EDIT1,7,183,295,58,ES_MULTILINE | ES_READONLY | WS_VSCROLL
LTEXT "Warning: Values might be incorrect.",IDC_WARN,7,250,115,8
LTEXT "Description:",IDC_DESCRIPTION,7,173,39,8
END


Expand Down Expand Up @@ -242,13 +257,29 @@ BEGIN
BOTTOMMARGIN, 49
END

IDD_DISKDRIVE_DETAILS, DIALOG
IDD_DISKDRIVE_DETAILS_SMART, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 302
TOPMARGIN, 7
BOTTOMMARGIN, 258
END

IDD_DISKDRIVE_DETAILS_FILESYSTEM, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 302
TOPMARGIN, 7
BOTTOMMARGIN, 258
END

IDD_DISKDRIVE_DETAILS_GENERAL, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 268
TOPMARGIN, 7
BOTTOMMARGIN, 255
END
END
#endif // APSTUDIO_INVOKED

Expand Down Expand Up @@ -293,7 +324,17 @@ BEGIN
0
END

IDD_DISKDRIVE_DETAILS AFX_DIALOG_LAYOUT
IDD_DISKDRIVE_DETAILS_SMART AFX_DIALOG_LAYOUT
BEGIN
0
END

IDD_DISKDRIVE_DETAILS_FILESYSTEM AFX_DIALOG_LAYOUT
BEGIN
0
END

IDD_DISKDRIVE_DETAILS_GENERAL AFX_DIALOG_LAYOUT
BEGIN
0
END
Expand Down
5 changes: 1 addition & 4 deletions plugins/HardwareDevices/adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,7 @@ VOID NetAdaptersUpdate(

if (PhGetIntegerSetting(SETTING_NAME_ENABLE_NDIS))
{
if (NT_SUCCESS(NetworkAdapterCreateHandle(
&deviceHandle,
entry->Id.InterfaceGuid
)))
if (NT_SUCCESS(NetworkAdapterCreateHandle(&deviceHandle, entry->Id.InterfaceGuid)))
{
if (!entry->CheckedDeviceSupport)
{
Expand Down
64 changes: 51 additions & 13 deletions plugins/HardwareDevices/devices.h
Original file line number Diff line number Diff line change
Expand Up @@ -438,19 +438,6 @@ typedef struct _DV_DISK_SYSINFO_CONTEXT
PH_LAYOUT_MANAGER LayoutManager;
} DV_DISK_SYSINFO_CONTEXT, *PDV_DISK_SYSINFO_CONTEXT;

typedef struct _DV_DISK_DETAILS_CONTEXT
{
PPH_STRING DiskName;
DV_DISK_ID DiskId;

HWND WindowHandle;
HWND ParentHandle;
HWND ListViewHandle;

PH_LAYOUT_MANAGER LayoutManager;
PH_CALLBACK_REGISTRATION ProcessesUpdatedRegistration;
} DV_DISK_DETAILS_CONTEXT, *PDV_DISK_DETAILS_CONTEXT;

typedef struct _DV_DISK_OPTIONS_CONTEXT
{
HWND ListViewHandle;
Expand All @@ -463,6 +450,11 @@ VOID DiskDrivesInitialize(VOID);
VOID DiskDrivesLoadList(VOID);
VOID DiskDrivesUpdate(VOID);

VOID DiskDriveUpdateDeviceInfo(
_In_opt_ HANDLE DeviceHandle,
_In_ PDV_DISK_ENTRY DiskEntry
);

VOID InitializeDiskId(
_Out_ PDV_DISK_ID Id,
_In_ PPH_STRING DevicePath
Expand Down Expand Up @@ -527,6 +519,52 @@ BOOLEAN DiskDriveQueryImminentFailure(
_Out_ PPH_LIST* DiskSmartAttributes
);

typedef struct _DISK_HANDLE_ENTRY
{
WCHAR DeviceLetter;
HANDLE DeviceHandle;
} DISK_HANDLE_ENTRY, *PDISK_HANDLE_ENTRY;

PPH_LIST DiskDriveQueryMountPointHandles(
_In_ ULONG DeviceNumber
);

typedef struct _NTFS_FILESYSTEM_STATISTICS
{
FILESYSTEM_STATISTICS FileSystemStatistics;
NTFS_STATISTICS NtfsStatistics;
} NTFS_FILESYSTEM_STATISTICS, *PNTFS_FILESYSTEM_STATISTICS;

typedef struct _FAT_FILESYSTEM_STATISTICS
{
FILESYSTEM_STATISTICS FileSystemStatistics;
NTFS_STATISTICS FatStatistics;
} FAT_FILESYSTEM_STATISTICS, *PFAT_FILESYSTEM_STATISTICS;

typedef struct _EXFAT_FILESYSTEM_STATISTICS
{
FILESYSTEM_STATISTICS FileSystemStatistics;
EXFAT_STATISTICS ExFatStatistics;
} EXFAT_FILESYSTEM_STATISTICS, *PEXFAT_FILESYSTEM_STATISTICS;

BOOLEAN DiskDriveQueryFileSystemInfo(
_In_ HANDLE DeviceHandle,
_Out_ USHORT* FileSystemType,
_Out_ PVOID* FileSystemStatistics
);


typedef struct _NTFS_VOLUME_INFO
{
NTFS_VOLUME_DATA_BUFFER VolumeData;
NTFS_EXTENDED_VOLUME_DATA ExtendedVolumeData;
} NTFS_VOLUME_INFO, *PNTFS_VOLUME_INFO;

BOOLEAN DiskDriveQueryNtfsVolumeInfo(
_In_ HANDLE DeviceHandle,
_Out_ PNTFS_VOLUME_INFO VolumeInfo
);

typedef enum _SMART_ATTRIBUTE_ID
{
SMART_ATTRIBUTE_ID_READ_ERROR_RATE = 0x01,
Expand Down
85 changes: 59 additions & 26 deletions plugins/HardwareDevices/disk.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ VOID DiskDrivesUpdate(

entry->QueueDepth = diskPerformance.QueueDepth;
entry->SplitCount = diskPerformance.SplitCount;
entry->DiskIndex = diskPerformance.StorageDeviceNumber;
entry->DevicePresent = TRUE;
}
else
Expand All @@ -131,37 +132,20 @@ VOID DiskDrivesUpdate(
entry->ActiveTime = 0.0f;
entry->QueueDepth = 0;
entry->SplitCount = 0;
entry->DiskIndex = ULONG_MAX;
entry->DevicePresent = FALSE;
}

// Delay the query for the disk name, index and type from startup to later at runtime.
// Note: If the user opens the Sysinfo window before this has fired,
// we have a second check in the UpdateDiskIndexText function that queries this information.
if (runCount > 1)
{
if (
!entry->DiskName ||
entry->DiskIndex == ULONG_MAX ||
entry->DiskType == 0
)
{
if (!entry->DiskName)
{
DiskDriveQueryDeviceInformation(deviceHandle, NULL, &entry->DiskName, NULL, NULL);
}

if (entry->DiskIndex == ULONG_MAX || entry->DiskType == 0)
{
ULONG diskIndex = ULONG_MAX; // Note: Do not initialize to zero.
DEVICE_TYPE diskType = 0;

if (NT_SUCCESS(DiskDriveQueryDeviceTypeAndNumber(deviceHandle, &diskIndex, &diskType)))
{
entry->DiskIndex = diskIndex;
entry->DiskType = diskType;
}
}
}
// Delay the first query for the disk name, index and type.
// 1) This information is not needed until the user opens the sysinfo window.
// 2) Try not to query this information while opening the sysinfo window (e.g. delay).
// 3) Try not to query this information during startup (e.g. delay).
//
// Note: If the user opens the Sysinfo window before we query the disk info,
// we have a second check in diskgraph.c that queries the information on demand.
DiskDriveUpdateDeviceInfo(deviceHandle, entry);
}

NtClose(deviceHandle);
Expand Down Expand Up @@ -213,6 +197,55 @@ VOID DiskDrivesUpdate(
runCount++;
}

VOID DiskDriveUpdateDeviceInfo(
_In_opt_ HANDLE DeviceHandle,
_In_ PDV_DISK_ENTRY DiskEntry
)
{
if (
!DiskEntry->DiskName ||
DiskEntry->DiskIndex == ULONG_MAX ||
DiskEntry->DiskType == 0
)
{
HANDLE deviceHandle = NULL;

if (!DeviceHandle)
{
DiskDriveCreateHandle(&deviceHandle, DiskEntry->Id.DevicePath);
}
else
{
deviceHandle = DeviceHandle;
}

if (deviceHandle)
{
if (!DiskEntry->DiskName)
{
DiskDriveQueryDeviceInformation(deviceHandle, NULL, &DiskEntry->DiskName, NULL, NULL);
}

if (DiskEntry->DiskIndex == ULONG_MAX || DiskEntry->DiskType == 0)
{
ULONG diskIndex = ULONG_MAX; // Note: Do not initialize to zero.
DEVICE_TYPE diskType = 0;

if (NT_SUCCESS(DiskDriveQueryDeviceTypeAndNumber(deviceHandle, &diskIndex, &diskType)))
{
DiskEntry->DiskIndex = diskIndex;
DiskEntry->DiskType = diskType;
}
}

if (!DeviceHandle)
{
NtClose(deviceHandle);
}
}
}
}

VOID InitializeDiskId(
_Out_ PDV_DISK_ID Id,
_In_ PPH_STRING DevicePath
Expand Down
Loading

0 comments on commit cae14cf

Please sign in to comment.