diff options
author | midipix <writeonce@midipix.org> | 2018-03-08 11:04:47 +0000 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2018-03-14 19:09:59 -0400 |
commit | 12d3bfc13a7b31e68b54619b526817d92b033a27 (patch) | |
tree | 2880734f1cf7aaacbc3bfbf96f458cbb743b6c66 | |
parent | f2dbb3b12560709a450d8422bcecda63b5b96e31 (diff) | |
download | ntapi-12d3bfc13a7b31e68b54619b526817d92b033a27.tar.bz2 ntapi-12d3bfc13a7b31e68b54619b526817d92b033a27.tar.xz |
__ntapi_msq_send(): unmap the ad-hoc section as needed.
-rw-r--r-- | src/msq/ntapi_msq_send.c | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/src/msq/ntapi_msq_send.c b/src/msq/ntapi_msq_send.c index 65443ea..53d9f0c 100644 --- a/src/msq/ntapi_msq_send.c +++ b/src/msq/ntapi_msq_send.c @@ -15,10 +15,18 @@ #include "ntapi_impl.h" static int32_t __msq_send_return( + void * mapaddr, intptr_t * hlock, int32_t status) { - at_store(hlock,0); + if (hlock) + at_store(hlock,0); + + if (mapaddr) + __ntapi->zw_unmap_view_of_section( + NT_CURRENT_PROCESS_HANDLE, + mapaddr); + return status; } @@ -35,6 +43,7 @@ int32_t __stdcall __ntapi_msq_send( __out nt_io_status_block * iosb) { int32_t status; + void * mapaddr; void * hsection; void * secaddr; size_t secsize; @@ -50,20 +59,28 @@ int32_t __stdcall __ntapi_msq_send( hsection = msq->section; secaddr = msq->section_addr; secsize = msq->section_size; + mapaddr = 0; } else if ((status = __ntapi->ipc_init_section_by_port( msq->hport,&hsection, &secaddr,&secsize))) return status; + else + mapaddr = secaddr; + if (len > secsize) - return NT_STATUS_INFO_LENGTH_MISMATCH; + return __msq_send_return( + mapaddr,0, + NT_STATUS_INFO_LENGTH_MISMATCH); /* lock */ hlock = &(__ntapi_internals()->hlock); if (at_locked_cas(hlock,0,1)) - return NT_STATUS_RESOURCE_NOT_OWNED; + return __msq_send_return( + mapaddr,0, + NT_STATUS_RESOURCE_NOT_OWNED); /* msq data to section */ __ntapi->tt_generic_memcpy( @@ -92,12 +109,12 @@ int32_t __stdcall __ntapi_msq_send( msg.data.msqinfo.riosb = iosb; if ((status = __ntapi->zw_request_wait_reply_port(msq->hport,&msg,&msg))) - return __msq_send_return(hlock,status); + return __msq_send_return(mapaddr,hlock,status); else if (msg.data.ttyinfo.status) - return __msq_send_return(hlock,msg.data.ttyinfo.status); + return __msq_send_return(mapaddr,hlock,msg.data.ttyinfo.status); iosb->status = msg.data.msqinfo.ntiosb.status; iosb->info = msg.data.msqinfo.ntiosb.info; - return __msq_send_return(hlock,NT_STATUS_SUCCESS); + return __msq_send_return(mapaddr,hlock,NT_STATUS_SUCCESS); } |