mirror of
https://github.com/reactos/reactos.git
synced 2025-06-13 07:28:32 +00:00
[WDF] Add Windows Driver Framework files
Takern from Microsoft GitHub repo:
d9c6040fe9
Licensed under MIT
This commit is contained in:
parent
545df81502
commit
8a978a179f
475 changed files with 285099 additions and 0 deletions
106
sdk/lib/drivers/wdf/shared/object/fxuserobject.cpp
Normal file
106
sdk/lib/drivers/wdf/shared/object/fxuserobject.cpp
Normal file
|
@ -0,0 +1,106 @@
|
|||
/*++
|
||||
|
||||
Copyright (c) Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
FxUserObject.cpp
|
||||
|
||||
Abstract:
|
||||
|
||||
This module implements the user object that device
|
||||
driver writers can use to take advantage of the
|
||||
driver frameworks infrastructure.
|
||||
|
||||
Author:
|
||||
|
||||
|
||||
|
||||
|
||||
Environment:
|
||||
|
||||
Both kernel and user mode
|
||||
|
||||
Revision History:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
--*/
|
||||
|
||||
#include "fxobjectpch.hpp"
|
||||
|
||||
#include "FxUserObject.hpp"
|
||||
|
||||
// Tracing support
|
||||
extern "C" {
|
||||
#if defined(EVENT_TRACING)
|
||||
#include "FxUserObject.tmh"
|
||||
#endif
|
||||
}
|
||||
|
||||
_Must_inspect_result_
|
||||
NTSTATUS
|
||||
FxUserObject::_Create(
|
||||
__in PFX_DRIVER_GLOBALS FxDriverGlobals,
|
||||
__in_opt PWDF_OBJECT_ATTRIBUTES Attributes,
|
||||
__out FxUserObject** pUserObject
|
||||
)
|
||||
{
|
||||
FxUserObject* pObject = NULL;
|
||||
NTSTATUS status;
|
||||
USHORT wrapperSize = 0;
|
||||
WDFOBJECT handle;
|
||||
|
||||
#ifdef INLINE_WRAPPER_ALLOCATION
|
||||
#if FX_CORE_MODE==FX_CORE_USER_MODE
|
||||
wrapperSize = FxUserObject::GetWrapperSize();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
pObject = new(FxDriverGlobals, Attributes, wrapperSize)
|
||||
FxUserObject(FxDriverGlobals);
|
||||
|
||||
|
||||
if (pObject == NULL) {
|
||||
DoTraceLevelMessage(FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGOBJECT,
|
||||
"Memory allocation failed");
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
|
||||
status = pObject->Commit(Attributes, &handle);
|
||||
|
||||
if (!NT_SUCCESS(status)) {
|
||||
DoTraceLevelMessage(FxDriverGlobals, TRACE_LEVEL_ERROR,
|
||||
TRACINGOBJECT,
|
||||
"FxObject::Commit failed %!STATUS!", status);
|
||||
}
|
||||
|
||||
if (NT_SUCCESS(status)) {
|
||||
*pUserObject = pObject;
|
||||
}
|
||||
else {
|
||||
pObject->DeleteFromFailedCreate();
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
//
|
||||
// Public constructors
|
||||
//
|
||||
|
||||
FxUserObject::FxUserObject(
|
||||
__in PFX_DRIVER_GLOBALS FxDriverGlobals
|
||||
) :
|
||||
#ifdef INLINE_WRAPPER_ALLOCATION
|
||||
FxNonPagedObject(FX_TYPE_USEROBJECT, sizeof(FxUserObject) + GetWrapperSize(), FxDriverGlobals)
|
||||
#else
|
||||
FxNonPagedObject(FX_TYPE_USEROBJECT, sizeof(FxUserObject), FxDriverGlobals)
|
||||
#endif
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue