|
|
dd89bb |
/********************************************************/
|
|
|
dd89bb |
|
|
|
dde53a |
|
|
|
dd89bb |
|
|
|
dd89bb |
/********************************************************/
|
|
|
dd89bb |
|
|
|
dd89bb |
#include <ntapi/ntapi.h>
|
|
|
dd89bb |
#include <ntapi/nt_file.h>
|
|
|
dd89bb |
#include "ntapi_impl.h"
|
|
|
dd89bb |
|
|
|
dd89bb |
int32_t __stdcall __ntapi_tt_open_physical_parent_directory(
|
|
|
dd89bb |
__out void ** hparent,
|
|
|
dd89bb |
__in void * hdir,
|
|
|
dd89bb |
__out uintptr_t * buffer,
|
|
|
dd89bb |
__in uint32_t buffer_size,
|
|
|
a75a96 |
__in uint32_t oattr,
|
|
|
dd89bb |
__in uint32_t desired_access,
|
|
|
a75a96 |
__in uint32_t share_access,
|
|
|
4d8da7 |
__in uint32_t open_options,
|
|
|
4d8da7 |
__out int * reserved)
|
|
|
dd89bb |
{
|
|
|
8bdef0 |
int32_t status;
|
|
|
8bdef0 |
nt_oa oa;
|
|
|
8bdef0 |
nt_iosb iosb;
|
|
|
8bdef0 |
wchar16_t * wch;
|
|
|
8bdef0 |
wchar16_t * root;
|
|
|
8bdef0 |
nt_unicode_string * path;
|
|
|
8bdef0 |
uint32_t len;
|
|
|
8bdef0 |
int mup;
|
|
|
dd89bb |
|
|
|
4d8da7 |
(void)reserved;
|
|
|
4d8da7 |
|
|
|
dd89bb |
path = (nt_unicode_string *)buffer;
|
|
|
dd89bb |
|
|
|
dd89bb |
if ((status = __ntapi->zw_query_object(
|
|
|
dd89bb |
hdir,
|
|
|
dd89bb |
NT_OBJECT_NAME_INFORMATION,
|
|
|
dd89bb |
path,
|
|
|
dd89bb |
buffer_size,
|
|
|
dd89bb |
&len)))
|
|
|
dd89bb |
return status;
|
|
|
8076b5 |
|
|
|
8076b5 |
|
|
|
8076b5 |
if (len == sizeof(nt_unicode_string))
|
|
|
dd89bb |
return NT_STATUS_BAD_FILE_TYPE;
|
|
|
dd89bb |
|
|
|
8076b5 |
|
|
|
8076b5 |
root = path->buffer;
|
|
|
8076b5 |
wch = path->buffer + (path->strlen / sizeof(uint16_t));
|
|
|
8076b5 |
|
|
|
dd89bb |
|
|
|
895156 |
if ((wch < &root[8])
|
|
|
895156 |
|| (root[0] != '\\')
|
|
|
8076b5 |
|| (root[1] != 'D') || (root[2] != 'e')
|
|
|
8076b5 |
|| (root[3] != 'v') || (root[4] != 'i')
|
|
|
8076b5 |
|| (root[5] != 'c') || (root[6] != 'e')
|
|
|
8076b5 |
|| (root[7] != '\\'))
|
|
|
8076b5 |
return NT_STATUS_INTERNAL_ERROR;
|
|
|
4fdb5b |
|
|
|
895156 |
mup = (wch > &root[11])
|
|
|
895156 |
&& (root[8]=='M')
|
|
|
895156 |
&& (root[9]=='u')
|
|
|
895156 |
&& (root[10]=='p')
|
|
|
895156 |
&& (root[11]=='\\');
|
|
|
895156 |
|
|
|
895156 |
root = mup ? &root[12] : &root[8];
|
|
|
895156 |
|
|
|
895156 |
for (; (root
|
|
|
8076b5 |
root++;
|
|
|
8076b5 |
|
|
|
895156 |
if (root == wch)
|
|
|
895156 |
return NT_STATUS_INTERNAL_ERROR;
|
|
|
895156 |
|
|
|
895156 |
if (mup)
|
|
|
895156 |
for (root++; (root
|
|
|
895156 |
root++;
|
|
|
895156 |
|
|
|
895156 |
if (root == wch)
|
|
|
895156 |
return NT_STATUS_INTERNAL_ERROR;
|
|
|
895156 |
|
|
|
895156 |
if (&root[1] == wch)
|
|
|
dd89bb |
return NT_STATUS_MORE_PROCESSING_REQUIRED;
|
|
|
dd89bb |
|
|
|
895156 |
if (wch[-1] == '\\')
|
|
|
895156 |
wch
|
|
|
895156 |
|
|
|
8076b5 |
|
|
|
895156 |
for (root++; (wch>=root) && (wch[-1]!='\\'); )
|
|
|
8076b5 |
wch
|
|
|
8076b5 |
|
|
|
895156 |
path->strlen = (uint16_t)(wch - path->buffer) * sizeof(uint16_t);
|
|
|
dd89bb |
path->maxlen = 0;
|
|
|
dd89bb |
|
|
|
dd89bb |
|
|
|
dd89bb |
oa.len = sizeof(nt_oa);
|
|
|
dd89bb |
oa.root_dir = 0;
|
|
|
dd89bb |
oa.obj_name = path;
|
|
|
a75a96 |
oa.obj_attr = oattr,
|
|
|
dd89bb |
oa.sec_desc = 0;
|
|
|
dd89bb |
oa.sec_qos = 0;
|
|
|
dd89bb |
|
|
|
dd89bb |
|
|
|
dd89bb |
desired_access = desired_access
|
|
|
dd89bb |
? desired_access
|
|
|
dd89bb |
: NT_SEC_SYNCHRONIZE | NT_FILE_READ_ATTRIBUTES | NT_FILE_READ_ACCESS;
|
|
|
dd89bb |
|
|
|
dd89bb |
|
|
|
dd89bb |
return __ntapi->zw_open_file(
|
|
|
dd89bb |
hparent,
|
|
|
dd89bb |
desired_access,
|
|
|
a75a96 |
&oa,&iosb,
|
|
|
a75a96 |
share_access,
|
|
|
dd89bb |
open_options | NT_FILE_DIRECTORY_FILE);
|
|
|
dd89bb |
}
|