60 |
extern DEVICE_FNS printer_fns; |
extern DEVICE_FNS printer_fns; |
61 |
extern DEVICE_FNS parallel_fns; |
extern DEVICE_FNS parallel_fns; |
62 |
extern DEVICE_FNS disk_fns; |
extern DEVICE_FNS disk_fns; |
63 |
|
#ifdef WITH_SCARD |
64 |
|
extern DEVICE_FNS scard_fns; |
65 |
|
#endif |
66 |
extern FILEINFO g_fileinfo[]; |
extern FILEINFO g_fileinfo[]; |
67 |
extern BOOL g_notify_stamp; |
extern BOOL g_notify_stamp; |
68 |
|
|
69 |
|
#ifdef WITH_SCARD |
70 |
|
VCHANNEL *rdpdr_channel; |
71 |
|
#else |
72 |
static VCHANNEL *rdpdr_channel; |
static VCHANNEL *rdpdr_channel; |
73 |
|
#endif |
74 |
|
|
75 |
/* If select() times out, the request for the device with handle g_min_timeout_fd is aborted */ |
/* If select() times out, the request for the device with handle g_min_timeout_fd is aborted */ |
76 |
NTHANDLE g_min_timeout_fd; |
NTHANDLE g_min_timeout_fd; |
162 |
|
|
163 |
while (iorq->fd != 0) |
while (iorq->fd != 0) |
164 |
{ |
{ |
165 |
// create new element if needed |
/* create new element if needed */ |
166 |
if (iorq->next == NULL) |
if (iorq->next == NULL) |
167 |
{ |
{ |
168 |
iorq->next = |
iorq->next = |
235 |
int size, i; |
int size, i; |
236 |
PRINTER *printerinfo; |
PRINTER *printerinfo; |
237 |
|
|
238 |
size = 8; //static announce size |
size = 8; /* static announce size */ |
239 |
size += g_num_devices * 0x14; |
size += g_num_devices * 0x14; |
240 |
|
|
241 |
for (i = 0; i < g_num_devices; i++) |
for (i = 0; i < g_num_devices; i++) |
316 |
channel_send(s, rdpdr_channel); |
channel_send(s, rdpdr_channel); |
317 |
} |
} |
318 |
|
|
319 |
static void |
void |
320 |
rdpdr_send_completion(uint32 device, uint32 id, uint32 status, uint32 result, uint8 * buffer, |
rdpdr_send_completion(uint32 device, uint32 id, uint32 status, uint32 result, uint8 * buffer, |
321 |
uint32 length) |
uint32 length) |
322 |
{ |
{ |
334 |
/* JIF */ |
/* JIF */ |
335 |
#ifdef WITH_DEBUG_RDP5 |
#ifdef WITH_DEBUG_RDP5 |
336 |
printf("--> rdpdr_send_completion\n"); |
printf("--> rdpdr_send_completion\n"); |
337 |
//hexdump(s->channel_hdr + 8, s->end - s->channel_hdr - 8); |
/* hexdump(s->channel_hdr + 8, s->end - s->channel_hdr - 8); */ |
338 |
#endif |
#endif |
339 |
channel_send(s, rdpdr_channel); |
channel_send(s, rdpdr_channel); |
340 |
} |
} |
359 |
error_mode, |
error_mode, |
360 |
share_mode, disposition, total_timeout, interval_timeout, flags_and_attributes = 0; |
share_mode, disposition, total_timeout, interval_timeout, flags_and_attributes = 0; |
361 |
|
|
362 |
char filename[256]; |
char filename[PATH_MAX]; |
363 |
uint8 *buffer, *pst_buf; |
uint8 *buffer, *pst_buf; |
364 |
struct stream out; |
struct stream out; |
365 |
DEVICE_FNS *fns; |
DEVICE_FNS *fns; |
402 |
break; |
break; |
403 |
|
|
404 |
case DEVICE_TYPE_SCARD: |
case DEVICE_TYPE_SCARD: |
405 |
|
#ifdef WITH_SCARD |
406 |
|
fns = &scard_fns; |
407 |
|
rw_blocking = False; |
408 |
|
break; |
409 |
|
#endif |
410 |
default: |
default: |
411 |
|
|
412 |
error("IRP for bad device %ld\n", device); |
error("IRP for bad device %ld\n", device); |
418 |
case IRP_MJ_CREATE: |
case IRP_MJ_CREATE: |
419 |
|
|
420 |
in_uint32_be(s, desired_access); |
in_uint32_be(s, desired_access); |
421 |
in_uint8s(s, 0x08); // unknown |
in_uint8s(s, 0x08); /* unknown */ |
422 |
in_uint32_le(s, error_mode); |
in_uint32_le(s, error_mode); |
423 |
in_uint32_le(s, share_mode); |
in_uint32_le(s, share_mode); |
424 |
in_uint32_le(s, disposition); |
in_uint32_le(s, disposition); |
475 |
break; |
break; |
476 |
} |
} |
477 |
|
|
478 |
if (rw_blocking) // Complete read immediately |
if (rw_blocking) /* Complete read immediately */ |
479 |
{ |
{ |
480 |
buffer = (uint8 *) xrealloc((void *) buffer, length); |
buffer = (uint8 *) xrealloc((void *) buffer, length); |
481 |
if (!buffer) |
if (!buffer) |
488 |
break; |
break; |
489 |
} |
} |
490 |
|
|
491 |
// Add request to table |
/* Add request to table */ |
492 |
pst_buf = (uint8 *) xmalloc(length); |
pst_buf = (uint8 *) xmalloc(length); |
493 |
if (!pst_buf) |
if (!pst_buf) |
494 |
{ |
{ |
528 |
break; |
break; |
529 |
} |
} |
530 |
|
|
531 |
if (rw_blocking) // Complete immediately |
if (rw_blocking) /* Complete immediately */ |
532 |
{ |
{ |
533 |
status = fns->write(file, s->p, length, offset, &result); |
status = fns->write(file, s->p, length, offset, &result); |
534 |
break; |
break; |
535 |
} |
} |
536 |
|
|
537 |
// Add to table |
/* Add to table */ |
538 |
pst_buf = (uint8 *) xmalloc(length); |
pst_buf = (uint8 *) xmalloc(length); |
539 |
if (!pst_buf) |
if (!pst_buf) |
540 |
{ |
{ |
641 |
/* JIF |
/* JIF |
642 |
unimpl("IRP major=0x%x minor=0x%x: IRP_MN_NOTIFY_CHANGE_DIRECTORY\n", major, minor); */ |
unimpl("IRP major=0x%x minor=0x%x: IRP_MN_NOTIFY_CHANGE_DIRECTORY\n", major, minor); */ |
643 |
|
|
644 |
in_uint32_le(s, info_level); // notify mask |
in_uint32_le(s, info_level); /* notify mask */ |
645 |
|
|
646 |
g_notify_stamp = True; |
g_notify_stamp = True; |
647 |
|
|
683 |
|
|
684 |
out.data = out.p = buffer; |
out.data = out.p = buffer; |
685 |
out.size = sizeof(buffer); |
out.size = sizeof(buffer); |
686 |
|
|
687 |
|
DEBUG_SCARD(("[SMART-CARD TRACE]\n")); |
688 |
|
DEBUG_SCARD(("device 0x%.8x\n", device)); |
689 |
|
DEBUG_SCARD(("file 0x%.8x\n", file)); |
690 |
|
DEBUG_SCARD(("id 0x%.8x\n", id)); |
691 |
|
#ifdef WITH_SCARD |
692 |
|
scardSetInfo(device, id, bytes_out + 0x14); |
693 |
|
#endif |
694 |
status = fns->device_control(file, request, s, &out); |
status = fns->device_control(file, request, s, &out); |
695 |
result = buffer_len = out.p - out.data; |
result = buffer_len = out.p - out.data; |
696 |
|
|
697 |
|
DEBUG_SCARD(("[SMART-CARD TRACE] OUT 0x%.8x\n", status)); |
698 |
|
|
699 |
/* Serial SERIAL_WAIT_ON_MASK */ |
/* Serial SERIAL_WAIT_ON_MASK */ |
700 |
if (status == STATUS_PENDING) |
if (status == STATUS_PENDING) |
701 |
{ |
{ |
706 |
break; |
break; |
707 |
} |
} |
708 |
} |
} |
709 |
|
#ifdef WITH_SCARD |
710 |
|
else if (status == (STATUS_PENDING | 0xC0000000)) |
711 |
|
status = STATUS_PENDING; |
712 |
|
#endif |
713 |
break; |
break; |
714 |
|
|
715 |
|
|
861 |
void |
void |
862 |
rdpdr_add_fds(int *n, fd_set * rfds, fd_set * wfds, struct timeval *tv, BOOL * timeout) |
rdpdr_add_fds(int *n, fd_set * rfds, fd_set * wfds, struct timeval *tv, BOOL * timeout) |
863 |
{ |
{ |
864 |
uint32 select_timeout = 0; // Timeout value to be used for select() (in millisecons). |
uint32 select_timeout = 0; /* Timeout value to be used for select() (in millisecons). */ |
865 |
struct async_iorequest *iorq; |
struct async_iorequest *iorq; |
866 |
char c; |
char c; |
867 |
|
|
946 |
} |
} |
947 |
else |
else |
948 |
{ |
{ |
949 |
// Even if NULL |
/* Even if NULL */ |
950 |
g_iorequest = iorq->next; |
g_iorequest = iorq->next; |
951 |
xfree(iorq); |
xfree(iorq); |
952 |
iorq = NULL; |
iorq = NULL; |
955 |
} |
} |
956 |
|
|
957 |
/* Check if select() returned with one of the rdpdr file descriptors, and complete io if it did */ |
/* Check if select() returned with one of the rdpdr file descriptors, and complete io if it did */ |
958 |
void |
static void |
959 |
_rdpdr_check_fds(fd_set * rfds, fd_set * wfds, BOOL timed_out) |
_rdpdr_check_fds(fd_set * rfds, fd_set * wfds, BOOL timed_out) |
960 |
{ |
{ |
961 |
NTSTATUS status; |
NTSTATUS status; |
985 |
{ |
{ |
986 |
|
|
987 |
/* iv_timeout between 2 chars, send partial_len */ |
/* iv_timeout between 2 chars, send partial_len */ |
988 |
//printf("RDPDR: IVT total %u bytes read of %u\n", iorq->partial_len, iorq->length); |
/*printf("RDPDR: IVT total %u bytes read of %u\n", iorq->partial_len, iorq->length); */ |
989 |
rdpdr_send_completion(iorq->device, |
rdpdr_send_completion(iorq->device, |
990 |
iorq->id, STATUS_SUCCESS, |
iorq->id, STATUS_SUCCESS, |
991 |
iorq->partial_len, |
iorq->partial_len, |
1206 |
prev = NULL; |
prev = NULL; |
1207 |
while (iorq != NULL) |
while (iorq != NULL) |
1208 |
{ |
{ |
1209 |
// Only remove from table when major is not set, or when correct major is supplied. |
/* Only remove from table when major is not set, or when correct major is supplied. |
1210 |
// Abort read should not abort a write io request. |
Abort read should not abort a write io request. */ |
1211 |
if ((iorq->fd == fd) && (major == 0 || iorq->major == major)) |
if ((iorq->fd == fd) && (major == 0 || iorq->major == major)) |
1212 |
{ |
{ |
1213 |
result = 0; |
result = 0; |