summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2018-03-08 07:07:31 +0000
committermidipix <writeonce@midipix.org>2018-03-14 19:09:58 -0400
commitdfc0800de97a99f555fc6035987d49af3fe1f68e (patch)
tree6cf23b2e4b9c290ad1e75a4399e33f72a3ef5d9f /src
parent29b2c1ac5e3c1b8ba1e54084a7e687abd5f8114d (diff)
downloadntapi-dfc0800de97a99f555fc6035987d49af3fe1f68e.tar.bz2
ntapi-dfc0800de97a99f555fc6035987d49af3fe1f68e.tar.xz
__ntapi_sem_query(): unmap the ad-hoc section as needed.
Diffstat (limited to 'src')
-rw-r--r--src/sem/ntapi_sem_query.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/src/sem/ntapi_sem_query.c b/src/sem/ntapi_sem_query.c
index f1e53a9..1a6b2e2 100644
--- a/src/sem/ntapi_sem_query.c
+++ b/src/sem/ntapi_sem_query.c
@@ -15,12 +15,18 @@
#include "ntapi_impl.h"
static int32_t __sem_query_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_query(
__in int32_t sem_ipc_cmd)
{
int32_t status;
+ void * mapaddr;
void * hsection;
void * secaddr;
size_t secsize;
@@ -65,17 +72,23 @@ int32_t __stdcall __ntapi_sem_query(
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;
+
/* lock */
hlock = &(__ntapi_internals()->hlock);
if (at_locked_cas(hlock,0,1))
- return NT_STATUS_RESOURCE_NOT_OWNED;
+ return __sem_query_return(
+ mapaddr,0,
+ NT_STATUS_RESOURCE_NOT_OWNED);
}
/* msg */
@@ -95,15 +108,15 @@ int32_t __stdcall __ntapi_sem_query(
msg.data.seminfo.section_size = secsize;
if ((status = __ntapi->zw_request_wait_reply_port(sem->hport,&msg,&msg)))
- return __sem_query_return(hlock,status);
+ return __sem_query_return(mapaddr,hlock,status);
else if (msg.data.ttyinfo.status)
- return __sem_query_return(hlock,msg.data.ttyinfo.status);
+ return __sem_query_return(mapaddr,hlock,msg.data.ttyinfo.status);
/* reply */
if (sem_ipc_cmd == NT_SEM_CMD_GETALL) {
if (msg.data.seminfo.section_size > sem_info_length)
return __sem_query_return(
- hlock,
+ mapaddr,hlock,
NT_STATUS_BUFFER_TOO_SMALL);
__ntapi->tt_generic_memcpy(
@@ -114,6 +127,11 @@ int32_t __stdcall __ntapi_sem_query(
iosb->status = NT_STATUS_SUCCESS;
iosb->info = msg.data.seminfo.section_size;
+
+ if (mapaddr)
+ __ntapi->zw_unmap_view_of_section(
+ NT_CURRENT_PROCESS_HANDLE,
+ mapaddr);
} else {
if (msg.header.data_size != sizeof(msg.data))
return NT_STATUS_UNEXPECTED_IO_ERROR;