summaryrefslogtreecommitdiffhomepage
path: root/src/internal
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2017-07-30 21:21:21 +0000
committermidipix <writeonce@midipix.org>2017-07-31 08:43:35 -0400
commit30d28dce7f884ffc2312a8b26f30759ae5f09aff (patch)
tree76fe681605a6744e6492ba293ada751833ae927e /src/internal
parenta1e25ad89de33c3ad253ab239d1d92a6ebb096e7 (diff)
downloadntapi-30d28dce7f884ffc2312a8b26f30759ae5f09aff.tar.bz2
ntapi-30d28dce7f884ffc2312a8b26f30759ae5f09aff.tar.xz
subsystem interfaces: integrated ipc connection handlers.
Diffstat (limited to 'src/internal')
-rw-r--r--src/internal/ntapi.c20
-rw-r--r--src/internal/ntapi_fnapi.h4
-rw-r--r--src/internal/ntapi_impl.h26
3 files changed, 48 insertions, 2 deletions
diff --git a/src/internal/ntapi.c b/src/internal/ntapi.c
index 336b5db..da91cfe 100644
--- a/src/internal/ntapi.c
+++ b/src/internal/ntapi.c
@@ -130,6 +130,20 @@ static int32_t __fastcall __ntapi_init_once(ntapi_vtbl ** pvtbl)
if (status != NT_STATUS_SUCCESS)
return status;
+ /* ipc connection list */
+ if ((status = dalist_init_ex(
+ &internals->ipc_conns,
+ sizeof(nt_ipc_conn),
+ NT_ALLOCATION_GRANULARITY,
+ __ntapi_ipc_page_alloc,
+ DALIST_MEMFN_CUSTOM)))
+ return status;
+
+ dalist_deposit_memory_block(
+ &internals->ipc_conns,
+ &__ntapi_img_bss.ipc_buffer,
+ __NT_BSS_IPC_BUFFER_SIZE);
+
/* hashed import table */
__ntapi_tt_populate_hashed_import_table(
pe_get_ntdll_module_handle(),
@@ -165,6 +179,12 @@ static int32_t __fastcall __ntapi_init_once(ntapi_vtbl ** pvtbl)
__ntapi->tt_open_logical_parent_directory = __ntapi_tt_open_logical_parent_directory;
__ntapi->tt_open_physical_parent_directory = __ntapi_tt_open_physical_parent_directory;
+ /* nt_ipc.h */
+ __ntapi->ipc_connect_by_attr = __ntapi_ipc_connect_by_attr;
+ __ntapi->ipc_connect_by_name = __ntapi_ipc_connect_by_name;
+ __ntapi->ipc_connect_by_symlink = __ntapi_ipc_connect_by_symlink;
+ __ntapi->ipc_connect_by_port = __ntapi_ipc_connect_by_port;
+
/* nt_ldr.h */
__ntapi->ldr_load_system_dll = __ntapi_ldr_load_system_dll;
__ntapi->ldr_create_state_snapshot = __ntapi_ldr_create_state_snapshot;
diff --git a/src/internal/ntapi_fnapi.h b/src/internal/ntapi_fnapi.h
index 546c335..8ff01f5 100644
--- a/src/internal/ntapi_fnapi.h
+++ b/src/internal/ntapi_fnapi.h
@@ -46,6 +46,10 @@ ntapi_tt_open_physical_parent_directory __ntapi_tt_open_physical_parent_directo
/* nt_ipc.h */
+ntapi_ipc_connect_by_attr __ntapi_ipc_connect_by_attr;
+ntapi_ipc_connect_by_name __ntapi_ipc_connect_by_name;
+ntapi_ipc_connect_by_symlink __ntapi_ipc_connect_by_symlink;
+ntapi_ipc_connect_by_port __ntapi_ipc_connect_by_port;
ntapi_ipc_create_pipe __ntapi_ipc_create_pipe_v1;
ntapi_ipc_create_pipe __ntapi_ipc_create_pipe_v2;
diff --git a/src/internal/ntapi_impl.h b/src/internal/ntapi_impl.h
index aca201b..870e5fd 100644
--- a/src/internal/ntapi_impl.h
+++ b/src/internal/ntapi_impl.h
@@ -39,6 +39,10 @@
#ifndef __NT_SYNC_BLOCK_LOCK_TRIES
#define __NT_SYNC_BLOCK_LOCK_TRIES 1024
#endif
+
+#ifndef __NT_IPC_PAGES
+#define __NT_IPC_PAGES 64
+#endif
/* user-defined options: tail */
/* internal page size */
@@ -48,23 +52,27 @@
/* .bss section */
#ifndef __NT_BSS_RESERVED_PAGES
-#define __NT_BSS_RESERVED_PAGES 8
+#define __NT_BSS_RESERVED_PAGES 10
#endif
/* runtime buffers */
#define __NT_BSS_ARGV_BUFFER_SIZE __NT_INTERNAL_PAGE_SIZE * 2
+#define __NT_BSS_IPC_BUFFER_SIZE __NT_INTERNAL_PAGE_SIZE * 2
+
#define __NT_BSS_ARGV_MAX_IDX __NT_BSS_ARGV_BUFFER_SIZE \
/ sizeof(uintptr_t)
#define __NT_BSS_ARGS_BUFFER_SIZE __NT_INTERNAL_PAGE_SIZE \
* __NT_BSS_RESERVED_PAGES \
- - __NT_BSS_ARGV_BUFFER_SIZE
+ - __NT_BSS_ARGV_BUFFER_SIZE \
+ - __NT_BSS_IPC_BUFFER_SIZE
/* ntapi .bss section structure */
typedef struct ___ntapi_img_sec_bss {
wchar16_t * argv_envp_array[__NT_BSS_ARGV_MAX_IDX];
char args_envs_buffer[__NT_BSS_ARGS_BUFFER_SIZE];
+ size_t ipc_buffer[__NT_BSS_IPC_BUFFER_SIZE / sizeof(size_t)];
} __ntapi_img_sec_bss;
@@ -85,6 +93,9 @@ typedef struct __attr_ptr_size_aligned__ _ntapi_internals {
void ** csr_port_handle_addr;
void * hdev_mount_point_mgr;
void * hany[8];
+ struct dalist_ex ipc_conns;
+ void * ipc_pages[__NT_IPC_PAGES];
+ int32_t ipc_page;
intptr_t hlock;
uintptr_t v1_pipe_counter;
ntapi_tt_get_csr_port_handle_addr_by_logic * tt_get_csr_port_handle_addr_by_logic;
@@ -92,6 +103,15 @@ typedef struct __attr_ptr_size_aligned__ _ntapi_internals {
} ntapi_internals;
+/* ipc internals */
+typedef struct _nt_ipc_conn {
+ nt_port_attr attr;
+ void * hsection;
+ void * secaddr;
+ size_t secsize;
+} nt_ipc_conn;
+
+
/* __ntapi_img_sec_data */
typedef struct __attr_ptr_size_aligned__ ___ntapi_img_sec_rdata {
ntapi_hashed_symbol __ntapi_import_table[__NT_IMPORTED_SYMBOLS_ARRAY_SIZE];
@@ -120,6 +140,8 @@ ntapi_internals * __cdecl __ntapi_internals(void);
int32_t __ntapi_tt_open_file_utf8(void ** hfile, void * hat, const char * arg, int fprivate, wchar16_t *, uint32_t);
int32_t __ntapi_tt_open_dir_utf8(void ** hfile, void * hat, const char * arg, int fprivate, wchar16_t *, uint32_t);
+/* ipc internals */
+int __ntapi_ipc_page_alloc(struct dalist_ex * dlist, void ** addr, size_t * alloc_size);
/* debug */
#define __ntidx(x) (&(((ntapi_vtbl *)0)->x)) / sizeof(size_t)