adding win32ksys the syscall lib for win32k
[reactos.git] / reactos / subsystems / win32 / csrss / win32csr / guiconsole.c
index bc7ec14..6bf3f8e 100644 (file)
@@ -139,8 +139,8 @@ GuiConsoleAppendMenuItems(HMENU hMenu,
                     hSubMenu = CreatePopupMenu();
                     if (hSubMenu != NULL)
                     {
-                        GuiConsoleAppendMenuItems(hSubMenu,
-                                                  Items[i].SubMenu);
+                        /*GuiConsoleAppendMenuItems(hSubMenu,
+                                                  Items[i].SubMenu);*/
 
                         if (!AppendMenuW(hMenu,
                                          MF_STRING | MF_POPUP,
@@ -148,6 +148,7 @@ GuiConsoleAppendMenuItems(HMENU hMenu,
                                          szMenuString))
                         {
                             DestroyMenu(hSubMenu);
+                            DPRINT1("DestroyMenu \n");
                         }
                     }
                 }
@@ -179,9 +180,14 @@ GuiConsoleCreateSysMenu(PCSRSS_CONSOLE Console)
                           FALSE);
     if (hMenu != NULL)
     {
+        DPRINT1("adding menu\n");
         GuiConsoleAppendMenuItems(hMenu,
                                   GuiConsoleMainMenuItems);
     }
+    else
+    {
+      DPRINT1("This should never happen, GetSystemMenu == NULL \n");
+    }
 }
 
 static VOID FASTCALL
@@ -236,10 +242,12 @@ GuiConsoleOpenUserRegistryPathPerProcessId(DWORD ProcessId, PHANDLE hProcHandle,
   RtlFreeUnicodeString(&SidName);
 
   CloseHandle(hProcessToken);
-  if (hProcHandle)
-    *hProcHandle = hProcess;
-  else
-    CloseHandle(hProcess);
+  CloseHandle(hProcess);
+
+  //if (hProcHandle)
+  //  *hProcHandle = hProcess;
+  //else
+  //  CloseHandle(hProcess);
 
   if (res != ERROR_SUCCESS)
     return FALSE;
@@ -276,21 +284,26 @@ GuiConsoleOpenUserSettings(PGUI_CONSOLE_DATA GuiData, DWORD ProcessId, PHKEY hSu
   
   DPRINT("GuiConsoleOpenUserSettings entered\n");
 
+  DPRINT1("ProcessId %d\n",ProcessId);
+
   if (!GuiConsoleOpenUserRegistryPathPerProcessId(ProcessId, &hProcess, &hKey, samDesired))
     {
-      DPRINT("GuiConsoleOpenUserRegistryPathPerProcessId failed\n"); 
+      DPRINT1("GuiConsoleOpenUserRegistryPathPerProcessId failed\n"); 
       return FALSE;
     }
+  
+  hProcess = OpenProcess( PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, ProcessId );
+
 
   /* FIXME we do not getting the process name so no menu will be loading, why ?*/
   fLength = GetProcessImageFileNameW(hProcess, szProcessName, sizeof(GuiData->szProcessName) / sizeof(WCHAR));
   CloseHandle(hProcess);
 
-  //DPRINT1("szProcessName3 : %S\n",szProcessName);
+  DPRINT1("szProcessName3 : %S\n",szProcessName);
 
   if (!fLength)
     {
-      DPRINT("GetProcessImageFileNameW failed(0x%x)ProcessId %d\n", GetLastError(),hProcess);
+      DPRINT1("GetProcessImageFileNameW failed(0x%x)ProcessId %d\n", GetLastError(),hProcess);
       return FALSE;
     }
   /*
@@ -658,6 +671,8 @@ GuiConsoleHandleNcCreate(HWND hWnd, CREATESTRUCTW *Create)
   if (Console->ProcessList.Flink != &Console->ProcessList)
     {
       ProcessData = CONTAINING_RECORD(Console->ProcessList.Flink, CSRSS_PROCESS_DATA, ProcessEntry);
+      DPRINT1("PtrToUlong(ProcessData->ProcessId) == %d",PtrToUlong(ProcessData->ProcessId));
+
       if (GuiConsoleOpenUserSettings(GuiData, PtrToUlong(ProcessData->ProcessId), &hKey, KEY_READ, FALSE))
         {
           GuiConsoleReadUserSettings(hKey, Console, GuiData, Console->ActiveBuffer);
@@ -1263,13 +1278,20 @@ GuiConsoleHandleNcDestroy(HWND hWnd)
 {
   PCSRSS_CONSOLE Console;
   PGUI_CONSOLE_DATA GuiData;
+  HMENU menu;
 
 
   GuiConsoleGetDataPointers(hWnd, &Console, &GuiData);
   KillTimer(hWnd, 1);
   Console->PrivateData = NULL;
   DeleteCriticalSection(&GuiData->Lock);
-  GetSystemMenu(hWnd, TRUE);
+
+  menu = GetSystemMenu(hWnd, TRUE);
+  if (menu == NULL)
+  {
+      DPRINT1("This should never happen, GetSystemMenu == NULL \n");
+  }
+
   if (GuiData->ConsoleLibrary)
     FreeLibrary(GuiData->ConsoleLibrary);