public inbox for cygwin-apps@cygwin.com
 help / color / mirror / Atom feed
* [PATCH] setup.exe: add autoload and version check for AttachConsole
@ 2009-04-01 11:44 Dave Korn
  2009-04-01 14:00 ` Christopher Faylor
  0 siblings, 1 reply; 3+ messages in thread
From: Dave Korn @ 2009-04-01 11:44 UTC (permalink / raw)
  To: cygwin-apps

[-- Attachment #1: Type: text/plain, Size: 834 bytes --]


    Hi gang,

  AttachConsole (added recently for stdout/stderr handling) doesn't exist on
win2k, having been introduced in xp/2k3, so setup HEAD currently doesn't run
there.

  The attached patch fixes the load-time problem by adding an autoload.  That
won't prevent the run-time crash if the function gets called, of course; so it
also adds a version check before the call.

  Unless anyone shouts, I'll commit it later today; I think this is basically
obvious.  Tested by verifying under GDB that it avoids the SEGV and by seeing
that with the patch the setup.log and setup.log.full files are successfully
generated.

	* autoload.c (kernel32):  Add autoload entry for AttachConsole.
	* main.cc (set_cout):  Check IsXpOrBetter before trying to use it.
	* win32.h (IsXpOrBetter):  New version check macro.

    cheers,
      DaveK


[-- Attachment #2: setup-console-autoload.diff --]
[-- Type: text/plain, Size: 1691 bytes --]

Index: autoload.c
===================================================================
RCS file: /cvs/cygwin-apps/setup/autoload.c,v
retrieving revision 2.7
diff -p -u -r2.7 autoload.c
--- autoload.c	8 Apr 2008 23:50:54 -0000	2.7
+++ autoload.c	1 Apr 2009 11:38:26 -0000
@@ -61,6 +61,8 @@ Auto (advapi32, OpenServiceA, 16);
 Auto (advapi32, QueryServiceStatus, 8);
 Auto (advapi32, StartServiceA, 16);
 
+DLL (kernel32);
+Auto (kernel32, AttachConsole, 4);
 
 typedef struct {
   DllInfo *dll;
Index: main.cc
===================================================================
RCS file: /cvs/cygwin-apps/setup/main.cc,v
retrieving revision 2.48
diff -p -u -r2.48 main.cc
--- main.cc	21 Mar 2009 21:00:25 -0000	2.48
+++ main.cc	1 Apr 2009 11:38:26 -0000
@@ -85,7 +85,7 @@ set_cout ()
 {
   HANDLE hstdout = GetStdHandle (STD_OUTPUT_HANDLE);
   if (GetFileType (hstdout) == FILE_TYPE_UNKNOWN && GetLastError () != NO_ERROR
-      && AttachConsole ((DWORD) -1))
+      && IsXpOrBetter () && AttachConsole ((DWORD) -1))
       {
 	ofstream *conout = new ofstream ("conout$");
 	cout.rdbuf (conout->rdbuf ());
Index: win32.h
===================================================================
RCS file: /cvs/cygwin-apps/setup/win32.h,v
retrieving revision 2.17
diff -p -u -r2.17 win32.h
--- win32.h	20 Aug 2008 10:33:25 -0000	2.17
+++ win32.h	1 Apr 2009 11:38:27 -0000
@@ -162,5 +162,8 @@ VersionInfo& GetVer ();
 #define IsWindowsNT() (GetVer ().isNT ())
 #define OSMajorVersion() (GetVer ().major ())
 #define OSMinorVersion() (GetVer ().minor ())
+#define IsXpOrBetter()   ((OSMajorVersion () > 5) \
+			   || (OSMajorVersion () == 5 && OSMinorVersion () >= 1))
+
 
 #endif /* SETUP_WIN32_H */

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] setup.exe: add autoload and version check for  AttachConsole
  2009-04-01 11:44 [PATCH] setup.exe: add autoload and version check for AttachConsole Dave Korn
@ 2009-04-01 14:00 ` Christopher Faylor
  2009-04-01 14:09   ` Dave Korn
  0 siblings, 1 reply; 3+ messages in thread
From: Christopher Faylor @ 2009-04-01 14:00 UTC (permalink / raw)
  To: cygwin-apps

On Wed, Apr 01, 2009 at 12:54:53PM +0100, Dave Korn wrote:
>
>    Hi gang,
>
>  AttachConsole (added recently for stdout/stderr handling) doesn't exist on
>win2k, having been introduced in xp/2k3, so setup HEAD currently doesn't run
>there.
>
>  The attached patch fixes the load-time problem by adding an autoload.  That
>won't prevent the run-time crash if the function gets called, of course; so it
>also adds a version check before the call.
>
>  Unless anyone shouts, I'll commit it later today; I think this is basically
>obvious.  Tested by verifying under GDB that it avoids the SEGV and by seeing
>that with the patch the setup.log and setup.log.full files are successfully
>generated.
>
>	* autoload.c (kernel32):  Add autoload entry for AttachConsole.
>	* main.cc (set_cout):  Check IsXpOrBetter before trying to use it.
>	* win32.h (IsXpOrBetter):  New version check macro.

Please don't submit this.  I'll fix the problem but not this way.

cgf

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] setup.exe: add autoload and version check for  AttachConsole
  2009-04-01 14:00 ` Christopher Faylor
@ 2009-04-01 14:09   ` Dave Korn
  0 siblings, 0 replies; 3+ messages in thread
From: Dave Korn @ 2009-04-01 14:09 UTC (permalink / raw)
  To: cygwin-apps

Christopher Faylor wrote:

> 
> Please don't submit this.  I'll fix the problem but not this way.


  Okeydokey, cancelled, NP :)

    cheers,
      DaveK

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-04-01 14:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-01 11:44 [PATCH] setup.exe: add autoload and version check for AttachConsole Dave Korn
2009-04-01 14:00 ` Christopher Faylor
2009-04-01 14:09   ` Dave Korn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).