diff --git a/python-scripts/xbox-info.py b/python-scripts/xbox-info.py new file mode 100755 index 0000000..f035066 --- /dev/null +++ b/python-scripts/xbox-info.py @@ -0,0 +1,69 @@ +#!/usr/bin/python3 -u + +from xboxpy import * + +import struct + +def malloc(size): + #FIXME: Use keNtAllocateVirtualMemory(&addr, 0, &size, ke.MEM_RESERVE | ke.MEM_COMMIT, ke.PAGE_READWRITE) + # (Where addr is a pointer to 32 bit of 0) + return ke.MmAllocateContiguousMemory(size) + +def free(ptr): + #FIXME: Once malloc is fixed, use ke.NtFreeVirtualMemory(ptr, 0, ke.MEM_RELEASE) + ke.MmFreeContiguousMemory(ptr) + +def read_pci_config(address): + addr = malloc(4) + assert(address & 0x80000000) + BusNumber = (address >> 16) & 0xFF + SlotNumber = (address >> 11) & 0x1F + function = (address >> 8) & 0x7 + RegisterNumber = (address >> 0) & 0xFF + assert(RegisterNumber & 0x3 == 0) + ke.HalReadWritePCISpace(BusNumber, SlotNumber, (function << 8) | RegisterNumber, addr, 4, ke.FALSE) + v = struct.unpack("