I intercept the file transfer, in the file permission.txt the paths to the files that can not be moved are recorded through \ n. Now I have strongly stopped on a sore subject for me - encodings. I can not understand how to take a string from a file and compare it with LPCWSTR:

BOOL WINAPI MyMoveFileExW(LPCWSTR lpExistingFileName, LPCWSTR lpNewFileName, DWORD dwFlags) { std::wstring lpEx(lpExistingFileName); std::wifstream wif("C:\\cpp\\permission.txt", std::ios::binary); if (wif.is_open()) { wif.imbue(std::locale(wif.getloc(), new std::codecvt_utf8<wchar_t, 0x10ffff, std::consume_header>)); std::wstring wline; while (std::getline(wif, wline)) { if(wline == lpEx){ return FALSE; } } wif.close(); } BOOL retValue; VirtualProtect((LPVOID)pOrigMBAddress_2, SIZE, myProtect_2, NULL); // assign read write protection memcpy((LPVOID)pOrigMBAddress_2, oldBytes_2, SIZE); // restore backup retValue = pOrigMBAddress_2(lpExistingFileName, lpNewFileName, dwFlags); memcpy((LPVOID)pOrigMBAddress_2, JMP_2, SIZE); // set the jump instruction again VirtualProtect((LPVOID)pOrigMBAddress_2, SIZE, oldProtect_2, NULL); // reset protection return TRUE; } 

Tell me, please, any option

  • It is not very clear where the problem is, and whether it is there, look at the transformation and comparison functions if we are talking about it .. And according to the theory, translate unicode in wchar_t and compare. - NewView 5:09
  • If the string is ANSI ie char * then it can be reconfigured in wchar_t * - nick_n_a
  • It makes sense to compare two strings only if both are in the same encoding. Translated - compared. - nick_n_a

0