Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add script to restart the running XBE #62

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions python-scripts/restart-xbe.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/env python3

# This prints the path of the currently running XBE, and then restarts it

from xboxpy import *

import struct


def runningXBEPath():

# USHORT Length
# USHORT MaximumLength
# CONST char *Buffer
filename = read(ke.XeImageFileName(), 8)
filename_len, filename_maxlen, filename_str_addr = struct.unpack("<HHL", filename)

filename_str = read(filename_str_addr, filename_len).decode('ascii')
print(filename_str)

return filename_str


def launchXBE(path):
launch_data_page_addr_addr = ke.LaunchDataPage()
launch_data_page_addr = read_u32(launch_data_page_addr_addr)

# Allocate LaunchDataPage if necessary
if launch_data_page_addr == 0x00000000:
launch_data_page_addr = ke.MmAllocateContiguousMemory(0x1000)
ke.MmPersistContiguousMemory(launch_data_page_addr, 0x1000, 1)
write_u32(launch_data_page_addr_addr, launch_data_page_addr)

#struct {
# uint32_t launch_data_type;
# uint32_t title_id;
# char launch_path[520];
# uint32_t flags;
# uint8_t pad[492];
# uint32_t launch_data[3072];
#}* LaunchDataPage;
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Link to xboxdevwiki instead


xbe_path, sep, xbe_name = path.rpartition('\\')
xbe_launch_str = xbe_path + ";" + xbe_name
print(xbe_launch_str)

write(launch_data_page_addr, bytes([0] * 0x1000))
write(launch_data_page_addr + 0, struct.pack("<L", 0xFFFFFFFF))
write(launch_data_page_addr + 4, struct.pack("<L", 0))
write(launch_data_page_addr + 8, (xbe_launch_str + "\0").encode('ascii'))
write(launch_data_page_addr + 528, struct.pack("<L", 0))

ke.HalReturnToFirmware(ke.HalQuickRebootRoutine)

# Restart the running XBE
xbe_path = runningXBEPath()
print("Currently running '%s'. Restarting..." % xbe_path)
launchXBE(xbe_path)