-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
The process_t::open(std::string_view name, std::uint32_t access) method uses case-sensitive string comparison when searching for processes by name. On Windows, process names should be compared case-insensitively.
Sample code:
#include <iostream>
#include <windows.h>
#include "wincpp/process.hpp"
int main() {
const std::uint32_t queryAccess = PROCESS_QUERY_LIMITED_INFORMATION;
try {
std::cout << "Attempting to open 'explorer.exe' with correct case...\n";
auto procCorrect = wincpp::process_t::open("explorer.exe", queryAccess);
if (procCorrect) {
std::cout << "Success: Process opened with correct case.\n";
} else {
std::cout << "Fail: Process not found with correct case.\n";
}
} catch (const std::exception &ex) {
std::cout << "Exception encountered with correct case: " << ex.what() << "\n";
}
try {
std::cout << "Attempting to open 'EXPLORER.EXE' with mismatched case...\n";
auto procIncorrect = wincpp::process_t::open("EXPLORER.EXE", queryAccess);
if (procIncorrect) {
std::cout << "Unexpected success: Process opened with mismatched case.\n";
} else {
std::cout << "Expected: Process not found with mismatched case due to case-sensitive bug.\n";
}
} catch (const std::exception &ex) {
std::cout << "Exception encountered with mismatched case: " << ex.what() << "\n";
}
return 0;
}Output:
Attempting to open 'explorer.exe' with correct case...
Success: Process opened with correct case.
Attempting to open 'EXPLORER.EXE' with mismatched case...
Expected: Process not found with mismatched case due to case-sensitive bug
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels