VO 32 Bit limitations
Posted: Sat Jul 14, 2018 5:03 am
I found some C# code that checks to see if an EXE is LARGE_ADDRESS_AWARE, and if not , it will update its header. I've verified that it works by using VMMAP.
I created a C# console app which is run as a part of my installation program and updates the EXE files found in installation folder as arguments. Anyway, I do not have to rely on third party tools except the .NET framework.
Source: https://stackoverflow.com/questions/905 ... re/9056757
Credit goes to authors:
I created a C# console app which is run as a part of my installation program and updates the EXE files found in installation folder as arguments. Anyway, I do not have to rely on third party tools except the .NET framework.
Source: https://stackoverflow.com/questions/905 ... re/9056757
Credit goes to authors:
Code: Select all
static bool LargeAware(string file) {
using (var fs = File.Open(file, FileMode.Open, FileAccess.ReadWrite, FileShare.None)) {
bool b = LargeAware(fs);
fs.Close();
return b;
}
}
const int IMAGE_FILE_LARGE_ADDRESS_AWARE = 0x20;
static bool LargeAware(Stream stream) {
var br = new BinaryReader(stream);
var bw = new BinaryWriter(stream);
if (br.ReadInt16() != 0x5A4D) //No MZ Header
return false;
br.BaseStream.Position = 0x3C;
var peloc = br.ReadInt32(); //Get the PE header location.
br.BaseStream.Position = peloc;
if (br.ReadInt32() != 0x4550) //No PE header
return false;
br.BaseStream.Position += 0x12;
long nFilePos = (int)br.BaseStream.Position;
Int16 nLgaInt = br.ReadInt16();
bool bIsLGA = (nLgaInt & IMAGE_FILE_LARGE_ADDRESS_AWARE) == IMAGE_FILE_LARGE_ADDRESS_AWARE;
if (bIsLGA)
return true;
nLgaInt |= IMAGE_FILE_LARGE_ADDRESS_AWARE;
long nFilePos1 = bw.Seek((int)nFilePos, SeekOrigin.Begin);
bw.Write(nLgaInt);
bw.Flush();
long nFilePos2 = br.BaseStream.Seek(nFilePos, SeekOrigin.Begin);
nLgaInt = br.ReadInt16();
bIsLGA = (nLgaInt & IMAGE_FILE_LARGE_ADDRESS_AWARE) == IMAGE_FILE_LARGE_ADDRESS_AWARE;
return bIsLGA;
}