diff options
-rw-r--r-- | src/pty/ntapi_pty_query.c | 42 | ||||
-rw-r--r-- | src/pty/ntapi_pty_set.c | 15 |
2 files changed, 34 insertions, 23 deletions
diff --git a/src/pty/ntapi_pty_query.c b/src/pty/ntapi_pty_query.c index 7f04119..72b3b31 100644 --- a/src/pty/ntapi_pty_query.c +++ b/src/pty/ntapi_pty_query.c @@ -26,12 +26,17 @@ int32_t __stdcall __ntapi_pty_query( if (pty_info_class>=NT_PTY_INFORMATION_CAP) return NT_STATUS_INVALID_INFO_CLASS; - else if (pty_info_class == NT_PTY_BASIC_INFORMATION) + + if (pty_info_class == NT_PTY_BASIC_INFORMATION) return NT_STATUS_NOT_IMPLEMENTED; - else if ((pty_info_class == NT_PTY_CLIENT_INFORMATION) && (pty_info_length != sizeof(nt_pty_client_info))) - return NT_STATUS_INVALID_PARAMETER; - else if ((pty_info_class == NT_PTY_INHERIT_INFORMATION) && (pty_info_length != sizeof(nt_pty_inherit_info))) - return NT_STATUS_INVALID_PARAMETER; + + if (pty_info_class == NT_PTY_CLIENT_INFORMATION) + if (pty_info_length < sizeof(nt_pty_client_info)) + return NT_STATUS_INVALID_PARAMETER; + + if (pty_info_class == NT_PTY_INHERIT_INFORMATION) + if (pty_info_length != sizeof(nt_pty_inherit_info)) + return NT_STATUS_INVALID_PARAMETER; __ntapi->tt_aligned_block_memset( &msg,0,sizeof(msg)); @@ -53,10 +58,10 @@ int32_t __stdcall __ntapi_pty_query( &pty->guid); } else if (pty_info_class == NT_PTY_INHERIT_INFORMATION) { - msg.data.ctlinfo.hpty = NT_INVALID_HANDLE_VALUE; - msg.data.ctlinfo.ctlcode = pty_info_class; + msg.data.ctlinfo.hpty = NT_INVALID_HANDLE_VALUE; + msg.data.ctlinfo.ctlcode = pty_info_class; - inherit = (nt_pty_inherit_info *)pty_info; + inherit = (nt_pty_inherit_info *)pty_info; msg.data.ctlinfo.ctxarg[0] = inherit->any[0]; msg.data.ctlinfo.ctxarg[1] = inherit->any[1]; msg.data.ctlinfo.ctxarg[2] = inherit->any[2]; @@ -69,6 +74,7 @@ int32_t __stdcall __ntapi_pty_query( if ((status = __ntapi->zw_request_wait_reply_port(hport,&msg,&msg))) return status; + else if (msg.data.ttyinfo.status) return msg.data.ttyinfo.status; @@ -76,22 +82,22 @@ int32_t __stdcall __ntapi_pty_query( iosb->status = msg.data.ctlinfo.iosb.status; if (pty_info_class == NT_PTY_CLIENT_INFORMATION) { - info = (uintptr_t *)pty_info; + info = (uintptr_t *)pty_info; info[0] = msg.data.ctlinfo.ctxarg[0]; info[1] = msg.data.ctlinfo.ctxarg[1]; info[2] = msg.data.ctlinfo.ctxarg[2]; info[3] = msg.data.ctlinfo.ctxarg[3]; } else if (pty_info_class == NT_PTY_INHERIT_INFORMATION) { - inherit = (nt_pty_inherit_info *)pty_info; - inherit->hpty = msg.data.ctlinfo.hpty; - inherit->luid.low = msg.data.ctlinfo.luid.low; - inherit->luid.high = msg.data.ctlinfo.luid.high; - - inherit->access = (uint32_t)msg.data.ctlinfo.ctxarg[0]; - inherit->flags = (uint32_t)msg.data.ctlinfo.ctxarg[1]; - inherit->share = (uint32_t)msg.data.ctlinfo.ctxarg[2]; - inherit->options = (uint32_t)msg.data.ctlinfo.ctxarg[3]; + inherit = (nt_pty_inherit_info *)pty_info; + inherit->hpty = msg.data.ctlinfo.hpty; + inherit->luid.low = msg.data.ctlinfo.luid.low; + inherit->luid.high = msg.data.ctlinfo.luid.high; + + inherit->access = (uint32_t)msg.data.ctlinfo.ctxarg[0]; + inherit->flags = (uint32_t)msg.data.ctlinfo.ctxarg[1]; + inherit->share = (uint32_t)msg.data.ctlinfo.ctxarg[2]; + inherit->options = (uint32_t)msg.data.ctlinfo.ctxarg[3]; __ntapi->tt_guid_copy( &inherit->guid, diff --git a/src/pty/ntapi_pty_set.c b/src/pty/ntapi_pty_set.c index 1b7074c..0793dc6 100644 --- a/src/pty/ntapi_pty_set.c +++ b/src/pty/ntapi_pty_set.c @@ -24,12 +24,16 @@ int32_t __stdcall __ntapi_pty_set( if (pty_info_class>=NT_PTY_INFORMATION_CAP) return NT_STATUS_INVALID_INFO_CLASS; - else if (pty_info_class == NT_PTY_BASIC_INFORMATION) + + if (pty_info_class == NT_PTY_BASIC_INFORMATION) return NT_STATUS_NOT_IMPLEMENTED; - else if (pty_info_class == NT_PTY_INHERIT_INFORMATION) + + if (pty_info_class == NT_PTY_INHERIT_INFORMATION) return NT_STATUS_INVALID_INFO_CLASS; - else if ((pty_info_class == NT_PTY_CLIENT_INFORMATION) && (pty_info_length != sizeof(nt_pty_client_info))) - return NT_STATUS_INVALID_PARAMETER; + + if (pty_info_class == NT_PTY_CLIENT_INFORMATION) + if (pty_info_length != sizeof(nt_pty_client_info)) + return NT_STATUS_INVALID_PARAMETER; __ntapi->tt_aligned_block_memset( &msg,0,sizeof(msg)); @@ -48,7 +52,7 @@ int32_t __stdcall __ntapi_pty_set( &msg.data.ctlinfo.guid, &pty->guid); - info = (uintptr_t *)pty_info; + info = (uintptr_t *)pty_info; msg.data.ctlinfo.ctxarg[0] = info[0]; msg.data.ctlinfo.ctxarg[1] = info[1]; msg.data.ctlinfo.ctxarg[2] = info[2]; @@ -56,6 +60,7 @@ int32_t __stdcall __ntapi_pty_set( if ((status = __ntapi->zw_request_wait_reply_port(pty->hport,&msg,&msg))) return status; + else if (msg.data.ttyinfo.status) return msg.data.ttyinfo.status; |