S
S
sddvxd2018-06-24 16:22:19
C++ / C#
sddvxd, 2018-06-24 16:22:19

Why does the expression fail validation?

Hello

BOOL WINAPI MyMoveFileExW(LPCWSTR lpExistingFileName, LPCWSTR lpNewFileName, DWORD dwFlags)
{
  BOOL retValue;
  if(lpExistingFileName != (LPCWSTR)L"C:\\Users\\sddvxd\\Desktop\\a.exe"){
  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
  }
  else{
     retValue = FALSE;
  }
  return retValue;

"If the filename matches such-and-such, prevent the file from being moved" - fails. Shielding yes

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman, 2018-06-24
@sddvxd

C strings must be compared in the function
www.cplusplus.com/reference/cwchar/wcscmp

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question