ReactOS  r75636
ObTypes.c File Reference
#include <kmt_test.h>
#include <debug.h>
Include dependency graph for ObTypes.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define ok_eq_ustr(value, expected)   ok(RtlEqualUnicodeString(value, expected, FALSE), #value " = \"%wZ\", expected \"%%wZ\"\n", value, expected)
 
#define CheckObjectType(TypeName, Variable, Flags, InvalidAttr,ReadMapping, WriteMapping, ExecMapping, AllMapping,ValidMask)
 
#define ObpDirectoryObjectType   NULL
 
#define ObpSymbolicLinkObjectType   NULL
 
#define DbgkDebugObjectType   NULL
 
#define ExEventPairObjectType   NULL
 
#define ExMutantObjectType   NULL
 
#define ExCallbackObjectType   NULL
 
#define ExTimerObjectType   NULL
 
#define ExProfileObjectType   NULL
 
#define ExpKeyedEventObjectType   NULL
 
#define CmpKeyObjectType   NULL
 
#define LpcWaitablePortObjectType   NULL
 
#define IoControllerObjectType   NULL
 
#define IoCompletionObjectType   NULL
 
#define WmipGuidObjectType   NULL
 
#define OBT_NO_DEFAULT   0x01
 
#define OBT_CUSTOM_SECURITY_PROC   0x02
 
#define OBT_SECURITY_REQUIRED   0x04
 
#define OBT_CASE_INSENSITIVE   0x08
 
#define OBT_MAINTAIN_TYPE_LIST   0x10
 
#define OBT_MAINTAIN_HANDLE_COUNT   0x20
 
#define OBT_PAGED_POOL   0x40
 
#define OBT_CUSTOM_KEY   0x80
 
#define TAG(x)   RtlUlongByteSwap(x)
 

Functions

static POBJECT_TYPE GetObjectType (IN PCWSTR TypeName)
 
static VOID TestObjectTypes (VOID)
 
 START_TEST (ObTypes)
 

Variables

static POBJECT_TYPE ObpTypeObjectType
 
static POBJECT_TYPE ObpDefaultObject
 
static OB_SECURITY_METHOD SeDefaultObjectMethod
 

Macro Definition Documentation

#define CheckObjectType (   TypeName,
  Variable,
  Flags,
  InvalidAttr,
  ReadMapping,
  WriteMapping,
  ExecMapping,
  AllMapping,
  ValidMask 
)

Definition at line 42 of file ObTypes.c.

Referenced by TestObjectTypes().

#define DbgkDebugObjectType   NULL

Definition at line 125 of file ObTypes.c.

Referenced by PspCreateProcess(), and TestObjectTypes().

#define ExCallbackObjectType   NULL

Definition at line 128 of file ObTypes.c.

Referenced by TestObjectTypes().

#define ExEventPairObjectType   NULL

Definition at line 126 of file ObTypes.c.

Referenced by TestObjectTypes().

#define ExMutantObjectType   NULL

Definition at line 127 of file ObTypes.c.

Referenced by NtSignalAndWaitForSingleObject(), and TestObjectTypes().

#define ExpKeyedEventObjectType   NULL

Definition at line 131 of file ObTypes.c.

Referenced by TestObjectTypes().

#define ExProfileObjectType   NULL

Definition at line 130 of file ObTypes.c.

Referenced by TestObjectTypes().

#define ExTimerObjectType   NULL

Definition at line 129 of file ObTypes.c.

Referenced by TestObjectTypes().

#define IoCompletionObjectType   NULL

Definition at line 135 of file ObTypes.c.

Referenced by TestObjectTypes().

#define IoControllerObjectType   NULL

Definition at line 134 of file ObTypes.c.

Referenced by TestObjectTypes().

#define LpcWaitablePortObjectType   NULL

Definition at line 133 of file ObTypes.c.

Referenced by TestObjectTypes().

#define NDEBUG

Definition at line 10 of file ObTypes.c.

#define ObpDirectoryObjectType   NULL

Definition at line 123 of file ObTypes.c.

Referenced by TestObjectTypes().

#define ObpSymbolicLinkObjectType   NULL

Definition at line 124 of file ObTypes.c.

Referenced by TestObjectTypes().

#define OBT_CASE_INSENSITIVE   0x08

Definition at line 144 of file ObTypes.c.

Referenced by TestObjectTypes().

#define OBT_CUSTOM_KEY   0x80

Definition at line 148 of file ObTypes.c.

Referenced by TestObjectTypes().

#define OBT_CUSTOM_SECURITY_PROC   0x02

Definition at line 142 of file ObTypes.c.

Referenced by TestObjectTypes().

#define OBT_MAINTAIN_HANDLE_COUNT   0x20

Definition at line 146 of file ObTypes.c.

Referenced by TestObjectTypes().

#define OBT_MAINTAIN_TYPE_LIST   0x10

Definition at line 145 of file ObTypes.c.

Referenced by TestObjectTypes().

#define OBT_NO_DEFAULT   0x01

Definition at line 141 of file ObTypes.c.

Referenced by TestObjectTypes().

#define OBT_PAGED_POOL   0x40

Definition at line 147 of file ObTypes.c.

Referenced by TestObjectTypes().

#define OBT_SECURITY_REQUIRED   0x04

Definition at line 143 of file ObTypes.c.

Referenced by TestObjectTypes().

#define ok_eq_ustr (   value,
  expected 
)    ok(RtlEqualUnicodeString(value, expected, FALSE), #value " = \"%wZ\", expected \"%%wZ\"\n", value, expected)

Definition at line 40 of file ObTypes.c.

#define TAG (   x)    RtlUlongByteSwap(x)

Definition at line 150 of file ObTypes.c.

#define WmipGuidObjectType   NULL

Definition at line 136 of file ObTypes.c.

Referenced by IoWMIQueryAllData(), and TestObjectTypes().

Function Documentation

static POBJECT_TYPE GetObjectType ( IN PCWSTR  TypeName)
static

Definition at line 15 of file ObTypes.c.

Referenced by CloseEnhMetaFile(), get_dc_data(), get_graphics_bounds(), MFDRV_CloseMetaFile(), OleIsDcMeta(), STATIC_PaintBitmapfn(), STATIC_PaintEnhMetafn(), STATIC_SetBitmap(), STATIC_SetEnhMetaFile(), sw_DescribePixelFormat(), test_CopyMetaFile(), test_D3DKMTCreateDCFromMemory(), test_data_handles(), test_DeleteDC(), test_device_caps(), test_ExtTextOut(), test_handles(), test_handles_process(), test_handles_process_dib(), test_handles_thread2(), test_hfont_lifetime(), test_logpen(), test_mf_Blank(), test_mf_Graphics(), test_mf_PatternBrush(), test_mono_1x1_bmp_dbg(), test_nonole_clipboard(), test_SetMetaFileBits(), TestObjectTypes(), and wglMakeCurrent().

17 {
21  HANDLE Handle;
23 
24  RtlInitUnicodeString(&Name, TypeName);
26  Status = ObOpenObjectByName(&ObjectAttributes, NULL, KernelMode, NULL, 0, NULL, &Handle);
27  ok_eq_hex(Status, STATUS_SUCCESS);
28  ok(Handle != NULL, "ObjectTypeHandle = NULL\n");
29  if (!skip(Status == STATUS_SUCCESS && Handle, "No handle\n"))
30  {
31  Status = ObReferenceObjectByHandle(Handle, 0, NULL, KernelMode, &ObjectType, NULL);
32  ok_eq_hex(Status, STATUS_SUCCESS);
33  ok(ObjectType != NULL, "ObjectType = NULL\n");
34  Status = ZwClose(Handle);
35  ok_eq_hex(Status, STATUS_SUCCESS);
36  }
37  return ObjectType;
38 }
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:2522
DWORD *typedef PVOID
Definition: winlogon.h:52
#define STATUS_SUCCESS
Definition: contextmenu.cpp:55
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
static POBJECTS_AND_NAME_A SE_OBJECT_TYPE ObjectType
Definition: security.c:80
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
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:388
smooth NULL
Definition: ftsmooth.c:513
_In_ HANDLE Handle
Definition: extypes.h:390
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
_In_ PUNICODE_STRING Name
Definition: mrx.h:218
Status
Definition: gdiplustypes.h:24
DWORD *typedef HANDLE
Definition: winlogon.h:52
LONG NTSTATUS
Definition: DriverTester.h:11
#define skip(...)
Definition: CString.cpp:57
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define ok(value,...)
Definition: CImage.cpp:33
#define ok_eq_hex(value, expected)
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
START_TEST ( ObTypes  )

Definition at line 257 of file ObTypes.c.

258 {
259  TestObjectTypes();
260 }
static VOID TestObjectTypes(VOID)
Definition: ObTypes.c:154
static VOID TestObjectTypes ( VOID  )
static

Definition at line 154 of file ObTypes.c.

Referenced by START_TEST().

155 {
156  ULONG Index;
157 
158  ObpTypeObjectType = GetObjectType(L"\\ObjectTypes\\Type");
159  if (skip(ObpTypeObjectType != NULL, "No Type object type\n"))
160  return;
161 
163  ok(ObpDefaultObject != NULL, "No ObpDefaultObject\n");
165  ok(SeDefaultObjectMethod != NULL, "No SeDefaultObjectMethod\n");
166 
167 #ifdef _PROPER_NT_NDK_EXPORTS
168 #define ObpTypeObjectType *ObpTypeObjectType
169 #define ObpDirectoryObjectType *ObpDirectoryObjectType
170 #define ObpSymbolicLinkObjectType *ObpSymbolicLinkObjectType
171 #define PsJobType *PsJobType
172 #define DbgkDebugObjectType *DbgkDebugObjectType
173 #define ExEventPairObjectType *ExEventPairObjectType
174 #define ExMutantObjectType *ExMutantObjectType
175 #define ExCallbackObjectType *ExCallbackObjectType
176 #define ExTimerObjectType *ExTimerObjectType
177 #define ExProfileObjectType *ExProfileObjectType
178 #define ExpKeyedEventObjectType *ExpKeyedEventObjectType
179 #define ExWindowStationObjectType *ExWindowStationObjectType
180 #define ExDesktopObjectType *ExDesktopObjectType
181 #define MmSectionObjectType *MmSectionObjectType
182 #define CmpKeyObjectType *CmpKeyObjectType
183 #define LpcPortObjectType *LpcPortObjectType
184 #define LpcWaitablePortObjectType *LpcWaitablePortObjectType
185 #define IoAdapterObjectType *IoAdapterObjectType
186 #define IoControllerObjectType *IoControllerObjectType
187 #define IoDeviceObjectType *IoDeviceObjectType
188 #define IoDriverObjectType *IoDriverObjectType
189 #define IoCompletionObjectType *IoCompletionObjectType
190 #define WmipGuidObjectType *WmipGuidObjectType
191 #endif
192 
193  Index = 1;
194  CheckObjectType(Type, ObpTypeObjectType, OBT_MAINTAIN_TYPE_LIST | OBT_CUSTOM_KEY, 0x100, 0x020000, 0x020000, 0x020000, 0x0f0001, 0x1f0001);
195  ok_eq_hex(ObpTypeObjectType->Key, TAG('ObjT'));
196  CheckObjectType(Directory, ObpDirectoryObjectType, OBT_CASE_INSENSITIVE | OBT_PAGED_POOL, 0x100, 0x020003, 0x02000c, 0x020003, 0x0f000f, 0x0f000f);
197  CheckObjectType(SymbolicLink, ObpSymbolicLinkObjectType, OBT_CASE_INSENSITIVE | OBT_PAGED_POOL, 0x100, 0x020001, 0x020000, 0x020001, 0x0f0001, 0x0f0001);
198  CheckObjectType(Token, *SeTokenObjectType, OBT_SECURITY_REQUIRED | OBT_PAGED_POOL, 0x100, 0x020008, 0x0200e0, 0x020000, 0x0f01ff, 0x1f01ff);
199  CheckObjectType(Process, *PsProcessType, OBT_NO_DEFAULT | OBT_SECURITY_REQUIRED, 0x0b0, 0x020410, 0x020beb, 0x120000, 0x1f0fff, 0x1f0fff);
200  CheckObjectType(Thread, *PsThreadType, OBT_NO_DEFAULT | OBT_SECURITY_REQUIRED, 0x0b0, 0x020048, 0x020037, 0x120000, 0x1f03ff, 0x1f03ff);
201  CheckObjectType(Job, PsJobType, OBT_NO_DEFAULT | OBT_SECURITY_REQUIRED, 0x000, 0x020004, 0x02000b, 0x120000, 0x1f03ff, 0x1f001f);
202  CheckObjectType(DebugObject, DbgkDebugObjectType, OBT_NO_DEFAULT | OBT_SECURITY_REQUIRED, 0x000, 0x020001, 0x020002, 0x120000, 0x1f000f, 0x1f000f);
203  CheckObjectType(Event, *ExEventObjectType, OBT_NO_DEFAULT, 0x100, 0x020001, 0x020002, 0x120000, 0x1f0003, 0x1f0003);
204  CheckObjectType(EventPair, ExEventPairObjectType, 0, 0x100, 0x120000, 0x120000, 0x120000, 0x1f0000, 0x1f0000);
205  CheckObjectType(Mutant, ExMutantObjectType, OBT_NO_DEFAULT, 0x100, 0x020001, 0x020000, 0x120000, 0x1f0001, 0x1f0001);
206  CheckObjectType(Callback, ExCallbackObjectType, OBT_NO_DEFAULT, 0x100, 0x020000, 0x020001, 0x120000, 0x1f0001, 0x1f0001);
207  CheckObjectType(Semaphore, *ExSemaphoreObjectType, OBT_NO_DEFAULT, 0x100, 0x020001, 0x020002, 0x120000, 0x1f0003, 0x1f0003);
208  CheckObjectType(Timer, ExTimerObjectType, OBT_NO_DEFAULT, 0x100, 0x020001, 0x020002, 0x120000, 0x1f0003, 0x1f0003);
209  CheckObjectType(Profile, ExProfileObjectType, OBT_NO_DEFAULT, 0x100, 0x020001, 0x020001, 0x020001, 0x0f0001, 0x0f0001);
210  CheckObjectType(KeyedEvent, ExpKeyedEventObjectType, OBT_PAGED_POOL, 0x000, 0x020001, 0x020002, 0x020000, 0x0f0003, 0x1f0003);
212  0x130, 0x020303, 0x02001c, 0x020060, 0x0f037f, 0x0f037f);
214  0x130, 0x020041, 0x0200be, 0x020100, 0x0f01ff, 0x0f01ff);
215  CheckObjectType(Section, MmSectionObjectType, OBT_PAGED_POOL, 0x100, 0x020005, 0x020002, 0x020008, 0x0f001f, 0x1f001f);
217  0x030, 0x020019, 0x020006, 0x020019, 0x0f003f, 0x1f003f);
218  CheckObjectType(Port, LpcPortObjectType, OBT_PAGED_POOL, 0x7b2, 0x020001, 0x010001, 0x000000, 0x1f0001, 0x1f0001);
219  CheckObjectType(WaitablePort, LpcWaitablePortObjectType, OBT_NO_DEFAULT, 0x7b2, 0x020001, 0x010001, 0x000000, 0x1f0001, 0x1f0001);
220  CheckObjectType(Adapter, IoAdapterObjectType, 0, 0x100, 0x120089, 0x120116, 0x1200a0, 0x1f01ff, 0x1f01ff);
221  CheckObjectType(Controller, IoControllerObjectType, 0, 0x100, 0x120089, 0x120116, 0x1200a0, 0x1f01ff, 0x1f01ff);
223  0x100, 0x120089, 0x120116, 0x1200a0, 0x1f01ff, 0x1f01ff);
224  CheckObjectType(Driver, IoDriverObjectType, OBT_CASE_INSENSITIVE, 0x100, 0x120089, 0x120116, 0x1200a0, 0x1f01ff, 0x1f01ff);
225  CheckObjectType(IoCompletion, IoCompletionObjectType, OBT_CASE_INSENSITIVE, 0x110, 0x020001, 0x020002, 0x120000, 0x1f0003, 0x1f0003);
227  0x130, 0x120089, 0x120116, 0x1200a0, 0x1f01ff, 0x1f01ff);
229  0x100, 0x000001, 0x000002, 0x000010, 0x120fff, 0x1f0fff);
230  CheckObjectType(FilterConnectionPort, NULL, OBT_NO_DEFAULT | OBT_SECURITY_REQUIRED, 0x100, 0x020001, 0x010001, 0x000000, 0x1f0001, 0x1f0001);
231  CheckObjectType(FilterCommunicationPort, NULL, OBT_NO_DEFAULT, 0x100, 0x020001, 0x010001, 0x000000, 0x1f0001, 0x1f0001);
232 
233  // exported but not created
235 
236  // my Win7/x64 additionally has:
237  // ALPC Port
238  // EtwConsumer
239  // EtwRegistration
240  // IoCompletionReserve
241  // PcwObject
242  // PowerRequest
243  // Session
244  // TmEn
245  // TmRm
246  // TmTm
247  // TmTx
248  // TpWorkerFactory
249  // UserApcReserve
250  // ... and does not have:
251  // Port
252  // WaitablePort
253 
255 }
CPPORT Port[4]
Definition: headless.c:34
#define IoCompletionObjectType
Definition: ObTypes.c:135
#define OBT_CUSTOM_KEY
Definition: ObTypes.c:148
POBJECT_TYPE ExWindowStationObjectType
Definition: win32k.c:25
Type
Definition: Type.h:6
POBJECT_TYPE PsJobType
Definition: job.c:19
#define OBT_MAINTAIN_HANDLE_COUNT
Definition: ObTypes.c:146
#define ExProfileObjectType
Definition: ObTypes.c:130
Definition: bidi.c:75
#define ExTimerObjectType
Definition: ObTypes.c:129
ACPI_EFI_DEVICE_PATH ACPI_EFI_HANDLE * Device
Definition: acefiex.h:649
#define ok_eq_pointer(value, expected)
#define ExpKeyedEventObjectType
Definition: ObTypes.c:131
_IRQL_requires_same_ _In_ PLSA_STRING _In_ SECURITY_LOGON_TYPE _In_ ULONG _In_ ULONG _In_opt_ PTOKEN_GROUPS _In_ PTOKEN_SOURCE _Out_ PVOID _Out_ PULONG _Inout_ PLUID _Out_ PHANDLE Token
POBJECT_TYPE ExDesktopObjectType
Definition: win32k.c:26
PVOID DefaultObject
Definition: obtypes.h:384
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:267
POBJECT_TYPE IoDriverObjectType
Definition: driver.c:32
_Must_inspect_result_ _In_ ULONG Index
Definition: fltkernel.h:1824
static POBJECT_TYPE ObpDefaultObject
Definition: ObTypes.c:138
POBJECT_TYPE ExEventObjectType
Definition: event.c:22
#define ExMutantObjectType
Definition: ObTypes.c:127
ULONG Key
Definition: obtypes.h:391
#define LpcWaitablePortObjectType
Definition: ObTypes.c:133
smooth NULL
Definition: ftsmooth.c:513
POBJECT_TYPE SeTokenObjectType
Definition: token.c:34
_In_ PCUNICODE_STRING _In_ PVOID Driver
Definition: cmfuncs.h:32
#define CheckObjectType(TypeName, Variable, Flags, InvalidAttr,ReadMapping, WriteMapping, ExecMapping, AllMapping,ValidMask)
Definition: ObTypes.c:42
#define IoControllerObjectType
Definition: ObTypes.c:134
POBJECT_TYPE LpcPortObjectType
Definition: port.c:17
#define ObpDirectoryObjectType
Definition: ObTypes.c:123
#define ExCallbackObjectType
Definition: ObTypes.c:128
#define OBT_PAGED_POOL
Definition: ObTypes.c:147
static OB_SECURITY_METHOD SeDefaultObjectMethod
Definition: ObTypes.c:139
POBJECT_TYPE IoDeviceHandlerObjectType
Definition: adapter.c:19
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
#define OBT_NO_DEFAULT
Definition: ObTypes.c:141
POBJECT_TYPE MmSectionObjectType
Definition: section.c:136
POBJECT_TYPE PsThreadType
Definition: thread.c:20
WORD TAG
Definition: sdbtypes.h:27
POBJECT_TYPE IoAdapterObjectType
Definition: adapter.c:18
OBJECT_TYPE_INITIALIZER TypeInfo
Definition: obtypes.h:390
POBJECT_TYPE IoFileObjectType
Definition: iomgr.c:36
#define OBT_SECURITY_REQUIRED
Definition: ObTypes.c:143
#define DbgkDebugObjectType
Definition: ObTypes.c:125
#define OBT_CASE_INSENSITIVE
Definition: ObTypes.c:144
#define ObpSymbolicLinkObjectType
Definition: ObTypes.c:124
#define OBT_MAINTAIN_TYPE_LIST
Definition: ObTypes.c:145
OB_SECURITY_METHOD SecurityProcedure
Definition: obtypes.h:371
#define skip(...)
Definition: CString.cpp:57
static POBJECT_TYPE GetObjectType(IN PCWSTR TypeName)
Definition: ObTypes.c:15
#define OBT_CUSTOM_SECURITY_PROC
Definition: ObTypes.c:142
static POBJECT_TYPE ObpTypeObjectType
Definition: ObTypes.c:122
#define WmipGuidObjectType
Definition: ObTypes.c:136
#define ExEventPairObjectType
Definition: ObTypes.c:126
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
unsigned int ULONG
Definition: retypes.h:1
#define CmpKeyObjectType
Definition: ObTypes.c:132
base for all directory entries
Definition: entries.h:138
#define ok(value,...)
Definition: CImage.cpp:33
#define ok_eq_hex(value, expected)
Definition: File.h:15
LPFNPSPCALLBACK Callback
Definition: desk.c:111
POBJECT_TYPE PsProcessType
Definition: process.c:20
POBJECT_TYPE IoDeviceObjectType
Definition: iomgr.c:35
static const WCHAR SymbolicLink[]
Definition: interface.c:31
NTSTATUS NTAPI IoCompletion(PDEVICE_OBJECT DeviceObject, PIRP Irp, PVOID Ctx)
Definition: control.c:382
POBJECT_TYPE ExSemaphoreObjectType
Definition: sem.c:22

Variable Documentation

POBJECT_TYPE ObpDefaultObject
static

Definition at line 138 of file ObTypes.c.

Referenced by ObInitSystem().

POBJECT_TYPE ObpTypeObjectType
static

Definition at line 122 of file ObTypes.c.

Referenced by ObInitSystem().

OB_SECURITY_METHOD SeDefaultObjectMethod
static