[Compuware Corporation] [Compuware NuMega home page]                [NuMega Lab]
[teal]

 [DriverStudio]    [Image][Image]
   Home
 [Driver Products]        Driver Technical Tips
   DriverStudio          Exporting Functions from VxDs to WDM Drivers
   DriverBundle
   Previews              VxDs and Win32 Driver Model drivers coexist on
   Compatibility         Windows 98. These two kinds of drivers employ
 [Downloads]             different methods of dynamic linkage, i.e. the means
                          by which the drivers link to external functions in
 Wizards                  other drivers. VxDs rely on a software interrupt (
   Utilities             INT 0x20 ), which is followed in the instruction
   NT source             stream by a constant that identifies the target
 examples                 service. WDM drivers rely on a load-time method based
   VxD source            on the same constructs in the PE executable that are
 examples                 used by applications to link to DLLs.
   WDM source
 examples                 Sometimes you want a WDM driver to call a function
 [Resources]             that is implemented in a VxD. If the VxD exports the
 Technical papers         function through its VxD Service Table, then it is
   Useful links          possible to call the service by inserting an INT 0x20
   Technical tips        sequence in the WDM driver. However, this code won't
 [Support]               work on Windows NT 5.0, because the INT 0x20 dynamic
                          linkage mechanism does not exist on that platform.
 Support
   Knowledge base        A better solution is to export the function from the
   Problem               VxD in a way that enables the system to locate it
 submission               using the normal load-time linkage mechanism for WDM
   Product               drivers. That way, imported functions can be resolved
 registration             in the same way on all WDM platforms. Windows 95 and
   Release notes         Windows 98 provide the service PELDR_AddExportTable
 [Shop NuMega]           for this purpose. It allows a VxD to export a set of
 Buy it!                  functions to PE modules by specifying a set of
   Price list            function names, addresses, and ordinals. Here is the
   How to buy            VtoolsD prototype for the service:
   Sales offices
                          LRESULT PELDR_AddExportTable(
                                  PHPEEXPORTTABLE phExportTable,
 [Y2K Compliance]                 PSTR pszModuleName,
                                  ULONG cExportedFunctions,
                                  ULONG cExportedNames,
 [More information]               ULONG ulOrdinalBase,
                                  PVOID *pExportNameList,
                                  PUSHORT pExportOrdinals,
                                  PVOID *pExportAddrs,
                                  PHLIST phList
                                  );

                          And the parameters are as follows:

                             * phExportTable is the address of the variable
                               that receives the handle of the export table on
                               output.
                             * pszModuleName points to the null terminated name
                               of the module to be associated with the export
                               table. This must match the name that the WDM
                               driver uses to identify functions that it
                               imports.
                             * cExportedFunctions is the number of functions to
                               be exported.
                             * cExportedNames is the number of exported
                               functions for which names are provided.
                             * ulOrdinalBase is the base ordinal for the set of
                               functions.
                             * pExportNameList is the address of an array of
                               pointers to null terminated functions names.
                             * pExportOrdinals is the address of an array of
                               ordinals. These values are zero-based array
                               indices into the array pointed to by
                               pExportAddrs. The length of this array is equal
                               to cExportedFunctions. If the ith element of
                               this array is zero, then the ith element of the
                               array pointed to by pExportAddrs is the address
                               of the function whose ordinal is given by
                               parameter ulOrdinalBase.
                             * pExportAddrs is the address of the array of
                               addresses of the exported functions.
                             * phList is the address of a handle for a list of
                               import tables. The service adds the new export
                               table to the list. A driver that controls
                               loading of PE modules can use this list to
                               restrict the set of export tables used to
                               resolve imports. Other drivers simply pass NULL,
                               which causes the service to add the new export
                               table to the global list of export table.

                          Note that the VxD must be loaded prior to the WDM
                          driver in order for this to work, and the tables
                          holding the names, addresses, and ordinals must
                          remain intact.

                          To remove an export table, use the service
                          PELDR_RemoveExportTable.

                          Creating export tables is not something that most
                          VxDs have to do. However, it could be helpful in
                          enabling your WDM driver to interoperate on multiple
                          WDM platforms.

                          Back to technical tip start page.

  DriverCentral  DriverStudio  Free downloads  Resources  Support and
                          Services  Shop NuMega
     Compuware NuMega  Tel: +1 603 578-8400  Updated: 9 August 1999 
                      Problems? Contact our webmaster.
