mirror of
https://git.triforceproject.com/triforce/source
synced 2026-11-20 08:39:58 -04:00
Triforce v0.3.3
This commit is contained in:
@@ -592,8 +592,12 @@ HLE(_ZN2nn2fs13OpenDirectoryEPNS0_15DirectoryHandleEPKci) {
|
||||
G64(ARG(0)) = new_handle(dh);
|
||||
RET(0);
|
||||
}
|
||||
/* (hookshot) A directory's listing is read, counted and closed under one lock: a CloseDirectory on another guest thread freed
|
||||
the handle (and its find handle) while a ReadDirectory or GetDirectoryEntryCount still walked it */
|
||||
static SRWLOCK dir_lock = SRWLOCK_INIT;
|
||||
/* ReadDirectory(long* count, DirectoryEntry* entries, DirectoryHandle, long max) */
|
||||
HLE(_ZN2nn2fs13ReadDirectoryEPlPNS0_14DirectoryEntryENS0_15DirectoryHandleEl) {
|
||||
AcquireSRWLockExclusive(&dir_lock);
|
||||
Handle *dh = get_handle(c, ARG(2));
|
||||
int64_t n = 0, max = (int64_t)ARG(3);
|
||||
while (n < max && !dh->find_done) {
|
||||
@@ -620,11 +624,13 @@ HLE(_ZN2nn2fs13ReadDirectoryEPlPNS0_14DirectoryEntryENS0_15DirectoryHandleEl) {
|
||||
G64(e + 0x308) = x->size;
|
||||
n++;
|
||||
}
|
||||
ReleaseSRWLockExclusive(&dir_lock);
|
||||
G64(ARG(0)) = (uint64_t)n;
|
||||
RET(0);
|
||||
}
|
||||
/* (hookshot) GetDirectoryEntryCount(long* count, DirectoryHandle): every entry the open mode lists, read or not */
|
||||
HLE(_ZN2nn2fs22GetDirectoryEntryCountEPlNS0_15DirectoryHandleE) {
|
||||
AcquireSRWLockExclusive(&dir_lock);
|
||||
Handle *dh = get_handle(c, ARG(1));
|
||||
int64_t n = 0;
|
||||
WIN32_FIND_DATAA fd;
|
||||
@@ -640,13 +646,16 @@ HLE(_ZN2nn2fs22GetDirectoryEntryCountEPlNS0_15DirectoryHandleE) {
|
||||
}
|
||||
for (int i = 0; i < dh->nextras; i++)
|
||||
n += (dh->extras[i].is_dir && (dh->is_dir & 1)) || (!dh->extras[i].is_dir && (dh->is_dir & 2));
|
||||
ReleaseSRWLockExclusive(&dir_lock);
|
||||
G64(ARG(0)) = (uint64_t)n;
|
||||
RET(0);
|
||||
}
|
||||
HLE(_ZN2nn2fs14CloseDirectoryENS0_15DirectoryHandleE) {
|
||||
AcquireSRWLockExclusive(&dir_lock);
|
||||
Handle *dh = get_handle(c, ARG(0));
|
||||
if (dh->find != INVALID_HANDLE_VALUE) FindClose(dh->find);
|
||||
free_handle(ARG(0));
|
||||
ReleaseSRWLockExclusive(&dir_lock);
|
||||
free(dh->extras);
|
||||
free(dh);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user