rdpdr.c revision a180a41bba1d50822df23fff0099e90b86638b89
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync/* -*- c-basic-offset: 8 -*-
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync rdesktop: A Remote Desktop Protocol client.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync Copyright (C) Matthew Chapman <matthewc.unsw.edu.au> 1999-2008
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync Copyright 2004-2011 Peter Astrand <astrand@cendio.se> for Cendio AB
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync Copyright 2010-2014 Henrik Andersson <hean01@cendio.se> for Cendio AB
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync This program is free software: you can redistribute it and/or modify
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync it under the terms of the GNU General Public License as published by
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync the Free Software Foundation, either version 3 of the License, or
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync (at your option) any later version.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync This program is distributed in the hope that it will be useful,
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync but WITHOUT ANY WARRANTY; without even the implied warranty of
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync GNU General Public License for more details.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync You should have received a copy of the GNU General Public License
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync along with this program. If not, see <http://www.gnu.org/licenses/>.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync Here are some resources, for your IRP hacking pleasure:
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync http://cvs.sourceforge.net/viewcvs.py/mingw/w32api/include/ddk/winddk.h?view=markup
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync http://undocumented.ntinternals.net/UserMode/Undocumented%20Functions/NT%20Objects/File/
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync#include <dirent.h> /* opendir, closedir, readdir */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync/* If select() times out, the request for the device with handle g_min_timeout_fd is aborted */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync/* Table with information about rdpdr devices */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync/* Used to store incoming io request, until they are ready to be completed */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync/* using a linked list ensures that they are processed in the right order, */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync/* if multiple ios are being done on the same fd */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync uint32 fd, major, minor, offset, device, id, length, partial_len;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync itv_timeout; /* Interval timeout (between serial characters) */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync struct async_iorequest *next; /* next element in list */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync/* Return device_id for a given handle */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync for (i = 0; i < RDPDR_MAX_DEVICES; i++)
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync/* Converts a windows path to a unix path */
static RD_BOOL
case DEVICE_TYPE_PARALLEL:
case DEVICE_TYPE_SERIAL:
case DEVICE_TYPE_PRINTER:
case DEVICE_TYPE_SCARD:
return False;
case DEVICE_TYPE_DISK:
return False;
return True;
static RD_BOOL
if (!g_iorequest)
return False;
return False;
return True;
STREAM s;
s_mark_end(s);
STREAM s;
s_mark_end(s);
int size, i;
for (i = 0; i < g_num_devices; i++)
return size;
STREAM s;
for (i = 0; i < g_num_devices; i++)
case DEVICE_TYPE_PRINTER:
out_uint32(s, 0);
s_mark_end(s);
STREAM s;
#ifdef WITH_SCARD
s_mark_end(s);
#ifdef WITH_DEBUG_RDP5
#ifdef WITH_SCARD
length = 0,
desired_access = 0,
file,
id,
char *filename;
buffer_len = 0;
buffer[0] = 0;
case DEVICE_TYPE_SERIAL:
case DEVICE_TYPE_PARALLEL:
case DEVICE_TYPE_PRINTER:
case DEVICE_TYPE_DISK:
case DEVICE_TYPE_SCARD:
#ifdef WITH_SCARD
switch (major)
case IRP_MJ_CREATE:
if (filename)
case IRP_MJ_CLOSE:
case IRP_MJ_READ:
#if WITH_DEBUG_RDP5
if (!buffer)
if (!pst_buf)
case IRP_MJ_WRITE:
#if WITH_DEBUG_RDP5
if (!pst_buf)
case IRP_MJ_QUERY_INFORMATION:
case IRP_MJ_SET_INFORMATION:
case IRP_MJ_DIRECTORY_CONTROL:
switch (minor)
case IRP_MN_QUERY_DIRECTORY:
if (filename)
&out);
if (!buffer_len)
buffer_len++;
result = 0;
case IRP_MJ_DEVICE_CONTROL:
if (!buffer)
#ifdef WITH_SCARD
#ifdef WITH_SCARD
case IRP_MJ_LOCK_CONTROL:
if (buffer)
STREAM s;
out_uint16_le(s, 0);
out_uint32_le(s, 0);
out_uint32_le(s, 0);
out_uint32_le(s, 0);
s_mark_end(s);
#if WITH_DEBUG_RDP5
switch (pakid)
g_epoch++;
case PAKID_CORE_DEVICE_REPLY:
#if WITH_DEBUG_RDP5
case IRP_MJ_READ:
&& (select_timeout == 0
&& (select_timeout == 0
case IRP_MJ_WRITE:
case IRP_MJ_DEVICE_CONTROL:
struct async_iorequest *
if (!iorq)
return NULL;
if (prev)
return iorq;
if (timed_out)
if (iorq)
case IRP_MJ_READ:
req_size =
if ((long) result > 0)
#if WITH_DEBUG_RDP5
(result == 0))
#if WITH_DEBUG_RDP5
case IRP_MJ_WRITE:
req_size =
if ((long) result > 0)
#if WITH_DEBUG_RDP5
result));
|| (result == 0))
#if WITH_DEBUG_RDP5
case IRP_MJ_DEVICE_CONTROL:
if (iorq)
case IRP_MJ_DIRECTORY_CONTROL:
if (g_notify_stamp)
status, 0,
NULL, 0);
iorq);
if (iorq)
result = 0;
return True;
return False;