unsafe public bool Start() { string cpu0_hex_path = hex0_path; string cpu1_hex_path = hex1_path; if ((File.Exists(@cpu0_hex_path) == false) || (File.Exists(@cpu1_hex_path) == false)) { MessageBox.Show("HEX not exist! " + cpu0_hex_path + " " + cpu1_hex_path + Dbg.GetStack(), "Warning!"); return(false); } FileInfo fi = new FileInfo(cpu0_hex_path); last_hex_time = fi.LastWriteTime; //记录上一次打开HEX的时间 Dbg.WriteLine("First. Create:" + fi.CreationTime.ToString() + " Write:" + fi.LastWriteTime + " Access:" + fi.LastAccessTime); char[] pwd_hex0 = hex0_path.ToCharArray(); char[] pwd_hex1 = hex1_path.ToCharArray(); Dbg.WriteLine("pwd_hex0:{0}", hex0_path); Dbg.WriteLine("pwd_hex1:{0}", hex1_path); //将内嵌的资源释放到临时目录下 if (File.Exists(fast_printf_dll_address) == false) { FileStream str = new FileStream(fast_printf_dll_address, FileMode.OpenOrCreate); str.Write(Properties.Resources.FastPrintf, 0, Properties.Resources.FastPrintf.Length); str.Close(); } mi_fa = new memory_desc(); mi_fb = new memory_desc(); mi_fa.pBuff = (byte *)Marshal.AllocHGlobal(MEMORY_MAX_BANK * MEMORY_BANK_SIZE); mi_fb.pBuff = (byte *)Marshal.AllocHGlobal(MEMORY_MAX_BANK * MEMORY_BANK_SIZE); mi_fa.bank = (memory_bank *)Marshal.AllocHGlobal(sizeof(memory_bank) * MEMORY_MAX_BANK); mi_fb.bank = (memory_bank *)Marshal.AllocHGlobal(sizeof(memory_bank) * MEMORY_MAX_BANK); hex2bin_mount(ref mi_fa); hex2bin_mount(ref mi_fb); if (hex2bin_read_hex(pwd_hex0, ref mi_fa) == 0) { MessageBox.Show("###open hex0 fail!", "Error!"); Close(); return(false); } if (hex2bin_read_hex(pwd_hex1, ref mi_fb) == 0) { MessageBox.Show("###open hex1 fail!", "Error!"); return(false); } input_data = (byte *)Marshal.AllocHGlobal(1024 * 1024); output_data = (byte *)Marshal.AllocHGlobal(1024 * 1024); is_active = true; return(true); }