[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

@ -36,15 +36,15 @@ extern "C" {
#include "mx.h"
}
#include "FxMin.hpp"
#include "fxmin.hpp"
#include "wdfmemory.h"
#include "wdfrequest.h"
#include "wdfdevice.h"
#include "wdfWmi.h"
#include "wdfChildList.h"
#include "wdfwmi.h"
#include "wdfchildlist.h"
#include "wdfpdo.h"
#include "wdffdo.h"
#include "wdfiotarget.h"
@ -53,26 +53,26 @@ extern "C" {
#include "wdfio.h"
#include "wdfqueryinterface.h"
#include "FxIrpQueue.hpp"
#include "FxCallback.hpp"
#include "fxirpqueue.hpp"
#include "fxcallback.hpp"
#if (FX_CORE_MODE == FX_CORE_USER_MODE)
#include "FxIrpUm.hpp"
#else if ((FX_CORE_MODE)==(FX_CORE_KERNEL_MODE))
#include "FxIrpKm.hpp"
#include "fxirpum.hpp"
#elif ((FX_CORE_MODE)==(FX_CORE_KERNEL_MODE))
#include "fxirpkm.hpp"
#endif
#include "FxTransactionedList.hpp"
#include "fxtransactionedlist.hpp"
#include "FxCollection.hpp"
#include "FxDeviceInitShared.hpp"
#include "FxDeviceToMxInterface.hpp"
#include "FxRequestContext.hpp"
#include "FxRequestContextTypes.h"
#include "FxRequestBase.hpp"
#include "FxRequestBuffer.hpp"
#include "IfxMemory.hpp"
#include "FxIoTarget.hpp"
#include "FxIoTargetRemote.hpp"
#include "FxIoTargetSelf.hpp"
#include "fxcollection.hpp"
#include "fxdeviceinitshared.hpp"
#include "fxdevicetomxinterface.hpp"
#include "fxrequestcontext.hpp"
#include "fxrequestcontexttypes.h"
#include "fxrequestbase.hpp"
#include "fxrequestbuffer.hpp"
#include "ifxmemory.hpp"
#include "fxiotarget.hpp"
#include "fxiotargetremote.hpp"
#include "fxiotargetself.hpp"

View file

@ -21,7 +21,7 @@ Revision History:
--*/
#include "..\FxTargetsShared.hpp"
#include "../fxtargetsshared.hpp"
extern "C" {
#if defined(EVENT_TRACING)
@ -308,12 +308,10 @@ FxIoTarget::GotoStartState(
__in BOOLEAN Lock
)
{
FxRequestBase* pRequest;
NTSTATUS status;
KIRQL irql;
irql = PASSIVE_LEVEL;
pRequest = NULL;
ADDREF(START_TAG);
@ -1110,7 +1108,7 @@ FxIoTarget::QueryInterface(
*Params->Object = (FxIoTarget*) this;
break;
default:
return __super::QueryInterface(Params);
return FxNonPagedObject::QueryInterface(Params); // __super call
}
return STATUS_SUCCESS;

View file

@ -20,10 +20,10 @@ Revision History:
--*/
#include "..\FxTargetsShared.hpp"
#include "../fxtargetsshared.hpp"
extern "C" {
#include "FxIoTargetAPI.tmh"
// #include "FxIoTargetAPI.tmh"
}
//
@ -34,6 +34,7 @@ extern "C" {
_Must_inspect_result_
__drv_maxIRQL(DISPATCH_LEVEL)
NTSTATUS
STDCALL
WDFEXPORT(WdfIoTargetStart)(
__in
PWDF_DRIVER_GLOBALS DriverGlobals,
@ -69,6 +70,7 @@ Return Value:
__drv_when(Action == 3, __drv_maxIRQL(DISPATCH_LEVEL))
__drv_when(Action == 0 || Action == 1 || Action == 2, __drv_maxIRQL(PASSIVE_LEVEL))
VOID
STDCALL
WDFEXPORT(WdfIoTargetStop)(
__in
PWDF_DRIVER_GLOBALS DriverGlobals,
@ -128,6 +130,7 @@ Return Value:
__drv_when(Action == 2, __drv_maxIRQL(DISPATCH_LEVEL))
__drv_when(Action == 0 || Action == 1, __drv_maxIRQL(PASSIVE_LEVEL))
VOID
STDCALL
WDFEXPORT(WdfIoTargetPurge)(
__in
PWDF_DRIVER_GLOBALS DriverGlobals,
@ -185,6 +188,7 @@ Return Value:
__drv_maxIRQL(DISPATCH_LEVEL)
WDF_IO_TARGET_STATE
STDCALL
WDFEXPORT(WdfIoTargetGetState)(
__in
PWDF_DRIVER_GLOBALS DriverGlobals,
@ -364,6 +368,7 @@ Return Value:
_Must_inspect_result_
__drv_maxIRQL(PASSIVE_LEVEL)
NTSTATUS
STDCALL
WDFEXPORT(WdfIoTargetCreate)(
__in
PWDF_DRIVER_GLOBALS DriverGlobals,
@ -437,6 +442,7 @@ Return Value:
_Must_inspect_result_
__drv_maxIRQL(PASSIVE_LEVEL)
NTSTATUS
STDCALL
WDFEXPORT(WdfIoTargetOpen)(
__in
PWDF_DRIVER_GLOBALS DriverGlobals,
@ -543,6 +549,7 @@ Return Value:
__drv_maxIRQL(PASSIVE_LEVEL)
VOID
STDCALL
WDFEXPORT(WdfIoTargetCloseForQueryRemove)(
__in
PWDF_DRIVER_GLOBALS DriverGlobals,
@ -591,6 +598,7 @@ Return Value:
__drv_maxIRQL(PASSIVE_LEVEL)
VOID
STDCALL
WDFEXPORT(WdfIoTargetClose)(
__in
PWDF_DRIVER_GLOBALS DriverGlobals,
@ -636,6 +644,7 @@ Return Value:
__drv_maxIRQL(DISPATCH_LEVEL)
WDFDEVICE
STDCALL
WDFEXPORT(WdfIoTargetGetDevice)(
__in
PWDF_DRIVER_GLOBALS DriverGlobals,
@ -943,6 +952,7 @@ Return Value:
_Must_inspect_result_
__drv_maxIRQL(PASSIVE_LEVEL)
NTSTATUS
STDCALL
WDFEXPORT(WdfIoTargetSendReadSynchronously)(
__in
PWDF_DRIVER_GLOBALS DriverGlobals,
@ -975,6 +985,7 @@ WDFEXPORT(WdfIoTargetSendReadSynchronously)(
_Must_inspect_result_
__drv_maxIRQL(DISPATCH_LEVEL)
NTSTATUS
STDCALL
WDFEXPORT(WdfIoTargetFormatRequestForRead)(
__in
PWDF_DRIVER_GLOBALS DriverGlobals,
@ -1005,6 +1016,7 @@ WDFEXPORT(WdfIoTargetFormatRequestForRead)(
_Must_inspect_result_
__drv_maxIRQL(PASSIVE_LEVEL)
NTSTATUS
STDCALL
WDFEXPORT(WdfIoTargetSendWriteSynchronously)(
__in
PWDF_DRIVER_GLOBALS DriverGlobals,
@ -1037,6 +1049,7 @@ WDFEXPORT(WdfIoTargetSendWriteSynchronously)(
_Must_inspect_result_
__drv_maxIRQL(DISPATCH_LEVEL)
NTSTATUS
STDCALL
WDFEXPORT(WdfIoTargetFormatRequestForWrite)(
__in
PWDF_DRIVER_GLOBALS DriverGlobals,
@ -1386,6 +1399,7 @@ Return Value:
_Must_inspect_result_
__drv_maxIRQL(PASSIVE_LEVEL)
NTSTATUS
STDCALL
WDFEXPORT(WdfIoTargetSendIoctlSynchronously)(
__in
PWDF_DRIVER_GLOBALS DriverGlobals,
@ -1423,6 +1437,7 @@ WDFEXPORT(WdfIoTargetSendIoctlSynchronously)(
_Must_inspect_result_
__drv_maxIRQL(DISPATCH_LEVEL)
NTSTATUS
STDCALL
WDFEXPORT(WdfIoTargetFormatRequestForIoctl)(
__in
PWDF_DRIVER_GLOBALS DriverGlobals,
@ -1458,6 +1473,7 @@ WDFEXPORT(WdfIoTargetFormatRequestForIoctl)(
_Must_inspect_result_
__drv_maxIRQL(PASSIVE_LEVEL)
NTSTATUS
STDCALL
WDFEXPORT(WdfIoTargetSendInternalIoctlSynchronously)(
__in
PWDF_DRIVER_GLOBALS DriverGlobals,
@ -1495,6 +1511,7 @@ WDFEXPORT(WdfIoTargetSendInternalIoctlSynchronously)(
_Must_inspect_result_
__drv_maxIRQL(DISPATCH_LEVEL)
NTSTATUS
STDCALL
WDFEXPORT(WdfIoTargetFormatRequestForInternalIoctl)(
__in
PWDF_DRIVER_GLOBALS DriverGlobals,
@ -1530,6 +1547,7 @@ WDFEXPORT(WdfIoTargetFormatRequestForInternalIoctl)(
_Must_inspect_result_
__drv_maxIRQL(PASSIVE_LEVEL)
NTSTATUS
STDCALL
WDFEXPORT(WdfIoTargetSendInternalIoctlOthersSynchronously)(
__in
PWDF_DRIVER_GLOBALS DriverGlobals,
@ -1708,6 +1726,7 @@ Return Value:
_Must_inspect_result_
__drv_maxIRQL(DISPATCH_LEVEL)
NTSTATUS
STDCALL
WDFEXPORT(WdfIoTargetFormatRequestForInternalIoctlOthers)(
__in
PWDF_DRIVER_GLOBALS DriverGlobals,
@ -1847,6 +1866,7 @@ Return Value:
_Must_inspect_result_
_IRQL_requires_max_(DISPATCH_LEVEL)
NTSTATUS
STDCALL
WDFEXPORT(WdfIoTargetSelfAssignDefaultIoQueue)(
_In_
PWDF_DRIVER_GLOBALS DriverGlobals,
@ -1964,6 +1984,7 @@ Returns:
__drv_maxIRQL(DISPATCH_LEVEL)
HANDLE
STDCALL
WDFEXPORT(WdfIoTargetWdmGetTargetFileHandle)(
__in
PWDF_DRIVER_GLOBALS DriverGlobals,

View file

@ -18,10 +18,10 @@ Revision History:
--*/
#include "..\FxTargetsShared.hpp"
#include "../fxtargetsshared.hpp"
extern "C" {
#include "FxIoTargetRemote.tmh"
// #include "FxIoTargetRemote.tmh"
}
#include <initguid.h>
@ -55,7 +55,7 @@ FxIoTargetRemote::FxIoTargetRemote(
#if (FX_CORE_MODE == FX_CORE_KERNEL_MODE)
m_TargetNotifyHandle = NULL;
#else (FX_CORE_MODE == FX_CORE_USER_MODE)
#elif (FX_CORE_MODE == FX_CORE_USER_MODE)
m_TargetNotifyHandle = WUDF_TARGET_CONTEXT_INVALID;
m_pIoDispatcher = NULL;
@ -173,7 +173,7 @@ FxIoTargetRemote::InitRemote(
//
// do the base class mode-specific initialization
//
status = __super::InitModeSpecific(Device);
status = FxIoTarget::InitModeSpecific(Device); // __super call
if (!NT_SUCCESS(status)) {
return status;
}
@ -757,7 +757,7 @@ FxIoTargetRemote::ClearTargetPointers(
// canceled or completing. When we receive either of those notifications,
// m_TargetNotifyHandle will be freed then.
//
__super::ClearTargetPointers();
FxIoTarget::ClearTargetPointers(); // __super call
}
VOID

View file

@ -24,7 +24,7 @@ Revision History:
--*/
#include "..\FxTargetsShared.hpp"
#include "../fxtargetsshared.hpp"
extern "C" {
#if defined(EVENT_TRACING)

View file

@ -20,10 +20,10 @@ Revision History:
--*/
#include "..\..\FxTargetsShared.hpp"
#include "../../fxtargetsshared.hpp"
extern "C" {
#include "FxIoTargetAPIKm.tmh"
// #include "FxIoTargetAPIKm.tmh"
}
//
@ -33,6 +33,7 @@ extern "C" {
__drv_maxIRQL(DISPATCH_LEVEL)
PDEVICE_OBJECT
STDCALL
WDFEXPORT(WdfIoTargetWdmGetTargetDeviceObject)(
__in
PWDF_DRIVER_GLOBALS DriverGlobals,
@ -76,6 +77,7 @@ Return Value:
__drv_maxIRQL(DISPATCH_LEVEL)
PDEVICE_OBJECT
STDCALL
WDFEXPORT(WdfIoTargetWdmGetTargetPhysicalDevice)(
__in
PWDF_DRIVER_GLOBALS DriverGlobals,
@ -121,6 +123,7 @@ Return Value:
__drv_maxIRQL(DISPATCH_LEVEL)
PFILE_OBJECT
STDCALL
WDFEXPORT(WdfIoTargetWdmGetTargetFileObject)(
__in
PWDF_DRIVER_GLOBALS DriverGlobals,
@ -165,6 +168,7 @@ Return Value:
__drv_maxIRQL(PASSIVE_LEVEL)
_Must_inspect_result_
NTSTATUS
STDCALL
WDFEXPORT(WdfIoTargetQueryForInterface)(
__in
PWDF_DRIVER_GLOBALS DriverGlobals,
@ -242,6 +246,7 @@ Return Value:
_Must_inspect_result_
__drv_maxIRQL(PASSIVE_LEVEL)
NTSTATUS
STDCALL
WDFEXPORT(WdfIoTargetQueryTargetProperty)(
__in
PWDF_DRIVER_GLOBALS DriverGlobals,
@ -254,7 +259,7 @@ WDFEXPORT(WdfIoTargetQueryTargetProperty)(
__drv_when(BufferLength != 0, __out_bcount_part_opt(BufferLength, *ResultLength))
__drv_when(BufferLength == 0, __out_opt)
PVOID PropertyBuffer,
__deref_out_range(<=,BufferLength)
__deref_out_range(<=,BufferLength)
PULONG ResultLength
)
/*++
@ -333,6 +338,7 @@ _Must_inspect_result_
__drv_maxIRQL(PASSIVE_LEVEL)
WDFAPI
NTSTATUS
STDCALL
WDFEXPORT(WdfIoTargetAllocAndQueryTargetProperty)(
__in
PWDF_DRIVER_GLOBALS DriverGlobals,

View file

@ -21,7 +21,7 @@ Revision History:
--*/
#include "..\..\FxTargetsShared.hpp"
#include "../../fxtargetsshared.hpp"
extern "C" {
#if defined(EVENT_TRACING)

View file

@ -18,10 +18,10 @@ Revision History:
--*/
#include "..\..\FxTargetsShared.hpp"
#include "../../fxtargetsshared.hpp"
extern "C" {
#include "FxIoTargetRemoteKm.tmh"
// #include "FxIoTargetRemoteKm.tmh"
}
#include <initguid.h>
@ -48,7 +48,7 @@ FxIoTargetRemote::_PlugPlayNotification(
// If that is the case, we need to be able to return and deref the object until
// we are done.
//
pThis->ADDREF(_PlugPlayNotification);
pThis->ADDREF((PVOID)_PlugPlayNotification);
pFxDriverGlobals = pThis->GetDriverGlobals();
@ -133,7 +133,7 @@ FxIoTargetRemote::_PlugPlayNotification(
}
}
pThis->RELEASE(_PlugPlayNotification);
pThis->RELEASE((PVOID)_PlugPlayNotification);
return status;
}

View file

@ -108,7 +108,7 @@ FxUsbDeviceControlContext::CopyParameters(
m_CompletionParams.IoStatus.Information = m_UmUrb.UmUrbControlTransfer.TransferBufferLength;
m_UsbParameters.Parameters.DeviceControlTransfer.Length = m_UmUrb.UmUrbControlTransfer.TransferBufferLength;
#endif
__super::CopyParameters(Request);
FxUsbRequestContext::CopyParameters(Request); // __super call
}
VOID
@ -131,7 +131,7 @@ FxUsbDeviceControlContext::ReleaseAndRestore(
m_PartialMdl = NULL;
}
__super::ReleaseAndRestore(Request);
FxUsbRequestContext::ReleaseAndRestore(Request); // __super call
}
USBD_STATUS
@ -262,7 +262,7 @@ FxUsbDeviceStringContext::CopyParameters(
}
}
__super::CopyParameters(Request);
FxUsbRequestContext::CopyParameters(Request); // __super call
}
VOID
@ -365,7 +365,7 @@ FxUsbUrb::Dispose(
m_pBuffer = NULL;
m_USBDHandle = NULL;
return __super::Dispose();
return FxMemoryBufferPreallocated::Dispose(); // __super call
}
FxUsbDevice::FxUsbDevice(
@ -429,7 +429,7 @@ FxUsbDevice::Dispose(
}
#endif
return __super::Dispose();
return FxIoTarget::Dispose(); // __super call
}
FxUsbDevice::~FxUsbDevice()
@ -2114,7 +2114,7 @@ FxUsbDevice::CancelSentIo(
}
}
}
__super::CancelSentIo();
FxIoTarget::CancelSentIo(); // __super call
}
__checkReturn

View file

@ -876,7 +876,7 @@ FxUsbPipeTransferContext::ReleaseAndRestore(
m_PartialMdl = NULL;
}
#endif
__super::ReleaseAndRestore(Request);
FxUsbRequestContext::ReleaseAndRestore(Request); // __super call
}
VOID
@ -896,7 +896,7 @@ FxUsbPipeTransferContext::CopyParameters(
Parameters.PipeWrite.Length));
m_UsbParameters.Parameters.PipeRead.Length = GetUrbTransferLength();
__super::CopyParameters(Request);
FxUsbRequestContext::CopyParameters(Request); // __super call
}
VOID
@ -957,7 +957,7 @@ FxUsbUrbContext::ReleaseAndRestore(
)
{
m_pUrb = NULL;
__super::ReleaseAndRestore(Request);
FxUsbRequestContext::ReleaseAndRestore(Request); // __super call
}
@ -1106,7 +1106,7 @@ FxUsbPipe::Dispose()
//
// Call base class: callbacks, terminates I/Os, etc.
//
callCleanup = __super::Dispose();
callCleanup = FxIoTarget::Dispose(); // __super call
//
// Don't need the reader anymore. The reader is deleted after calling the
@ -1245,7 +1245,7 @@ FxUsbPipe::GotoStopState(
Action = WdfIoTargetCancelSentIo;
}
__super::GotoStopState(Action, SentRequestListHead, Wait, FALSE);
FxIoTarget::GotoStopState(Action, SentRequestListHead, Wait, FALSE); // __super call
if (m_Reader != NULL) {
//
@ -1323,7 +1323,7 @@ FxUsbPipe::GotoPurgeState(
Action = WdfIoTargetPurgeIoAndWait;
}
__super::GotoPurgeState(Action,
FxIoTarget::GotoPurgeState(Action, // __super call
PendedRequestListHead,
SentRequestListHead,
Wait,
@ -1395,7 +1395,7 @@ FxUsbPipe::GotoRemoveState(
}
}
__super::GotoRemoveState(NewState,
FxIoTarget::GotoRemoveState(NewState, // __super call
PendedRequestListHead,
SentRequestListHead,
FALSE,
@ -1455,7 +1455,7 @@ FxUsbPipe::WaitForSentIoToComplete(
//
// Finally, let the parent class wait for all I/O to complete
//
__super::WaitForSentIoToComplete();
FxIoTarget::WaitForSentIoToComplete(); // __super call
}
_Must_inspect_result_

View file

@ -698,7 +698,7 @@ FxUsbDeviceControlContext::StoreAndReferenceMemory(
m_Urb->Hdr.Function = URB_FUNCTION_CONTROL_TRANSFER;
m_Urb->Hdr.Length = sizeof(*m_Urb);
__super::StoreAndReferenceMemory(Buffer);
FxUsbRequestContext::StoreAndReferenceMemory(Buffer); // __super call
//
// Set the values using what is stored in the buffer

View file

@ -32,7 +32,7 @@ Return Value:
m_Urb->Hdr.Function = URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER;
m_Urb->Hdr.Length = sizeof(*m_Urb);
__super::StoreAndReferenceMemory(Buffer);
FxUsbRequestContext::StoreAndReferenceMemory(Buffer); // __super call
Buffer->AssignValues(&m_Urb->TransferBuffer,
&m_Urb->TransferBufferMDL,

View file

@ -562,7 +562,7 @@ FxUsbDeviceControlContext::StoreAndReferenceMemory(
{
SetUsbType(WdfUsbRequestTypeDeviceControlTransfer);
__super::StoreAndReferenceMemory(Buffer);
FxUsbRequestContext::StoreAndReferenceMemory(Buffer); // __super call
//
// Convert WDF_USB_CONTROL_SETUP_PACKET to WINUSB_SETUP_PACKET

View file

@ -51,7 +51,7 @@ Return Value:
m_UmUrb.UmUrbHeader.Function = UMURB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER;
m_UmUrb.UmUrbHeader.Length = sizeof(_UMURB_BULK_OR_INTERRUPT_TRANSFER);
__super::StoreAndReferenceMemory(Buffer);
FxUsbRequestContext::StoreAndReferenceMemory(Buffer); // __super call
Buffer->AssignValues(&m_UmUrb.UmUrbBulkOrInterruptTransfer.TransferBuffer,
NULL,