ReactOS 0.4.15-dev-7842-g558ab78
driverobj.c File Reference
#include <win32k.h>
#include <debug.h>
Include dependency graph for driverobj.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

VOID NTAPI DRIVEROBJ_vCleanup (PVOID pObject)
 DRIVEROBJ cleanup function.
 
_Must_inspect_result_ HDRVOBJ APIENTRY EngCreateDriverObj (_In_ PVOID pvObj, _In_opt_ FREEOBJPROC pFreeObjProc, _In_ HDEV hdev)
 
BOOL APIENTRY EngDeleteDriverObj (_In_ _Post_ptr_invalid_ HDRVOBJ hdo, _In_ BOOL bCallBack, _In_ BOOL bLocked)
 
PDRIVEROBJ APIENTRY EngLockDriverObj (_In_ HDRVOBJ hdo)
 
BOOL APIENTRY EngUnlockDriverObj (_In_ _Post_ptr_invalid_ HDRVOBJ hdo)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Includes

Definition at line 13 of file driverobj.c.

Function Documentation

◆ DRIVEROBJ_vCleanup()

VOID NTAPI DRIVEROBJ_vCleanup ( PVOID  pObject)

DRIVEROBJ cleanup function.

Internal interface

Definition at line 24 of file driverobj.c.

25{
26 PEDRIVEROBJ pedo = pObject;
27 FREEOBJPROC pFreeProc;
28
29 pFreeProc = pedo->drvobj.pFreeProc;
30 if (pFreeProc)
31 {
32 NT_VERIFY(pFreeProc(&pedo->drvobj));
33 }
34}
FxObject * pObject
FREEOBJPROC pFreeProc
Definition: winddi.h:410
DRIVEROBJ drvobj
Definition: driverobj.h:7
#define NT_VERIFY(exp)
Definition: rtlfuncs.h:3287

◆ EngCreateDriverObj()

_Must_inspect_result_ HDRVOBJ APIENTRY EngCreateDriverObj ( _In_ PVOID  pvObj,
_In_opt_ FREEOBJPROC  pFreeObjProc,
_In_ HDEV  hdev 
)

Public interface

Definition at line 41 of file driverobj.c.

45{
46 PEDRIVEROBJ pedo;
47 HDRVOBJ hdo;
48 PDEVOBJ *ppdev = (PDEVOBJ*)hdev;
49
50 /* Allocate a new DRIVEROBJ */
52 if (!pedo)
53 {
54 return NULL;
55 }
56 hdo = pedo->baseobj.hHmgr;
57
58 /* Fill in fields */
59 pedo->drvobj.pvObj = pvObj;
60 pedo->drvobj.pFreeProc = pFreeObjProc;
61 pedo->drvobj.hdev = hdev;
62 pedo->drvobj.dhpdev = ppdev->dhpdev;
63
64 /* Unlock the object */
66
67 /* Return the handle */
68 return hdo;
69}
HGDIOBJ hHmgr(VOID)
Definition: baseobj.hpp:95
#define NULL
Definition: types.h:112
#define DRIVEROBJ_AllocObjectWithHandle()
Definition: driverobj.h:17
#define DRIVEROBJ_UnlockObject(pdo)
Definition: driverobj.h:18
PVOID pvObj
Definition: winddi.h:409
HDEV hdev
Definition: winddi.h:411
DHPDEV dhpdev
Definition: winddi.h:412
BASEOBJECT baseobj
Definition: driverobj.h:6
DHPDEV dhpdev
Definition: pdevobj.h:120
_In_ HDEV hdev
Definition: winddi.h:3449

◆ EngDeleteDriverObj()

BOOL APIENTRY EngDeleteDriverObj ( _In_ _Post_ptr_invalid_ HDRVOBJ  hdo,
_In_ BOOL  bCallBack,
_In_ BOOL  bLocked 
)

Definition at line 74 of file driverobj.c.

78{
79 PEDRIVEROBJ pedo;
80
81 /* Lock the object */
82 pedo = DRIVEROBJ_TryLockObject(hdo);
83 if (!pedo)
84 {
85 return FALSE;
86 }
87
88 /* Manually call cleanup callback */
89 if (bCallBack)
90 {
91 if (!pedo->drvobj.pFreeProc(&pedo->drvobj))
92 {
93 /* Callback failed */
95 return FALSE;
96 }
97 }
98
99 /* Prevent cleanup callback from being called again */
100 pedo->drvobj.pFreeProc = NULL;
101
102 /* Unlock if the caller indicates it is locked */
103 if (bLocked)
105
106 /* Now delete the object */
108 return TRUE;
109}
BOOLEAN bLocked
Definition: Mke2fs.c:19
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
FORCEINLINE PEDRIVEROBJ DRIVEROBJ_TryLockObject(HDRVOBJ hdo)
Definition: driverobj.h:22
VOID NTAPI GDIOBJ_vDeleteObject(POBJ pobj)
Definition: gdiobj.c:1111

◆ EngLockDriverObj()

PDRIVEROBJ APIENTRY EngLockDriverObj ( _In_ HDRVOBJ  hdo)

Definition at line 114 of file driverobj.c.

116{
117 PEDRIVEROBJ pedo;
118
119 /* Lock the object */
120 pedo = DRIVEROBJ_TryLockObject(hdo);
121
122 /* Return pointer to the DRIVEROBJ structure */
123 return pedo ? &pedo->drvobj : NULL;
124}

◆ EngUnlockDriverObj()

BOOL APIENTRY EngUnlockDriverObj ( _In_ _Post_ptr_invalid_ HDRVOBJ  hdo)

Definition at line 129 of file driverobj.c.

131{
132 PEDRIVEROBJ pedo;
134
135 /* First lock to get a pointer to the object */
136 pedo = DRIVEROBJ_TryLockObject(hdo);
137 if(!pedo)
138 {
139 /* Object could not be locked, fail. */
140 return FALSE;
141 }
142
143 /* Unlock object */
146
147 /* Check if we still hold a lock */
148 if (cLocks < 2)
149 {
150 /* Object wasn't locked before, fail. */
151 return FALSE;
152 }
153
154 /* Unlock again */
156
157 /* Success */
158 return TRUE;
159}
static LONG cLocks
Definition: compobj.c:119
USHORT cExclusiveLock
Definition: gdiobj.h:45
uint32_t ULONG
Definition: typedefs.h:59