示例#1
0
 public static UImageResult TryLoad(string fileName, out UImage uImage)
 {
     uImage = null;
     if (new FileInfo(fileName).Length < 64)
     {
         return(UImageResult.NotUImage);
     }
     byte[] headerForCrc;
     using (var reader = new BinaryReader(File.OpenRead(fileName)))
     {
         headerForCrc = reader.ReadBytes(64);
         // we need to zero crc part
         for (var i = 4; i < 8; i++)
         {
             headerForCrc[i] = 0;
         }
     }
     using (var reader = new BinaryReader(File.OpenRead(fileName)))
     {
         var magic = reader.ReadUInt32BigEndian();
         if (magic != Magic)
         {
             return(UImageResult.NotUImage);
         }
         var crc = reader.ReadUInt32BigEndian();
         if (crc != GzipCrc32(headerForCrc))
         {
             return(UImageResult.BadChecksum);
         }
         reader.ReadBytes(22);
         var imageType = (ImageType)reader.ReadByte();
         if (!Enum.IsDefined(typeof(ImageType), imageType))
         {
             return(UImageResult.NotSupportedImageType);
         }
         // TODO: check CRC of the header
         uImage = new UImage(fileName);
         return(UImageResult.OK);
     }
 }
示例#2
0
		public static UImageResult TryLoad(string fileName, out UImage uImage)
		{
			uImage = null;
			if(new FileInfo(fileName).Length < 64)
			{
				return UImageResult.NotUImage;
			}
			byte[] headerForCrc;
			using(var reader = new BinaryReader(File.OpenRead(fileName)))
			{
				headerForCrc = reader.ReadBytes(64);
				// we need to zero crc part
				for(var i = 4; i < 8; i++)
				{
					headerForCrc[i] = 0;
				}
			}
			using(var reader = new BinaryReader(File.OpenRead(fileName)))
			{
				var magic = reader.ReadUInt32BigEndian();
				if(magic != Magic)
				{
					return UImageResult.NotUImage;
				}
				var crc = reader.ReadUInt32BigEndian();
				if(crc != GzipCrc32(headerForCrc))
				{
					return UImageResult.BadChecksum;
				}
				reader.ReadBytes(22);
				var imageType = (ImageType)reader.ReadByte();
				if(!Enum.IsDefined(typeof(ImageType), imageType))
				{
					return UImageResult.NotSupportedImageType;
				}
				// TODO: check CRC of the header
				uImage = new UImage(fileName);
				return UImageResult.OK;
			}
		}
示例#3
0
文件: CortexM.cs 项目: emul8/emul8
 void IControllableCPU.InitFromUImage(UImage uImage)
 {
     // do nothing
 }
示例#4
0
 public virtual void InitFromUImage(UImage uImage)
 {
     this.Log(LogLevel.Info, "Setting PC value to 0x{0:X}.", uImage.EntryPoint);
     SetPCFromEntryPoint(uImage.EntryPoint);
 }
示例#5
0
文件: PowerPc.cs 项目: rte-se/emul8
 public override void InitFromUImage(UImage uImage)
 {
     this.Log(LogLevel.Warning, "PowerPC VLE mode not implemented for uImage loading.");
     base.InitFromUImage(uImage);
 }