diff --git a/dlls/dbgeng/dbgeng.c b/dlls/dbgeng/dbgeng.c index d4f8205726b..b5650d86797 100644 --- a/dlls/dbgeng/dbgeng.c +++ b/dlls/dbgeng/dbgeng.c @@ -144,6 +144,22 @@ static const struct module_info *debug_target_get_module_info(struct target_proc return &target->modules.info[i]; } +static const struct module_info *debug_target_get_module_info_by_base(struct target_process *target, ULONG64 base) +{ + unsigned int i; + + if (FAILED(debug_target_init_modules_info(target))) + return NULL; + + for (i = 0; i < target->modules.loaded; ++i) + { + if (target->modules.info[i].params.Base == base) + return &target->modules.info[i]; + } + + return NULL; +} + static void debug_client_detach_target(struct target_process *target) { NTSTATUS status; @@ -1055,11 +1071,44 @@ static HRESULT STDMETHODCALLTYPE debugsymbols_GetModuleNames(IDebugSymbols3 *ifa } static HRESULT STDMETHODCALLTYPE debugsymbols_GetModuleParameters(IDebugSymbols3 *iface, ULONG count, ULONG64 *bases, - ULONG start, DEBUG_MODULE_PARAMETERS *parameters) + ULONG start, DEBUG_MODULE_PARAMETERS *params) { - FIXME("%p, %u, %p, %u, %p stub.\n", iface, count, bases, start, parameters); + struct debug_client *debug_client = impl_from_IDebugSymbols3(iface); + const struct module_info *info; + struct target_process *target; + unsigned int i; - return E_NOTIMPL; + TRACE("%p, %u, %p, %u, %p.\n", iface, count, bases, start, params); + + if (!(target = debug_client_get_target(debug_client))) + return E_UNEXPECTED; + + if (bases) + { + for (i = 0; i < count; ++i) + { + if ((info = debug_target_get_module_info_by_base(target, bases[i]))) + { + params[i] = info->params; + } + else + { + memset(¶ms[i], 0, sizeof(*params)); + params[i].Base = DEBUG_INVALID_OFFSET; + } + } + } + else + { + for (i = start; i < start + count; ++i) + { + if (!(info = debug_target_get_module_info(target, i))) + return E_INVALIDARG; + params[i] = info->params; + } + } + + return S_OK; } static HRESULT STDMETHODCALLTYPE debugsymbols_GetSymbolModule(IDebugSymbols3 *iface, const char *symbol, ULONG64 *base) diff --git a/dlls/dbgeng/tests/dbgeng.c b/dlls/dbgeng/tests/dbgeng.c index 74f9e7ceb6f..2002beb37f7 100644 --- a/dlls/dbgeng/tests/dbgeng.c +++ b/dlls/dbgeng/tests/dbgeng.c @@ -322,11 +322,13 @@ todo_wine static void test_module_information(void) { static const char *event_name = "dbgeng_test_event"; + DEBUG_MODULE_PARAMETERS params[2]; unsigned int loaded, unloaded; PROCESS_INFORMATION info; IDebugSymbols *symbols; IDebugControl *control; IDebugClient *client; + ULONG64 bases[2]; ULONG64 base; HANDLE event; HRESULT hr; @@ -370,6 +372,33 @@ static void test_module_information(void) ok(hr == S_OK, "Unexpected hr %#x.\n", hr); ok(!!base, "Unexpected module base.\n"); + /* Parameters. */ + hr = symbols->lpVtbl->GetModuleParameters(symbols, 1, NULL, 0, params); + ok(hr == S_OK, "Failed to get module parameters, hr %#x.\n", hr); + ok(params[0].Base == base, "Unexpected module base.\n"); + + hr = symbols->lpVtbl->GetModuleParameters(symbols, 1, &base, 100, params); + ok(hr == S_OK, "Failed to get module parameters, hr %#x.\n", hr); + ok(params[0].Base == base, "Unexpected module base.\n"); + + bases[0] = base + 1; + bases[1] = base; + hr = symbols->lpVtbl->GetModuleParameters(symbols, 2, bases, 0, params); + ok(hr == S_OK || broken(hr == E_NOINTERFACE) /* XP */, "Failed to get module parameters, hr %#x.\n", hr); + ok(params[0].Base == DEBUG_INVALID_OFFSET, "Unexpected module base.\n"); + ok(params[0].Size == 0, "Unexpected module size.\n"); + ok(params[1].Base == base, "Unexpected module base.\n"); + ok(params[1].Size != 0, "Unexpected module size.\n"); + + hr = symbols->lpVtbl->GetModuleParameters(symbols, 1, bases, 0, params); + ok(hr == S_OK || broken(hr == E_NOINTERFACE) /* XP */, "Failed to get module parameters, hr %#x.\n", hr); + + hr = symbols->lpVtbl->GetModuleParameters(symbols, 1, bases, loaded, params); + ok(hr == S_OK || broken(hr == E_NOINTERFACE) /* XP */, "Failed to get module parameters, hr %#x.\n", hr); + + hr = symbols->lpVtbl->GetModuleParameters(symbols, 1, NULL, loaded, params); + ok(FAILED(hr), "Unexpected hr %#x.\n", hr); + hr = client->lpVtbl->DetachProcesses(client); ok(hr == S_OK, "Failed to detach, hr %#x.\n", hr); diff --git a/include/dbgeng.h b/include/dbgeng.h index 3b7ff2be4f4..f50a1ca21d9 100644 --- a/include/dbgeng.h +++ b/include/dbgeng.h @@ -162,6 +162,8 @@ DEFINE_GUID(IID_IDebugSystemObjects3, 0xe9676e2f, 0xe286, 0x4ea3, 0xb0, 0xf9 #define DEBUG_CDS_REFRESH_INLINESTEP 16 #define DEBUG_CDS_REFRESH_INLINESTEP_PSEUDO 17 +#define DEBUG_INVALID_OFFSET ((ULONG64)-1) + typedef struct _DEBUG_MODULE_PARAMETERS { ULONG64 Base;