[PATCH 5/5] dbgeng: Implement GetModuleByOffset().
Nikolay Sivov
nsivov at codeweavers.com
Mon Apr 22 01:42:29 CDT 2019
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
dlls/dbgeng/dbgeng.c | 25 +++++++++++++++++++++++--
dlls/dbgeng/tests/dbgeng.c | 22 +++++++++++++++++++++-
2 files changed, 44 insertions(+), 3 deletions(-)
diff --git a/dlls/dbgeng/dbgeng.c b/dlls/dbgeng/dbgeng.c
index b5650d8679..1acfe0b318 100644
--- a/dlls/dbgeng/dbgeng.c
+++ b/dlls/dbgeng/dbgeng.c
@@ -1053,9 +1053,30 @@ static HRESULT STDMETHODCALLTYPE debugsymbols_GetModuleByModuleName(IDebugSymbol
static HRESULT STDMETHODCALLTYPE debugsymbols_GetModuleByOffset(IDebugSymbols3 *iface, ULONG64 offset,
ULONG start_index, ULONG *index, ULONG64 *base)
{
- FIXME("%p, %s, %u, %p, %p stub.\n", iface, wine_dbgstr_longlong(offset), start_index, index, base);
+ struct debug_client *debug_client = impl_from_IDebugSymbols3(iface);
+ static struct target_process *target;
+ const struct module_info *info;
- return E_NOTIMPL;
+ TRACE("%p, %s, %u, %p, %p.\n", iface, wine_dbgstr_longlong(offset), start_index, index, base);
+
+ if (!(target = debug_client_get_target(debug_client)))
+ return E_UNEXPECTED;
+
+ while ((info = debug_target_get_module_info(target, start_index)))
+ {
+ if (offset >= info->params.Base && offset < info->params.Base + info->params.Size)
+ {
+ if (index)
+ *index = start_index;
+ if (base)
+ *base = info->params.Base;
+ return S_OK;
+ }
+
+ start_index++;
+ }
+
+ return E_INVALIDARG;
}
static HRESULT STDMETHODCALLTYPE debugsymbols_GetModuleNames(IDebugSymbols3 *iface, ULONG index, ULONG64 base,
diff --git a/dlls/dbgeng/tests/dbgeng.c b/dlls/dbgeng/tests/dbgeng.c
index 2002beb37f..2a2dd3ad06 100644
--- a/dlls/dbgeng/tests/dbgeng.c
+++ b/dlls/dbgeng/tests/dbgeng.c
@@ -322,8 +322,8 @@ todo_wine
static void test_module_information(void)
{
static const char *event_name = "dbgeng_test_event";
+ unsigned int loaded, unloaded, index;
DEBUG_MODULE_PARAMETERS params[2];
- unsigned int loaded, unloaded;
PROCESS_INFORMATION info;
IDebugSymbols *symbols;
IDebugControl *control;
@@ -372,7 +372,27 @@ static void test_module_information(void)
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
ok(!!base, "Unexpected module base.\n");
+ hr = symbols->lpVtbl->GetModuleByOffset(symbols, 0, 0, &index, &base);
+ ok(FAILED(hr), "Unexpected hr %#x.\n", hr);
+
+ hr = symbols->lpVtbl->GetModuleByOffset(symbols, base, 0, &index, &base);
+ ok(hr == S_OK, "Failed to get module, hr %#x.\n", hr);
+
+ hr = symbols->lpVtbl->GetModuleByOffset(symbols, base, 0, NULL, NULL);
+ ok(hr == S_OK, "Failed to get module, hr %#x.\n", hr);
+
+ hr = symbols->lpVtbl->GetModuleByOffset(symbols, base + 1, 0, NULL, NULL);
+ ok(hr == S_OK, "Failed to get module, hr %#x.\n", hr);
+
+ hr = symbols->lpVtbl->GetModuleByOffset(symbols, base, loaded, NULL, NULL);
+ ok(FAILED(hr), "Unexpected hr %#x.\n", hr);
+
/* Parameters. */
+ base = 0;
+ hr = symbols->lpVtbl->GetModuleByIndex(symbols, 0, &base);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+ ok(!!base, "Unexpected module base.\n");
+
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");
--
2.20.1
More information about the wine-devel
mailing list