win32: Add the following options for the disk plugin:

disk:<name>:* will share all windows drives
disk:<name>:% will share the home directory of the user

In addition c+\xxx in the pathname will be replaced by c:\xxx to avoid conflicts with option separators
This commit is contained in:
richterger 2012-10-02 09:02:17 +02:00
parent fbe8a2eaae
commit 6bb2a8f6b0

View File

@ -263,7 +263,7 @@ static void disk_process_irp_read(DISK_DEVICE* disk, IRP* irp)
if (Length > 0)
{
stream_check_size(irp->output, Length);
stream_check_size(irp->output, (int)Length);
stream_write(irp->output, buffer, Length);
}
@ -647,19 +647,23 @@ static void disk_free(DEVICE* device)
xfree(disk);
}
#ifdef WITH_STATIC_PLUGINS
int disk_entry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
#else
int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
#endif
{
char* name;
char* path;
int i, length;
DISK_DEVICE* disk;
name = (char*) pEntryPoints->plugin_data->data[1];
path = (char*) pEntryPoints->plugin_data->data[2];
void disk_register_disk_path(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints, char *name, char *path)
{
DISK_DEVICE* disk;
int i, length ;
#ifdef WIN32
// We cannot enter pathes like c:\ because : is an arg separator
// thus, pathes are entered as c+\ and the + is substitutet 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])
{
@ -687,8 +691,66 @@ int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
pEntryPoints->RegisterDevice(pEntryPoints->devman, (DEVICE*) disk);
ResumeThread(disk->thread);
ResumeThread(disk->thread);
}
return 0;
}
#ifdef WITH_STATIC_PLUGINS
int disk_entry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
#else
int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
#endif
{
char* name;
char* path;
int i ;
#ifdef WIN32
char devlist[512], buf[512];
char *dev;
int len ;
#endif
name = (char*) pEntryPoints->plugin_data->data[1];
path = (char*) pEntryPoints->plugin_data->data[2];
#ifndef WIN32
disk_register_disk_path(pEntryPoints, name, path);
#else
// Special case: path[0] == '*' -> export all drives
// Special case: path[0] == '%' -> user home dir
if( path[0] == '%' )
{
_snprintf(buf, sizeof(buf), "%s\\", getenv("USERPROFILE"));
disk_register_disk_path(pEntryPoints, name, xstrdup(buf));
}
else if( path[0] == '*' )
{
// Enumerate all devices:
GetLogicalDriveStringsA(sizeof(devlist)-1, devlist);
for(dev=devlist, i=0; *dev; dev += 4, i++ )
{
if( *dev > 'B')
{ // Supress disk drives A and B to avoid pesty messages
_snprintf(buf, sizeof(buf)-4, "%s", name);
len=strlen(buf);
buf[len] = '_';
buf[len+1] = dev[0];
buf[len+2] = 0;
buf[len+3] = 0;
disk_register_disk_path(pEntryPoints, xstrdup(buf), xstrdup(dev));
}
}
}
else
{
disk_register_disk_path(pEntryPoints, name, path);
}
#endif
return 0;
}