summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2018-03-08 07:11:05 +0000
committermidipix <writeonce@midipix.org>2018-03-14 19:09:58 -0400
commit1d474579c86e56d006f327683782dba92b9cea0f (patch)
treeda18e5acf9d6fd4064246bdfc468f024b24c0a53 /src
parentdfc0800de97a99f555fc6035987d49af3fe1f68e (diff)
downloadntapi-1d474579c86e56d006f327683782dba92b9cea0f.tar.bz2
ntapi-1d474579c86e56d006f327683782dba92b9cea0f.tar.xz
__ntapi_sem_set(): unmap the ad-hoc section as needed.
Diffstat (limited to 'src')
-rw-r--r--src/sem/ntapi_sem_set.c25
1 files changed, 20 insertions, 5 deletions
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);
}