From: Alan Klietz on
If you want to publish a Windows application that runs on Windows 2000 or
Windows XP, using the latest compiler (Visual Studio 2005), you can do so.
Without requiring that you ship megabytes of code from the VS2005 runtime
libraries (MSVCRT80.DLL and MFC80.DLL).

Follow these steps:

1) Install the Windows Server 2003 SP1 Platform SDK (April 2005 Edition).
The April 2005 PSDK bundles the VS 2005 compiler (version 14.0) and its
associated include headers and libraries. With VC6 installed it allows you
to link VC6 compatible apps for 32-bit applications.
2) You won't be able to use the 64-bit compiler bundled with the April 2005
PSDK on your 32-bit apps. But (and this is the key trick) you can use
Visual Studio 2005's compiler with the April 2005 PSDK. Just point Visual
Studio 2005's INCLUDE folders at the PSSDK folders: include\mfc,
include\atl, and include\crt. Point the LIB folder to your original VC6
installation. Now you can compile with Visual Studio 2005 and link
correctly with MFC42.LIB and MSVCRT.LIB while enjoying all the new IDE
goodies and security checking of Visual Studio 2005.



You still need the VS 2005 version of RunTmChk.lib and sehprolg.obj in order
to write the __security_check_cookie stub. (See Matt Pietrek's postings for
more info on this topic.)



To fix the remaining link errors with CxxFrameHandler3 and alloca use the
following:



.386
.model flat
;
; vc8-to-vc6 bridge assembly code.
;
; This module patches up gaps in order to a build a bridge to connect our
code
; compiled with the VC8 compiler and with the code in the VC6 runtime
library.
;
; Trampoline from ___CxxFrameHandler3 --> ___CxxFrameHandler
;
; ___CxxFrameHandler[n] is called for try/catch blocks (C++)
;
; See "How a C++ compiler implements exception handling"
; http://www.codeproject.com/cpp/exceptionhandler.asp

;

; MSVCRT.DLL
extrn __imp____CxxFrameHandler:dword ; external memory addr

public ___CxxFrameHandler3

___CxxFrameHandler3 proc near

; Jump indirect: Jumps to (*__imp__CxxFrameHandler)
jmp __imp____CxxFrameHandler ; Trampoline bounce

___CxxFrameHandler3 endp

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

extrn __chkstk:abs ; Absolute external constant

public __alloca_probe_16
__alloca_probe_16 proc near

arg_0 = dword ptr 8
push ecx
lea ecx, [esp+arg_0]
sub ecx, eax
and ecx, 0Fh
add eax, ecx
sbb ecx, ecx
or eax, ecx
pop ecx
jmp near ptr __chkstk

__alloca_probe_16 endp

public __alloca_probe_8
__alloca_probe_8 proc near
arg_0 = dword ptr 8
push ecx
lea ecx, [esp+arg_0]
sub ecx, eax
and ecx, 7
add eax, ecx
sbb ecx, ecx
or eax, ecx
pop ecx
jmp near ptr __chkstk

__alloca_probe_8 endp



-- Alan Klietz (alank at NOSPAM algintech dot com)






From: "TerryFei" on
Hi Alan,
Thanks for your sharing knowledge. It will benefit others in the newsgroup
facing this issue.

Best Regards,

Terry Fei[MSFT]
Microsoft Community Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

--------------------
>From: "Alan Klietz" <alank(a)newsgroup.nospam>
>Subject: Using VS2005 to ship legacy code for XP and Windows 2000.
>Date: Mon, 13 Feb 2006 18:05:42 -0600
>Lines: 108
>Organization: Algin Technology LLC
>X-Priority: 3
>X-MSMail-Priority: Normal
>X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
>X-RFC2646: Format=Flowed; Original
>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
>Message-ID: <#bixmpPMGHA.2416(a)TK2MSFTNGP15.phx.gbl>
>Newsgroups: microsoft.public.vc.mfc
>NNTP-Posting-Host: 64-131-62-6.usfamily.net 64.131.62.6
>Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP15.phx.gbl
>Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.vc.mfc:466701
>X-Tomcat-NG: microsoft.public.vc.mfc
>
>If you want to publish a Windows application that runs on Windows 2000 or
>Windows XP, using the latest compiler (Visual Studio 2005), you can do so.
>Without requiring that you ship megabytes of code from the VS2005 runtime
>libraries (MSVCRT80.DLL and MFC80.DLL).
>
>Follow these steps:
>
>1) Install the Windows Server 2003 SP1 Platform SDK (April 2005 Edition).
>The April 2005 PSDK bundles the VS 2005 compiler (version 14.0) and its
>associated include headers and libraries. With VC6 installed it allows
you
>to link VC6 compatible apps for 32-bit applications.
>2) You won't be able to use the 64-bit compiler bundled with the April
2005
>PSDK on your 32-bit apps. But (and this is the key trick) you can use
>Visual Studio 2005's compiler with the April 2005 PSDK. Just point Visual
>Studio 2005's INCLUDE folders at the PSSDK folders: include\mfc,
>include\atl, and include\crt. Point the LIB folder to your original VC6
>installation. Now you can compile with Visual Studio 2005 and link
>correctly with MFC42.LIB and MSVCRT.LIB while enjoying all the new IDE
>goodies and security checking of Visual Studio 2005.
>
>
>
>You still need the VS 2005 version of RunTmChk.lib and sehprolg.obj in
order
>to write the __security_check_cookie stub. (See Matt Pietrek's postings
for
>more info on this topic.)
>
>
>
>To fix the remaining link errors with CxxFrameHandler3 and alloca use the
>following:
>
>
>
> .386
> .model flat
> ;
> ; vc8-to-vc6 bridge assembly code.
> ;
> ; This module patches up gaps in order to a build a bridge to connect
our
>code
> ; compiled with the VC8 compiler and with the code in the VC6 runtime
>library.
> ;
> ; Trampoline from ___CxxFrameHandler3 --> ___CxxFrameHandler
> ;
> ; ___CxxFrameHandler[n] is called for try/catch blocks (C++)
> ;
> ; See "How a C++ compiler implements exception handling"
> ; http://www.codeproject.com/cpp/exceptionhandler.asp
>
> ;
>
> ; MSVCRT.DLL
> extrn __imp____CxxFrameHandler:dword ; external memory addr
>
>public ___CxxFrameHandler3
>
>___CxxFrameHandler3 proc near
>
> ; Jump indirect: Jumps to (*__imp__CxxFrameHandler)
> jmp __imp____CxxFrameHandler ; Trampoline bounce
>
>___CxxFrameHandler3 endp
>
>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
> extrn __chkstk:abs ; Absolute external constant
>
> public __alloca_probe_16
>__alloca_probe_16 proc near
>
>arg_0 = dword ptr 8
> push ecx
> lea ecx, [esp+arg_0]
> sub ecx, eax
> and ecx, 0Fh
> add eax, ecx
> sbb ecx, ecx
> or eax, ecx
> pop ecx
> jmp near ptr __chkstk
>
>__alloca_probe_16 endp
>
> public __alloca_probe_8
>__alloca_probe_8 proc near
>arg_0 = dword ptr 8
> push ecx
> lea ecx, [esp+arg_0]
> sub ecx, eax
> and ecx, 7
> add eax, ecx
> sbb ecx, ecx
> or eax, ecx
> pop ecx
> jmp near ptr __chkstk
>
>__alloca_probe_8 endp
>
>
>
>-- Alan Klietz (alank at NOSPAM algintech dot com)
>
>
>
>
>
>
>