FindModuleByVa finds the module name by probing the range of the given virtual address.
(addr va.Address)
| 549 | // FindModuleByVa finds the module name by |
| 550 | // probing the range of the given virtual address. |
| 551 | func (ps *PS) FindModuleByVa(addr va.Address) *Module { |
| 552 | mod := ps.findModuleByVa(addr) |
| 553 | if mod != nil { |
| 554 | return mod |
| 555 | } |
| 556 | |
| 557 | ps.onceMods.Do(func() { |
| 558 | // query live process modules |
| 559 | ps.modules = queryLiveModules(ps.PID) |
| 560 | }) |
| 561 | |
| 562 | // try to find the module within the VA space |
| 563 | // and if found, add it to process modules for |
| 564 | // future lookups |
| 565 | for _, m := range ps.modules { |
| 566 | b := va.Address(m.BaseOfDll) |
| 567 | size := uint64(m.SizeOfImage) |
| 568 | |
| 569 | if addr < b || addr >= b.Inc(size) { |
| 570 | continue |
| 571 | } |
| 572 | |
| 573 | mod := Module{ |
| 574 | Name: m.Name, |
| 575 | BaseAddress: b, |
| 576 | Size: size, |
| 577 | DefaultBaseAddress: b, |
| 578 | } |
| 579 | |
| 580 | ps.Lock() |
| 581 | ps.Modules = append(ps.Modules, mod) |
| 582 | ps.Unlock() |
| 583 | |
| 584 | return &mod |
| 585 | } |
| 586 | |
| 587 | return nil |
| 588 | } |
| 589 | |
| 590 | func (ps *PS) findModuleByVa(addr va.Address) *Module { |
| 591 | ps.RLock() |