MCPcopy Create free account
hub / github.com/acl-dev/acl / EditImports

Method EditImports

lib_fiber/cpp/src/detours/image.cpp:1432–1596  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1430}
1431
1432BOOL CImage::EditImports(PVOID pContext,
1433 PF_DETOUR_BINARY_BYWAY_CALLBACK pfBywayCallback,
1434 PF_DETOUR_BINARY_FILE_CALLBACK pfFileCallback,
1435 PF_DETOUR_BINARY_SYMBOL_CALLBACK pfSymbolCallback,
1436 PF_DETOUR_BINARY_COMMIT_CALLBACK pfCommitCallback)
1437{
1438 CImageImportFile *pImportFile = NULL;
1439 CImageImportFile **ppLastFile = &m_pImportFiles;
1440
1441 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1442
1443 while ((pImportFile = *ppLastFile) != NULL) {
1444
1445 if (pfBywayCallback != NULL) {
1446 LPCSTR pszFile = NULL;
1447 if (!(*pfBywayCallback)(pContext, NULL, &pszFile)) {
1448 goto fail;
1449 }
1450
1451 if (pszFile != NULL) {
1452 // Insert a new Byway.
1453 CImageImportFile *pByway = NewByway(pszFile);
1454 if (pByway == NULL) {
1455 return FALSE;
1456 }
1457
1458 pByway->m_pNextFile = pImportFile;
1459 *ppLastFile = pByway;
1460 ppLastFile = &pByway->m_pNextFile;
1461 continue; // Retry after Byway.
1462 }
1463 }
1464
1465 if (pImportFile->m_fByway) {
1466 if (pfBywayCallback != NULL) {
1467 LPCSTR pszFile = NULL;
1468
1469 if (!(*pfBywayCallback)(pContext, pImportFile->m_pszName, &pszFile)) {
1470 goto fail;
1471 }
1472
1473 if (pszFile != NULL) {
1474 // Replace? Byway
1475 if (pszFile != pImportFile->m_pszName) {
1476 LPCSTR pszLast = pImportFile->m_pszName;
1477 pImportFile->m_pszName = DuplicateString(pszFile);
1478 ReleaseString(pszLast);
1479
1480 if (pImportFile->m_pszName == NULL) {
1481 goto fail;
1482 }
1483 }
1484 }
1485 else { // Delete Byway
1486 *ppLastFile = pImportFile->m_pNextFile;
1487 pImportFile->m_pNextFile = NULL;
1488 delete pImportFile;
1489 m_nImportFiles--;

Callers 2

DetourBinaryResetImportsFunction · 0.80
DetourBinaryEditImportsFunction · 0.80

Calls 2

DuplicateStringFunction · 0.85
ReleaseStringFunction · 0.85

Tested by

no test coverage detected