Changeset 93144 in vbox
- Timestamp:
- Jan 8, 2022 2:43:00 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/os2/VBoxOs2AdditionsInstall.cpp
r93143 r93144 43 43 #define MY_NIL_HFILE (~(HFILE)0) 44 44 45 #if defined(DOXYGEN_RUNNING) 46 /** Enabled extra debug output in the matching functions. */ 47 # define DEBUG_MATCHING 48 #endif 49 45 50 46 51 /********************************************************************************************************************************* … … 54 59 size_t cbNewAlloc; 55 60 char *pszNew; 61 bool fAppendEof; 56 62 bool fOverflowed; 63 size_t cBogusChars; 57 64 } FILEEDITOR; 58 65 … … 70 77 static size_t g_cchBootDrivePath = sizeof("C:\\") - 1; 71 78 /** Where to install the guest additions files. */ 72 static CHAR g_szDstPath[CCHMAXPATH] = "C:\\VBox GA\\";79 static CHAR g_szDstPath[CCHMAXPATH] = "C:\\VBoxAdd\\"; 73 80 /** The length of g_szDstPath, including a trailing slash. */ 74 static size_t g_cchDstPath = sizeof("C:\\VBox GA\\") - 1;81 static size_t g_cchDstPath = sizeof("C:\\VBoxAdd\\") - 1; 75 82 /** Mask of SKIP_XXX flags of components/tasks to skip. */ 76 83 static uint8_t g_fSkipMask = 0; … … 171 178 static char *MyNumToString(char *pszBuf, unsigned uNum) 172 179 { 180 char *pszRet = pszBuf; 181 173 182 /* Convert to decimal and inverted digit order: */ 174 183 char szTmp[32]; … … 184 193 *pszBuf++ = szTmp[off]; 185 194 *pszBuf = '\0'; 186 return pszBuf; 195 196 return pszRet; 187 197 } 188 198 … … 238 248 static RTEXITCODE EditorReadInFile(FILEEDITOR *pEditor, const char *pszFilename, size_t cbExtraEdit, bool fMustExist) 239 249 { 250 FILESTATUS3 FileSts; 251 240 252 if (g_fVerbose) 241 253 WriteStrings(g_hStdOut, "info: Preparing \"", pszFilename, "\" modifications...\r\n", NULL); … … 250 262 OPEN_ACCESS_READONLY | OPEN_SHARE_DENYWRITE | OPEN_FLAGS_SEQUENTIAL | OPEN_FLAGS_NOINHERIT, 251 263 NULL /*pEaOp2*/); 264 if (rc == ERROR_OPEN_FAILED) 265 rc = DosQueryPathInfo(pszFilename, FIL_STANDARD, &FileSts, sizeof(FileSts)); 252 266 if (rc == ERROR_FILE_NOT_FOUND) 253 267 hFile = MY_NIL_HFILE; … … 258 272 * Get it's size and check that it's sane. 259 273 */ 260 FILESTATUS3 FileSts;261 274 if (hFile != MY_NIL_HFILE) 262 275 { … … 277 290 size_t cbAlloc = FileSts.cbFile * 2 + cbExtraEdit + 16; 278 291 rc = DosAllocMem(&pvAlloc, cbAlloc, PAG_COMMIT | PAG_WRITE | PAG_READ); 279 if (rc == NO_ERROR)292 if (rc != NO_ERROR) 280 293 return ApiError("DosAllocMem", rc); 281 294 282 295 memset(pvAlloc, 0, cbAlloc); 283 pEditor->cbOrg = FileSts.cbFile; 284 pEditor->pszOrg = (char *)pvAlloc; 285 pEditor->pszNew = (char *)pvAlloc + FileSts.cbFile + 1; 286 pEditor->cbNew = 0; 287 pEditor->cbNewAlloc = cbAlloc - FileSts.cbFile - 2; 296 pEditor->cbOrg = FileSts.cbFile; 297 pEditor->pszOrg = (char *)pvAlloc; 298 pEditor->pszNew = (char *)pvAlloc + FileSts.cbFile + 1; 299 pEditor->cbNew = 0; 300 pEditor->cbNewAlloc = cbAlloc - FileSts.cbFile - 2; 301 pEditor->fAppendEof = false; 302 pEditor->fOverflowed = false; 303 pEditor->cBogusChars = 0; 288 304 289 305 /* … … 300 316 3, "DosRead(\"", pszFilename, "\")"); 301 317 DosClose(hFile); 318 319 /* 320 * Check for EOF/SUB character. 321 */ 322 char *pchEof = (char *)memchr(pEditor->pszOrg, 0x1a, FileSts.cbFile); 323 if (pchEof) 324 { 325 size_t offEof = pchEof - pEditor->pszOrg; 326 for (size_t off = offEof + 1; off < FileSts.cbFile; off++) 327 if (!RT_C_IS_SPACE(pEditor->pszOrg[off])) 328 return ErrorNStrings(RT_STR_TUPLE("Refusing to modify \""), pszFilename, -1, 329 RT_STR_TUPLE("\" because of EOF character followed by text!")); 330 pEditor->cbOrg = offEof; 331 pEditor->fAppendEof = true; 332 } 302 333 } 303 334 … … 350 381 ULONG cbWritten = 0; 351 382 do 352 rc = DosWrite(hFile, pEditor->pszOrg, pEditor->cbOrg , &cbWritten);383 rc = DosWrite(hFile, pEditor->pszOrg, pEditor->cbOrg + (pEditor->fAppendEof ? 1 : 0), &cbWritten); 353 384 while (rc == ERROR_INTERRUPT); 354 385 DosClose(hFile); … … 381 412 return ApiErrorN(rc, 3, "Opening \"", pszFilename, "\" for writing"); 382 413 414 ULONG cbToWrite = pEditor->cbNew; 415 if (pEditor->fAppendEof) 416 { 417 pEditor->pszNew[cbToWrite] = 0x1a; /* replacing terminator */ 418 cbToWrite++; 419 } 420 383 421 ULONG cbWritten = 0; 384 422 do 385 rc = DosWrite(hFile, pEditor->pszNew, pEditor->cbNew, &cbWritten);423 rc = DosWrite(hFile, pEditor->pszNew, cbToWrite, &cbWritten); 386 424 while (rc == ERROR_INTERRUPT); 387 388 425 RTEXITCODE rcExit = RTEXITCODE_SUCCESS; 389 426 if (rc != NO_ERROR) 390 427 rcExit = ApiErrorN(rc, 3, "Failed writing \"", pszFilename, "\""); 391 else if (cbWritten != pEditor->cbNew) 392 rcExit = ApiErrorN(ERROR_MORE_DATA, 3, "Failed writing \"", pszFilename, "\" - incomplete write"); 428 else if (cbWritten != cbToWrite) 429 { 430 char szNum1[32], szNum2[32]; 431 rcExit = ErrorNStrings(RT_STR_TUPLE("Failed writing \""), pszFilename, -1, RT_STR_TUPLE("\" - incomplete write: "), 432 MyNumToString(szNum1, cbWritten), -1, RT_STR_TUPLE(" written, requested "), 433 MyNumToString(szNum2, cbToWrite), NULL, 0); 434 } 393 435 394 436 rc = DosClose(hFile); 395 437 if (rc != NO_ERROR) 396 438 rcExit = ApiErrorN(rc, 3, "Failed closing \"", pszFilename, "\""); 439 440 pEditor->pszNew[pEditor->cbNew - 1] = '\0'; /* replacing EOF */ 397 441 398 442 return rcExit; … … 450 494 451 495 /** 496 * Checks that a string doesn't contain any funny control characters. 497 * 498 * These bogus characters are counted and EditorCheckState should be called to 499 * check these after editing has completed. 500 */ 501 static void EditorCheckString(FILEEDITOR *pEditor, const char *pchString, size_t cchString, const char *pszCaller) 502 { 503 for (size_t off = 0; off < cchString; off++) 504 { 505 if ( RT_C_IS_CNTRL(pchString[off]) 506 && pchString[off] != '\t') 507 { 508 static char s_szHex[] = "0123456789abcdef"; 509 char szDigits[3] = { s_szHex[pchString[off] >> 4], s_szHex[pchString[off] & 0xf], '\0' }; 510 ErrorNStrings(pszCaller, -1, RT_STR_TUPLE(": Bogus control character in "), 511 pEditor == &g_ConfigSys ? "Config.sys: " : "Startup.cmd: ", -1, szDigits, 2, NULL, 0); 512 pEditor->cBogusChars++; 513 } 514 } 515 } 516 517 518 /** 452 519 * Adds a line to the output buffer. 453 520 * … … 463 530 static bool EditorPutLine(FILEEDITOR *pEditor, const char *pchLine, size_t cchLine) 464 531 { 532 EditorCheckString(pEditor, pchLine, cchLine, "EditorPutLine"); 533 465 534 size_t offNew = pEditor->cbNew; 466 535 if (offNew + cchLine + 2 < pEditor->cbNewAlloc) … … 492 561 static bool EditorPutStringN(FILEEDITOR *pEditor, const char *pchString, size_t cchString) 493 562 { 563 EditorCheckString(pEditor, pchString, cchString, "EditorPutStringN"); 564 494 565 size_t offNew = pEditor->cbNew; 495 566 if (offNew + cchString < pEditor->cbNewAlloc) … … 508 579 509 580 /** 581 * Checks the editor state and makes the editing was successful. 582 */ 583 static RTEXITCODE EditorCheckState(FILEEDITOR *pEditor, const char *pszFilename) 584 { 585 if (pEditor->fOverflowed) 586 return ErrorNStrings(RT_STR_TUPLE("Editor overflowed while modifying \""), pszFilename, -1, RT_STR_TUPLE("\"")); 587 if (pEditor->cBogusChars > 0) 588 return ErrorNStrings(RT_STR_TUPLE("Editing failed because \""), pszFilename, -1, 589 RT_STR_TUPLE("\" contains bogus control characters (see above)")); 590 return RTEXITCODE_SUCCESS; 591 } 592 593 594 /** 510 595 * Simplistic case-insensitive memory compare function. 511 596 */ … … 531 616 * @returns true if matched, false if not. 532 617 * @param pchLine The line we're working on. 533 * @param off The current line offset.618 * @param poff The current line offset. Updated on match. 534 619 * @param cchLine The current line length. 535 620 * @param pszWord The word to match with. … … 537 622 * @param chAltSep Alternative word separator, optional. 538 623 */ 539 static bool MatchWord(const char *pchLine, size_t off, size_t cchLine, const char *pszWord, size_t cchWord, char chAltSep = ' ') 540 { 624 static bool MatchWord(const char *pchLine, size_t *poff, size_t cchLine, const char *pszWord, size_t cchWord, char chAltSep = ' ') 625 { 626 size_t off = *poff; 541 627 pchLine += off; 542 628 cchLine -= off; … … 546 632 || RT_C_IS_BLANK(pchLine[cchWord]) 547 633 || pchLine[cchWord] == chAltSep) 634 { 635 *poff += cchWord; 548 636 return true; 637 } 549 638 return false; 550 639 } … … 552 641 553 642 /** 554 * Checks if the path @a pch Stringends with @a pszFilename, ignoring case.643 * Checks if the path @a pchLine[@a off] ends with @a pszFilename, ignoring case. 555 644 * 556 645 * @returns true if filename found, false if not. 557 * @param pchString The image PATH of a DEVICE or IFS statement. 558 * @param cchString The length of valid string. 646 * @param pchLine The line we're working on. 647 * @param off The current line offset where the image path of 648 * a DEVICE or IFS statement starts. 649 * @param cchLine The current line length. 559 650 * @param pszFilename The filename (no path) to match with, all upper 560 651 * cased. 561 652 * @param cchFilename The length of the filename to match with. 562 653 */ 563 static bool MatchOnlyFilename(const char *pchString, size_t cchString, const char *pszFilename, size_t cchFilename) 564 { 654 static bool MatchOnlyFilename(const char *pchLine, size_t off, size_t cchLine, const char *pszFilename, size_t cchFilename) 655 { 656 pchLine += off; 657 cchLine -= off; 658 565 659 /* 566 660 * Skip ahead in pchString till we get to the filename. … … 568 662 size_t offFilename = 0; 569 663 size_t offCur = 0; 570 if ( cch String> 2571 && pch String[1] == ':'572 && RT_C_IS_ALPHA(pch String[0]))664 if ( cchLine > 2 665 && pchLine[1] == ':' 666 && RT_C_IS_ALPHA(pchLine[0])) 573 667 offCur += 2; 574 while (offCur < cch String)575 { 576 char ch = pch String[offCur];577 if (RTPATH_IS_SLASH(pch String[offCur]))668 while (offCur < cchLine) 669 { 670 char ch = pchLine[offCur]; 671 if (RTPATH_IS_SLASH(pchLine[offCur])) 578 672 offFilename = offCur + 1; 579 673 else if (RT_C_IS_BLANK(ch)) … … 582 676 } 583 677 size_t const cchLeftFilename = offCur - offFilename; 678 #ifdef DEBUG_MATCHING 679 WriteNStrings(g_hStdOut, RT_STR_TUPLE("debug: MatchOnlyFilename: '"), &pchLine[offFilename], cchLeftFilename, 680 RT_STR_TUPLE("' vs '"), pszFilename, cchFilename, RT_STR_TUPLE("'\r\n"), NULL, 0); 681 #endif 584 682 585 683 /* … … 592 690 * Check if the filenames matches (ASSUMES right side is uppercased). 593 691 */ 594 pch String+= offFilename;692 pchLine += offFilename; 595 693 while (cchFilename-- > 0) 596 694 { 597 if (RT_C_TO_UPPER(*pch String) != *pszFilename)695 if (RT_C_TO_UPPER(*pchLine) != *pszFilename) 598 696 return false; 599 pch String++;697 pchLine++; 600 698 pszFilename++; 601 699 } 700 #ifdef DEBUG_MATCHING 701 WriteStrings(g_hStdOut, "debug: MatchOnlyFilename: -> true\r\n", NULL); 702 #endif 602 703 return true; 704 } 705 706 707 static bool MatchPath(const char *pchPath1, size_t cchPath1, const char *pchPath2, size_t cchPath2) 708 { 709 #ifdef DEBUG_MATCHING 710 WriteNStrings(g_hStdOut, RT_STR_TUPLE("debug: MatchPath: '"), pchPath1, cchPath1, 711 RT_STR_TUPLE("' vs '"), pchPath2, cchPath2, RT_STR_TUPLE("'\r\n"), NULL, 0); 712 #endif 713 714 while (cchPath1 > 0 && cchPath2 > 0) 715 { 716 char const ch1 = *pchPath1++; 717 cchPath1--; 718 char const ch2 = *pchPath2++; 719 cchPath2--; 720 721 /* Slashes are special as it generally doesn't matter how many are in 722 a row, at least no on decent systems. */ 723 if (RTPATH_IS_SLASH(ch1)) 724 { 725 if (!RTPATH_IS_SLASH(ch2)) 726 return false; 727 while (cchPath1 > 0 && RTPATH_IS_SLASH(*pchPath1)) 728 pchPath1++, cchPath1--; 729 while (cchPath2 > 0 && RTPATH_IS_SLASH(*pchPath2)) 730 pchPath2++, cchPath2--; 731 } 732 /* Just uppercase before comparing to save space. */ 733 else if (RT_C_TO_UPPER(ch1) != RT_C_TO_UPPER(ch2)) 734 return false; 735 } 736 737 /* Ignore trailing slashes before reaching a conclusion. */ 738 while (cchPath1 > 0 && RTPATH_IS_SLASH(*pchPath1)) 739 pchPath1++, cchPath1--; 740 while (cchPath2 > 0 && RTPATH_IS_SLASH(*pchPath2)) 741 pchPath2++, cchPath2--; 742 743 #ifdef DEBUG_MATCHING 744 if (cchPath1 == 0 && cchPath2 == 0) 745 WriteStrings(g_hStdOut, "debug: MatchPath: -> true\r\n", NULL); 746 #endif 747 return cchPath1 == 0 && cchPath2 == 0; 603 748 } 604 749 … … 617 762 APIRET rc = DosQueryPathInfo(g_szBootDrivePath, FIL_STANDARD, &FileSts, sizeof(FileSts)); 618 763 if (rc != NO_ERROR) 619 return ApiErrorN(rc, 3, "DosQueryPathInfo(\"", g_szBootDrivePath, "\",,,) - installed gengradd?");764 return ApiErrorN(rc, 3, "DosQueryPathInfo(\"", g_szBootDrivePath, "\",,,) [installed gengradd?] "); 620 765 621 766 /* Note! GRADD precense in Config.sys is checked below while modifying it. */ … … 685 830 686 831 strcpy(&g_szBootDrivePath[g_cchBootDrivePath], "CONFIG.SYS"); 687 RTEXITCODE rcExit = EditorReadInFile(&g_ConfigSys, g_szBootDrivePath, 2048, true /*fMustExist*/);832 RTEXITCODE rcExit = EditorReadInFile(&g_ConfigSys, g_szBootDrivePath, 4096, true /*fMustExist*/); 688 833 if (rcExit != RTEXITCODE_SUCCESS) 689 834 return rcExit; … … 744 889 */ 745 890 char szLineNo[32]; 891 char szNumBuf[32]; 746 892 bool fInsertedGuest = false; 747 893 bool fInsertedMouse = RT_BOOL(g_fSkipMask & SKIP_MOUSE); … … 773 919 * If there are multiple SET PATH statements, we add ourselves to all of them. 774 920 */ 775 if (MatchWord(pchLine, off, cchLine, RT_STR_TUPLE("SET"))) 776 { 777 off += sizeof("SET") - 1; 921 if (MatchWord(pchLine, &off, cchLine, RT_STR_TUPLE("SET"))) 922 { 778 923 SKIP_BLANKS(); 779 if (MatchWord(pchLine, off, cchLine, RT_STR_TUPLE("PATH"), '='))924 if (MatchWord(pchLine, &off, cchLine, RT_STR_TUPLE("PATH"), '=')) 780 925 { 781 off += sizeof("PATH") - 1;782 926 SKIP_BLANKS(); 783 927 if (cchLine > off && pchLine[off] == '=') … … 789 933 WriteStrings(g_hStdOut, "info: Config.sys line ", MyNumToString(szLineNo, iLine), ": SET PATH\r\n", NULL); 790 934 791 /* check if already part of the string */ 792 bool fNeeded = true; 793 /** @todo look for destination directory in PATH. */ 794 795 if (fNeeded) 935 /* Strip trailing spaces and semicolons. */ 936 while (cchLine > off && (RT_C_IS_BLANK(pchLine[cchLine - 1]) || pchLine[cchLine - 1] == ';')) 937 cchLine--; 938 939 /* Remove any previous entries of the destination directory. */ 940 unsigned iElement = 0; 941 char chLast = 0; 942 uint32_t cchWritten = 0; 943 while (off < cchLine) 796 944 { 797 while (cchLine > off && RT_C_IS_BLANK(pchLine[cchLine - 1])) 798 cchLine--; 799 EditorPutStringN(&g_ConfigSys, pchLine, cchLine); 800 if (pchLine[cchLine - 1] != ';') 801 EditorPutStringN(&g_ConfigSys, RT_STR_TUPLE(";")); 802 EditorPutStringN(&g_ConfigSys, g_szDstPath, g_cchDstPath - (g_cchDstPath > 3 ? 1 : 0)); 803 EditorPutLine(&g_ConfigSys, RT_STR_TUPLE(";")); 804 fDone = true; 945 iElement++; 946 const char *pszElement = &pchLine[off]; 947 const char *pszSemiColon = (const char *)memchr(&pchLine[off], ';', cchLine - off); 948 size_t cchElement = (pszSemiColon ? pszSemiColon : &pchLine[cchLine]) - pszElement; 949 if (MatchPath(pszElement, cchElement, g_szDstPath, g_cchDstPath - (g_cchDstPath > 3 ? 1 : 0))) 950 { 951 if (g_fVerbose) 952 WriteNStrings(g_hStdOut, RT_STR_TUPLE("info: Config.sys line "), 953 MyNumToString(szLineNo, iLine), -1, RT_STR_TUPLE(": Removing PATH element #"), 954 MyNumToString(szNumBuf, iElement), -1, RT_STR_TUPLE(" \""), pszElement, cchElement, 955 RT_STR_TUPLE("\"\r\n"), NULL, 0); 956 EditorPutStringN(&g_ConfigSys, &pchLine[cchWritten], off - cchWritten); 957 chLast = pchLine[off - 1]; 958 cchWritten = off + cchElement + (chLast == ';'); 959 } 960 off += cchElement + 1; 805 961 } 962 963 /* Write out the rest of the line and append the destination directory to it. */ 964 if (cchLine > cchWritten) 965 { 966 EditorPutStringN(&g_ConfigSys, &pchLine[cchWritten], cchLine - cchWritten); 967 chLast = pchLine[cchLine - 1]; 968 } 969 if (chLast != ';') 970 EditorPutStringN(&g_ConfigSys, RT_STR_TUPLE(";")); 971 EditorPutStringN(&g_ConfigSys, g_szDstPath, g_cchDstPath - (g_cchDstPath > 3 ? 1 : 0)); 972 EditorPutLine(&g_ConfigSys, RT_STR_TUPLE(";")); 973 fDone = true; 974 806 975 cPathsFound += 1; 807 976 } … … 815 984 * other values can only be done by users or special drivers. 816 985 */ 817 else if (MatchWord(pchLine, off, cchLine, RT_STR_TUPLE("GRADD_CHAINS"), '='))986 else if (MatchWord(pchLine, &off, cchLine, RT_STR_TUPLE("GRADD_CHAINS"), '=')) 818 987 { 819 off += sizeof("GRADD_CHAINS") - 1;820 988 SKIP_BLANKS(); 821 989 if (cchLine > off && pchLine[off] == '=') … … 856 1024 * Look for the chains listed by GRADD_CHAINS. 857 1025 */ 858 else if (MatchWord(pchLine, off, cchLine, pchGraddChains, cchGraddChains, '='))1026 else if (MatchWord(pchLine, &off, cchLine, pchGraddChains, cchGraddChains, '=')) 859 1027 { 860 off += cchGraddChains;861 1028 SKIP_BLANKS(); 862 1029 if (cchLine > off && pchLine[off] == '=') … … 880 1047 * Look for that IFS that should be loaded before we can load our drivers. 881 1048 */ 882 else if (MatchWord(pchLine, off, cchLine, RT_STR_TUPLE("IFS"), '=')) 883 { 884 off += sizeof("IFS") - 1; 1049 else if (MatchWord(pchLine, &off, cchLine, RT_STR_TUPLE("IFS"), '=')) 1050 { 885 1051 SKIP_BLANKS(); 886 1052 if (cchLine > off && pchLine[off] == '=') … … 888 1054 off++; 889 1055 SKIP_BLANKS(); 890 if (MatchOnlyFilename( &pchLine[off], cchLine - off, pszAfterIfs, cchAfterIfs))1056 if (MatchOnlyFilename(pchLine, off, cchLine, pszAfterIfs, cchAfterIfs)) 891 1057 { 892 1058 if (g_fVerbose) … … 905 1071 /* Remove old VBoxSF.IFS lines */ 906 1072 else if ( !(g_fSkipMask & SKIP_SHARED_FOLDERS) 907 && MatchOnlyFilename(&pchLine[off], cchLine, RT_STR_TUPLE("VBOXSF.IFS"))) 1073 && ( MatchOnlyFilename(pchLine, off, cchLine, RT_STR_TUPLE("VBOXFS.IFS")) 1074 || MatchOnlyFilename(pchLine, off, cchLine, RT_STR_TUPLE("VBOXSF.IFS")) ) ) 908 1075 { 909 1076 if (g_fVerbose) … … 918 1085 * as well as older VBoxGuest.sys statements we should remove. 919 1086 */ 920 else if (MatchWord(pchLine, off, cchLine, RT_STR_TUPLE("DEVICE"), '=')) 921 { 922 off += sizeof("DEVICE") - 1; 1087 else if (MatchWord(pchLine, &off, cchLine, RT_STR_TUPLE("DEVICE"), '=')) 1088 { 923 1089 SKIP_BLANKS(); 924 1090 if (cchLine > off && pchLine[off] == '=') … … 927 1093 SKIP_BLANKS(); 928 1094 if ( !(g_fSkipMask & SKIP_MOUSE) 929 && MatchOnlyFilename( &pchLine[off], cchLine - off, RT_STR_TUPLE("MOUSE.SYS")))1095 && MatchOnlyFilename(pchLine, off, cchLine, RT_STR_TUPLE("MOUSE.SYS"))) 930 1096 { 931 1097 if (g_fVerbose) … … 946 1112 /* Remove or replace old VBoxMouse.IFS lines */ 947 1113 else if ( !(g_fSkipMask & SKIP_MOUSE) 948 && MatchOnlyFilename( &pchLine[off], cchLine, RT_STR_TUPLE("VBOXMOUSE.SYS")))1114 && MatchOnlyFilename(pchLine, off, cchLine, RT_STR_TUPLE("VBOXMOUSE.SYS"))) 949 1115 { 950 1116 if (g_fVerbose) … … 962 1128 } 963 1129 /* Remove old VBoxGuest.sys lines. */ 964 else if (MatchOnlyFilename( &pchLine[off], cchLine, RT_STR_TUPLE("VBOXGUEST.SYS")))1130 else if (MatchOnlyFilename(pchLine, off, cchLine, RT_STR_TUPLE("VBOXGUEST.SYS"))) 965 1131 { 966 1132 if (g_fVerbose) … … 1041 1207 } 1042 1208 1043 return RTEXITCODE_SUCCESS;1209 return EditorCheckState(&g_ConfigSys, g_szBootDrivePath); 1044 1210 } 1045 1211 … … 1049 1215 { 1050 1216 if (g_fVerbose) 1051 WriteStrings(g_hStdOut, "info: Starting VBoxService at line ", pszLineNo, " inStartup.cmd\r\n", NULL);1217 WriteStrings(g_hStdOut, "info: Starting VBoxService at line ", pszLineNo, " of Startup.cmd\r\n", NULL); 1052 1218 EditorPutStringN(&g_StartupCmd, g_szDstPath, g_cchDstPath); 1053 1219 EditorPutLine(&g_StartupCmd, RT_STR_TUPLE("VBoxService.exe")); … … 1092 1258 SKIP_BLANKS(); 1093 1259 } 1094 if (MatchWord(pchLine, off, cchLine, RT_STR_TUPLE("ECHO"))) 1095 { 1096 off += sizeof("ECHO") - 1; 1260 if (MatchWord(pchLine, &off, cchLine, RT_STR_TUPLE("ECHO"))) 1261 { 1097 1262 SKIP_BLANKS(); 1098 1263 1099 if (MatchWord(pchLine, off, cchLine, RT_STR_TUPLE("OFF")))1264 if (MatchWord(pchLine, &off, cchLine, RT_STR_TUPLE("OFF"))) 1100 1265 { 1101 1266 iInsertBeforeLine = iLine + 1; … … 1103 1268 } 1104 1269 } 1105 else if (MatchWord(pchLine, off, cchLine, RT_STR_TUPLE("REM")))1270 else if (MatchWord(pchLine, &off, cchLine, RT_STR_TUPLE("REM"))) 1106 1271 { /* skip */ } 1107 1272 else … … 1135 1300 } 1136 1301 1137 if (MatchWord(pchLine, off, cchLine, RT_STR_TUPLE("DETACH"))) 1138 { 1139 off += sizeof("DEATCH") - 1; 1302 if (MatchWord(pchLine, &off, cchLine, RT_STR_TUPLE("DETACH"))) 1140 1303 SKIP_BLANKS(); 1141 } 1142 1143 if (MatchWord(pchLine, off, cchLine, RT_STR_TUPLE("CALL"))) 1144 { 1145 off += sizeof("CALL") - 1; 1304 1305 if (MatchWord(pchLine, &off, cchLine, RT_STR_TUPLE("CALL"))) 1146 1306 SKIP_BLANKS(); 1147 } 1148 1149 if (MatchWord(pchLine, off, cchLine, RT_STR_TUPLE("START"))) 1150 { 1151 off += sizeof("START") - 1; 1307 1308 if (MatchWord(pchLine, &off, cchLine, RT_STR_TUPLE("START"))) 1152 1309 SKIP_BLANKS(); 1153 } 1154 1155 if ( cchLine - off < sizeof("VBOXSERVICE") - 1 /* (Should be harmless to go past end of buffer due to missing .EXE) */ 1156 && ( MatchOnlyFilename(&pchLine[off], cchLine - off, RT_STR_TUPLE("VBOXSERVICE.EXE")) == 0 1157 || MatchOnlyFilename(&pchLine[off], cchLine - off, RT_STR_TUPLE("VBOXSERVICE")) == 0)) 1310 1311 if ( MatchOnlyFilename(pchLine, off, cchLine, RT_STR_TUPLE("VBOXSERVICE.EXE")) 1312 || MatchOnlyFilename(pchLine, off, cchLine, RT_STR_TUPLE("VBOXSERVICE")) ) 1158 1313 { 1159 1314 if (g_fVerbose) … … 1167 1322 } 1168 1323 1169 1170 return RTEXITCODE_SUCCESS; 1324 return EditorCheckState(&g_StartupCmd, g_szBootDrivePath); 1171 1325 } 1172 1326 … … 1183 1337 FILESTATUS3 FileSts; 1184 1338 APIRET rc = DosQueryPathInfo(pszDst, FIL_STANDARD, &FileSts, sizeof(FileSts)); 1185 if (rc != NO_ERROR && (FileSts.attrFile & FILE_READONLY)) 1186 { 1187 rc = DosQueryPathInfo(pszDst, FIL_STANDARD, &FileSts, sizeof(FileSts)); 1188 1339 if (rc == NO_ERROR && (FileSts.attrFile & FILE_READONLY)) 1340 { 1189 1341 FileSts.attrFile &= ~FILE_READONLY; 1190 1342 … … 1247 1399 *psz = '\0'; 1248 1400 APIRET rc = DosMkDir(g_szDstPath, 0); 1249 if (rc != NO_ERROR && rc != ERROR_A LREADY_EXISTS)1401 if (rc != NO_ERROR && rc != ERROR_ACCESS_DENIED /*HPFS*/ && rc != ERROR_ALREADY_EXISTS /*what one would expect*/) 1250 1402 return ApiErrorN(rc, 3, "DosMkDir(\"", g_szDstPath, "\")"); 1251 1403 if (ch == '\0') … … 1272 1424 { "VBoxControl.exe", NULL, 0 }, 1273 1425 { "VBoxReplaceDll.exe", NULL, 0 }, 1274 { "gengradd.dll", " \\OS2\\DLL\\gengradd.dll", SKIP_GRAPHICS },1275 { "libc06.dll", " \\OS2\\DLL\\libc06.dll", SKIP_LIBC_DLLS },1276 { "libc061.dll", " \\OS2\\DLL\\libc061.dll", SKIP_LIBC_DLLS },1277 { "libc062.dll", " \\OS2\\DLL\\libc062.dll", SKIP_LIBC_DLLS },1278 { "libc063.dll", " \\OS2\\DLL\\libc063.dll", SKIP_LIBC_DLLS },1279 { "libc064.dll", " \\OS2\\DLL\\libc064.dll", SKIP_LIBC_DLLS },1280 { "libc065.dll", " \\OS2\\DLL\\libc065.dll", SKIP_LIBC_DLLS },1281 { "libc066.dll", " \\OS2\\DLL\\libc066.dll", SKIP_LIBC_DLLS },1426 { "gengradd.dll", "OS2\\DLL\\gengradd.dll", SKIP_GRAPHICS }, 1427 { "libc06.dll", "OS2\\DLL\\libc06.dll", SKIP_LIBC_DLLS }, 1428 { "libc061.dll", "OS2\\DLL\\libc061.dll", SKIP_LIBC_DLLS }, 1429 { "libc062.dll", "OS2\\DLL\\libc062.dll", SKIP_LIBC_DLLS }, 1430 { "libc063.dll", "OS2\\DLL\\libc063.dll", SKIP_LIBC_DLLS }, 1431 { "libc064.dll", "OS2\\DLL\\libc064.dll", SKIP_LIBC_DLLS }, 1432 { "libc065.dll", "OS2\\DLL\\libc065.dll", SKIP_LIBC_DLLS }, 1433 { "libc066.dll", "OS2\\DLL\\libc066.dll", SKIP_LIBC_DLLS }, 1282 1434 { "VBoxGuest.sys", NULL, 0 }, 1283 1435 { "VBoxSF.ifs", NULL, 0 }, … … 1300 1452 && !(s_aFiles[i].fSkipMask & g_fSkipMask) /* ASSUMES one skip bit per file */) 1301 1453 { 1302 strcpy(&g_szBootDrivePath[g_cchBootDrivePath], s_aFiles[i].psz File);1454 strcpy(&g_szBootDrivePath[g_cchBootDrivePath], s_aFiles[i].pszAltDst); 1303 1455 1304 1456 rcExit2 = CopyOneFile(g_szSrcPath, g_szBootDrivePath); … … 1332 1484 return RTEXITCODE_SUCCESS; 1333 1485 strcpy(&g_szBootDrivePath[g_cchBootDrivePath], "STARTUP.CMD"); 1334 return EditorWriteOutFile(&g_ ConfigSys, g_szBootDrivePath);1486 return EditorWriteOutFile(&g_StartupCmd, g_szBootDrivePath); 1335 1487 } 1336 1488 … … 1355 1507 " or VBoxIs2AdditionsInstall.exe <-v|--version>\r\n" 1356 1508 "\r\n" 1357 "Options \r\n:"1509 "Options:\r\n" 1358 1510 " -s<path>, --source[=]<path>\r\n" 1359 1511 " Specifies where the files to install are. Default: Same as installer\r\n" 1360 1512 " -d<path>, --destination[=]<path>\r\n" 1361 1513 " Specifies where to install all the VBox OS/2 additions files.\r\n" 1362 " Default: C:\VBox GA(C is replaced by actual boot drive)\r\n"1514 " Default: C:\VBoxAdd (C is replaced by actual boot drive)\r\n" 1363 1515 " -b<path>, --boot-drive[=]<path>\r\n" 1364 1516 " Specifies the boot drive. Default: C: (C is replaced by the actual one)\r\n" … … 1502 1654 ULONG ulBootDrv = 0x80; 1503 1655 DosQuerySysInfo(QSV_BOOT_DRIVE, QSV_BOOT_DRIVE, &ulBootDrv, sizeof(ulBootDrv)); 1504 g_szBootDrivePath[0] = g_szDstPath[0] = 'A' + ulBootDrv ;1656 g_szBootDrivePath[0] = g_szDstPath[0] = 'A' + ulBootDrv - 1; 1505 1657 1506 1658 /* … … 1643 1795 RTPathStripFilename(g_szSrcPath); 1644 1796 g_cchSrcPath = RTPathEnsureTrailingSeparator(g_szSrcPath, sizeof(g_szSrcPath)); 1645 if (g_cchSrcPath )1797 if (g_cchSrcPath == 0) 1646 1798 return ApiError("RTPathEnsureTrailingSeparator", ERROR_BUFFER_OVERFLOW); 1647 1799 }
Note:
See TracChangeset
for help on using the changeset viewer.