Compiling a Driver's MOF File

To compile a MOF file that defines WMI data and event blocks, use the MOF compiler, called Mofcomp, that is included with the Microsoft Windows operating systems. Use the following syntax:

 mofcomp -WMI -B:filename.bmf filename.mof

The following items appear in the preceding syntax:

-WMI
Validates all classes in filename.mof for use with WMI. If any class definition is invalid, Mofcomp deletes the output file filename.bmf. If -WMI is omitted, you should run Wmimofck on filename.bmf to validate the classes. A driver must either use the WMI switch or run Wmimofck to validate the MOF. Failure to do so can result in the MOF file not loading correctly into the WMI schema.

-B:filename.bmf
Requests that the compiler create a platform-independent binary version of the MOF file in filename.bmf without making any modifications to the CIMOM object repository.

filename.mof
Specifies the name of the input MOF file.

To learn more about how to use Mofcomp, open a Command Prompt window and type mofcomp /?.

For more information about Mofcomp, see MofComp and other topics in the Windows SDK.

To include the compiled MOF file as a resource in the driver's binary image, add the following line to the driver's resource script (RC) file:

MofResource MOFDATA filename.bmf

A driver specifies its MOF resource name in response to a registration request (an IRP_MN_REGINFO or IRP_MN_REGINFO_EX request with Parameters.WMI.DataPath set to WMIREGISTER):

  • If the driver is using the WMI library routines to handle WMI IRPs, it specifies the MOF resource name in its DpWmiQueryReginfo routine.

  • If the driver is handling WMI IRPs directly, it specifies the MOF resource name in the WMIREGINFO structure that the driver passes to WMI.

For more information about handling IRP_MN_REGINFO and IRP_MN_REGINFO_EX requests, see Registering as a WMI Data Provider.

For more information about handling WMI IRPs using WMI iibrary routines, see Handling WMI Requests.

For more information about defining and including resources in executable files, see the Microsoft Windows SDK.