[SOLVED] not a valid Win32 application

Discussions about using Windows guests in VirtualBox.
Sasquatch
Volunteer
Posts: 17798
Joined: 17. Mar 2008, 13:41
Primary OS: Debian other
VBox Version: PUEL
Guest OSses: Windows XP, Windows 7, Linux
Location: /dev/random

Re: not a valid Win32 application

Post by Sasquatch »

mpack wrote:A question for Wine experts if you please: if you were to take a Linux executable and run it on Windows then you would get a "Not a Win32 executable" message. What would happen if you ran the same executable under Wine? Wine obviously has the capacity to recognize and run that file, but would it?
This is the result:
wine /usr/bin/leafpad
wine: Bad EXE format for Z:\usr\bin\leafpad.
So, it really does look for a .exe format. It can't run Linux native executables, because there are no file extensions on Linux. To give you some more information, this is the difference between a Linux executable and a Windows executable:
file /usr/bin/leafpad
/usr/bin/leafpad: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, stripped

file /media/programs/Installed\ Programs/NewsLeecher/newsLeecher.exe
/media/programs/Installed Programs/NewsLeecher/newsLeecher.exe: PE32 executable for MS Windows (GUI) Intel 80386 32-bit
When you open a .exe file in a text editor like Notepad, you will clearly see a piece of plain text on the first line:
This program must be run under Win32
If this does not exist, it's not a valid Windows executable I reckon. Wine's own executables, like notepad, will not run on Windows because of that. Though it won't give an error at all.
Read the Forum Posting Guide before opening a topic.
VirtualBox FAQ: Check this before asking questions.
Online User Manual: A must read if you want to know what we're talking about.
Howto: Install Linux Guest Additions
Howto: Use Shared Folders on Linux Guest
See the Tutorials and FAQ section at the top of the Forum for more guides.
Try searching the forums first with Google and add the site filter for this forum.
E.g. install guest additions site:forums.virtualbox.org

Retired from this Forum since OSSO introduction.
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: not a valid Win32 application

Post by mpack »

Sasquatch wrote:This is the result:
Thanks for that, that blows my idea that this might be a Linux executable (e.g. compiled with gcc) even though it has a .exe name.
Sasquatch wrote:When you open a .exe file in a text editor like Notepad, you will clearly see a piece of plain text on the first line:
This program must be run under Win32
If this does not exist, it's not a valid Windows executable I reckon.
Actually, not quite. Every PE32 executable has a stub 16bit DOS executable preceding it, and that string you see is just a string embedded in the most common 16bit executable stub that people use. The idea of that particular stub is that if you run this .exe in a DOS shell it will print out that message. But there is no requirement that every 32bit app use that particular stub. It could use a stub with a different message, or a stub that does something else entirely.
 Edit:  Mind you, you are probably correct to say that if you don't see this string then it probably isn't a valid Win32 executable. Another thing to look for is the start of the true Win32 PE header, marked with the characters 'PE', usually at offset 100h (256 decimal). You may see this followed (after a gap) with the words "CODE", "DATA" and "INIT".

Also, that error message only shows in DOS (*) - it is totally distinct from the OPs error message, which is issued by Windows when it tries and fails to load a Win32 image for execution.

(*) ps, the Cmd shell is not DOS. The message does not show up there. 
Okie2003
Posts: 32
Joined: 16. Jan 2008, 07:27
Primary OS: Ubuntu other
VBox Version: PUEL
Guest OSses: Windows 7
Location: Stilwell, OK USA

Re: not a valid Win32 application

Post by Okie2003 »

mpack wrote:
Okie2003 wrote:. . . Did you do the check I suggested? It would settle the matter in minutes, and remove the need for speculation.
OK, I hope I did what you suggested. I got Frhed - Free hex editor 1.7.1.0 and did a partial open on a BW file that works and one of the recent ones that does not. I am not sure what i am looking at. The first line is identical (I think), the second is different, the third is identical and then my eyes crossed ;-) kudos to you programmers. AnywayI copied a few lines of each into notepad:
MZ<bh:90><bh:00><bh:03><bh:00><bh:00><bh:00><bh:04><bh:00><bh:00><bh:00><bh:ff><bh:ff><bh:00><bh:00><bh:b8><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00>@<bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00>0<bh:01><bh:00><bh:00><bh:0e><bh:1f><bh:ba><bh:0e><bh:00><bh:b4><bh:09><bh:cd>!<bh:b8><bh:01>L<bh:cd>!This program cannot be run in DOS mode.

$<bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00>Z<bh:be>GP<bh:1e><bh:df>)<bh:03><bh:1e><bh:df>)<bh:03><bh:1e><bh:df>)<bh:03><bh:8d><bh:91><bh:b1><bh:03>
<bh:df>)<bh:03>q<bh:a9><bh:b7><bh:03>&<bh:df>)<bh:03><bh:17><bh:a7><bh:aa><bh:03><bh:10><bh:df>)<bh:03>q<bh:a9><bh:87><bh:03>
<bh:df>)<bh:03>9<bh:19>T<bh:03><bh:c1><bh:df>)<bh:03><bh:1b><bh:d3>v<bh:03>~<bh:df>)<bh:03><bh:18><bh:fc>#<bh:03><bh:04><bh:df>)<bh:03><bh:e1><bh:ff>-<bh:03><bh:0e><bh:df>)<bh:03><bh:1e><bh:df>)<bh:03><bh:ff><bh:db>)<bh:03><bh:17><bh:a7><bh:ad><bh:03><bh:1f><bh:df>)<bh:03><bh:17><bh:a7><bh:ba><bh:03>?<bh:df>)<bh:03><bh:1e><bh:df>(<bh:03>b<bh:dd>)<bh:03>q<bh:a9><bh:82><bh:03><bh:9c><bh:df>)<bh:03>q<bh:a9><bh:83><bh:03>K<bh:de>)<bh:03>q<bh:a9><bh:b2><bh:03><bh:1f><bh:df>)<bh:03>q<bh:a9><bh:b3><bh:03><bh:1f><bh:df>)<bh:03><bh:1e><bh:df><bh:be><bh:03><bh:1f><bh:df>)<bh:03>q<bh:a9><bh:b4><bh:03><bh:1f><bh:df>)<bh:03>Rich<bh:1e><bh:df>)<bh:03><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00>PE<bh:00><bh:00>L<bh:01><bh:04><bh:00><bh:17>t+L<bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:e0><bh:00><bh:03><bh:01><bh:0b><bh:01>
<bh:00><bh:00>Bu<bh:00><bh:00><bh:e8>2<bh:00><bh:00><bh:00><bh:00><bh:00>1<bh:fe>G<bh:00><bh:00><bh:10><bh:00><bh:00><bh:00>`u<bh:00><bh:00><bh:00>@<bh:00><bh:00><bh:10><bh:00><bh:00><bh:00><bh:02><bh:00><bh:00><bh:05><bh:00><bh:01><bh:00><bh:00><bh:00><bh:00><bh:00><bh:05><bh:00><bh:01><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00>P<bh:a8><bh:00><bh:00><bh:04><bh:00><bh:00><bh:e9><bh:0b><bh:98><bh:00><bh:02><bh:00><bh:00><bh:81><bh:00>@<bh:1f><bh:00><bh:00><bh:10><bh:00><bh:00><bh:00><bh:00><bh:10><bh:00><bh:00><bh:10><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:10><bh:00><bh:00><bh:00><bh:f0>?w<bh:00><bh:91><bh:0f><bh:00><bh:00><bh:cc><bh:08>w<bh:00><bh:cc><bh:01><bh:00><bh:00><bh:00><bh:10><bh:94><bh:00><bh:98>9<bh:14><bh:00><bh:00><bh


Above from a file that won't work

Below from a file that will

MZ<bh:90><bh:00><bh:03><bh:00><bh:00><bh:00><bh:04><bh:00><bh:00><bh:00><bh:ff><bh:ff><bh:00><bh:00><bh:b8><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00>@<bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00>@<bh:01><bh:00><bh:00><bh:0e><bh:1f><bh:ba><bh:0e><bh:00><bh:b4><bh:09><bh:cd>!<bh:b8><bh:01>L<bh:cd>!This program cannot be run in DOS mode.

$<bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00>T"`<bh:cd><bh:10>C<bh:0e><bh:9e><bh:10>C<bh:0e><bh:9e><bh:10>C<bh:0e><bh:9e><bh:ad><bh:0c><bh:98><bh:9e><bh:04>C<bh:0e><bh:9e><bh:19>;<bh:9b><bh:9e>&C<bh:0e><bh:9e>7<bh:85>c<bh:9e><bh:1e>C<bh:0e><bh:9e><bh:0e><bh:11><bh:8a><bh:9e>8C<bh:0e><bh:9e><bh:19>;<bh:87><bh:9e><bh:03>C<bh:0e><bh:9e>7<bh:85>s<bh:9e><bh:cf>C<bh:0e><bh:9e><bh:15>OQ<bh:9e>pC<bh:0e><bh:9e><bh:16>`<bh:04><bh:9e>
C<bh:0e><bh:9e><bh:ef>c
<bh:9e><bh:00>C<bh:0e><bh:9e><bh:10>C<bh:0e><bh:9e><bh:f1>G<bh:0e><bh:9e>7<bh:85>`<bh:9e><bh:11>C<bh:0e><bh:9e>7<bh:85>u<bh:9e>1C<bh:0e><bh:9e><bh:10>C<bh:0f><bh:9e>aA<bh:0e><bh:9e><bh:19>;<bh:8a><bh:9e>^C<bh:0e><bh:9e><bh:19>;<bh:8d><bh:9e>XB<bh:0e><bh:9e><bh:19>;<bh:9c><bh:9e><bh:11>C<bh:0e><bh:9e><bh:0e><bh:11><bh:9a><bh:9e><bh:11>C<bh:0e><bh:9e><bh:10>C<bh:99><bh:9e><bh:11>C<bh:0e><bh:9e><bh:19>;<bh:9f><bh:9e><bh:11>C<bh:0e><bh:9e>Rich<bh:10>C<bh:0e><bh:9e><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00><bh:00>PE<bh:00><bh:00>L<bh:01><bh:04><bh:00><bh:9c>Q<bh:8d>

Does this tell us anything or should I do something else. If I did not do what you ask, please try again and I will try again.
Dell Latitude E6510, Netrunner (Kubuntu 12.04), Win 7 in VB
Okie2003
Posts: 32
Joined: 16. Jan 2008, 07:27
Primary OS: Ubuntu other
VBox Version: PUEL
Guest OSses: Windows 7
Location: Stilwell, OK USA

Re: not a valid Win32 application

Post by Okie2003 »

I have created a new virtual hard-drive and installed a test copy of Win XP. I then did a minimal install of BibleWorks and updated. The update DID work. I have asked on the BW forum if anyone is still running a native install of Win 2000.
Dell Latitude E6510, Netrunner (Kubuntu 12.04), Win 7 in VB
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: not a valid Win32 application

Post by mpack »

Hmm. Without going through it byte by byte it the two do look the same, no obvious signs of corruption: the non-working one is definitely intended to be a PE32 and not a Linux executable, garbage, all zeros etc. In which case I must accept the idea that it's a Windows version thing. Now I know that the PE32 format has not fundamentally changed since Win9x days (since I still use a Win9x era C compiler for most of my work!), so the only thing I can think of is that the PE header sets a new flag that Win2K doesn't recognize. If that is true then you ought to get the same error in native Win2K.

I do have a question for the BW developers: is Win2K a supported host OS?
Okie2003
Posts: 32
Joined: 16. Jan 2008, 07:27
Primary OS: Ubuntu other
VBox Version: PUEL
Guest OSses: Windows 7
Location: Stilwell, OK USA

Re: not a valid Win32 application

Post by Okie2003 »

Just a follow up: First, thanks to all who took time to think about and reply to this thread. Second, the problem is that BibleWorks no longer works right with Win2k. BibleWorks does not know why. I suspect that very few, if any are using Win2k so it is not worth the effort to look into it. I just assumed since it had worked with Win2k and it worked in wine that it should work in Win2k. That's what I get for assuming.

Thanks again to all.
Dell Latitude E6510, Netrunner (Kubuntu 12.04), Win 7 in VB
__Vano
Posts: 1
Joined: 8. Nov 2015, 16:38

Re: [SOLVED] not a valid Win32 application

Post by __Vano »

The "not a valid Win32 application" error in this case must be triggered by the fields in the .exe's IMAGE_OPTIONAL_HEADER: Major/MinorOperatingSystemVersion and Major/MinorSubsystemVersion . They are typically set to the same value that corresponds to a Windows internal version number.

If those in your app are set to "5.1", it will run on XP (5.1) but not 2000 (5.0). You can hack the values in all the executable modules of the app to circumvent this, but the app may still fail due to API changes between the OS versions.
Post Reply