[USETUP][ROSAPPS][EXT2LIB] NtReadFile() calls: Remove unused 'ByteOffset = 0', Use...
[reactos.git] / base / setup / usetup / native / utils / console.c
index 327efe3..2ab380a 100644 (file)
@@ -19,7 +19,7 @@
 /*
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS text-mode setup
- * FILE:            subsys/system/usetup/console.c
+ * FILE:            base/setup/usetup/native/utils/console.c
  * PURPOSE:         Console support functions
  * PROGRAMMER:      Eric Kohl
  */
@@ -170,7 +170,7 @@ FlushConsoleInputBuffer(
                             &InputData,
                             sizeof(KEYBOARD_INPUT_DATA),
                             &Offset,
-                            0);
+                            NULL);
         if (Status == STATUS_PENDING)
         {
             Timeout.QuadPart = -100;
@@ -208,7 +208,7 @@ ReadConsoleInput(
                         &InputData,
                         sizeof(KEYBOARD_INPUT_DATA),
                         &Offset,
-                        0);
+                        NULL);
     if (Status == STATUS_PENDING)
     {
         Status = NtWaitForSingleObject(hConsoleInput, FALSE, NULL);
@@ -218,7 +218,7 @@ ReadConsoleInput(
         return FALSE;
 
     lpBuffer->EventType = KEY_EVENT;
-    Status = IntTranslateKey(&InputData, &lpBuffer->Event.KeyEvent);
+    Status = IntTranslateKey(hConsoleInput, &InputData, &lpBuffer->Event.KeyEvent);
     if (!NT_SUCCESS(Status))
         return FALSE;
 
@@ -285,19 +285,44 @@ WriteConsoleOutputCharacterW(
     COORD *pCoord;
     PCHAR pText;
     NTSTATUS Status;
-    ULONG i;
+//    ULONG i;
+
+    UNICODE_STRING UnicodeString;
+    OEM_STRING OemString;
+    ULONG OemLength;
+
+    UnicodeString.Length = nLength * sizeof(WCHAR);
+    UnicodeString.MaximumLength = nLength * sizeof(WCHAR);
+    UnicodeString.Buffer = (LPWSTR)lpCharacter;
+
+    OemLength = RtlUnicodeStringToOemSize(&UnicodeString);
+
 
     Buffer = (CHAR*)RtlAllocateHeap(ProcessHeap,
                                     0,
-                                    nLength + sizeof(COORD));
+                                    OemLength + sizeof(COORD));
+//                                    nLength + sizeof(COORD));
+    if (Buffer== NULL)
+        return FALSE;
+
     pCoord = (COORD *)Buffer;
     pText = (PCHAR)(pCoord + 1);
 
     *pCoord = dwWriteCoord;
 
+    OemString.Length = 0;
+    OemString.MaximumLength = OemLength;
+    OemString.Buffer = pText;
+
+    Status = RtlUnicodeStringToOemString(&OemString,
+                                         &UnicodeString,
+                                         FALSE);
+    if (!NT_SUCCESS(Status))
+        goto done;
+
     /* FIXME: use real unicode->oem conversion */
-    for (i = 0; i < nLength; i++)
-        pText[i] = (CHAR)lpCharacter[i];
+//    for (i = 0; i < nLength; i++)
+//        pText[i] = (CHAR)lpCharacter[i];
 
     Status = NtDeviceIoControlFile(hConsoleOutput,
                                    NULL,
@@ -310,6 +335,7 @@ WriteConsoleOutputCharacterW(
                                    Buffer,
                                    nLength + sizeof(COORD));
 
+done:
     RtlFreeHeap(ProcessHeap, 0, Buffer);
     if (!NT_SUCCESS(Status))
         return FALSE;