MCPcopy Create free account
hub / github.com/Zalafina/QKeyMapper / isInterceptionDriverFileExist

Method isInterceptionDriverFileExist

QKeyMapper/interception_worker.cpp:307–365  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

305}
306
307bool Interception_Worker::isInterceptionDriverFileExist()
308{
309 wchar_t system32Path[MAX_PATH];
310 UINT result = GetSystemDirectory(system32Path, MAX_PATH);
311 if (result == 0)
312 {
313 return false;
314 }
315
316 QString driverFilePath = QString::fromWCharArray(system32Path) + QString("\\drivers\\keyboard.sys");
317 DWORD dummy;
318 DWORD size = GetFileVersionInfoSize((LPCWSTR)driverFilePath.utf16(), &dummy);
319 if (size == 0) {
320 return false;
321 }
322
323 QByteArray data(size, 0);
324 if (!GetFileVersionInfo((LPCWSTR)driverFilePath.utf16(), 0, size, data.data())) {
325 return false;
326 }
327
328 void *value = nullptr;
329 UINT length;
330 QString fileDescription;
331 QString productName;
332 QString originalFilename;
333 if (!VerQueryValue(data.data(), L"\\StringFileInfo\\040904b0\\FileDescription", &value, &length)) {
334 return false;
335 }
336 fileDescription = QString::fromUtf16(reinterpret_cast<Utf16Pointer>(value), length);
337 fileDescription.remove(QChar('\0'));
338 if (!VerQueryValue(data.data(), L"\\StringFileInfo\\040904b0\\ProductName", &value, &length)) {
339 return false;
340 }
341 productName = QString::fromUtf16(reinterpret_cast<Utf16Pointer>(value), length);
342 productName.remove(QChar('\0'));
343 if (!VerQueryValue(data.data(), L"\\StringFileInfo\\040904b0\\OriginalFilename", &value, &length)) {
344 return false;
345 }
346 originalFilename = QString::fromUtf16(reinterpret_cast<Utf16Pointer>(value), length);
347 originalFilename.remove(QChar('\0'));
348
349#ifdef DEBUG_LOGOUT_ON
350 qDebug() << "[isInterceptionDriverFileExist]" << "FileDescription:" << fileDescription;
351 qDebug() << "[isInterceptionDriverFileExist]" << "ProductName:" << productName;
352 qDebug() << "[isInterceptionDriverFileExist]" << "originalFilename:" << originalFilename;
353#endif
354
355 if (fileDescription == "Keyboard Upper Filter Driver"
356 && productName == "Interception"
357 && originalFilename == "keyboard.sys") {
358#ifdef DEBUG_LOGOUT_ON
359 qDebug() << "[isInterceptionDriverFileExist]" << "Interception driver file exists.";
360#endif
361 return true;
362 }
363
364 return false;

Callers

nothing calls this directly

Calls 1

removeMethod · 0.80

Tested by

no test coverage detected