dbgeng: Implement IsPointer64Bit().

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2019-04-23 10:38:16 +03:00 committed by Alexandre Julliard
parent 911050d87b
commit f2f9d8b269
2 changed files with 55 additions and 2 deletions

View File

@ -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,

View File

@ -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);