ReactOS 0.4.15-dev-8102-g108db8f
ObType.c File Reference
#include <kmt_test.h>
#include <debug.h>
Include dependency graph for ObType.c:

Go to the source code of this file.

Classes

struct  _MY_OBJECT1
 
struct  _MY_OBJECT2
 
struct  _COUNTS
 

Macros

#define NDEBUG
 
#define CheckObject(Handle, Pointers, Handles)
 
#define NUM_OBTYPES   5
 
#define CheckCounts(OpenCount, CloseCount, DeleteCount, ParseCount, OkayToCloseCount, QueryNameCount)
 
#define SaveCounts(Save)   memcpy(&Save, &Counts, sizeof Counts)
 
#define NUM_OBTYPES2   2
 

Typedefs

typedef struct _MY_OBJECT1 MY_OBJECT1
 
typedef struct _MY_OBJECT1PMY_OBJECT1
 
typedef struct _MY_OBJECT2 MY_OBJECT2
 
typedef struct _MY_OBJECT2PMY_OBJECT2
 
typedef struct _COUNTS COUNTS
 
typedef struct _COUNTSPCOUNTS
 

Functions

static VOID NTAPI DumpProc (IN PVOID Object, IN POB_DUMP_CONTROL DumpControl)
 
static NTSTATUS NTAPI OpenProc (IN OB_OPEN_REASON OpenReason, IN PEPROCESS Process, IN PVOID Object, IN ACCESS_MASK GrantedAccess, IN ULONG HandleCount)
 
static VOID NTAPI CloseProc (IN PEPROCESS Process, IN PVOID Object, IN ACCESS_MASK GrantedAccess, IN ULONG ProcessHandleCount, IN ULONG SystemHandleCount)
 
static VOID NTAPI DeleteProc (IN PVOID Object)
 
static NTSTATUS NTAPI ParseProc (IN PVOID ParseObject, IN PVOID ObjectType, IN OUT PACCESS_STATE AccessState, IN KPROCESSOR_MODE AccessMode, IN ULONG Attributes, IN OUT PUNICODE_STRING CompleteName, IN OUT PUNICODE_STRING RemainingName, IN OUT PVOID Context OPTIONAL, IN PSECURITY_QUALITY_OF_SERVICE SecurityQos OPTIONAL, OUT PVOID *Object)
 
static BOOLEAN NTAPI OkayToCloseProc (IN PEPROCESS Process OPTIONAL, IN PVOID Object, IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
 
static NTSTATUS NTAPI QueryNameProc (IN PVOID Object, IN BOOLEAN HasObjectName, OUT POBJECT_NAME_INFORMATION ObjectNameInfo, IN ULONG Length, OUT PULONG ReturnLength, IN KPROCESSOR_MODE AccessMode)
 
static VOID ObtCreateObjectTypes (VOID)
 
static VOID ObtCreateDirectory (VOID)
 
static VOID ObtCreateObjects (VOID)
 
static VOID ObtClose (BOOLEAN Clean, BOOLEAN AlternativeMethod)
 
static VOID TestObjectType (IN BOOLEAN Clean)
 
 START_TEST (ObType)
 
 START_TEST (ObTypeNoClean)
 
 START_TEST (ObTypeClean)
 

Variables

static POBJECT_TYPE ObTypes [NUM_OBTYPES]
 
static UNICODE_STRING ObTypeName [NUM_OBTYPES]
 
static UNICODE_STRING ObName [NUM_OBTYPES]
 
static OBJECT_TYPE_INITIALIZER ObTypeInitializer [NUM_OBTYPES]
 
static UNICODE_STRING ObDirectoryName
 
static OBJECT_ATTRIBUTES ObDirectoryAttributes
 
static OBJECT_ATTRIBUTES ObAttributes [NUM_OBTYPES]
 
static PVOID ObBody [NUM_OBTYPES]
 
static HANDLE ObHandle1 [NUM_OBTYPES]
 
static HANDLE DirectoryHandle
 
static COUNTS Counts
 

Macro Definition Documentation

◆ CheckCounts

#define CheckCounts (   OpenCount,
  CloseCount,
  DeleteCount,
  ParseCount,
  OkayToCloseCount,
  QueryNameCount 
)
Value:
do \
{ \
ok_eq_uint(Counts.Open, OpenCount); \
ok_eq_uint(Counts.Close, CloseCount); \
ok_eq_uint(Counts.Delete, DeleteCount); \
ok_eq_uint(Counts.Parse, ParseCount); \
ok_eq_uint(Counts.OkayToClose, OkayToCloseCount); \
ok_eq_uint(Counts.QueryName, QueryNameCount); \
} while (0)
static COUNTS Counts
Definition: ObType.c:60
DWORD OpenCount
Definition: legacy.c:25
USHORT QueryName
Definition: ObType.c:58
USHORT Open
Definition: ObType.c:53
USHORT Delete
Definition: ObType.c:55
USHORT OkayToClose
Definition: ObType.c:57
USHORT Parse
Definition: ObType.c:56
USHORT Close
Definition: ObType.c:54

Definition at line 262 of file ObType.c.

◆ CheckObject

#define CheckObject (   Handle,
  Pointers,
  Handles 
)
Value:
do \
{ \
Status = ZwQueryObject(Handle, ObjectBasicInformation, \
&ObjectInfo, sizeof ObjectInfo, NULL); \
ok_eq_hex(Status, STATUS_SUCCESS); \
ok_eq_ulong(ObjectInfo.PointerCount, Pointers); \
ok_eq_ulong(ObjectInfo.HandleCount, Handles); \
} while (0)
@ ObjectBasicInformation
Definition: DriverTester.h:54
#define NULL
Definition: types.h:112
ULONG Handle
Definition: gdb_input.c:15
Status
Definition: gdiplustypes.h:25
#define STATUS_SUCCESS
Definition: shellext.h:65

Definition at line 16 of file ObType.c.

◆ NDEBUG

#define NDEBUG

Definition at line 13 of file ObType.c.

◆ NUM_OBTYPES

#define NUM_OBTYPES   5

Definition at line 26 of file ObType.c.

◆ NUM_OBTYPES2

#define NUM_OBTYPES2   2

Definition at line 276 of file ObType.c.

◆ SaveCounts

#define SaveCounts (   Save)    memcpy(&Save, &Counts, sizeof Counts)

Definition at line 273 of file ObType.c.

Typedef Documentation

◆ COUNTS

◆ MY_OBJECT1

◆ MY_OBJECT2

◆ PCOUNTS

typedef struct _COUNTS * PCOUNTS

◆ PMY_OBJECT1

◆ PMY_OBJECT2

Function Documentation

◆ CloseProc()

static VOID NTAPI CloseProc ( IN PEPROCESS  Process,
IN PVOID  Object,
IN ACCESS_MASK  GrantedAccess,
IN ULONG  ProcessHandleCount,
IN ULONG  SystemHandleCount 
)
static

Definition at line 92 of file ObType.c.

98{
99 DPRINT("CloseProc() 0x%p, ProcessHandleCount %lu, SystemHandleCount %lu, AccessMask 0x%lX\n",
100 Object, ProcessHandleCount, SystemHandleCount, GrantedAccess);
101 ++Counts.Close;
102}
@ ProcessHandleCount
Definition: winternl.h:876
#define DPRINT
Definition: sndvol32.h:73
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
_In_ PSECURITY_SUBJECT_CONTEXT _In_ BOOLEAN _In_ ACCESS_MASK _In_ ACCESS_MASK _Outptr_opt_ PPRIVILEGE_SET _In_ PGENERIC_MAPPING _In_ KPROCESSOR_MODE _Out_ PACCESS_MASK GrantedAccess
Definition: sefuncs.h:20

Referenced by ObtCreateObjectTypes().

◆ DeleteProc()

static VOID NTAPI DeleteProc ( IN PVOID  Object)
static

Definition at line 107 of file ObType.c.

109{
110 DPRINT("DeleteProc() 0x%p\n", Object);
111 ++Counts.Delete;
112}

Referenced by ObtCreateObjectTypes().

◆ DumpProc()

static VOID NTAPI DumpProc ( IN PVOID  Object,
IN POB_DUMP_CONTROL  DumpControl 
)
static

Definition at line 65 of file ObType.c.

68{
69 DPRINT("DumpProc() called\n");
70 ++Counts.Dump;
71}
USHORT Dump
Definition: ObType.c:52

Referenced by ObtCreateObjectTypes().

◆ ObtClose()

static VOID ObtClose ( BOOLEAN  Clean,
BOOLEAN  AlternativeMethod 
)
static

Definition at line 327 of file ObType.c.

330{
332 LONG_PTR Ret;
333 PVOID TypeObject;
334 INT i;
335 UNICODE_STRING ObPathName[NUM_OBTYPES];
337
338 // Close what we have opened and free what we allocated
339 for (i = 0; i < NUM_OBTYPES2; ++i)
340 {
341 if (!skip(ObBody[i] != NULL, "Nothing to dereference\n"))
342 {
343 if (ObHandle1[i]) CheckObject(ObHandle1[i], 3LU, 1LU);
344 Ret = ObReferenceObject(ObBody[i]);
345 if (ObHandle1[i]) CheckObject(ObHandle1[i], 4LU, 1LU);
347 ok_eq_longptr(Ret, (LONG_PTR)2);
348 if (ObHandle1[i]) CheckObject(ObHandle1[i], 3LU, 1LU);
349 ObBody[i] = NULL;
350 }
351 if (!skip(ObHandle1[i] != NULL, "Nothing to close\n"))
352 {
355 ObHandle1[i] = NULL;
356 }
357 }
358
359 if (skip(Clean, "Not cleaning up, as requested. Use ObTypeClean to clean up\n"))
360 return;
361
362 // Now we have to get rid of a directory object
363 // Since it is permanent, we have to firstly make it temporary
364 // and only then kill
365 // (this procedure is described in DDK)
366 if (!skip(DirectoryHandle != NULL, "No directory handle\n"))
367 {
369
373
376 }
377
378 /* we don't delete the object types we created. It makes Windows unstable.
379 * TODO: perhaps make it work in ROS anyway */
380 return;
381 if (!AlternativeMethod)
382 {
383 for (i = 0; i < NUM_OBTYPES; ++i)
384 if (!skip(ObTypes[i] != NULL, "No object type to delete\n"))
385 {
387 ok_eq_longptr(Ret, (LONG_PTR)0);
388 ObTypes[i] = NULL;
389 }
390 }
391 else
392 {
393 for (i = 0; i < NUM_OBTYPES; ++i)
394 {
395 if (!skip(ObTypes[i] != NULL, "No object type to delete\n"))
396 {
397 Status = RtlStringCbPrintfW(Name, sizeof Name, L"\\ObjectTypes\\MyObjectType%d", i);
398 RtlInitUnicodeString(&ObPathName[i], Name);
399 Status = ObReferenceObjectByName(&ObPathName[i], OBJ_CASE_INSENSITIVE, NULL, 0L, NULL, KernelMode, NULL, &TypeObject);
400
401 Ret = ObDereferenceObject(TypeObject);
402 ok_eq_longptr(Ret, (LONG_PTR)2);
403 Ret = ObDereferenceObject(TypeObject);
404 ok_eq_longptr(Ret, (LONG_PTR)1);
405 DPRINT("Reference Name %wZ = %p, ObTypes[%d] = %p\n",
406 ObPathName[i], TypeObject, i, ObTypes[i]);
407 ObTypes[i] = NULL;
408 }
409 }
410 }
411}
#define NUM_OBTYPES2
Definition: ObType.c:276
static HANDLE ObHandle1[NUM_OBTYPES]
Definition: ObType.c:47
#define CheckObject(Handle, Pointers, Handles)
Definition: ObType.c:16
#define NUM_OBTYPES
Definition: ObType.c:26
static PVOID ObBody[NUM_OBTYPES]
Definition: ObType.c:46
static HANDLE DirectoryHandle
Definition: ObType.c:48
static POBJECT_TYPE ObTypes[NUM_OBTYPES]
Definition: ObType.c:39
#define ok_eq_hex(value, expected)
Definition: apitest.h:77
#define ok_eq_longptr(value, expected)
Definition: apitest.h:70
#define skip(...)
Definition: atltest.h:64
LONG NTSTATUS
Definition: precomp.h:26
#define U(x)
Definition: wordpad.c:45
#define MAX_PATH
Definition: compat.h:34
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define KernelMode
Definition: asm.h:34
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
NTSYSAPI NTSTATUS NTAPI ZwMakeTemporaryObject(_In_ HANDLE Handle)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSTRSAFEVAPI RtlStringCbPrintfW(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
Definition: ntstrsafe.h:1173
#define L(x)
Definition: ntvdm.h:50
NTSTATUS NTAPI ObReferenceObjectByName(IN PUNICODE_STRING ObjectPath, IN ULONG Attributes, IN PACCESS_STATE PassedAccessState, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, IN OUT PVOID ParseContext, OUT PVOID *ObjectPtr)
Definition: obref.c:409
int32_t INT
Definition: typedefs.h:58
#define ObDereferenceObject
Definition: obfuncs.h:203
#define ObReferenceObject
Definition: obfuncs.h:204
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by START_TEST(), and TestObjectType().

◆ ObtCreateDirectory()

static VOID ObtCreateDirectory ( VOID  )
static

Definition at line 251 of file ObType.c.

252{
254
255 RtlInitUnicodeString(&ObDirectoryName, L"\\ObtDirectory");
260}
static OBJECT_ATTRIBUTES ObDirectoryAttributes
Definition: ObType.c:44
static UNICODE_STRING ObDirectoryName
Definition: ObType.c:43
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define OBJ_PERMANENT
Definition: winternl.h:226
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
NTSYSAPI NTSTATUS NTAPI ZwCreateDirectoryObject(_Out_ PHANDLE DirectoryHandle, _In_ ACCESS_MASK DesiredAccess, _In_ POBJECT_ATTRIBUTES ObjectAttributes)
#define DELETE
Definition: nt_native.h:57

Referenced by TestObjectType().

◆ ObtCreateObjects()

static VOID ObtCreateObjects ( VOID  )
static

Definition at line 279 of file ObType.c.

280{
284 INT i;
286 ULONG ObjectSize[NUM_OBTYPES2] = { sizeof(MY_OBJECT1), sizeof(MY_OBJECT2) };
287
288 // Create two objects
289 for (i = 0; i < NUM_OBTYPES2; ++i)
290 {
291 ASSERT(sizeof Name[i] == MAX_PATH * sizeof(WCHAR));
292 Status = RtlStringCbPrintfW(Name[i], sizeof Name[i], L"\\ObtDirectory\\MyObject%d", i + 1);
296 }
298
299 for (i = 0; i < NUM_OBTYPES2; ++i)
300 {
303 }
304
306
307 // Insert them
308 for (i = 0; i < NUM_OBTYPES2; ++i)
309 {
311 Status = ObInsertObject(ObBody[i], NULL, Access[i], 0, &ObBody[i], &ObHandle1[i]);
313 ok(ObBody[i] != NULL, "Object body = NULL\n");
314 ok(ObHandle1[i] != NULL, "Handle = NULL\n");
315 CheckObject(ObHandle1[i], 3LU, 1LU);
316 CheckCounts(SaveCounts.Open + 1, SaveCounts.Close, SaveCounts.Delete, SaveCounts.Parse, SaveCounts.OkayToClose, SaveCounts.QueryName);
319 }
320
321 //DPRINT1("%d %d %d %d %d %d %d\n", DumpCount, OpenCount, CloseCount, DeleteCount, ParseCount, OkayToCloseCount, QueryNameCount);
322 CheckCounts(SaveCounts.Open, SaveCounts.Close, SaveCounts.Delete, SaveCounts.Parse, SaveCounts.OkayToClose, SaveCounts.QueryName);
323}
#define CheckCounts(OpenCount, CloseCount, DeleteCount, ParseCount, OkayToCloseCount, QueryNameCount)
Definition: ObType.c:262
#define SaveCounts(Save)
Definition: ObType.c:273
static OBJECT_ATTRIBUTES ObAttributes[NUM_OBTYPES]
Definition: ObType.c:45
static UNICODE_STRING ObName[NUM_OBTYPES]
Definition: ObType.c:41
struct _MY_OBJECT1 MY_OBJECT1
#define ok(value,...)
Definition: atltest.h:57
#define ASSERT(a)
Definition: mode.c:44
ULONG ACCESS_MASK
Definition: nt_native.h:40
#define STANDARD_RIGHTS_ALL
Definition: nt_native.h:69
#define GENERIC_ALL
Definition: nt_native.h:92
NTSTATUS NTAPI ObInsertObject(IN PVOID Object, IN PACCESS_STATE AccessState OPTIONAL, IN ACCESS_MASK DesiredAccess, IN ULONG ObjectPointerBias, OUT PVOID *NewObject OPTIONAL, OUT PHANDLE Handle)
Definition: obhandle.c:2935
NTSTATUS NTAPI ObCreateObject(IN KPROCESSOR_MODE ProbeMode OPTIONAL, IN POBJECT_TYPE Type, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN KPROCESSOR_MODE AccessMode, IN OUT PVOID ParseContext OPTIONAL, IN ULONG ObjectSize, IN ULONG PagedPoolCharge OPTIONAL, IN ULONG NonPagedPoolCharge OPTIONAL, OUT PVOID *Object)
Definition: oblife.c:1039
Definition: ObType.c:51
uint32_t ULONG
Definition: typedefs.h:59

Referenced by TestObjectType().

◆ ObtCreateObjectTypes()

static VOID ObtCreateObjectTypes ( VOID  )
static

Definition at line 173 of file ObType.c.

174{
175 INT i;
177 struct
178 {
179 WCHAR DirectoryName[sizeof "\\ObjectTypes\\" - 1];
180 WCHAR TypeName[15];
181 } Name;
183 HANDLE ObjectTypeHandle;
184 UNICODE_STRING ObjectPath;
185
186 RtlCopyMemory(&Name.DirectoryName, L"\\ObjectTypes\\", sizeof Name.DirectoryName);
187
188 for (i = 0; i < NUM_OBTYPES; ++i)
189 {
190 Status = RtlStringCbPrintfW(Name.TypeName, sizeof Name.TypeName, L"MyObjectType%x", i);
193 DPRINT("Creating object type %wZ\n", &ObTypeName[i]);
194
200
201 // Test for invalid parameter
202 // FIXME: Make it more exact, to see which params Win2k3 checks
203 // existence of
206
214 //ObTypeInitializer[i].SecurityProcedure = SecurityProc;
215
218 {
219 /* as we cannot delete the object types, get a pointer if they
220 * already exist */
221 RtlInitUnicodeString(&ObjectPath, Name.DirectoryName);
223 Status = ObOpenObjectByName(&ObjectAttributes, NULL, KernelMode, NULL, 0, NULL, &ObjectTypeHandle);
225 ok(ObjectTypeHandle != NULL, "ObjectTypeHandle = NULL\n");
226 if (!skip(Status == STATUS_SUCCESS && ObjectTypeHandle, "No handle\n"))
227 {
228 Status = ObReferenceObjectByHandle(ObjectTypeHandle, 0, NULL, KernelMode, (PVOID)&ObTypes[i], NULL);
230 if (!skip(Status == STATUS_SUCCESS && ObTypes[i], "blah\n"))
231 {
239 }
240 Status = ZwClose(ObjectTypeHandle);
241 }
242 }
243
245 ok(ObTypes[i] != NULL, "ObType = NULL\n");
246 }
247}
static OBJECT_TYPE_INITIALIZER ObTypeInitializer[NUM_OBTYPES]
Definition: ObType.c:42
static VOID NTAPI CloseProc(IN PEPROCESS Process, IN PVOID Object, IN ACCESS_MASK GrantedAccess, IN ULONG ProcessHandleCount, IN ULONG SystemHandleCount)
Definition: ObType.c:92
static NTSTATUS NTAPI ParseProc(IN PVOID ParseObject, IN PVOID ObjectType, IN OUT PACCESS_STATE AccessState, IN KPROCESSOR_MODE AccessMode, IN ULONG Attributes, IN OUT PUNICODE_STRING CompleteName, IN OUT PUNICODE_STRING RemainingName, IN OUT PVOID Context OPTIONAL, IN PSECURITY_QUALITY_OF_SERVICE SecurityQos OPTIONAL, OUT PVOID *Object)
Definition: ObType.c:117
static NTSTATUS NTAPI QueryNameProc(IN PVOID Object, IN BOOLEAN HasObjectName, OUT POBJECT_NAME_INFORMATION ObjectNameInfo, IN ULONG Length, OUT PULONG ReturnLength, IN KPROCESSOR_MODE AccessMode)
Definition: ObType.c:154
static UNICODE_STRING ObTypeName[NUM_OBTYPES]
Definition: ObType.c:40
static NTSTATUS NTAPI OpenProc(IN OB_OPEN_REASON OpenReason, IN PEPROCESS Process, IN PVOID Object, IN ACCESS_MASK GrantedAccess, IN ULONG HandleCount)
Definition: ObType.c:76
static VOID NTAPI DeleteProc(IN PVOID Object)
Definition: ObType.c:107
static VOID NTAPI DumpProc(IN PVOID Object, IN POB_DUMP_CONTROL DumpControl)
Definition: ObType.c:65
static BOOLEAN NTAPI OkayToCloseProc(IN PEPROCESS Process OPTIONAL, IN PVOID Object, IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: ObType.c:139
struct NameRec_ * Name
Definition: cdprocs.h:460
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define TRUE
Definition: types.h:120
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define NonPagedPool
Definition: env_spec_w32.h:307
#define OBJECT_TYPE_ALL_ACCESS
Definition: nt_native.h:1248
NTSTATUS NTAPI ObOpenObjectByName(IN POBJECT_ATTRIBUTES ObjectAttributes, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, IN PACCESS_STATE PassedAccessState, IN ACCESS_MASK DesiredAccess, IN OUT PVOID ParseContext, OUT PHANDLE Handle)
Definition: obhandle.c:2532
NTSTATUS NTAPI ObCreateObjectType(IN PUNICODE_STRING TypeName, IN POBJECT_TYPE_INITIALIZER ObjectTypeInitializer, IN PVOID Reserved, OUT POBJECT_TYPE *ObjectType)
Definition: oblife.c:1136
NTSTATUS NTAPI ObReferenceObjectByHandle(IN HANDLE Handle, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, OUT PVOID *Object, OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL)
Definition: obref.c:494
OB_CLOSE_METHOD CloseProcedure
Definition: obtypes.h:368
OB_DELETE_METHOD DeleteProcedure
Definition: obtypes.h:369
OB_OPEN_METHOD OpenProcedure
Definition: obtypes.h:367
BOOLEAN MaintainHandleCount
Definition: obtypes.h:361
OB_QUERYNAME_METHOD QueryNameProcedure
Definition: obtypes.h:372
OB_PARSE_METHOD ParseProcedure
Definition: obtypes.h:370
OB_OKAYTOCLOSE_METHOD OkayToCloseProcedure
Definition: obtypes.h:373
OB_DUMP_METHOD DumpProcedure
Definition: obtypes.h:366
OBJECT_TYPE_INITIALIZER TypeInfo
Definition: obtypes.h:390
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_OBJECT_NAME_COLLISION
Definition: udferr_usr.h:150

Referenced by TestObjectType().

◆ OkayToCloseProc()

static BOOLEAN NTAPI OkayToCloseProc ( IN PEPROCESS Process  OPTIONAL,
IN PVOID  Object,
IN HANDLE  Handle,
IN KPROCESSOR_MODE  AccessMode 
)
static

Definition at line 139 of file ObType.c.

144{
145 DPRINT("OkayToCloseProc() 0x%p, Handle 0x%p, AccessMask 0x%lX\n",
148 return TRUE;
149}
_In_ PEPROCESS _In_ KPROCESSOR_MODE AccessMode
Definition: mmfuncs.h:396

Referenced by ObtCreateObjectTypes().

◆ OpenProc()

static NTSTATUS NTAPI OpenProc ( IN OB_OPEN_REASON  OpenReason,
IN PEPROCESS  Process,
IN PVOID  Object,
IN ACCESS_MASK  GrantedAccess,
IN ULONG  HandleCount 
)
static

Definition at line 76 of file ObType.c.

82{
83 DPRINT("OpenProc() 0x%p, OpenReason %d, HandleCount %lu, AccessMask 0x%lX\n",
84 Object, OpenReason, HandleCount, GrantedAccess);
85 ++Counts.Open;
86 return STATUS_SUCCESS;
87}

Referenced by ObtCreateObjectTypes().

◆ ParseProc()

static NTSTATUS NTAPI ParseProc ( IN PVOID  ParseObject,
IN PVOID  ObjectType,
IN OUT PACCESS_STATE  AccessState,
IN KPROCESSOR_MODE  AccessMode,
IN ULONG  Attributes,
IN OUT PUNICODE_STRING  CompleteName,
IN OUT PUNICODE_STRING  RemainingName,
IN OUT PVOID Context  OPTIONAL,
IN PSECURITY_QUALITY_OF_SERVICE SecurityQos  OPTIONAL,
OUT PVOID Object 
)
static

Definition at line 117 of file ObType.c.

128{
129 DPRINT("ParseProc() called\n");
130 *Object = NULL;
131
132 ++Counts.Parse;
133 return STATUS_OBJECT_NAME_NOT_FOUND;//STATUS_SUCCESS;
134}
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149

Referenced by ObtCreateObjectTypes().

◆ QueryNameProc()

static NTSTATUS NTAPI QueryNameProc ( IN PVOID  Object,
IN BOOLEAN  HasObjectName,
OUT POBJECT_NAME_INFORMATION  ObjectNameInfo,
IN ULONG  Length,
OUT PULONG  ReturnLength,
IN KPROCESSOR_MODE  AccessMode 
)
static

Definition at line 154 of file ObType.c.

161{
162 DPRINT("QueryNameProc() 0x%p, HasObjectName %d, Len %lu, AccessMask 0x%lX\n",
163 Object, HasObjectName, Length, AccessMode);
165
166 ObjectNameInfo = NULL;
167 ReturnLength = 0;
169}
IN CINT OUT PVOID IN ULONG OUT PULONG ReturnLength
Definition: dumpinfo.c:43
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102

Referenced by ObtCreateObjectTypes().

◆ START_TEST() [1/3]

START_TEST ( ObType  )

Definition at line 433 of file ObType.c.

434{
436}
static VOID TestObjectType(IN BOOLEAN Clean)
Definition: ObType.c:415

◆ START_TEST() [2/3]

START_TEST ( ObTypeClean  )

Definition at line 445 of file ObType.c.

446{
448}
static VOID ObtClose(BOOLEAN Clean, BOOLEAN AlternativeMethod)
Definition: ObType.c:327
#define FALSE
Definition: types.h:117

◆ START_TEST() [3/3]

START_TEST ( ObTypeNoClean  )

Definition at line 439 of file ObType.c.

440{
442}

◆ TestObjectType()

static VOID TestObjectType ( IN BOOLEAN  Clean)
static

Definition at line 415 of file ObType.c.

417{
418 RtlZeroMemory(&Counts, sizeof Counts);
419
421 DPRINT("ObtCreateObjectTypes() done\n");
422
424 DPRINT("ObtCreateDirectory() done\n");
425
426 if (!skip(ObTypes[0] != NULL, "No object types!\n"))
428 DPRINT("ObtCreateObjects() done\n");
429
430 ObtClose(Clean, FALSE);
431}
static VOID ObtCreateDirectory(VOID)
Definition: ObType.c:251
static VOID ObtCreateObjectTypes(VOID)
Definition: ObType.c:173
static VOID ObtCreateObjects(VOID)
Definition: ObType.c:279

Referenced by START_TEST().

Variable Documentation

◆ Counts

◆ DirectoryHandle

◆ ObAttributes

OBJECT_ATTRIBUTES ObAttributes[NUM_OBTYPES]
static

Definition at line 45 of file ObType.c.

Referenced by ObtCreateObjects().

◆ ObBody

PVOID ObBody[NUM_OBTYPES]
static

Definition at line 46 of file ObType.c.

Referenced by ObtClose(), and ObtCreateObjects().

◆ ObDirectoryAttributes

OBJECT_ATTRIBUTES ObDirectoryAttributes
static

Definition at line 44 of file ObType.c.

Referenced by ObtCreateDirectory().

◆ ObDirectoryName

UNICODE_STRING ObDirectoryName
static

Definition at line 43 of file ObType.c.

Referenced by ObtCreateDirectory().

◆ ObHandle1

HANDLE ObHandle1[NUM_OBTYPES]
static

Definition at line 47 of file ObType.c.

Referenced by ObtClose(), and ObtCreateObjects().

◆ ObName

UNICODE_STRING ObName[NUM_OBTYPES]
static

Definition at line 41 of file ObType.c.

Referenced by ObtCreateObjects().

◆ ObTypeInitializer

OBJECT_TYPE_INITIALIZER ObTypeInitializer[NUM_OBTYPES]
static

Definition at line 42 of file ObType.c.

Referenced by ObtCreateObjectTypes().

◆ ObTypeName

UNICODE_STRING ObTypeName[NUM_OBTYPES]
static

Definition at line 40 of file ObType.c.

Referenced by ObtCreateObjectTypes().

◆ ObTypes

POBJECT_TYPE ObTypes[NUM_OBTYPES]
static

Definition at line 39 of file ObType.c.

Referenced by ObtClose(), ObtCreateObjects(), ObtCreateObjectTypes(), and TestObjectType().