ReactOS  0.4.14-dev-583-g2a1ba2c
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. More...
 
_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 }
FREEOBJPROC pFreeProc
Definition: winddi.h:410
DRIVEROBJ drvobj
Definition: driverobj.h:7
#define NT_VERIFY(exp)
Definition: rtlfuncs.h:3289

◆ 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 }
DHPDEV dhpdev
Definition: pdevobj.h:121
BASEOBJECT baseobj
Definition: driverobj.h:6
FREEOBJPROC pFreeProc
Definition: winddi.h:410
DRIVEROBJ drvobj
Definition: driverobj.h:7
#define DRIVEROBJ_UnlockObject(pdo)
Definition: driverobj.h:18
HGDIOBJ hHmgr(VOID)
Definition: baseobj.hpp:95
smooth NULL
Definition: ftsmooth.c:416
DHPDEV dhpdev
Definition: winddi.h:412
#define DRIVEROBJ_AllocObjectWithHandle()
Definition: driverobj.h:17
PVOID pvObj
Definition: winddi.h:409
_In_ HDEV hdev
Definition: winddi.h:3449
HDEV hdev
Definition: winddi.h:411

◆ 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 }
#define TRUE
Definition: types.h:120
BASEOBJECT baseobj
Definition: driverobj.h:6
FREEOBJPROC pFreeProc
Definition: winddi.h:410
DRIVEROBJ drvobj
Definition: driverobj.h:7
#define DRIVEROBJ_UnlockObject(pdo)
Definition: driverobj.h:18
smooth NULL
Definition: ftsmooth.c:416
VOID NTAPI GDIOBJ_vDeleteObject(POBJ pobj)
Definition: gdiobj.c:1108
BOOLEAN bLocked
Definition: Mke2fs.c:19
FORCEINLINE PEDRIVEROBJ DRIVEROBJ_TryLockObject(HDRVOBJ hdo)
Definition: driverobj.h:22

◆ 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->drvobj;
124 }
DRIVEROBJ drvobj
Definition: driverobj.h:7
FORCEINLINE PEDRIVEROBJ DRIVEROBJ_TryLockObject(HDRVOBJ hdo)
Definition: driverobj.h:22

◆ EngUnlockDriverObj()

BOOL APIENTRY EngUnlockDriverObj ( _In_ _Post_ptr_invalid_ HDRVOBJ  hdo)

Definition at line 129 of file driverobj.c.

131 {
132  PEDRIVEROBJ pedo;
133  ULONG cLocks;
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 */
144  cLocks = pedo->baseobj.cExclusiveLock;
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 }
#define TRUE
Definition: types.h:120
BASEOBJECT baseobj
Definition: driverobj.h:6
static LONG cLocks
Definition: compobj.c:119
USHORT cExclusiveLock
Definition: gdiobj.h:45
#define DRIVEROBJ_UnlockObject(pdo)
Definition: driverobj.h:18
unsigned int ULONG
Definition: retypes.h:1
FORCEINLINE PEDRIVEROBJ DRIVEROBJ_TryLockObject(HDRVOBJ hdo)
Definition: driverobj.h:22