windows - Reading blacklist from a text file in C++ -
i need driver read (line line) programs going blacklisted.
_t("bannedfile.exe") need put blacklisted program.
how can make _tcscmp read text file, line line?
(it makes comparison between host program loads driver, , blacklisted one)
bool processblacklist() { tchar modulename[max_path]; getmodulefilename(null, modulename, max_path); pathstrippath(modulename); if (_tcscmp(modulename, _t("bannedfile.exe")) != 1) { return 0; } else { return 0x2; } }
can't done way.
you should able use use getline read file line line , pass lines _tcscmp. should work this:
wchar_t const name[] = l"bannedfile.exe"; std::wifstream file(name); std::wstring line; while (std::getline(file, line) { if (_tcscmp(modulename, line.c_str()) == 0) { return true; //module in list } } return false; // module not in list
lacking copy of vs test @ moment.
if run unicode parsing problems because file's encoding isn't quite defaults expect, give read: what std::wifstream::getline doing wchar_t array? it's treated byte array after getline returns
Comments
Post a Comment