diff options
author | midipix <writeonce@midipix.org> | 2016-07-13 04:50:51 -0400 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2016-07-21 03:47:27 -0400 |
commit | 11483c8f8afb089c39acabb2055f1a7167a9f531 (patch) | |
tree | ea2f39e60bf74a72aed6d1c2850c18a4293ebad5 /src | |
parent | e4a3350202070c1ac22008cc14c71bd5654115fc (diff) | |
download | ptycon-11483c8f8afb089c39acabb2055f1a7167a9f531.tar.bz2 ptycon-11483c8f8afb089c39acabb2055f1a7167a9f531.tar.xz |
debug: ptyc_dbg_raw(): initial implementation.
Diffstat (limited to 'src')
-rw-r--r-- | src/debug/ptyc_dbg_raw.c | 58 |
1 files changed, 56 insertions, 2 deletions
diff --git a/src/debug/ptyc_dbg_raw.c b/src/debug/ptyc_dbg_raw.c index 0e5814f..8d30d3e 100644 --- a/src/debug/ptyc_dbg_raw.c +++ b/src/debug/ptyc_dbg_raw.c @@ -14,6 +14,60 @@ int __stdcall ptyc_dbg_raw(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 nbytes; + unsigned char uch; + unsigned int keyval; + char xch[6] = {0,0,0,0,0,0}; + + 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, + &uch,1, + 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; + } + + ntapi->sprintf(xch,"0x%02x ",(keyval = uch)); + nbytes = sizeof(xch) - 1; + + for (ch=xch; nbytes; ) { + status = ntapi->pty_write( + ictx->cctx.hpts, + hwait,0,0, + &iosb, + ch,nbytes, + 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; + nbytes -= iosb.info; + } + } while (1); } |