VBoxPeSetVersion.cpp revision 01b927bd5e6f4ed282b59586dbadeb7739e5fa37
01b927bd5e6f4ed282b59586dbadeb7739e5fa37vboxsync * IPRT - Change the OS and SubSystem version to 4.0 (VS2010 trick).
01b927bd5e6f4ed282b59586dbadeb7739e5fa37vboxsync * Copyright (C) 2012 Oracle Corporation
01b927bd5e6f4ed282b59586dbadeb7739e5fa37vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
01b927bd5e6f4ed282b59586dbadeb7739e5fa37vboxsync * available from http://www.virtualbox.org. This file is free software;
01b927bd5e6f4ed282b59586dbadeb7739e5fa37vboxsync * you can redistribute it and/or modify it under the terms of the GNU
01b927bd5e6f4ed282b59586dbadeb7739e5fa37vboxsync * General Public License (GPL) as published by the Free Software
01b927bd5e6f4ed282b59586dbadeb7739e5fa37vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
01b927bd5e6f4ed282b59586dbadeb7739e5fa37vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
01b927bd5e6f4ed282b59586dbadeb7739e5fa37vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
01b927bd5e6f4ed282b59586dbadeb7739e5fa37vboxsync * The contents of this file may alternatively be used under the terms
01b927bd5e6f4ed282b59586dbadeb7739e5fa37vboxsync * of the Common Development and Distribution License Version 1.0
01b927bd5e6f4ed282b59586dbadeb7739e5fa37vboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
01b927bd5e6f4ed282b59586dbadeb7739e5fa37vboxsync * VirtualBox OSE distribution, in which case the provisions of the
01b927bd5e6f4ed282b59586dbadeb7739e5fa37vboxsync * CDDL are applicable instead of those of the GPL.
01b927bd5e6f4ed282b59586dbadeb7739e5fa37vboxsync * You may elect to license modified versions of this file under the
01b927bd5e6f4ed282b59586dbadeb7739e5fa37vboxsync * terms and conditions of either the GPL or the CDDL or both.
01b927bd5e6f4ed282b59586dbadeb7739e5fa37vboxsync/*******************************************************************************
01b927bd5e6f4ed282b59586dbadeb7739e5fa37vboxsync* Header Files *
01b927bd5e6f4ed282b59586dbadeb7739e5fa37vboxsync*******************************************************************************/
01b927bd5e6f4ed282b59586dbadeb7739e5fa37vboxsync/** @todo Rewrite this so it can take options and print out error messages. */
01b927bd5e6f4ed282b59586dbadeb7739e5fa37vboxsync if (NtHdrs.FileHeader.Machine != IMAGE_FILE_MACHINE_I386)
01b927bd5e6f4ed282b59586dbadeb7739e5fa37vboxsync if (NtHdrs.OptionalHeader.Magic != IMAGE_NT_OPTIONAL_HDR32_MAGIC)
01b927bd5e6f4ed282b59586dbadeb7739e5fa37vboxsync if (NtHdrs.OptionalHeader.Magic != IMAGE_NT_OPTIONAL_HDR32_MAGIC)
01b927bd5e6f4ed282b59586dbadeb7739e5fa37vboxsync if (NtHdrsNew.OptionalHeader.MajorOperatingSystemVersion > 4)
01b927bd5e6f4ed282b59586dbadeb7739e5fa37vboxsync NtHdrsNew.OptionalHeader.MajorOperatingSystemVersion = 4;
01b927bd5e6f4ed282b59586dbadeb7739e5fa37vboxsync NtHdrsNew.OptionalHeader.MinorOperatingSystemVersion = 0;
01b927bd5e6f4ed282b59586dbadeb7739e5fa37vboxsync if (NtHdrsNew.OptionalHeader.MajorSubsystemVersion > 4)
01b927bd5e6f4ed282b59586dbadeb7739e5fa37vboxsync NtHdrsNew.OptionalHeader.MajorSubsystemVersion = 4;
01b927bd5e6f4ed282b59586dbadeb7739e5fa37vboxsync NtHdrsNew.OptionalHeader.MinorSubsystemVersion = 0;
01b927bd5e6f4ed282b59586dbadeb7739e5fa37vboxsync /** @todo calc checksum. */