diff options
author | midipix <writeonce@midipix.org> | 2018-05-05 00:29:32 +0000 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2018-05-07 08:33:42 -0400 |
commit | 6a47931d980b8a417f769545eea1bda7b51afea9 (patch) | |
tree | 9b73d8f9126496cb05f563e7806bd95571b5916a /src/afl/ntapi_afl_query.c | |
parent | dbeebdf22fad8254aa615b071c878b7a086246ed (diff) | |
download | ntapi-6a47931d980b8a417f769545eea1bda7b51afea9.tar.bz2 ntapi-6a47931d980b8a417f769545eea1bda7b51afea9.tar.xz |
advisory file locking: integrated client-side interfaces.
Diffstat (limited to 'src/afl/ntapi_afl_query.c')
-rw-r--r-- | src/afl/ntapi_afl_query.c | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/src/afl/ntapi_afl_query.c b/src/afl/ntapi_afl_query.c new file mode 100644 index 0000000..0128ac6 --- /dev/null +++ b/src/afl/ntapi_afl_query.c @@ -0,0 +1,67 @@ +/********************************************************/ +/* ntapi: Native API core library */ +/* Copyright (C) 2013--2017 Z. Gilboa */ +/* Released under GPLv2 and GPLv3; see COPYING.NTAPI. */ +/********************************************************/ + +#include <psxtypes/psxtypes.h> +#include <ntapi/nt_file.h> +#include <ntapi/nt_string.h> +#include <ntapi/nt_atomic.h> +#include <ntapi/nt_port.h> +#include <ntapi/nt_ipc.h> +#include <ntapi/nt_afl.h> +#include <ntapi/ntapi.h> +#include "ntapi_impl.h" + +int32_t __stdcall __ntapi_afl_query( + __in nt_afl_info * afl, + __out nt_io_status_block * iosb, + __out void * afl_info, + __in uint32_t afl_info_length, + __in int32_t afl_info_class) +{ + int32_t status; + nt_afl_info_msg msg; + + /* validate */ + if (!iosb) + return NT_STATUS_INVALID_PARAMETER; + + else if (!afl_info) + return NT_STATUS_INVALID_PARAMETER; + + else if (afl_info_length < sizeof(msg.data.aflinfo)) + return NT_STATUS_BUFFER_TOO_SMALL; + + else if (afl_info_class) + return NT_STATUS_INVALID_INFO_CLASS; + + /* msg */ + __ntapi->tt_aligned_block_memset( + &msg,0,sizeof(msg)); + + msg.header.msg_type = NT_LPC_NEW_MESSAGE; + msg.header.data_size = sizeof(msg.data); + msg.header.msg_size = sizeof(msg); + msg.data.ttyinfo.opcode = NT_TTY_AFL_QUERY; + + if ((status = __ntapi->zw_request_wait_reply_port(afl->hport,&msg,&msg))) + return status; + else if (msg.data.ttyinfo.status) + return msg.data.ttyinfo.status; + + /* reply */ + if (msg.header.data_size != sizeof(msg.data)) + return NT_STATUS_UNEXPECTED_IO_ERROR; + + __ntapi->tt_generic_memcpy( + afl_info, + &msg.data.aflinfo, + sizeof(msg.data.aflinfo)); + + iosb->status = NT_STATUS_SUCCESS; + iosb->info = sizeof(msg.data.aflinfo); + + return NT_STATUS_SUCCESS; +} |