summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2018-03-08 07:14:49 +0000
committermidipix <writeonce@midipix.org>2018-03-14 19:09:59 -0400
commit31d7ced24c5a8454dc6e5ad74ab6a4d0e3fc7549 (patch)
tree215fc1c22922d0eff9dc4f06bb096c8e2fa99eb9
parent1d474579c86e56d006f327683782dba92b9cea0f (diff)
downloadntapi-31d7ced24c5a8454dc6e5ad74ab6a4d0e3fc7549.tar.bz2
ntapi-31d7ced24c5a8454dc6e5ad74ab6a4d0e3fc7549.tar.xz
__ntapi_sem_ioctl(): unmap the ad-hoc section as needed.
-rw-r--r--src/sem/ntapi_sem_ioctl.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/src/sem/ntapi_sem_ioctl.c b/src/sem/ntapi_sem_ioctl.c
index 9735dfc..5c6a0a1 100644
--- a/src/sem/ntapi_sem_ioctl.c
+++ b/src/sem/ntapi_sem_ioctl.c
@@ -15,10 +15,18 @@
#include "ntapi_impl.h"
static int32_t __sem_ioctl_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;
}
@@ -36,6 +44,7 @@ int32_t __stdcall __ntapi_sem_ioctl(
__in uint32_t output_buffer_length)
{
int32_t status;
+ void * mapaddr;
void * hsection;
void * secaddr;
size_t secsize;
@@ -63,20 +72,28 @@ int32_t __stdcall __ntapi_sem_ioctl(
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;
+
if (input_buffer_length > secsize)
- return NT_STATUS_INFO_LENGTH_MISMATCH;
+ return __sem_ioctl_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 __sem_ioctl_return(
+ mapaddr,0,
+ NT_STATUS_RESOURCE_NOT_OWNED);
/* semop array to section */
__ntapi->tt_generic_memcpy(
@@ -104,12 +121,12 @@ int32_t __stdcall __ntapi_sem_ioctl(
msg.data.seminfo.riosb = iosb;
if ((status = __ntapi->zw_request_wait_reply_port(sem->hport,&msg,&msg)))
- return __sem_ioctl_return(hlock,status);
+ return __sem_ioctl_return(mapaddr,hlock,status);
else if (msg.data.ttyinfo.status)
- return __sem_ioctl_return(hlock,msg.data.ttyinfo.status);
+ return __sem_ioctl_return(mapaddr,hlock,msg.data.ttyinfo.status);
iosb->status = NT_STATUS_SUCCESS;
iosb->info = 0;
- return __sem_ioctl_return(hlock,NT_STATUS_SUCCESS);
+ return __sem_ioctl_return(mapaddr,hlock,NT_STATUS_SUCCESS);
}