internal EmulationRegisterCollection(EmulationRegister[] registers) { p_Registers = registers; //set a local copy of the length //so that in future we don't have //redundancy hopping across object properties. p_Length = registers.Length; }
public EmulationRegisterCollection GetRegisters(EmulationProcessor processor) { Monitor.Enter(p_SyncLock); //get all the registers assigned to the processor monitorExecute("human-monitor-command", new string[][] { new string[] { "command-line", "info registers" }, new string[] { "cpu-index", processor.Index.ToString() } }); JSONObject registers = monitorReadObject(true)[0]; //get the string which contains the raw register data returned //from Qemu string raw = registers["return"].ToString(); raw = raw.Replace("\\r", "").Replace("\\n", " "); //we assume that each register is seperated by a space. string[] split = raw.Split(' '); //iterate over the register strings EmulationRegister[] buffer = new EmulationRegister[0]; for (int c = 0; c < split.Length; c++) { string entry = split[c]; //don't know what the [...] bit means yet. if (entry.StartsWith("[")) { continue; } //get the register name and value string string[] eSplit = entry.Split('='); if (eSplit.Length != 2) { continue; } string name = eSplit[0]; string value = eSplit[1]; if (name.Replace(" ", "").Length == 0) { continue; } if (value.Length == 0) { value = "0"; } //add the register to the return buffer //(we convert the value string from hex to a 64bit int) try { Helpers.AddObject(ref buffer, new EmulationRegister( name, Convert.ToInt64(value, 16))); } catch { } } Monitor.Exit(p_SyncLock); return new EmulationRegisterCollection(buffer); }
public EmulationRegisterCollection GetRegisters(EmulationProcessor processor) { Monitor.Enter(p_SyncLock); //get all the registers assigned to the processor monitorExecute("human-monitor-command", new string[][] { new string[] { "command-line", "info registers" }, new string[] { "cpu-index", processor.Index.ToString() } }); JSONObject registers = monitorReadObject(true)[0]; //get the string which contains the raw register data returned //from Qemu string raw = registers["return"].ToString(); raw = raw.Replace("\\r", "").Replace("\\n", " "); //we assume that each register is seperated by a space. string[] split = raw.Split(' '); //iterate over the register strings EmulationRegister[] buffer = new EmulationRegister[0]; for (int c = 0; c < split.Length; c++) { string entry = split[c]; //don't know what the [...] bit means yet. if (entry.StartsWith("[")) { continue; } //get the register name and value string string[] eSplit = entry.Split('='); if (eSplit.Length != 2) { continue; } string name = eSplit[0]; string value = eSplit[1]; if (name.Replace(" ", "").Length == 0) { continue; } if (value.Length == 0) { value = "0"; } //add the register to the return buffer //(we convert the value string from hex to a 64bit int) try { Helpers.AddObject(ref buffer, new EmulationRegister( name, Convert.ToInt64(value, 16))); } catch { } } Monitor.Exit(p_SyncLock); return(new EmulationRegisterCollection(buffer)); }