/[winpt]/trunk/Src/wptFileDisk.c
ViewVC logotype

Diff of /trunk/Src/wptFileDisk.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 35 by twoaday, Mon Jan 31 11:02:21 2005 UTC revision 36 by werner, Thu Oct 27 15:25:13 2005 UTC
# Line 1  Line 1 
1  /*  /*
2      Control program for a virtual disk driver for Windows NT/2000/XP.      Control program for a virtual disk driver for Windows NT/2000/XP.
3      Copyright (C) 1999, 2000, 2001, 2002 Bo Brant�n.      Copyright (C) 1999, 2000, 2001, 2002 Bo Brant�n.
4    
5      Heavily modified for the use with Cryptdisk by Timo Schulz      Heavily modified for the use with Cryptdisk by Timo Schulz
6      (C) 2004 Timo Schulz      (C) 2004 Timo Schulz
7    
8      This program is free software; you can redistribute it and/or modify      This program is free software; you can redistribute it and/or modify
9      it under the terms of the GNU General Public License as published by      it under the terms of the GNU General Public License as published by
10      the Free Software Foundation; either version 2 of the License, or      the Free Software Foundation; either version 2 of the License, or
11      (at your option) any later version.      (at your option) any later version.
12      This program is distributed in the hope that it will be useful,      This program is distributed in the hope that it will be useful,
13      but WITHOUT ANY WARRANTY; without even the implied warranty of      but WITHOUT ANY WARRANTY; without even the implied warranty of
14      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15      GNU General Public License for more details.      GNU General Public License for more details.
16      You should have received a copy of the GNU General Public License      You should have received a copy of the GNU General Public License
17      along with this program; if not, write to the Free Software      along with this program; if not, write to the Free Software
18      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */  */
20    
21  #include <windows.h>  #ifdef HAVE_CONFIG_H
22  #include <winioctl.h>  #include <config.h>
23  #include <stdio.h>  #endif
24  #include <sys/types.h>  
25    #include <windows.h>
26  #include "openpgp.h"  #include <windows.h>
27    #include <winioctl.h>
28  /* remember to change the values in wptErrors.h also */  #include <stdio.h>
29  #define CDISK_ERR_LOCK   201  #include <sys/types.h>
30  #define CDISK_ERR_MOUNT  202  
31  #define CDISK_ERR_UMOUNT 203  #include "openpgp.h"
32  #define CDISK_ERR_OPEN   204  
33  #define CDISK_ERR_BUSY   205  /* remember to change the values in wptErrors.h also */
34  #define CDISK_ERR_QUERY  206  #define CDISK_ERR_LOCK   201
35    #define CDISK_ERR_MOUNT  202
36  #define MAX_KEYS                64  #define CDISK_ERR_UMOUNT 203
37  #define MAX_KEYHASH             32  #define CDISK_ERR_OPEN   204
38  #define MAX_KEY_LENGTH          50  #define CDISK_ERR_BUSY   205
39  #define CCVERSION               0x04  #define CDISK_ERR_QUERY  206
40    
41  #define DEVICE_BASE_NAME    "\\FileDisk"  #define MAX_KEYS                64
42  #define DEVICE_DIR_NAME     "\\Device"          DEVICE_BASE_NAME  #define MAX_KEYHASH             32
43  #define DEVICE_NAME_PREFIX  DEVICE_DIR_NAME     DEVICE_BASE_NAME  #define MAX_KEY_LENGTH          50
44    #define CCVERSION               0x04
45  #define FILE_DEVICE_FILE_DISK       0x8000  
46    #define DEVICE_BASE_NAME    "\\FileDisk"
47  #define IOCTL_FILE_DISK_OPEN_FILE   CTL_CODE(FILE_DEVICE_FILE_DISK, 0x800, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)  #define DEVICE_DIR_NAME     "\\Device"          DEVICE_BASE_NAME
48  #define IOCTL_FILE_DISK_CLOSE_FILE  CTL_CODE(FILE_DEVICE_FILE_DISK, 0x801, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)  #define DEVICE_NAME_PREFIX  DEVICE_DIR_NAME     DEVICE_BASE_NAME
49  #define IOCTL_FILE_DISK_QUERY_FILE  CTL_CODE(FILE_DEVICE_FILE_DISK, 0x802, METHOD_BUFFERED, FILE_READ_ACCESS)  
50    #define FILE_DEVICE_FILE_DISK       0x8000
51  typedef struct _OPEN_FILE_INFORMATION {  
52      USHORT          version;  #define IOCTL_FILE_DISK_OPEN_FILE   CTL_CODE(FILE_DEVICE_FILE_DISK, 0x800, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
53      LARGE_INTEGER   FileSize;  #define IOCTL_FILE_DISK_CLOSE_FILE  CTL_CODE(FILE_DEVICE_FILE_DISK, 0x801, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
54      BOOLEAN         ReadOnly;  #define IOCTL_FILE_DISK_QUERY_FILE  CTL_CODE(FILE_DEVICE_FILE_DISK, 0x802, METHOD_BUFFERED, FILE_READ_ACCESS)
55      USHORT          KeyType;            //0 None 1 2Fish 2 AES256  
56      USHORT          KeyNum;  typedef struct _OPEN_FILE_INFORMATION {
57      USHORT          KeyLength;      USHORT          version;
58      USHORT          FileNameLength;      LARGE_INTEGER   FileSize;
59      UCHAR           Key[MAX_KEYS][MAX_KEYHASH];      BOOLEAN         ReadOnly;
60      UCHAR           DriveLetter;      USHORT          KeyType;            //0 None 1 2Fish 2 AES256
61      UCHAR           FileName[1];      USHORT          KeyNum;
62  } OPEN_FILE_INFORMATION, *POPEN_FILE_INFORMATION;      USHORT          KeyLength;
63        USHORT          FileNameLength;
64  static void      UCHAR           Key[MAX_KEYS][MAX_KEYHASH];
65  print_lasterr (char * prefix)      UCHAR           DriveLetter;
66  {      UCHAR           FileName[1];
67      LPVOID msg;  } OPEN_FILE_INFORMATION, *POPEN_FILE_INFORMATION;
68    
69      FormatMessage(  static void
70          FORMAT_MESSAGE_ALLOCATE_BUFFER |  print_lasterr (char * prefix)
71          FORMAT_MESSAGE_FROM_SYSTEM |  {
72          FORMAT_MESSAGE_IGNORE_INSERTS,      LPVOID msg;
73          NULL,  
74          GetLastError(),      FormatMessage(
75          0,          FORMAT_MESSAGE_ALLOCATE_BUFFER |
76          (LPTSTR) &msg,          FORMAT_MESSAGE_FROM_SYSTEM |
77          0,          FORMAT_MESSAGE_IGNORE_INSERTS,
78          NULL          NULL,
79          );          GetLastError(),
80      MessageBox (NULL, (LPTSTR)msg, prefix, MB_ICONERROR|MB_OK);          0,
81      LocalFree (msg);          (LPTSTR) &msg,
82  }          0,
83            NULL
84            );
85  static void      MessageBox (NULL, (LPTSTR)msg, prefix, MB_ICONERROR|MB_OK);
86  add_key (POPEN_FILE_INFORMATION ka, const char * key, size_t len)      LocalFree (msg);
87  {  }
88      gpg_md_t md;  
89    
90      if (ka->KeyNum >= MAX_KEYS)  static void
91          return;  add_key (POPEN_FILE_INFORMATION ka, const char * key, size_t len)
92    {
93      switch (ka->KeyType) {      gpg_md_t md;
94      case 1: /* 2fish */  
95          md = gpg_md_open (MD_RMD160);      if (ka->KeyNum >= MAX_KEYS)
96          ka->KeyLength=20;          return;
97          break;  
98      case 2: /* AES256 */      switch (ka->KeyType) {
99          md = gpg_md_open (MD_SHA512);      case 1: /* 2fish */
100          ka->KeyLength=32;                md = gpg_md_open (MD_RMD160);
101          break;          ka->KeyLength=20;
102      case 3: /* AES128 */          break;
103          md = gpg_md_open (MD_SHA256);      case 2: /* AES256 */
104          ka->KeyLength=16;          md = gpg_md_open (MD_SHA512);
105          break;          ka->KeyLength=32;      
106      case 4: /* AES192 */          break;
107          ka->KeyLength=24;      case 3: /* AES128 */
108          md = gpg_md_open (MD_SHA384);          md = gpg_md_open (MD_SHA256);
109          break;          ka->KeyLength=16;
110      }          break;
111      gpg_md_write (md, (char *)key, len);      case 4: /* AES192 */
112      gpg_md_final (md);          ka->KeyLength=24;
113      memcpy (ka->Key[ka->KeyNum++], gpg_md_read (md), ka->KeyLength);          md = gpg_md_open (MD_SHA384);
114      gpg_md_close (md);          break;
115  }      }
116        gpg_md_write (md, (char *)key, len);
117        gpg_md_final (md);
118  int      memcpy (ka->Key[ka->KeyNum++], gpg_md_read (md), ka->KeyLength);
119  filedisk_mount (int                     DeviceNumber,      gpg_md_close (md);
120                  POPEN_FILE_INFORMATION  ofi,  }
121                  char                    drivelet,  
122                  BOOLEAN                 CdImage)  
123  {  int
124      char    VolumeName[] = "\\\\.\\ :";  filedisk_mount (int                     DeviceNumber,
125      char    DeviceName[255];                  POPEN_FILE_INFORMATION  ofi,
126      HANDLE  Device;                  char                    drivelet,
127      DWORD   BytesReturned;                  BOOLEAN                 CdImage)
128    {
129      VolumeName[4] = drivelet;      char    VolumeName[] = "\\\\.\\ :";
130        char    DeviceName[255];
131      Device = CreateFile (VolumeName,      HANDLE  Device;
132                           GENERIC_READ | GENERIC_WRITE,      DWORD   BytesReturned;
133                           FILE_SHARE_READ | FILE_SHARE_WRITE,  
134                           NULL,      VolumeName[4] = drivelet;
135                           OPEN_EXISTING,  
136                           FILE_FLAG_NO_BUFFERING,      Device = CreateFile (VolumeName,
137                           NULL);                           GENERIC_READ | GENERIC_WRITE,
138      if (Device != INVALID_HANDLE_VALUE) {                           FILE_SHARE_READ | FILE_SHARE_WRITE,
139          SetLastError (ERROR_BUSY);                           NULL,
140          print_lasterr (&VolumeName[4]);                           OPEN_EXISTING,
141          return CDISK_ERR_BUSY;                           FILE_FLAG_NO_BUFFERING,
142      }                           NULL);
143        if (Device != INVALID_HANDLE_VALUE) {
144      if (CdImage)          SetLastError (ERROR_BUSY);
145          sprintf (DeviceName, DEVICE_NAME_PREFIX "Cd" "%u", DeviceNumber);          print_lasterr (&VolumeName[4]);
146      else          return CDISK_ERR_BUSY;
147          sprintf (DeviceName, DEVICE_NAME_PREFIX "%u", DeviceNumber);      }
148    
149      if (!DefineDosDevice (DDD_RAW_TARGET_PATH,      if (CdImage)
150                            &VolumeName[4],          sprintf (DeviceName, DEVICE_NAME_PREFIX "Cd" "%u", DeviceNumber);
151                            DeviceName)) {      else
152          print_lasterr (&VolumeName[4]);          sprintf (DeviceName, DEVICE_NAME_PREFIX "%u", DeviceNumber);
153          return CDISK_ERR_OPEN;  
154      }      if (!DefineDosDevice (DDD_RAW_TARGET_PATH,
155                              &VolumeName[4],
156      Device = CreateFile (VolumeName,                            DeviceName)) {
157                           GENERIC_READ | GENERIC_WRITE,          print_lasterr (&VolumeName[4]);
158                           FILE_SHARE_READ | FILE_SHARE_WRITE,          return CDISK_ERR_OPEN;
159                           NULL,      }
160                           OPEN_EXISTING,  
161                           FILE_FLAG_NO_BUFFERING,      Device = CreateFile (VolumeName,
162                           NULL);                           GENERIC_READ | GENERIC_WRITE,
163                             FILE_SHARE_READ | FILE_SHARE_WRITE,
164      if (Device == INVALID_HANDLE_VALUE) {                           NULL,
165          print_lasterr (&VolumeName[4]);                           OPEN_EXISTING,
166          DefineDosDevice (DDD_REMOVE_DEFINITION, &VolumeName[4], NULL);                           FILE_FLAG_NO_BUFFERING,
167          return CDISK_ERR_OPEN;                           NULL);
168      }  
169        if (Device == INVALID_HANDLE_VALUE) {
170      if (!DeviceIoControl (Device,          print_lasterr (&VolumeName[4]);
171                            IOCTL_FILE_DISK_OPEN_FILE,          DefineDosDevice (DDD_REMOVE_DEFINITION, &VolumeName[4], NULL);
172                            ofi,          return CDISK_ERR_OPEN;
173                            sizeof(OPEN_FILE_INFORMATION) + ofi->FileNameLength - 1,      }
174                            NULL, 0, &BytesReturned, NULL)) {  
175          print_lasterr ("Cryptdisk Error");      if (!DeviceIoControl (Device,
176          DefineDosDevice (DDD_REMOVE_DEFINITION, &VolumeName[4], NULL);                            IOCTL_FILE_DISK_OPEN_FILE,
177          return CDISK_ERR_MOUNT;                            ofi,
178      }                            sizeof(OPEN_FILE_INFORMATION) + ofi->FileNameLength - 1,
179                              NULL, 0, &BytesReturned, NULL)) {
180      return 0;          print_lasterr ("Cryptdisk Error");
181  }          DefineDosDevice (DDD_REMOVE_DEFINITION, &VolumeName[4], NULL);
182            return CDISK_ERR_MOUNT;
183        }
184  static int  
185  filedisk_unmount2 (char drivelet, int flags, int forced)      return 0;
186  {  }
187      char    VolumeName[60] = "\\\\.\\ :";  
188      HANDLE  Device;  
189      DWORD   BytesReturned;  static int
190    filedisk_unmount2 (char drivelet, int flags, int forced)
191      if (!flags)  {
192          VolumeName[4] = drivelet;      char    VolumeName[60] = "\\\\.\\ :";
193      else if (flags & 1)      HANDLE  Device;
194          sprintf(VolumeName,"\\\\.\\FileDisk%d", drivelet);      DWORD   BytesReturned;
195      else if (flags & 2)  
196          sprintf(VolumeName,"\\\\.\\FileDiskCd%d",drivelet);      if (!flags)
197            VolumeName[4] = drivelet;
198      Device = CreateFile (VolumeName,      else if (flags & 1)
199                           GENERIC_READ | GENERIC_WRITE,          sprintf(VolumeName,"\\\\.\\FileDisk%d", drivelet);
200                           FILE_SHARE_READ | FILE_SHARE_WRITE,      else if (flags & 2)
201                           NULL,          sprintf(VolumeName,"\\\\.\\FileDiskCd%d",drivelet);
202                           OPEN_EXISTING,  
203                           FILE_FLAG_NO_BUFFERING,      Device = CreateFile (VolumeName,
204                           NULL);                           GENERIC_READ | GENERIC_WRITE,
205      if (Device == INVALID_HANDLE_VALUE) {                           FILE_SHARE_READ | FILE_SHARE_WRITE,
206          if (forced)                           NULL,
207              print_lasterr(&VolumeName[4]);                           OPEN_EXISTING,
208          return CDISK_ERR_OPEN;                           FILE_FLAG_NO_BUFFERING,
209      }                           NULL);
210        if (Device == INVALID_HANDLE_VALUE) {
211      if (!DeviceIoControl (Device,          if (forced)
212                            FSCTL_LOCK_VOLUME,              print_lasterr(&VolumeName[4]);
213                            NULL, 0, NULL, 0,          return CDISK_ERR_OPEN;
214                            &BytesReturned, NULL)) {      }
215          if (forced) {  
216              print_lasterr(&VolumeName[4]);      if (!DeviceIoControl (Device,
217              return CDISK_ERR_LOCK;                            FSCTL_LOCK_VOLUME,
218          }                            NULL, 0, NULL, 0,
219      }                            &BytesReturned, NULL)) {
220            if (forced) {
221      if (!DeviceIoControl (Device,              print_lasterr(&VolumeName[4]);
222                            IOCTL_FILE_DISK_CLOSE_FILE,              return CDISK_ERR_LOCK;
223                            NULL, 0, NULL, 0,          }
224                            &BytesReturned, NULL )) {      }
225          if (forced)  
226              print_lasterr ("Cryptdisk Error");      if (!DeviceIoControl (Device,
227          return CDISK_ERR_UMOUNT;                            IOCTL_FILE_DISK_CLOSE_FILE,
228      }                            NULL, 0, NULL, 0,
229                              &BytesReturned, NULL )) {
230      if (!DeviceIoControl (          if (forced)
231          Device, FSCTL_DISMOUNT_VOLUME,              print_lasterr ("Cryptdisk Error");
232          NULL, 0, NULL, 0,          return CDISK_ERR_UMOUNT;
233          &BytesReturned, NULL)) {      }
234          if (forced)  
235              print_lasterr (&VolumeName[4]);      if (!DeviceIoControl (
236          return CDISK_ERR_UMOUNT;          Device, FSCTL_DISMOUNT_VOLUME,
237      }          NULL, 0, NULL, 0,
238            &BytesReturned, NULL)) {
239      if (!DeviceIoControl (Device,          if (forced)
240                            FSCTL_UNLOCK_VOLUME,              print_lasterr (&VolumeName[4]);
241                            NULL, 0, NULL, 0,          return CDISK_ERR_UMOUNT;
242                            &BytesReturned, NULL)) {      }
243          if (forced) {  
244              print_lasterr (&VolumeName[4]);      if (!DeviceIoControl (Device,
245              return CDISK_ERR_LOCK;                            FSCTL_UNLOCK_VOLUME,
246          }                            NULL, 0, NULL, 0,
247      }                            &BytesReturned, NULL)) {
248            if (forced) {
249      CloseHandle (Device);              print_lasterr (&VolumeName[4]);
250                return CDISK_ERR_LOCK;
251      if (!DefineDosDevice (          }
252          DDD_REMOVE_DEFINITION,      }
253          &VolumeName[4], NULL)) {  
254          if (forced)      CloseHandle (Device);
255              print_lasterr (&VolumeName[4]);  
256          return CDISK_ERR_UMOUNT;      if (!DefineDosDevice (
257      }          DDD_REMOVE_DEFINITION,
258            &VolumeName[4], NULL)) {
259      return 0;          if (forced)
260  }              print_lasterr (&VolumeName[4]);
261            return CDISK_ERR_UMOUNT;
262  int      }
263  filedisk_unmount (char drivelet, int forced)  
264  {                return 0;
265      char i;  }
266    
267      if (drivelet) {  int
268          int rc = filedisk_unmount2 (drivelet, 0, forced);  filedisk_unmount (char drivelet, int forced)
269          if (rc)  {          
270              print_lasterr ("Unmount�");      char i;
271          return rc;  
272      }      if (drivelet) {
273      for (i=0; i<20;i++) {          int rc = filedisk_unmount2 (drivelet, 0, forced);
274          if (filedisk_unmount2 (i, 1, 0) == CDISK_ERR_OPEN)          if (rc)
275              break;              print_lasterr ("Unmount�");
276      }          return rc;
277      for (i=0; i<20;i++) {      }
278          if (filedisk_unmount2 (i, 2, 0) == CDISK_ERR_OPEN)      for (i=0; i<20;i++) {
279              break;          if (filedisk_unmount2 (i, 1, 0) == CDISK_ERR_OPEN)
280      }              break;
281      return 0;      }
282  }      for (i=0; i<20;i++) {
283            if (filedisk_unmount2 (i, 2, 0) == CDISK_ERR_OPEN)
284                break;
285  int      }
286  filedisk_status (char drivelet, LARGE_INTEGER * size, int * rdonly)      return 0;
287  {  }
288      char                    VolumeName[] = "\\\\.\\ :";  
289      HANDLE                  Device;  
290      POPEN_FILE_INFORMATION  ofi;  int
291      DWORD                   BytesReturned;  filedisk_status (char drivelet, LARGE_INTEGER * size, int * rdonly)
292    {
293      VolumeName[4] = drivelet;      char                    VolumeName[] = "\\\\.\\ :";
294        HANDLE                  Device;
295      Device = CreateFile (VolumeName,      POPEN_FILE_INFORMATION  ofi;
296                           GENERIC_READ,      DWORD                   BytesReturned;
297                           FILE_SHARE_READ | FILE_SHARE_WRITE,  
298                           NULL,      VolumeName[4] = drivelet;
299                           OPEN_EXISTING,  
300                           FILE_FLAG_NO_BUFFERING,      Device = CreateFile (VolumeName,
301                          NULL);                           GENERIC_READ,
302                             FILE_SHARE_READ | FILE_SHARE_WRITE,
303      if (Device == INVALID_HANDLE_VALUE) {                           NULL,
304          print_lasterr(&VolumeName[4]);                           OPEN_EXISTING,
305          return CDISK_ERR_OPEN;                           FILE_FLAG_NO_BUFFERING,
306      }                          NULL);
307    
308      ofi = malloc (sizeof(OPEN_FILE_INFORMATION) + MAX_PATH);      if (Device == INVALID_HANDLE_VALUE) {
309            print_lasterr(&VolumeName[4]);
310      if (!DeviceIoControl (Device,          return CDISK_ERR_OPEN;
311                            IOCTL_FILE_DISK_QUERY_FILE,      }
312                            NULL,  
313                            0,      ofi = malloc (sizeof(OPEN_FILE_INFORMATION) + MAX_PATH);
314                            ofi,  
315                            sizeof(OPEN_FILE_INFORMATION) + MAX_PATH,      if (!DeviceIoControl (Device,
316                            &BytesReturned, NULL)) {                            IOCTL_FILE_DISK_QUERY_FILE,
317          print_lasterr (&VolumeName[4]);                            NULL,
318          return CDISK_ERR_QUERY;                            0,
319      }                            ofi,
320                              sizeof(OPEN_FILE_INFORMATION) + MAX_PATH,
321      if (BytesReturned < sizeof(OPEN_FILE_INFORMATION)) {                            &BytesReturned, NULL)) {
322          SetLastError (ERROR_INSUFFICIENT_BUFFER);          print_lasterr (&VolumeName[4]);
323          print_lasterr (&VolumeName[4]);          return CDISK_ERR_QUERY;
324          return CDISK_ERR_QUERY;      }
325      }  
326        if (BytesReturned < sizeof(OPEN_FILE_INFORMATION)) {
327      if (size)          SetLastError (ERROR_INSUFFICIENT_BUFFER);
328          *size = ofi->FileSize;          print_lasterr (&VolumeName[4]);
329      if (rdonly)          return CDISK_ERR_QUERY;
330          *rdonly = ofi->ReadOnly;      }
331    
332      return 0;      if (size)
333  }          *size = ofi->FileSize;
334        if (rdonly)
335            *rdonly = ofi->ReadOnly;
336  POPEN_FILE_INFORMATION  
337  filedisk_init_info (int devnum, char drivelet, const char * file,      return 0;
338                      int ro, int cd_img, unsigned long size, const char * key,  }
339                      int keyalgo)  
340  {  
341      POPEN_FILE_INFORMATION pfi;  POPEN_FILE_INFORMATION
342    filedisk_init_info (int devnum, char drivelet, const char * file,
343      pfi = calloc (1, sizeof(OPEN_FILE_INFORMATION) + strlen (file) + 7);                      int ro, int cd_img, unsigned long size, const char * key,
344                        int keyalgo)
345      pfi->version = CCVERSION;  {
346      if (file[0] == '\\') {      POPEN_FILE_INFORMATION pfi;
347          if (file[1] == '\\' && file[2] != '.') {  
348              /* \\server\share\path\filedisk.img */      pfi = calloc (1, sizeof(OPEN_FILE_INFORMATION) + strlen (file) + 7);
349              strcpy(pfi->FileName, "\\??\\UNC");  
350              strcat(pfi->FileName, file + 1);      pfi->version = CCVERSION;
351          }      if (file[0] == '\\') {
352          else /* \Device\Harddisk0\Partition1\path\filedisk.img */          if (file[1] == '\\' && file[2] != '.') {
353              strcpy(pfi->FileName, file);              /* \\server\share\path\filedisk.img */
354      }                strcpy(pfi->FileName, "\\??\\UNC");
355      else { // c:\path\filedisk.img              strcat(pfi->FileName, file + 1);
356          strcpy (pfi->FileName, "\\??\\");          }
357          strcat (pfi->FileName, file);          else /* \Device\Harddisk0\Partition1\path\filedisk.img */
358      }              strcpy(pfi->FileName, file);
359        }  
360      pfi->FileNameLength = (USHORT) strlen (pfi->FileName);      else { // c:\path\filedisk.img
361      pfi->ReadOnly = ro? TRUE : FALSE;          strcpy (pfi->FileName, "\\??\\");
362      if (cd_img)          strcat (pfi->FileName, file);
363          pfi->ReadOnly = TRUE;      }
364      if (size)  
365          pfi->FileSize.QuadPart = size * 1024;      pfi->FileNameLength = (USHORT) strlen (pfi->FileName);
366      if (key) {      pfi->ReadOnly = ro? TRUE : FALSE;
367          if (keyalgo < 1 || keyalgo > 4)      if (cd_img)
368              pfi->KeyType = 1;          pfi->ReadOnly = TRUE;
369          else      if (size)
370              pfi->KeyType = keyalgo;          pfi->FileSize.QuadPart = size * 1024;
371          add_key (pfi, key, strlen (key));      if (key) {
372      }          if (keyalgo < 1 || keyalgo > 4)
373                pfi->KeyType = 1;
374      return pfi;          else
375  }              pfi->KeyType = keyalgo;
376            add_key (pfi, key, strlen (key));
377        }
378  void  
379  filedisk_free_info (POPEN_FILE_INFORMATION pfi)      return pfi;
380  {  }
381      if (!pfi)  
382          return;  
383      free (pfi);  void
384  }  filedisk_free_info (POPEN_FILE_INFORMATION pfi)
385    {
386        if (!pfi)
387            return;
388        free (pfi);
389    }
390    

Legend:
Removed from v.35  
changed lines
  Added in v.36

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26