[WDF] Fix KMDF so it can compile with ReactOS SDK

Not all files are included, but these are necessary to compile cdrom driver.
So far it can only be statically linked with drivers, a proper
implementation requires wdfldr helper driver
This commit is contained in:
Victor Perevertkin 2020-10-16 06:30:51 +03:00
parent 8a978a179f
commit 1f377076d7
No known key found for this signature in database
GPG key ID: C750B7222E9C7830
258 changed files with 4047 additions and 2387 deletions

View file

@ -109,7 +109,7 @@ Return Value:
(DebugPrintLevel <= DebugLevel &&
((DebugPrintFlag & DebugFlag) == DebugPrintFlag))) {
#if FX_CORE_MODE==FX_CORE_KERNEL_MODE
DbgPrint("WDFTrace: %s", debugMessageBuffer);
DbgPrint("WDFTrace: %s\n", debugMessageBuffer);
#else
OutputDebugString("WDFTrace: ");
OutputDebugString(DebugMessage);

View file

@ -36,6 +36,7 @@ extern "C" {
__drv_maxIRQL(DISPATCH_LEVEL)
WDFAPI
VOID
STDCALL
WDFEXPORT(WdfObjectReferenceActual)(
__in
PWDF_DRIVER_GLOBALS DriverGlobals,
@ -81,6 +82,7 @@ Return Value:
__drv_maxIRQL(DISPATCH_LEVEL)
WDFAPI
VOID
STDCALL
WDFEXPORT(WdfObjectDereferenceActual)(
__in
PWDF_DRIVER_GLOBALS DriverGlobals,
@ -170,6 +172,7 @@ Returns:
__drv_maxIRQL(DISPATCH_LEVEL)
WDFAPI
VOID
STDCALL
WDFEXPORT(WdfObjectAcquireLock)(
__in
PWDF_DRIVER_GLOBALS DriverGlobals,
@ -229,6 +232,7 @@ WDFEXPORT(WdfObjectAcquireLock)(
__drv_maxIRQL(DISPATCH_LEVEL)
WDFAPI
VOID
STDCALL
WDFEXPORT(WdfObjectReleaseLock)(
__in
PWDF_DRIVER_GLOBALS DriverGlobals,
@ -284,6 +288,7 @@ WDFEXPORT(WdfObjectReleaseLock)(
__drv_maxIRQL(DISPATCH_LEVEL)
WDFAPI
VOID
STDCALL
WDFEXPORT(WdfObjectDelete)(
__in
PWDF_DRIVER_GLOBALS DriverGlobals,
@ -322,6 +327,7 @@ _Must_inspect_result_
__drv_maxIRQL(DISPATCH_LEVEL)
WDFAPI
NTSTATUS
STDCALL
WDFEXPORT(WdfObjectQuery)(
__in
PWDF_DRIVER_GLOBALS DriverGlobals,

View file

@ -25,6 +25,6 @@ Revision History:
#include "objectpriv.hpp"
#include "fxmin.hpp"
#include "FxToObjectItf.hpp"
#include "fxtoobjectitf.hpp"
#endif // __FX_CORE_PCH_H__

View file

@ -39,6 +39,7 @@ extern "C" {
extern
_Success_(return != 0)
USHORT
STDCALL
RtlCaptureStackBackTrace(
_In_ ULONG FramesToSkip,
_In_ ULONG FramesToCapture,

View file

@ -32,7 +32,7 @@ Revision History:
#include "fxobjectpch.hpp"
#include "FxUserObject.hpp"
#include "fxuserobject.hpp"
// Tracing support
extern "C" {

View file

@ -24,7 +24,7 @@ Revision History:
#include "fxobjectpch.hpp"
#include "FxUserObject.hpp"
#include "fxuserobject.hpp"
// Tracing support
extern "C" {
@ -39,6 +39,7 @@ extern "C" {
_Must_inspect_result_
__drv_maxIRQL(DISPATCH_LEVEL)
NTSTATUS
STDCALL
WDFEXPORT(WdfObjectCreate)(
__in
PWDF_DRIVER_GLOBALS DriverGlobals,

View file

@ -39,8 +39,8 @@ extern "C" {
//=============================================================================
DECLSPEC_NORETURN
VOID
__declspec(noreturn)
FxVerifierBugCheckWorker(
__in PFX_DRIVER_GLOBALS FxDriverGlobals,
__in WDF_BUGCHECK_CODES WdfBugCheckCode,
@ -72,8 +72,8 @@ Returns:
(ULONG_PTR) FxDriverGlobals );
}
DECLSPEC_NORETURN
VOID
__declspec(noreturn)
FxVerifierNullBugCheck(
__in PFX_DRIVER_GLOBALS FxDriverGlobals,
__in PVOID ReturnAddress

View file

@ -289,7 +289,7 @@ FxDriverGlobalsInitializeDebugExtension(
return;
}
RtlZeroMemory(pExtension, sizeof(*pExtension));
*pExtension = {};
pExtension->AllocatedTagTrackersLock.Initialize();
@ -678,7 +678,7 @@ FxLibraryGlobalsCommission(
// Register for the global (library) bugcheck callbacks.
//
FxInitializeBugCheckDriverInfo();
#ifdef EVENT_TRACING // __REACTOS__
//
// Init driver usage tracker. This tracker is used by the debug dump
// callback routines for finding the driver's dump log file to write
@ -728,7 +728,9 @@ FxLibraryGlobalsCommission(
//
ASSERT(FxLibraryGlobals.PerfTraceRoutines->Size >=
sizeof(WMI_WDF_NOTIFY_ROUTINES));
#else
status = STATUS_SUCCESS; // __REACTOS__
#endif // EVENT_TRACING
#else
status = STATUS_SUCCESS;
#endif
@ -810,7 +812,7 @@ LockVerifierSection(
// VerifierLockHandle is a function that we use to lock in all the code from it's section
// since all the verifier code is in the same section as VerifierLockHandle.
//
FxLibraryGlobals.VerifierSectionHandle = MmLockPagableCodeSection(VerifierPageLockHandle);
FxLibraryGlobals.VerifierSectionHandle = MmLockPagableCodeSection((PVOID)VerifierPageLockHandle);
}
else {
MmLockPagableSectionByHandle(FxLibraryGlobals.VerifierSectionHandle);
@ -898,7 +900,7 @@ Returns:
//
// Initialize IFR logging
//
FxIFRStart(FxDriverGlobals, RegistryPath, DriverObject);
// FxIFRStart(FxDriverGlobals, RegistryPath, DriverObject); __REACTOS__
DoTraceLevelMessage(FxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGDRIVER,
"Initialize globals for %!wZ!", RegistryPath);
@ -912,7 +914,7 @@ Returns:
// FxPoolPackageInitialize logs a message in case of failure so
// we don't need to log failure here.
//
FxIFRStop(FxDriverGlobals);
// FxIFRStop(FxDriverGlobals); __REACTOS__
return status;
}
@ -1002,7 +1004,7 @@ Returns:
//
// Release the last reference.
//
FxDriverGlobals->RELEASE(FxDestroy);
FxDriverGlobals->RELEASE((PVOID)FxDestroy);
//
// Wait for everyone else to be done.
@ -1052,7 +1054,7 @@ FxAllocateDriverGlobals(
)
{
PFX_DRIVER_GLOBALS pFxDriverGlobals;
KIRQL irql;
// KIRQL irql;
NTSTATUS status;
pFxDriverGlobals = (PFX_DRIVER_GLOBALS)
@ -1062,7 +1064,7 @@ FxAllocateDriverGlobals(
return NULL;
}
RtlZeroMemory(pFxDriverGlobals, sizeof(FX_DRIVER_GLOBALS));
*pFxDriverGlobals = {};
pFxDriverGlobals->Refcnt = 1;
@ -1079,10 +1081,12 @@ FxAllocateDriverGlobals(
//
// Initialize this new FxDriverGlobals structure.
//
#ifndef __REACTOS__
FxLibraryGlobals.FxDriverGlobalsListLock.Acquire(&irql);
InsertHeadList(&FxLibraryGlobals.FxDriverGlobalsList,
&pFxDriverGlobals->Linkage);
FxLibraryGlobals.FxDriverGlobalsListLock.Release(irql);
#endif
pFxDriverGlobals->WdfHandleMask = FxHandleValueMask;
pFxDriverGlobals->WdfVerifierAllocateFailCount = (ULONG) -1;
@ -1140,7 +1144,8 @@ FxAllocateDriverGlobals(
pFxDriverGlobals->FxForceLogsInMiniDump = FALSE;
#if (FX_CORE_MODE==FX_CORE_KERNEL_MODE)
pFxDriverGlobals->FxTrackDriverForMiniDumpLog = TRUE;
// pFxDriverGlobals->FxTrackDriverForMiniDumpLog = TRUE;
pFxDriverGlobals->FxTrackDriverForMiniDumpLog = FALSE; // __REACTOS__
pFxDriverGlobals->IsUserModeDriver = FALSE;
#else
pFxDriverGlobals->FxTrackDriverForMiniDumpLog = FALSE;
@ -1163,9 +1168,11 @@ FxAllocateDriverGlobals(
// Allocate a telemetry context if a telemetry client is enabled, for any level/keyword.
//
pFxDriverGlobals->TelemetryContext = NULL;
#ifdef EVENT_TRACING // __REACTOS__
if (TraceLoggingProviderEnabled(g_TelemetryProvider, 0 ,0)) {
AllocAndInitializeTelemetryContext(&(pFxDriverGlobals->TelemetryContext));
}
#endif
return &pFxDriverGlobals->Public;
}

View file

@ -504,6 +504,7 @@ _Must_inspect_result_
__drv_maxIRQL(DISPATCH_LEVEL)
WDFAPI
NTSTATUS
STDCALL
WDFEXPORT(WdfObjectAllocateContext)(
__in
PWDF_DRIVER_GLOBALS DriverGlobals,

View file

@ -6,10 +6,10 @@
// Tracing support
extern "C" {
#if defined(EVENT_TRACING)
#include "GlobalsKm.tmh"
#include "globalskm.tmh"
#endif
#include <wdfcxbase.h>
// #include <wdfcxbase.h>
#include <fxldr.h>
@ -45,6 +45,7 @@ __drv_minIRQL(DISPATCH_LEVEL)
__drv_requiresIRQL(DISPATCH_LEVEL)
__drv_sameIRQL
VOID
STDCALL
FxFlushDpc (
__in struct _KDPC *Dpc,
__in_opt PVOID DeferredContext,

View file

@ -41,6 +41,7 @@ extern "C" {
__drv_maxIRQL(DISPATCH_LEVEL)
NTKERNELAPI
PMDL
STDCALL
IoAllocateMdl(
__in_opt __drv_aliasesMem PVOID VirtualAddress,
__in ULONG Length,
@ -52,6 +53,7 @@ IoAllocateMdl(
__drv_maxIRQL(DISPATCH_LEVEL)
NTKERNELAPI
VOID
STDCALL
IoFreeMdl(
PMDL Mdl
);

View file

@ -1,10 +1,10 @@
//
// Copyright (C) Microsoft. All rights reserved.
//
#include "FxMin.hpp"
#include "fxmin.hpp"
#include "fxobjectpch.hpp"
#include "FxUserObject.hpp"
#include "fxuserobject.hpp"
#include "pnppriv.hpp"
//

View file

@ -150,7 +150,7 @@ Remarks:
if (FxDriverGlobals->IsPoolTrackingOn()) {
if (FxDriverGlobals->FxVerifierOn &&
(FxDriverGlobals->WdfVerifierAllocateFailCount != 0xFFFFFFFF)) {
(FxDriverGlobals->WdfVerifierAllocateFailCount != -1L)) {
//
// If the registry key VerifierAllocateFailCount is set, all allocations