VirtualBox

Changeset 3376 in kBuild for trunk/src


Ignore:
Timestamp:
Jun 10, 2020 9:09:15 PM (5 years ago)
Author:
bird
Message:

kWorker: The missing SetDllDirectoryW hack (for the tool/exe). Better error reporting should an .exe import fail to load. Shut up weird assertion on changing back an .idata page from readwrite to readonly, failed with NOACCESS on a 17763 build box.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kWorker/kWorker.c

    r3374 r3376  
    21722172                                    {
    21732173                                        fRc = VirtualProtect(pbProtRange, cbProtRange, fOldProt, NULL /*pfOldProt*/);
    2174                                         kHlpAssert(fRc);
     2174                                        kHlpAssert(fRc || GetLastError() == ERROR_NOACCESS /*tinderwin2*/);
    21752175                                        fOldProt = 0;
    21762176                                    }
     
    28862886            default:
    28872887                rc = KERR_GENERAL_FAILURE;
     2888                kwErrPrintf("kwLdrModuleCreateNonNative: Unsupported module type %d (%s)!\n", pLdrMod->enmType, pszPath);
    28882889                break;
    28892890        }
     
    29872988                                        continue;
    29882989                                }
     2990                                kwErrPrintf("Error getting import '%s' for '%s': %d\n", szName, pMod->pszPath);
    29892991                                break;
    29902992                            }
     
    30443046                                        return pMod;
    30453047                                    }
     3048                                    kwErrPrintf("kwLdrModuleCreateNonNativeSetupTls failed with %d for %s\n", rc, pMod->pszPath);
    30463049                                }
    30473050                                else
     
    30623065                        kwErrPrintf("Failed to allocate %#x bytes\n", pMod->cbImage);
    30633066                }
    3064             }
     3067                else
     3068                    kwErrPrintf("kwLdrModuleCreateNonNative: out of memory!\n");
     3069            }
     3070            else
     3071                kwErrPrintf("kwLdrModuleCreateNonNative: kLdrModNumberOfImports failed for '%s'\n", pszPath);
    30653072        }
    30663073        kLdrModClose(pLdrMod);
     
    40864093    {
    40874094        KBOOL fRc;
     4095        wchar_t wcSaved;
     4096        wchar_t *pwcEnd;
    40884097        pTool->pwszPath = (wchar_t const *)(pTool + 1);
    40894098        fRc = kFsCacheObjGetFullPathW(pToolFsObj, (wchar_t *)pTool->pwszPath, cwcPath, '\\');
     
    40944103        kHlpAssert(fRc);
    40954104
     4105        /* HACK ALERT! This is to help the loader search the application directory. */
     4106        pwcEnd = (wchar_t *)&pTool->pwszPath[pToolFsObj->cwcParent];
     4107        wcSaved = *pwcEnd;
     4108        *pwcEnd = '\0';
     4109        if (!SetDllDirectoryW(pTool->pwszPath))
     4110            kwErrPrintf("SetDllDirectoryW(tool) failed: %u\n", GetLastError());
     4111        *pwcEnd = wcSaved;
     4112
    40964113        pTool->enmType = KWTOOLTYPE_SANDBOXED;
    40974114        pTool->u.Sandboxed.pExe = kwLdrModuleCreateNonNative(pTool->pszPath, kwStrHash(pTool->pszPath), K_TRUE /*fExe*/,
    4098                                                              NULL /*pEexeMod*/, pszSearchPath);
     4115                                                             NULL /*pExeMod*/, pszSearchPath);
    40994116        if (pTool->u.Sandboxed.pExe)
    41004117        {
     
    41194136        }
    41204137        else
     4138        {
     4139            kwErrPrintf("kwLdrModuleCreateNonNative failed!\n");
    41214140            pTool->enmType = KWTOOLTYPE_EXEC;
     4141        }
    41224142
    41234143        kFsCacheObjRelease(g_pFsCache, pToolFsObj);
     
    41254145        return pTool;
    41264146    }
     4147    kwErrPrintf("kFsCacheObjAddUserData failed!\n");
    41274148    kFsCacheObjRelease(g_pFsCache, pToolFsObj);
    41284149    return NULL;
Note: See TracChangeset for help on using the changeset viewer.

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