Troubleshooting "Not a valid win32 Application" error at the startup.



Recently, we came across a very interesting issue. A purely native application written in C++ was failing with "Not a valid win32 application" error at the startup on Windows XP machine.


 


There are a few basic checks that we do to troubleshoot this error. We did the following checks:


1)      Checked if all the modules are built for the same platform. (no mixing of modules intended for x86 and x64 platforms)


2)      Checked the Event Log entry. Sometimes EventLog gives very good clues to move towards resolution. There was no information available for this error.


3)      Tried spawning the exe from a debugger. It didn’t break inside the application but crashed even before it. Had enabled Loader snaps using gflags that come with “Debugging Tools for Windows” to check which DLL fails to load. But the application was crashing before any dependent DLL got loaded.


4)      For the first time even Process Monitor failed to give any clues.


 


Then we thought of getting the dumpbin header output (dumpbin /headers test.exe > DumpBinTest.txt). Analyzing the output file showed that target Operating System was 5.02. It means that the exe was intended for Windows Server 2003 and higher version of Operating Systems and not for XP. We tried running the exe on Windows Server 2003 machine and it worked fine. So that was the root cause. Changing the winver from 502 to 501 resolved the issue. J


 


Here is a part of the DumpBin header that confirmed the issue:


 


=============================


Microsoft (R) COFF/PE Dumper Version 9.00.30729.01


Copyright (C) Microsoft Corporation.  All rights reserved.


 


 


Dump of file TestWin32.exe


 


PE signature found


 


File Type: EXECUTABLE IMAGE


 


FILE HEADER VALUES


             14C machine (x86)


               7 number of sections


        48CFDFAC time date stamp Tue Sep 16 22:02:44 2008


               0 file pointer to symbol table


               0 number of symbols


              E0 size of optional header


             102 characteristics


                   Executable


                   32 bit word machine


 


OPTIONAL HEADER VALUES


             10B magic # (PE32)


            9.00 linker version


            3200 size of code


            4200 size of initialized data


               0 size of uninitialized data


           11073 entry point (00411073) @ILT+110(_wmainCRTStartup)


            1000 base of code


            1000 base of data


          400000 image base (00400000 to 0041AFFF)


            1000 section alignment


             200 file alignment


            5.02 operating system version


            0.00 image version


<snip>


==================================


 


 


Here are a few links for  your information:


1)      For more information on Minimum value for _WIN32_WINNT and WINVER, please check this MSDN Link.


2)      The /SUBSYSTEM option specifies the environment for the executable. Here is the link which describes it more.


3)      This blog discusses different windows version symbols. It is a nice read.


4)      This link describes how to modify the WINVER and _WIN32_WINNT and also describes what change happened in Visual Studio 2008.


 


Ravi Kumar


Microsoft Developer Support - VC++ & C#

Comments (2)

  1. fordspark701 says:

    Thank for the tips, I usually got this error when converting my OS  in a newly version of windows.

  2. Sunny says:

    What are some things to prevent or fix the win32 error from coming up when trying to download?

Skip to main content