c29c370c7819a011edaccc3a456bfd8ac7e0bcc8
[reactos.git] / reactos / ntoskrnl / ex / win32k.c
1 /* $Id$
2 *
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: ntoskrnl/ex/win32k.c
6 * PURPOSE: Executive Win32 subsystem support
7 *
8 * PROGRAMMERS: Alex Ionescu (alex@relsoft.net) - Moved callbacks to win32k and cleanup.
9 * Casper S. Hornstrup (chorns@users.sourceforge.net)
10 */
11
12 #include <ntoskrnl.h>
13 #define NDEBUG
14 #include <internal/debug.h>
15
16 #if defined (ALLOC_PRAGMA)
17 #pragma alloc_text(INIT, ExpWin32kInit)
18 #endif
19
20 /* DATA **********************************************************************/
21
22 POBJECT_TYPE ExWindowStationObjectType = NULL;
23 POBJECT_TYPE ExDesktopObjectType = NULL;
24
25 static GENERIC_MAPPING ExpWindowStationMapping =
26 {
27 STANDARD_RIGHTS_READ,
28 STANDARD_RIGHTS_WRITE,
29 STANDARD_RIGHTS_EXECUTE,
30 STANDARD_RIGHTS_REQUIRED
31 };
32
33 static GENERIC_MAPPING ExpDesktopMapping =
34 {
35 STANDARD_RIGHTS_READ,
36 STANDARD_RIGHTS_WRITE,
37 STANDARD_RIGHTS_EXECUTE,
38 STANDARD_RIGHTS_REQUIRED
39 };
40
41 OB_OPEN_METHOD ExpWindowStationObjectOpen = NULL;
42 OB_PARSE_METHOD ExpWindowStationObjectParse = NULL;
43 OB_DELETE_METHOD ExpWindowStationObjectDelete = NULL;
44 OB_FIND_METHOD ExpWindowStationObjectFind = NULL;
45 OB_CREATE_METHOD ExpDesktopObjectCreate = NULL;
46 OB_DELETE_METHOD ExpDesktopObjectDelete = NULL;
47
48 /* FUNCTIONS ****************************************************************/
49
50 NTSTATUS
51 STDCALL
52 ExpWinStaObjectOpen(OB_OPEN_REASON Reason,
53 PVOID ObjectBody,
54 PEPROCESS Process,
55 ULONG HandleCount,
56 ACCESS_MASK GrantedAccess)
57 {
58 /* Call the Registered Callback */
59 return ExpWindowStationObjectOpen(Reason,
60 ObjectBody,
61 Process,
62 HandleCount,
63 GrantedAccess);
64 }
65
66 VOID
67 STDCALL
68 ExpWinStaObjectDelete(PVOID DeletedObject)
69 {
70 /* Call the Registered Callback */
71 ExpWindowStationObjectDelete(DeletedObject);
72 }
73
74 PVOID
75 STDCALL
76 ExpWinStaObjectFind(PVOID WinStaObject,
77 PWSTR Name,
78 ULONG Attributes)
79 {
80 /* Call the Registered Callback */
81 return ExpWindowStationObjectFind(WinStaObject,
82 Name,
83 Attributes);
84 }
85
86 NTSTATUS
87 STDCALL
88 ExpWinStaObjectParse(PVOID Object,
89 PVOID *NextObject,
90 PUNICODE_STRING FullPath,
91 PWSTR *Path,
92 ULONG Attributes)
93 {
94 /* Call the Registered Callback */
95 return ExpWindowStationObjectParse(Object,
96 NextObject,
97 FullPath,
98 Path,
99 Attributes);
100 }
101
102 NTSTATUS
103 STDCALL
104 ExpDesktopCreate(PVOID ObjectBody,
105 PVOID Parent,
106 PWSTR RemainingPath,
107 struct _OBJECT_ATTRIBUTES* ObjectAttributes)
108 {
109 /* Call the Registered Callback */
110 return ExpDesktopObjectCreate(ObjectBody,
111 Parent,
112 RemainingPath,
113 ObjectAttributes);
114 }
115
116 VOID
117 STDCALL
118 ExpDesktopDelete(PVOID DeletedObject)
119 {
120 /* Call the Registered Callback */
121 ExpDesktopObjectDelete(DeletedObject);
122 }
123
124 VOID
125 INIT_FUNCTION
126 STDCALL
127 ExpWin32kInit(VOID)
128 {
129 OBJECT_TYPE_INITIALIZER ObjectTypeInitializer;
130 UNICODE_STRING Name;
131
132 DPRINT("Creating window station Object Type\n");
133
134 /* Create the window station Object Type */
135 RtlZeroMemory(&ObjectTypeInitializer, sizeof(ObjectTypeInitializer));
136 RtlInitUnicodeString(&Name, L"WindowStation");
137 ObjectTypeInitializer.Length = sizeof(ObjectTypeInitializer);
138 ObjectTypeInitializer.GenericMapping = ExpWindowStationMapping;
139 ObjectTypeInitializer.PoolType = NonPagedPool;
140 ObjectTypeInitializer.OpenProcedure = ExpWinStaObjectOpen;
141 ObjectTypeInitializer.DeleteProcedure = ExpWinStaObjectDelete;
142 ObjectTypeInitializer.ParseProcedure = ExpWinStaObjectParse;
143 ObpCreateTypeObject(&ObjectTypeInitializer, &Name, &ExWindowStationObjectType);
144
145 /* Create desktop object type */
146 RtlInitUnicodeString(&Name, L"Desktop");
147 ObjectTypeInitializer.GenericMapping = ExpDesktopMapping;
148 ObjectTypeInitializer.OpenProcedure = NULL;
149 ObjectTypeInitializer.DeleteProcedure = ExpDesktopDelete;
150 ObjectTypeInitializer.ParseProcedure = NULL;
151
152 ObpCreateTypeObject(&ObjectTypeInitializer, &Name, &ExDesktopObjectType);
153 }
154
155 /* EOF */