Changeset 1394 for trunk/dll/valid.c
- Timestamp:
- Feb 5, 2009, 5:17:25 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/valid.c
r1387 r1394 29 29 25 Dec 08 GKY Add code to allow write verify to be turned off on a per drive basis 30 30 03 Jan 09 GKY Check for system that is protectonly to gray out Dos/Win command lines and prevent 31 31 Dos/Win programs from being inserted into the execute dialog with message why. 32 32 03 Jan 09 GKY Modify IsExecutable to prevent some text files from being treated as executable 33 33 and prevent dlls from being loaded into execute dialog. 34 34 05 Jan 09 GKY Fix IsBinary to recognize values above \xc4 (maybe lower) as positive. 35 35 When these high codes were it text files they showed as hex in new view. 36 36 37 37 ***********************************************************************/ … … 121 121 122 122 int TestFDates(char *file1, char *file2, FDATE *datevar1, FTIME *timevar1, 123 123 FDATE *datevar2, FTIME *timevar2) 124 124 { 125 125 int comp = 0; … … 140 140 if (&datevar1 && &datevar2 && &timevar1 && &timevar2) { 141 141 comp = (datevar2->year > 142 142 datevar1->year) ? 1 : 143 143 (datevar2->year < 144 144 datevar1->year) ? -1 : … … 173 173 174 174 int TestCDates(CDATE *datevar1, CTIME *timevar1, 175 175 CDATE *datevar2, CTIME *timevar2) 176 176 { 177 177 int comp = 0; … … 179 179 if (&datevar1 && &datevar2 && &timevar1 && &timevar2) { 180 180 comp = (datevar2->year > 181 181 datevar1->year) ? 1 : 182 182 (datevar2->year < 183 183 datevar1->year) ? -1 : … … 212 212 } 213 213 214 #if 0 214 #if 0 // JBS 11 Sep 08 215 215 BOOL IsDesktop(HAB hab, HWND hwnd) 216 216 { … … 329 329 *pulType |= DRIVE_NOTWRITEABLE; 330 330 if (pulType && !strcmp(pfsn, NDFS32)){ 331 331 *pulType |= DRIVE_VIRTUAL; 332 332 } 333 333 if (pulType && !strcmp(pfsn, RAMFS)){ 334 334 *pulType |= DRIVE_RAMDISK; 335 335 } 336 336 if (((PFSQBUFFER2) pvBuffer)->iType == FSAT_REMOTEDRV && … … 359 359 !strcmp(pfsn, JFS) || 360 360 !strcmp(pfsn, FAT32) || 361 362 363 364 361 !strcmp(pfsn, RAMFS) || 362 !strcmp(pfsn, NDFS32) || 363 !strcmp(pfsn, NTFS) || 364 !strcmp(pfsn, HPFS386))) { 365 365 *pulType &= ~DRIVE_NOLONGNAMES; 366 366 } … … 401 401 NonRemovable = 1; // Preset as non removable 402 402 DosError(FERR_DISABLEHARDERR); 403 rc = DosDevIOCtl(hDev, IOCTL_DISK, DSK_BLOCKREMOVABLE, &parmPkt.Cmd, /* 404 sizeof(parmPkt.Cmd), /* 405 &clParmBytes, /* 406 &NonRemovable, /* 407 sizeof(NonRemovable), /* 408 &clDataBytes); /* 403 rc = DosDevIOCtl(hDev, IOCTL_DISK, DSK_BLOCKREMOVABLE, &parmPkt.Cmd, /* Address of the command-specific argument list. */ 404 sizeof(parmPkt.Cmd), /* Length, in bytes, of pParams. */ 405 &clParmBytes, /* Pointer to the length of parameters. */ 406 &NonRemovable, /* Address of the data area. */ 407 sizeof(NonRemovable), /* Length, in bytes, of pData. */ 408 &clDataBytes); /* Pointer to the length of data. */ 409 409 410 410 if (!rc && NonRemovable) { … … 414 414 memset(&dataPkt, 0xff, sizeof(dataPkt)); 415 415 DosError(FERR_DISABLEHARDERR); 416 rc = DosDevIOCtl(hDev, IOCTL_DISK, DSK_GETDEVICEPARAMS, &parmPkt.Cmd, /* 417 sizeof(parmPkt.Cmd), /* 418 &clParmBytes, /* 419 &dataPkt, /* 420 sizeof(dataPkt), /* 421 &clDataBytes); /* 416 rc = DosDevIOCtl(hDev, IOCTL_DISK, DSK_GETDEVICEPARAMS, &parmPkt.Cmd, /* Address of the command-specific argument list. */ 417 sizeof(parmPkt.Cmd), /* Length, in bytes, of pParams. */ 418 &clParmBytes, /* Pointer to the length of parameters. */ 419 &dataPkt, /* Address of the data area. */ 420 sizeof(dataPkt), /* Length, in bytes, of pData. */ 421 &clDataBytes); /* Pointer to the length of data. */ 422 422 423 423 if (!rc && (dataPkt.bpb.fsDeviceAttr & BPB_REMOVABLE_MEDIA)) … … 438 438 BOOL IsFileSame(CHAR * filename1, CHAR * filename2) 439 439 { 440 /* returns: 440 /* returns: -1 (error), 0 (is a directory), or 1 (is a file) */ 441 441 442 442 FILESTATUS3L fsa1, fsa2; … … 463 463 #endif 464 464 465 INT IsFile( CHAR *filename)466 { 467 /* returns: 465 INT IsFile(PCSZ filename) 466 { 467 /* returns: -1 (error), 0 (is a directory), or 1 (is a file) */ 468 468 469 469 FILESTATUS3 fsa; … … 487 487 } 488 488 489 BOOL IsRoot( CHAR *filename)489 BOOL IsRoot(PCSZ filename) 490 490 { 491 491 return (filename && isalpha(*filename) && filename[1] == ':' && … … 608 608 } 609 609 if (apptype & (FAPPTYP_DLL | 610 611 612 610 FAPPTYP_PHYSDRV | 611 FAPPTYP_VIRTDRV | 612 FAPPTYP_PROTDLL)) 613 613 return FALSE; 614 614 if (apptype == 0x000b && (!p || 615 616 617 618 619 615 (stricmp(p, ".EXE") && 616 stricmp(p, ".COM") && 617 stricmp(p, ".CMD") && 618 stricmp(p, ".BAT") && 619 stricmp(p, ".BTM")))) 620 620 return FALSE; 621 621 if (!fProtectOnly) { 622 622 if ((!ret && (!apptype || 623 624 625 626 627 628 629 630 631 632 633 634 623 (apptype & 624 (FAPPTYP_NOTWINDOWCOMPAT | 625 FAPPTYP_WINDOWCOMPAT | 626 FAPPTYP_WINDOWAPI | 627 FAPPTYP_BOUND | 628 FAPPTYP_DOS | 629 FAPPTYP_WINDOWSREAL | 630 FAPPTYP_WINDOWSPROT | 631 FAPPTYP_32BIT | 632 FAPPTYP_WINDOWSPROT31)))) || 633 (p && (!stricmp(p, ".CMD") || !stricmp(p, ".BAT") || !stricmp(p, ".BTM")))) 634 return TRUE; 635 635 } 636 636 else if ((!ret && (!apptype || 637 638 639 640 641 642 643 637 (apptype & 638 (FAPPTYP_NOTWINDOWCOMPAT | 639 FAPPTYP_WINDOWCOMPAT | 640 FAPPTYP_WINDOWAPI | 641 FAPPTYP_BOUND | 642 FAPPTYP_32BIT)))) || 643 (p && (!stricmp(p, ".CMD") || !stricmp(p, ".BTM")))) 644 644 return TRUE; 645 645 if (fProtectOnly && (apptype & 646 647 648 649 650 646 (FAPPTYP_DOS | 647 FAPPTYP_WINDOWSREAL | 648 FAPPTYP_WINDOWSPROT | 649 FAPPTYP_WINDOWSPROT31)) && 650 (p && (!stricmp(p, ".EXE") || !stricmp(p, ".COM")))) 651 651 saymsg(MB_OK, 652 653 654 655 652 HWND_DESKTOP, 653 NullStr, 654 GetPString(IDS_NOTPROTECTONLYEXE), 655 filename); 656 656 } 657 657 return FALSE; … … 733 733 driveflags[x] &= (DRIVE_IGNORE | DRIVE_NOPRESCAN | DRIVE_NOLOADICONS | 734 734 DRIVE_NOLOADSUBJS | DRIVE_NOLOADLONGS | 735 736 735 DRIVE_INCLUDEFILES | DRIVE_SLOW | DRIVE_NOSTATS | 736 DRIVE_WRITEVERIFYOFF); 737 737 if (removable != -1) { 738 738 struct … … 800 800 driveflags[x] &= (DRIVE_IGNORE | DRIVE_NOPRESCAN | DRIVE_NOLOADICONS | 801 801 DRIVE_NOLOADSUBJS | DRIVE_NOLOADLONGS | 802 803 802 DRIVE_INCLUDEFILES | DRIVE_SLOW | DRIVE_NOSTATS | 803 DRIVE_WRITEVERIFYOFF); 804 804 memset(driveserial, -1, sizeof(driveserial)); 805 805 DosError(FERR_DISABLEHARDERR); … … 808 808 if (ulDriveMap & (1 << x) && !(driveflags[x] & DRIVE_IGNORE)) { 809 809 { 810 811 812 813 814 815 816 810 ULONG flags = 0, size = sizeof(ULONG); 811 CHAR FlagKey[80]; 812 813 sprintf(FlagKey, "%c.DriveFlags", (CHAR) (x + 'A')); 814 if (PrfQueryProfileData(fmprof, appname, FlagKey, &flags, &size) && 815 size == sizeof(ULONG)) 816 driveflags[x] |= flags; 817 817 } 818 818 … … 849 849 PrfQueryProfileData(fmprof, appname, Key, &fVerifyOffChecked[x], &size); 850 850 if (!fVerifyOffChecked[x]) { 851 852 853 854 855 856 851 if (driveflags[x] & DRIVE_REMOVABLE) 852 driveflags[x] |= DRIVE_WRITEVERIFYOFF; 853 if (!(driveflags[x] & DRIVE_INVALID)) { 854 fVerifyOffChecked[x] = TRUE; 855 PrfWriteProfileData(fmprof, appname, Key, &fVerifyOffChecked[x], sizeof(BOOL)); 856 } 857 857 } 858 858 } … … 972 972 } 973 973 974 BOOL needs_quoting( register CHAR *f)974 BOOL needs_quoting(PCSZ f) 975 975 { 976 976 register CHAR *p = " &|<>"; … … 992 992 if ((UINT) str[x] < ' ' && str[x] != '\r' && str[x] != '\n' && str[x] != '\t' 993 993 && str[x] != '\x1b' && str[x] != '\x1a' && str[x] != '\x07' 994 995 994 && str[x] != '\x0c') { 995 return TRUE; 996 996 } 997 997 x++;
Note:
See TracChangeset
for help on using the changeset viewer.