static void ClearDllBit(byte[] peImageData) { using (var mainPeImage = new MyPEImage(peImageData)) { uint characteristicsOffset = (uint)mainPeImage.PEImage.ImageNTHeaders.FileHeader.StartOffset + 18; ushort characteristics = mainPeImage.OffsetReadUInt16(characteristicsOffset); characteristics &= 0xDFFF; characteristics |= 2; mainPeImage.OffsetWriteUInt16(characteristicsOffset, characteristics); } }