Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation needs to include adding <ClCompile ...><Wpp* ...></ClCompile> to VS project? #260

Open
paulpv opened this issue Nov 9, 2024 · 3 comments

Comments

@paulpv
Copy link

paulpv commented Nov 9, 2024

I wanted to learn how to create a DMF project, so I:

  1. Cloned DMF
  2. Built the DMF solution successfully
  3. In Visual Studio 2022 [Community] added a new standard template KMDF project and removed some its boilerplate code
  4. Manually integrated Dmf.props into my KMDF DMF project following the [IMHO important but very buried] instructions at:
    https://github.com/Microsoft/DMF/blob/master/Dmf/Documentation/Driver%20Module%20Framework.md#simplifying-compilation-and-linking-with-dmf
  5. Added some basic hello world DMF code from:
    https://github.com/Microsoft/DMF/blob/master/Dmf/Documentation/Driver%20Module%20Framework.md#using-dmf-in-a-driver-that-does-not-have-a-deviceadd-callback
    Roughly...
#include "DmfModules.Library.h"
DRIVER_INITIALIZE DriverEntry;
EVT_WDF_DRIVER_DEVICE_ADD StorageFwUpdateDeviceAdd;
EVT_WDF_OBJECT_CONTEXT_CLEANUP StorageFwUpdateDriverContextCleanup;
EVT_DMF_DEVICE_MODULES_ADD DmfDeviceModulesAdd;

/*WPP_INIT_TRACING(); (This comment is necessary for WPP Scanner.)*/
#pragma code_seg("INIT")
DMF_DEFAULT_DRIV<RENTRY(DriverEntry, 
                        StorageFwUpdateDriverContextCleanup,
                        StorageFwUpdateDeviceAdd)
#pragma code_seg()

#pragma code_seg("PAGED")
DMF_DEFAULT_DRIVERCLEANUP(StorageFwUpdateDriverContextCleanup)
DMF_DEFAULT_DEVICEADD(StorageFwUpdateDeviceAdd,
                      DmfDeviceModulesAdd)
#pragma code_seg()
  1. Built the project and got this errors saying
Severity	Code	Description	Project	File	Line	Suppression State	Details
Error	C4013	'WPP_CLEANUP' undefined; assuming extern returning int	KMDF WDF DMF VHF KMClone	DmfInterface.c	9		
Error	C4013	'WPP_INIT_TRACING' undefined; assuming extern returning int	KMDF WDF DMF VHF KMClone	DmfInterface.c	9		

I diffed my project with the DmfSamples and found that the DmfSamples had this:

#include "Trace.h"
#include "DmfInterface.tmh"

I had my own Trace.h from the template.
But what was this "DmfInterface.tmh"?

It took me about half a day to this nugget of goodness in all of the DmfSample projects:

  <ItemGroup Label="WrappedTaskItems">
    <ClCompile Include="DmfInterface.c">
      <WppEnabled>true</WppEnabled>
      <WppKernelMode>true</WppKernelMode>
      <WppTraceFunction>TraceEvents(LEVEL,FLAGS,MSG,...)</WppTraceFunction>
      <WppGenerateUsingTemplateFile>{km-WdfDefault.tpl}*.tmh</WppGenerateUsingTemplateFile>
    </ClCompile>
  </ItemGroup>

I also learned something new: WPP

I think this ClCompile Wpp section needs to be in the documentation at:
https://github.com/Microsoft/DMF/blob/master/Dmf/Documentation/Driver%20Module%20Framework.md

@samtertzakian
Copy link
Member

Hmm.... This is strange. For us, all the sample drivers compile. Let me investigate this issue. It is not clear to me why it was not working for you.
Thank you for the information.

@paulpv
Copy link
Author

paulpv commented Nov 15, 2024

Hmm.... This is strange. For us, all the sample drivers compile. Let me investigate this issue. It is not clear to me why it was not working for you. Thank you for the information.

All of the sample drivers do work fine for me.

It is when I create my own new KMDF [DMF] driver project from scratch that I have to add that undocumented config to the project file.

@nefarius
Copy link
Contributor

Maybe this is an issue with the WDK templates rather than DMF? In none of my DMF projects do I need to add this snippet, it should be compatible with WPP in project skeletons out of the box. Maybe share your complete demo project, if you can (anonymised ofc.).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants