diff options
author | midipix <writeonce@midipix.org> | 2022-11-18 17:29:49 +0000 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2022-11-18 19:02:48 +0000 |
commit | 1717a8ab178466bb73fd4c0a7fba1402df9deef0 (patch) | |
tree | 288489dba2c18b8751b04ec8f079a9edc85619c1 | |
parent | 3b05e82a2c5d529cb383a5c06b509883dc59d628 (diff) | |
download | ntapi-1717a8ab178466bb73fd4c0a7fba1402df9deef0.tar.bz2 ntapi-1717a8ab178466bb73fd4c0a7fba1402df9deef0.tar.xz |
ipc helper interfaces: allow requesting an existing connection.
-rw-r--r-- | include/ntapi/nt_ipc.h | 18 | ||||
-rw-r--r-- | src/afl/ntapi_afl_connect.c | 8 | ||||
-rw-r--r-- | src/internal/ntapi_impl.h | 4 | ||||
-rw-r--r-- | src/ipc/ntapi_ipc_connect.c | 43 | ||||
-rw-r--r-- | src/msq/ntapi_msq_connect.c | 8 | ||||
-rw-r--r-- | src/sem/ntapi_sem_connect.c | 8 |
6 files changed, 59 insertions, 30 deletions
diff --git a/include/ntapi/nt_ipc.h b/include/ntapi/nt_ipc.h index 9eab304..51a76bc 100644 --- a/include/ntapi/nt_ipc.h +++ b/include/ntapi/nt_ipc.h @@ -60,17 +60,20 @@ typedef int32_t __stdcall ntapi_ipc_create_pipe( typedef int32_t __stdcall ntapi_ipc_connect_by_attr( __out void ** hport, - __in nt_port_attr * attr); + __in nt_port_attr * attr, + __in int fexisting); typedef int32_t __stdcall ntapi_ipc_connect_by_name( __out void ** hport, - __in nt_port_name * name); + __in nt_port_name * name, + __in int fexisting); typedef int32_t __stdcall ntapi_ipc_connect_by_symlink( __out void ** hport, - __in void * hsymlink); + __in void * hsymlink, + __in int fexisting); typedef int32_t __stdcall ntapi_ipc_connect_by_port( @@ -83,7 +86,8 @@ typedef int32_t __stdcall ntapi_ipc_connect_section_by_attr( __in nt_port_attr * attr, __out void ** hsection, __out void ** section_addr, - __out size_t * section_size); + __out size_t * section_size, + __in int fexisting); typedef int32_t __stdcall ntapi_ipc_connect_section_by_name( @@ -91,7 +95,8 @@ typedef int32_t __stdcall ntapi_ipc_connect_section_by_name( __in nt_port_name * name, __out void ** hsection, __out void ** section_addr, - __out size_t * section_size); + __out size_t * section_size, + __in int fexisting); typedef int32_t __stdcall ntapi_ipc_connect_section_by_symlink( @@ -99,7 +104,8 @@ typedef int32_t __stdcall ntapi_ipc_connect_section_by_symlink( __in void * hsymlink, __out void ** hsection, __out void ** section_addr, - __out size_t * section_size); + __out size_t * section_size, + __in int fexisting); typedef int32_t __stdcall ntapi_ipc_connect_section_by_port( diff --git a/src/afl/ntapi_afl_connect.c b/src/afl/ntapi_afl_connect.c index fc615b3..c5098d6 100644 --- a/src/afl/ntapi_afl_connect.c +++ b/src/afl/ntapi_afl_connect.c @@ -67,7 +67,8 @@ static int32_t __aflctl_server_connect( /* connect */ if ((status = __ntapi->ipc_connect_by_attr( &rtdata->haflctl, - &aflctl->attr))) + &aflctl->attr, + false))) return status; /* update */ @@ -193,7 +194,8 @@ static int32_t __stdcall __afl_open( /* new afl node? */ if (opcode == NT_TTY_AFL_ALLOC) if ((status = __ntapi->ipc_connect_by_attr( - &hipc,&msg.svcinfo.attr))) + &hipc,&msg.svcinfo.attr, + false))) return status; /* all done */ @@ -320,7 +322,7 @@ int32_t __stdcall __ntapi_afl_open( /* ipc connect */ status = __ntapi->ipc_connect_by_symlink( - &hipc,hsymlink); + &hipc,hsymlink,false); __ntapi->zw_close( hsymlink); diff --git a/src/internal/ntapi_impl.h b/src/internal/ntapi_impl.h index e974d29..96cc08a 100644 --- a/src/internal/ntapi_impl.h +++ b/src/internal/ntapi_impl.h @@ -28,6 +28,10 @@ #define __NT_IS_MISALIGNED_LENGTH(x) (x % sizeof(size_t)) #define __NT_FILE_SYNC_IO (NT_FILE_SYNCHRONOUS_IO_ALERT|NT_FILE_SYNCHRONOUS_IO_NONALERT) +/* boolean definitions */ +#define true (1) +#define false (0) + /* user-defined options: head */ #ifndef __NT_TTY_MONITORS #define __NT_TTY_MONITORS 0x10 diff --git a/src/ipc/ntapi_ipc_connect.c b/src/ipc/ntapi_ipc_connect.c index 21a7146..700ac37 100644 --- a/src/ipc/ntapi_ipc_connect.c +++ b/src/ipc/ntapi_ipc_connect.c @@ -475,7 +475,8 @@ int32_t __stdcall __ntapi_ipc_connect_section_by_attr( __in nt_port_attr * attr, __out void ** hsection, __out void ** secaddr, - __out size_t * secsize) + __out size_t * secsize, + __in int fexisting) { nt_port_name name; nt_unicode_string str; @@ -489,7 +490,8 @@ int32_t __stdcall __ntapi_ipc_connect_section_by_attr( return __ipc_connect_by_attr( hport,attr,&str,0, - hsection,secaddr,secsize,0); + hsection,secaddr,secsize, + fexisting); } @@ -498,7 +500,8 @@ int32_t __stdcall __ntapi_ipc_connect_section_by_name( __in nt_port_name * name, __out void ** hsection, __out void ** secaddr, - __out size_t * secsize) + __out size_t * secsize, + __in int fexisting) { int32_t status; nt_port_attr attr; @@ -513,7 +516,8 @@ int32_t __stdcall __ntapi_ipc_connect_section_by_name( return __ipc_connect_by_attr( hport,&attr,&str,0, - hsection,secaddr,secsize,0); + hsection,secaddr,secsize, + fexisting); } @@ -522,7 +526,8 @@ int32_t __stdcall __ntapi_ipc_connect_section_by_symlink( __in void * hsymlink, __out void ** hsection, __out void ** secaddr, - __out size_t * secsize) + __out size_t * secsize, + __in int fexisting) { int32_t status; nt_port_attr attr; @@ -550,7 +555,8 @@ int32_t __stdcall __ntapi_ipc_connect_section_by_symlink( return __ipc_connect_by_attr( hport,&attr,str,0, - hsection,secaddr,secsize,0); + hsection,secaddr,secsize, + fexisting); } @@ -563,43 +569,50 @@ int32_t __stdcall __ntapi_ipc_connect_section_by_port( { return __ipc_connect_by_attr( &(void *){0},attr,0,hconn, - hsection,secaddr,secsize,0); + hsection,secaddr,secsize, + false); } int32_t __stdcall __ntapi_ipc_connect_by_attr( __out void ** hport, - __in nt_port_attr * attr) + __in nt_port_attr * attr, + __in int fexisting) { return __ntapi_ipc_connect_section_by_attr( hport,attr, &(void *){0}, &(void *){0}, - &(size_t){0}); + &(size_t){0}, + fexisting); } int32_t __stdcall __ntapi_ipc_connect_by_name( __out void ** hport, - __in nt_port_name * name) + __in nt_port_name * name, + __in int fexisting) { return __ntapi_ipc_connect_section_by_name( hport,name, &(void *){0}, &(void *){0}, - &(size_t){0}); + &(size_t){0}, + fexisting); } int32_t __stdcall __ntapi_ipc_connect_by_symlink( __out void ** hport, - __in void * hsymlink) + __in void * hsymlink, + __in int fexisting) { return __ntapi_ipc_connect_section_by_symlink( hport,hsymlink, &(void *){0}, &(void *){0}, - &(size_t){0}); + &(size_t){0}, + fexisting); } @@ -624,7 +637,7 @@ int32_t __stdcall __ntapi_ipc_get_port_by_attr( &(void *){0}, &(void *){0}, &(size_t){0}, - 1); + true); } @@ -640,7 +653,7 @@ int32_t __stdcall __ntapi_ipc_get_port_section_by_attr( hsection, section_addr, section_size, - 1); + true); } diff --git a/src/msq/ntapi_msq_connect.c b/src/msq/ntapi_msq_connect.c index 532cac0..db4a314 100644 --- a/src/msq/ntapi_msq_connect.c +++ b/src/msq/ntapi_msq_connect.c @@ -67,7 +67,8 @@ static int32_t __msqctl_server_connect( /* connect */ if ((status = __ntapi->ipc_connect_by_attr( &rtdata->hmsqctl, - &msqctl->attr))) + &msqctl->attr, + false))) return status; /* update */ @@ -200,7 +201,8 @@ static int32_t __stdcall __msq_open( /* new msqueue? */ if (opcode == NT_TTY_MSQ_ALLOC) if ((status = __ntapi->ipc_connect_by_attr( - &hipc,&msg.svcinfo.attr))) + &hipc,&msg.svcinfo.attr, + false))) return status; /* all done */ @@ -334,7 +336,7 @@ int32_t __stdcall __ntapi_msq_open( /* ipc connect */ status = __ntapi->ipc_connect_by_symlink( - &hipc,hsymlink); + &hipc,hsymlink,false); __ntapi->zw_close( hsymlink); diff --git a/src/sem/ntapi_sem_connect.c b/src/sem/ntapi_sem_connect.c index 9d05604..33edc13 100644 --- a/src/sem/ntapi_sem_connect.c +++ b/src/sem/ntapi_sem_connect.c @@ -67,7 +67,8 @@ static int32_t __semctl_server_connect( /* connect */ if ((status = __ntapi->ipc_connect_by_attr( &rtdata->hsemctl, - &semctl->attr))) + &semctl->attr, + false))) return status; /* update */ @@ -200,7 +201,8 @@ static int32_t __stdcall __sem_open( /* new semaphore? */ if (opcode == NT_TTY_SEM_ALLOC) if ((status = __ntapi->ipc_connect_by_attr( - &hipc,&msg.svcinfo.attr))) + &hipc,&msg.svcinfo.attr, + false))) return status; /* all done */ @@ -334,7 +336,7 @@ int32_t __stdcall __ntapi_sem_open( /* ipc connect */ status = __ntapi->ipc_connect_by_symlink( - &hipc,hsymlink); + &hipc,hsymlink,false); __ntapi->zw_close( hsymlink); |