[KERNEL32][CONSRV]
[reactos.git] / reactos / win32ss / user / winsrv / consrv / conoutput.c
index 9265958..e8c55c7 100644 (file)
@@ -63,7 +63,7 @@ CSR_API(SrvSetConsolePalette)
     // PGRAPHICS_SCREEN_BUFFER Buffer;
     PCONSOLE_SCREEN_BUFFER Buffer;
 
-    DPRINT1("SrvSetConsolePalette\n");
+    DPRINT("SrvSetConsolePalette\n");
 
     // NOTE: Tests show that this function is used only for graphics screen buffers
     // and otherwise it returns FALSE + sets last error to invalid handle.
@@ -80,15 +80,21 @@ CSR_API(SrvSetConsolePalette)
                                    &Buffer, GENERIC_WRITE, TRUE);
     if (!NT_SUCCESS(Status)) return Status;
 
-    DPRINT1("ConDrvSetConsolePalette calling...\n");
+    /*
+     * Make the palette handle public, so that it can be
+     * used by other threads calling GDI functions on it.
+     * Indeed, the palette handle comes from a console app
+     * calling ourselves, running in CSRSS.
+     */
+    NtUserConsoleControl(ConsoleMakePalettePublic,
+                         &SetPaletteRequest->PaletteHandle,
+                         sizeof(SetPaletteRequest->PaletteHandle));
 
     Status = ConDrvSetConsolePalette(Buffer->Header.Console,
                                      Buffer,
                                      SetPaletteRequest->PaletteHandle,
                                      SetPaletteRequest->Usage);
 
-    DPRINT1("ConDrvSetConsolePalette returned Status 0x%08lx\n", Status);
-
     ConSrvReleaseScreenBuffer(Buffer, TRUE);
     return Status;
 }
@@ -317,7 +323,7 @@ CSR_API(SrvSetConsoleActiveScreenBuffer)
 static NTSTATUS
 DoWriteConsole(IN PCSR_API_MESSAGE ApiMessage,
                IN PCSR_THREAD ClientThread,
-               IN BOOL CreateWaitBlock OPTIONAL);
+               IN BOOLEAN CreateWaitBlock OPTIONAL);
 
 // Wait function CSR_WAIT_FUNCTION
 static BOOLEAN
@@ -345,9 +351,7 @@ WriteConsoleThread(IN PLIST_ENTRY WaitList,
         goto Quit;
     }
 
-    Status = DoWriteConsole(WaitApiMessage,
-                            WaitThread,
-                            FALSE);
+    Status = DoWriteConsole(WaitApiMessage, WaitThread, FALSE);
 
 Quit:
     if (Status != STATUS_PENDING)
@@ -368,7 +372,7 @@ ConDrvWriteConsole(IN PCONSOLE Console,
 static NTSTATUS
 DoWriteConsole(IN PCSR_API_MESSAGE ApiMessage,
                IN PCSR_THREAD ClientThread,
-               IN BOOL CreateWaitBlock OPTIONAL)
+               IN BOOLEAN CreateWaitBlock OPTIONAL)
 {
     NTSTATUS Status;
     PCONSOLE_WRITECONSOLE WriteConsoleRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.WriteConsoleRequest;
@@ -511,9 +515,7 @@ CSR_API(SrvWriteConsole)
         return STATUS_INVALID_PARAMETER;
     }
 
-    Status = DoWriteConsole(ApiMessage,
-                            CsrGetClientThread(),
-                            TRUE);
+    Status = DoWriteConsole(ApiMessage, CsrGetClientThread(), TRUE);
 
     if (Status == STATUS_PENDING) *ReplyCode = CsrReplyPending;