0

I am trying to open sigverif.exe from my code in c++ but the return value is 2 and .exe does not open

ShellExecute(NULL, _T("open"), _T("C:\\Windows\\System32\\sigverif.exe"), NULL, NULL, SW_RESTORE);

If I open the sigverif.exe from run command typing

"C:\Windows\system32\sigverif.exe"

it works fine

What could be the issue?

Sandeep Kumar
  • 85
  • 1
  • 3
  • 10

1 Answers1

4

the return value is 2 and .exe does not open

The return value based on System Error Codes means ERROR_FILE_NOT_FOUND.

Yes, indeed your application failed to find the given path, because you're building it on x86, where Windows's automatic redirection involves, and replace C:\Windows\System32 with C:\Windows\SysWOW64, which contains 32-bit binaries for Windows.

You have two options:

Either you just build it on x64, or disable the automatic redirection by using Wow64DisableWow64FsRedirection as follows:

PVOID OldValue = nullptr;
Wow64DisableWow64FsRedirection(&OldValue);
ShellExecute(NULL, _T("open"), _T("C:\\Windows\\System32\\sigverif.exe"), NULL, NULL, SW_RESTORE);

Be aware that Wow64DisableWow64FsRedirection affects globally in the current thread, as you can find more detail in the page:

Note The Wow64DisableWow64FsRedirection function affects all file operations performed by the current thread, which can have unintended consequences if file system redirection is disabled for any length of time....

So make sure it won't affect other operations unintentionally, or set it back to enabled immediately after your desire is resolved by invoking Wow64EnableWow64FsRedirection.

Dean Seo
  • 5,486
  • 3
  • 30
  • 49