Thread: Portable executable in C

  1. #1
    Registered User
    Join Date
    Dec 2011
    Posts
    69

    Portable executable in C

    I've been reading up on portable executables(Portable Executable - Wikipedia, the free encyclopedia), as they quite interest me. I would hate to have to compile my programs to work on different processors. This is in windows I am talking about. I read up a bit on Wow64, but I would like to target Windows 2000+. Alright, I'm going to use an analogy of something that interests me. On pentest forums I see malware developers saying that their malware will work on Windows 2000, xp, vista/win7 32/64bit. The only way I can imagine this can work is because they make their programs Portable executables(Like in the Wiki link). Am I correct on this one? Does anybody have any tutorials on making C programs portable? I have used Google to try and find some, but sometimes the best information doesn't always show up. I'm guessing you guys would have the best knowledge in this and could give me some references. Please and thank you.

  2. #2
    Registered User
    Join Date
    May 2012
    Location
    Arizona, USA
    Posts
    948
    Portable Executable format is portable only in the sense that the executable wrapper itself is versatile enough that it can be used in a variety of systems and architectures. The executable code inside the wrapper has to be compiled for whatever system will run it.

    I'm sure you've been told this in another thread already, but I'll say it again: all the Windows systems you listed can run 32-bit x86 executables. They're not "different processors" if you stick with the 32-bit instruction set that they have in common.

  3. #3
    Registered User
    Join Date
    Aug 2012
    Posts
    1
    You have a fundamental misunderstanding of PE's. The word 'portable' has *nothing* to do with 'portable applications'. It was originally named that because the format was robust enough to allow for all sorts of use, but in practice it is only used in Windows. So, again, forget the word portable and just say PE, it will simplify things for you ;p. Source: Author of PECompact, been writing PE manipulation utilities for 15 years.

    Now, as far as Windows 2000 compatibility, Microsoft dropped that from Windows Visual Studio 2010. To achieve compatibility, you have to change the OS MajorVersion/MinorVersion settings in the PE header, *or* use VS2008 (VC9) build tools. Similarly, Microsoft dropped XP/2003 in VS2012 (VC11), so you need to use the older platform toolset (VC10) to build utilities compatible with XP. Due to this rapid abandonment of Windows 2000, XP, 2003 by Microsoft, I have dropped Windows 2000 myself. I still support XP though, and am using VC10 with VS2012 until the announced out-of-band update to VS2012 restores proper XP/2003 target support.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. portable bitfields
    By Yarin in forum C++ Programming
    Replies: 2
    Last Post: 08-14-2007, 01:39 PM
  2. C - Portable?
    By vb.bajpai in forum C Programming
    Replies: 2
    Last Post: 07-15-2007, 09:09 AM
  3. Portable Doubles
    By EvilGuru in forum C Programming
    Replies: 31
    Last Post: 08-31-2006, 07:44 PM
  4. calling an executable from an executable
    By dee in forum C Programming
    Replies: 4
    Last Post: 01-10-2004, 01:32 PM
  5. Command line executable not a KDE executable?
    By FillYourBrain in forum Linux Programming
    Replies: 3
    Last Post: 10-03-2003, 12:01 PM