Are the .com files in x64 systems really .com files?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
npocmaka_
Posts: 480
Joined: 24 Jun 2013 17:10
Location: Bulgaria
Contact:

Are the .com files in x64 systems really .com files?

#1 Post by npocmaka_ » 09 Aug 2014 03:41

here's explained difference between .COM and .EXE - http://blogs.msdn.com/b/oldnewthing/arc ... 32730.aspx
But when I open a .COM file with a text editor all of them starts with "MZ"

Only these .COM commands are left in x64 systems - chcp.com;diskcomp.com;diskcopy.com;format.com;mode.com;more.com;tree.com

(i.e. missing command.com,edit.com,graftabl.com,win.com ...) but at the moment I have no x32 system to compare them.

I assume that only the listed above were possible for porting to .EXE but the extensions were left for compatibility.

penpen
Expert
Posts: 1650
Joined: 23 Jun 2013 06:15
Location: Germany

Re: Are the .com files in x64 systems really .com files?

#2 Post by penpen » 09 Aug 2014 11:31

If you mean the following, then the answer is "No", i fear:
"Are the .com files in x64 systems really executable files containing raw 16 bit machine code?"
As you assumed they are in the PE format.

penpen.

npocmaka_
Posts: 480
Joined: 24 Jun 2013 17:10
Location: Bulgaria
Contact:

Re: Are the .com files in x64 systems really .com files?

#3 Post by npocmaka_ » 09 Aug 2014 12:28

Wonderful :!:

A brand new way to check if a system is a x32 or x64 :


Code: Select all

@echo off
setlocal enableExtensions
dpath %windir%\system32

for /f %%a in ('type diskcopy.com') do (
   set "fline=%%~a"
   goto :break
)
:break

if "%fline:~0,2%" == "MZ" (
   echo x64
) else (
   echo x32
)
endlocal


:lol:

penpen
Expert
Posts: 1650
Joined: 23 Jun 2013 06:15
Location: Germany

Re: Are the .com files in x64 systems really .com files?

#4 Post by penpen » 09 Aug 2014 12:43

Sorry, but that does not mean, that all com files in 32 bit systems are 16 bit machine code executable.

Under win Xp you can see this:
PE files:
"chcp.com", "diskcomp.com", "diskcopy.com", "format.com", "graftabl.com",
"mode.com", "more.com", "tree.com", and "win.com".

32 bit executable, but no PE file:
edit.com

16 bit executables:
"command.com", "graphics.com", "kb16.com", and "loadfix.com"

penpen

Post Reply