0

I'm trying to load several symbol modules using the following code:

DWORD64 dwBaseDllSymLocal = 0;
SymInitializeW(GetCurrentProcess(), NULL, FALSE);
SymSetOptions(SYMOPT_DEBUG);

dwBaseDllSymLocal = SymLoadModuleExW(GetCurrentProcess(), NULL, L"C:\\module1.dll", NULL, 0, 0, NULL, 0);
if (0 == dwBaseDllSymLocal)
{
    __debugbreak();
}

dwBaseDllSymLocal is 10000000 now.

dwBaseDllSymLocal = SymLoadModuleExW(GetCurrentProcess(), NULL, L"C:\\module2.dll", NULL, 0, 0, NULL, 0);
if (0 == dwBaseDllSymLocal)
{
    __debugbreak();
}

Dbghelp gives the following message: module1 is already loaded at 10000000.

Same behavior happens when I try to load the same module twice. (unlike what is written in the documentation of the function).

Last error is ERROR_INVALID_ADDRESS though it doesn't seem relevant, because last error has this value following the first successful function call too.

Is it possible to load several modules with SymLoadModuleExW? What is the right way to do so?

macro_controller
  • 1,469
  • 1
  • 14
  • 32

1 Answers1

0

You are loading these binaries outside of the context of a debugger session, right? In which case, the fifth parameter, BaseOfDll, might be causing a problem:

The load address of the module. If the value is zero, the library obtains the load address from the symbol file.

When loading a binary standalone, it might just use 10000000 for everything... in which case, the second module load would conflict with the first one. So try passing something different there.

Last error is [...] though it doesn't seem relevant, because last error has this value following the first successful function call too.

If the function succeeds, the last error is not applicable; it could contain anything, but you should ignore it unless the documentation explicitly says that it sets the last error in success cases.

jazzdelightsme
  • 457
  • 3
  • 14