// Old CS versions byte[] unpackNativeFile1(PeImage peImage) { const int dataDirNum = 6; // debug dir const int dotNetDirNum = 14; if (peImage.OptionalHeader.dataDirectories[dataDirNum].virtualAddress == 0) { return(null); } if (peImage.OptionalHeader.dataDirectories[dataDirNum].size != 0x48) { return(null); } var fileData = peImage.readAllBytes(); int dataDir = (int)peImage.OptionalHeader.offsetOfDataDirectory(dataDirNum); int dotNetDir = (int)peImage.OptionalHeader.offsetOfDataDirectory(dotNetDirNum); writeUInt32(fileData, dotNetDir, BitConverter.ToUInt32(fileData, dataDir)); writeUInt32(fileData, dotNetDir + 4, BitConverter.ToUInt32(fileData, dataDir + 4)); writeUInt32(fileData, dataDir, 0); writeUInt32(fileData, dataDir + 4, 0); ModuleBytes = fileData; return(fileData); }