c++http-redirectwow64

Executable "C:\Windows\System32\Fodhelper.exe" not found


I am trying to start the above builtin Windows executable from within a C++ program. Firstly I can confirm that the program does exist, at the path "C:\Windows\System32\fodhelper.exe"

System32 Directory

I have tried 3 different methods for running this program:

None of these methods work. The error I receive is: The system cannot find the file specified.

Due to the fact that I can start this executable as my usual Windows account from the start menu, run box and from within Windows explorer, i believe that my user account does have the privileges to run the program. Also, I am not receiving an access denied error from my code. Regardless, I have run VS as an Administrator and I have still experienced the same problem.

I believe the code I am using to start the process is correct, as the same code will start cmd.exe without issue. See below:

#include <Windows.h>
#include <tchar.h>
#include <iostream>

void CreateProcessMethod(LPCWSTR programPath) {

    HRESULT result;
    STARTUPINFO startupInfo;
    PROCESS_INFORMATION processInformation;

    ZeroMemory(&startupInfo, sizeof(startupInfo));
    startupInfo.cb = sizeof(startupInfo);
    ZeroMemory(&processInformation, sizeof(processInformation));

    result = CreateProcessW(programPath, NULL, NULL, NULL, FALSE, CREATE_NEW_CONSOLE, NULL, NULL, &startupInfo, &processInformation);
    if (result == 0) {

        wchar_t buf[256];
        FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
            NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
            buf, (sizeof(buf) / sizeof(wchar_t)), NULL);

        /* Display error */
        std::wcout << programPath << " not started: " << buf << std::endl;

    }
    else {
        std::wcout << programPath << " started successfuly" << std::endl;
    }

}

void ShellExecuteMethod(LPCWSTR programPath) {

    SHELLEXECUTEINFOW shExecInfo = { 0 };
    shExecInfo.cbSize = sizeof(SHELLEXECUTEINFOW);

        
    shExecInfo.fMask = SEE_MASK_FLAG_NO_UI;
    shExecInfo.hwnd = nullptr;
    shExecInfo.lpVerb = L"open";
    shExecInfo.lpFile = programPath;
    shExecInfo.lpParameters = L"\\C";
    shExecInfo.nShow = SW_SHOWNORMAL;

    if (ShellExecuteExW(&shExecInfo) == 0)
    {
        if (GetLastError() != ERROR_CANCELLED) // Operation canceled by the user
        {
            wchar_t buf[256];
            FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
                NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
                buf, (sizeof(buf) / sizeof(wchar_t)), NULL);

            /* Display error */
            std::wcout << programPath << " not started: " << buf << std::endl;
        }
    }
    else {
        std::wcout << programPath << " started successfuly" << std::endl;
    }

}

int main(){

    CreateProcessMethod(L"C:\\Windows\\System32\\cmd.exe");
    CreateProcessMethod(L"C:\\Windows\\System32\\fodhelper.exe");

    ShellExecuteMethod(L"C:\\Windows\\System32\\cmd.exe");
    ShellExecuteMethod(L"C:\\Windows\\System32\\fodhelper.exe");

    
}

See output of the program below:

Output window

Does anyone have any insight into what exactly I am doing wrong here? I cannot find any information that relates to this issue. Is far as I can understand, the code attempting to run the program is correct, works with different executables. This also occurs with three different methods. Any help would greatly be appreciated.


Solution

  • 32-bit applications running on WOW64 will be put under file system redirection. Therefore if your app is a 32-bit one, the path C:\Windows\System32\fodhelper.exe will be redirected to C:\Windows\SysWOW64\fodhelper.exe which doesn't exist. You have some solutions: