From 1d474579c86e56d006f327683782dba92b9cea0f Mon Sep 17 00:00:00 2001 From: midipix Date: Thu, 8 Mar 2018 07:11:05 +0000 Subject: __ntapi_sem_set(): unmap the ad-hoc section as needed. --- src/sem/ntapi_sem_set.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'src/sem') diff --git a/src/sem/ntapi_sem_set.c b/src/sem/ntapi_sem_set.c index 02a23e6..b8b3ad1 100644 --- a/src/sem/ntapi_sem_set.c +++ b/src/sem/ntapi_sem_set.c @@ -15,12 +15,18 @@ #include "ntapi_impl.h" static int32_t __sem_set_return( + void * mapaddr, intptr_t * hlock, int32_t status) { if (hlock) at_store(hlock,0); + if (mapaddr) + __ntapi->zw_unmap_view_of_section( + NT_CURRENT_PROCESS_HANDLE, + mapaddr); + return status; } @@ -32,6 +38,7 @@ int32_t __stdcall __ntapi_sem_set( __in int32_t sem_ipc_cmd) { int32_t status; + void * mapaddr; void * hsection; void * secaddr; size_t secsize; @@ -66,21 +73,29 @@ int32_t __stdcall __ntapi_sem_set( hsection = sem->section; secaddr = sem->section_addr; secsize = sem->section_size; + mapaddr = 0; } else if ((status = __ntapi->ipc_init_section_by_port( sem->hport,&hsection, &secaddr,&secsize))) return status; + else + mapaddr = secaddr; + /* data size */ if (secsize < sem_info_length) - return NT_STATUS_DATA_OVERRUN; + return __sem_set_return( + mapaddr,0, + NT_STATUS_DATA_OVERRUN); /* lock */ hlock = &(__ntapi_internals()->hlock); if (at_locked_cas(hlock,0,1)) - return NT_STATUS_RESOURCE_NOT_OWNED; + return __sem_set_return( + mapaddr,0, + NT_STATUS_RESOURCE_NOT_OWNED); /* data copy */ __ntapi->tt_generic_memcpy( @@ -106,13 +121,13 @@ int32_t __stdcall __ntapi_sem_set( msg.data.seminfo.section_size = sem_info_length; if ((status = __ntapi->zw_request_wait_reply_port(sem->hport,&msg,&msg))) - return __sem_set_return(hlock,status); + return __sem_set_return(mapaddr,hlock,status); else if (msg.data.ttyinfo.status) - return __sem_set_return(hlock,msg.data.ttyinfo.status); + return __sem_set_return(mapaddr,hlock,msg.data.ttyinfo.status); /* reply */ iosb->status = NT_STATUS_SUCCESS; iosb->info = 0; - return __sem_set_return(hlock,NT_STATUS_SUCCESS); + return __sem_set_return(mapaddr,hlock,NT_STATUS_SUCCESS); } -- cgit v1.2.3