diff --binary -ruN perl-5.8.8.orig/README.win32 perl-5.8.8/README.win32
--- perl-5.8.8.orig/README.win32	2006-01-31 22:40:14.000000000 +0000
+++ perl-5.8.8/README.win32	2007-08-22 16:42:43.369047800 +0100
@@ -52,8 +52,10 @@
 away free.  The Borland compiler is available as "Borland C++ Compiler Free
 Command Line Tools" and is the same compiler that ships with the full
 "Borland C++ Builder" product.  The Microsoft compiler is available as
-"Visual C++ Toolkit 2003", and also as part of the ".NET Framework SDK", and
-is the same compiler that ships with "Visual Studio .NET 2003 Professional".
+"Visual C++ Toolkit 2003" or "Visual C++ 2005 Express Edition" (and also as
+part of the ".NET Framework SDK") and is the same compiler that ships with
+"Visual C++ .NET 2003 Professional" or "Visual C++ 2005 Professional"
+respectively.
 
 This port can also be built on the Intel IA64 using:
 
@@ -133,10 +135,51 @@
 latter step is only essential if you want to use dmake as your default
 make for building extensions using MakeMaker.
 
+=item Microsoft Visual C++ 2005 Express Edition
+
+This free version of Visual C++ 2005 Professional contains the same compiler
+and linker that ship with the full version, but doesn't contain everything
+necessary to build Perl.
+
+You will also need to download the "Platform SDK" (the "Core SDK" and "MDAC
+SDK" components are required) for more header files and libraries.
+
+These packages can both be downloaded by searching in the Download Center at
+http://www.microsoft.com/downloads/search.aspx?displaylang=en.  (Providing exact
+links to these packages has proven a pointless task because the links keep on
+changing so often.)
+
+Try to obtain the latest version of the Platform SDK.  Sometimes these packages
+contain a particular Windows OS version in their name, but actually work on
+other OS versions too.  For example, the "Windows Server 2003 R2 Platform SDK"
+also runs on Windows XP SP2 and Windows 2000.
+
+According to the download pages these packages are only supported on Windows
+2000/XP/2003, so trying to use these tools on Windows 95/98/ME and even Windows
+NT probably won't work.
+
+Install Visual C++ 2005 first, then the Platform SDK.  Setup your environment
+as follows (assuming default installation locations were chosen):
+
+	SET PATH=%SystemRoot%\system32;%SystemRoot%;C:\Program Files\Microsoft Visual Studio 8\Common7\IDE;C:\Program Files\Microsoft Visual Studio 8\VC\BIN;C:\Program Files\Microsoft Visual Studio 8\Common7\Tools;C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\bin;C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727;C:\Program Files\Microsoft Visual Studio 8\VC\VCPackages;C:\Program Files\Microsoft Platform SDK\Bin
+
+	SET INCLUDE=C:\Program Files\Microsoft Visual Studio 8\VC\INCLUDE;C:\Program Files\Microsoft Platform SDK\include
+
+	SET LIB=C:\Program Files\Microsoft Visual Studio 8\VC\LIB;C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\lib;C:\Program Files\Microsoft Platform SDK\lib
+
+	SET LIBPATH=C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727
+
+Perl should now build using the win32/Makefile.  You will need to edit that
+file to set
+
+	CCTYPE = MSVC80FREE
+
+and to set CCHOME, CCINCDIR and CCLIBDIR as per the environment setup above.
+
 =item Microsoft Visual C++ Toolkit 2003
 
 This free toolkit contains the same compiler and linker that ship with
-Visual Studio .NET 2003 Professional, but doesn't contain everything
+Visual C++ .NET 2003 Professional, but doesn't contain everything
 necessary to build Perl.
 
 You will also need to download the "Platform SDK" (the "Core SDK" and "MDAC
@@ -153,19 +196,21 @@
 
 Try to obtain the latest version of the Platform SDK.  Sometimes these packages
 contain a particular Windows OS version in their name, but actually work on
-other OS versions too.  For example, the "Windows Server 2003 SP1 Platform SDK"
+other OS versions too.  For example, the "Windows Server 2003 R2 Platform SDK"
 also runs on Windows XP SP2 and Windows 2000.
 
-According to the download pages the Toolkit and the .NET Framework SDK are only
-supported on Windows 2000/XP/2003, so trying to use these tools on Windows
-95/98/ME and even Windows NT probably won't work.
+According to the download pages these packages are only supported on Windows
+2000/XP/2003, so trying to use these tools on Windows 95/98/ME and even Windows
+NT probably won't work.
 
 Install the Toolkit first, then the Platform SDK, then the .NET Framework SDK.
 Setup your environment as follows (assuming default installation locations
 were chosen):
 
 	SET PATH=%SystemRoot%\system32;%SystemRoot%;C:\Program Files\Microsoft Visual C++ Toolkit 2003\bin;C:\Program Files\Microsoft SDK\Bin;C:\Program Files\Microsoft.NET\SDK\v1.1\Bin
+
 	SET INCLUDE=C:\Program Files\Microsoft Visual C++ Toolkit 2003\include;C:\Program Files\Microsoft SDK\include;C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include
+
 	SET LIB=C:\Program Files\Microsoft Visual C++ Toolkit 2003\lib;C:\Program Files\Microsoft SDK\lib;C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\lib
 
 Several required files will still be missing:
@@ -321,6 +366,9 @@
 Makefile if you're using VC++ 6.0 without the latest service pack and
 the linker reports an internal error.
 
+If you are using VC++ 4.2 or earlier then you'll have to change the /EHsc
+option in the CXX_FLAG macro to the equivalent /GX option.
+
 If you have either the source or a library that contains des_fcrypt(),
 enable the appropriate option in the makefile.  A ready-to-use version
 of fcrypt.c, based on the version originally written by Eric Young at
@@ -919,6 +967,6 @@
 
 Support for 64-bit Windows added in 5.8 (ActiveState Corp).
 
-Last updated: 30 September 2005
+Last updated: 25 May 2007
 
 =cut
diff --binary -ruN perl-5.8.8.orig/ext/POSIX/t/posix.t perl-5.8.8/ext/POSIX/t/posix.t
--- perl-5.8.8.orig/ext/POSIX/t/posix.t	2003-11-30 18:41:58.000000000 +0000
+++ perl-5.8.8/ext/POSIX/t/posix.t	2007-08-22 16:51:34.685593000 +0100
@@ -173,7 +173,7 @@
 # didn't detect it.  If this fails, try adding
 # -DSTRUCT_TM_HASZONE to your cflags when compiling ext/POSIX/POSIX.c.
 # See ext/POSIX/hints/sunos_4.pl and ext/POSIX/hints/linux.pl 
-print POSIX::strftime("ok 21 # %H:%M, on %D\n", localtime());
+print POSIX::strftime("ok 21 # %H:%M, on %m/%d/%y\n", localtime());
 next_test();
 
 # If that worked, validate the mini_mktime() routine's normalisation of
@@ -186,7 +186,14 @@
 
 $lc = &POSIX::setlocale(&POSIX::LC_TIME, 'C') if $Config{d_setlocale};
 try_strftime("Wed Feb 28 00:00:00 1996 059", 0,0,0, 28,1,96);
-try_strftime("Thu Feb 29 00:00:60 1996 060", 60,0,-24, 30,1,96);
+SKIP: {
+    skip("VC++ 8 and Vista's CRTs regard 60 seconds as an invalid parameter", 1)
+	if ($Is_W32 and (($Config{cc} eq 'cl' and
+	                 $Config{ccversion} =~ /^(\d+)/ and $1 >= 14) or
+	                 (Win32::GetOSVersion())[1] >= 6));
+
+    try_strftime("Thu Feb 29 00:00:60 1996 060", 60,0,-24, 30,1,96);
+}
 try_strftime("Fri Mar 01 00:00:00 1996 061", 0,0,-24, 31,1,96);
 try_strftime("Sun Feb 28 00:00:00 1999 059", 0,0,0, 28,1,99);
 try_strftime("Mon Mar 01 00:00:00 1999 060", 0,0,24, 28,1,99);
diff --binary -ruN perl-5.8.8.orig/lib/ExtUtils/MM_Win32.pm perl-5.8.8/lib/ExtUtils/MM_Win32.pm
--- perl-5.8.8.orig/lib/ExtUtils/MM_Win32.pm	2005-10-21 15:10:46.000000000 +0100
+++ perl-5.8.8/lib/ExtUtils/MM_Win32.pm	2007-08-22 17:05:08.768909800 +0100
@@ -340,6 +340,12 @@
       push(@m,
        q{	$(LD) -out:$@ $(LDDLFLAGS) }.$ldfrom.q{ $(OTHERLDFLAGS) }
       .q{$(MYEXTLIB) $(PERL_ARCHIVE) $(LDLOADLIBS) -def:$(EXPORT_LIST)});
+      # VS2005 (aka VC 8) or higher, but not for 64-bit compiler from Platform SDK
+      if ($Config{ivsize} == 4 && $Config{cc} eq 'cl' and $Config{ccversion} =~ /^(\d+)/ and $1 >= 14) {
+        push(@m,
+          q{	
+	mt -nologo -manifest $@.manifest -outputresource:$@;2 && del $@.manifest});
+      }
     }
     push @m, '
 	$(CHMOD) $(PERM_RWX) $@
diff --binary -ruN perl-5.8.8.orig/lib/ExtUtils/t/Embed.t perl-5.8.8/lib/ExtUtils/t/Embed.t
--- perl-5.8.8.orig/lib/ExtUtils/t/Embed.t	2005-10-21 15:34:58.000000000 +0100
+++ perl-5.8.8/lib/ExtUtils/t/Embed.t	2007-08-22 16:42:43.369047800 +0100
@@ -135,6 +135,7 @@
 $status = system($embed_test);
 print (($status? 'not ':'')."ok 9 # system returned $status\n");
 unlink($exe,"embed_test.c",$obj);
+unlink("$exe.manifest") if $cl and $Config{'ccversion'} =~ /^(\d+)/ and $1 >= 14;
 unlink("$exe$Config{exe_ext}") if $skip_exe;
 unlink("embed_test.map","embed_test.lis") if $^O eq 'VMS';
 unlink(glob("./*.dll")) if $^O eq 'cygwin';
diff --binary -ruN perl-5.8.8.orig/makedef.pl perl-5.8.8/makedef.pl
--- perl-5.8.8.orig/makedef.pl	2006-01-27 19:12:54.000000000 +0000
+++ perl-5.8.8/makedef.pl	2007-08-22 16:42:43.384672000 +0100
@@ -154,7 +154,11 @@
 if ($PLATFORM =~ /^win(?:32|ce)$/) {
     ($dll = ($define{PERL_DLL} || "perl58")) =~ s/\.dll$//i;
     print "LIBRARY $dll\n";
-    print "DESCRIPTION 'Perl interpreter'\n";
+    # The DESCRIPTION module definition file statement is not supported
+    # by VC7 onwards.
+    if ($CCTYPE !~ /^MSVC7/ && $CCTYPE !~ /^MSVC8/) {
+	print "DESCRIPTION 'Perl interpreter'\n";
+    }
     print "EXPORTS\n";
     if ($define{PERL_IMPLICIT_SYS}) {
 	output_symbol("perl_get_host_info");
diff --binary -ruN perl-5.8.8.orig/patchlevel.h perl-5.8.8/patchlevel.h
--- perl-5.8.8.orig/patchlevel.h	2006-01-31 15:12:10.000000000 +0000
+++ perl-5.8.8/patchlevel.h	2007-08-22 17:05:36.876845600 +0100
@@ -120,7 +120,27 @@
 
 #if !defined(PERL_PATCHLEVEL_H_IMPLICIT) && !defined(LOCAL_PATCH_COUNT)
 static const char *local_patches[] = {
-	NULL
+	 NULL
+	,"27500 First step in supporting VC8 (Makefile macros)"
+	,"27503 Document that VC8 is currently not supported"
+	,"27556 Add support for PSDK 64-bit & change deprecated compiler switch"
+	,"27888 Fix support for PSDK 64-bit"
+	,"28978 Start support for VC8 (Build notes & Makefile macros)"
+	,"29218 Extend support for VC8 (Invalid parameters & MSVCRT_READFIX fix)"
+	,"29233 Extend support for VC8 (Don't use MSVCRT_READFIX)"
+	,"29266 Extend support for VC8 (Embed manifest files)"
+	,"29350 Fix infinite loop in Perl_my_strftime() for failing strftime()"
+	,"29352 Extend support for VC8 (Skip false negative test failure)"
+	,"29358 Extend support for VC8 (Don't warn about unsafe/POSIX CRT funcs)"
+	,"29375 Extend support for VC8 (Cleanup manifest file left by test)"
+	,"29409 Complete support for VC8 (except for one test failure)"
+	,"30878 Fix support for PSDK 64-bit (broken by 29218)"
+	,"31271 Fix support for VC8 (Don't use FIXED_OSFHANDLE)"
+	,"31343 Silence VC8 warning about DESCRIPTION in .def file"
+	,"31344 Silence VC8 warning about /DPERLDLL being overridden"
+	,"31721 Skip false negative test failure on Vista (as per VC8)"
+	,"31725 Fix test broken by 31721"
+	,"31742 Silence VC8 warning about POSIX CRT functions better"
 	,NULL
 };
 
diff --binary -ruN perl-5.8.8.orig/pod/perltodo.pod perl-5.8.8/pod/perltodo.pod
--- perl-5.8.8.orig/pod/perltodo.pod	2005-12-30 14:11:26.000000000 +0000
+++ perl-5.8.8/pod/perltodo.pod	2007-08-22 16:52:30.213999800 +0100
@@ -425,6 +425,29 @@
 
 
 
+=head2 Use secure CRT functions when building with VC8 on Win32
+
+Visual C++ 2005 (VC++ 8.x) deprecated a number of CRT functions on the basis
+that they were "unsafe" and introduced differently named secure versions of
+them as replacements, e.g. instead of writing
+
+    FILE* f = fopen(__FILE__, "r");
+
+one should now write
+
+    FILE* f;
+    errno_t err = fopen_s(&f, __FILE__, "r"); 
+
+Currently, the warnings about these deprecations have been disabled by adding
+-D_CRT_SECURE_NO_DEPRECATE to the CFLAGS. It would be nice to remove that
+warning suppressant and actually make use of the new secure CRT functions.
+
+There is also a similar issue with POSIX CRT function names like fileno having
+been deprecated in favour of ISO C++ conformant names like _fileno. These
+warnings are also currently suppressed by adding -D_CRT_NONSTDC_NO_DEPRECATE. It
+might be nice to do as Microsoft suggest here too, although, unlike the secure
+functions issue, there is presumably little or no benefit in this case.
+
 =head1 Tasks that need a knowledge of XS
 
 These tasks would need C knowledge, and roughly the level of knowledge of
diff --binary -ruN perl-5.8.8.orig/util.c perl-5.8.8/util.c
--- perl-5.8.8.orig/util.c	2006-01-08 20:00:00.000000000 +0000
+++ perl-5.8.8/util.c	2007-08-22 16:49:03.646451600 +0100
@@ -3967,7 +3967,7 @@
   else {
     /* Possibly buf overflowed - try again with a bigger buf */
     const int fmtlen = strlen(fmt);
-    const int bufsize = fmtlen + buflen;
+    int bufsize = fmtlen + buflen;
 
     Newx(buf, bufsize, char);
     while (buf) {
@@ -3980,7 +3980,8 @@
 	buf = NULL;
 	break;
       }
-      Renew(buf, bufsize*2, char);
+      bufsize *= 2;
+      Renew(buf, bufsize, char);
     }
     return buf;
   }
diff --binary -ruN perl-5.8.8.orig/win32/Makefile perl-5.8.8/win32/Makefile
--- perl-5.8.8.orig/win32/Makefile	2006-01-31 22:40:14.000000000 +0000
+++ perl-5.8.8/win32/Makefile	2007-08-22 16:52:59.056273000 +0100
@@ -1,8 +1,8 @@
 #
 # Makefile to build perl on Windows NT using Microsoft NMAKE.
 # Supported compilers:
-#	Visual C++ 2.0 through 7.0 (and possibly newer versions)
-#	MS Platform SDK 64-bit compiler and tools **experimental**
+#	Visual C++ 2.0 or later
+#	MS Platform SDK 64-bit compiler and tools
 #
 # This is set up to build a perl.exe that runs off a shared library
 # (perl58.dll).  Also makes individual DLLs for the XS extensions.
@@ -104,12 +104,16 @@
 #CCTYPE		= MSVC20
 # Visual C++ > 2.x and < 6.x
 #CCTYPE		= MSVC
-# Visual C++ 6.x (aka Visual Studio 98)
+# Visual C++ 6.x (aka Visual C++ 98)
 CCTYPE		= MSVC60
-# Visual C++ Toolkit 2003 (free version of Visual C++ 7.x command-line tools)
+# Visual C++ Toolkit 2003 (aka Visual C++ 7.x) (free command-line tools)
 #CCTYPE		= MSVC70FREE
-# Visual C++ 7.x (aka Visual Studio .NET 2003) (full version)
+# Visual C++ .NET 2003 (aka Visual C++ 7.x) (full version)
 #CCTYPE		= MSVC70
+# Visual C++ 2005 Express Edition (aka Visual C++ 8.x) (free version)
+#CCTYPE		= MSVC80FREE
+# Visual C++ 2005 (aka Visual C++ 8.x) (full version)
+#CCTYPE		= MSVC80
 
 #
 # uncomment next line if you want debug version of perl (big,slow)
@@ -323,11 +327,14 @@
 !ENDIF
 
 !IF "$(WIN64)" == ""
+# When we are running from a 32bit cmd.exe on AMD64 then
+# PROCESSOR_ARCHITECTURE is set to x86 and PROCESSOR_ARCHITEW6432
+# is set to AMD64
 !IF "$(PROCESSOR_ARCHITEW6432)" != ""
 PROCESSOR_ARCHITECTURE	= $(PROCESSOR_ARCHITEW6432)
 WIN64			= define
 !ELSE
-!IF "$(PROCESSOR_ARCHITECTURE)" == "IA64"
+!IF "$(PROCESSOR_ARCHITECTURE)" == "AMD64" || "$(PROCESSOR_ARCHITECTURE)" == "IA64"
 WIN64			= define
 !ELSE
 WIN64			= undef
@@ -335,16 +342,24 @@
 !ENDIF
 !ENDIF
 
+ARCHITECTURE = $(PROCESSOR_ARCHITECTURE)
+!IF "$(ARCHITECTURE)" == "AMD64"
+ARCHITECTURE	= x64
+!ENDIF
+!IF "$(ARCHITECTURE)" == "IA64"
+ARCHITECTURE	= ia64
+!ENDIF
+
 !IF "$(USE_5005THREADS)" == "define"
-ARCHNAME	= MSWin32-$(PROCESSOR_ARCHITECTURE)-thread
+ARCHNAME	= MSWin32-$(ARCHITECTURE)-thread
 !ELSE
 !IF "$(USE_MULTI)" == "define"
-ARCHNAME	= MSWin32-$(PROCESSOR_ARCHITECTURE)-multi
+ARCHNAME	= MSWin32-$(ARCHITECTURE)-multi
 !ELSE
 !IF "$(USE_PERLIO)" == "define"
-ARCHNAME	= MSWin32-$(PROCESSOR_ARCHITECTURE)-perlio
+ARCHNAME	= MSWin32-$(ARCHITECTURE)-perlio
 !ELSE
-ARCHNAME	= MSWin32-$(PROCESSOR_ARCHITECTURE)
+ARCHNAME	= MSWin32-$(ARCHITECTURE)
 !ENDIF
 !ENDIF
 !ENDIF
@@ -357,13 +372,26 @@
 ARCHNAME	= $(ARCHNAME)-thread
 !ENDIF
 
-# Visual Studio 98 and .NET 2003 specific
-# VC++ 6.x and 7.x can load DLL's on demand.  Makes the test suite run in
-# about 10% less time.  (The free version of 7.x can't do this, however.)
-!IF "$(CCTYPE)" == "MSVC60" || "$(CCTYPE)" == "MSVC70"
+# Visual C++ 98, .NET 2003 and 2005 specific.
+# VC++ 6.x, 7.x and 8.x can load DLL's on demand.  Makes the test suite run in
+# about 10% less time.  (The free version of 7.x can't do this, but the free
+# version of 8.x can.)
+!IF "$(CCTYPE)" == "MSVC60" || "$(CCTYPE)" == "MSVC70" || \
+    "$(CCTYPE)" == "MSVC80" || "$(CCTYPE)" == "MSVC80FREE"
 DELAYLOAD	= -DELAYLOAD:ws2_32.dll -DELAYLOAD:shell32.dll delayimp.lib
 !ENDIF
 
+# Visual C++ 2005 (VC++ 8.x) creates manifest files for EXEs and DLLs. These
+# either need copying everywhere with the binaries, or else need embedding in
+# them otherwise MSVCR80.dll won't be found. Embed them for simplicity, and
+# delete them afterwards so that they don't get installed too.
+!IF "$(CCTYPE)" == "MSVC80" || "$(CCTYPE)" == "MSVC80FREE"
+EMBED_EXE_MANI	= mt -nologo -manifest $@.manifest -outputresource:$@;1 && \
+		  del $@.manifest
+EMBED_DLL_MANI	= mt -nologo -manifest $@.manifest -outputresource:$@;2 && \
+		  del $@.manifest
+!ENDIF
+
 ARCHDIR		= ..\lib\$(ARCHNAME)
 COREDIR		= ..\lib\CORE
 AUTODIR		= ..\lib\auto
@@ -399,7 +427,7 @@
 DEFINES		= -DWIN32 -D_CONSOLE -DNO_STRICT $(CRYPT_FLAG)
 LOCDEFS		= -DPERLDLL -DPERL_CORE
 SUBSYS		= console
-CXX_FLAG	= -TP -GX
+CXX_FLAG	= -TP -EHsc
 
 !IF "$(USE_PERLCRT)" != "define"
 LIBC	= msvcrt.lib
@@ -437,36 +465,42 @@
 
 !IF "$(WIN64)" == "define"
 DEFINES		= $(DEFINES) -DWIN64 -DCONSERVATIVE
-OPTIMIZE	= $(OPTIMIZE) -Wp64 -Op
+OPTIMIZE	= $(OPTIMIZE) -Wp64 -fp:precise
 !ENDIF
 
-# the string-pooling option -Gf is deprecated in VC++ 7.x and will be removed
-# in later versions, so use read-only string-pooling (-GF) instead
-!IF "$(CCTYPE)" == "MSVC70FREE" || "$(CCTYPE)" == "MSVC70"
-STRPOOL		= -GF
-!ELSE
-STRPOOL		= -Gf
+# For now, silence VC++ 8.x's warnings about "unsafe" CRT functions and POSIX
+# CRT function names being deprecated.
+!IF "$(CCTYPE)" == "MSVC80" || "$(CCTYPE)" == "MSVC80FREE"
+DEFINES		= $(DEFINES) -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE
 !ENDIF
 
-!IF "$(USE_PERLCRT)" != "define"
+# Use the MSVCRT read() fix if the PerlCRT was not chosen, but only when using
+# VC++ 6.x or earlier. Later versions use MSVCR70.dll, MSVCR71.dll, etc, which
+# do not require the fix.
+!IF "$(CCTYPE)" == "MSVC20" || "$(CCTYPE)" == "MSVC" || "$(CCTYPE)" == "MSVC60" 
+!  IF "$(USE_PERLCRT)" != "define"
 BUILDOPT	= $(BUILDOPT) -DPERL_MSVCRT_READFIX
+!  ENDIF
 !ENDIF
 
 LIBBASEFILES	= $(CRYPT_LIB) \
 		oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib \
 		comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib \
 		netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib \
-		version.lib
+		version.lib odbc32.lib odbccp32.lib
 
-# win64 doesn't have some libs
-!IF "$(WIN64)" != "define"
-LIBBASEFILES	= $(LIBBASEFILES) odbc32.lib odbccp32.lib
+# The 64 bit Platform SDK compilers contain a runtime library that doesn't
+# include the buffer overrun verification code used by the /GS switch.
+# Since the code links against libraries that are compiled with /GS, this
+# "security cookie verification" must be included via bufferoverlow.lib.
+!IF "$(WIN64)" == "define"
+LIBBASEFILES    = $(LIBBASEFILES) bufferoverflowU.lib
 !ENDIF
 
 # we add LIBC here, since we may be using PerlCRT.dll
 LIBFILES	= $(LIBBASEFILES) $(LIBC)
 
-EXTRACFLAGS	= -nologo $(STRPOOL) -W3
+EXTRACFLAGS	= -nologo -GF -W3
 CFLAGS		= $(EXTRACFLAGS) $(INCLUDES) $(DEFINES) $(LOCDEFS) \
 		$(PCHFLAGS) $(OPTIMIZE)
 LINK_FLAGS	= -nologo -nodefaultlib $(LINK_DBG) \
@@ -497,6 +531,7 @@
 $(o).dll:
 	$(LINK32) -dll -subsystem:windows -implib:$(*B).lib -def:$(*B).def \
 	    -out:$@ $(LINK_FLAGS) $(LIBFILES) $< $(LIBPERL)
+	$(EMBED_DLL_MANI)
 
 .rc.res:
 	$(RSC) -i.. $<
@@ -517,7 +552,7 @@
 CONFIGPM	= ..\lib\Config.pm ..\lib\Config_heavy.pl
 MINIMOD		= ..\lib\ExtUtils\Miniperl.pm
 X2P		= ..\x2p\a2p.exe
-
+  
 # Unicode data files generated by mktables
 UNIDATAFILES	 = ..\lib\unicore\Canonical.pl ..\lib\unicore\Exact.pl \
 		   ..\lib\unicore\Properties ..\lib\unicore\Decomposition.pl \
@@ -914,6 +949,7 @@
 $(GLOBEXE) : perlglob$(o)
 	$(LINK32) $(LINK_FLAGS) $(LIBFILES) -out:$@ -subsystem:$(SUBSYS) \
 	    perlglob$(o) setargv$(o)
+	$(EMBED_EXE_MANI)
 
 perlglob$(o)  : perlglob.c
 
@@ -958,6 +994,7 @@
 	$(LINK32) -subsystem:console -out:$@ @<<
 	$(LINK_FLAGS) $(LIBFILES) $(MINI_OBJ)
 <<
+	$(EMBED_EXE_MANI)
 
 $(MINIDIR) :
 	if not exist "$(MINIDIR)" mkdir "$(MINIDIR)"
@@ -993,6 +1030,7 @@
 	$(LINK32) -dll -def:perldll.def -base:0x28000000 -out:$@ @Extensions_static @<<
 		$(LINK_FLAGS) $(DELAYLOAD) $(LIBFILES) $(PERLDLL_OBJ) $(PERLDLL_RES)
 <<
+	$(EMBED_DLL_MANI)
 	$(XCOPY) $(PERLIMPLIB) $(COREDIR)
 
 $(PERLEXE_ICO): $(MINIPERL) makeico.pl
@@ -1026,16 +1064,18 @@
 	$(LINK32) -subsystem:console -out:$@ @<<
 		$(LINK_FLAGS) $(LIBFILES) $(X2P_OBJ)
 <<
+	$(EMBED_EXE_MANI)
 
 perlmain.c : runperl.c
 	copy runperl.c perlmain.c
 
 perlmain$(o) : perlmain.c
-	$(CC) $(CFLAGS_O) -UPERLDLL $(OBJOUT_FLAG)$@ -c perlmain.c
+ 	$(CC) $(CFLAGS_O:-DPERLDLL=-UPERLDLL) $(OBJOUT_FLAG)$@ -c perlmain.c
 
 $(PERLEXE): $(PERLDLL) $(CONFIGPM) $(PERLEXE_OBJ) $(PERLEXE_RES)
 	$(LINK32) -subsystem:console -out:$@ -stack:0x1000000 $(LINK_FLAGS) \
 	    $(LIBFILES) $(PERLEXE_OBJ) $(SETARGV_OBJ) $(PERLIMPLIB) $(PERLEXE_RES)
+	$(EMBED_EXE_MANI)
 	copy $(PERLEXE) $(WPERLEXE)
 	$(MINIPERL) -I..\lib bin\exetype.pl $(WPERLEXE) WINDOWS
 	copy splittree.pl ..
diff --binary -ruN perl-5.8.8.orig/win32/makefile.mk perl-5.8.8/win32/makefile.mk
--- perl-5.8.8.orig/win32/makefile.mk	2006-01-31 22:40:14.000000000 +0000
+++ perl-5.8.8/win32/makefile.mk	2007-08-22 16:53:15.321065200 +0100
@@ -1,9 +1,9 @@
 #
 # Makefile to build perl on Windows NT using DMAKE.
 # Supported compilers:
-#	Visual C++ 2.0 through 7.0 (and possibly newer versions)
-#	Borland C++ 5.02 or better
-#	Mingw32 with gcc-2.95.2 or better
+#	Visual C++ 2.0 or later
+#	Borland C++ 5.02 or later
+#	MinGW with gcc-2.95.2 or later
 #	MS Platform SDK 64-bit compiler and tools **experimental**
 #
 # This is set up to build a perl.exe that runs off a shared library
@@ -106,12 +106,16 @@
 #CCTYPE		*= MSVC20
 # Visual C++ > 2.x and < 6.x
 #CCTYPE		*= MSVC
-# Visual C++ 6.x (aka Visual Studio 98)
+# Visual C++ 6.x (aka Visual C++ 98)
 #CCTYPE		*= MSVC60
-# Visual C++ Toolkit 2003 (free version of Visual C++ 7.x command-line tools)
+# Visual C++ Toolkit 2003 (aka Visual C++ 7.x) (free command-line tools)
 #CCTYPE		*= MSVC70FREE
-# Visual C++ 7.x (aka Visual Studio .NET 2003) (full version)
+# Visual C++ .NET 2003 (aka Visual C++ 7.x) (full version)
 #CCTYPE		*= MSVC70
+# Visual C++ 2005 Express Edition (aka Visual C++ 8.x) (free version)
+#CCTYPE		*= MSVC80FREE
+# Visual C++ 2005 (aka Visual C++ 8.x) (full version)
+#CCTYPE		*= MSVC80
 # Borland 5.02 or later
 #CCTYPE		*= BORLAND
 # MinGW with gcc-2.95.2 or later
@@ -326,40 +330,64 @@
 PROCESSOR_ARCHITECTURE *= x86
 
 .IF "$(WIN64)" == ""
+# When we are running from a 32bit cmd.exe on AMD64 then
+# PROCESSOR_ARCHITECTURE is set to x86 and PROCESSOR_ARCHITEW6432
+# is set to AMD64
 .IF "$(PROCESSOR_ARCHITEW6432)" != ""
 PROCESSOR_ARCHITECTURE	!= $(PROCESSOR_ARCHITEW6432)
 WIN64			= define
-.ELIF "$(PROCESSOR_ARCHITECTURE)" == "IA64"
+.ELIF "$(PROCESSOR_ARCHITECTURE)" == "AMD64" || "$(PROCESSOR_ARCHITECTURE)" == "IA64"
 WIN64			= define
 .ELSE
 WIN64			= undef
 .ENDIF
 .ENDIF
 
+ARCHITECTURE = $(PROCESSOR_ARCHITECTURE)
+.IF "$(ARCHITECTURE)" == "AMD64"
+ARCHITECTURE	= x64
+.ENDIF
+.IF "$(ARCHITECTURE)" == "IA64"
+ARCHITECTURE	= ia64
+.ENDIF
+
 .IF "$(USE_5005THREADS)" == "define"
-ARCHNAME	= MSWin32-$(PROCESSOR_ARCHITECTURE)-thread
+ARCHNAME	= MSWin32-$(ARCHITECTURE)-thread
 .ELIF "$(USE_MULTI)" == "define"
-ARCHNAME	= MSWin32-$(PROCESSOR_ARCHITECTURE)-multi
+ARCHNAME	= MSWin32-$(ARCHITECTURE)-multi
 .ELSE
 .IF "$(USE_PERLIO)" == "define"
-ARCHNAME	= MSWin32-$(PROCESSOR_ARCHITECTURE)-perlio
+ARCHNAME	= MSWin32-$(ARCHITECTURE)-perlio
 .ELSE
-ARCHNAME	= MSWin32-$(PROCESSOR_ARCHITECTURE)
+ARCHNAME	= MSWin32-$(ARCHITECTURE)
 .ENDIF
-ARCHNAME	= MSWin32-$(PROCESSOR_ARCHITECTURE)
+ARCHNAME	= MSWin32-$(ARCHITECTURE)
 .ENDIF
 
 .IF "$(USE_ITHREADS)" == "define"
 ARCHNAME	!:= $(ARCHNAME)-thread
 .ENDIF
 
-# Visual Studio 98 and .NET 2003 specific
-# VC++ 6.x and 7.x can load DLL's on demand.  Makes the test suite run in
-# about 10% less time.  (The free version of 7.x can't do this, however.)
-.IF "$(CCTYPE)" == "MSVC60" || "$(CCTYPE)" == "MSVC70"
+# Visual C++ 98, .NET 2003 and 2005 specific.
+# VC++ 6.x, 7.x and 8.x can load DLL's on demand.  Makes the test suite run in
+# about 10% less time.  (The free version of 7.x can't do this, but the free
+# version of 8.x can.)
+.IF "$(CCTYPE)" == "MSVC60" || "$(CCTYPE)" == "MSVC70" \
+    "$(CCTYPE)" == "MSVC80" || "$(CCTYPE)" == "MSVC80FREE"
 DELAYLOAD	*= -DELAYLOAD:ws2_32.dll -DELAYLOAD:shell32.dll delayimp.lib
 .ENDIF
 
+# Visual C++ 2005 (VC++ 8.x) creates manifest files for EXEs and DLLs. These
+# either need copying everywhere with the binaries, or else need embedding in
+# them otherwise MSVCR80.dll won't be found. Embed them for simplicity, and
+# delete them afterwards so that they don't get installed too.
+.IF "$(CCTYPE)" == "MSVC80" || "$(CCTYPE)" == "MSVC80FREE"
+EMBED_EXE_MANI	= mt -nologo -manifest $@.manifest -outputresource:$@;1 && \
+		  del $@.manifest
+EMBED_DLL_MANI	= mt -nologo -manifest $@.manifest -outputresource:$@;2 && \
+		  del $@.manifest
+.ENDIF
+
 ARCHDIR		= ..\lib\$(ARCHNAME)
 COREDIR		= ..\lib\CORE
 AUTODIR		= ..\lib\auto
@@ -488,6 +516,7 @@
 LIBOUT_FLAG	=
 
 # NOTE: we assume that GCC uses MSVCRT.DLL
+# See comments about PERL_MSVCRT_READFIX in the "cl" compiler section below.
 BUILDOPT	+= -fno-strict-aliasing -DPERL_MSVCRT_READFIX
 
 .ELSE
@@ -506,7 +535,7 @@
 DEFINES		= -DWIN32 -D_CONSOLE -DNO_STRICT $(CRYPT_FLAG)
 LOCDEFS		= -DPERLDLL -DPERL_CORE
 SUBSYS		= console
-CXX_FLAG	= -TP -GX
+CXX_FLAG	= -TP -EHsc
 
 .IF "$(USE_PERLCRT)" != "define"
 LIBC	= msvcrt.lib
@@ -544,36 +573,42 @@
 
 .IF "$(WIN64)" == "define"
 DEFINES		+= -DWIN64 -DCONSERVATIVE
-OPTIMIZE	+= -Wp64 -Op
+OPTIMIZE	+= -Wp64 -fp:precise
 .ENDIF
 
-# the string-pooling option -Gf is deprecated in VC++ 7.x and will be removed
-# in later versions, so use read-only string-pooling (-GF) instead
-.IF "$(CCTYPE)" == "MSVC70FREE" || "$(CCTYPE)" == "MSVC70"
-STRPOOL		= -GF
-.ELSE
-STRPOOL		= -Gf
+# For now, silence VC++ 8.x's warnings about "unsafe" CRT functions and POSIX
+# CRT function names being deprecated.
+.IF "$(CCTYPE)" == "MSVC80" || "$(CCTYPE)" == "MSVC80FREE"
+DEFINES		+= -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE
 .ENDIF
 
+# Use the MSVCRT read() fix if the PerlCRT was not chosen, but only when using
+# VC++ 6.x or earlier. Later versions use MSVCR70.dll, MSVCR71.dll, etc, which
+# do not require the fix.
+.IF "$(CCTYPE)" == "MSVC20" || "$(CCTYPE)" == "MSVC" || "$(CCTYPE)" == "MSVC60" 
 .IF "$(USE_PERLCRT)" != "define"
 BUILDOPT	+= -DPERL_MSVCRT_READFIX
 .ENDIF
+.ENDIF
 
 LIBBASEFILES	= $(CRYPT_LIB) \
 		oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib \
 		comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib \
 		netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib \
-		version.lib
+		version.lib odbc32.lib odbccp32.lib
 
-# win64 doesn't have some libs
-.IF "$(WIN64)" != "define"
-LIBBASEFILES	+= odbc32.lib odbccp32.lib
+# The 64 bit Platform SDK compilers contain a runtime library that doesn't
+# include the buffer overrun verification code used by the /GS switch.
+# Since the code links against libraries that are compiled with /GS, this
+# "security cookie verification" must be included via bufferoverlow.lib.
+.IF "$(WIN64)" == "define"
+LIBBASEFILES    = $(LIBBASEFILES) bufferoverflowU.lib
 .ENDIF
 
 # we add LIBC here, since we may be using PerlCRT.dll
 LIBFILES	= $(LIBBASEFILES) $(LIBC)
 
-EXTRACFLAGS	= -nologo $(STRPOOL) -W3
+EXTRACFLAGS	= -nologo -GF -W3
 CFLAGS		= $(EXTRACFLAGS) $(INCLUDES) $(DEFINES) $(LOCDEFS) \
 		$(PCHFLAGS) $(OPTIMIZE)
 LINK_FLAGS	= -nologo -nodefaultlib $(LINK_DBG) \
@@ -649,6 +684,7 @@
 .ELSE
 	$(LINK32) -dll -subsystem:windows -implib:$(*B).lib -def:$(*B).def \
 	    -out:$@ $(BLINK_FLAGS) $(LIBFILES) $< $(LIBPERL)
+	$(EMBED_DLL_MANI)
 .ENDIF
 
 .rc.res:
@@ -1039,6 +1075,7 @@
 .ELSE
 	$(LINK32) $(BLINK_FLAGS) $(LIBFILES) -out:$@ -subsystem:$(SUBSYS) \
 	    perlglob$(o) setargv$(o)
+	$(EMBED_EXE_MANI)
 .ENDIF
 
 perlglob$(o)  : perlglob.c
@@ -1091,6 +1128,7 @@
 .ELSE
 	$(LINK32) -subsystem:console -out:$@ \
 	    @$(mktmp $(BLINK_FLAGS) $(LIBFILES) $(MINI_OBJ:s,\,$B,))
+	$(EMBED_EXE_MANI)
 .ENDIF
 
 $(MINIDIR) :
@@ -1158,6 +1196,7 @@
 	    @Extensions_static \
 	    @$(mktmp -base:0x28000000 $(BLINK_FLAGS) $(DELAYLOAD) $(LIBFILES) \
 	        $(PERLDLL_RES) $(PERLDLL_OBJ:s,\,$B,))
+	$(EMBED_DLL_MANI)
 .ENDIF
 	$(XCOPY) $(PERLIMPLIB) $(COREDIR)
 
@@ -1197,13 +1236,14 @@
 .ELSE
 	$(LINK32) -subsystem:console -out:$@ \
 	    @$(mktmp $(BLINK_FLAGS) $(LIBFILES) $(X2P_OBJ:s,\,$B,))
+	$(EMBED_EXE_MANI)
 .ENDIF
 
 perlmain.c : runperl.c
 	copy runperl.c perlmain.c
 
 perlmain$(o) : perlmain.c
-	$(CC) $(CFLAGS_O) -UPERLDLL $(OBJOUT_FLAG)$@ -c perlmain.c
+ 	$(CC) $(CFLAGS_O:s,-DPERLDLL,-UPERLDLL,) $(OBJOUT_FLAG)$@ -c perlmain.c
 
 $(PERLEXE): $(PERLDLL) $(CONFIGPM) $(PERLEXE_OBJ) $(PERLEXE_RES)
 .IF "$(CCTYPE)" == "BORLAND"
@@ -1217,6 +1257,7 @@
 .ELSE
 	$(LINK32) -subsystem:console -out:$@ -stack:0x1000000 $(BLINK_FLAGS) \
 	    $(LIBFILES) $(PERLEXE_OBJ) $(SETARGV_OBJ) $(PERLIMPLIB) $(PERLEXE_RES)
+	$(EMBED_EXE_MANI)
 .ENDIF
 	copy $(PERLEXE) $(WPERLEXE)
 	$(MINIPERL) -I..\lib bin\exetype.pl $(WPERLEXE) WINDOWS
diff --binary -ruN perl-5.8.8.orig/win32/win32.c perl-5.8.8/win32/win32.c
--- perl-5.8.8.orig/win32/win32.c	2006-01-06 21:28:34.000000000 +0000
+++ perl-5.8.8/win32/win32.c	2007-08-22 16:42:43.400296200 +0100
@@ -127,6 +127,36 @@
 }
 #endif
 
+/* VS2005 (MSC version 14) provides a mechanism to set an invalid
+ * parameter handler.  This functionality is not available in the
+ * 64-bit compiler from the Platform SDK, which unfortunately also
+ * believes itself to be MSC version 14.
+ *
+ * There is no #define related to _set_invalid_parameter_handler(),
+ * but we can check for one of the constants defined for
+ * _set_abort_behavior(), which was introduced into stdlib.h at
+ * the same time.
+ */
+
+#if _MSC_VER >= 1400 && defined(_WRITE_ABORT_MSG)
+#  define SET_INVALID_PARAMETER_HANDLER
+#endif
+
+#ifdef SET_INVALID_PARAMETER_HANDLER
+void my_invalid_parameter_handler(const wchar_t* expression,
+    const wchar_t* function, 
+    const wchar_t* file, 
+    unsigned int line, 
+    uintptr_t pReserved)
+{
+#  ifdef _DEBUG
+    wprintf(L"Invalid parameter detected in function %s."
+            L" File: %s Line: %d\n", function, file, line);
+    wprintf(L"Expression: %s\n", expression);
+#  endif
+}
+#endif
+
 int
 IsWin95(void)
 {
@@ -5091,9 +5121,19 @@
 }
 
 
+#ifdef SET_INVALID_PARAMETER_HANDLER
+#  include <crtdbg.h>
+#endif
+
 void
 Perl_win32_init(int *argcp, char ***argvp)
 {
+#ifdef SET_INVALID_PARAMETER_HANDLER
+    _invalid_parameter_handler oldHandler, newHandler;
+    newHandler = my_invalid_parameter_handler;
+    oldHandler = _set_invalid_parameter_handler(newHandler);
+    _CrtSetReportMode(_CRT_ASSERT, 0);
+#endif
     /* Disable floating point errors, Perl will trap the ones we
      * care about.  VC++ RTL defaults to switching these off
      * already, but the Borland RTL doesn't.  Since we don't
diff --binary -ruN perl-5.8.8.orig/win32/win32.h perl-5.8.8/win32/win32.h
--- perl-5.8.8.orig/win32/win32.h	2006-01-06 22:36:04.000000000 +0000
+++ perl-5.8.8/win32/win32.h	2007-08-22 16:42:43.415920400 +0100
@@ -127,8 +127,11 @@
 /* Define USE_FIXED_OSFHANDLE to fix MSVCRT's _open_osfhandle() on W95.
    It now uses some black magic to work seamlessly with the DLL CRT and
    works with MSVC++ 4.0+ or GCC/Mingw32
-	-- BKS 1-24-2000 */
-#if (defined(_M_IX86) && _MSC_VER >= 1000) || defined(__MINGW32__)
+	-- BKS 1-24-2000
+   Only use this fix for VC++ 6.x or earlier (and for GCC, which we assume
+   uses MSVCRT.DLL). Later versions use MSVCR70.dll, MSVCR71.dll, etc, which
+   do not require the fix. */
+#if (defined(_M_IX86) && _MSC_VER >= 1000 && _MSC_VER <= 1200) || defined(__MINGW32__)
 #define USE_FIXED_OSFHANDLE
 #endif
 
