* the cygwin1.dll messes with the console mode so store and restore the console mode if necessary

git-svn-id: trunk@7218 -
This commit is contained in:
florian 2007-04-30 20:02:36 +00:00
parent 63c49a1555
commit 91cdcff845
3 changed files with 21 additions and 2 deletions

View File

@ -30,6 +30,9 @@ program FP;
(**********************************************************************)
uses
{$ifdef Windows}
windows,
{$endif Windows}
{$ifndef NODEBUG}
{$ifdef Windows}
fpcygwin,
@ -523,9 +526,13 @@ BEGIN
{$ifdef VESA}
DoneVESAScreenModes;
{$endif}
{$ifdef unix}
{$if defined(unix)}
Keyboard.RestoreStartMode;
{$endif unix}
{$endif defined(unix)}
{$if defined(windows)}
writeln(hexstr(StartupConsoleMode,8));
SetConsoleMode(GetStdHandle(cardinal(Std_Input_Handle)),StartupConsoleMode);
{$endif defined(windows)}
StreamError:=nil;
{$ifdef DEBUG}
if CloseImmediately then

View File

@ -28,6 +28,12 @@ unit sysinitcyg;
procedure Cygwin_crt0(p : pointer);cdecl;external name 'cygwin_crt0';
procedure __main;cdecl;external name '__main';
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 CMainEXE;cdecl;
begin
asm
@ -57,6 +63,10 @@ unit sysinitcyg;
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;

View File

@ -95,6 +95,8 @@ var
MainInstance,
cmdshow : longint;
DLLreason,DLLparam:longint;
StartupConsoleMode : DWORD;
type
TDLL_Process_Entry_Hook = function (dllparam : longint) : longbool;
TDLL_Entry_Hook = procedure (dllparam : longint);