From 04a41cbd6bc7694b198867fb5f8e4e226394014c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 17 Dec 2023 21:49:54 +0800 Subject: [PATCH] DiskIO (Windows): don't use registry --- src/detection/diskio/diskio_windows.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/detection/diskio/diskio_windows.c b/src/detection/diskio/diskio_windows.c index 99149e948..a0c18ffad 100644 --- a/src/detection/diskio/diskio_windows.c +++ b/src/detection/diskio/diskio_windows.c @@ -7,23 +7,15 @@ const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options) { - FF_HKEY_AUTO_DESTROY hKey = NULL; - if (!ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Services\\disk\\Enum", &hKey, NULL)) - return "ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L\"SYSTEM\\CurrentControlSet\\Services\\disk\\Enum\") failed"; - - uint32_t nDevices; - if (!ffRegReadUint(hKey, L"Count", &nDevices, NULL)) - return "ffRegReadUint(hKey, L\"Count\", &nDevices) failed"; - wchar_t szDevice[32] = L"\\\\.\\PhysicalDrive"; wchar_t* pNum = szDevice + strlen("\\\\.\\PhysicalDrive"); - for (uint32_t idev = 0; idev <= nDevices; ++idev) + for (uint32_t idev = 0; ; ++idev) { _ultow(idev, pNum, 10); FF_AUTO_CLOSE_FD HANDLE hDevice = CreateFileW(szDevice, FILE_READ_ATTRIBUTES, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); if (hDevice == INVALID_HANDLE_VALUE) - continue; + break; DWORD retSize; char sddBuffer[4096];