From: Eric Pouech eric.pouech@gmail.com
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: Eric Pouech eric.pouech@gmail.com --- dlls/dbghelp/tests/dbghelp.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-)
diff --git a/dlls/dbghelp/tests/dbghelp.c b/dlls/dbghelp/tests/dbghelp.c index 618ee6e8cdb..04833e28dc7 100644 --- a/dlls/dbghelp/tests/dbghelp.c +++ b/dlls/dbghelp/tests/dbghelp.c @@ -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",