VirtualBox

Changeset 93144 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Jan 8, 2022 2:43:00 AM (3 years ago)
Author:
vboxsync
Message:

Add/os2: Debugged the installer code and implemented removal of old PATH elements. Config.sys and Startup.cmd often contains an EOF character (0x1a) at the end, so remove it during editing and re-add it when writing it to disk.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/os2/VBoxOs2AdditionsInstall.cpp

    r93143 r93144  
    4343#define MY_NIL_HFILE        (~(HFILE)0)
    4444
     45#if defined(DOXYGEN_RUNNING)
     46/** Enabled extra debug output in the matching functions. */
     47# define DEBUG_MATCHING
     48#endif
     49
    4550
    4651/*********************************************************************************************************************************
     
    5459    size_t          cbNewAlloc;
    5560    char           *pszNew;
     61    bool            fAppendEof;
    5662    bool            fOverflowed;
     63    size_t          cBogusChars;
    5764} FILEEDITOR;
    5865
     
    7077static size_t       g_cchBootDrivePath              = sizeof("C:\\") - 1;
    7178/** Where to install the guest additions files.  */
    72 static CHAR         g_szDstPath[CCHMAXPATH]         = "C:\\VBoxGA\\";
     79static CHAR         g_szDstPath[CCHMAXPATH]         = "C:\\VBoxAdd\\";
    7380/** The length of g_szDstPath, including a trailing slash. */
    74 static size_t       g_cchDstPath                    = sizeof("C:\\VBoxGA\\") - 1;
     81static size_t       g_cchDstPath                    = sizeof("C:\\VBoxAdd\\") - 1;
    7582/** Mask of SKIP_XXX flags of components/tasks to skip. */
    7683static uint8_t      g_fSkipMask                     = 0;
     
    171178static char *MyNumToString(char *pszBuf, unsigned uNum)
    172179{
     180    char *pszRet = pszBuf;
     181
    173182    /* Convert to decimal and inverted digit order:  */
    174183    char     szTmp[32];
     
    184193        *pszBuf++ = szTmp[off];
    185194    *pszBuf = '\0';
    186     return pszBuf;
     195
     196    return pszRet;
    187197}
    188198
     
    238248static RTEXITCODE EditorReadInFile(FILEEDITOR *pEditor, const char *pszFilename, size_t cbExtraEdit, bool fMustExist)
    239249{
     250    FILESTATUS3 FileSts;
     251
    240252    if (g_fVerbose)
    241253        WriteStrings(g_hStdOut, "info: Preparing \"", pszFilename, "\" modifications...\r\n", NULL);
     
    250262                        OPEN_ACCESS_READONLY | OPEN_SHARE_DENYWRITE | OPEN_FLAGS_SEQUENTIAL | OPEN_FLAGS_NOINHERIT,
    251263                        NULL /*pEaOp2*/);
     264    if (rc == ERROR_OPEN_FAILED)
     265        rc = DosQueryPathInfo(pszFilename, FIL_STANDARD, &FileSts, sizeof(FileSts));
    252266    if (rc == ERROR_FILE_NOT_FOUND)
    253267        hFile = MY_NIL_HFILE;
     
    258272     * Get it's size and check that it's sane.
    259273     */
    260     FILESTATUS3 FileSts;
    261274    if (hFile != MY_NIL_HFILE)
    262275    {
     
    277290    size_t cbAlloc = FileSts.cbFile * 2 + cbExtraEdit + 16;
    278291    rc = DosAllocMem(&pvAlloc, cbAlloc, PAG_COMMIT | PAG_WRITE | PAG_READ);
    279     if (rc == NO_ERROR)
     292    if (rc != NO_ERROR)
    280293        return ApiError("DosAllocMem", rc);
    281294
    282295    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;
    288304
    289305    /*
     
    300316                             3, "DosRead(\"", pszFilename, "\")");
    301317        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        }
    302333    }
    303334
     
    350381                ULONG cbWritten = 0;
    351382                do
    352                     rc = DosWrite(hFile, pEditor->pszOrg, pEditor->cbOrg, &cbWritten);
     383                    rc = DosWrite(hFile, pEditor->pszOrg, pEditor->cbOrg + (pEditor->fAppendEof ? 1 : 0), &cbWritten);
    353384                while (rc == ERROR_INTERRUPT);
    354385                DosClose(hFile);
     
    381412        return ApiErrorN(rc, 3, "Opening \"", pszFilename, "\" for writing");
    382413
     414    ULONG cbToWrite = pEditor->cbNew;
     415    if (pEditor->fAppendEof)
     416    {
     417        pEditor->pszNew[cbToWrite] = 0x1a; /* replacing terminator */
     418        cbToWrite++;
     419    }
     420
    383421    ULONG cbWritten = 0;
    384422    do
    385         rc = DosWrite(hFile, pEditor->pszNew, pEditor->cbNew, &cbWritten);
     423        rc = DosWrite(hFile, pEditor->pszNew, cbToWrite, &cbWritten);
    386424    while (rc == ERROR_INTERRUPT);
    387 
    388425    RTEXITCODE rcExit = RTEXITCODE_SUCCESS;
    389426    if (rc != NO_ERROR)
    390427        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    }
    393435
    394436    rc = DosClose(hFile);
    395437    if (rc != NO_ERROR)
    396438        rcExit = ApiErrorN(rc, 3, "Failed closing \"", pszFilename, "\"");
     439
     440    pEditor->pszNew[pEditor->cbNew - 1] = '\0'; /* replacing EOF */
    397441
    398442    return rcExit;
     
    450494
    451495/**
     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 */
     501static 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/**
    452519 * Adds a line to the output buffer.
    453520 *
     
    463530static bool EditorPutLine(FILEEDITOR *pEditor, const char *pchLine, size_t cchLine)
    464531{
     532    EditorCheckString(pEditor, pchLine, cchLine, "EditorPutLine");
     533
    465534    size_t offNew = pEditor->cbNew;
    466535    if (offNew + cchLine + 2 < pEditor->cbNewAlloc)
     
    492561static bool EditorPutStringN(FILEEDITOR *pEditor, const char *pchString, size_t cchString)
    493562{
     563    EditorCheckString(pEditor, pchString, cchString, "EditorPutStringN");
     564
    494565    size_t offNew = pEditor->cbNew;
    495566    if (offNew + cchString < pEditor->cbNewAlloc)
     
    508579
    509580/**
     581 * Checks the editor state and makes the editing was successful.
     582 */
     583static 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/**
    510595 * Simplistic case-insensitive memory compare function.
    511596 */
     
    531616 * @returns true if matched, false if not.
    532617 * @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.
    534619 * @param   cchLine     The current line length.
    535620 * @param   pszWord     The word to match with.
     
    537622 * @param   chAltSep    Alternative word separator, optional.
    538623 */
    539 static bool MatchWord(const char *pchLine, size_t off, size_t cchLine, const char *pszWord, size_t cchWord, char chAltSep = ' ')
    540 {
     624static 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;
    541627    pchLine += off;
    542628    cchLine -= off;
     
    546632                || RT_C_IS_BLANK(pchLine[cchWord])
    547633                || pchLine[cchWord] == chAltSep)
     634            {
     635                *poff += cchWord;
    548636                return true;
     637            }
    549638    return false;
    550639}
     
    552641
    553642/**
    554  * Checks if the path @a pchString ends with @a pszFilename, ignoring case.
     643 * Checks if the path @a pchLine[@a off] ends with @a pszFilename, ignoring case.
    555644 *
    556645 * @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.
    559650 * @param   pszFilename         The filename (no path) to match with, all upper
    560651 *                              cased.
    561652 * @param   cchFilename         The length of the filename to match with.
    562653 */
    563 static bool MatchOnlyFilename(const char *pchString, size_t cchString, const char *pszFilename, size_t cchFilename)
    564 {
     654static 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
    565659    /*
    566660     * Skip ahead in pchString till we get to the filename.
     
    568662    size_t offFilename = 0;
    569663    size_t offCur      = 0;
    570     if (   cchString > 2
    571         && pchString[1] == ':'
    572         && RT_C_IS_ALPHA(pchString[0]))
     664    if (   cchLine > 2
     665        && pchLine[1] == ':'
     666        && RT_C_IS_ALPHA(pchLine[0]))
    573667        offCur += 2;
    574     while (offCur < cchString)
    575     {
    576         char ch = pchString[offCur];
    577         if (RTPATH_IS_SLASH(pchString[offCur]))
     668    while (offCur < cchLine)
     669    {
     670        char ch = pchLine[offCur];
     671        if (RTPATH_IS_SLASH(pchLine[offCur]))
    578672            offFilename = offCur + 1;
    579673        else if (RT_C_IS_BLANK(ch))
     
    582676    }
    583677    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
    584682
    585683    /*
     
    592690     * Check if the filenames matches (ASSUMES right side is uppercased).
    593691     */
    594     pchString += offFilename;
     692    pchLine += offFilename;
    595693    while (cchFilename-- > 0)
    596694    {
    597         if (RT_C_TO_UPPER(*pchString) != *pszFilename)
     695        if (RT_C_TO_UPPER(*pchLine) != *pszFilename)
    598696            return false;
    599         pchString++;
     697        pchLine++;
    600698        pszFilename++;
    601699    }
     700#ifdef DEBUG_MATCHING
     701    WriteStrings(g_hStdOut, "debug: MatchOnlyFilename: -> true\r\n", NULL);
     702#endif
    602703    return true;
     704}
     705
     706
     707static 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;
    603748}
    604749
     
    617762    APIRET rc = DosQueryPathInfo(g_szBootDrivePath, FIL_STANDARD, &FileSts, sizeof(FileSts));
    618763    if (rc != NO_ERROR)
    619         return ApiErrorN(rc, 3, "DosQueryPathInfo(\"", g_szBootDrivePath, "\",,,) - installed gengradd?");
     764        return ApiErrorN(rc, 3, "DosQueryPathInfo(\"", g_szBootDrivePath, "\",,,) [installed gengradd?] ");
    620765
    621766    /* Note! GRADD precense in Config.sys is checked below while modifying it. */
     
    685830
    686831    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*/);
    688833    if (rcExit != RTEXITCODE_SUCCESS)
    689834        return rcExit;
     
    744889     */
    745890    char        szLineNo[32];
     891    char        szNumBuf[32];
    746892    bool        fInsertedGuest = false;
    747893    bool        fInsertedMouse = RT_BOOL(g_fSkipMask & SKIP_MOUSE);
     
    773919         * If there are multiple SET PATH statements, we add ourselves to all of them.
    774920         */
    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        {
    778923            SKIP_BLANKS();
    779             if (MatchWord(pchLine, off, cchLine, RT_STR_TUPLE("PATH"), '='))
     924            if (MatchWord(pchLine, &off, cchLine, RT_STR_TUPLE("PATH"), '='))
    780925            {
    781                 off += sizeof("PATH") - 1;
    782926                SKIP_BLANKS();
    783927                if (cchLine > off && pchLine[off] == '=')
     
    789933                        WriteStrings(g_hStdOut, "info: Config.sys line ", MyNumToString(szLineNo, iLine), ": SET PATH\r\n", NULL);
    790934
    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)
    796944                    {
    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;
    805961                    }
     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
    806975                    cPathsFound += 1;
    807976                }
     
    815984             * other values can only be done by users or special drivers.
    816985             */
    817             else if (MatchWord(pchLine, off, cchLine, RT_STR_TUPLE("GRADD_CHAINS"), '='))
     986            else if (MatchWord(pchLine, &off, cchLine, RT_STR_TUPLE("GRADD_CHAINS"), '='))
    818987            {
    819                 off += sizeof("GRADD_CHAINS") - 1;
    820988                SKIP_BLANKS();
    821989                if (cchLine > off && pchLine[off] == '=')
     
    8561024             * Look for the chains listed by GRADD_CHAINS.
    8571025             */
    858             else if (MatchWord(pchLine, off, cchLine, pchGraddChains, cchGraddChains, '='))
     1026            else if (MatchWord(pchLine, &off, cchLine, pchGraddChains, cchGraddChains, '='))
    8591027            {
    860                 off += cchGraddChains;
    8611028                SKIP_BLANKS();
    8621029                if (cchLine > off && pchLine[off] == '=')
     
    8801047         * Look for that IFS that should be loaded before we can load our drivers.
    8811048         */
    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        {
    8851051            SKIP_BLANKS();
    8861052            if (cchLine > off && pchLine[off] == '=')
     
    8881054                off++;
    8891055                SKIP_BLANKS();
    890                 if (MatchOnlyFilename(&pchLine[off], cchLine - off, pszAfterIfs, cchAfterIfs))
     1056                if (MatchOnlyFilename(pchLine, off, cchLine, pszAfterIfs, cchAfterIfs))
    8911057                {
    8921058                    if (g_fVerbose)
     
    9051071                /* Remove old VBoxSF.IFS lines */
    9061072                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")) ) )
    9081075                {
    9091076                    if (g_fVerbose)
     
    9181085         * as well as older VBoxGuest.sys statements we should remove.
    9191086         */
    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        {
    9231089            SKIP_BLANKS();
    9241090            if (cchLine > off && pchLine[off] == '=')
     
    9271093                SKIP_BLANKS();
    9281094                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")))
    9301096                {
    9311097                    if (g_fVerbose)
     
    9461112                /* Remove or replace old VBoxMouse.IFS lines */
    9471113                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")))
    9491115                {
    9501116                    if (g_fVerbose)
     
    9621128                }
    9631129                /* 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")))
    9651131                {
    9661132                    if (g_fVerbose)
     
    10411207    }
    10421208
    1043     return RTEXITCODE_SUCCESS;
     1209    return EditorCheckState(&g_ConfigSys, g_szBootDrivePath);
    10441210}
    10451211
     
    10491215{
    10501216    if (g_fVerbose)
    1051         WriteStrings(g_hStdOut, "info: Starting VBoxService at line ", pszLineNo, " in Startup.cmd\r\n", NULL);
     1217        WriteStrings(g_hStdOut, "info: Starting VBoxService at line ", pszLineNo, " of Startup.cmd\r\n", NULL);
    10521218    EditorPutStringN(&g_StartupCmd, g_szDstPath, g_cchDstPath);
    10531219    EditorPutLine(&g_StartupCmd, RT_STR_TUPLE("VBoxService.exe"));
     
    10921258            SKIP_BLANKS();
    10931259        }
    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        {
    10971262            SKIP_BLANKS();
    10981263
    1099             if (MatchWord(pchLine, off, cchLine, RT_STR_TUPLE("OFF")))
     1264            if (MatchWord(pchLine, &off, cchLine, RT_STR_TUPLE("OFF")))
    11001265            {
    11011266                iInsertBeforeLine = iLine + 1;
     
    11031268            }
    11041269        }
    1105         else if (MatchWord(pchLine, off, cchLine, RT_STR_TUPLE("REM")))
     1270        else if (MatchWord(pchLine, &off, cchLine, RT_STR_TUPLE("REM")))
    11061271        { /* skip */ }
    11071272        else
     
    11351300        }
    11361301
    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")))
    11401303            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")))
    11461306            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")))
    11521309            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")) )
    11581313        {
    11591314            if (g_fVerbose)
     
    11671322    }
    11681323
    1169 
    1170     return RTEXITCODE_SUCCESS;
     1324    return EditorCheckState(&g_StartupCmd, g_szBootDrivePath);
    11711325}
    11721326
     
    11831337    FILESTATUS3 FileSts;
    11841338    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    {
    11891341        FileSts.attrFile &= ~FILE_READONLY;
    11901342
     
    12471399            *psz = '\0';
    12481400        APIRET rc = DosMkDir(g_szDstPath, 0);
    1249         if (rc != NO_ERROR && rc != ERROR_ALREADY_EXISTS)
     1401        if (rc != NO_ERROR && rc != ERROR_ACCESS_DENIED /*HPFS*/ && rc != ERROR_ALREADY_EXISTS /*what one would expect*/)
    12501402            return ApiErrorN(rc, 3, "DosMkDir(\"", g_szDstPath, "\")");
    12511403        if (ch == '\0')
     
    12721424        { "VBoxControl.exe",    NULL, 0 },
    12731425        { "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 },
    12821434        { "VBoxGuest.sys",      NULL, 0 },
    12831435        { "VBoxSF.ifs",         NULL, 0 },
     
    13001452            && !(s_aFiles[i].fSkipMask & g_fSkipMask) /* ASSUMES one skip bit per file */)
    13011453        {
    1302             strcpy(&g_szBootDrivePath[g_cchBootDrivePath], s_aFiles[i].pszFile);
     1454            strcpy(&g_szBootDrivePath[g_cchBootDrivePath], s_aFiles[i].pszAltDst);
    13031455
    13041456            rcExit2 = CopyOneFile(g_szSrcPath, g_szBootDrivePath);
     
    13321484        return RTEXITCODE_SUCCESS;
    13331485    strcpy(&g_szBootDrivePath[g_cchBootDrivePath], "STARTUP.CMD");
    1334     return EditorWriteOutFile(&g_ConfigSys, g_szBootDrivePath);
     1486    return EditorWriteOutFile(&g_StartupCmd, g_szBootDrivePath);
    13351487}
    13361488
     
    13551507        "   or  VBoxIs2AdditionsInstall.exe <-v|--version>\r\n"
    13561508        "\r\n"
    1357         "Options\r\n:"
     1509        "Options:\r\n"
    13581510        "  -s<path>, --source[=]<path>\r\n"
    13591511        "      Specifies where the files to install are.  Default: Same as installer\r\n"
    13601512        "  -d<path>, --destination[=]<path>\r\n"
    13611513        "      Specifies where to install all the VBox OS/2 additions files.\r\n"
    1362         "      Default: C:\VBoxGA  (C is replaced by actual boot drive)\r\n"
     1514        "      Default: C:\VBoxAdd  (C is replaced by actual boot drive)\r\n"
    13631515        "  -b<path>, --boot-drive[=]<path>\r\n"
    13641516        "      Specifies the boot drive.  Default: C: (C is replaced by the actual one)\r\n"
     
    15021654    ULONG ulBootDrv = 0x80;
    15031655    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;
    15051657
    15061658    /*
     
    16431795        RTPathStripFilename(g_szSrcPath);
    16441796        g_cchSrcPath = RTPathEnsureTrailingSeparator(g_szSrcPath, sizeof(g_szSrcPath));
    1645         if (g_cchSrcPath)
     1797        if (g_cchSrcPath == 0)
    16461798            return ApiError("RTPathEnsureTrailingSeparator", ERROR_BUFFER_OVERFLOW);
    16471799    }
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette