|
|
47f21a |
/********************************************************/
|
|
|
47f21a |
/* ntapi: Native API core library */
|
|
|
47f21a |
/* Copyright (C) 2013--2017 Z. Gilboa */
|
|
|
47f21a |
/* Released under GPLv2 and GPLv3; see COPYING.NTAPI. */
|
|
|
47f21a |
/********************************************************/
|
|
|
47f21a |
|
|
|
47f21a |
#include <psxtypes/psxtypes.h>
|
|
|
47f21a |
#include <ntapi/nt_file.h>
|
|
|
47f21a |
#include <ntapi/nt_string.h>
|
|
|
47f21a |
#include <ntapi/nt_atomic.h>
|
|
|
47f21a |
#include <ntapi/nt_port.h>
|
|
|
47f21a |
#include <ntapi/nt_ipc.h>
|
|
|
47f21a |
#include <ntapi/nt_msq.h>
|
|
|
47f21a |
#include <ntapi/ntapi.h>
|
|
|
47f21a |
#include "ntapi_impl.h"
|
|
|
47f21a |
|
|
|
47f21a |
int32_t __stdcall __ntapi_msq_query(
|
|
|
47f21a |
__in nt_msq_info * msq,
|
|
|
47f21a |
__out nt_io_status_block * iosb,
|
|
|
47f21a |
__out void * msq_info,
|
|
|
47f21a |
__in uint32_t msq_info_length,
|
|
|
47f21a |
__in int32_t msq_info_class)
|
|
|
47f21a |
{
|
|
|
47f21a |
int32_t status;
|
|
|
47f21a |
nt_msq_info_msg msg;
|
|
|
47f21a |
|
|
|
47f21a |
/* validate */
|
|
|
47f21a |
if (!iosb)
|
|
|
47f21a |
return NT_STATUS_INVALID_PARAMETER;
|
|
|
47f21a |
|
|
|
47f21a |
else if (!msq_info)
|
|
|
47f21a |
return NT_STATUS_INVALID_PARAMETER;
|
|
|
47f21a |
|
|
|
47f21a |
else if (msq_info_length < sizeof(msg.data.msqinfo))
|
|
|
47f21a |
return NT_STATUS_BUFFER_TOO_SMALL;
|
|
|
47f21a |
|
|
|
47f21a |
else if (msq_info_class)
|
|
|
47f21a |
return NT_STATUS_INVALID_INFO_CLASS;
|
|
|
47f21a |
|
|
|
47f21a |
/* msg */
|
|
|
47f21a |
__ntapi->tt_aligned_block_memset(
|
|
|
47f21a |
&msg,0,sizeof(msg));
|
|
|
47f21a |
|
|
|
47f21a |
msg.header.msg_type = NT_LPC_NEW_MESSAGE;
|
|
|
47f21a |
msg.header.data_size = sizeof(msg.data);
|
|
|
47f21a |
msg.header.msg_size = sizeof(msg);
|
|
|
47f21a |
msg.data.ttyinfo.opcode = NT_TTY_MSQ_QUERY;
|
|
|
47f21a |
|
|
|
47f21a |
msg.data.msqinfo.msqkey = msq->msqkey;
|
|
|
47f21a |
msg.data.msqinfo.msqid = msq->msqid;
|
|
|
47f21a |
|
|
|
47f21a |
if ((status = __ntapi->zw_request_wait_reply_port(msq->hport,&msg,&msg)))
|
|
|
47f21a |
return status;
|
|
|
47f21a |
else if (msg.data.ttyinfo.status)
|
|
|
47f21a |
return msg.data.ttyinfo.status;
|
|
|
47f21a |
|
|
|
47f21a |
/* reply */
|
|
|
47f21a |
if (msg.header.data_size != sizeof(msg.data))
|
|
|
47f21a |
return NT_STATUS_UNEXPECTED_IO_ERROR;
|
|
|
47f21a |
|
|
|
47f21a |
__ntapi->tt_generic_memcpy(
|
|
|
47f21a |
msq_info,
|
|
|
47f21a |
&msg.data.msqinfo,
|
|
|
47f21a |
sizeof(msg.data.msqinfo));
|
|
|
47f21a |
|
|
|
47f21a |
iosb->status = NT_STATUS_SUCCESS;
|
|
|
47f21a |
iosb->info = sizeof(msg.data.msqinfo);
|
|
|
47f21a |
|
|
|
47f21a |
return NT_STATUS_SUCCESS;
|
|
|
47f21a |
}
|