/// <summary> /// Shared connection function /// </summary> private void _connect() { // establish debug session connection = new TcpClient(); connection.ReceiveBufferSize = 20 * 0x100000; connection.SendBufferSize = 20 * 0x100000; connection.NoDelay = true; foreach (DebugConnection dc in connections) if (dc.IP == debugIP) { connection.Client.Bind(new IPEndPoint(dc.LocalIP, 0)); break; } connection.Connect(debugIP, notificationPort); connected = Ping(100); // make sure it is successful // make sure they are using the current xbdm.dll v7887 debugMonitorVersion = new Version(SendCommand("dmversion").Message); if (DebugMonitorVersion != new Version("1.00.7887.1")) { Disconnect(); // unsafe to proceed, so disconnect... throw new ApiException("Must use xbdm.dll v1.00.7887.1 before connecting"); } // register our notification session RegisterNotificationSession(notificationPort); // must have for our shitty setmem hack to work ;P CreateFile("E:\\fUkM$DeVs", FileMode.Create); //initialize components memoryStream = new MemoryStream(this); memoryReader = new BinaryReader(memoryStream); memoryWriter = new BinaryWriter(memoryStream); kernel = new XboxKernel(this); SetMemory(0xB00292D0, ScriptBufferAddress); // set up the script buffer InitializeHistory(); eeprom = ReadEEPROM(); GetXboxInformation(); }
private void Initialize(string xboxIP) { // establish debug session connection = new TcpClient(); connection.SendTimeout = 250; connection.ReceiveTimeout = 250; connection.ReceiveBufferSize = 0x100000 * 3; // todo: check on this connection.SendBufferSize = 0x100000 * 3; connection.NoDelay = true; connection.Connect(xboxIP, 731); connected = Ping(100); // make sure it is successful if (connected) { // make sure they are using the current xbdm.dll v7887 debugMonitorVersion = new Version(SendCommand("dmversion").Message); if (DebugMonitorVersion != new Version("1.00.7887.1")) { Disconnect(); // unsafe to proceed, so disconnect... throw new ApiException("Must use our hacked xbdm.dll v1.00.7887.1 before connecting"); } // check correct module entrypoint SendCommand("modules"); modules = new List<ModuleInfo>(); string line = ReceiveSocketLine(); while (line[0] != '.') { ModuleInfo module = new ModuleInfo(); module.Sections = new List<ModuleSection>(); var info = Util.ExtractResponseInformation(line); module.Name = (string)info[0]; module.BaseAddress = Convert.ToUInt32(info[1]); if (module.Name == "xbdm.dll" && module.BaseAddress != 0xB0000000) throw new Exception("You seem to be most likely running the Complex v4627 Debug Bios. YeloDebug is not compatible with this bios."); module.Size = (uint)info[2]; module.Checksum = (uint)info[3]; module.TimeStamp = Util.TimeStampToUniversalDateTime((uint)info[4]); modules.Add(module); line = ReceiveSocketLine(); } foreach (ModuleInfo module in modules) { SendCommand("modsections name=\"{0}\"", module.Name); List<string> response = ReceiveMultilineResponseList(); foreach (string r in response) { ModuleSection modSection = new ModuleSection(); var info = Util.ExtractResponseInformation(r); modSection.Name = (string)info[0]; modSection.Base = Convert.ToUInt32(info[1]); modSection.Size = Convert.ToUInt32(info[2]); modSection.Index = Convert.ToUInt32(info[3]); modSection.Flags = Convert.ToUInt32(info[4]); module.Sections.Add(modSection); } } // register our notification session if (notificationSessionEnabled) RegisterNotificationSession(notificationPort); // must have for our shitty setmem hack to work ;P CreateFile("E:\\fUkM$DeVs", FileMode.Create); //initialize main components - order specific!!! MemoryStream = new XboxMemoryStream(this); MemoryStream.SafeMode = true; MemoryReader = new BinaryReader(MemoryStream); MemoryWriter = new BinaryWriter(MemoryStream); kernel = new XboxKernel(this); History = new XboxHistory(this); Gamepad = new XboxGamepad(this); eeprom = ReadEEPROM(); // get xbox production information ProductionInfo pInfo = new ProductionInfo(); string serial = ASCIIEncoding.ASCII.GetString(eeprom, 0x34, 12); switch (serial[11]) { case '2': pInfo.Country = "Mexico"; break; case '3': pInfo.Country = "Hungary"; break; case '5': pInfo.Country = "China"; break; case '6': pInfo.Country = "Taiwan"; break; default: pInfo.Country = "Unknown"; break; } pInfo.LineNumber = Convert.ToUInt32(serial.Substring(0, 1)); pInfo.Week = Convert.ToUInt32(serial.Substring(8, 2)); pInfo.Year = Convert.ToUInt32("200" + serial[7]); productionInfo = pInfo; // xbox video encoder type if (CallAddressEx(Kernel.HalReadSMBusValue, null, true, SMCDevices.VideoEncoderXcalibur, VideoEncoderCommand.Detect, 0, History.ScratchBuffer) == 0) videoEncoderType = VideoEncoder.Xcalibur; else if (CallAddressEx(Kernel.HalReadSMBusValue, null, true, SMCDevices.VideoEncoderConnexant, VideoEncoderCommand.Detect, 0, History.ScratchBuffer) == 0) videoEncoderType = VideoEncoder.Connexant; else if (CallAddressEx(Kernel.HalReadSMBusValue, null, true, SMCDevices.VideoEncoderFocus, VideoEncoderCommand.Detect, 0, History.ScratchBuffer) == 0) videoEncoderType = VideoEncoder.Focus; else videoEncoderType = VideoEncoder.Unknown; // processor information SetMemory(XboxHistory.ScriptBufferAddress, Util.HexStringToBytes("B8010000000FA2A300000100B80000DB02C21000")); SendCommand("crashdump"); uint eax = GetUInt32(0x10000); processor.Stepping = eax & 0xf; processor.Model = (eax >> 4) & 0xf; processor.Family = (eax >> 8) & 0xf; if (processor.Model == 11) { processor.Identification = "1.48 GHz Intel Tualatin Celeron (DreamX)"; } else if (processor.Model == 8 && processor.Stepping == 6) { processor.Identification = "1.00 GHz Intel Pentium III Coppermine"; } else { processor.Identification = "733.33 MHz Intel Pentium III"; } // hardware info uint ver = GetUInt32(Kernel.HardwareInfo); string vstr = Convert.ToString(ver, 16).PadLeft(8, '0'); string vstr2 = Util.HexBytesToString(GetMemory(Kernel.HardwareInfo + 4, 2)).Insert(2, " "); hardwareInfo = vstr + " " + vstr2; macAddress = BitConverter.ToString(eeprom, 0x40, 6).Replace('-', ':'); serialNumber = Convert.ToUInt64(ASCIIEncoding.ASCII.GetString(eeprom, 0x34, 12)); lanKey = GetMemory(Kernel.XboxLANKey, 16); signatureKey = GetMemory(Kernel.XboxSignatureKey, 16); eepromKey = GetMemory(Kernel.XboxEEPROMKey, 16); hardDriveKey = GetMemory(Kernel.XboxHDKey, 16); byte[] hdModelInfo = GetMemory(Kernel.HalDiskModelNumber, 40); uint unk1 = BitConverter.ToUInt32(hdModelInfo, 0); uint index = BitConverter.ToUInt32(hdModelInfo, 4); hardDriveModel = ASCIIEncoding.ASCII.GetString(hdModelInfo, 8, 32).Trim().Replace("\0", ""); byte[] hdSerialInfo = GetMemory(Kernel.HalDiskSerialNumber, 32); unk1 = BitConverter.ToUInt32(hdSerialInfo, 0); index = BitConverter.ToUInt32(hdSerialInfo, 4); hardDriveSerial = ASCIIEncoding.ASCII.GetString(hdSerialInfo, 8, 16).Trim().Replace("\0", ""); alternateSignatureKeys = new byte[16][]; byte[] keyData = GetMemory(Kernel.XboxAlternateSignatureKeys, 256); for (int i = 0; i < 16; i++) { alternateSignatureKeys[i] = new byte[16]; Buffer.BlockCopy(keyData, i * 16, alternateSignatureKeys[i], 0, 16); } StringBuilder krnlStr = new StringBuilder(); byte[] krnlVersion = GetMemory(Kernel.XboxKrnlVersion, 8); krnlStr.AppendFormat("{0}.{1}.{2}.{3}", BitConverter.ToUInt16(krnlVersion, 0), BitConverter.ToUInt16(krnlVersion, 2), BitConverter.ToUInt16(krnlVersion, 4), BitConverter.ToUInt16(krnlVersion, 6) ); kernelVersion = new Version(krnlStr.ToString()); try { // OPTIONAL - will fail on some boxes that return "not debuggable" error processID = Convert.ToUInt32(SendCommand("getpid").Message.Substring(6), 16); SendCommand("xbeinfo running"); xbeInfo = new XbeInfo(); line = ReceiveSocketLine(); XbeInfo.TimeStamp = Util.TimeStampToUniversalDateTime((uint)Util.GetResponseInfo(line, 0)); XbeInfo.Checksum = (uint)Util.GetResponseInfo(line, 1); line = ReceiveSocketLine(); XbeInfo.LaunchPath = (string)Util.GetResponseInfo(line, 0); ReceiveSocketLine(); // '.' } catch { } try { string hex = SendCommand("altaddr").Message.Substring(7); titleIP = new IPAddress(Util.HexStringToBytes(hex)); } catch { } linkStatus = (LinkStatus)CallAddressEx(Kernel.PhyGetLinkState, null, true, 0); MemoryStream.SafeMode = false; } else throw new NoConnectionException("Unable to connect."); }