-
Notifications
You must be signed in to change notification settings - Fork 73
Expands XLaunchXBE to allow caller to set LaunchData. #501
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,51 +9,78 @@ | |
|
||
#define KernelMode 0 | ||
|
||
#define LaunchDataPageSize 0x1000 | ||
|
||
void XReboot() | ||
{ | ||
HalReturnToFirmware(HalRebootRoutine); | ||
HalReturnToFirmware(HalRebootRoutine); | ||
} | ||
|
||
int XGetLaunchInfo(unsigned long *launchDataType, const unsigned char **launchData) | ||
{ | ||
*launchDataType = LDT_NONE; | ||
*launchData = NULL; | ||
|
||
if (LaunchDataPage == NULL) { | ||
LaunchDataPage = MmAllocateContiguousMemory(LaunchDataPageSize); | ||
if (LaunchDataPage == NULL) { | ||
return -1; | ||
} | ||
memset(LaunchDataPage, 0, LaunchDataPageSize); | ||
LaunchDataPage->Header.dwLaunchDataType = LDT_FROM_DASHBOARD; | ||
} | ||
|
||
*launchDataType = LaunchDataPage->Header.dwLaunchDataType; | ||
*launchData = LaunchDataPage->LaunchData; | ||
return 0; | ||
} | ||
|
||
void XLaunchXBE(const char *xbePath) | ||
{ | ||
XLaunchXBEEx(xbePath, NULL); | ||
} | ||
|
||
/** | ||
* Launches an XBE. Examples of xbePath might be: | ||
* c:\\blah.xbe | ||
* c:/foo/bar.xbe | ||
* If the XBE is able to be launched, this method will | ||
* not return. If there is a problem, then it return. | ||
*/ | ||
void XLaunchXBE(char *xbePath) | ||
void XLaunchXBEEx(const char *xbePath, const void *launchData) | ||
{ | ||
#if 0 | ||
struct stat statbuf; | ||
if (stat(xbePath, &statbuf) < 0) | ||
return; | ||
#endif | ||
|
||
if (LaunchDataPage == NULL) | ||
LaunchDataPage = MmAllocateContiguousMemory(0x1000); | ||
|
||
if (LaunchDataPage == NULL) | ||
return; | ||
|
||
MmPersistContiguousMemory(LaunchDataPage, 0x1000, TRUE); | ||
|
||
memset((void*)LaunchDataPage, 0, 0x1000); | ||
|
||
LaunchDataPage->Header.dwLaunchDataType = 0xFFFFFFFF; | ||
LaunchDataPage->Header.dwTitleId = 0; | ||
XConvertDOSFilenameToXBOX(xbePath, LaunchDataPage->Header.szLaunchPath); | ||
|
||
// one last thing... xbePath now looks like: | ||
// \Device\Harddisk0\Partition2\blah\doom.xbe | ||
// but it has to look like: | ||
// \Device\Harddisk0\Partition2\blah;doom.xbe | ||
char *lastSlash = strrchr(LaunchDataPage->Header.szLaunchPath, '\\'); | ||
if (lastSlash != NULL) | ||
{ | ||
*lastSlash = ';'; | ||
HalReturnToFirmware(HalQuickRebootRoutine); | ||
} | ||
|
||
// if we couldn't find a trailing slash, the conversion to | ||
// the xbox path mustn't have worked, so we will return | ||
if (LaunchDataPage == NULL) { | ||
LaunchDataPage = MmAllocateContiguousMemory(LaunchDataPageSize); | ||
if (LaunchDataPage == NULL) { | ||
return; | ||
} | ||
} | ||
|
||
// For ease of debugging. | ||
PLAUNCH_DATA_PAGE launchDataPage = LaunchDataPage; | ||
|
||
MmPersistContiguousMemory(launchDataPage, LaunchDataPageSize, TRUE); | ||
memset((void*)launchDataPage, 0, LaunchDataPageSize); | ||
|
||
launchDataPage->Header.dwLaunchDataType = LDT_TITLE; | ||
launchDataPage->Header.dwTitleId = CURRENT_XBE_HEADER->CertificateHeader->TitleID; | ||
launchDataPage->Header.dwFlags = 0x0000; | ||
|
||
if (!xbePath) { | ||
launchDataPage->Header.dwLaunchDataType = LDT_LAUNCH_DASHBOARD; | ||
} else { | ||
XConvertDOSFilenameToXBOX(xbePath, launchDataPage->Header.szLaunchPath); | ||
|
||
// one last thing... xbePath now looks like: | ||
// \Device\Harddisk0\Partition2\blah\doom.xbe | ||
// but it has to look like: | ||
// \Device\Harddisk0\Partition2\blah;doom.xbe | ||
char *lastSlash = strrchr(launchDataPage->Header.szLaunchPath, '\\'); | ||
if (!lastSlash) { | ||
// if we couldn't find a trailing slash, the conversion to | ||
// the xbox path mustn't have worked, so we will return | ||
return; | ||
} | ||
|
||
*lastSlash = ';'; | ||
} | ||
|
||
if (launchData) { | ||
memcpy(launchDataPage->LaunchData, launchData, sizeof(launchDataPage->LaunchData)); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is intentional that LaunchDataPage's LaunchData will be zero bytes (preserving the existing behavior). |
||
|
||
HalReturnToFirmware(HalQuickRebootRoutine); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: What should happen to the
LaunchDataPage
here? Should the allocation be undone?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect it should, but I was conservative about preserving the existing behavior which does leave the LDP allocated and persisted.