none
How to install a 64-bit service from WOW64?

    Question

  • I (have to) use a 32-bit application to install a 64-bit service binary.

    CreateServiceW() works, but the service is "marked" as beeing a "WOW64" service.

    Therefore, if the service binary is located in %SystemRoot%\System32 (installed with disabled file system redirection) the StartService() call fails with ERROR_FILE_NOT_FOUND.

     

    Well, I cound manually delete the "WOW64" registry value... but:

    a) I don't want to hard-code the registry path

    b) remote installations must be supported

    (for the latter one the RemoteRegistry service must be enabled, started, and afterwards restored to the old state)

     

    The root of the problem seems to be the implementation of CreateServiceW().

    It uses IsWow64Process(GetCurrentProcess)) to "detect" WOW64 services (and then calling RCreateServiceWOW64W() instead of RCreateServiceW()).

    Is there an option to disable this behavior?

    Shouldn't the "detection" be based on the service binary image (at least if the image is available)?

     

    I don't want to temporary hook the IAT of AdvApi32 to "fix" this problem...

    (well, I have done this to test if the internal call to RCreateServiceW() works)

    Monday, November 26, 2007 4:17 PM

Answers

  •  

    Windows Installer 1.1 can't install 64-bit packages. You need to be using at least version 2 of the schema as detailed here.
    Tuesday, November 27, 2007 9:34 PM

All replies

  • Assuming you installed the 64 bit service with an MSI. How are you invoking it (what are the parameters) are you using to createservicew. For example, what is your dwServiceType value.

     

    I wasn't aware that you could execute a 64 bit process from one that is under emulation.

     

    You should create a native 64 bit version of your application to use the 64 bit service.

    Tuesday, November 27, 2007 1:40 AM
  •  Bruce N. Baker - MSFT wrote:
    Assuming you installed the 64 bit service with an MSI.

     

    Currently we are forced to use MSI 1.1 for several reasons.

    We tried including both binaries and registering (DllRegisterServer) the x86 or x64 library from the setup.

    But on x64 the registration call sometimes/randomly fails with ERROR_BAD_EXE_FORMAT or ERROR_FILE_NOT_FOUND.

    However, pressing the "retry" button works in most cases (but the error is a bad user experience).

     

     Bruce N. Baker - MSFT wrote:
    I wasn't aware that you could execute a 64 bit process from one that is under emulation.

     

    It is a 32-bit setup (MSI).

     

     Bruce N. Baker - MSFT wrote:
    How are you invoking it (what are the parameters) are you using to createservicew. For example, what is your dwServiceType value.

     

    Code Block

    SCManager = OpenSCManagerW(

        MachineName,

        SERVICES_ACTIVE_DATABASEW,

        SC_MANAGER_CREATE_SERVICE);

    //...

    Service = CreateServiceW(

        SCManager,

        ServiceName,

        DisplayName,

        GENERIC_ALL,

        SERVICE_WIN32_OWN_PROCESS,

        SERVICE_DEMAND_START,

        SERVICE_ERROR_IGNORE,

        BinaryPathName,  // L"%SystemRoot%\\System32\\Xxx.exe"

        NULL,

        NULL,

        NULL,

        NULL,

        NULL);

     

    As mentioned above, It doesn't seem to matter how the API is called.

    What ever I tried, it is always marked as an WOW64 service, because my installer "application" (dll or exe) is running inside WOW64.

    And the API has no documented flag that signals "Even if I'm a 32-bit process, I know what I'm doing - please skip the WOW64 emulation" (like the APIs and flags for the file system redirection and the registry redirection/reflection).

     

     Bruce N. Baker - MSFT wrote:
    You should create a native 64 bit version of your application to use the 64 bit service.

     

    We might split the setup into x86 and x64 (much) later, but currently this is no option.

     

     

    Thanks for the fast reply,

    Nico

    Tuesday, November 27, 2007 9:08 AM
  •  

    Windows Installer 1.1 can't install 64-bit packages. You need to be using at least version 2 of the schema as detailed here.
    Tuesday, November 27, 2007 9:34 PM
  •  

    Thanks for the pointers.

    It seems that I have to use the hack until the setup is splitted into x86 and x64 releases.

    Monday, December 10, 2007 9:33 AM