Nikolay Sivov : dbgeng: Partially implement GetModuleNameString().
Alexandre Julliard
julliard at winehq.org
Tue Apr 23 17:39:54 CDT 2019
Module: wine
Branch: master
Commit: 64aa7f61ad3c5c5517848e9c1c432a0f10fffc4a
URL: https://source.winehq.org/git/wine.git/?a=commit;h=64aa7f61ad3c5c5517848e9c1c432a0f10fffc4a
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Tue Apr 23 10:38:18 2019 +0300
dbgeng: Partially implement GetModuleNameString().
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/dbgeng/dbgeng.c | 62 ++++++++++++++++++++++++++++++++++++++++++++--
dlls/dbgeng/tests/dbgeng.c | 27 +++++++++++++++++---
include/dbgeng.h | 8 ++++++
3 files changed, 92 insertions(+), 5 deletions(-)
diff --git a/dlls/dbgeng/dbgeng.c b/dlls/dbgeng/dbgeng.c
index a62c052..704084c 100644
--- a/dlls/dbgeng/dbgeng.c
+++ b/dlls/dbgeng/dbgeng.c
@@ -42,6 +42,7 @@ extern NTSTATUS WINAPI NtResumeProcess(HANDLE handle);
struct module_info
{
DEBUG_MODULE_PARAMETERS params;
+ char image_name[MAX_PATH];
};
struct target_process
@@ -136,6 +137,9 @@ static HRESULT debug_target_init_modules_info(struct target_process *target)
target->modules.info[i].params.Base = (ULONG_PTR)info.lpBaseOfDll;
target->modules.info[i].params.Size = info.SizeOfImage;
+
+ GetModuleFileNameExA(target->handle, modules[i], target->modules.info[i].image_name,
+ ARRAY_SIZE(target->modules.info[i].image_name));
}
}
@@ -1448,13 +1452,67 @@ static HRESULT STDMETHODCALLTYPE debugsymbols_GetModuleVersionInformation(IDebug
return E_NOTIMPL;
}
+static HRESULT debug_target_return_string(const char *str, char *buffer, unsigned int buffer_size,
+ unsigned int *size)
+{
+ unsigned int len = strlen(str), dst_len;
+
+ if (size)
+ *size = len + 1;
+
+ if (buffer && buffer_size)
+ {
+ dst_len = min(len, buffer_size - 1);
+ if (dst_len)
+ memcpy(buffer, str, dst_len);
+ buffer[dst_len] = 0;
+ }
+
+ return len < buffer_size ? S_OK : S_FALSE;
+}
+
static HRESULT STDMETHODCALLTYPE debugsymbols_GetModuleNameString(IDebugSymbols3 *iface, ULONG which, ULONG index,
ULONG64 base, char *buffer, ULONG buffer_size, ULONG *name_size)
{
- FIXME("%p, %u, %u, %s, %p, %u, %p stub.\n", iface, which, index, wine_dbgstr_longlong(base), buffer, buffer_size,
+ struct debug_client *debug_client = impl_from_IDebugSymbols3(iface);
+ const struct module_info *info;
+ struct target_process *target;
+ HRESULT hr;
+
+ TRACE("%p, %u, %u, %s, %p, %u, %p.\n", iface, which, index, wine_dbgstr_longlong(base), buffer, buffer_size,
name_size);
- return E_NOTIMPL;
+ if (!(target = debug_client_get_target(debug_client)))
+ return E_UNEXPECTED;
+
+ if (index == DEBUG_ANY_ID)
+ info = debug_target_get_module_info_by_base(target, base);
+ else
+ info = debug_target_get_module_info(target, index);
+
+ if (!info)
+ {
+ WARN("Was unable to locate module.\n");
+ return E_INVALIDARG;
+ }
+
+ switch (which)
+ {
+ case DEBUG_MODNAME_IMAGE:
+ hr = debug_target_return_string(info->image_name, buffer, buffer_size, name_size);
+ break;
+ case DEBUG_MODNAME_MODULE:
+ case DEBUG_MODNAME_LOADED_IMAGE:
+ case DEBUG_MODNAME_SYMBOL_FILE:
+ case DEBUG_MODNAME_MAPPED_IMAGE:
+ FIXME("Unsupported name info %d.\n", which);
+ return E_NOTIMPL;
+ default:
+ WARN("Unknown name info %d.\n", which);
+ return E_INVALIDARG;
+ }
+
+ return hr;
}
static HRESULT STDMETHODCALLTYPE debugsymbols_GetConstantName(IDebugSymbols3 *iface, ULONG64 module, ULONG type_id,
diff --git a/dlls/dbgeng/tests/dbgeng.c b/dlls/dbgeng/tests/dbgeng.c
index 32f9001..715649b 100644
--- a/dlls/dbgeng/tests/dbgeng.c
+++ b/dlls/dbgeng/tests/dbgeng.c
@@ -326,11 +326,11 @@ static void test_module_information(void)
DEBUG_MODULE_PARAMETERS params[2];
IDebugDataSpaces *dataspaces;
PROCESS_INFORMATION info;
- IDebugSymbols *symbols;
+ IDebugSymbols2 *symbols;
IDebugControl *control;
ULONG64 bases[2], base;
+ char buffer[MAX_PATH];
IDebugClient *client;
- char buffer[64];
HANDLE event;
HRESULT hr;
BOOL ret;
@@ -341,7 +341,7 @@ static void test_module_information(void)
hr = client->lpVtbl->QueryInterface(client, &IID_IDebugControl, (void **)&control);
ok(hr == S_OK, "Failed to get interface pointer, hr %#x.\n", hr);
- hr = client->lpVtbl->QueryInterface(client, &IID_IDebugSymbols, (void **)&symbols);
+ hr = client->lpVtbl->QueryInterface(client, &IID_IDebugSymbols2, (void **)&symbols);
ok(hr == S_OK, "Failed to get interface pointer, hr %#x.\n", hr);
hr = client->lpVtbl->QueryInterface(client, &IID_IDebugDataSpaces, (void **)&dataspaces);
@@ -432,6 +432,27 @@ static void test_module_information(void)
hr = symbols->lpVtbl->GetModuleParameters(symbols, 1, NULL, loaded, params);
ok(FAILED(hr), "Unexpected hr %#x.\n", hr);
+ /* Image name. */
+ hr = symbols->lpVtbl->GetModuleNameString(symbols, DEBUG_MODNAME_IMAGE, 0, 0, buffer, sizeof(buffer), &length);
+ ok(hr == S_OK, "Failed to get image name, hr %#x.\n", hr);
+ ok(strlen(buffer) + 1 == length, "Unexpected length.\n");
+
+ hr = symbols->lpVtbl->GetModuleNameString(symbols, DEBUG_MODNAME_IMAGE, 0, 0, NULL, sizeof(buffer), &length);
+ ok(hr == S_OK, "Failed to get image name, hr %#x.\n", hr);
+ ok(length > 0, "Unexpected length.\n");
+
+ hr = symbols->lpVtbl->GetModuleNameString(symbols, DEBUG_MODNAME_IMAGE, DEBUG_ANY_ID, base, buffer, sizeof(buffer),
+ &length);
+ ok(hr == S_OK, "Failed to get image name, hr %#x.\n", hr);
+ ok(strlen(buffer) + 1 == length, "Unexpected length.\n");
+
+ hr = symbols->lpVtbl->GetModuleNameString(symbols, DEBUG_MODNAME_IMAGE, 0, 0, buffer, length - 1, &length);
+ ok(hr == S_FALSE, "Failed to get image name, hr %#x.\n", hr);
+ ok(strlen(buffer) + 2 == length, "Unexpected length %u, %u.\n", length, strlen(buffer));
+
+ hr = symbols->lpVtbl->GetModuleNameString(symbols, DEBUG_MODNAME_IMAGE, 0, 0, NULL, length - 1, NULL);
+ ok(hr == S_FALSE, "Failed to get image name, hr %#x.\n", hr);
+
/* Read memory. */
base = 0;
hr = symbols->lpVtbl->GetModuleByIndex(symbols, 0, &base);
diff --git a/include/dbgeng.h b/include/dbgeng.h
index f50a1ca..3017eda 100644
--- a/include/dbgeng.h
+++ b/include/dbgeng.h
@@ -162,7 +162,15 @@ DEFINE_GUID(IID_IDebugSystemObjects3, 0xe9676e2f, 0xe286, 0x4ea3, 0xb0, 0xf9
#define DEBUG_CDS_REFRESH_INLINESTEP 16
#define DEBUG_CDS_REFRESH_INLINESTEP_PSEUDO 17
+/* GetModuleNameString() indices */
+#define DEBUG_MODNAME_IMAGE 0
+#define DEBUG_MODNAME_MODULE 1
+#define DEBUG_MODNAME_LOADED_IMAGE 2
+#define DEBUG_MODNAME_SYMBOL_FILE 3
+#define DEBUG_MODNAME_MAPPED_IMAGE 4
+
#define DEBUG_INVALID_OFFSET ((ULONG64)-1)
+#define DEBUG_ANY_ID 0xffffffff
typedef struct _DEBUG_MODULE_PARAMETERS
{
More information about the wine-cvs
mailing list