Fix one of the added hacks. ObpCreateHAndle not exported anymore, and win32k now duplicates the handle nicely (Also faster since we don't have to attach/detach to csr anymore
Modified: trunk/reactos/ntoskrnl/ntoskrnl.def
Modified: trunk/reactos/subsys/win32k/include/csr.h
Modified: trunk/reactos/subsys/win32k/ntuser/csr.c
Modified: trunk/reactos/subsys/win32k/ntuser/desktop.c

Modified: trunk/reactos/ntoskrnl/ntoskrnl.def
--- trunk/reactos/ntoskrnl/ntoskrnl.def	2005-05-19 22:04:45 UTC (rev 15415)
+++ trunk/reactos/ntoskrnl/ntoskrnl.def	2005-05-19 23:26:56 UTC (rev 15416)
@@ -823,7 +823,6 @@
 ;ObCheckCreateObjectAccess@28
 ;ObCheckObjectAccess@20
 ObCreateObject@36
-ObpCreateHandle ; FIXME! See win32k/ntuser/csr.c!
 ObFindHandleForObject@20
 ObGetObjectPointerCount@4
 ObGetObjectSecurity@12

Modified: trunk/reactos/subsys/win32k/include/csr.h
--- trunk/reactos/subsys/win32k/include/csr.h	2005-05-19 22:04:45 UTC (rev 15415)
+++ trunk/reactos/subsys/win32k/include/csr.h	2005-05-19 23:26:56 UTC (rev 15416)
@@ -15,7 +15,11 @@
 extern NTSTATUS FASTCALL CsrInit(void);
 extern NTSTATUS FASTCALL CsrNotify(PCSRSS_API_REQUEST Request, PCSRSS_API_REPLY Reply);
 extern NTSTATUS FASTCALL CsrCloseHandle(HANDLE Handle);
-extern NTSTATUS STDCALL CsrInsertObject(PVOID, PACCESS_STATE, ACCESS_MASK, ULONG, PVOID*, PHANDLE);
+NTSTATUS
+STDCALL
+CsrInsertObject(HANDLE ObjectHandle,
+                ACCESS_MASK DesiredAccess,
+                PHANDLE Handle);
 
 #endif /* CSR_H_INCLUDED */
 

Modified: trunk/reactos/subsys/win32k/ntuser/csr.c
--- trunk/reactos/subsys/win32k/ntuser/csr.c	2005-05-19 22:04:45 UTC (rev 15415)
+++ trunk/reactos/subsys/win32k/ntuser/csr.c	2005-05-19 23:26:56 UTC (rev 15416)
@@ -11,13 +11,6 @@
 
 static HANDLE WindowsApiPort = NULL;
 PEPROCESS CsrProcess = NULL;
-
-NTSTATUS
-ObpCreateHandle(PEPROCESS Process,
-                PVOID ObjectBody,
-                ACCESS_MASK GrantedAccess,
-                BOOLEAN Inherit,
-                PHANDLE HandleReturn);
            
 NTSTATUS FASTCALL
 CsrInit(void)
@@ -83,37 +76,46 @@
   return Status;
 }
 
-NTSTATUS STDCALL
-CsrInsertObject(PVOID Object,
-                PACCESS_STATE PassedAccessState,
+NTSTATUS
+STDCALL
+CsrInsertObject(HANDLE ObjectHandle,
                 ACCESS_MASK DesiredAccess,
-                ULONG AdditionalReferences,
-                PVOID* ReferencedObject,
                 PHANDLE Handle)
 {
   NTSTATUS Status;
-  PEPROCESS OldProcess;
+  HANDLE CsrProcessHandle;
+  OBJECT_ATTRIBUTES ObjectAttributes;
+  CLIENT_ID Cid;
+  
+  /* Put CSR'S CID */
+  Cid.UniqueProcess = CsrProcess->UniqueProcessId;
+  Cid.UniqueThread = 0;
+  
+  /* Empty Attributes */
+  InitializeObjectAttributes(&ObjectAttributes,
+                             NULL,
+                             0,
+                             NULL,
+                             NULL);
+  
+  /* Get a Handle to Csrss */
+  Status = ZwOpenProcess(&CsrProcessHandle,
+                         PROCESS_DUP_HANDLE,
+                         &ObjectAttributes,
+                         &Cid);
+                         
+  /* Duplicate the Handle */
+  Status = ZwDuplicateObject(NtCurrentProcess(),
+                             ObjectHandle,
+                             CsrProcessHandle,
+                             Handle,
+                             DesiredAccess,
+                             TRUE,
+                             0);
+  
+  /* Close our handle to CSRSS */
+  NtClose(CsrProcessHandle);
 
-  /* Switch to the process in which the handle is valid */
-  OldProcess = PsGetCurrentProcess();
-  if (CsrProcess != OldProcess)
-    {
-      KeAttachProcess(CsrProcess);
-    }
-
-  /* FIXME!!!!!!!!! SOMETHING HAS GOT TO BE DONE ABOUT THIS !!!!! */
-  Status = ObpCreateHandle(PsGetCurrentProcess(),
-                           Object,
-                           DesiredAccess,
-                           BODY_TO_HEADER(Object)->Inherit,
-                           Handle);
-  /* FIXME!!!!!!!!! SOMETHING HAS GOT TO BE DONE ABOUT ^^^^ THAT !!!!! */
-
-  if (CsrProcess != OldProcess)
-    {
-      KeDetachProcess();
-    }
-
   return Status;
 }
 

Modified: trunk/reactos/subsys/win32k/ntuser/desktop.c
--- trunk/reactos/subsys/win32k/ntuser/desktop.c	2005-05-19 22:04:45 UTC (rev 15415)
+++ trunk/reactos/subsys/win32k/ntuser/desktop.c	2005-05-19 23:26:56 UTC (rev 15416)
@@ -843,11 +843,8 @@
    * Create a handle for CSRSS and notify CSRSS
    */
   Request.Type = CSRSS_CREATE_DESKTOP;
-  Status = CsrInsertObject((PVOID)DesktopObject,
-                           NULL,
+  Status = CsrInsertObject(Desktop,
                            GENERIC_ALL,
-                           0,
-                           NULL,
                            (HANDLE*)&Request.Data.CreateDesktopRequest.DesktopHandle);
   if (! NT_SUCCESS(Status))
   {