rtoss - Diff between revs 203 and 204

Subversion Repositories:
Rev:
Show entire file - Ignore whitespace
Rev 203 Rev 204
Line 1... Line 1...
1 #include <windows.h> 1 #include <windows.h>
2 #include <stdio.h> 2 #include <stdio.h>
3 #include <stdint.h> 3 #include <stdint.h>
4 #include <string.h> 4 #include <string.h>
5 #include <locale.h> 5 #include <locale.h>
-   6
-   7 void vpath_pairs_append(WCHAR *volpath, WCHAR *win32path);
-   8 void vpath_pairs_free();
-   9
-   10 WCHAR* FindDriveLetterFromVolumePath(WCHAR* wszVolumePath);
-   11
-   12 BOOL ProcessVolumeMountPoint(HANDLE hPt, WCHAR *PtBuf, DWORD dwPtBufSize, WCHAR *Buf);
-   13 BOOL ProcessVolume(HANDLE hVol, WCHAR *Buf, DWORD iBufSize);
-   14 int GetMountPoint(void);
6 15
7 void DisplayVolumePaths(PWCHAR VolumeName); 16 void DisplayVolumePaths(PWCHAR VolumeName);
8 WCHAR *fdigitsW(uint64_t integer); 17 WCHAR *fdigitsW(uint64_t integer);
9 WCHAR *ComputerUnits(uint64_t integer, int maxdiv); 18 WCHAR *ComputerUnits(uint64_t integer, int maxdiv);
10 void DrawGauge(int length, int percent, int isempty); 19 void DrawGauge(int length, int percent, int isempty);
11 int IsTargetDrive(int DriveType, int flgNoRemoveable); -  
-   20 int IsTargetDrive(int DriveType, int flgNoRemoveable, int flgIsRealFloppy);
12 void ShowVolume(WCHAR* VolumeName, int flgShowDevName, int flgVerbose, int flgUnit, int flgGauge, int flgNoRemoveable); 21 void ShowVolume(WCHAR* VolumeName, int flgShowDevName, int flgVerbose, int flgUnit, int flgGauge, int flgNoRemoveable);
-   22
-   23 typedef BOOL (WINAPI *PGVPNFVNW)(LPCWSTR,LPWSTR,DWORD,PDWORD);
-   24
-   25 struct vpath_pairs{
-   26  WCHAR vpath[MAX_PATH];
-   27  WCHAR w32path[MAX_PATH];
-   28  struct vpath_pairs *next;
-   29 };
-   30
-   31 static struct vpath_pairs *vpath = NULL;
-   32
-   33 void vpath_pairs_append(WCHAR *volpath, WCHAR *win32path) {
-   34     struct vpath_pairs* v;
-   35     if(!vpath) {
-   36         vpath = (struct vpath_pairs*) malloc(sizeof(struct vpath_pairs));
-   37         wcscpy(vpath->vpath, volpath);
-   38         wcscpy(vpath->w32path, win32path);
-   39         vpath->next = NULL;
-   40     } else {
-   41         v = vpath;
-   42         while(v->next != NULL) v = v->next;
-   43         v->next = (struct vpath_pairs*) malloc(sizeof(struct vpath_pairs));
-   44         wcscpy(v->next->vpath, volpath);
-   45         wcscpy(v->next->w32path, win32path);
-   46         vpath->next->next = NULL;
-   47     }
-   48 }
-   49
-   50 void vpath_pairs_free() {
-   51     struct vpath_pairs *v, *t;
-   52     if(vpath) {
-   53         v = vpath;
-   54         while(v->next != NULL) {
-   55             t = v;
-   56             v = v->next;
-   57             free(t);
-   58         }
-   59         vpath = NULL;
-   60     }
-   61 }
-   62
-   63
-   64 WCHAR* FindDriveLetterFromVolumePath(WCHAR* wszVolumePath) {
-   65     static WCHAR** vPathLetters = NULL;
-   66     static WCHAR tmp[10] = {0};
-   67     static int vPathFilled = 0;
-   68     int i = 0;
-   69
-   70     if(wszVolumePath) {
-   71         wcscpy(tmp,L"A:\\");
-   72         if(!vPathLetters) { // malloc the 2D array
-   73             vPathLetters = (WCHAR**) malloc(26*sizeof(WCHAR*));
-   74             for (i = 0; i < 26; i++)
-   75                 vPathLetters[i] = (WCHAR*) malloc((MAX_PATH+1)*sizeof(WCHAR));
-   76         }
-   77         if(!vPathFilled) {
-   78             for(i = 0; i < 26; i++, tmp[0]++) {
-   79                 GetVolumeNameForVolumeMountPointW(tmp, vPathLetters[i], MAX_PATH);
-   80             }
-   81             vPathFilled = 1;
-   82         }
-   83
-   84         tmp[0] = L'A';
-   85         for(i = 0; i < 26; i++, tmp[0]++) {
-   86             if(wcsicmp(wszVolumePath, vPathLetters[i]) == 0) {
-   87                 tmp[0] = L'A' + i;
-   88                 return tmp;
-   89             }
-   90         }
-   91     } else { // free the 2D array
-   92         if(vPathLetters) { // avoid double free/free uninitialized
-   93             for (i = 0; i < 26; i++)
-   94                 free(vPathLetters[i]);
-   95             free(vPathLetters);
-   96         }
-   97         vPathLetters = NULL;
-   98         vPathFilled = 0;
-   99     }
-   100     return NULL;
-   101 }
-   102
-   103 // *******
-   104 BOOL ProcessVolumeMountPoint(HANDLE hPt, WCHAR *PtBuf, DWORD dwPtBufSize, WCHAR *Buf) {
-   105     BOOL bFlag;
-   106     WCHAR Path[MAX_PATH];
-   107     WCHAR Target[MAX_PATH];
-   108
-   109     wcscpy(Path, Buf);
-   110     wcscat(Path, PtBuf);
-   111
-   112     bFlag = GetVolumeNameForVolumeMountPointW(Path,Target,MAX_PATH);
-   113
-   114     if (bFlag) {
-   115         wcscpy(Path, FindDriveLetterFromVolumePath(Buf));
-   116         wcscat(Path, PtBuf);
-   117         vpath_pairs_append(Target, Path);
-   118     }
-   119
-   120     bFlag = FindNextVolumeMountPointW(hPt,PtBuf,dwPtBufSize);
-   121     return (bFlag);
-   122 }
-   123
-   124 BOOL ProcessVolume(HANDLE hVol, WCHAR *Buf, DWORD iBufSize) {
-   125     BOOL bFlag;
-   126     HANDLE hPt;
-   127     WCHAR PtBuf[MAX_PATH];
-   128     DWORD dwSysFlags;
-   129     WCHAR FileSysNameBuf[MAX_PATH];
-   130
-   131     // is NTFS?
-   132     GetVolumeInformationW( Buf, NULL, 0, NULL, NULL, &dwSysFlags, FileSysNameBuf, MAX_PATH);
-   133
-   134     if ((dwSysFlags & FILE_SUPPORTS_REPARSE_POINTS)) {
-   135         hPt = FindFirstVolumeMountPointW(Buf, PtBuf, MAX_PATH);
-   136
-   137         if (hPt != INVALID_HANDLE_VALUE) {
-   138             bFlag = ProcessVolumeMountPoint(hPt, PtBuf, MAX_PATH, Buf);
-   139             while (bFlag)
-   140                 bFlag = ProcessVolumeMountPoint (hPt, PtBuf, MAX_PATH, Buf);
-   141             FindVolumeMountPointClose(hPt);
-   142         }
-   143     }
-   144
-   145     bFlag = FindNextVolumeW(hVol, Buf, iBufSize);
-   146     return (bFlag);
-   147 }
-   148 int GetMountPoint(void) {
-   149     WCHAR buf[MAX_PATH];
-   150     HANDLE hVol;
-   151     BOOL bFlag;
-   152
-   153     hVol = FindFirstVolumeW(buf, MAX_PATH);
-   154     if (hVol == INVALID_HANDLE_VALUE) {
-   155        return (-1);
-   156     }
-   157
-   158     bFlag = ProcessVolume(hVol, buf, MAX_PATH);
-   159     while (bFlag) {
-   160        bFlag = ProcessVolume(hVol, buf, MAX_PATH);
-   161     }
-   162
-   163     bFlag = FindVolumeClose( hVol );
-   164     return (bFlag);
-   165 }
-   166 // *******
13 167
14 void DisplayVolumePaths(PWCHAR VolumeName) { 168 void DisplayVolumePaths(PWCHAR VolumeName) {
15     DWORD  CharCount = MAX_PATH + 1; 169     DWORD  CharCount = MAX_PATH + 1;
16     PWCHAR Names     = NULL; 170     PWCHAR Names     = NULL;
17     PWCHAR NameIdx   = NULL; 171     PWCHAR NameIdx   = NULL;
18     BOOL   Success   = FALSE; 172     BOOL   Success   = FALSE;
-   173     HANDLE hFvn      = NULL;
19 174
20     for (;;) { -  
21         // -  
22         //  Allocate a buffer to hold the paths. -  
23         Names = (PWCHAR) malloc(CharCount * sizeof(WCHAR)); -  
-   175     struct vpath_pairs* v;
24 176
25         if ( !Names ) { -  
-   177     PGVPNFVNW pGVPNFVNW;
-   178     pGVPNFVNW = (PGVPNFVNW) GetProcAddress(
-   179         GetModuleHandle("kernel32.dll"),
-   180         "GetVolumePathNamesForVolumeNameW");
-   181
-   182     if(pGVPNFVNW) {
-   183         for (;;) {
26             // 184             //
27             //  If memory can't be allocated, return. -  
28             return; -  
29         } -  
-   185             //  Allocate a buffer to hold the paths.
-   186             Names = (PWCHAR) malloc(CharCount * sizeof(WCHAR));
30 187
31         // -  
32         //  Obtain all of the paths -  
33         //  for this volume. -  
34         Success = GetVolumePathNamesForVolumeNameW( -  
35             VolumeName, Names, CharCount, &CharCount -  
36             ); -  
-   188             if ( !Names ) {
-   189                 //
-   190                 //  If memory can't be allocated, return.
-   191                 return;
-   192             }
-   193
-   194             //
-   195             //  Obtain all of the paths
-   196             //  for this volume.
-   197             Success = pGVPNFVNW(VolumeName, Names, CharCount, &CharCount);
-   198
-   199             if ( Success ) {
-   200                 break;
-   201             }
-   202
-   203             if ( GetLastError() != ERROR_MORE_DATA ) {
-   204                 break;
-   205             }
-   206
-   207             //
-   208             //  Try again with the
-   209             //  new suggested size.
-   210             free(Names);
-   211             Names = NULL;
-   212         }
37 213
38         if ( Success ) { 214         if ( Success ) {
39             break; -  
-   215             //
-   216             //  Display the various paths.
-   217             for ( NameIdx = Names;
-   218                   NameIdx[0] != L'\0';
-   219                   NameIdx += wcslen(NameIdx) + 1 ) {
-   220                 wprintf(L"  %s", NameIdx);
-   221             }
-   222             //wprintf(L"\n");
40         } 223         }
41 224
42         if ( GetLastError() != ERROR_MORE_DATA ) { -  
43             break; -  
-   225         if ( Names != NULL ) {
-   226             free(Names);
-   227             Names = NULL;
44         } 228         }
-   229     } else {
-   230         // GetVolumePathNamesForVolumeNameW cannot be used (Win2000)
45 231
46         // -  
47         //  Try again with the -  
48         //  new suggested size. -  
49         free(Names); -  
50         Names = NULL; -  
51     } -  
-   232         // print drive letter first
-   233         Names = FindDriveLetterFromVolumePath(VolumeName);
-   234         wprintf(L"  %s", Names);
52 235
53     if ( Success ) { -  
54         // -  
55         //  Display the various paths. -  
56         for ( NameIdx = Names; -  
57               NameIdx[0] != L'\0'; -  
58               NameIdx += wcslen(NameIdx) + 1 ) { -  
59             wprintf(L"  %s", NameIdx); -  
-   236         // then mountpoints
-   237         GetMountPoint();
-   238         if(vpath) {
-   239             v = vpath;
-   240             while(v != NULL) {
-   241                 if(wcsicmp(v->vpath, VolumeName) == 0) {
-   242                     wprintf(L"  %s", v->w32path);
-   243                 }
-   244                 v = v->next;
-   245             }
60         } 246         }
61         //wprintf(L"\n"); -  
62     } -  
63 247
64     if ( Names != NULL ) { -  
65         free(Names); -  
66         Names = NULL; -  
67     } 248     }
68 249
69     return; 250     return;
70 } 251 }
71 252
72 #define MAX_PLACES 40 -  
-   253 #define MAX_PLACES 64
73 WCHAR *fdigitsW(uint64_t integer) { 254 WCHAR *fdigitsW(uint64_t integer) {
74     static WCHAR fdigits[MAX_PLACES + (MAX_PLACES / 3) + 1]; 255     static WCHAR fdigits[MAX_PLACES + (MAX_PLACES / 3) + 1];
75     WCHAR digits[MAX_PLACES + 1]; 256     WCHAR digits[MAX_PLACES + 1];
76     WCHAR *dgt = digits, *fdgt = fdigits; 257     WCHAR *dgt = digits, *fdgt = fdigits;
77     int places; 258     int places;
Line 87... Line 268...
87 } 268 }
88 269
89 WCHAR *ComputerUnits(uint64_t integer, int maxdiv) { 270 WCHAR *ComputerUnits(uint64_t integer, int maxdiv) {
90     static WCHAR fdigits[MAX_PLACES + (MAX_PLACES / 3) + 1]; 271     static WCHAR fdigits[MAX_PLACES + (MAX_PLACES / 3) + 1];
91     WCHAR *units[] = {L"B",L"KB",L"MB",L"GB",L"TB",L"PB",L"EB", NULL}; 272     WCHAR *units[] = {L"B",L"KB",L"MB",L"GB",L"TB",L"PB",L"EB", NULL};
92     WCHAR tmp[10]; -  
-   273     WCHAR tmp[10] = {0};
93     int count = 0; 274     int count = 0;
94     double smallfloat; 275     double smallfloat;
95     uint64_t smallint; 276     uint64_t smallint;
96 277
97     for(smallint = smallfloat = integer; smallint > 1024 && count < maxdiv;) { 278     for(smallint = smallfloat = integer; smallint > 1024 && count < maxdiv;) {
Line 125... Line 306...
125         printf(tmp,""); 306         printf(tmp,"");
126     } 307     }
127     putchar('|'); 308     putchar('|');
128 } 309 }
129 310
130 int IsTargetDrive(int DriveType, int flgRemoveable) { -  
-   311 int IsTargetDrive(int DriveType, int flgRemoveable, int flgIsRealFloppy) {
131     if(!flgRemoveable) 312     if(!flgRemoveable)
132         return DriveType > 1 && DriveType != 2 && DriveType != 5; 313         return DriveType > 1 && DriveType != 2 && DriveType != 5;
133     else -  
-   314     else if(flgRemoveable == 2)
134         return DriveType > 1; 315         return DriveType > 1;
-   316     else
-   317         return DriveType > 1 && !flgIsRealFloppy;
135 } 318 }
136 319
137 void ShowVolume(WCHAR* VolumeName, int flgShowDevName, int flgVerbose, int flgUnit, int flgGauge, int flgRemoveable) { 320 void ShowVolume(WCHAR* VolumeName, int flgShowDevName, int flgVerbose, int flgUnit, int flgGauge, int flgRemoveable) {
138     DWORD  Error                = ERROR_SUCCESS; 321     DWORD  Error                = ERROR_SUCCESS;
139     DWORD  CharCount            = 0; 322     DWORD  CharCount            = 0;
Line 146... Line 329...
146     DWORD  BytesPerSector       = 0; 329     DWORD  BytesPerSector       = 0;
147     DWORD  NumberOfFreeClusters = 0; 330     DWORD  NumberOfFreeClusters = 0;
148     DWORD  TotalNumberOfClusters= 0; 331     DWORD  TotalNumberOfClusters= 0;
149     uint64_t TotalSize          = 0; 332     uint64_t TotalSize          = 0;
150     uint64_t FreeSize           = 0; 333     uint64_t FreeSize           = 0;
-   334
-   335     UINT   flgIsRealFloppy      = 0;
151 336
152     double den                  = 0.0f; 337     double den                  = 0.0f;
153     double percent              = 0.0f; 338     double percent              = 0.0f;
154 339
155     wcscpy(tmp, VolumeName); 340     wcscpy(tmp, VolumeName);
Line 182... Line 367...
182         if ( CharCount == 0 ) { 367         if ( CharCount == 0 ) {
183             Error = GetLastError(); 368             Error = GetLastError();
184             wprintf(L"QueryDosDeviceW failed with error code %d\n", Error); 369             wprintf(L"QueryDosDeviceW failed with error code %d\n", Error);
185             return; 370             return;
186         } 371         }
-   372
-   373         if(flgRemoveable == 1) {
-   374             flgIsRealFloppy = (wcsstr(DeviceName, L"Floppy") != NULL);
-   375         }
-   376
187     } 377     }
188 378
189     VolumeType = GetDriveTypeW(tmp); 379     VolumeType = GetDriveTypeW(tmp);
190     switch(VolumeType) { 380     switch(VolumeType) {
191         case 0: 381         case 0:
Line 209... Line 399...
209         case 6: 399         case 6:
210             VolumeTypeName = L"(RAM Disk)"; 400             VolumeTypeName = L"(RAM Disk)";
211             break; 401             break;
212     } 402     }
213 403
214     if(!flgVerbose && !IsTargetDrive(VolumeType,1)) return; -  
-   404     if(!flgVerbose && !IsTargetDrive(VolumeType,1,0)) return;
215     // get free space information 405     // get free space information
216     if(IsTargetDrive(VolumeType,flgRemoveable)) { -  
-   406     if(IsTargetDrive(VolumeType,flgRemoveable,flgIsRealFloppy)) {
217         GetDiskFreeSpaceW(tmp, &SectorsPerCluster, &BytesPerSector, &NumberOfFreeClusters, &TotalNumberOfClusters); 407         GetDiskFreeSpaceW(tmp, &SectorsPerCluster, &BytesPerSector, &NumberOfFreeClusters, &TotalNumberOfClusters);
218         FreeSize = TotalSize = SectorsPerCluster; 408         FreeSize = TotalSize = SectorsPerCluster;
219         FreeSize *= BytesPerSector; 409         FreeSize *= BytesPerSector;
220         TotalSize *= BytesPerSector; 410         TotalSize *= BytesPerSector;
221         FreeSize *= NumberOfFreeClusters; 411         FreeSize *= NumberOfFreeClusters;
Line 230... Line 420...
230         wprintf(L"\nFound a device: %s", DeviceName); 420         wprintf(L"\nFound a device: %s", DeviceName);
231         wprintf(L"\nVolume name: %s %s", tmp, VolumeTypeName); 421         wprintf(L"\nVolume name: %s %s", tmp, VolumeTypeName);
232         wprintf(L"\nPaths:"); 422         wprintf(L"\nPaths:");
233     } 423     }
234     else if(flgGauge) { 424     else if(flgGauge) {
235         DrawGauge(36,(int)percent,!IsTargetDrive(VolumeType,flgRemoveable)|!TotalSize); -  
-   425         DrawGauge(36,(int)percent,!IsTargetDrive(VolumeType,flgRemoveable,flgIsRealFloppy)|!TotalSize);
236     } 426     }
237 427
238     if (flgShowDevName) 428     if (flgShowDevName)
239         DisplayVolumePaths(tmp); 429         DisplayVolumePaths(tmp);
240     else 430     else
241         wprintf(L"  %s", tmp); 431         wprintf(L"  %s", tmp);
242 432
243 433
244     if(IsTargetDrive(VolumeType,flgRemoveable)) { -  
-   434     if(IsTargetDrive(VolumeType,flgRemoveable,flgIsRealFloppy)) {
245         // VolumeName is reused here 435         // VolumeName is reused here
246         wcscpy(tmp, ComputerUnits(FreeSize, flgUnit)); 436         wcscpy(tmp, ComputerUnits(FreeSize, flgUnit));
247 437
248         // DeviceName is reused here 438         // DeviceName is reused here
249         if(TotalSize) 439         if(TotalSize)
Line 274... Line 464...
274     int flgVerbose      = 0; 464     int flgVerbose      = 0;
275     int flgUnit         = 3; 465     int flgUnit         = 3;
276     int flgGauge        = 0; 466     int flgGauge        = 0;
277     int flgRemoveable   = 0; 467     int flgRemoveable   = 0;
278     int flgNonEnum      = 0; 468     int flgNonEnum      = 0;
-   469     int flgForceEnum    = 0;
279     int OldMode; //a place to store the old error mode 470     int OldMode; //a place to store the old error mode
-   471
-   472     //save the old error mode and set the new mode to let us do the work:
-   473     OldMode = SetErrorMode(SEM_FAILCRITICALERRORS);
280 474
281     for (; i < argc; i++) { 475     for (; i < argc; i++) {
282         if(stricmp(argv[i],"-g") == 0) { 476         if(stricmp(argv[i],"-g") == 0) {
283             flgGauge = 1; 477             flgGauge = 1;
284         } else if(strnicmp(argv[i],"-u",2) == 0) { 478         } else if(strnicmp(argv[i],"-u",2) == 0) {
285             if(argv[i][2] >= '0' && argv[i][2] <= '4') 479             if(argv[i][2] >= '0' && argv[i][2] <= '4')
286                 flgUnit = argv[i][2] - '0'; 480                 flgUnit = argv[i][2] - '0';
287         } else if(stricmp(argv[i],"-r") == 0) { -  
-   481         } else if(strnicmp(argv[i],"-r",2) == 0) {
288             flgRemoveable = 1; 482             flgRemoveable = 1;
-   483             if(argv[i][2] == 'f')
-   484                 flgRemoveable += 1;
289         } else if(stricmp(argv[i],"-v") == 0) { 485         } else if(stricmp(argv[i],"-v") == 0) {
290             flgVerbose = 1; 486             flgVerbose = 1;
-   487         } else if(stricmp(argv[i],"-a") == 0) {
-   488             flgForceEnum = 1;
291         } else if(strcmp(argv[i],"-?") == 0) { 489         } else if(strcmp(argv[i],"-?") == 0) {
292             printf("%s [-v] [-g] [-r] [-u#] [-?] [drive|path...]\n\n" -  
-   490             printf("%s [-v] [-g] [-a] [-r[f]] [-u#] [-?] [drive|path...]\n\n"
293                 " -v\t\tbe verbose (-g switch will be turned off)\n" 491                 " -v\t\tbe verbose (-g switch will be turned off)\n"
294                 " -g\t\tdraw gauge of free space\n" 492                 " -g\t\tdraw gauge of free space\n"
295                 " -r\t\tdetect removable device free space\n" -  
-   493                 " -a\t\tappend drive|path to detected list\n"
-   494                 " -r[f]\t\tdetect removable device free space (-rf for real floppy drive)\n"
296                 " -u[num]\tuse unit # (0=byte, 1=KB, 2=MB, 3=GB, 4=TB)\n" 495                 " -u[num]\tuse unit # (0=byte, 1=KB, 2=MB, 3=GB, 4=TB)\n"
297                 " -?\t\tshow this help and exit\n" 496                 " -?\t\tshow this help and exit\n"
298                 " drive|path...\tshow individual drives\n" 497                 " drive|path...\tshow individual drives\n"
299                 " \t\texample:  C: D: F:\\mountpoint\\\n", argv[0]); 498                 " \t\texample:  C: D: F:\\mountpoint\\\n", argv[0]);
300             return 0; 499             return 0;
301         } else { 500         } else {
302             // assume it is a path 501             // assume it is a path
303             dwAttrib = GetFileAttributesA(argv[i]); 502             dwAttrib = GetFileAttributesA(argv[i]);
304             if(dwAttrib != INVALID_FILE_ATTRIBUTES && (dwAttrib & FILE_ATTRIBUTE_DIRECTORY)) { 503             if(dwAttrib != INVALID_FILE_ATTRIBUTES && (dwAttrib & FILE_ATTRIBUTE_DIRECTORY)) {
305                 // yes it is valid path 504                 // yes it is valid path
306                 flgNonEnum = 1; -  
-   505                 if(!flgForceEnum)
-   506                     flgNonEnum = 1;
307                 // dwAttrib is reused 507                 // dwAttrib is reused
308                 dwAttrib = MultiByteToWideChar(CP_ACP, 0, argv[i], -1, VolumeName, MAX_PATH); 508                 dwAttrib = MultiByteToWideChar(CP_ACP, 0, argv[i], -1, VolumeName, MAX_PATH);
309                 // workaround on getting free space from \\host\share 509                 // workaround on getting free space from \\host\share
310                 if (VolumeName[dwAttrib-2] != L'\\') VolumeName[dwAttrib-1] = L'\\'; 510                 if (VolumeName[dwAttrib-2] != L'\\') VolumeName[dwAttrib-1] = L'\\';
311                 ShowVolume(VolumeName, 0, flgVerbose, flgUnit, flgGauge, flgRemoveable); 511                 ShowVolume(VolumeName, 0, flgVerbose, flgUnit, flgGauge, flgRemoveable);
Line 315... Line 515...
315             } 515             }
316         } 516         }
317     } 517     }
318 518
319     setlocale(LC_CTYPE, ""); // reset locale 519     setlocale(LC_CTYPE, ""); // reset locale
320 -  
321     //save the old error mode and set the new mode to let us do the work: -  
322     OldMode = SetErrorMode(SEM_FAILCRITICALERRORS); -  
323 520
324     if(!flgNonEnum) { 521     if(!flgNonEnum) {
325         // 522         //
326         //  Enumerate all volumes in the system. 523         //  Enumerate all volumes in the system.
327         FindHandle = FindFirstVolumeW(VolumeName, ARRAYSIZE(VolumeName)); 524         FindHandle = FindFirstVolumeW(VolumeName, ARRAYSIZE(VolumeName));
Line 359... Line 556...
359         FindHandle = INVALID_HANDLE_VALUE; 556         FindHandle = INVALID_HANDLE_VALUE;
360 557
361     } 558     }
362 559
363     SetErrorMode(OldMode); //put things back the way they were 560     SetErrorMode(OldMode); //put things back the way they were
-   561     FindDriveLetterFromVolumePath(NULL); // free the array
-   562     vpath_pairs_free(); // free the linked list
364     return 0; 563     return 0;
365 } 564 }
366 565