ReactOS  0.4.13-dev-242-g611e6d7
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)
USHORT Close
Definition: ObType.c:54
USHORT Delete
Definition: ObType.c:55
static COUNTS Counts
Definition: ObType.c:60
USHORT QueryName
Definition: ObType.c:58
USHORT OkayToClose
Definition: ObType.c:57
USHORT Open
Definition: ObType.c:53
DWORD OpenCount
Definition: legacy.c:25
USHORT Parse
Definition: ObType.c:56

Definition at line 262 of file ObType.c.

◆ CheckObject

#define CheckObject (   Handle,
  Pointers,
  Handles 
)
Value:
do \
{ \
PUBLIC_OBJECT_BASIC_INFORMATION ObjectInfo; \
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)
smooth NULL
Definition: ftsmooth.c:416
_In_ HANDLE Handle
Definition: extypes.h:390
Status
Definition: gdiplustypes.h:24
return STATUS_SUCCESS
Definition: btrfs.c:2745

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 }
void DPRINT(...)
Definition: polytest.cpp:61
USHORT Close
Definition: ObType.c:54
static COUNTS Counts
Definition: ObType.c:60
static IUnknown Object
Definition: main.c:512
_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:13

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 }
void DPRINT(...)
Definition: polytest.cpp:61
USHORT Delete
Definition: ObType.c:55
static COUNTS Counts
Definition: ObType.c:60
static IUnknown Object
Definition: main.c:512

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 }
void DPRINT(...)
Definition: polytest.cpp:61
static COUNTS Counts
Definition: ObType.c:60
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);
346  Ret = ObDereferenceObject(ObBody[i]);
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  {
368  CheckObject(DirectoryHandle, 3LU, 1LU);
369 
372  CheckObject(DirectoryHandle, 3LU, 1LU);
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  {
386  Ret = ObDereferenceObject(ObTypes[i]);
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
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
LONG NTSTATUS
Definition: precomp.h:26
static HANDLE DirectoryHandle
Definition: ObType.c:48
#define NUM_OBTYPES
Definition: ObType.c:26
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
int32_t INT
Definition: typedefs.h:56
static HANDLE ObHandle1[NUM_OBTYPES]
Definition: ObType.c:47
static PVOID ObBody[NUM_OBTYPES]
Definition: ObType.c:46
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
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
#define CheckObject(Handle, Pointers, Handles)
Definition: ObType.c:16
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
static const WCHAR L[]
Definition: oid.c:1250
static __inline NTSTATUS 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:1120
Status
Definition: gdiplustypes.h:24
#define ok_eq_longptr(value, expected)
Definition: kmt_test.h:248
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
static POBJECT_TYPE ObTypes[NUM_OBTYPES]
Definition: ObType.c:39
#define skip(...)
#define ObReferenceObject
Definition: obfuncs.h:204
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define ok_eq_hex(value, expected)
return STATUS_SUCCESS
Definition: btrfs.c:2745
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:411
NTSYSAPI NTSTATUS NTAPI ZwMakeTemporaryObject(_In_ HANDLE Handle)

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");
259  CheckObject(DirectoryHandle, 3LU, 1LU);
260 }
static UNICODE_STRING ObDirectoryName
Definition: ObType.c:43
LONG NTSTATUS
Definition: precomp.h:26
static HANDLE DirectoryHandle
Definition: ObType.c:48
#define OBJ_PERMANENT
Definition: winternl.h:226
static OBJECT_ATTRIBUTES ObDirectoryAttributes
Definition: ObType.c:44
NTSYSAPI NTSTATUS NTAPI ZwCreateDirectoryObject(_Out_ PHANDLE DirectoryHandle, _In_ ACCESS_MASK DesiredAccess, _In_ POBJECT_ATTRIBUTES ObjectAttributes)
smooth NULL
Definition: ftsmooth.c:416
#define CheckObject(Handle, Pointers, Handles)
Definition: ObType.c:16
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
static const WCHAR L[]
Definition: oid.c:1250
Status
Definition: gdiplustypes.h:24
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define ok_eq_hex(value, expected)
return STATUS_SUCCESS
Definition: btrfs.c:2745
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#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  }
297  CheckObject(DirectoryHandle, 3LU, 1LU);
298 
299  for (i = 0; i < NUM_OBTYPES2; ++i)
300  {
301  Status = ObCreateObject(KernelMode, ObTypes[i], &ObAttributes[i], KernelMode, NULL, ObjectSize[i], 0L, 0L, &ObBody[i]);
303  }
304 
306 
307  // Insert them
308  for (i = 0; i < NUM_OBTYPES2; ++i)
309  {
310  CheckObject(DirectoryHandle, 3LU + i, 1LU);
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);
318  CheckObject(DirectoryHandle, 4LU + i, 1LU);
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 GENERIC_ALL
Definition: nt_native.h:92
#define CheckCounts(OpenCount, CloseCount, DeleteCount, ParseCount, OkayToCloseCount, QueryNameCount)
Definition: ObType.c:262
#define NUM_OBTYPES2
Definition: ObType.c:276
LONG NTSTATUS
Definition: precomp.h:26
static HANDLE DirectoryHandle
Definition: ObType.c:48
int32_t INT
Definition: typedefs.h:56
static HANDLE ObHandle1[NUM_OBTYPES]
Definition: ObType.c:47
static PVOID ObBody[NUM_OBTYPES]
Definition: ObType.c:46
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
static UNICODE_STRING ObName[NUM_OBTYPES]
Definition: ObType.c:41
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
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:952
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
#define CheckObject(Handle, Pointers, Handles)
Definition: ObType.c:16
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
static const WCHAR L[]
Definition: oid.c:1250
static __inline NTSTATUS 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:1120
Status
Definition: gdiplustypes.h:24
static OBJECT_ATTRIBUTES ObAttributes[NUM_OBTYPES]
Definition: ObType.c:45
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:2932
#define STANDARD_RIGHTS_ALL
Definition: nt_native.h:69
#define SaveCounts(Save)
Definition: ObType.c:273
static POBJECT_TYPE ObTypes[NUM_OBTYPES]
Definition: ObType.c:39
struct _MY_OBJECT1 MY_OBJECT1
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define ok_eq_hex(value, expected)
return STATUS_SUCCESS
Definition: btrfs.c:2745
ULONG ACCESS_MASK
Definition: nt_native.h:40
Definition: ObType.c:50

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);
192  RtlInitUnicodeString(&ObTypeName[i], Name.TypeName);
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 }
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:2529
#define STATUS_OBJECT_NAME_COLLISION
Definition: udferr_usr.h:150
OB_DUMP_METHOD DumpProcedure
Definition: obtypes.h:366
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
NTSTATUS NTAPI ObCreateObjectType(IN PUNICODE_STRING TypeName, IN POBJECT_TYPE_INITIALIZER ObjectTypeInitializer, IN PVOID Reserved, OUT POBJECT_TYPE *ObjectType)
Definition: oblife.c:1048
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
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 VOID NTAPI CloseProc(IN PEPROCESS Process, IN PVOID Object, IN ACCESS_MASK GrantedAccess, IN ULONG ProcessHandleCount, IN ULONG SystemHandleCount)
Definition: ObType.c:92
OB_OKAYTOCLOSE_METHOD OkayToCloseProcedure
Definition: obtypes.h:373
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
LONG NTSTATUS
Definition: precomp.h:26
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
#define NUM_OBTYPES
Definition: ObType.c:26
static OBJECT_TYPE_INITIALIZER ObTypeInitializer[NUM_OBTYPES]
Definition: ObType.c:42
int32_t INT
Definition: typedefs.h:56
static UNICODE_STRING ObTypeName[NUM_OBTYPES]
Definition: ObType.c:40
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
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:496
BOOLEAN MaintainHandleCount
Definition: obtypes.h:361
#define ok(value,...)
struct NameRec_ * Name
Definition: cdprocs.h:464
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
OB_CLOSE_METHOD CloseProcedure
Definition: obtypes.h:368
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
OB_PARSE_METHOD ParseProcedure
Definition: obtypes.h:370
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
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
OB_OPEN_METHOD OpenProcedure
Definition: obtypes.h:367
static const WCHAR L[]
Definition: oid.c:1250
static __inline NTSTATUS 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:1120
OBJECT_TYPE_INITIALIZER TypeInfo
Definition: obtypes.h:390
#define OBJECT_TYPE_ALL_ACCESS
Definition: nt_native.h:1248
Status
Definition: gdiplustypes.h:24
static VOID NTAPI DeleteProc(IN PVOID Object)
Definition: ObType.c:107
static POBJECT_TYPE ObTypes[NUM_OBTYPES]
Definition: ObType.c:39
#define skip(...)
static VOID NTAPI DumpProc(IN PVOID Object, IN POB_DUMP_CONTROL DumpControl)
Definition: ObType.c:65
OB_QUERYNAME_METHOD QueryNameProcedure
Definition: obtypes.h:372
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define ok_eq_hex(value, expected)
return STATUS_SUCCESS
Definition: btrfs.c:2745
OB_DELETE_METHOD DeleteProcedure
Definition: obtypes.h:369
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
static BOOLEAN NTAPI OkayToCloseProc(IN PEPROCESS Process OPTIONAL, IN PVOID Object, IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: ObType.c:139

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 }
#define TRUE
Definition: types.h:120
_In_ PEPROCESS _In_ KPROCESSOR_MODE AccessMode
Definition: mmfuncs.h:396
void DPRINT(...)
Definition: polytest.cpp:61
_In_ HANDLE Handle
Definition: extypes.h:390
static COUNTS Counts
Definition: ObType.c:60
static IUnknown Object
Definition: main.c:512
USHORT OkayToClose
Definition: ObType.c:57

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 }
void DPRINT(...)
Definition: polytest.cpp:61
static COUNTS Counts
Definition: ObType.c:60
static IUnknown Object
Definition: main.c:512
USHORT Open
Definition: ObType.c:53
_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:13
return STATUS_SUCCESS
Definition: btrfs.c:2745

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 }
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
static COUNTS Counts
Definition: ObType.c:60
static IUnknown Object
Definition: main.c:512
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149
USHORT Parse
Definition: ObType.c:56

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);
164  ++Counts.QueryName;
165 
166  ObjectNameInfo = NULL;
167  ReturnLength = 0;
169 }
IN CINT OUT PVOID IN ULONG OUT PULONG ReturnLength
Definition: dumpinfo.c:39
_In_ PEPROCESS _In_ KPROCESSOR_MODE AccessMode
Definition: mmfuncs.h:396
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
static COUNTS Counts
Definition: ObType.c:60
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
static IUnknown Object
Definition: main.c:512
USHORT QueryName
Definition: ObType.c:58
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149

Referenced by ObtCreateObjectTypes().

◆ START_TEST() [1/3]

START_TEST ( ObType  )

Definition at line 433 of file ObType.c.

434 {
436 }
#define TRUE
Definition: types.h:120
static VOID TestObjectType(IN BOOLEAN Clean)
Definition: ObType.c:415

◆ START_TEST() [2/3]

START_TEST ( ObTypeNoClean  )

Definition at line 439 of file ObType.c.

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

◆ START_TEST() [3/3]

START_TEST ( ObTypeClean  )

Definition at line 445 of file ObType.c.

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

◆ 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 ObtCreateObjects(VOID)
Definition: ObType.c:279
static VOID ObtClose(BOOLEAN Clean, BOOLEAN AlternativeMethod)
Definition: ObType.c:327
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
static COUNTS Counts
Definition: ObType.c:60
static POBJECT_TYPE ObTypes[NUM_OBTYPES]
Definition: ObType.c:39
#define skip(...)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
static VOID ObtCreateObjectTypes(VOID)
Definition: ObType.c:173

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().