18a978a17SVictor Perevertkin 28a978a17SVictor Perevertkin /*++ 38a978a17SVictor Perevertkin 48a978a17SVictor Perevertkin Copyright (c) Microsoft. All rights reserved. 58a978a17SVictor Perevertkin 68a978a17SVictor Perevertkin Module Name: 78a978a17SVictor Perevertkin 88a978a17SVictor Perevertkin FxUserObject.hpp 98a978a17SVictor Perevertkin 108a978a17SVictor Perevertkin Abstract: 118a978a17SVictor Perevertkin 128a978a17SVictor Perevertkin This module implements the user object that device 138a978a17SVictor Perevertkin driver writers can use to take advantage of the 148a978a17SVictor Perevertkin driver frameworks infrastructure. 158a978a17SVictor Perevertkin 168a978a17SVictor Perevertkin Author: 178a978a17SVictor Perevertkin 188a978a17SVictor Perevertkin 198a978a17SVictor Perevertkin 208a978a17SVictor Perevertkin 218a978a17SVictor Perevertkin Environment: 228a978a17SVictor Perevertkin 238a978a17SVictor Perevertkin Both kernel and user mode 248a978a17SVictor Perevertkin 258a978a17SVictor Perevertkin Revision History: 268a978a17SVictor Perevertkin 278a978a17SVictor Perevertkin 288a978a17SVictor Perevertkin Made mode agnostic 298a978a17SVictor Perevertkin 308a978a17SVictor Perevertkin --*/ 318a978a17SVictor Perevertkin 328a978a17SVictor Perevertkin #ifndef _FXUSEROBJECT_H_ 338a978a17SVictor Perevertkin #define _FXUSEROBJECT_H_ 348a978a17SVictor Perevertkin 358a978a17SVictor Perevertkin class FxUserObject : public FxNonPagedObject { 368a978a17SVictor Perevertkin 378a978a17SVictor Perevertkin private: 388a978a17SVictor Perevertkin 398a978a17SVictor Perevertkin public: 408a978a17SVictor Perevertkin 418a978a17SVictor Perevertkin static 428a978a17SVictor Perevertkin _Must_inspect_result_ 438a978a17SVictor Perevertkin NTSTATUS 448a978a17SVictor Perevertkin _Create( 458a978a17SVictor Perevertkin __in PFX_DRIVER_GLOBALS FxDriverGlobals, 468a978a17SVictor Perevertkin __in_opt PWDF_OBJECT_ATTRIBUTES Attributes, 478a978a17SVictor Perevertkin __out FxUserObject** Object 488a978a17SVictor Perevertkin ); 498a978a17SVictor Perevertkin 508a978a17SVictor Perevertkin FxUserObject( 518a978a17SVictor Perevertkin __in PFX_DRIVER_GLOBALS FxDriverGlobals 528a978a17SVictor Perevertkin ); 538a978a17SVictor Perevertkin 548a978a17SVictor Perevertkin virtual 558a978a17SVictor Perevertkin NTSTATUS QueryInterface(__in FxQueryInterfaceParams * Params)568a978a17SVictor Perevertkin QueryInterface( 578a978a17SVictor Perevertkin __in FxQueryInterfaceParams* Params 588a978a17SVictor Perevertkin ) 598a978a17SVictor Perevertkin { 608a978a17SVictor Perevertkin switch (Params->Type) { 618a978a17SVictor Perevertkin case FX_TYPE_USEROBJECT: 628a978a17SVictor Perevertkin *Params->Object = (FxUserObject*) this; 638a978a17SVictor Perevertkin break; 648a978a17SVictor Perevertkin 658a978a17SVictor Perevertkin default: 66*1f377076SVictor Perevertkin return FxNonPagedObject::QueryInterface(Params); // __super call 678a978a17SVictor Perevertkin } 688a978a17SVictor Perevertkin 698a978a17SVictor Perevertkin return STATUS_SUCCESS; 708a978a17SVictor Perevertkin } 718a978a17SVictor Perevertkin 728a978a17SVictor Perevertkin __inline 738a978a17SVictor Perevertkin WDFOBJECT GetHandle(VOID)748a978a17SVictor Perevertkin GetHandle( 758a978a17SVictor Perevertkin VOID 768a978a17SVictor Perevertkin ) 778a978a17SVictor Perevertkin { 788a978a17SVictor Perevertkin return (WDFOBJECT) GetObjectHandle(); 798a978a17SVictor Perevertkin } 808a978a17SVictor Perevertkin 818a978a17SVictor Perevertkin private: 828a978a17SVictor Perevertkin 838a978a17SVictor Perevertkin #ifdef INLINE_WRAPPER_ALLOCATION 848a978a17SVictor Perevertkin #if (FX_CORE_MODE==FX_CORE_USER_MODE) 858a978a17SVictor Perevertkin static 868a978a17SVictor Perevertkin USHORT 878a978a17SVictor Perevertkin GetWrapperSize( 888a978a17SVictor Perevertkin VOID 898a978a17SVictor Perevertkin ); 908a978a17SVictor Perevertkin 918a978a17SVictor Perevertkin public: 928a978a17SVictor Perevertkin FORCEINLINE 938a978a17SVictor Perevertkin PVOID GetCOMWrapper(VOID)948a978a17SVictor Perevertkin GetCOMWrapper( 958a978a17SVictor Perevertkin VOID 968a978a17SVictor Perevertkin ) 978a978a17SVictor Perevertkin { 988a978a17SVictor Perevertkin PBYTE ptr = (PBYTE) this; 998a978a17SVictor Perevertkin return (ptr + (USHORT) WDF_ALIGN_SIZE_UP(sizeof(*this), MEMORY_ALLOCATION_ALIGNMENT)); 1008a978a17SVictor Perevertkin } 1018a978a17SVictor Perevertkin #endif 1028a978a17SVictor Perevertkin #endif 1038a978a17SVictor Perevertkin }; 1048a978a17SVictor Perevertkin 1058a978a17SVictor Perevertkin #endif // _FXUSEROBJECT_H_ 1068a978a17SVictor Perevertkin 107