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