diff options
author | midipix <writeonce@midipix.org> | 2016-07-13 03:45:07 -0400 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2016-07-21 03:47:27 -0400 |
commit | e21cdc9b96c16e48cee9aecc9d38a319c03b557f (patch) | |
tree | bb937fa90fa306e75baf5ed5fb100dd6236fe5fe /src | |
parent | 5399d490f74045133a0aeb1bd619c5fee8221c8a (diff) | |
download | ptycon-e21cdc9b96c16e48cee9aecc9d38a319c03b557f.tar.bz2 ptycon-e21cdc9b96c16e48cee9aecc9d38a319c03b557f.tar.xz |
debug: ptyc_dbg_oven(): initial implementation.
Diffstat (limited to 'src')
-rw-r--r-- | src/debug/ptyc_dbg_oven.c | 56 |
1 files changed, 54 insertions, 2 deletions
diff --git a/src/debug/ptyc_dbg_oven.c b/src/debug/ptyc_dbg_oven.c index 7357f57..4adc5f8 100644 --- a/src/debug/ptyc_dbg_oven.c +++ b/src/debug/ptyc_dbg_oven.c @@ -14,6 +14,58 @@ int __stdcall ptyc_dbg_oven(struct ptyc_driver_ctx_impl * ictx) { - (void)ictx; - return ntapi->tt_wait_for_dummy_event(); + int32_t status; + void * hwait; + char * ch; + nt_iosb iosb; + size_t nread; + uintptr_t buffer[4196/sizeof(uintptr_t)]; + + if ((status = ntapi->tt_create_private_event( + &hwait, + NT_NOTIFICATION_EVENT, + NT_EVENT_NOT_SIGNALED))) + return status; + + do { + status = ntapi->pty_read( + ictx->cctx.hpts, + hwait,0,0, + &iosb, + buffer,sizeof(buffer), + 0,0); + + if (status == NT_STATUS_PENDING) + status = ntapi->zw_wait_for_single_object( + hwait,NT_SYNC_ALERTABLE,0); + + if (status || iosb.status) { + ntapi->zw_close(hwait); + return status ? status : iosb.status; + } + + ch = (char *)buffer; + nread = iosb.info; + + for ( ; nread; ) { + status = ntapi->pty_write( + ictx->cctx.hpts, + hwait,0,0, + &iosb, + ch,nread, + 0,0); + + if (status == NT_STATUS_PENDING) + status = ntapi->zw_wait_for_single_object( + hwait,NT_SYNC_ALERTABLE,0); + + if (status || iosb.status) { + ntapi->zw_close(hwait); + return status ? status : iosb.status; + } + + ch += iosb.info; + nread -= iosb.info; + } + } while (1); } |