Changeset 38531 in vbox for trunk/src/VBox/Runtime/common/ldr
- Timestamp:
- Aug 25, 2011 2:30:23 PM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 73678
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/ldr/ldrkStuff.cpp
r38515 r38531 86 86 { 87 87 PFNRT pfn; 88 PFNRTLDRENUMDBG pfnEnumDbgInfo; 88 89 PFNRTLDRENUMSYMS pfnEnumSyms; 89 90 PFNRTLDRIMPORT pfnGetImport; … … 92 93 const void *pvBits; 93 94 PRTLDRMODKLDR pMod; 95 int rc; 94 96 } RTLDRMODKLDRARGS, *PRTLDRMODKLDRARGS; 95 96 97 /*******************************************************************************98 * Internal Functions *99 *******************************************************************************/100 static int rtkldrConvertError(int krc);101 static int rtkldrConvertErrorFromIPRT(int rc);102 103 104 static int rtkldrRdrCreate( PPKRDR ppRdr, const char *pszFilename);105 static int rtkldrRdrDestroy( PKRDR pRdr);106 static int rtkldrRdrRead( PKRDR pRdr, void *pvBuf, KSIZE cb, KFOFF off);107 static int rtkldrRdrAllMap( PKRDR pRdr, const void **ppvBits);108 static int rtkldrRdrAllUnmap(PKRDR pRdr, const void *pvBits);109 static KFOFF rtkldrRdrSize( PKRDR pRdr);110 static KFOFF rtkldrRdrTell( PKRDR pRdr);111 static const char * rtkldrRdrName(PKRDR pRdr);112 static KIPTR rtkldrRdrNativeFH(PKRDR pRdr);113 static KSIZE rtkldrRdrPageSize(PKRDR pRdr);114 static int rtkldrRdrMap( PKRDR pRdr, void **ppvBase, KU32 cSegments, PCKLDRSEG paSegments, KBOOL fFixed);115 static int rtkldrRdrRefresh( PKRDR pRdr, void *pvBase, KU32 cSegments, PCKLDRSEG paSegments);116 static int rtkldrRdrProtect( PKRDR pRdr, void *pvBase, KU32 cSegments, PCKLDRSEG paSegments, KBOOL fUnprotectOrProtect);117 static int rtkldrRdrUnmap( PKRDR pRdr, void *pvBase, KU32 cSegments, PCKLDRSEG paSegments);118 static void rtkldrRdrDone( PKRDR pRdr);119 120 121 static DECLCALLBACK(int) rtkldrClose(PRTLDRMODINTERNAL pMod);122 static DECLCALLBACK(int) rtkldrDone(PRTLDRMODINTERNAL pMod);123 static DECLCALLBACK(int) rtkldrEnumSymbols(PRTLDRMODINTERNAL pMod, unsigned fFlags, const void *pvBits,124 RTUINTPTR BaseAddress,PFNRTLDRENUMSYMS pfnCallback, void *pvUser);125 static int rtkldrEnumSymbolsWrapper(PKLDRMOD pMod, uint32_t iSymbol,126 const char *pchSymbol, KSIZE cchSymbol, const char *pszVersion,127 KLDRADDR uValue, uint32_t fKind, void *pvUser);128 static DECLCALLBACK(size_t) rtkldrGetImageSize(PRTLDRMODINTERNAL pMod);129 static DECLCALLBACK(int) rtkldrGetBits(PRTLDRMODINTERNAL pMod, void *pvBits, RTUINTPTR BaseAddress,130 PFNRTLDRIMPORT pfnGetImport, void *pvUser);131 static DECLCALLBACK(int) rtkldrRelocate(PRTLDRMODINTERNAL pMod, void *pvBits, RTUINTPTR NewBaseAddress,132 RTUINTPTR OldBaseAddress, PFNRTLDRIMPORT pfnGetImport, void *pvUser);133 static int rtkldrGetImportWrapper(PKLDRMOD pMod, uint32_t iImport, uint32_t iSymbol, const char *pchSymbol, KSIZE cchSymbol,134 const char *pszVersion, PKLDRADDR puValue, uint32_t *pfKind, void *pvUser);135 136 static DECLCALLBACK(int) rtkldrGetSymbolEx(PRTLDRMODINTERNAL pMod, const void *pvBits, RTUINTPTR BaseAddress,137 const char *pszSymbol, RTUINTPTR *pValue);138 static DECLCALLBACK(int) rtkldr_EnumDbgInfo(PRTLDRMODINTERNAL pMod, const void *pvBits,139 PFNRTLDRENUMDBG pfnCallback, void *pvUser);140 141 97 142 98 … … 271 227 272 228 229 230 /** @copydoc KLDRRDROPS::pfnCreate 231 * @remark This is a dummy which isn't used. */ 232 static int rtkldrRdr_Create( PPKRDR ppRdr, const char *pszFilename) 233 { 234 AssertReleaseFailed(); 235 return -1; 236 } 237 238 239 /** @copydoc KLDRRDROPS::pfnDestroy */ 240 static int rtkldrRdr_Destroy( PKRDR pRdr) 241 { 242 PRTLDRREADER pReader = ((PRTKLDRRDR)pRdr)->pReader; 243 int rc = pReader->pfnDestroy(pReader); 244 return rtkldrConvertErrorFromIPRT(rc); 245 } 246 247 248 /** @copydoc KLDRRDROPS::pfnRead */ 249 static int rtkldrRdr_Read( PKRDR pRdr, void *pvBuf, KSIZE cb, KFOFF off) 250 { 251 PRTLDRREADER pReader = ((PRTKLDRRDR)pRdr)->pReader; 252 int rc = pReader->pfnRead(pReader, pvBuf, cb, off); 253 return rtkldrConvertErrorFromIPRT(rc); 254 } 255 256 257 /** @copydoc KLDRRDROPS::pfnAllMap */ 258 static int rtkldrRdr_AllMap( PKRDR pRdr, const void **ppvBits) 259 { 260 PRTLDRREADER pReader = ((PRTKLDRRDR)pRdr)->pReader; 261 int rc = pReader->pfnMap(pReader, ppvBits); 262 return rtkldrConvertErrorFromIPRT(rc); 263 } 264 265 266 /** @copydoc KLDRRDROPS::pfnAllUnmap */ 267 static int rtkldrRdr_AllUnmap(PKRDR pRdr, const void *pvBits) 268 { 269 PRTLDRREADER pReader = ((PRTKLDRRDR)pRdr)->pReader; 270 int rc = pReader->pfnUnmap(pReader, pvBits); 271 return rtkldrConvertErrorFromIPRT(rc); 272 } 273 274 275 /** @copydoc KLDRRDROPS::pfnSize */ 276 static KFOFF rtkldrRdr_Size( PKRDR pRdr) 277 { 278 PRTLDRREADER pReader = ((PRTKLDRRDR)pRdr)->pReader; 279 return (KFOFF)pReader->pfnSize(pReader); 280 } 281 282 283 /** @copydoc KLDRRDROPS::pfnTell */ 284 static KFOFF rtkldrRdr_Tell( PKRDR pRdr) 285 { 286 PRTLDRREADER pReader = ((PRTKLDRRDR)pRdr)->pReader; 287 return (KFOFF)pReader->pfnTell(pReader); 288 } 289 290 291 /** @copydoc KLDRRDROPS::pfnName */ 292 static const char * rtkldrRdr_Name(PKRDR pRdr) 293 { 294 PRTLDRREADER pReader = ((PRTKLDRRDR)pRdr)->pReader; 295 return pReader->pfnLogName(pReader); 296 } 297 298 299 /** @copydoc KLDRRDROPS::pfnNativeFH */ 300 static KIPTR rtkldrRdr_NativeFH(PKRDR pRdr) 301 { 302 AssertFailed(); 303 return -1; 304 } 305 306 307 /** @copydoc KLDRRDROPS::pfnPageSize */ 308 static KSIZE rtkldrRdr_PageSize(PKRDR pRdr) 309 { 310 return PAGE_SIZE; 311 } 312 313 314 /** @copydoc KLDRRDROPS::pfnMap */ 315 static int rtkldrRdr_Map( PKRDR pRdr, void **ppvBase, KU32 cSegments, PCKLDRSEG paSegments, KBOOL fFixed) 316 { 317 //PRTLDRREADER pReader = ((PRTKLDRRDR)pRdr)->pReader; 318 AssertFailed(); 319 return -1; 320 } 321 322 323 /** @copydoc KLDRRDROPS::pfnRefresh */ 324 static int rtkldrRdr_Refresh( PKRDR pRdr, void *pvBase, KU32 cSegments, PCKLDRSEG paSegments) 325 { 326 //PRTLDRREADER pReader = ((PRTKLDRRDR)pRdr)->pReader; 327 AssertFailed(); 328 return -1; 329 } 330 331 332 /** @copydoc KLDRRDROPS::pfnProtect */ 333 static int rtkldrRdr_Protect( PKRDR pRdr, void *pvBase, KU32 cSegments, PCKLDRSEG paSegments, KBOOL fUnprotectOrProtect) 334 { 335 //PRTLDRREADER pReader = ((PRTKLDRRDR)pRdr)->pReader; 336 AssertFailed(); 337 return -1; 338 } 339 340 341 /** @copydoc KLDRRDROPS::pfnUnmap */ 342 static int rtkldrRdr_Unmap( PKRDR pRdr, void *pvBase, KU32 cSegments, PCKLDRSEG paSegments) 343 { 344 //PRTLDRREADER pReader = ((PRTKLDRRDR)pRdr)->pReader; 345 AssertFailed(); 346 return -1; 347 } 348 349 /** @copydoc KLDRRDROPS::pfnDone */ 350 static void rtkldrRdr_Done( PKRDR pRdr) 351 { 352 //PRTLDRREADER pReader = ((PRTKLDRRDR)pRdr)->pReader; 353 } 354 355 273 356 /** 274 357 * The file reader operations. … … 280 363 /* .pszName = */ "IPRT", 281 364 /* .pNext = */ NULL, 282 /* .pfnCreate = */ rtkldrRdr Create,283 /* .pfnDestroy = */ rtkldrRdr Destroy,284 /* .pfnRead = */ rtkldrRdr Read,285 /* .pfnAllMap = */ rtkldrRdr AllMap,286 /* .pfnAllUnmap = */ rtkldrRdr AllUnmap,287 /* .pfnSize = */ rtkldrRdr Size,288 /* .pfnTell = */ rtkldrRdr Tell,289 /* .pfnName = */ rtkldrRdr Name,290 /* .pfnNativeFH = */ rtkldrRdr NativeFH,291 /* .pfnPageSize = */ rtkldrRdr PageSize,292 /* .pfnMap = */ rtkldrRdr Map,293 /* .pfnRefresh = */ rtkldrRdr Refresh,294 /* .pfnProtect = */ rtkldrRdr Protect,295 /* .pfnUnmap = */ rtkldrRdr Unmap,296 /* .pfnDone = */ rtkldrRdr Done,365 /* .pfnCreate = */ rtkldrRdr_Create, 366 /* .pfnDestroy = */ rtkldrRdr_Destroy, 367 /* .pfnRead = */ rtkldrRdr_Read, 368 /* .pfnAllMap = */ rtkldrRdr_AllMap, 369 /* .pfnAllUnmap = */ rtkldrRdr_AllUnmap, 370 /* .pfnSize = */ rtkldrRdr_Size, 371 /* .pfnTell = */ rtkldrRdr_Tell, 372 /* .pfnName = */ rtkldrRdr_Name, 373 /* .pfnNativeFH = */ rtkldrRdr_NativeFH, 374 /* .pfnPageSize = */ rtkldrRdr_PageSize, 375 /* .pfnMap = */ rtkldrRdr_Map, 376 /* .pfnRefresh = */ rtkldrRdr_Refresh, 377 /* .pfnProtect = */ rtkldrRdr_Protect, 378 /* .pfnUnmap = */ rtkldrRdr_Unmap, 379 /* .pfnDone = */ rtkldrRdr_Done, 297 380 /* .u32Dummy = */ 42 298 381 }; 299 382 300 383 301 /** @copydoc KLDRRDROPS::pfnCreate 302 * @remark This is a dummy which isn't used. */ 303 static int rtkldrRdrCreate( PPKRDR ppRdr, const char *pszFilename) 304 { 305 AssertReleaseFailed(); 306 return -1; 307 } 308 309 310 /** @copydoc KLDRRDROPS::pfnDestroy */ 311 static int rtkldrRdrDestroy( PKRDR pRdr) 312 { 313 PRTLDRREADER pReader = ((PRTKLDRRDR)pRdr)->pReader; 314 int rc = pReader->pfnDestroy(pReader); 315 return rtkldrConvertErrorFromIPRT(rc); 316 } 317 318 319 /** @copydoc KLDRRDROPS::pfnRead */ 320 static int rtkldrRdrRead( PKRDR pRdr, void *pvBuf, KSIZE cb, KFOFF off) 321 { 322 PRTLDRREADER pReader = ((PRTKLDRRDR)pRdr)->pReader; 323 int rc = pReader->pfnRead(pReader, pvBuf, cb, off); 324 return rtkldrConvertErrorFromIPRT(rc); 325 } 326 327 328 /** @copydoc KLDRRDROPS::pfnAllMap */ 329 static int rtkldrRdrAllMap( PKRDR pRdr, const void **ppvBits) 330 { 331 PRTLDRREADER pReader = ((PRTKLDRRDR)pRdr)->pReader; 332 int rc = pReader->pfnMap(pReader, ppvBits); 333 return rtkldrConvertErrorFromIPRT(rc); 334 } 335 336 337 /** @copydoc KLDRRDROPS::pfnAllUnmap */ 338 static int rtkldrRdrAllUnmap(PKRDR pRdr, const void *pvBits) 339 { 340 PRTLDRREADER pReader = ((PRTKLDRRDR)pRdr)->pReader; 341 int rc = pReader->pfnUnmap(pReader, pvBits); 342 return rtkldrConvertErrorFromIPRT(rc); 343 } 344 345 346 /** @copydoc KLDRRDROPS::pfnSize */ 347 static KFOFF rtkldrRdrSize( PKRDR pRdr) 348 { 349 PRTLDRREADER pReader = ((PRTKLDRRDR)pRdr)->pReader; 350 return (KFOFF)pReader->pfnSize(pReader); 351 } 352 353 354 /** @copydoc KLDRRDROPS::pfnTell */ 355 static KFOFF rtkldrRdrTell( PKRDR pRdr) 356 { 357 PRTLDRREADER pReader = ((PRTKLDRRDR)pRdr)->pReader; 358 return (KFOFF)pReader->pfnTell(pReader); 359 } 360 361 362 /** @copydoc KLDRRDROPS::pfnName */ 363 static const char * rtkldrRdrName(PKRDR pRdr) 364 { 365 PRTLDRREADER pReader = ((PRTKLDRRDR)pRdr)->pReader; 366 return pReader->pfnLogName(pReader); 367 } 368 369 370 /** @copydoc KLDRRDROPS::pfnNativeFH */ 371 static KIPTR rtkldrRdrNativeFH(PKRDR pRdr) 372 { 373 AssertFailed(); 374 return -1; 375 } 376 377 378 /** @copydoc KLDRRDROPS::pfnPageSize */ 379 static KSIZE rtkldrRdrPageSize(PKRDR pRdr) 380 { 381 return PAGE_SIZE; 382 } 383 384 385 /** @copydoc KLDRRDROPS::pfnMap */ 386 static int rtkldrRdrMap( PKRDR pRdr, void **ppvBase, KU32 cSegments, PCKLDRSEG paSegments, KBOOL fFixed) 387 { 388 //PRTLDRREADER pReader = ((PRTKLDRRDR)pRdr)->pReader; 389 AssertFailed(); 390 return -1; 391 } 392 393 394 /** @copydoc KLDRRDROPS::pfnRefresh */ 395 static int rtkldrRdrRefresh( PKRDR pRdr, void *pvBase, KU32 cSegments, PCKLDRSEG paSegments) 396 { 397 //PRTLDRREADER pReader = ((PRTKLDRRDR)pRdr)->pReader; 398 AssertFailed(); 399 return -1; 400 } 401 402 403 /** @copydoc KLDRRDROPS::pfnProtect */ 404 static int rtkldrRdrProtect( PKRDR pRdr, void *pvBase, KU32 cSegments, PCKLDRSEG paSegments, KBOOL fUnprotectOrProtect) 405 { 406 //PRTLDRREADER pReader = ((PRTKLDRRDR)pRdr)->pReader; 407 AssertFailed(); 408 return -1; 409 } 410 411 412 /** @copydoc KLDRRDROPS::pfnUnmap */ 413 static int rtkldrRdrUnmap( PKRDR pRdr, void *pvBase, KU32 cSegments, PCKLDRSEG paSegments) 414 { 415 //PRTLDRREADER pReader = ((PRTKLDRRDR)pRdr)->pReader; 416 AssertFailed(); 417 return -1; 418 } 419 420 /** @copydoc KLDRRDROPS::pfnDone */ 421 static void rtkldrRdrDone( PKRDR pRdr) 422 { 423 //PRTLDRREADER pReader = ((PRTKLDRRDR)pRdr)->pReader; 424 } 425 426 427 428 429 430 431 /** 432 * Operations for a kLdr module. 433 */ 434 static const RTLDROPS g_rtkldrOps = 435 { 436 "kLdr", 437 rtkldrClose, 438 NULL, 439 rtkldrDone, 440 rtkldrEnumSymbols, 441 /* ext */ 442 rtkldrGetImageSize, 443 rtkldrGetBits, 444 rtkldrRelocate, 445 rtkldrGetSymbolEx, 446 rtkldr_EnumDbgInfo, 447 42 448 }; 384 449 385 450 386 451 387 /** @copydoc RTLDROPS::pfnClose */ 452 static DECLCALLBACK(int) rtkldr Close(PRTLDRMODINTERNAL pMod)388 static DECLCALLBACK(int) rtkldr_Close(PRTLDRMODINTERNAL pMod) 453 389 { 454 390 PKLDRMOD pModkLdr = ((PRTLDRMODKLDR)pMod)->pMod; … … 459 395 460 396 /** @copydoc RTLDROPS::pfnDone */ 461 static DECLCALLBACK(int) rtkldr Done(PRTLDRMODINTERNAL pMod)397 static DECLCALLBACK(int) rtkldr_Done(PRTLDRMODINTERNAL pMod) 462 398 { 463 399 PKLDRMOD pModkLdr = ((PRTLDRMODKLDR)pMod)->pMod; 464 400 int rc = kLdrModMostlyDone(pModkLdr); 465 return rtkldrConvertError(rc);466 }467 468 469 /** @copydoc RTLDROPS::pfnEnumSymbols */470 static DECLCALLBACK(int) rtkldrEnumSymbols(PRTLDRMODINTERNAL pMod, unsigned fFlags, const void *pvBits, RTUINTPTR BaseAddress,471 PFNRTLDRENUMSYMS pfnCallback, void *pvUser)472 {473 PKLDRMOD pModkLdr = ((PRTLDRMODKLDR)pMod)->pMod;474 RTLDRMODKLDRARGS Args;475 Args.pvUser = pvUser;476 Args.u.pfnEnumSyms = pfnCallback;477 Args.pMod = (PRTLDRMODKLDR)pMod;478 Args.pvBits = pvBits;479 int rc = kLdrModEnumSymbols(pModkLdr, pvBits, BaseAddress,480 fFlags & RTLDR_ENUM_SYMBOL_FLAGS_ALL ? KLDRMOD_ENUM_SYMS_FLAGS_ALL : 0,481 rtkldrEnumSymbolsWrapper, &Args);482 401 return rtkldrConvertError(rc); 483 402 } … … 514 433 515 434 435 /** @copydoc RTLDROPS::pfnEnumSymbols */ 436 static DECLCALLBACK(int) rtkldr_EnumSymbols(PRTLDRMODINTERNAL pMod, unsigned fFlags, const void *pvBits, RTUINTPTR BaseAddress, 437 PFNRTLDRENUMSYMS pfnCallback, void *pvUser) 438 { 439 PKLDRMOD pModkLdr = ((PRTLDRMODKLDR)pMod)->pMod; 440 RTLDRMODKLDRARGS Args; 441 Args.pvUser = pvUser; 442 Args.u.pfnEnumSyms = pfnCallback; 443 Args.pMod = (PRTLDRMODKLDR)pMod; 444 Args.pvBits = pvBits; 445 Args.rc = VINF_SUCCESS; 446 int rc = kLdrModEnumSymbols(pModkLdr, pvBits, BaseAddress, 447 fFlags & RTLDR_ENUM_SYMBOL_FLAGS_ALL ? KLDRMOD_ENUM_SYMS_FLAGS_ALL : 0, 448 rtkldrEnumSymbolsWrapper, &Args); 449 if (Args.rc != VINF_SUCCESS) 450 rc = Args.rc; 451 else 452 rc = rtkldrConvertError(rc); 453 return rc; 454 } 455 456 516 457 /** @copydoc RTLDROPS::pfnGetImageSize */ 517 static DECLCALLBACK(size_t) rtkldr GetImageSize(PRTLDRMODINTERNAL pMod)458 static DECLCALLBACK(size_t) rtkldr_GetImageSize(PRTLDRMODINTERNAL pMod) 518 459 { 519 460 PKLDRMOD pModkLdr = ((PRTLDRMODKLDR)pMod)->pMod; 520 461 return kLdrModSize(pModkLdr); 521 }522 523 524 /** @copydoc RTLDROPS::pfnGetBits */525 static DECLCALLBACK(int) rtkldrGetBits(PRTLDRMODINTERNAL pMod, void *pvBits, RTUINTPTR BaseAddress,526 PFNRTLDRIMPORT pfnGetImport, void *pvUser)527 {528 PKLDRMOD pModkLdr = ((PRTLDRMODKLDR)pMod)->pMod;529 RTLDRMODKLDRARGS Args;530 Args.pvUser = pvUser;531 Args.u.pfnGetImport = pfnGetImport;532 Args.pMod = (PRTLDRMODKLDR)pMod;533 Args.pvBits = pvBits;534 int rc = kLdrModGetBits(pModkLdr, pvBits, BaseAddress, rtkldrGetImportWrapper, &Args);535 return rtkldrConvertError(rc);536 }537 538 539 /** @copydoc RTLDROPS::pfnRelocate */540 static DECLCALLBACK(int) rtkldrRelocate(PRTLDRMODINTERNAL pMod, void *pvBits, RTUINTPTR NewBaseAddress,541 RTUINTPTR OldBaseAddress, PFNRTLDRIMPORT pfnGetImport, void *pvUser)542 {543 PKLDRMOD pModkLdr = ((PRTLDRMODKLDR)pMod)->pMod;544 RTLDRMODKLDRARGS Args;545 Args.pvUser = pvUser;546 Args.u.pfnGetImport = pfnGetImport;547 Args.pMod = (PRTLDRMODKLDR)pMod;548 Args.pvBits = pvBits;549 int rc = kLdrModRelocateBits(pModkLdr, pvBits, NewBaseAddress, OldBaseAddress, rtkldrGetImportWrapper, &Args);550 return rtkldrConvertError(rc);551 462 } 552 463 … … 597 508 598 509 510 /** @copydoc RTLDROPS::pfnGetBits */ 511 static DECLCALLBACK(int) rtkldr_GetBits(PRTLDRMODINTERNAL pMod, void *pvBits, RTUINTPTR BaseAddress, 512 PFNRTLDRIMPORT pfnGetImport, void *pvUser) 513 { 514 PKLDRMOD pModkLdr = ((PRTLDRMODKLDR)pMod)->pMod; 515 RTLDRMODKLDRARGS Args; 516 Args.pvUser = pvUser; 517 Args.u.pfnGetImport = pfnGetImport; 518 Args.pMod = (PRTLDRMODKLDR)pMod; 519 Args.pvBits = pvBits; 520 Args.rc = VINF_SUCCESS; 521 int rc = kLdrModGetBits(pModkLdr, pvBits, BaseAddress, rtkldrGetImportWrapper, &Args); 522 if (Args.rc != VINF_SUCCESS) 523 rc = Args.rc; 524 else 525 rc = rtkldrConvertError(rc); 526 return rc; 527 } 528 529 530 /** @copydoc RTLDROPS::pfnRelocate */ 531 static DECLCALLBACK(int) rtkldr_Relocate(PRTLDRMODINTERNAL pMod, void *pvBits, RTUINTPTR NewBaseAddress, 532 RTUINTPTR OldBaseAddress, PFNRTLDRIMPORT pfnGetImport, void *pvUser) 533 { 534 PKLDRMOD pModkLdr = ((PRTLDRMODKLDR)pMod)->pMod; 535 RTLDRMODKLDRARGS Args; 536 Args.pvUser = pvUser; 537 Args.u.pfnGetImport = pfnGetImport; 538 Args.pMod = (PRTLDRMODKLDR)pMod; 539 Args.pvBits = pvBits; 540 Args.rc = VINF_SUCCESS; 541 int rc = kLdrModRelocateBits(pModkLdr, pvBits, NewBaseAddress, OldBaseAddress, rtkldrGetImportWrapper, &Args); 542 if (Args.rc != VINF_SUCCESS) 543 rc = Args.rc; 544 else 545 rc = rtkldrConvertError(rc); 546 return rc; 547 } 548 599 549 600 550 /** @copydoc RTLDROPS::pfnGetSymbolEx */ 601 static DECLCALLBACK(int) rtkldr GetSymbolEx(PRTLDRMODINTERNAL pMod, const void *pvBits, RTUINTPTR BaseAddress,602 const char *pszSymbol, RTUINTPTR *pValue)551 static DECLCALLBACK(int) rtkldr_GetSymbolEx(PRTLDRMODINTERNAL pMod, const void *pvBits, RTUINTPTR BaseAddress, 552 const char *pszSymbol, RTUINTPTR *pValue) 603 553 { 604 554 PKLDRMOD pModkLdr = ((PRTLDRMODKLDR)pMod)->pMod; … … 631 581 632 582 583 /** @copydoc FNKLDRENUMDBG */ 584 static int rtkldrEnumDbgInfoWrapper(PKLDRMOD pMod, KU32 iDbgInfo, KLDRDBGINFOTYPE enmType, KI16 iMajorVer, KI16 iMinorVer, 585 const char *pszPartNm, KLDRFOFF offFile, KLDRADDR LinkAddress, KLDRSIZE cb, 586 const char *pszExtFile, void *pvUser) 587 { 588 PRTLDRMODKLDRARGS pArgs = (PRTLDRMODKLDRARGS)pvUser; 589 590 RTLDRDBGINFOTYPE enmMyType; 591 switch (enmType) 592 { 593 case KLDRDBGINFOTYPE_UNKNOWN: enmMyType = RTLDRDBGINFOTYPE_UNKNOWN; break; 594 case KLDRDBGINFOTYPE_STABS: enmMyType = RTLDRDBGINFOTYPE_STABS; break; 595 case KLDRDBGINFOTYPE_DWARF: enmMyType = RTLDRDBGINFOTYPE_DWARF; break; 596 case KLDRDBGINFOTYPE_CODEVIEW: enmMyType = RTLDRDBGINFOTYPE_CODEVIEW; break; 597 case KLDRDBGINFOTYPE_WATCOM: enmMyType = RTLDRDBGINFOTYPE_WATCOM; break; 598 case KLDRDBGINFOTYPE_HLL: enmMyType = RTLDRDBGINFOTYPE_HLL; break; 599 default: 600 AssertFailed(); 601 enmMyType = RTLDRDBGINFOTYPE_UNKNOWN; 602 break; 603 } 604 605 int rc = pArgs->u.pfnEnumDbgInfo(&pArgs->pMod->Core, iDbgInfo, enmMyType, iMajorVer, iMinorVer, pszPartNm, 606 offFile, LinkAddress, cb, pszExtFile, pArgs->pvUser); 607 if (RT_FAILURE(rc)) 608 return rc; /* don't bother converting. */ 609 return 0; 610 } 611 612 633 613 /** @copydoc RTLDROPS::pfnEnumDbgInfo */ 634 614 static DECLCALLBACK(int) rtkldr_EnumDbgInfo(PRTLDRMODINTERNAL pMod, const void *pvBits, 635 615 PFNRTLDRENUMDBG pfnCallback, void *pvUser) 636 616 { 637 return VERR_NOT_SUPPORTED; 638 } 617 PRTLDRMODKLDR pThis = (PRTLDRMODKLDR)pMod; 618 RTLDRMODKLDRARGS Args; 619 Args.pvUser = pvUser; 620 Args.u.pfnEnumDbgInfo = pfnCallback; 621 Args.pvBits = pvBits; 622 Args.pMod = pThis; 623 Args.rc = VINF_SUCCESS; 624 int rc = kLdrModEnumDbgInfo(pThis->pMod, pvBits, rtkldrEnumDbgInfoWrapper, &Args); 625 if (Args.rc != VINF_SUCCESS) 626 rc = Args.rc; 627 return rc; 628 } 629 630 631 /** 632 * Operations for a kLdr module. 633 */ 634 static const RTLDROPS g_rtkldrOps = 635 { 636 "kLdr", 637 rtkldr_Close, 638 NULL, 639 rtkldr_Done, 640 rtkldr_EnumSymbols, 641 /* ext */ 642 rtkldr_GetImageSize, 643 rtkldr_GetBits, 644 rtkldr_Relocate, 645 rtkldr_GetSymbolEx, 646 rtkldr_EnumDbgInfo, 647 42 648 }; 639 649 640 650 … … 667 677 } 668 678 669 /* Create a rtkldrRdr instance. */679 /* Create a rtkldrRdr_ instance. */ 670 680 PRTKLDRRDR pRdr = (PRTKLDRRDR)RTMemAllocZ(sizeof(*pRdr)); 671 681 if (!pRdr)
Note:
See TracChangeset
for help on using the changeset viewer.