2007-01-02 13:23:48 +00:00
|
|
|
/*
|
|
|
|
* Wine debugger - loading a module for debug purposes
|
|
|
|
*
|
|
|
|
* Copyright 2006 Eric Pouech
|
|
|
|
*
|
|
|
|
* 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 <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#include "debugger.h"
|
|
|
|
|
|
|
|
|
|
|
|
static struct be_process_io be_process_module_io;
|
|
|
|
|
2009-06-05 13:16:14 +00:00
|
|
|
static BOOL tgt_process_module_read(HANDLE hProcess, const void* addr,
|
|
|
|
void* buffer, SIZE_T len, SIZE_T* rlen)
|
2007-01-02 13:23:48 +00:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2009-06-05 13:16:14 +00:00
|
|
|
static BOOL tgt_process_module_write(HANDLE hProcess, void* addr,
|
|
|
|
const void* buffer, SIZE_T len, SIZE_T* wlen)
|
2007-01-02 13:23:48 +00:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
enum dbg_start tgt_module_load(const char* name, BOOL keep)
|
|
|
|
{
|
|
|
|
DWORD opts = SymGetOptions();
|
2019-06-06 23:44:31 +00:00
|
|
|
BOOL native;
|
2007-01-02 13:23:48 +00:00
|
|
|
HANDLE hDummy = (HANDLE)0x87654321;
|
2007-03-04 16:02:31 +00:00
|
|
|
enum dbg_start ret = start_ok;
|
2008-10-18 07:15:19 +00:00
|
|
|
WCHAR* nameW;
|
|
|
|
unsigned len;
|
2007-01-02 13:23:48 +00:00
|
|
|
|
|
|
|
SymSetOptions((opts & ~(SYMOPT_UNDNAME|SYMOPT_DEFERRED_LOADS)) |
|
2019-06-06 23:44:31 +00:00
|
|
|
SYMOPT_LOAD_LINES | SYMOPT_AUTO_PUBLICS);
|
|
|
|
native = SymSetExtendedOption(SYMOPT_EX_WINE_NATIVE_MODULES, TRUE);
|
2008-08-30 06:44:48 +00:00
|
|
|
if (!dbg_init(hDummy, NULL, FALSE))
|
2007-03-04 16:02:31 +00:00
|
|
|
return start_error_init;
|
2008-10-18 07:15:19 +00:00
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, name, -1, NULL, 0);
|
2022-07-20 12:28:42 +00:00
|
|
|
nameW = malloc(len * sizeof(WCHAR));
|
2008-10-18 07:15:19 +00:00
|
|
|
if (!nameW)
|
2007-03-04 16:02:31 +00:00
|
|
|
{
|
|
|
|
ret = start_error_init;
|
|
|
|
keep = FALSE;
|
|
|
|
}
|
2008-10-18 07:15:19 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, name, -1, nameW, len);
|
|
|
|
if (!dbg_load_module(hDummy, NULL, nameW, 0, 0))
|
|
|
|
{
|
|
|
|
ret = start_error_init;
|
|
|
|
keep = FALSE;
|
|
|
|
}
|
2022-07-20 12:28:42 +00:00
|
|
|
free(nameW);
|
2008-10-18 07:15:19 +00:00
|
|
|
}
|
2007-01-02 13:23:48 +00:00
|
|
|
|
|
|
|
if (keep)
|
|
|
|
{
|
|
|
|
dbg_printf("Non supported mode... errors may occur\n"
|
|
|
|
"Use at your own risks\n");
|
2019-06-06 23:44:31 +00:00
|
|
|
SymSetExtendedOption(SYMOPT_EX_WINE_NATIVE_MODULES, TRUE);
|
2007-01-02 13:23:48 +00:00
|
|
|
dbg_curr_process = dbg_add_process(&be_process_module_io, 1, hDummy);
|
|
|
|
dbg_curr_pid = 1;
|
2007-03-04 16:02:31 +00:00
|
|
|
dbg_curr_thread = dbg_add_thread(dbg_curr_process, 2, NULL, NULL);
|
|
|
|
|
2007-01-02 13:23:48 +00:00
|
|
|
/* FIXME: missing thread creation, fetching frames, restoring dbghelp's options... */
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SymCleanup(hDummy);
|
|
|
|
SymSetOptions(opts);
|
2019-06-06 23:44:31 +00:00
|
|
|
SymSetExtendedOption(SYMOPT_EX_WINE_NATIVE_MODULES, native);
|
2007-01-02 13:23:48 +00:00
|
|
|
}
|
|
|
|
|
2007-03-04 16:02:31 +00:00
|
|
|
return ret;
|
2007-01-02 13:23:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL tgt_process_module_close_process(struct dbg_process* pcs, BOOL kill)
|
|
|
|
{
|
|
|
|
SymCleanup(pcs->handle);
|
|
|
|
dbg_del_process(pcs);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2009-06-05 13:16:14 +00:00
|
|
|
static BOOL tgt_process_module_get_selector(HANDLE hThread, DWORD sel, LDT_ENTRY* le)
|
2008-01-13 16:02:55 +00:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2007-01-02 13:23:48 +00:00
|
|
|
static struct be_process_io be_process_module_io =
|
|
|
|
{
|
|
|
|
tgt_process_module_close_process,
|
|
|
|
tgt_process_module_read,
|
|
|
|
tgt_process_module_write,
|
2008-01-13 16:02:55 +00:00
|
|
|
tgt_process_module_get_selector,
|
2007-01-02 13:23:48 +00:00
|
|
|
};
|