forked from wjp/idados
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dosbox_local_impl.cpp
75 lines (62 loc) · 2.18 KB
/
dosbox_local_impl.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include <segment.hpp>
//--------------------------------------------------------------------------
// installs or uninstalls debugger specific idc functions
inline bool register_idc_funcs(bool)
{
return true;
}
//--------------------------------------------------------------------------
void idaapi rebase_if_required_to(ea_t new_base)
{
ea_t currentbase = new_base;
ea_t imagebase = inf.baseaddr<<4;
msg("imagebase = %a newbase=%a\n", imagebase, new_base);
if ( imagebase != currentbase )
{
adiff_t delta = currentbase - imagebase;
delta /= 16;
msg("delta = %d\n", delta);
int code = rebase_program(currentbase - imagebase, MSF_FIXONCE);
if ( code != MOVE_SEGM_OK )
{
msg("Failed to rebase program, error code %d\n", code);
warning("IDA failed to rebase the program.\n"
"Most likely it happened because of the debugger\n"
"segments created to reflect the real memory state.\n\n"
"Please stop the debugger and rebase the program manually.\n"
"For that, please select the whole program and\n"
"use Edit, Segments, Rebase program with delta 0x%08a",
currentbase - imagebase);
}
warning("Database rebased to %ah\n", new_base);
}
}
//--------------------------------------------------------------------------
static bool init_plugin(void)
{
#ifndef RPC_CLIENT
if (!init_subsystem())
return false;
#endif
debugger.resume_modes = DBG_RESMOD_STEP_INTO;
if ( !netnode::inited() || is_miniidb() || inf.is_snapshot() )
{
//dosbox is always remote.
return debugger.is_remote();
}
if ( inf.filetype != f_EXE && inf.filetype != f_COM )
return false; // only MSDOS EXE or COM files
if ( ph.id != PLFM_386 )
return false; // only IBM PC
return true;
}
//--------------------------------------------------------------------------
inline void term_plugin(void)
{
}
//--------------------------------------------------------------------------
char comment[] = "Userland dosbox debugger plugin.";
char help[] =
"Userland dosbox debugger plugin.\n"
"\n"
"This module lets you debug programs running in DOSBox.\n";