]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/BufferImage.c
ShellPkg: Fix calls to SimpleTextOut->SetAttribute to not use reserved bits
[mirror_edk2.git] / ShellPkg / Library / UefiShellDebug1CommandsLib / HexEdit / BufferImage.c
index 1d770ea0c11f8ff4196ca3e9e3c4710630d92140..777c2e0199bc11559115a0c91f14b0aefc9ed4c4 100644 (file)
@@ -2,7 +2,7 @@
   Defines HBufferImage - the view of the file that is visible at any point,\r
   as well as the event handlers for editing the file\r
   \r
-  Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved. <BR>\r
+  Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved. <BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -318,9 +318,9 @@ HBufferImagePrintLine (
     }\r
 \r
     if (BeNewColor) {\r
-      gST->ConOut->SetAttribute (gST->ConOut, New.Data);\r
+      gST->ConOut->SetAttribute (gST->ConOut, New.Data & 0x7F);\r
     } else {\r
-      gST->ConOut->SetAttribute (gST->ConOut, Orig.Data);\r
+      gST->ConOut->SetAttribute (gST->ConOut, Orig.Data & 0x7F);\r
     }\r
 \r
     Pos = 10 + (Index * 3);\r
@@ -337,7 +337,7 @@ HBufferImagePrintLine (
 \r
   }\r
 \r
-  gST->ConOut->SetAttribute (gST->ConOut, Orig.Data);\r
+  gST->ConOut->SetAttribute (gST->ConOut, Orig.Data & 0x7F);\r
   while (Index < 0x08) {\r
     Pos = 10 + (Index * 3);\r
     ShellPrintEx ((INT32)Pos - 1, (INT32)Row - 1, L"    ");\r
@@ -355,9 +355,9 @@ HBufferImagePrintLine (
     }\r
 \r
     if (BeNewColor) {\r
-      gST->ConOut->SetAttribute (gST->ConOut, New.Data);\r
+      gST->ConOut->SetAttribute (gST->ConOut, New.Data & 0x7F);\r
     } else {\r
-      gST->ConOut->SetAttribute (gST->ConOut, Orig.Data);\r
+      gST->ConOut->SetAttribute (gST->ConOut, Orig.Data & 0x7F);\r
     }\r
 \r
     Pos = 10 + (Index * 3) + 1;\r
@@ -370,7 +370,7 @@ HBufferImagePrintLine (
     Index++;\r
   }\r
 \r
-  gST->ConOut->SetAttribute (gST->ConOut, Orig.Data);\r
+  gST->ConOut->SetAttribute (gST->ConOut, Orig.Data & 0x7F);\r
   while (Index < 0x10) {\r
     Pos = 10 + (Index * 3) + 1;\r
     ShellPrintEx ((INT32)Pos - 1, (INT32)Row - 1, L"   ");\r
@@ -379,7 +379,7 @@ HBufferImagePrintLine (
   //\r
   // restore the original color\r
   //\r
-  gST->ConOut->SetAttribute (gST->ConOut, Orig.Data);\r
+  gST->ConOut->SetAttribute (gST->ConOut, Orig.Data & 0x7F);\r
 \r
   //\r
   // PRINT the buffer content\r
@@ -581,8 +581,8 @@ HBufferImageRestoreMousePosition (
       //\r
       Orig                  = HMainEditor.ColorAttributes;\r
       New.Data              = 0;\r
-      New.Colors.Foreground = Orig.Colors.Background;\r
-      New.Colors.Background = Orig.Colors.Foreground;\r
+      New.Colors.Foreground = Orig.Colors.Background & 0xF;\r
+      New.Colors.Background = Orig.Colors.Foreground & 0x7;\r
 \r
       //\r
       // if in selected area,\r
@@ -594,7 +594,7 @@ HBufferImageRestoreMousePosition (
             )) {\r
         gST->ConOut->SetAttribute (gST->ConOut, Orig.Data);\r
       } else {\r
-        gST->ConOut->SetAttribute (gST->ConOut, New.Data);\r
+        gST->ConOut->SetAttribute (gST->ConOut, New.Data & 0x7F);\r
       }\r
       //\r
       // clear the old mouse position\r
@@ -646,7 +646,7 @@ HBufferImageRestoreMousePosition (
             HBufferImage.MousePosition.Row,\r
             HBufferImage.MousePosition.Column\r
             )) {\r
-        gST->ConOut->SetAttribute (gST->ConOut, New.Data);\r
+        gST->ConOut->SetAttribute (gST->ConOut, New.Data & 0x7F);\r
       } else {\r
         gST->ConOut->SetAttribute (gST->ConOut, Orig.Data);\r
       }\r