Microsoft KB Archive/843594

= A signed executable file that was made with Visual FoxPro 6 or Visual FoxPro 7 does not run correctly =

Article ID: 843594

Article Last Modified on 3/9/2005

-

APPLIES TO


 * Microsoft Visual FoxPro 7.0 Professional Edition
 * Microsoft Visual FoxPro 6.0 Professional Edition

-



SUMMARY
Because security is an important consideration for many developers, signing executable files to validate their authenticity is becoming a general practice. Unfortunately, when an executable file is made with a version of Microsoft Visual FoxPro that is earlier than Visual FoxPro 8 and then that executable file is signed, the executable file no longer runs correctly.



SYMPTOMS
You create an executable file by using Visual FoxPro 6 or Visual FoxPro 7. Then, this executable file is signed with a Software Publisher Certificate. When you run the signed executable file, a Do dialog box appears. The expected behavior is for the executable file to run.



CAUSE
When the executable file is signed, the following events occur:
 * The size of the file increases by the size of the certificate.
 * The certificate is added to the end of the file.
 * Some bytes from the EXE header are modified.

This problem occurs because Visual FoxPro makes some verifications when the application is loaded. Visual FoxPro looks for information that should be in a fixed position at the end of the file. However, because the signing process modifies the original file by adding the certificate at the end, Visual FoxPro cannot find this information any longer. Therefore, the dialog box that is described in the &quot;Symptoms&quot; section prompts you for this information.



RESOLUTION
To resolve this problem, upgrade to Microsoft Visual FoxPro version 8.0 or a later version, and recompile the custom executable in that version. When it is recompiled, the custom executable must be signed again with a Software Publisher Certificate.



Steps to reproduce the problem by using Visual FoxPro 6 or Visual FoxPro 7
Note You must have Signcode.exe to reproduce this problem. Signcode.exe signs a portable executable (PE) file by using an Authenticode digital signature or &quot;cert&quot;. A portable executable (PE) file is a .dll file or an .exe file. Signcode.exe is included with the Microsoft .NET Framework SDK. For additional information, visit the following Microsoft Web site:

Note You do not have run Microsoft Visual Studio to install and use the .NET Framework SDK. However, you must have the .NET Framework Redistributable Package version 1.1 installed. For additional information about the .NET Framework Redistributable Package, visit the .NET Framework SDK download Web page. When you have installed the .NET Framework SDK, follow these steps:   In Visual FoxPro 6 or Visual FoxPro 7, run the following code to create an executable file that is named Vfp_testexe.exe in the root folder on the C drive: CD (ADDBS(JUSTPATH(SYS(16)))) CLOSE ALL ERASE VFP_TESTEXE*.* STRTOFILE(  [_SCREEN.Caption = 'Build With ' + VERSION] + CHR(13) + ;    [WAIT WINDOW &quot;HELLO WORLD&quot;], [VFP_TESTEXE.PRG])

BUILD PROJECT VFP_TESTEXE FROM VFP_TESTEXE.PRG BUILD EXE C:\VFP_TESTEXE.EXE FROM VFP_TESTEXE RECOMPILE  At a command prompt, locate the Bin subfolder in the .NET Framework SDK folder. You will use the cert and private key files that you create in this step to create a test Software Publisher Certificate. To create a test private key file that is named C:\Vfptest.pvk and a test certificate that is named C:\Vfptest.cer, type the following command at the command prompt:

makecert -sv &quot;C:\VFPTEST.pvk&quot; -n &quot;CN=My Company&quot; C:\VFPTEST.cer

Every time that you are prompted to type a password, type the same random password. Make a note of this password. Create a test Software Publisher Certificate (.spc) file from the test cert file that you created in step 3. To do this, type the following command at the command prompt:

cert2spc C:\VFPTEST.cer C:\VFPTEST.spc

 Use the test Software Publisher Certificate to sign the Visual FoxPro executable file. To do this, type the following command at the command prompt:

signcode -v C:\VFPTEST.pvk -spc C:\VFPTEST.spc C:\VFP_TESTEXE.EXE

You are prompted for a password. Type the password that you noted in step 3. Try to run C:\Vfp_testexe.exe. If you created this file by using a version of Visual FoxPro that is earlier than 8.0, a Do dialog box appears.</li></ol>

Keywords: kbcodesnippet kbprb KB843594

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.