Turns out NtQueryDirectoryFile only returns a single entry at a time.

This commit is contained in:
gibbed
2014-01-19 06:56:56 -08:00
parent c7276454d7
commit 870a59f225
5 changed files with 126 additions and 138 deletions

View File

@@ -84,45 +84,29 @@ X_STATUS DiscImageEntry::QueryDirectory(
}
}
auto current_buf = (uint8_t*)out_info;
auto end = current_buf + length;
auto end = (uint8_t*)out_info + length;
XDirectoryInfo* current = (XDirectoryInfo*)current_buf;
if (((uint8_t*)&current->file_name[0]) + xestrlena((*gdfx_entry_iterator_)->name.c_str()) > end) {
auto entry = *gdfx_entry_iterator_;
auto entry_name = entry->name.c_str();
size_t entry_name_length = xestrlena(entry_name);
if (((uint8_t*)&out_info->file_name[0]) + entry_name_length > end) {
gdfx_entry_iterator_ = gdfx_entry_->children.end();
return X_STATUS_UNSUCCESSFUL;
}
do {
auto entry = *gdfx_entry_iterator_;
out_info->next_entry_offset = 0;
out_info->file_index = 0xCDCDCDCD;
out_info->creation_time = 0;
out_info->last_access_time = 0;
out_info->last_write_time = 0;
out_info->change_time = 0;
out_info->end_of_file = entry->size;
out_info->allocation_size = 2048;
out_info->attributes = (X_FILE_ATTRIBUTES)entry->attributes;
out_info->file_name_length = (uint32_t)entry_name_length;
memcpy(out_info->file_name, entry_name, entry_name_length);
auto file_name = entry->name.c_str();
size_t file_name_length = xestrlena(file_name);
if (((uint8_t*)&((XDirectoryInfo*)current_buf)->file_name[0]) + file_name_length > end) {
break;
}
current = (XDirectoryInfo*)current_buf;
current->file_index = 0xCDCDCDCD;
current->creation_time = 0;
current->last_access_time = 0;
current->last_write_time = 0;
current->change_time = 0;
current->end_of_file = entry->size;
current->allocation_size = 2048;
current->attributes = (X_FILE_ATTRIBUTES)entry->attributes;
current->file_name_length = (uint32_t)file_name_length;
memcpy(current->file_name, file_name, file_name_length);
auto next_buf = (((uint8_t*)&current->file_name[0]) + file_name_length);
next_buf += 8 - ((uint8_t)next_buf % 8);
current->next_entry_offset = (uint32_t)(next_buf - current_buf);
current_buf = next_buf;
} while (current_buf < end &&
(++gdfx_entry_iterator_) != gdfx_entry_->children.end());
current->next_entry_offset = 0;
return X_STATUS_SUCCESS;
}