Search code examples
ndis

Two binaries in one INF file for NDIS 6 LWF


In previous times with NDIS 5.1 we managed to make one inf file that installed the respectie 32 or 64 bit sys file binary, depending on the OS where it was installed.

We are trying now the same thing with a NDIS 6 LWF INF file, and have no idea how we could duplicate the [Install.Services] section, so the OS will choose automatically which binary to pick up, the 32 or the 64-bit one.

This basically brings us down to the following INF file sections:

[Install.Services]
; You may also want to add the SPSVCINST_STARTSERVICE flag, like this:
;     AddService=NdisLwf,0x800,NdisLwf_Service_Inst ; SPSVCINST_STARTSERVICE
AddService=Daihinia,,Daihinia_Service_Inst

[Daihinia_Service_Inst]
DisplayName     = %Daihinia_Desc%
ServiceType     = 1 ;SERVICE_KERNEL_DRIVER
; Typically you will want your filter driver to start with SERVICE_SYSTEM_START.
; If it is an Optional filter, you may also use 3;SERVICE_DEMAND_START.
StartType       = 1 ;SERVICE_SYSTEM_START
ErrorControl    = 1 ;SERVICE_ERROR_NORMAL
ServiceBinary   = %12%\daihinia6-32.sys
LoadOrderGroup  = NDIS
Description     = %Daihinia_Desc%
AddReg          = Common.Params.reg, NdisImPlatformBindingOptions.reg

In the [Daihinia_Service_Inst] we have the 32bit binary in the above example.

Any insight how to modify them, given that the [Install.Services] section is not referenced anywhere in the INF explicitly, so we can't make a fork there?


Solution

  • We don't generally encourage drivers to have a different name based on the CPU architecture. All the built-in drivers have the same name on x86, ia64, amd64, arm, etc. So one easy way to solve the problem is just ship a file named "daihinia.sys" on all platforms.

    But if you really want to have different file names, then you have two high-level options:

    1. Use the same INF on all platforms, but decorate the Manufacturer section with per-architecture INF sections; or
    2. Ship a different INF on each architecture. Where the only difference is the name of the ServiceBinary. The stampinf tool can help you avoid code duplication, by generating each architecture-specific INF from one INX template.

    An example of the first option:

    [Manufacturer]
    %Msft%=MSFT,NTx86,NTamd64
    
    [MSFT.NTx86]
    %NdisLwf_Desc%=Install32, MS_NdisLwf
    
    [MSFT.NTamd64]
    %NdisLwf_Desc%=Install64, MS_NdisLwf
    
    [Install32.Services]
    AddService=MyService,,Service32
    
    [Install64.Services]
    AddService=MyService,,Service64
    
    [Service32]
    ServiceBinary=%12%\MyImage32.sys
    . . . other options . . .
    
    [Service64]
    ServiceBinary=%12%\MyImage64.sys
    . . . other options . . .