diff --git a/src/internal/toksvc_open_impl.c b/src/internal/toksvc_open_impl.c index a5095cf..6cd6926 100644 --- a/src/internal/toksvc_open_impl.c +++ b/src/internal/toksvc_open_impl.c @@ -14,7 +14,10 @@ static int32_t toks_open( void ** hfile, void * hat, const char * arg, + nt_sd * sd, + uint32_t attr, uint32_t options, + uint32_t disposition, bool fprivate) { int32_t status; @@ -25,6 +28,8 @@ static int32_t toks_open( wchar16_t buffer[4096]; wchar16_t * wch; size_t nbytes; + uint32_t access; + nt_large_integer alloc_size; /* utf-8 --> utf-16 */ params.src = (const unsigned char *)arg; @@ -54,23 +59,34 @@ static int32_t toks_open( oa.root_dir = (buffer[0]=='\\') ? 0 : hat; oa.obj_name = &path; oa.obj_attr = fprivate ? 0 : NT_OBJ_INHERIT; - oa.sec_desc = 0; + oa.sec_desc = sd; oa.sec_qos = 0; - /* open */ - return ntapi->zw_open_file( + /* alloc_size (always zero) */ + alloc_size.quad = 0; + + /* access */ + access = NT_SEC_SYNCHRONIZE | NT_FILE_READ_ATTRIBUTES | NT_FILE_READ_DATA; + access |= (disposition == NT_FILE_OPEN_IF) ? NT_FILE_WRITE_DATA : 0; + + /* open/create */ + return ntapi->zw_create_file( hfile, - NT_SEC_SYNCHRONIZE | NT_FILE_READ_ATTRIBUTES | NT_FILE_READ_DATA, - &oa,&iosb, + access,&oa,&iosb,&alloc_size,attr, NT_FILE_SHARE_READ | NT_FILE_SHARE_WRITE | NT_FILE_SHARE_DELETE, - options | NT_FILE_SYNCHRONOUS_IO_ALERT); + disposition, + options | NT_FILE_SYNCHRONOUS_IO_ALERT, + 0,0); } static int32_t toks_open_volume( void ** hfile, void * hat, const char * arg, + nt_sd * sd, + uint32_t attr, uint32_t options, + uint32_t disposition, bool fprivate) { int32_t status; @@ -87,8 +103,9 @@ static int32_t toks_open_volume( } status = toks_open( - hfile,hat,arg, - options,fprivate); + hfile,hat,arg,sd,attr, + options,disposition, + fprivate); if (hvolume) ntapi->zw_close(hvolume); @@ -98,10 +115,20 @@ static int32_t toks_open_volume( int32_t toks_open_file(void ** hfile, void * hat, const char * arg, bool fprivate) { - return toks_open_volume(hfile,hat,arg,NT_FILE_NON_DIRECTORY_FILE,fprivate); + return toks_open_volume( + hfile,hat,arg,0, + NT_FILE_ATTRIBUTE_NORMAL, + NT_FILE_NON_DIRECTORY_FILE, + NT_FILE_OPEN, + fprivate); } int32_t toks_open_dir(void ** hfile, void * hat, const char * arg, bool fprivate) { - return toks_open_volume(hfile,hat,arg,NT_FILE_DIRECTORY_FILE,fprivate); + return toks_open_volume( + hfile,hat,arg,0, + NT_FILE_ATTRIBUTE_DIRECTORY, + NT_FILE_DIRECTORY_FILE, + NT_FILE_OPEN, + fprivate); }