diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/fs/ntapi_tt_istat.c | 92 |
1 files changed, 44 insertions, 48 deletions
diff --git a/src/fs/ntapi_tt_istat.c b/src/fs/ntapi_tt_istat.c index bd1b92d..bdfa09f 100644 --- a/src/fs/ntapi_tt_istat.c +++ b/src/fs/ntapi_tt_istat.c @@ -26,7 +26,6 @@ int32_t __stdcall __ntapi_tt_istat( nt_oa oa; nt_iosb iosb; nt_unicode_string * sdev; - uint32_t hash; wchar16_t * wch; wchar16_t * wch_mark; @@ -45,15 +44,15 @@ int32_t __stdcall __ntapi_tt_istat( oa.sec_qos = 0; /* open file/folder */ - status = __ntapi->zw_open_file( - &hfile, - NT_SEC_SYNCHRONIZE | NT_FILE_READ_ATTRIBUTES | NT_FILE_READ_ACCESS, - &oa, - &iosb, - NT_FILE_SHARE_READ | NT_FILE_SHARE_WRITE, - open_options | NT_FILE_SYNCHRONOUS_IO_ALERT); - - if (status != NT_STATUS_SUCCESS) + if ((status = __ntapi->zw_open_file( + &hfile, + NT_SEC_SYNCHRONIZE + | NT_FILE_READ_ATTRIBUTES + | NT_FILE_READ_ACCESS, + &oa, + &iosb, + NT_FILE_SHARE_READ | NT_FILE_SHARE_WRITE, + open_options | NT_FILE_SYNCHRONOUS_IO_ALERT))) return status; istat->flags_out = NT_STAT_NEW_HANDLE; @@ -63,60 +62,57 @@ int32_t __stdcall __ntapi_tt_istat( istat->flags_in = flags; /* file index number */ - status = __ntapi->zw_query_information_file( - hfile, - &iosb, - &istat->fii, - sizeof(istat->fii), - NT_FILE_INTERNAL_INFORMATION); - - if (status != NT_STATUS_SUCCESS) + if ((status = __ntapi->zw_query_information_file( + hfile, + &iosb, + &istat->fii, + sizeof(istat->fii), + NT_FILE_INTERNAL_INFORMATION))) return status; /* attributes & reparse tag information */ - status = __ntapi->zw_query_information_file( - hfile, - &iosb, - &istat->ftagi, - sizeof(istat->ftagi), - NT_FILE_ATTRIBUTE_TAG_INFORMATION); - - if (status != NT_STATUS_SUCCESS) + if ((status = __ntapi->zw_query_information_file( + hfile, + &iosb, + &istat->ftagi, + sizeof(istat->ftagi), + NT_FILE_ATTRIBUTE_TAG_INFORMATION))) return status; - /* TODO: consolidate with statfs */ /* system-unique device name */ - iosb.info = 0; - status = __ntapi->zw_query_object( - hfile, - NT_OBJECT_NAME_INFORMATION, - buffer, - buffer_size, - (uint32_t *)&iosb.info); - - if (status != NT_STATUS_SUCCESS) + if ((status = __ntapi->zw_query_object( + hfile, + NT_OBJECT_NAME_INFORMATION, + buffer, + buffer_size, + (uint32_t *)&iosb.info))) return status; sdev = (nt_unicode_string *)buffer; + wch = sdev->buffer; if (sdev->strlen < __DEVICE_PATH_PREFIX_LEN) return NT_STATUS_INVALID_HANDLE; - hash = __ntapi->tt_buffer_crc32( - 0, - sdev->buffer, - __DEVICE_PATH_PREFIX_LEN); - - if (hash != __DEVICE_PATH_PREFIX_HASH) + if ((wch[0] != '\\') + || (wch[1] != 'D') + || (wch[2] != 'e') + || (wch[3] != 'v') + || (wch[4] != 'i') + || (wch[5] != 'c') + || (wch[6] != 'e') + || (wch[7] != '\\')) return NT_STATUS_INVALID_HANDLE; - wch_mark = sdev->buffer + __DEVICE_PATH_PREFIX_LEN/sizeof(wchar16_t); - wch = wch_mark; - while (*wch != '\\') wch++; - istat->dev_name_strlen = (uint16_t)((wch - sdev->buffer) * sizeof(uint16_t)); + wch_mark = &wch[8]; + wch = wch_mark; - istat->dev_name_hash = __ntapi->tt_buffer_crc32( - hash, + while (*wch != '\\') + wch++; + + istat->dev_name_strlen = (uint16_t)((wch - sdev->buffer) * sizeof(uint16_t)); + istat->dev_name_hash = __ntapi->tt_buffer_crc32( + __DEVICE_PATH_PREFIX_HASH, wch_mark, (uintptr_t)wch - (uintptr_t)wch_mark); |