summaryrefslogtreecommitdiffhomepage
path: root/src/fs/ntapi_tt_istat.c
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-12-25 02:21:53 -0500
committermidipix <writeonce@midipix.org>2016-12-25 02:21:53 -0500
commitd8b4079264a3139f35d784b873d3490b40ffbeff (patch)
tree9d9f7e51f06167c950ca41e1c4626a37fd9b9061 /src/fs/ntapi_tt_istat.c
parent1d3e991a03ff78741f801f88a7bd4ec541bdc99e (diff)
downloadntapi-d8b4079264a3139f35d784b873d3490b40ffbeff.tar.bz2
ntapi-d8b4079264a3139f35d784b873d3490b40ffbeff.tar.xz
{i}stat{fs} interfaces: remove fluff, require valid handle, simplify logic.
Diffstat (limited to 'src/fs/ntapi_tt_istat.c')
-rw-r--r--src/fs/ntapi_tt_istat.c72
1 files changed, 22 insertions, 50 deletions
diff --git a/src/fs/ntapi_tt_istat.c b/src/fs/ntapi_tt_istat.c
index f54f8ea..83c7f9a 100644
--- a/src/fs/ntapi_tt_istat.c
+++ b/src/fs/ntapi_tt_istat.c
@@ -13,57 +13,31 @@
int32_t __stdcall __ntapi_tt_istat(
__in void * hfile,
- __in void * hroot __optional,
- __in nt_unicode_string * path,
__out nt_istat * istat,
+ __in uint32_t infolen,
__out uintptr_t * buffer,
__in uint32_t buffer_size,
- __in uint32_t open_options,
__in uint32_t flags)
{
int32_t status;
- nt_oa oa;
nt_iosb iosb;
nt_unicode_string * sdev;
wchar16_t * wch;
wchar16_t * wch_mark;
uint32_t hash;
-
- (void)flags;
+ uint32_t written;
/* validaton */
- if (!hfile && !path)
- return NT_STATUS_INVALID_PARAMETER;
-
- /* hfile */
- if (hfile) {
- istat->flags = 0;
- } else {
- /* oa */
- oa.len = sizeof(nt_oa);
- oa.root_dir = hroot;
- oa.obj_name = path;
- oa.obj_attr = 0;
- oa.sec_desc = 0;
- oa.sec_qos = 0;
-
- /* open file/folder */
- 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;
+ if (infolen < sizeof(*istat))
+ return NT_STATUS_INFO_LENGTH_MISMATCH;
- istat->flags = NT_STAT_NEW_HANDLE;
- }
+ /* init */
+ __ntapi->tt_aligned_block_memset(
+ istat,0,sizeof(*istat));
- istat->hfile = hfile;
+ istat->hfile = hfile;
+ istat->dev_name_maxlen = infolen - sizeof(*istat);
/* file index number */
if (!(flags & NT_ISTAT_DEV_NAME_ONLY))
@@ -91,14 +65,14 @@ int32_t __stdcall __ntapi_tt_istat(
NT_OBJECT_NAME_INFORMATION,
buffer,
buffer_size,
- (uint32_t *)&iosb.info)))
+ &written)))
return status;
sdev = (nt_unicode_string *)buffer;
wch = sdev->buffer;
if (sdev->strlen < __DEVICE_PATH_PREFIX_LEN)
- return NT_STATUS_INVALID_HANDLE;
+ return NT_STATUS_NOT_SUPPORTED;
if ((wch[0] != '\\')
|| (wch[1] != 'D')
@@ -108,19 +82,21 @@ int32_t __stdcall __ntapi_tt_istat(
|| (wch[5] != 'c')
|| (wch[6] != 'e')
|| (wch[7] != '\\'))
- return NT_STATUS_INVALID_HANDLE;
+ return NT_STATUS_NOT_SUPPORTED;
if ((sdev->strlen >= __DEVICE_MUP_PREFIX_LEN)
&& (wch[8]=='M')
&& (wch[9]=='u')
&& (wch[10]=='p')
&& (wch[11]=='\\')) {
- wch_mark = &wch[12];
- hash = __DEVICE_MUP_PREFIX_HASH;
+ hash = __DEVICE_MUP_PREFIX_HASH;
istat->flags |= NT_STATFS_MUP_DEVICE;
- for (wch=wch_mark; *wch!='\\'; wch++)
- (void)0;
+ wch_mark = &wch[12];
+ wch = wch_mark;
+
+ for (; *wch!='\\'; )
+ wch++;
wch++;
} else {
wch_mark = &wch[8];
@@ -133,10 +109,10 @@ int32_t __stdcall __ntapi_tt_istat(
istat->obj_name_strlen = sdev->strlen;
istat->obj_name_maxlen = istat->dev_name_maxlen;
- istat->dev_name_strlen = (uint16_t)((wch - sdev->buffer) * sizeof(uint16_t));
+ istat->dev_name_strlen = sizeof(uint16_t) * (uint16_t)(wch - sdev->buffer);
istat->dev_name_hash = __ntapi->tt_buffer_crc32(
hash,wch_mark,
- sizeof(wchar16_t)*(wch-wch_mark));
+ sizeof(wchar16_t) * (wch - wch_mark));
if (!(flags & NT_ISTAT_DEV_NAME_COPY))
return NT_STATUS_SUCCESS;
@@ -164,12 +140,8 @@ int32_t __stdcall __ntapi_tt_validate_fs_handle(
status = __ntapi->tt_istat(
hfile,
- (void *)0,
- (nt_unicode_string *)0,
- &istat,
- buffer,
- buffer_size,
- 0,
+ &istat,sizeof(istat),
+ buffer,buffer_size,
NT_ISTAT_DEFAULT);
if (status) return status;