2019-04-08 08:35:39 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2019 Nikolay Sivov for CodeWeavers
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
2019-04-11 15:03:10 +02:00
|
|
|
#include <stdio.h>
|
2019-04-08 08:35:39 +02:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
|
|
|
|
#include "initguid.h"
|
|
|
|
#include "dbgeng.h"
|
|
|
|
|
|
|
|
#include "wine/test.h"
|
|
|
|
|
|
|
|
static void test_engine_options(void)
|
|
|
|
{
|
|
|
|
IDebugControl *control;
|
|
|
|
ULONG options;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = DebugCreate(&IID_IDebugControl, (void **)&control);
|
|
|
|
ok(hr == S_OK, "Failed to create engine object, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
options = 0xf;
|
|
|
|
hr = control->lpVtbl->GetEngineOptions(control, &options);
|
|
|
|
ok(hr == S_OK, "Failed to get engine options, hr %#x.\n", hr);
|
|
|
|
ok(options == 0, "Unexpected options %#x.\n", options);
|
|
|
|
|
|
|
|
hr = control->lpVtbl->AddEngineOptions(control, DEBUG_ENGOPT_INITIAL_BREAK);
|
|
|
|
ok(hr == S_OK, "Failed to add engine options, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
options = 0;
|
|
|
|
hr = control->lpVtbl->GetEngineOptions(control, &options);
|
|
|
|
ok(hr == S_OK, "Failed to get engine options, hr %#x.\n", hr);
|
|
|
|
ok(options == DEBUG_ENGOPT_INITIAL_BREAK, "Unexpected options %#x.\n", options);
|
|
|
|
|
2020-10-11 08:33:08 +02:00
|
|
|
hr = control->lpVtbl->AddEngineOptions(control, 0x01000000);
|
2019-04-08 08:35:39 +02:00
|
|
|
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
|
|
|
|
|
|
|
|
options = 0;
|
|
|
|
hr = control->lpVtbl->GetEngineOptions(control, &options);
|
|
|
|
ok(hr == S_OK, "Failed to get engine options, hr %#x.\n", hr);
|
|
|
|
ok(options == DEBUG_ENGOPT_INITIAL_BREAK, "Unexpected options %#x.\n", options);
|
|
|
|
|
2020-10-11 08:33:08 +02:00
|
|
|
hr = control->lpVtbl->RemoveEngineOptions(control, 0x01000000);
|
2019-04-08 08:35:39 +02:00
|
|
|
ok(hr == S_OK, "Failed to remove options, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = control->lpVtbl->AddEngineOptions(control, DEBUG_ENGOPT_IGNORE_DBGHELP_VERSION);
|
|
|
|
ok(hr == S_OK, "Failed to add engine options, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
options = 0;
|
|
|
|
hr = control->lpVtbl->GetEngineOptions(control, &options);
|
|
|
|
ok(hr == S_OK, "Failed to get engine options, hr %#x.\n", hr);
|
|
|
|
ok(options == (DEBUG_ENGOPT_INITIAL_BREAK | DEBUG_ENGOPT_IGNORE_DBGHELP_VERSION),
|
|
|
|
"Unexpected options %#x.\n", options);
|
|
|
|
|
|
|
|
hr = control->lpVtbl->RemoveEngineOptions(control, DEBUG_ENGOPT_INITIAL_BREAK);
|
|
|
|
ok(hr == S_OK, "Failed to remove options, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
options = 0;
|
|
|
|
hr = control->lpVtbl->GetEngineOptions(control, &options);
|
|
|
|
ok(hr == S_OK, "Failed to get engine options, hr %#x.\n", hr);
|
|
|
|
ok(options == DEBUG_ENGOPT_IGNORE_DBGHELP_VERSION, "Unexpected options %#x.\n", options);
|
|
|
|
|
|
|
|
hr = control->lpVtbl->SetEngineOptions(control, DEBUG_ENGOPT_INITIAL_BREAK);
|
|
|
|
ok(hr == S_OK, "Failed to set options, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
options = 0;
|
|
|
|
hr = control->lpVtbl->GetEngineOptions(control, &options);
|
|
|
|
ok(hr == S_OK, "Failed to get engine options, hr %#x.\n", hr);
|
|
|
|
ok(options == DEBUG_ENGOPT_INITIAL_BREAK, "Unexpected options %#x.\n", options);
|
|
|
|
|
2020-10-11 08:33:08 +02:00
|
|
|
hr = control->lpVtbl->SetEngineOptions(control, 0x01000000);
|
2019-04-08 08:35:39 +02:00
|
|
|
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
|
|
|
|
|
2020-10-11 08:33:08 +02:00
|
|
|
hr = control->lpVtbl->SetEngineOptions(control, 0x01000000 | DEBUG_ENGOPT_IGNORE_DBGHELP_VERSION);
|
2019-04-08 08:35:39 +02:00
|
|
|
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
|
|
|
|
|
|
|
|
options = 0;
|
|
|
|
hr = control->lpVtbl->GetEngineOptions(control, &options);
|
|
|
|
ok(hr == S_OK, "Failed to get engine options, hr %#x.\n", hr);
|
|
|
|
ok(options == DEBUG_ENGOPT_INITIAL_BREAK, "Unexpected options %#x.\n", options);
|
|
|
|
|
|
|
|
control->lpVtbl->Release(control);
|
|
|
|
}
|
|
|
|
|
2019-04-11 15:03:10 +02:00
|
|
|
static HRESULT WINAPI event_callbacks_QueryInterface(IDebugEventCallbacks *iface, REFIID riid, void **out)
|
|
|
|
{
|
|
|
|
if (IsEqualIID(riid, &IID_IDebugEventCallbacks) ||
|
|
|
|
IsEqualIID(riid, &IID_IUnknown))
|
|
|
|
{
|
|
|
|
*out = iface;
|
|
|
|
iface->lpVtbl->AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
*out = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI event_callbacks_AddRef(IDebugEventCallbacks *iface)
|
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI event_callbacks_Release(IDebugEventCallbacks *iface)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI event_callbacks_GetInterestMask(IDebugEventCallbacks *iface, ULONG *mask)
|
|
|
|
{
|
|
|
|
*mask = ~0u;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI event_callbacks_Breakpoint(IDebugEventCallbacks *iface, PDEBUG_BREAKPOINT breakpoint)
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI event_callbacks_Exception(IDebugEventCallbacks *iface, EXCEPTION_RECORD64 *exception,
|
|
|
|
ULONG first_chance)
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI event_callbacks_CreateThread(IDebugEventCallbacks *iface, ULONG64 handle, ULONG64 data_offset,
|
|
|
|
ULONG64 start_offset)
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI event_callbacks_ExitThread(IDebugEventCallbacks *iface, ULONG exit_code)
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI event_callbacks_CreateProcess(IDebugEventCallbacks *iface, ULONG64 image_handle, ULONG64 handle,
|
|
|
|
ULONG64 base_offset, ULONG module_size, const char *module_name, const char *image_name, ULONG checksum,
|
|
|
|
ULONG timedatestamp, ULONG64 initial_thread_handle, ULONG64 thread_data_offset, ULONG64 start_offset)
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI event_callbacks_ExitProcess(IDebugEventCallbacks *iface, ULONG exit_code)
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI event_callbacks_LoadModule(IDebugEventCallbacks *iface, ULONG64 image_handle,
|
|
|
|
ULONG64 base_offset, ULONG module_size, const char *module_name, const char *image_name, ULONG checksum,
|
|
|
|
ULONG timedatestamp)
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI event_callbacks_UnloadModule(IDebugEventCallbacks *iface, const char *image_basename,
|
|
|
|
ULONG64 base_offset)
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI event_callbacks_SystemError(IDebugEventCallbacks *iface, ULONG error, ULONG level)
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI event_callbacks_SessionStatus(IDebugEventCallbacks *iface, ULONG status)
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI event_callbacks_ChangeDebuggeeState(IDebugEventCallbacks *iface, ULONG flags, ULONG64 argument)
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI event_callbacks_ChangeEngineState(IDebugEventCallbacks *iface, ULONG flags, ULONG64 argument)
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI event_callbacks_ChangeSymbolState(IDebugEventCallbacks *iface, ULONG flags, ULONG64 argument)
|
|
|
|
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IDebugEventCallbacksVtbl event_callbacks_vtbl =
|
|
|
|
{
|
|
|
|
event_callbacks_QueryInterface,
|
|
|
|
event_callbacks_AddRef,
|
|
|
|
event_callbacks_Release,
|
|
|
|
event_callbacks_GetInterestMask,
|
|
|
|
event_callbacks_Breakpoint,
|
|
|
|
event_callbacks_Exception,
|
|
|
|
event_callbacks_CreateThread,
|
|
|
|
event_callbacks_ExitThread,
|
|
|
|
event_callbacks_CreateProcess,
|
|
|
|
event_callbacks_ExitProcess,
|
|
|
|
event_callbacks_LoadModule,
|
|
|
|
event_callbacks_UnloadModule,
|
|
|
|
event_callbacks_SystemError,
|
|
|
|
event_callbacks_SessionStatus,
|
|
|
|
event_callbacks_ChangeDebuggeeState,
|
|
|
|
event_callbacks_ChangeEngineState,
|
|
|
|
event_callbacks_ChangeSymbolState,
|
|
|
|
};
|
|
|
|
|
2019-04-22 08:42:27 +02:00
|
|
|
static BOOL create_target_process(const char *event_name, PROCESS_INFORMATION *info)
|
2019-04-22 08:42:26 +02:00
|
|
|
{
|
2019-04-22 08:42:27 +02:00
|
|
|
static const char *event_target_ready_name = "dbgeng_test_target_ready_event";
|
2019-04-22 08:42:26 +02:00
|
|
|
char path_name[MAX_PATH];
|
|
|
|
STARTUPINFOA startup;
|
2019-04-22 08:42:27 +02:00
|
|
|
HANDLE ready_event;
|
2019-04-22 08:42:26 +02:00
|
|
|
char **argv;
|
2019-04-22 08:42:27 +02:00
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
ready_event = CreateEventA(NULL, FALSE, FALSE, event_target_ready_name);
|
|
|
|
ok(ready_event != NULL, "Failed to create event.\n");
|
2019-04-22 08:42:26 +02:00
|
|
|
|
|
|
|
winetest_get_mainargs(&argv);
|
|
|
|
memset(&startup, 0, sizeof(startup));
|
|
|
|
startup.cb = sizeof(startup);
|
2019-04-22 08:42:27 +02:00
|
|
|
sprintf(path_name, "%s dbgeng target %s %s", argv[0], event_name, event_target_ready_name);
|
|
|
|
ret = CreateProcessA(NULL, path_name, NULL, NULL, FALSE, 0, NULL, NULL, &startup, info);
|
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
WaitForSingleObject(ready_event, INFINITE);
|
|
|
|
}
|
|
|
|
|
|
|
|
CloseHandle(ready_event);
|
|
|
|
|
|
|
|
return ret;
|
2019-04-22 08:42:26 +02:00
|
|
|
}
|
|
|
|
|
2019-04-11 15:03:10 +02:00
|
|
|
static void test_attach(void)
|
|
|
|
{
|
2019-04-22 08:42:27 +02:00
|
|
|
static const char *event_name = "dbgeng_test_event";
|
2019-04-11 15:03:10 +02:00
|
|
|
IDebugEventCallbacks event_callbacks = { &event_callbacks_vtbl };
|
|
|
|
PROCESS_INFORMATION info;
|
|
|
|
IDebugControl *control;
|
|
|
|
IDebugClient *client;
|
|
|
|
BOOL is_debugged;
|
|
|
|
HANDLE event;
|
|
|
|
HRESULT hr;
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
hr = DebugCreate(&IID_IDebugClient, (void **)&client);
|
|
|
|
ok(hr == S_OK, "Failed to create engine object, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
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->SetEventCallbacks(client, &event_callbacks);
|
|
|
|
ok(hr == S_OK, "Failed to set event callbacks, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
event = CreateEventA(NULL, FALSE, FALSE, event_name);
|
|
|
|
ok(event != NULL, "Failed to create event.\n");
|
|
|
|
|
2019-04-22 08:42:27 +02:00
|
|
|
ret = create_target_process(event_name, &info);
|
2019-04-11 15:03:10 +02:00
|
|
|
ok(ret, "Failed to create target process.\n");
|
|
|
|
|
|
|
|
is_debugged = TRUE;
|
|
|
|
CheckRemoteDebuggerPresent(info.hProcess, &is_debugged);
|
|
|
|
ok(!is_debugged, "Unexpected mode.\n");
|
|
|
|
|
|
|
|
/* Non-invasive mode. */
|
|
|
|
hr = client->lpVtbl->AttachProcess(client, 0, info.dwProcessId, DEBUG_ATTACH_NONINVASIVE);
|
|
|
|
ok(hr == S_OK, "Failed to attach to process, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
is_debugged = TRUE;
|
|
|
|
ret = CheckRemoteDebuggerPresent(info.hProcess, &is_debugged);
|
|
|
|
ok(ret, "Failed to check target status.\n");
|
|
|
|
ok(!is_debugged, "Unexpected mode.\n");
|
|
|
|
|
|
|
|
hr = control->lpVtbl->WaitForEvent(control, 0, INFINITE);
|
|
|
|
ok(hr == S_OK, "Waiting for event failed, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
is_debugged = TRUE;
|
|
|
|
ret = CheckRemoteDebuggerPresent(info.hProcess, &is_debugged);
|
|
|
|
ok(ret, "Failed to check target status.\n");
|
|
|
|
ok(!is_debugged, "Unexpected mode.\n");
|
|
|
|
|
|
|
|
hr = client->lpVtbl->DetachProcesses(client);
|
|
|
|
ok(hr == S_OK, "Failed to detach, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = client->lpVtbl->EndSession(client, DEBUG_END_ACTIVE_DETACH);
|
|
|
|
todo_wine
|
|
|
|
ok(hr == S_OK, "Failed to end session, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
SetEvent(event);
|
|
|
|
|
2020-03-16 23:52:21 +01:00
|
|
|
wait_child_process(info.hProcess);
|
2019-04-11 15:03:10 +02:00
|
|
|
|
|
|
|
CloseHandle(info.hProcess);
|
|
|
|
CloseHandle(info.hThread);
|
|
|
|
|
|
|
|
CloseHandle(event);
|
|
|
|
|
|
|
|
client->lpVtbl->Release(client);
|
|
|
|
control->lpVtbl->Release(control);
|
|
|
|
}
|
|
|
|
|
2019-04-22 08:42:26 +02:00
|
|
|
static void test_module_information(void)
|
|
|
|
{
|
2019-04-22 08:42:27 +02:00
|
|
|
static const char *event_name = "dbgeng_test_event";
|
2019-04-23 09:38:15 +02:00
|
|
|
unsigned int loaded, unloaded, index, length;
|
2019-04-22 08:42:28 +02:00
|
|
|
DEBUG_MODULE_PARAMETERS params[2];
|
2019-04-23 09:38:15 +02:00
|
|
|
IDebugDataSpaces *dataspaces;
|
2019-04-22 08:42:26 +02:00
|
|
|
PROCESS_INFORMATION info;
|
2019-04-23 09:38:18 +02:00
|
|
|
IDebugSymbols2 *symbols;
|
2019-04-22 08:42:26 +02:00
|
|
|
IDebugControl *control;
|
2019-04-23 09:38:15 +02:00
|
|
|
ULONG64 bases[2], base;
|
2019-04-23 09:38:18 +02:00
|
|
|
char buffer[MAX_PATH];
|
2019-04-22 08:42:26 +02:00
|
|
|
IDebugClient *client;
|
|
|
|
HANDLE event;
|
|
|
|
HRESULT hr;
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
hr = DebugCreate(&IID_IDebugClient, (void **)&client);
|
|
|
|
ok(hr == S_OK, "Failed to create engine object, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = client->lpVtbl->QueryInterface(client, &IID_IDebugControl, (void **)&control);
|
|
|
|
ok(hr == S_OK, "Failed to get interface pointer, hr %#x.\n", hr);
|
|
|
|
|
2019-04-23 09:38:18 +02:00
|
|
|
hr = client->lpVtbl->QueryInterface(client, &IID_IDebugSymbols2, (void **)&symbols);
|
2019-04-22 08:42:26 +02:00
|
|
|
ok(hr == S_OK, "Failed to get interface pointer, hr %#x.\n", hr);
|
|
|
|
|
2019-04-23 09:38:15 +02:00
|
|
|
hr = client->lpVtbl->QueryInterface(client, &IID_IDebugDataSpaces, (void **)&dataspaces);
|
|
|
|
ok(hr == S_OK, "Failed to get interface pointer, hr %#x.\n", hr);
|
|
|
|
|
2019-04-23 09:38:16 +02:00
|
|
|
hr = control->lpVtbl->IsPointer64Bit(control);
|
|
|
|
ok(hr == E_UNEXPECTED, "Unexpected hr %#x.\n", hr);
|
|
|
|
|
2019-04-22 08:42:26 +02:00
|
|
|
event = CreateEventA(NULL, FALSE, FALSE, event_name);
|
|
|
|
ok(event != NULL, "Failed to create event.\n");
|
|
|
|
|
2019-04-22 08:42:27 +02:00
|
|
|
ret = create_target_process(event_name, &info);
|
2019-04-22 08:42:26 +02:00
|
|
|
ok(ret, "Failed to create target process.\n");
|
|
|
|
|
2019-04-22 08:42:27 +02:00
|
|
|
hr = control->lpVtbl->SetEngineOptions(control, DEBUG_ENGOPT_INITIAL_BREAK);
|
|
|
|
ok(hr == S_OK, "Failed to set engine options, hr %#x.\n", hr);
|
|
|
|
|
2019-04-22 08:42:26 +02:00
|
|
|
hr = client->lpVtbl->AttachProcess(client, 0, info.dwProcessId, DEBUG_ATTACH_NONINVASIVE);
|
|
|
|
ok(hr == S_OK, "Failed to attach to process, hr %#x.\n", hr);
|
|
|
|
|
2019-04-23 09:38:16 +02:00
|
|
|
hr = control->lpVtbl->IsPointer64Bit(control);
|
|
|
|
ok(hr == E_UNEXPECTED, "Unexpected hr %#x.\n", hr);
|
|
|
|
|
2019-04-22 08:42:26 +02:00
|
|
|
hr = control->lpVtbl->WaitForEvent(control, 0, INFINITE);
|
|
|
|
ok(hr == S_OK, "Waiting for event failed, hr %#x.\n", hr);
|
|
|
|
|
2019-04-23 09:38:16 +02:00
|
|
|
hr = control->lpVtbl->IsPointer64Bit(control);
|
|
|
|
ok(SUCCEEDED(hr), "Failed to get pointer length, hr %#x.\n", hr);
|
|
|
|
|
2019-04-22 08:42:26 +02:00
|
|
|
/* Number of modules. */
|
|
|
|
hr = symbols->lpVtbl->GetNumberModules(symbols, &loaded, &unloaded);
|
|
|
|
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
2019-04-22 08:42:27 +02:00
|
|
|
ok(loaded > 0, "Unexpected module count %u.\n", loaded);
|
|
|
|
|
|
|
|
/* Module base. */
|
|
|
|
hr = symbols->lpVtbl->GetModuleByIndex(symbols, loaded, &base);
|
|
|
|
ok(FAILED(hr), "Unexpected hr %#x.\n", hr);
|
|
|
|
|
|
|
|
base = 0;
|
|
|
|
hr = symbols->lpVtbl->GetModuleByIndex(symbols, 0, &base);
|
|
|
|
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
|
|
|
ok(!!base, "Unexpected module base.\n");
|
2019-04-22 08:42:26 +02:00
|
|
|
|
2019-04-22 08:42:29 +02:00
|
|
|
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);
|
|
|
|
|
2019-04-22 08:42:28 +02:00
|
|
|
/* Parameters. */
|
2019-04-22 08:42:29 +02:00
|
|
|
base = 0;
|
|
|
|
hr = symbols->lpVtbl->GetModuleByIndex(symbols, 0, &base);
|
|
|
|
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
|
|
|
ok(!!base, "Unexpected module base.\n");
|
|
|
|
|
2019-04-22 08:42:28 +02:00
|
|
|
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);
|
|
|
|
|
2019-04-23 09:38:18 +02:00
|
|
|
/* 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);
|
2019-05-01 09:01:20 +02:00
|
|
|
ok(strlen(buffer) + 2 == length, "Unexpected length %u.\n", length);
|
2019-04-23 09:38:18 +02:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2019-04-23 09:38:15 +02:00
|
|
|
/* Read memory. */
|
|
|
|
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 = dataspaces->lpVtbl->ReadVirtual(dataspaces, base, buffer, sizeof(buffer), &length);
|
|
|
|
ok(hr == S_OK, "Failed to read process memory, hr %#x.\n", hr);
|
|
|
|
ok(length == sizeof(buffer), "Unexpected length %u.\n", length);
|
|
|
|
ok(buffer[0] == 'M' && buffer[1] == 'Z', "Unexpected contents.\n");
|
|
|
|
|
|
|
|
memset(buffer, 0, sizeof(buffer));
|
|
|
|
hr = dataspaces->lpVtbl->ReadVirtual(dataspaces, base, buffer, sizeof(buffer), NULL);
|
|
|
|
ok(hr == S_OK, "Failed to read process memory, hr %#x.\n", hr);
|
|
|
|
ok(buffer[0] == 'M' && buffer[1] == 'Z', "Unexpected contents.\n");
|
|
|
|
|
2019-04-22 08:42:26 +02:00
|
|
|
hr = client->lpVtbl->DetachProcesses(client);
|
|
|
|
ok(hr == S_OK, "Failed to detach, hr %#x.\n", hr);
|
|
|
|
|
|
|
|
SetEvent(event);
|
2020-03-16 23:52:21 +01:00
|
|
|
wait_child_process(info.hProcess);
|
2019-04-22 08:42:26 +02:00
|
|
|
|
|
|
|
CloseHandle(info.hProcess);
|
|
|
|
CloseHandle(info.hThread);
|
2019-05-01 09:01:20 +02:00
|
|
|
CloseHandle(event);
|
2019-04-22 08:42:26 +02:00
|
|
|
|
|
|
|
client->lpVtbl->Release(client);
|
|
|
|
control->lpVtbl->Release(control);
|
|
|
|
symbols->lpVtbl->Release(symbols);
|
2019-04-23 09:38:15 +02:00
|
|
|
dataspaces->lpVtbl->Release(dataspaces);
|
2019-04-22 08:42:26 +02:00
|
|
|
}
|
|
|
|
|
2019-04-22 08:42:27 +02:00
|
|
|
static void target_proc(const char *event_name, const char *event_ready_name)
|
2019-04-11 15:03:10 +02:00
|
|
|
{
|
2019-04-22 08:42:27 +02:00
|
|
|
HANDLE terminate_event, ready_event;
|
2019-04-11 15:03:10 +02:00
|
|
|
|
2019-04-22 08:42:27 +02:00
|
|
|
terminate_event = OpenEventA(SYNCHRONIZE, FALSE, event_name);
|
|
|
|
ok(terminate_event != NULL, "Failed to open event handle.\n");
|
|
|
|
|
|
|
|
ready_event = OpenEventA(EVENT_MODIFY_STATE, FALSE, event_ready_name);
|
|
|
|
ok(ready_event != NULL, "Failed to open event handle.\n");
|
|
|
|
|
|
|
|
SetEvent(ready_event);
|
2019-04-11 15:03:10 +02:00
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
2019-04-22 08:42:27 +02:00
|
|
|
if (WaitForSingleObject(terminate_event, 100) == WAIT_OBJECT_0)
|
2019-04-11 15:03:10 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-04-22 08:42:27 +02:00
|
|
|
CloseHandle(terminate_event);
|
|
|
|
CloseHandle(ready_event);
|
2019-04-11 15:03:10 +02:00
|
|
|
}
|
|
|
|
|
2019-04-08 08:35:39 +02:00
|
|
|
START_TEST(dbgeng)
|
|
|
|
{
|
2019-04-11 15:03:10 +02:00
|
|
|
char **argv;
|
|
|
|
int argc;
|
|
|
|
|
|
|
|
argc = winetest_get_mainargs(&argv);
|
|
|
|
|
2019-04-22 08:42:27 +02:00
|
|
|
if (argc > 4 && !strcmp(argv[2], "target"))
|
2019-04-11 15:03:10 +02:00
|
|
|
{
|
2019-04-22 08:42:27 +02:00
|
|
|
target_proc(argv[3], argv[4]);
|
2019-04-11 15:03:10 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-04-08 08:35:39 +02:00
|
|
|
test_engine_options();
|
2019-04-11 15:03:10 +02:00
|
|
|
test_attach();
|
2019-04-22 08:42:26 +02:00
|
|
|
test_module_information();
|
2019-04-08 08:35:39 +02:00
|
|
|
}
|