--- edit/libEditor.c (revision 30)\r
+++ edit/libEditor.c (working copy)\r
@@ -88,8 +88,6 @@\r
- )\r
- {\r
- EFI_STATUS Status;\r
-- EFI_HANDLE *HandleBuffer;\r
-- UINTN HandleCount;\r
- \r
- //\r
- // basic initialization\r
+ )
+ {
+ EFI_STATUS Status;
+- EFI_HANDLE *HandleBuffer;
+- UINTN HandleCount;
+
+ //
+ // basic initialization
@@ -117,38 +115,22 @@\r
- );\r
- \r
- //\r
-- // Find mouse\r
-+ // Find mouse in System Table ConsoleInHandle\r
- //\r
-- HandleBuffer = NULL;\r
-- Status = LibLocateHandle (\r
-- ByProtocol,\r
-- &gEfiPrimaryConsoleInDeviceGuid,\r
-- NULL,\r
-- &HandleCount,\r
-- &HandleBuffer\r
-- );\r
-+ Status = BS->HandleProtocol (\r
-+ In,\r
-+ &gEfiSimplePointerProtocolGuid,\r
-+ &MainEditor.MouseInterface\r
-+ );\r
- \r
-- if (!EFI_ERROR (Status)) {\r
-- if (HandleCount > 0) {\r
-- Status = BS->HandleProtocol (\r
-- HandleBuffer[0],\r
-- &gEfiSimplePointerProtocolGuid,\r
-- &MainEditor.MouseInterface\r
-- );\r
--\r
-- if (EFI_ERROR (Status)) {\r
-- MainEditor.MouseInterface = NULL;\r
-- } else {\r
-- MainEditor.MouseAccumulatorX = 0;\r
-- MainEditor.MouseAccumulatorY = 0;\r
-- MainEditor.MouseSupported = TRUE;\r
-- }\r
-- }\r
-+ if (EFI_ERROR (Status)) {\r
-+ MainEditor.MouseInterface = NULL;\r
-+ } else {\r
-+ MainEditor.MouseAccumulatorX = 0;\r
-+ MainEditor.MouseAccumulatorY = 0;\r
-+ MainEditor.MouseSupported = TRUE;\r
- }\r
- \r
-- if (HandleBuffer) {\r
-- FreePool (HandleBuffer);\r
-- }\r
- //\r
- // below will call the five components' init function\r
- //\r
+ );
+
+ //
+- // Find mouse
++ // Find mouse in System Table ConsoleInHandle
+ //
+- HandleBuffer = NULL;
+- Status = LibLocateHandle (
+- ByProtocol,
+- &gEfiPrimaryConsoleInDeviceGuid,
+- NULL,
+- &HandleCount,
+- &HandleBuffer
+- );
++ Status = BS->HandleProtocol (
++ In,
++ &gEfiSimplePointerProtocolGuid,
++ &MainEditor.MouseInterface
++ );
+
+- if (!EFI_ERROR (Status)) {
+- if (HandleCount > 0) {
+- Status = BS->HandleProtocol (
+- HandleBuffer[0],
+- &gEfiSimplePointerProtocolGuid,
+- &MainEditor.MouseInterface
+- );
+-
+- if (EFI_ERROR (Status)) {
+- MainEditor.MouseInterface = NULL;
+- } else {
+- MainEditor.MouseAccumulatorX = 0;
+- MainEditor.MouseAccumulatorY = 0;
+- MainEditor.MouseSupported = TRUE;
+- }
+- }
++ if (EFI_ERROR (Status)) {
++ MainEditor.MouseInterface = NULL;
++ } else {
++ MainEditor.MouseAccumulatorX = 0;
++ MainEditor.MouseAccumulatorY = 0;
++ MainEditor.MouseSupported = TRUE;
+ }
+
+- if (HandleBuffer) {
+- FreePool (HandleBuffer);
+- }
+ //
+ // below will call the five components' init function
+ //
Index: edit/libFileBuffer.c\r
===================================================================\r
--- edit/libFileBuffer.c (revision 30)\r
+ if ((FileSize >= 2) && (*((UINT16 *) Buffer) == EFI_UNICODE_BYTE_ORDER_MARK)) {
//
// Unicode file's size should be even
- //\r
+ //
Index: hexedit/libEditor.c\r
===================================================================\r
--- hexedit/libEditor.c (revision 30)\r
+++ hexedit/libEditor.c (working copy)\r
@@ -100,8 +100,6 @@\r
- --*/\r
- {\r
- EFI_STATUS Status;\r
-- EFI_HANDLE *HandleBuffer;\r
-- UINTN HandleCount;\r
- \r
- //\r
- // basic initialization\r
+ --*/
+ {
+ EFI_STATUS Status;
+- EFI_HANDLE *HandleBuffer;
+- UINTN HandleCount;
+
+ //
+ // basic initialization
@@ -129,36 +127,19 @@\r
- &(HMainEditor.ScreenSize.Row)\r
- );\r
- \r
-- HandleBuffer = NULL;\r
-- Status = LibLocateHandle (\r
-- ByProtocol,\r
-- &gEfiPrimaryConsoleInDeviceGuid,\r
-- NULL,\r
-- &HandleCount,\r
-- &HandleBuffer\r
-- );\r
--\r
-- if (!EFI_ERROR (Status)) {\r
--\r
-- if (HandleCount > 0) {\r
-- Status = BS->HandleProtocol (\r
-- HandleBuffer[0],\r
-- &gEfiSimplePointerProtocolGuid,\r
-- &HMainEditor.MouseInterface\r
-- );\r
-- if (EFI_ERROR (Status)) {\r
-- HMainEditor.MouseInterface = NULL;\r
-- } else {\r
-- HMainEditor.MouseAccumulatorX = 0;\r
-- HMainEditor.MouseAccumulatorY = 0;\r
-- HMainEditor.MouseSupported = TRUE;\r
-- }\r
-- }\r
-+ Status = BS->HandleProtocol (\r
-+ In,\r
-+ &gEfiSimplePointerProtocolGuid,\r
-+ &HMainEditor.MouseInterface\r
-+ );\r
-+ if (EFI_ERROR (Status)) {\r
-+ HMainEditor.MouseInterface = NULL;\r
-+ } else {\r
-+ HMainEditor.MouseAccumulatorX = 0;\r
-+ HMainEditor.MouseAccumulatorY = 0;\r
-+ HMainEditor.MouseSupported = TRUE;\r
- }\r
- \r
-- if (HandleBuffer != NULL) {\r
-- FreePool (HandleBuffer);\r
-- }\r
- //\r
- // below will call the five components' init function\r
+ &(HMainEditor.ScreenSize.Row)
+ );
+
+- HandleBuffer = NULL;
+- Status = LibLocateHandle (
+- ByProtocol,
+- &gEfiPrimaryConsoleInDeviceGuid,
+- NULL,
+- &HandleCount,
+- &HandleBuffer
+- );
+-
+- if (!EFI_ERROR (Status)) {
+-
+- if (HandleCount > 0) {
+- Status = BS->HandleProtocol (
+- HandleBuffer[0],
+- &gEfiSimplePointerProtocolGuid,
+- &HMainEditor.MouseInterface
+- );
+- if (EFI_ERROR (Status)) {
+- HMainEditor.MouseInterface = NULL;
+- } else {
+- HMainEditor.MouseAccumulatorX = 0;
+- HMainEditor.MouseAccumulatorY = 0;
+- HMainEditor.MouseSupported = TRUE;
+- }
+- }
++ Status = BS->HandleProtocol (
++ In,
++ &gEfiSimplePointerProtocolGuid,
++ &HMainEditor.MouseInterface
++ );
++ if (EFI_ERROR (Status)) {
++ HMainEditor.MouseInterface = NULL;
++ } else {
++ HMainEditor.MouseAccumulatorX = 0;
++ HMainEditor.MouseAccumulatorY = 0;
++ HMainEditor.MouseSupported = TRUE;
+ }
+
+- if (HandleBuffer != NULL) {
+- FreePool (HandleBuffer);
+- }
+ //
+ // below will call the five components' init function
//
Index: Library/EfiShellLib.h\r
===================================================================\r
--- shellenv/Connect.c (revision 30)\r
+++ shellenv/Connect.c (working copy)\r
@@ -831,6 +831,16 @@\r
- return Status;\r
- }\r
- \r
-+ //\r
-+ // Close proxy console before disconnect all devices.\r
-+ //\r
-+ SEnvCloseConsoleProxy (\r
-+ ST->ConsoleInHandle,\r
-+ &ST->ConIn,\r
-+ ST->ConsoleOutHandle,\r
-+ &ST->ConOut\r
-+ );\r
-+\r
- for (Index = 0; Index < AllHandleCount; Index++) {\r
- //\r
- // Check whether the handle is still in handle database\r
+ return Status;
+ }
+
++ //
++ // Close proxy console before disconnect all devices.
++ //
++ SEnvCloseConsoleProxy (
++ ST->ConsoleInHandle,
++ &ST->ConIn,
++ ST->ConsoleOutHandle,
++ &ST->ConOut
++ );
++
+ for (Index = 0; Index < AllHandleCount; Index++) {
+ //
+ // Check whether the handle is still in handle database
@@ -1004,7 +1014,6 @@\r
- VOID\r
- SEnvConnectConsole (\r
- CHAR16 *VariableName,\r
-- EFI_GUID *PrimaryGuid,\r
- EFI_GUID *ConsoleGuid,\r
- EFI_HANDLE *ConsoleHandle,\r
- VOID **ConsoleInterface\r
-@@ -1018,9 +1027,8 @@\r
- EFI_HANDLE *AllHandleBuffer;\r
- VOID *Interface;\r
- \r
-- *ConsoleHandle = NULL;\r
-- *ConsoleInterface = NULL;\r
- ConsoleIndex = 0;\r
-+ AllHandleBuffer = NULL;\r
- \r
- DevicePath = LibGetVariable (VariableName, &gEfiGlobalVariableGuid);\r
- if (DevicePath != NULL) {\r
-@@ -1028,17 +1036,19 @@\r
- FreePool (DevicePath);\r
- }\r
- \r
-- AllHandleBuffer = NULL;\r
-- Status = BS->LocateHandleBuffer (\r
-- ByProtocol,\r
-- PrimaryGuid,\r
-- NULL,\r
-- &AllHandleCount,\r
-- &AllHandleBuffer\r
-- );\r
-- if (!EFI_ERROR (Status) && AllHandleCount > 0) {\r
-- *ConsoleHandle = AllHandleBuffer[0];\r
-- } else if (*ConsoleHandle == NULL) {\r
-+ Status = EFI_NOT_FOUND;\r
-+ //\r
-+ // Check ConsoleHandle validation whatever it was updated or not.\r
-+ //\r
-+ if (*ConsoleHandle != NULL) {\r
-+ Status = BS->HandleProtocol (\r
-+ *ConsoleHandle,\r
-+ ConsoleGuid,\r
-+ &Interface\r
-+ );\r
-+ }\r
-+\r
-+ if (EFI_ERROR (Status)) {\r
- AllHandleBuffer = NULL;\r
- Status = BS->LocateHandleBuffer (\r
- ByProtocol,\r
-@@ -1063,16 +1073,16 @@\r
- &gEfiDevicePathProtocolGuid,\r
- &Interface\r
- );\r
-- if (EFI_ERROR (Status)) {\r
-+ if (!EFI_ERROR (Status)) {\r
- ConsoleIndex = Index;\r
- break;\r
- }\r
- }\r
-+ \r
-+ *ConsoleHandle = AllHandleBuffer[ConsoleIndex];\r
- }\r
- }\r
- \r
-- *ConsoleHandle = AllHandleBuffer[ConsoleIndex];\r
--\r
- if (*ConsoleHandle != NULL) {\r
- BS->HandleProtocol (\r
- *ConsoleHandle,\r
-@@ -1081,7 +1091,7 @@\r
- );\r
- }\r
- \r
-- if (AllHandleBuffer) {\r
-+ if (AllHandleBuffer != NULL) {\r
- FreePool (AllHandleBuffer);\r
- }\r
- }\r
-@@ -1189,8 +1199,7 @@\r
- EFI_STATUS Status;\r
- \r
- //\r
-- // Check current ConIn and ConOut to ensure it is the ConsoleProxy\r
-- // Otherwise, the Console should not be close\r
-+ // Check current ConIn and ConOut to judge it is the ConsoleProxy\r
- //\r
- Status = SEnvCheckConsoleProxy (\r
- ST->ConsoleInHandle,\r
-@@ -1203,23 +1212,21 @@\r
- // Indicate the Console is replaced by redirection operation\r
- // It is not safe to connect Console here\r
- //\r
-- if (EFI_ERROR (Status)) {\r
-- return ;\r
-+ if (!EFI_ERROR (Status)) {\r
-+ //\r
-+ // It is proxy console, to prevent the proxy console form being restored to original console,\r
-+ // close it temporary before connect all console\r
-+ //\r
-+ SEnvCloseConsoleProxy (\r
-+ ST->ConsoleInHandle,\r
-+ &ST->ConIn,\r
-+ ST->ConsoleOutHandle,\r
-+ &ST->ConOut\r
-+ );\r
- }\r
-- //\r
-- // To prevent the proxy console form being restored to original console,\r
-- // close it temporary before connect all console\r
-- //\r
-- SEnvCloseConsoleProxy (\r
-- ST->ConsoleInHandle,\r
-- &ST->ConIn,\r
-- ST->ConsoleOutHandle,\r
-- &ST->ConOut\r
-- );\r
- \r
- SEnvConnectConsole (\r
- VarErrorOut,\r
-- &gEfiPrimaryStandardErrorDeviceGuid,\r
- &gEfiSimpleTextOutProtocolGuid,\r
- &ST->StandardErrorHandle,\r
- (VOID **) &ST->StdErr\r
-@@ -1227,7 +1234,6 @@\r
- \r
- SEnvConnectConsole (\r
- VarConsoleOut,\r
-- &gEfiPrimaryConsoleOutDeviceGuid,\r
- &gEfiSimpleTextOutProtocolGuid,\r
- &ST->ConsoleOutHandle,\r
- (VOID **) &ST->ConOut\r
-@@ -1235,7 +1241,6 @@\r
- \r
- SEnvConnectConsole (\r
- VarConsoleIn,\r
-- &gEfiPrimaryConsoleInDeviceGuid,\r
- &gEfiSimpleTextInProtocolGuid,\r
- &ST->ConsoleInHandle,\r
- (VOID **) &ST->ConIn\r
-@@ -1254,6 +1259,8 @@\r
- SetCrc (&ST->Hdr);\r
- }\r
- \r
-+\r
-+\r
- EFI_STATUS\r
- EFIAPI\r
- SEnvCmdReconnect (\r
+ VOID
+ SEnvConnectConsole (
+ CHAR16 *VariableName,
+- EFI_GUID *PrimaryGuid,
+ EFI_GUID *ConsoleGuid,
+ EFI_HANDLE *ConsoleHandle,
+ VOID **ConsoleInterface
+@@ -1018,27 +1027,36 @@\r
+ EFI_HANDLE *AllHandleBuffer;
+ VOID *Interface;
+
+- *ConsoleHandle = NULL;
+- *ConsoleInterface = NULL;
+ ConsoleIndex = 0;
++ AllHandleBuffer = NULL;
+
+ DevicePath = LibGetVariable (VariableName, &gEfiGlobalVariableGuid);
+- if (DevicePath != NULL) {
+- SEnvConnectDevicePath (DevicePath);
+- FreePool (DevicePath);
++ if (DevicePath == NULL) {
++ //
++ // If no any device defined in EFI variable, do nothing
++ //
++ return;
+ }
+
+- AllHandleBuffer = NULL;
+- Status = BS->LocateHandleBuffer (
+- ByProtocol,
+- PrimaryGuid,
+- NULL,
+- &AllHandleCount,
+- &AllHandleBuffer
+- );
+- if (!EFI_ERROR (Status) && AllHandleCount > 0) {
+- *ConsoleHandle = AllHandleBuffer[0];
+- } else if (*ConsoleHandle == NULL) {
++ //
++ // Connect all console devices
++ //
++ SEnvConnectDevicePath (DevicePath);
++ FreePool (DevicePath);
++
++ Status = EFI_NOT_FOUND;
++ //
++ // Check ConsoleHandle validation whatever it was updated or not.
++ //
++ if (*ConsoleHandle != NULL) {
++ Status = BS->HandleProtocol (
++ *ConsoleHandle,
++ ConsoleGuid,
++ &Interface
++ );
++ }
++
++ if (EFI_ERROR (Status)) {
+ AllHandleBuffer = NULL;
+ Status = BS->LocateHandleBuffer (
+ ByProtocol,
+@@ -1063,16 +1081,16 @@\r
+ &gEfiDevicePathProtocolGuid,
+ &Interface
+ );
+- if (EFI_ERROR (Status)) {
++ if (!EFI_ERROR (Status)) {
+ ConsoleIndex = Index;
+ break;
+ }
+ }
++
++ *ConsoleHandle = AllHandleBuffer[ConsoleIndex];
+ }
+ }
+
+- *ConsoleHandle = AllHandleBuffer[ConsoleIndex];
+-
+ if (*ConsoleHandle != NULL) {
+ BS->HandleProtocol (
+ *ConsoleHandle,
+@@ -1081,7 +1099,7 @@\r
+ );
+ }
+
+- if (AllHandleBuffer) {
++ if (AllHandleBuffer != NULL) {
+ FreePool (AllHandleBuffer);
+ }
+ }
+@@ -1189,8 +1207,7 @@\r
+ EFI_STATUS Status;
+
+ //
+- // Check current ConIn and ConOut to ensure it is the ConsoleProxy
+- // Otherwise, the Console should not be close
++ // Check current ConIn and ConOut to judge it is the ConsoleProxy
+ //
+ Status = SEnvCheckConsoleProxy (
+ ST->ConsoleInHandle,
+@@ -1203,23 +1220,21 @@\r
+ // Indicate the Console is replaced by redirection operation
+ // It is not safe to connect Console here
+ //
+- if (EFI_ERROR (Status)) {
+- return ;
++ if (!EFI_ERROR (Status)) {
++ //
++ // It is proxy console, to prevent the proxy console form being restored to original console,
++ // close it temporary before connect all console
++ //
++ SEnvCloseConsoleProxy (
++ ST->ConsoleInHandle,
++ &ST->ConIn,
++ ST->ConsoleOutHandle,
++ &ST->ConOut
++ );
+ }
+- //
+- // To prevent the proxy console form being restored to original console,
+- // close it temporary before connect all console
+- //
+- SEnvCloseConsoleProxy (
+- ST->ConsoleInHandle,
+- &ST->ConIn,
+- ST->ConsoleOutHandle,
+- &ST->ConOut
+- );
+
+ SEnvConnectConsole (
+ VarErrorOut,
+- &gEfiPrimaryStandardErrorDeviceGuid,
+ &gEfiSimpleTextOutProtocolGuid,
+ &ST->StandardErrorHandle,
+ (VOID **) &ST->StdErr
+@@ -1227,7 +1242,6 @@\r
+
+ SEnvConnectConsole (
+ VarConsoleOut,
+- &gEfiPrimaryConsoleOutDeviceGuid,
+ &gEfiSimpleTextOutProtocolGuid,
+ &ST->ConsoleOutHandle,
+ (VOID **) &ST->ConOut
+@@ -1235,7 +1249,6 @@\r
+
+ SEnvConnectConsole (
+ VarConsoleIn,
+- &gEfiPrimaryConsoleInDeviceGuid,
+ &gEfiSimpleTextInProtocolGuid,
+ &ST->ConsoleInHandle,
+ (VOID **) &ST->ConIn
+@@ -1254,6 +1267,8 @@\r
+ SetCrc (&ST->Hdr);
+ }
+
++
++
+ EFI_STATUS
+ EFIAPI
+ SEnvCmdReconnect (
Index: SmbiosView/PrintInfo.c\r
===================================================================\r
--- SmbiosView/PrintInfo.c (revision 30)\r