-
Notifications
You must be signed in to change notification settings - Fork 11
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 work-in-progress xbe-loader, for bootstrapping background tasks #63
Conversation
|
||
static uint32_t LookupKernelExport(unsigned int ordinal) { | ||
uint32_t image_base = 0x80010000; | ||
uint32_t tmp = *(uint32_t*)(image_base + 0x3C); |
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.
Since you've defined _NO_RETURN and others, it's probably best to use defines for these magic constants too (0x3C, 0x78, 0x14, 0x1C, ...)
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.
Code was stolen from xboxpy, which, I believe, was stolen from elsewhere (probably a project by @Ernegien).
I don't even remember what each of those magics were, and I don't care enough to fix it myself. But I definitely agree.
xbe-loader/main.c
Outdated
|
||
// Relocate our binary | ||
if (relocation_section == NULL) { | ||
debugPrint("Unable to find relocation section; will break if image base %d is not %d xbe base\n", image_base, xbe); |
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.
s/%d/%x
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.
Yes, I had this, but nxdk does not support "%X". I'm not sure if it supports "%x" and did not try it. I just figured "%d" was probably the most reliable printf
for now (I have to FTP each change to Xbox first, so I wasn't really motivated to try many options).
xbe-loader/main.c
Outdated
|
||
|
||
static uint32_t LookupKernelExport(unsigned int ordinal) { | ||
uint32_t image_base = 0x80010000; |
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.
const static
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.
Will do and probably make it a global, because we might want to resolve other PE module exports later. Issue exists because this is just xboxpy (Python) code with uint32_t
added infront of each line.
|
||
unsigned int index = ordinal - 1; | ||
|
||
return image_base + *(uint32_t*)(ExportBase + index * 4); |
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.
Perhaps calculate ExportBase
once in caller, so that LookupKernelExport
can accept it as an argument?
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 don't think that's a good idea. If anything, I'd rather see proper structs for the exe.
For now, there are bigger design issues, rather than these small implementation details.
The kernel lookup also isn't critical for performance (and a couple of indirect lookups aren't that bad).
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.
true
e87e2a4
to
ddd4321
Compare
Leaking line_buffer |
switch (IrpSp->Parameters.DeviceIoControl.IoControlCode) { | ||
//FIXME: Handle these | ||
default: | ||
assert(false) |
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.
Missing ;
?
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.
yup. I assume the code still works because I define asserts away. Will fix in the future
Note to self: Deleted branch locally. Moved to separate personal projects (not XboxDev; git history not preserved). |
I've moved this to https://github.com/JayFoxRox/xbe-loader now. I did not check the state of the code before pushing to the new location. I'll also keep a |
Requires JayFoxRox/nxdk#7
This has basically gotten no testing. I only started working on it 3 hours ago.
I expect there to be plenty of bugs - but I'm okay with that.
This tool is a temporary proof-of-concept and bootstrapping (for projects like nv2a-trace, but also an open-source dashboard and other tools).
I've only tried running XboxDev/nxdk#46 without the XVideo init during startup.
I've also made the LED hook specifically for that binary.
It depends on the ".reloc" section being present, so it does not work for retail games (yet).It does support self-relocation now, but XDK applications just return immediately for unknown reasons.