Nikolay Sivov : dbgeng: Implement IsPointer64Bit().

Alexandre Julliard julliard at winehq.org
Tue Apr 23 17:39:54 CDT 2019


Module: wine
Branch: master
Commit: f2f9d8b26982a168017f66002e2d73c14994f915
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=f2f9d8b26982a168017f66002e2d73c14994f915

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Tue Apr 23 10:38:16 2019 +0300

dbgeng: Implement IsPointer64Bit().

Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/dbgeng/dbgeng.c       | 48 ++++++++++++++++++++++++++++++++++++++++++++--
 dlls/dbgeng/tests/dbgeng.c |  9 +++++++++
 2 files changed, 55 insertions(+), 2 deletions(-)

diff --git a/dlls/dbgeng/dbgeng.c b/dlls/dbgeng/dbgeng.c
index d7f8191..5352d3c 100644
--- a/dlls/dbgeng/dbgeng.c
+++ b/dlls/dbgeng/dbgeng.c
@@ -57,6 +57,7 @@ struct target_process
         unsigned int unloaded;
         BOOL initialized;
     } modules;
+    ULONG cpu_type;
 };
 
 struct debug_client
@@ -79,6 +80,21 @@ static struct target_process *debug_client_get_target(struct debug_client *debug
     return LIST_ENTRY(list_head(&debug_client->targets), struct target_process, entry);
 }
 
+static WORD debug_target_get_module_machine(struct target_process *target, HMODULE module)
+{
+    IMAGE_DOS_HEADER dos = { 0 };
+    WORD machine = 0;
+
+    ReadProcessMemory(target->handle, module, &dos, sizeof(dos), NULL);
+    if (dos.e_magic == IMAGE_DOS_SIGNATURE)
+    {
+        ReadProcessMemory(target->handle, (const char *)module + dos.e_lfanew + 4 /* signature */, &machine,
+                sizeof(machine), NULL);
+    }
+
+    return machine;
+}
+
 static HRESULT debug_target_init_modules_info(struct target_process *target)
 {
     unsigned int i, count;
@@ -123,6 +139,8 @@ static HRESULT debug_target_init_modules_info(struct target_process *target)
         }
     }
 
+    target->cpu_type = debug_target_get_module_machine(target, modules[0]);
+
     heap_free(modules);
 
     target->modules.loaded = count;
@@ -2465,9 +2483,35 @@ static HRESULT STDMETHODCALLTYPE debugcontrol_GetPageSize(IDebugControl2 *iface,
 
 static HRESULT STDMETHODCALLTYPE debugcontrol_IsPointer64Bit(IDebugControl2 *iface)
 {
-    FIXME("%p stub.\n", iface);
+    struct debug_client *debug_client = impl_from_IDebugControl2(iface);
+    static struct target_process *target;
+    HRESULT hr;
 
-    return E_NOTIMPL;
+    TRACE("%p.\n", iface);
+
+    if (!(target = debug_client_get_target(debug_client)))
+        return E_UNEXPECTED;
+
+    if (FAILED(hr = debug_target_init_modules_info(target)))
+        return hr;
+
+    switch (target->cpu_type)
+    {
+        case IMAGE_FILE_MACHINE_I386:
+        case IMAGE_FILE_MACHINE_ARM:
+            hr = S_FALSE;
+            break;
+        case IMAGE_FILE_MACHINE_IA64:
+        case IMAGE_FILE_MACHINE_AMD64:
+        case IMAGE_FILE_MACHINE_ARM64:
+            hr = S_OK;
+            break;
+        default:
+            FIXME("Unexpected cpu type %#x.\n", target->cpu_type);
+            hr = E_UNEXPECTED;
+    }
+
+    return hr;
 }
 
 static HRESULT STDMETHODCALLTYPE debugcontrol_ReadBugCheckData(IDebugControl2 *iface, ULONG *code, ULONG64 *arg1,
diff --git a/dlls/dbgeng/tests/dbgeng.c b/dlls/dbgeng/tests/dbgeng.c
index c8906c90..32f9001 100644
--- a/dlls/dbgeng/tests/dbgeng.c
+++ b/dlls/dbgeng/tests/dbgeng.c
@@ -347,6 +347,9 @@ static void test_module_information(void)
     hr = client->lpVtbl->QueryInterface(client, &IID_IDebugDataSpaces, (void **)&dataspaces);
     ok(hr == S_OK, "Failed to get interface pointer, hr %#x.\n", hr);
 
+    hr = control->lpVtbl->IsPointer64Bit(control);
+    ok(hr == E_UNEXPECTED, "Unexpected hr %#x.\n", hr);
+
     event = CreateEventA(NULL, FALSE, FALSE, event_name);
     ok(event != NULL, "Failed to create event.\n");
 
@@ -359,9 +362,15 @@ static void test_module_information(void)
     hr = client->lpVtbl->AttachProcess(client, 0, info.dwProcessId, DEBUG_ATTACH_NONINVASIVE);
     ok(hr == S_OK, "Failed to attach to process, hr %#x.\n", hr);
 
+    hr = control->lpVtbl->IsPointer64Bit(control);
+    ok(hr == E_UNEXPECTED, "Unexpected hr %#x.\n", hr);
+
     hr = control->lpVtbl->WaitForEvent(control, 0, INFINITE);
     ok(hr == S_OK, "Waiting for event failed, hr %#x.\n", hr);
 
+    hr = control->lpVtbl->IsPointer64Bit(control);
+    ok(SUCCEEDED(hr), "Failed to get pointer length, hr %#x.\n", hr);
+
     /* Number of modules. */
     hr = symbols->lpVtbl->GetNumberModules(symbols, &loaded, &unloaded);
     ok(hr == S_OK, "Unexpected hr %#x.\n", hr);




More information about the wine-cvs mailing list