From: Gurusamy Sarathy Date: Mon, 7 Feb 2000 08:38:25 +0000 (+0000) Subject: add exetype.pl (from Jan Dubois) X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1065c7ba04e29eafefcb46a4a5a7f73d860d2f49;p=p5sagit%2Fp5-mst-13.2.git add exetype.pl (from Jan Dubois) p4raw-id: //depot/perl@5016 --- diff --git a/MANIFEST b/MANIFEST index c3bbfee..b9b4c51 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1540,6 +1540,7 @@ vos/vosish.h VOS-specific header file warnings.h The warning numbers warnings.pl Program to write warnings.h and lib/warnings.pm win32/Makefile Win32 makefile for NMAKE (Visual C++ build) +win32/bin/exetype.pl Set executable type to CONSOLE or WINDOWS win32/bin/perlglob.pl Win32 globbing win32/bin/pl2bat.pl wrap perl scripts into batch files win32/bin/runperl.pl run perl script via batch file namesake diff --git a/win32/bin/exetype.pl b/win32/bin/exetype.pl new file mode 100644 index 0000000..5846b3e --- /dev/null +++ b/win32/bin/exetype.pl @@ -0,0 +1,61 @@ +#!perl -w +use strict; +unless (@ARGV == 2) { + print "Usage: $0 exefile [CONSOLE|WINDOWS]\n"; + exit; +} +unless ($ARGV[1] =~ /^(console|windows)$/i) { + print "Invalid subsystem $ARGV[1], please use CONSOLE or WINDOWS\n"; + exit; +} +my ($record,$magic,$offset,$size); +open EXE, "+< $ARGV[0]" or die "Cannot open $ARGV[0]: $!"; +binmode EXE; +read EXE, $record, 32*4; +($magic,$offset) = unpack "Sx58L", $record; +die "Not an MSDOS executable file" unless $magic == 0x5a4d; +seek EXE, $offset, 0; +read EXE, $record, 24; +($magic,$size) = unpack "Lx16S", $record; +die "PE header not found" unless $magic == 0x4550; +die "Optional header not in NT32 format" unless $size == 224; +seek EXE, $offset+24+68, 0; +print EXE pack "S", uc($ARGV[1]) eq 'CONSOLE' ? 3 : 2; +close EXE; +__END__ + +=head1 NAME + +exetype - Change executable subsystem type between "Console" and "Windows" + +=head1 SYNOPSIS + + C:\perl\bin> copy perl.exe guiperl.exe + C:\perl\bin> exetype guiperl.exe windows + +=head1 DESCRIPTION + +This program edits an executable file to indicate which subsystem the +operating system must invoke for execution. + +You can specify any of the following subsystems: + +=over + +=item CONSOLE + +The CONSOLE subsystem handles a Win32 character-mode application that +use a console supplied by the operating system. + +=item WINDOWS + +The WINDOWS subsystem handles an application that does not require a +console and creates its own windows, if required. + +=back + +=head1 AUTHOR + +Jan Dubois + +=cut