MCPcopy Create free account
hub / github.com/crownengine/crown / findModule

Function findModule

3rdparty/bgfx/src/bgfx.cpp:2657–2731  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2655 static_assert(BX_COUNTOF(s_rendererCreator) == RendererType::Count);
2656
2657 void* findModule(const char* _name)
2658 {
2659#if BX_PLATFORM_WINDOWS
2660 // NOTE: there was some reason to do it this way instead of simply calling GetModuleHandleA,
2661 // but not sure what it was.
2662 HANDLE process = GetCurrentProcess();
2663 DWORD size;
2664 BOOL result = EnumProcessModules(process
2665 , NULL
2666 , 0
2667 , &size
2668 );
2669 if (0 != result)
2670 {
2671 HMODULE* modules = (HMODULE*)BX_STACK_ALLOC(size);
2672 result = EnumProcessModules(process
2673 , modules
2674 , size
2675 , &size
2676 );
2677
2678 if (0 != result)
2679 {
2680 char moduleName[MAX_PATH];
2681
2682 for (uint32_t ii = 0, num = uint32_t(size/sizeof(HMODULE) ); ii < num; ++ii)
2683 {
2684 result = GetModuleBaseNameA(process
2685 , modules[ii]
2686 , moduleName
2687 , BX_COUNTOF(moduleName)
2688 );
2689
2690 if (0 != result
2691 && 0 == bx::strCmpI(_name, moduleName) )
2692 {
2693 return (void*)modules[ii];
2694 }
2695 }
2696 }
2697 }
2698
2699 return NULL;
2700#elif BX_PLATFORM_LINUX
2701 struct DlIterateCallbackData
2702 {
2703 const char* name;
2704 void* ptr;
2705 } cbData =
2706 {
2707 .name = _name,
2708 .ptr = NULL,
2709 };
2710
2711 auto dlIterateCb = [](struct dl_phdr_info* _info, size_t /* _size */, void* _data) -> int
2712 {
2713 DlIterateCallbackData& data = *(DlIterateCallbackData*)_data;
2714

Callers 5

initMethod · 0.85
initMethod · 0.85
loadRenderDocFunction · 0.85
initMethod · 0.85
initMethod · 0.85

Calls 2

strCmpIFunction · 0.85
dlopenFunction · 0.85

Tested by

no test coverage detected