Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Implement
direct.h
functions #636base: master
Are you sure you want to change the base?
Implement
direct.h
functions #636Changes from 2 commits
680b892
18c6acf
0b37066
e2f40bf
72ae765
aa89850
8893c02
6078f61
a5e09e0
cd71cb3
21fe551
57cded3
5ef78d2
014d662
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
This is reachable when disabling assertions.
In that case,
errno
must be set, so I suggest setting it toEACCES
?(Other functions, too - but you need to look up appropriate error codes)
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.
Ah crap, forgot you could do that, I'll sort it out
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 believe we can hard-code this for now, so at least apps which use this to find files will work (sometimes some SDK or API will require absolute paths, and then the application might query the base path through this).
I can see how that would be a lot of additional implementation effort, so it can be done in a follow-up PR.
If this follows the same convention, we might be able to use:
nxdk/lib/nxdk/path.c
Lines 9 to 14 in 500354e
Otherwise, we might be able to hardcode it to
D:\\
which is either (I don't remember) a kernel requirement or at least a dashboard- or self-imposed XBE controlled symlink?Eitherway, we'd have to follow conventions of the MS implementation (regarding forward vs backward slash, device names vs driver letters etc.).
Similar reasoning for
_getdrive
, although I speculate that this is required much less.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.
D drive letter mount is handled by XDK on boot when D drive letter isn't set by the kernel. Otherwise, it is handled by the kernel on reboot.
Though, I highly recommended to check
LaunchDataPage->Header.szLaunchPath
first for semicolon character which is mount as working directory by the kernel itself. Then fallback to XeImageFileName with null terminate append at end of string.fyi: I provided this type of information in XboxDev discord server based on what I had researched years ago.
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'd prefer
XeImageFileName
(which the kernel uses to talk to the app / after launching) overLaunchDataPage
(which is used by the app to talk to the kernel / before launching)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, LaunchDataPage is used to talk to the kernel but that's only half correct. It is also used by the app as well hence the LaunchData member variable from LAUNCH_DATA_PAGE structure is used to tell the app, either from same xbe or another xbe, what to do next after reboot occur. The kernel doesn't modify LaunchDataPage created by the app. The kernel read from
LaunchDataPage->Header
structure to do what the app want the kernel to do on reboot.Here's a log of how it works on first boot and reboot:
As you can see XeImageFileName doesn't include semicolon which break working directory mount from D: symlink pointing to a parent directory than the same directory according to reboot process.
This is the same/similar concept on Windows' command prompt or powershell usage. When you change directory from the terminal itself, i.e.
C:\logs>
. Then executeD:\build\UnitTest.exe
which will create log file intoC:\logs
instead ofD:\build
directory.In summary, this is how demo discs and even xbox live works when they focus on D:\ symlink as a working directory. Otherwise attempting to access the contents wouldn't work engineered by original xbox team. I hope this is more clarified for you and everyone else reading this.
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.
The macOS man page says:
Regarding return values:
Similar wording is in POSIX https://pubs.opengroup.org/onlinepubs/009696699/functions/getwd.html
which should be trivial to implement.
I can't find anything about it in the MSDN docs though. Is it contained in the Windows SDK / MS implementations?
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.
Ah, yea, Wikipedia, and digitalmars state that getwd exists so I'm going on that
Should be trivial to implement though
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 see it in https://github.com/microsoft/win32metadata/blob/main/generation/WinSDK/RecompiledIdlHeaders/ucrt/direct.h either.
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.
Seems like getwd is a legacy function which was discontinued. The question is when did it get removed? As for digitalmars state it exists, I don't see getwd mentioned in the referenced link from the OP post. Heck, even did a search for whole site which also has no mention too.