本文整理汇总了C++中PDEVICE_SERVICE_ENTRY_POINTS类的典型用法代码示例。如果您正苦于以下问题:C++ PDEVICE_SERVICE_ENTRY_POINTS类的具体用法?C++ PDEVICE_SERVICE_ENTRY_POINTS怎么用?C++ PDEVICE_SERVICE_ENTRY_POINTS使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PDEVICE_SERVICE_ENTRY_POINTS类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DeviceServiceEntry
int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
{
char* name;
char* path;
int i, length, ck;
RDPDR_SMARTCARD* device;
SMARTCARD_DEVICE* smartcard;
device = (RDPDR_SMARTCARD*) pEntryPoints->device;
name = device->Name;
path = device->Path;
/* TODO: check if server supports sc redirect (version 5.1) */
smartcard = (SMARTCARD_DEVICE*) malloc(sizeof(SMARTCARD_DEVICE));
ZeroMemory(smartcard, sizeof(SMARTCARD_DEVICE));
smartcard->device.type = RDPDR_DTYP_SMARTCARD;
smartcard->device.name = "SCARD";
smartcard->device.IRPRequest = smartcard_irp_request;
smartcard->device.Free = smartcard_free;
length = strlen(smartcard->device.name);
smartcard->device.data = Stream_New(NULL, length + 1);
Stream_Write(smartcard->device.data, "SCARD", 6);
smartcard->name = NULL;
smartcard->path = NULL;
if (path)
{
smartcard->path = path;
smartcard->name = name;
}
else if (name)
{
if (1 == sscanf(name, "%d", &ck))
smartcard->path = name;
else
smartcard->name = name;
}
smartcard->pIrpList = (PSLIST_HEADER) _aligned_malloc(sizeof(SLIST_HEADER), MEMORY_ALLOCATION_ALIGNMENT);
InitializeSListHead(smartcard->pIrpList);
smartcard->irpEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
smartcard->stopEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
smartcard->thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) smartcard_thread_func,
smartcard, CREATE_SUSPENDED, NULL);
smartcard->CompletionIds = list_new();
smartcard->CompletionIdsMutex = CreateMutex(NULL, FALSE, NULL);
pEntryPoints->RegisterDevice(pEntryPoints->devman, (DEVICE*) smartcard);
ResumeThread(smartcard->thread);
return 0;
}
示例2: drive_register_drive_path
void drive_register_drive_path(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints, char* name, char* path)
{
int i, length;
DRIVE_DEVICE* disk;
#ifdef WIN32
/*
* We cannot enter paths like c:\ because : is an arg separator
* thus, paths are entered as c+\ and the + is substituted here
*/
if ( path[1] == '+' )
{
if ( (path[0]>='a' && path[0]<='z') || (path[0]>='A' && path[0]<='Z') )
{
path[1] = ':';
}
}
#endif
if (name[0] && path[0])
{
disk = (DRIVE_DEVICE*) malloc(sizeof(DRIVE_DEVICE));
ZeroMemory(disk, sizeof(DRIVE_DEVICE));
disk->device.type = RDPDR_DTYP_FILESYSTEM;
disk->device.name = name;
disk->device.IRPRequest = drive_irp_request;
disk->device.Free = drive_free;
length = strlen(name);
disk->device.data = stream_new(length + 1);
for (i = 0; i <= length; i++)
stream_write_BYTE(disk->device.data, name[i] < 0 ? '_' : name[i]);
disk->path = path;
disk->files = list_new();
disk->pIrpList = (PSLIST_HEADER) _aligned_malloc(sizeof(SLIST_HEADER), MEMORY_ALLOCATION_ALIGNMENT);
InitializeSListHead(disk->pIrpList);
disk->irpEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
disk->stopEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
disk->thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) drive_thread_func, disk, CREATE_SUSPENDED, NULL);
pEntryPoints->RegisterDevice(pEntryPoints->devman, (DEVICE*) disk);
ResumeThread(disk->thread);
}
}
示例3: drive_register_drive_path
void drive_register_drive_path(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints, char* name, char* path)
{
int i, length;
DRIVE_DEVICE* drive;
#ifdef WIN32
/*
* We cannot enter paths like c:\ because : is an arg separator
* thus, paths are entered as c+\ and the + is substituted here
*/
if (path[1] == '+')
{
if ((path[0]>='a' && path[0]<='z') || (path[0]>='A' && path[0]<='Z'))
{
path[1] = ':';
}
}
#endif
if (name[0] && path[0])
{
drive = (DRIVE_DEVICE*) malloc(sizeof(DRIVE_DEVICE));
ZeroMemory(drive, sizeof(DRIVE_DEVICE));
drive->device.type = RDPDR_DTYP_FILESYSTEM;
drive->device.name = name;
drive->device.IRPRequest = drive_irp_request;
drive->device.Free = drive_free;
length = (int) strlen(name);
drive->device.data = Stream_New(NULL, length + 1);
for (i = 0; i <= length; i++)
Stream_Write_UINT8(drive->device.data, name[i] < 0 ? '_' : name[i]);
drive->path = path;
drive->files = ListDictionary_New(TRUE);
ListDictionary_ValueObject(drive->files)->fnObjectFree = (OBJECT_FREE_FN) drive_file_free;
drive->IrpQueue = MessageQueue_New(NULL);
drive->thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) drive_thread_func, drive, CREATE_SUSPENDED, NULL);
pEntryPoints->RegisterDevice(pEntryPoints->devman, (DEVICE*) drive);
ResumeThread(drive->thread);
}
}
示例4: DeviceServiceEntry
int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
{
char* name;
char* path;
int i, length;
RDPDR_PARALLEL* device;
PARALLEL_DEVICE* parallel;
device = (RDPDR_PARALLEL*) pEntryPoints->device;
name = device->Name;
path = device->Path;
if (!name || (name[0] == '*'))
{
/* TODO: implement auto detection of parallel ports */
return 0;
}
if (name[0] && path[0])
{
parallel = (PARALLEL_DEVICE*) calloc(1, sizeof(PARALLEL_DEVICE));
if (!parallel)
return -1;
parallel->device.type = RDPDR_DTYP_PARALLEL;
parallel->device.name = name;
parallel->device.IRPRequest = parallel_irp_request;
parallel->device.Free = parallel_free;
length = strlen(name);
parallel->device.data = Stream_New(NULL, length + 1);
for (i = 0; i <= length; i++)
Stream_Write_UINT8(parallel->device.data, name[i] < 0 ? '_' : name[i]);
parallel->path = path;
parallel->queue = MessageQueue_New(NULL);
pEntryPoints->RegisterDevice(pEntryPoints->devman, (DEVICE*) parallel);
parallel->thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) parallel_thread_func, (void*) parallel, 0, NULL);
}
return 0;
}
示例5: DeviceServiceEntry
int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
{
int i, len;
char* name;
char* path;
RDPDR_SERIAL* device;
SERIAL_DEVICE* serial;
device = (RDPDR_SERIAL*) pEntryPoints->device;
name = device->Name;
path = device->Path;
if ((name && name[0]) && (path && path[0]))
{
serial = (SERIAL_DEVICE*) malloc(sizeof(SERIAL_DEVICE));
ZeroMemory(serial, sizeof(SERIAL_DEVICE));
serial->device.type = RDPDR_DTYP_SERIAL;
serial->device.name = name;
serial->device.IRPRequest = serial_irp_request;
serial->device.Free = serial_free;
len = strlen(name);
serial->device.data = Stream_New(NULL, len + 1);
for (i = 0; i <= len; i++)
Stream_Write_UINT8(serial->device.data, name[i] < 0 ? '_' : name[i]);
serial->path = path;
serial->queue = Queue_New(TRUE, -1, -1);
serial->pending_irps = list_new();
serial->stopEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
serial->newEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
pEntryPoints->RegisterDevice(pEntryPoints->devman, (DEVICE*) serial);
serial->thread = CreateThread(NULL, 0,
(LPTHREAD_START_ROUTINE) serial_thread_func, (void*) serial, 0, NULL);
serial->mthread = NULL;
}
return 0;
}
示例6: DeviceServiceEntry
int
DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
{
SCARD_DEVICE* scard;
char* name;
char* path;
int i, length;
name = (char *)pEntryPoints->plugin_data->data[1];
path = (char *)pEntryPoints->plugin_data->data[2];
if (name)
{
/* TODO: check if server supports sc redirect (version 5.1) */
scard = xnew(SCARD_DEVICE);
scard->device.type = RDPDR_DTYP_SMARTCARD;
scard->device.name = "SCARD";
scard->device.IRPRequest = scard_irp_request;
scard->device.Free = scard_free;
length = strlen(scard->device.name);
scard->device.data = stream_new(length + 1);
for (i = 0; i <= length; i++)
stream_write_uint8(scard->device.data, name[i] < 0 ? '_' : name[i]);
scard->path = path;
scard->irp_list = list_new();
scard->thread = freerdp_thread_new();
scard->CompletionIds = list_new();
scard->CompletionIdsMutex = freerdp_mutex_new();
pEntryPoints->RegisterDevice(pEntryPoints->devman, (DEVICE *)scard);
freerdp_thread_start(scard->thread, scard_thread_func, scard);
}
return 0;
}
示例7: DeviceServiceEntry
int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
{
char* name;
char* path;
int i, length;
RDPDR_PARALLEL* device;
PARALLEL_DEVICE* parallel;
device = (RDPDR_PARALLEL*) pEntryPoints->device;
name = device->Name;
path = device->Path;
if (name[0] && path[0])
{
parallel = (PARALLEL_DEVICE*) malloc(sizeof(PARALLEL_DEVICE));
ZeroMemory(parallel, sizeof(PARALLEL_DEVICE));
parallel->device.type = RDPDR_DTYP_PARALLEL;
parallel->device.name = name;
parallel->device.IRPRequest = parallel_irp_request;
parallel->device.Free = parallel_free;
length = strlen(name);
parallel->device.data = stream_new(length + 1);
for (i = 0; i <= length; i++)
stream_write_BYTE(parallel->device.data, name[i] < 0 ? '_' : name[i]);
parallel->path = path;
parallel->pIrpList = (PSLIST_HEADER) _aligned_malloc(sizeof(SLIST_HEADER), MEMORY_ALLOCATION_ALIGNMENT);
InitializeSListHead(parallel->pIrpList);
parallel->thread = freerdp_thread_new();
pEntryPoints->RegisterDevice(pEntryPoints->devman, (DEVICE*) parallel);
freerdp_thread_start(parallel->thread, parallel_thread_func, parallel);
}
return 0;
}
示例8: DeviceServiceEntry
int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
{
SERIAL_DEVICE* serial;
char* name;
char* path;
int i, len;
name = (char*)pEntryPoints->plugin_data->data[1];
path = (char*)pEntryPoints->plugin_data->data[2];
if (name[0] && path[0])
{
serial = xnew(SERIAL_DEVICE);
serial->device.type = RDPDR_DTYP_SERIAL;
serial->device.name = name;
serial->device.IRPRequest = serial_irp_request;
serial->device.Free = serial_free;
len = strlen(name);
serial->device.data = stream_new(len + 1);
for (i = 0; i <= len; i++)
stream_write_uint8(serial->device.data, name[i] < 0 ? '_' : name[i]);
serial->path = path;
serial->irp_list = list_new();
serial->pending_irps = list_new();
serial->thread = freerdp_thread_new();
serial->in_event = wait_obj_new();
pEntryPoints->RegisterDevice(pEntryPoints->devman, (DEVICE*)serial);
freerdp_thread_start(serial->thread, serial_thread_func, serial);
}
return 0;
}
示例9: DeviceServiceEntry
int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
{
char* name;
char* path;
int i, length;
PARALLEL_DEVICE* parallel;
name = (char*) pEntryPoints->plugin_data->data[1];
path = (char*) pEntryPoints->plugin_data->data[2];
if (name[0] && path[0])
{
parallel = xnew(PARALLEL_DEVICE);
parallel->device.type = RDPDR_DTYP_PARALLEL;
parallel->device.name = name;
parallel->device.IRPRequest = parallel_irp_request;
parallel->device.Free = parallel_free;
length = strlen(name);
parallel->device.data = stream_new(length + 1);
for (i = 0; i <= length; i++)
stream_write_uint8(parallel->device.data, name[i] < 0 ? '_' : name[i]);
parallel->path = path;
parallel->irp_list = list_new();
parallel->thread = freerdp_thread_new();
pEntryPoints->RegisterDevice(pEntryPoints->devman, (DEVICE*) parallel);
freerdp_thread_start(parallel->thread, parallel_thread_func, parallel);
}
return 0;
}
示例10: printer_register
void printer_register(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints, rdpPrinter* printer)
{
char* port;
UINT32 Flags;
int DriverNameLen;
WCHAR* DriverName = NULL;
int PrintNameLen;
WCHAR* PrintName = NULL;
UINT32 CachedFieldsLen;
BYTE* CachedPrinterConfigData;
PRINTER_DEVICE* printer_dev;
port = malloc(10);
snprintf(port, 10, "PRN%d", printer->id);
printer_dev = (PRINTER_DEVICE*) malloc(sizeof(PRINTER_DEVICE));
ZeroMemory(printer_dev, sizeof(PRINTER_DEVICE));
printer_dev->device.type = RDPDR_DTYP_PRINT;
printer_dev->device.name = port;
printer_dev->device.IRPRequest = printer_irp_request;
printer_dev->device.Free = printer_free;
printer_dev->printer = printer;
CachedFieldsLen = 0;
CachedPrinterConfigData = NULL;
DEBUG_SVC("Printer %s registered", printer->name);
Flags = 0;
if (printer->is_default)
Flags |= RDPDR_PRINTER_ANNOUNCE_FLAG_DEFAULTPRINTER;
DriverNameLen = ConvertToUnicode(CP_UTF8, 0, printer->driver, -1, &DriverName, 0) * 2;
PrintNameLen = ConvertToUnicode(CP_UTF8, 0, printer->name, -1, &PrintName, 0) * 2;
printer_dev->device.data = stream_new(28 + DriverNameLen + PrintNameLen + CachedFieldsLen);
stream_write_UINT32(printer_dev->device.data, Flags);
stream_write_UINT32(printer_dev->device.data, 0); /* CodePage, reserved */
stream_write_UINT32(printer_dev->device.data, 0); /* PnPNameLen */
stream_write_UINT32(printer_dev->device.data, DriverNameLen + 2);
stream_write_UINT32(printer_dev->device.data, PrintNameLen + 2);
stream_write_UINT32(printer_dev->device.data, CachedFieldsLen);
stream_write(printer_dev->device.data, DriverName, DriverNameLen);
stream_write_UINT16(printer_dev->device.data, 0);
stream_write(printer_dev->device.data, PrintName, PrintNameLen);
stream_write_UINT16(printer_dev->device.data, 0);
if (CachedFieldsLen > 0)
{
stream_write(printer_dev->device.data, CachedPrinterConfigData, CachedFieldsLen);
}
free(DriverName);
free(PrintName);
printer_dev->pIrpList = (PSLIST_HEADER) _aligned_malloc(sizeof(SLIST_HEADER), MEMORY_ALLOCATION_ALIGNMENT);
InitializeSListHead(printer_dev->pIrpList);
printer_dev->thread = freerdp_thread_new();
pEntryPoints->RegisterDevice(pEntryPoints->devman, (DEVICE*) printer_dev);
freerdp_thread_start(printer_dev->thread, printer_thread_func, printer_dev);
}
示例11: DeviceServiceEntry
/**
* Function description
*
* @return 0 on success, otherwise a Win32 error code
*/
UINT DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
{
char* name;
char* path;
char* driver;
RDPDR_SERIAL* device;
#if defined __linux__ && !defined ANDROID
int i, len;
SERIAL_DEVICE* serial;
#endif /* __linux__ */
UINT error = CHANNEL_RC_OK;
device = (RDPDR_SERIAL*) pEntryPoints->device;
name = device->Name;
path = device->Path;
driver = device->Driver;
if (!name || (name[0] == '*'))
{
/* TODO: implement auto detection of serial ports */
return CHANNEL_RC_OK;
}
if ((name && name[0]) && (path && path[0]))
{
wLog* log;
WLog_Init();
log = WLog_Get("com.freerdp.channel.serial.client");
WLog_Print(log, WLOG_DEBUG, "initializing");
#ifndef __linux__ /* to be removed */
WLog_Print(log, WLOG_WARN,
"Serial ports redirection not supported on this platform.");
return CHANNEL_RC_INITIALIZATION_ERROR;
#else /* __linux __ */
WLog_Print(log, WLOG_DEBUG, "Defining %s as %s", name, path);
if (!DefineCommDevice(name /* eg: COM1 */, path /* eg: /dev/ttyS0 */))
{
WLog_ERR(TAG, "DefineCommDevice failed!");
return ERROR_INTERNAL_ERROR;
}
serial = (SERIAL_DEVICE*) calloc(1, sizeof(SERIAL_DEVICE));
if (!serial)
{
WLog_ERR(TAG, "calloc failed!");
return CHANNEL_RC_NO_MEMORY;
}
serial->log = log;
serial->device.type = RDPDR_DTYP_SERIAL;
serial->device.name = name;
serial->device.IRPRequest = serial_irp_request;
serial->device.Free = serial_free;
serial->rdpcontext = pEntryPoints->rdpcontext;
len = strlen(name);
serial->device.data = Stream_New(NULL, len + 1);
if (!serial->device.data)
{
WLog_ERR(TAG, "calloc failed!");
error = CHANNEL_RC_NO_MEMORY;
goto error_out;
}
for (i = 0; i <= len; i++)
Stream_Write_UINT8(serial->device.data, name[i] < 0 ? '_' : name[i]);
if (driver != NULL)
{
if (_stricmp(driver, "Serial") == 0)
serial->ServerSerialDriverId = SerialDriverSerialSys;
else if (_stricmp(driver, "SerCx") == 0)
serial->ServerSerialDriverId = SerialDriverSerCxSys;
else if (_stricmp(driver, "SerCx2") == 0)
serial->ServerSerialDriverId = SerialDriverSerCx2Sys;
else
{
assert(FALSE);
WLog_Print(serial->log, WLOG_DEBUG,
"Unknown server's serial driver: %s. SerCx2 will be used", driver);
serial->ServerSerialDriverId = SerialDriverSerialSys;
}
}
else
{
/* default driver */
serial->ServerSerialDriverId = SerialDriverSerialSys;
}
if (device->Permissive != NULL)
{
if (_stricmp(device->Permissive, "permissive") == 0)
{
serial->permissive = TRUE;
//.........这里部分代码省略.........
示例12: DeviceServiceEntry
/**
* Function description
*
* @return 0 on success, otherwise a Win32 error code
*/
UINT DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
{
SMARTCARD_DEVICE* smartcard = NULL;
size_t length;
UINT error = CHANNEL_RC_NO_MEMORY;
if (!sSmartcard)
{
wObject* obj;
smartcard = (SMARTCARD_DEVICE*) calloc(1, sizeof(SMARTCARD_DEVICE));
if (!smartcard)
{
WLog_ERR(TAG, "calloc failed!");
return CHANNEL_RC_NO_MEMORY;
}
smartcard->device.type = RDPDR_DTYP_SMARTCARD;
smartcard->device.name = "SCARD";
smartcard->device.IRPRequest = smartcard_irp_request;
smartcard->device.Init = smartcard_init;
smartcard->device.Free = smartcard_free;
smartcard->names = LinkedList_New();
smartcard->rdpcontext = pEntryPoints->rdpcontext;
length = strlen(smartcard->device.name);
smartcard->device.data = Stream_New(NULL, length + 1);
if (!smartcard->device.data || !smartcard->names)
{
WLog_ERR(TAG, "Stream_New failed!");
goto fail;
}
Stream_Write(smartcard->device.data, "SCARD", 6);
smartcard->IrpQueue = MessageQueue_New(NULL);
if (!smartcard->IrpQueue)
{
WLog_ERR(TAG, "MessageQueue_New failed!");
goto fail;
}
smartcard->CompletedIrpQueue = Queue_New(TRUE, -1, -1);
if (!smartcard->CompletedIrpQueue)
{
WLog_ERR(TAG, "Queue_New failed!");
goto fail;
}
smartcard->rgSCardContextList = ListDictionary_New(TRUE);
if (!smartcard->rgSCardContextList)
{
WLog_ERR(TAG, "ListDictionary_New failed!");
goto fail;
}
obj = ListDictionary_ValueObject(smartcard->rgSCardContextList);
obj->fnObjectFree = smartcard_context_free;
smartcard->rgOutstandingMessages = ListDictionary_New(TRUE);
if (!smartcard->rgOutstandingMessages)
{
WLog_ERR(TAG, "ListDictionary_New failed!");
goto fail;
}
if ((error = pEntryPoints->RegisterDevice(pEntryPoints->devman, &smartcard->device)))
{
WLog_ERR(TAG, "RegisterDevice failed!");
goto fail;
}
smartcard->thread = CreateThread(NULL, 0,
smartcard_thread_func,
smartcard, CREATE_SUSPENDED, NULL);
if (!smartcard->thread)
{
WLog_ERR(TAG, "ListDictionary_New failed!");
error = ERROR_INTERNAL_ERROR;
goto fail;
}
ResumeThread(smartcard->thread);
}
else
smartcard = sSmartcard;
if (pEntryPoints->device->Name)
LinkedList_AddLast(smartcard->names, pEntryPoints->device->Name);
sSmartcard = smartcard;
return CHANNEL_RC_OK;
//.........这里部分代码省略.........
示例13: printer_register
void printer_register(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints, rdpPrinter* printer) {
PRINTER_DEVICE* printer_dev;
char* port;
UNICONV* uniconv;
uint32 Flags;
size_t DriverNameLen;
char* DriverName;
size_t PrintNameLen;
char* PrintName;
uint32 CachedFieldsLen;
uint8* CachedPrinterConfigData;
port = xmalloc(10);
snprintf(port, 10, "PRN%d", printer->id);
printer_dev = xnew(PRINTER_DEVICE);
printer_dev->device.type = RDPDR_DTYP_PRINT;
printer_dev->device.name = port;
printer_dev->device.IRPRequest = printer_irp_request;
printer_dev->device.Free = printer_free;
printer_dev->printer = printer;
CachedFieldsLen = 0;
CachedPrinterConfigData = NULL;
log_debug("Printer '%s' registered", printer->name);
Flags = 0;
if (printer->is_default)
Flags |= RDPDR_PRINTER_ANNOUNCE_FLAG_DEFAULTPRINTER;
uniconv = freerdp_uniconv_new();
DriverName = freerdp_uniconv_out(uniconv, printer->driver, &DriverNameLen);
PrintName = freerdp_uniconv_out(uniconv, printer->name, &PrintNameLen);
freerdp_uniconv_free(uniconv);
printer_dev->device.data = stream_new(28 + DriverNameLen + PrintNameLen + CachedFieldsLen);
stream_write_uint32(printer_dev->device.data, Flags);
stream_write_uint32(printer_dev->device.data, 0);
/* CodePage, reserved */
stream_write_uint32(printer_dev->device.data, 0);
/* PnPNameLen */
stream_write_uint32(printer_dev->device.data, DriverNameLen + 2);
stream_write_uint32(printer_dev->device.data, PrintNameLen + 2);
stream_write_uint32(printer_dev->device.data, CachedFieldsLen);
stream_write(printer_dev->device.data, DriverName, DriverNameLen);
stream_write_uint16(printer_dev->device.data, 0);
stream_write(printer_dev->device.data, PrintName, PrintNameLen);
stream_write_uint16(printer_dev->device.data, 0);
if (CachedFieldsLen > 0) {
stream_write(printer_dev->device.data, CachedPrinterConfigData, CachedFieldsLen);
}
xfree(DriverName);
xfree(PrintName);
printer_dev->irp_list = list_new();
printer_dev->thread = freerdp_thread_new();
pEntryPoints->RegisterDevice(pEntryPoints->devman, (DEVICE*) printer_dev);
freerdp_thread_start(printer_dev->thread, printer_thread_func, printer_dev);
}
示例14: DeviceServiceEntry
int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
{
char* name;
char* path;
int length, ck;
RDPDR_SMARTCARD* device;
SMARTCARD_DEVICE* smartcard;
device = (RDPDR_SMARTCARD*) pEntryPoints->device;
name = device->Name;
path = device->Path;
smartcard = (SMARTCARD_DEVICE*) calloc(1, sizeof(SMARTCARD_DEVICE));
if (!smartcard)
return -1;
smartcard->device.type = RDPDR_DTYP_SMARTCARD;
smartcard->device.name = "SCARD";
smartcard->device.IRPRequest = smartcard_irp_request;
smartcard->device.Init = smartcard_init;
smartcard->device.Free = smartcard_free;
length = strlen(smartcard->device.name);
smartcard->device.data = Stream_New(NULL, length + 1);
if (!smartcard->device.data)
goto error_device_data;
Stream_Write(smartcard->device.data, "SCARD", 6);
smartcard->name = NULL;
smartcard->path = NULL;
if (path)
{
smartcard->path = path;
smartcard->name = name;
}
else if (name)
{
if (1 == sscanf(name, "%d", &ck))
smartcard->path = name;
else
smartcard->name = name;
}
smartcard->IrpQueue = MessageQueue_New(NULL);
if (!smartcard->IrpQueue)
goto error_irp_queue;
smartcard->CompletedIrpQueue = Queue_New(TRUE, -1, -1);
if (!smartcard->CompletedIrpQueue)
goto error_completed_irp_queue;
smartcard->rgSCardContextList = ListDictionary_New(TRUE);
if (!smartcard->rgSCardContextList)
goto error_context_list;
ListDictionary_ValueObject(smartcard->rgSCardContextList)->fnObjectFree =
(OBJECT_FREE_FN) smartcard_context_free;
smartcard->rgOutstandingMessages = ListDictionary_New(TRUE);
if (!smartcard->rgOutstandingMessages)
goto error_outstanding_messages;
smartcard->thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) smartcard_thread_func,
smartcard, CREATE_SUSPENDED, NULL);
if (!smartcard->thread)
goto error_thread;
pEntryPoints->RegisterDevice(pEntryPoints->devman, (DEVICE*) smartcard);
ResumeThread(smartcard->thread);
return 0;
error_thread:
ListDictionary_Free(smartcard->rgOutstandingMessages);
error_outstanding_messages:
ListDictionary_Free(smartcard->rgSCardContextList);
error_context_list:
Queue_Free(smartcard->CompletedIrpQueue);
error_completed_irp_queue:
MessageQueue_Free(smartcard->IrpQueue);
error_irp_queue:
Stream_Free(smartcard->device.data, TRUE);
error_device_data:
free(smartcard);
return -1;
}
示例15: drive_register_drive_path
/**
* Function description
*
* @return 0 on success, otherwise a Win32 error code
*/
UINT drive_register_drive_path(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints,
char* name, char* path)
{
int i, length;
DRIVE_DEVICE* drive;
UINT error;
#ifdef WIN32
/*
* We cannot enter paths like c:\ because : is an arg separator
* thus, paths are entered as c+\ and the + is substituted here
*/
if (path[1] == '+')
{
if ((path[0] >= 'a' && path[0] <= 'z') || (path[0] >= 'A' && path[0] <= 'Z'))
{
path[1] = ':';
}
}
#endif
if (name[0] && path[0])
{
drive = (DRIVE_DEVICE*) calloc(1, sizeof(DRIVE_DEVICE));
if (!drive)
{
WLog_ERR(TAG, "calloc failed!");
return CHANNEL_RC_NO_MEMORY;
}
drive->device.type = RDPDR_DTYP_FILESYSTEM;
drive->device.name = name;
drive->device.IRPRequest = drive_irp_request;
drive->device.Free = drive_free;
drive->rdpcontext = pEntryPoints->rdpcontext;
length = (int) strlen(name);
drive->device.data = Stream_New(NULL, length + 1);
if (!drive->device.data)
{
WLog_ERR(TAG, "Stream_New failed!");
error = CHANNEL_RC_NO_MEMORY;
goto out_error;
}
for (i = 0; i <= length; i++)
Stream_Write_UINT8(drive->device.data, name[i] < 0 ? '_' : name[i]);
drive->path = path;
drive->files = ListDictionary_New(TRUE);
if (!drive->files)
{
WLog_ERR(TAG, "ListDictionary_New failed!");
error = CHANNEL_RC_NO_MEMORY;
goto out_error;
}
ListDictionary_ValueObject(drive->files)->fnObjectFree =
(OBJECT_FREE_FN) drive_file_free;
drive->IrpQueue = MessageQueue_New(NULL);
if (!drive->IrpQueue)
{
WLog_ERR(TAG, "ListDictionary_New failed!");
error = CHANNEL_RC_NO_MEMORY;
goto out_error;
}
if ((error = pEntryPoints->RegisterDevice(pEntryPoints->devman,
(DEVICE*) drive)))
{
WLog_ERR(TAG, "RegisterDevice failed with error %u!", error);
goto out_error;
}
if (!(drive->thread = CreateThread(NULL, 0,
(LPTHREAD_START_ROUTINE) drive_thread_func, drive, CREATE_SUSPENDED, NULL)))
{
WLog_ERR(TAG, "CreateThread failed!");
goto out_error;
}
ResumeThread(drive->thread);
}
return CHANNEL_RC_OK;
out_error:
MessageQueue_Free(drive->IrpQueue);
ListDictionary_Free(drive->files);
free(drive);
return error;
}