/// <summary> /// Reads all static xbox information that will remain constant throughout a session. /// </summary> private void GetXboxInformation() { // xbox video encoder type if (CallAddressEx(Kernel.HalReadSMBusValue, null, true, SMBusDevices.VideoEncoderXcalibur, VideoEncoderCommand.Detect, 0, scratchBuffer) == 0) videoEncoderType = VideoEncoder.Xcalibur; else if (CallAddressEx(Kernel.HalReadSMBusValue, null, true, SMBusDevices.VideoEncoderConnexant, VideoEncoderCommand.Detect, 0, scratchBuffer) == 0) videoEncoderType = VideoEncoder.Connexant; else if (CallAddressEx(Kernel.HalReadSMBusValue, null, true, SMBusDevices.VideoEncoderFocus, VideoEncoderCommand.Detect, 0, scratchBuffer) == 0) videoEncoderType = VideoEncoder.Focus; else videoEncoderType = VideoEncoder.Unknown; // xbox version info CallAddressEx(Kernel.HalReadSMBusValue, null, false, SMBusDevices.PIC, PICCommand.Version, 0, scratchBuffer); CallAddressEx(Kernel.HalReadSMBusValue, null, false, SMBusDevices.PIC, PICCommand.Version, 0, scratchBuffer + 1); CallAddressEx(Kernel.HalReadSMBusValue, null, false, SMBusDevices.PIC, PICCommand.Version, 0, scratchBuffer + 2); string code = ASCIIEncoding.ASCII.GetString(GetMemory(scratchBuffer, 3)); switch (code) { case "01D": case "D01": case "1D0": case "0D1": version = "Xbox Development Kit"; break; case "P01": version = "Xbox v1.0"; break; case "P05": version = "Xbox v1.1"; break; case "P11": case "1P1": case "11P": if (videoEncoderType == VideoEncoder.Focus) version = "1.4"; else version = "Xbox v1.2/1.3"; break; case "P2L": version = "Xbox v1.6"; break; case "B11": case "DBG": version = "Xbox Debug Kit"; break; // green default: version = code + ": Unknown Xbox"; break; } // processor information SetMemory(ScriptBufferAddress, Util.StringToHexBytes("B8010000000FA2A300000100B80000DB02C21000")); SendCommand("crashdump"); uint eax = GetUInt32(0x10000); processorInformation.Stepping = eax & 0xf; processorInformation.Model = (eax >> 4) & 0xf; processorInformation.Family = (eax >> 8) & 0xf; if (processorInformation.Model == 11) cpuFrequency = "1.48 GHz"; // DreamX console else if (processorInformation.Model == 8 && processorInformation.Stepping == 6) cpuFrequency = "1.00 GHz"; // Intel Pentium III Coppermine else cpuFrequency = "733.33 MHz"; // 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()); SendCommand("modules"); modules = new List<ModuleInfo>(); string line = ReceiveSocketLine(); while (line[0] != '.') { ModuleInfo module = new ModuleInfo(); module.Sections = new List<ModuleSection>(); List<object> info = Util.ExtractResponseInformation(line); module.Name = (string)info[0]; module.BaseAddress = (uint)info[1]; 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); line = ReceiveSocketLine(); while (line[0] != '.') { ModuleSection modSection = new ModuleSection(); List<object> info = Util.ExtractResponseInformation(line); modSection.Name = (string)info[0]; modSection.Base = (uint)info[1]; modSection.Size = (uint)info[2]; modSection.Index = (uint)info[3]; modSection.Flags = (uint)info[4]; module.Sections.Add(modSection); line = ReceiveSocketLine(); } } string hex = SendCommand("altaddr").Message.Substring(7); titleIP = new IPAddress(Util.StringToHexBytes(hex)); linkStatus = (LinkStatus)CallAddressEx(Kernel.PhyGetLinkState, null, true, 0); // Attempt to load title/game info. Will throw exception if we are in Debug Dash try { getTitleInformation(); } catch { } }
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."); }