Convert title from UNICODE_STRING to nul-terminated
authorGé van Geldorp <ge@gse.nl>
Fri, 9 Sep 2005 11:43:26 +0000 (11:43 +0000)
committerGé van Geldorp <ge@gse.nl>
Fri, 9 Sep 2005 11:43:26 +0000 (11:43 +0000)
svn path=/trunk/; revision=17761

reactos/subsys/csrss/win32csr/guiconsole.c

index 29e6f2c..2494552 100644 (file)
@@ -786,6 +786,7 @@ GuiConsoleNotifyWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
   HWND NewWindow;
   LONG WindowCount;
   MSG Msg;
+  PWCHAR Buffer, Title;
   PCSRSS_CONSOLE Console = (PCSRSS_CONSOLE) lParam;
 
   switch(msg)
@@ -794,8 +795,20 @@ GuiConsoleNotifyWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
         SetWindowLongW(hWnd, GWL_USERDATA, 0);
         return 0;
       case PM_CREATE_CONSOLE:
+        Buffer = HeapAlloc(Win32CsrApiHeap, 0,
+                           Console->Title.Length + sizeof(WCHAR));
+        if (NULL != Buffer)
+          {
+            memcpy(Buffer, Console->Title.Buffer, Console->Title.Length);
+            Buffer[Console->Title.Length / sizeof(WCHAR)] = L'\0';
+            Title = Buffer;
+          }
+        else
+          {
+            Title = L"";
+          }
         NewWindow = CreateWindowW(L"ConsoleWindowClass",
-                                  Console->Title.Buffer,
+                                  Title,
                                   WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX,
                                   CW_USEDEFAULT,
                                   CW_USEDEFAULT,
@@ -805,6 +818,10 @@ GuiConsoleNotifyWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
                                   NULL,
                                   (HINSTANCE) GetModuleHandleW(NULL),
                                   (PVOID) Console);
+        if (NULL != Buffer)
+          {
+            HeapFree(Win32CsrApiHeap, 0, Buffer);
+          }
         Console->hWindow = NewWindow;
         if (NULL != NewWindow)
           {
@@ -934,7 +951,25 @@ GuiInitScreenBuffer(PCSRSS_CONSOLE Console, PCSRSS_SCREEN_BUFFER Buffer)
 STATIC BOOL STDCALL
 GuiChangeTitle(PCSRSS_CONSOLE Console)
 {
-  SendMessageW(Console->hWindow, WM_SETTEXT, 0, (LPARAM) Console->Title.Buffer);
+  PWCHAR Buffer, Title;
+
+  Buffer = HeapAlloc(Win32CsrApiHeap, 0,
+                     Console->Title.Length + sizeof(WCHAR));
+  if (NULL != Buffer)
+    {
+      memcpy(Buffer, Console->Title.Buffer, Console->Title.Length);
+      Buffer[Console->Title.Length / sizeof(WCHAR)] = L'\0';
+      Title = Buffer;
+    }
+  else
+    {
+      Title = L"";
+    }
+  SendMessageW(Console->hWindow, WM_SETTEXT, 0, (LPARAM) Title);
+  if (NULL != Buffer)
+    {
+      HeapFree(Win32CsrApiHeap, 0, Buffer);
+    }
 
   return TRUE;
 }