diff options
author | midipix <writeonce@midipix.org> | 2018-03-08 11:03:49 +0000 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2018-03-14 19:09:59 -0400 |
commit | f2dbb3b12560709a450d8422bcecda63b5b96e31 (patch) | |
tree | 7bbed9a200d0a9c4f65b327e2e7c62a49372e52e | |
parent | 31d7ced24c5a8454dc6e5ad74ab6a4d0e3fc7549 (diff) | |
download | ntapi-f2dbb3b12560709a450d8422bcecda63b5b96e31.tar.bz2 ntapi-f2dbb3b12560709a450d8422bcecda63b5b96e31.tar.xz |
__ntapi_msq_recv(): unmap the ad-hoc section as needed.
-rw-r--r-- | src/msq/ntapi_msq_recv.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/src/msq/ntapi_msq_recv.c b/src/msq/ntapi_msq_recv.c index 4da7cbe..8c4a4b0 100644 --- a/src/msq/ntapi_msq_recv.c +++ b/src/msq/ntapi_msq_recv.c @@ -15,10 +15,18 @@ #include "ntapi_impl.h" static int32_t __msq_recv_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_recv( __out nt_io_status_block * iosb) { int32_t status; + void * mapaddr; void * hsection; void * secaddr; size_t secsize; @@ -53,12 +62,16 @@ int32_t __stdcall __ntapi_msq_recv( 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; + /* len */ if (len > secsize) len = secsize; @@ -67,7 +80,9 @@ int32_t __stdcall __ntapi_msq_recv( hlock = &(__ntapi_internals()->hlock); if (at_locked_cas(hlock,0,1)) - return NT_STATUS_RESOURCE_NOT_OWNED; + return __msq_recv_return( + mapaddr,0, + NT_STATUS_RESOURCE_NOT_OWNED); /* msg */ __ntapi->tt_aligned_block_memset( @@ -92,9 +107,9 @@ int32_t __stdcall __ntapi_msq_recv( msg.data.msqinfo.riosb = iosb; if ((status = __ntapi->zw_request_wait_reply_port(msq->hport,&msg,&msg))) - return __msq_recv_return(hlock,status); + return __msq_recv_return(mapaddr,hlock,status); else if (msg.data.ttyinfo.status) - return __msq_recv_return(hlock,msg.data.ttyinfo.status); + return __msq_recv_return(mapaddr,hlock,msg.data.ttyinfo.status); /* msq data section to buffer */ __ntapi->tt_generic_memcpy( @@ -105,5 +120,5 @@ int32_t __stdcall __ntapi_msq_recv( iosb->status = msg.data.msqinfo.ntiosb.status; iosb->info = msg.data.msqinfo.ntiosb.info; - return __msq_recv_return(hlock,NT_STATUS_SUCCESS); + return __msq_recv_return(mapaddr,hlock,NT_STATUS_SUCCESS); } |