Commit 394361cd authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

dbghelp/tests: Add wrapper for EnumerateLoadedModulesW64().

Since this API sporadically fails with STATUS_INFO_LENGTH_MISMATCH as GetLastError() (sic!) on Windows 11, retrying the call let us get the relevant output. No clear explanation of the cause of the failure, it's maybe generated when modules are still loaded into child process and it detects modification of the modules' list while enumerating all modules. Signed-off-by: 's avatarEric Pouech <eric.pouech@gmail.com>
parent 1774db38
......@@ -16,6 +16,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "ntstatus.h"
#define WIN32_NO_STATUS
#include "windows.h"
#include "psapi.h"
#include "verrsrc.h"
......@@ -308,6 +310,24 @@ static BOOL CALLBACK nth_module_cb(const char* name, DWORD64 base, void* usr)
return FALSE;
}
/* wrapper around EnumerateLoadedModuleW64 which sometimes fails for unknown reasons on Win11,
* with STATUS_INFO_LENGTH_MISMATCH as GetLastError()!
*/
static BOOL wrapper_EnumerateLoadedModulesW64(HANDLE proc, PENUMLOADED_MODULES_CALLBACKW64 cb, void* usr)
{
BOOL ret;
int retry;
for (retry = !strcmp(winetest_platform, "wine") ? 1 : 5; retry >= 0; retry--)
{
ret = EnumerateLoadedModulesW64(proc, cb, usr);
if (ret || GetLastError() != STATUS_INFO_LENGTH_MISMATCH)
break;
Sleep(10);
}
return ret;
}
static BOOL test_modules(void)
{
BOOL ret;
......@@ -600,7 +620,7 @@ static void test_loaded_modules(void)
memset(&aggregation, 0, sizeof(aggregation));
aggregation.proc = pi.hProcess;
ret = EnumerateLoadedModulesW64(pi.hProcess, aggregate_cb, &aggregation);
ret = wrapper_EnumerateLoadedModulesW64(pi.hProcess, aggregate_cb, &aggregation);
ok(ret, "EnumerateLoadedModulesW64 failed: %lu\n", GetLastError());
if (is_win64)
......@@ -649,7 +669,7 @@ static void test_loaded_modules(void)
memset(&aggregation, 0, sizeof(aggregation));
aggregation.proc = pi.hProcess;
ret = EnumerateLoadedModulesW64(pi.hProcess, aggregate_cb, &aggregation);
ret = wrapper_EnumerateLoadedModulesW64(pi.hProcess, aggregate_cb, &aggregation);
ok(ret, "EnumerateLoadedModulesW64 failed: %lu\n", GetLastError());
todo_wine
......@@ -687,7 +707,7 @@ static void test_loaded_modules(void)
ok(ret, "SymInitialize failed: %lu\n", GetLastError());
memset(&aggregation2, 0, sizeof(aggregation2));
aggregation2.proc = pi.hProcess;
ret = EnumerateLoadedModulesW64(pi.hProcess, aggregate_cb, &aggregation2);
ret = wrapper_EnumerateLoadedModulesW64(pi.hProcess, aggregate_cb, &aggregation2);
ok(ret, "EnumerateLoadedModulesW64 failed: %lu\n", GetLastError());
ok(aggregation2.count_32bit && aggregation2.count_64bit, "Wrong bitness aggregation count %u %u\n",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment