Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Working with a mounted flash drive #270

Merged
merged 5 commits into from
Mar 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 36 additions & 4 deletions al-khaser/AntiVM/Generic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,33 @@ BOOL number_cores_wmi()
return bFound;
}

/*
Filter for removable disk, CD-ROM, network drive or RAM disk
*/
BOOL checkDriveType(IWbemClassObject* pclsObj)
{
if (!pclsObj)
return FALSE;

BOOL res = FALSE;
VARIANT vtDriveType;
HRESULT hResDriveType;

hResDriveType = pclsObj->Get(_T("DriveType"), 0, &vtDriveType, NULL, 0);
if (SUCCEEDED(hResDriveType) && V_VT(&vtDriveType) != VT_NULL)
{
if (vtDriveType.uintVal == 2 // removable disk (USB)
|| vtDriveType.uintVal == 4 // network drive
|| vtDriveType.uintVal == 5 // CD-ROM
|| vtDriveType.uintVal == 6 // RAM disk
)
{
res = TRUE;
}
VariantClear(&vtDriveType);
}
return res;
}

/*
Check hard disk size using WMI
Expand Down Expand Up @@ -545,7 +572,13 @@ BOOL disk_size_wmi()
hRes = pEnumerator->Next(WBEM_INFINITE, 1, &pclsObj, &uReturn);
if (0 == uReturn)
break;


// Don`t check removable disk, network drive CD-ROM and RAM disk
if (checkDriveType(pclsObj)) {
pclsObj->Release();
continue;
}

// Get the value of the Name property
hRes = pclsObj->Get(_T("Size"), 0, &vtProp, NULL, 0);
if (SUCCEEDED(hRes)) {
Expand All @@ -561,8 +594,7 @@ BOOL disk_size_wmi()
if (diskSizeBytes < minHardDiskSize) { // Less than 80GB
bFound = TRUE;
}
}

}
// release the current result object
VariantClear(&vtProp);
}
Expand Down Expand Up @@ -2011,4 +2043,4 @@ BOOL number_SMBIOS_tables()
free(smbios);
}
return result;
}
}
Loading