diff options
author | midipix <writeonce@midipix.org> | 2016-06-20 19:30:33 -0400 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2016-06-20 19:30:33 -0400 |
commit | 7a0fb6a94af10109933460865e33e220682b49a1 (patch) | |
tree | f15f9ed1f1e823ba83ec4089eb0d024b0366dd50 | |
parent | 7845d0d8d1aa9d2a3b981cc05d523451ad0628f8 (diff) | |
download | ntapi-7a0fb6a94af10109933460865e33e220682b49a1.tar.bz2 ntapi-7a0fb6a94af10109933460865e33e220682b49a1.tar.xz |
__ntapi_tt_create_pipe_v2(): refactor, always close hdevpipes.
-rw-r--r-- | src/ipc/ntapi_tt_create_pipe_v2.c | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/src/ipc/ntapi_tt_create_pipe_v2.c b/src/ipc/ntapi_tt_create_pipe_v2.c index 7252bf4..23cc61d 100644 --- a/src/ipc/ntapi_tt_create_pipe_v2.c +++ b/src/ipc/ntapi_tt_create_pipe_v2.c @@ -26,7 +26,7 @@ int32_t __stdcall __ntapi_ipc_create_pipe_v2( nt_io_status_block iosb; nt_sqos sqos; nt_unicode_string nt_name; - nt_large_integer timeout; + nt_timeout timeout; const wchar16_t pipe_dir[] = { '\\','D','e','v','i','c','e', @@ -54,15 +54,13 @@ int32_t __stdcall __ntapi_ipc_create_pipe_v2( oa.sec_desc = (nt_security_descriptor *)0; oa.sec_qos = &sqos; - status = __ntapi->zw_open_file( - &hdevpipes, - NT_GENERIC_READ | NT_SEC_SYNCHRONIZE, - &oa, - &iosb, - NT_FILE_SHARE_READ | NT_FILE_SHARE_WRITE, - NT_FILE_DIRECTORY_FILE); - - if (status != NT_STATUS_SUCCESS) + if ((status = __ntapi->zw_open_file( + &hdevpipes, + NT_GENERIC_READ | NT_SEC_SYNCHRONIZE, + &oa, + &iosb, + NT_FILE_SHARE_READ | NT_FILE_SHARE_WRITE, + NT_FILE_DIRECTORY_FILE))) return status; timeout.ihigh = 0xffffffff; @@ -70,8 +68,8 @@ int32_t __stdcall __ntapi_ipc_create_pipe_v2( oa.root_dir = hdevpipes; - nt_name.strlen=0; - nt_name.buffer = (uint16_t *)0; + nt_name.strlen = 0; + nt_name.buffer = 0; status = __ntapi->zw_create_named_pipe_file( &hread, @@ -89,10 +87,11 @@ int32_t __stdcall __ntapi_ipc_create_pipe_v2( 0x2000, &timeout); - if (status != NT_STATUS_SUCCESS) { - __ntapi->zw_close(hdevpipes); + __ntapi->zw_close( + hdevpipes); + + if (status) return status; - } /* the pipe is now our root directory */ oa.root_dir = hread; @@ -105,8 +104,7 @@ int32_t __stdcall __ntapi_ipc_create_pipe_v2( NT_FILE_SHARE_READ | NT_FILE_SHARE_WRITE, NT_FILE_WRITE_THROUGH | NT_FILE_ASYNCHRONOUS_IO | NT_FILE_NON_DIRECTORY_FILE); - if (status != NT_STATUS_SUCCESS) { - __ntapi->zw_close(hdevpipes); + if (status) { __ntapi->zw_close(hread); return status; } |