Browse Source

* set ConsoleStartupMode in all startup codes

git-svn-id: trunk@7274 -
florian 18 years ago
parent
commit
4e375e0c38
2 changed files with 17 additions and 0 deletions
  1. 10 0
      rtl/win32/sysinitgprof.pp
  2. 7 0
      rtl/win32/sysinitpas.pp

+ 10 - 0
rtl/win32/sysinitgprof.pp

@@ -45,6 +45,12 @@ unit sysinitgprof;
     procedure CMainEXE;cdecl;forward;
     procedure CMainDLL;cdecl;forward;
 
+    const
+      STD_INPUT_HANDLE = dword(-10);
+
+    function GetStdHandle(nStdHandle:DWORD) : THandle; stdcall; external 'kernel32' name 'GetStdHandle';
+    function GetConsoleMode(hConsoleHandle: THandle; var lpMode: DWORD): Boolean; stdcall; external 'kernel32' name 'GetConsoleMode';
+
     procedure EXEgmon_start;
       begin
         if monstarted=0 then
@@ -96,6 +102,10 @@ unit sysinitgprof;
           subl   $0x8,%esp
           andl   $0xfffffff0,%esp
         end;
+        { it seems cygwin messed around with the console mode so we've to
+          store the startup console mode before cygwin can do anything (FK)
+        }
+        GetConsoleMode(GetStdHandle((Std_Input_Handle)),StartupConsoleMode);
         Cygwin_crt0(@CMainEXE);
       end;
 

+ 7 - 0
rtl/win32/sysinitpas.pp

@@ -25,10 +25,17 @@ unit sysinitpas;
     procedure EXE_Entry; external name '_FPC_EXE_Entry';
     function DLL_entry : longbool; external name '_FPC_DLL_Entry';
 
+    const
+      STD_INPUT_HANDLE = dword(-10);
+
+    function GetStdHandle(nStdHandle:DWORD) : THandle; stdcall; external 'kernel32' name 'GetStdHandle';
+    function GetConsoleMode(hConsoleHandle: THandle; var lpMode: DWORD): Boolean; stdcall; external 'kernel32' name 'GetConsoleMode';
 
     procedure _FPC_mainCRTStartup;stdcall;public name '_mainCRTStartup';
     begin
       IsConsole:=true;
+      { do it like it is necessary for the startup code linking against cygwin }
+      GetConsoleMode(GetStdHandle((Std_Input_Handle)),StartupConsoleMode);
       Exe_entry;
     end;