mirror of
https://github.com/radareorg/radare2.git
synced 2024-12-03 02:41:08 +00:00
Fix win64 debugger (#6371)
* fixed win64 debugger with x32 app * fixed win64 debugger with x32 app * Update cmd_open.c * Update windows.c
This commit is contained in:
parent
675f7b2f3c
commit
427429204e
7
libr/core/cconfig.c
Normal file → Executable file
7
libr/core/cconfig.c
Normal file → Executable file
@ -407,6 +407,13 @@ static int cb_asmbits(void *user, void *data) {
|
||||
}
|
||||
if (load_from_debug) {
|
||||
if (core->dbg->h && core->dbg->h->reg_profile) {
|
||||
#if __WINDOWS__
|
||||
#if !defined(__MINGW64__)
|
||||
core->dbg->bits = R_SYS_BITS_32;
|
||||
#else
|
||||
core->dbg->bits = R_SYS_BITS_64;
|
||||
#endif
|
||||
#endif
|
||||
char *rp = core->dbg->h->reg_profile (core->dbg);
|
||||
r_reg_set_profile_string (core->dbg->reg, rp);
|
||||
r_reg_set_profile_string (core->anal->reg, rp);
|
||||
|
@ -236,8 +236,7 @@ static void cmd_open_map (RCore *core, const char *input) {
|
||||
}
|
||||
r_core_block_read (core);
|
||||
}
|
||||
|
||||
R_API void r_core_file_reopen_in_malloc(RCore *core) {
|
||||
R_API void r_core_file_reopen_in_malloc (RCore *core) {
|
||||
RCoreFile *f;
|
||||
RListIter *iter;
|
||||
r_list_foreach (core->files, iter, f) {
|
||||
@ -263,7 +262,7 @@ R_API void r_core_file_reopen_in_malloc(RCore *core) {
|
||||
}
|
||||
}
|
||||
|
||||
R_API void r_core_file_reopen_debug(RCore *core, const char *args) {
|
||||
R_API void r_core_file_reopen_debug (RCore *core, const char *args) {
|
||||
RCoreFile *ofile = core->file;
|
||||
RBinFile *bf = NULL;
|
||||
char *binpath = NULL;
|
||||
@ -310,6 +309,7 @@ R_API void r_core_file_reopen_debug(RCore *core, const char *args) {
|
||||
free (newfile);
|
||||
}
|
||||
|
||||
|
||||
static int cmd_open(void *data, const char *input) {
|
||||
const char *help_msg[] = {
|
||||
"Usage: o","[com- ] [file] ([offset])","",
|
||||
|
0
libr/core/file.c
Normal file → Executable file
0
libr/core/file.c
Normal file → Executable file
44
libr/debug/p/native/maps/windows.c
Normal file → Executable file
44
libr/debug/p/native/maps/windows.c
Normal file → Executable file
@ -41,6 +41,7 @@ static RList *w32_dbg_maps(RDebug *dbg) {
|
||||
HANDLE hModuleSnap = 0;
|
||||
IMAGE_DOS_HEADER *dos_header;
|
||||
IMAGE_NT_HEADERS *nt_headers;
|
||||
IMAGE_NT_HEADERS32 *nt_headers32;
|
||||
IMAGE_SECTION_HEADER *SectionHeader;
|
||||
SIZE_T ret_len;
|
||||
MODULEENTRY32 me32;
|
||||
@ -64,28 +65,24 @@ static RList *w32_dbg_maps(RDebug *dbg) {
|
||||
CloseHandle (hModuleSnap);
|
||||
return NULL;
|
||||
}
|
||||
hProcess=w32_openprocess (PROCESS_QUERY_INFORMATION |PROCESS_VM_READ,
|
||||
FALSE, pid );
|
||||
hProcess = w32_openprocess (PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid);
|
||||
do {
|
||||
ReadProcessMemory (WIN32_PI (hProcess),
|
||||
(const void *)me32.modBaseAddr,
|
||||
(LPVOID)PeHeader, sizeof(PeHeader), &ret_len);
|
||||
|
||||
ReadProcessMemory (WIN32_PI (hProcess), (const void *)me32.modBaseAddr, (LPVOID)PeHeader, sizeof(PeHeader), &ret_len);
|
||||
if (ret_len == sizeof (PeHeader) && CheckValidPE (PeHeader)) {
|
||||
dos_header = (IMAGE_DOS_HEADER *)PeHeader;
|
||||
if (!dos_header) continue;
|
||||
nt_headers = (IMAGE_NT_HEADERS *)((char *)dos_header \
|
||||
+ dos_header->e_lfanew);
|
||||
nt_headers = (IMAGE_NT_HEADERS *)((char *)dos_header + dos_header->e_lfanew);
|
||||
if (!nt_headers) continue;
|
||||
NumSections = nt_headers->FileHeader.NumberOfSections;
|
||||
SectionHeader = (IMAGE_SECTION_HEADER *) ((char *)nt_headers \
|
||||
+ sizeof(IMAGE_NT_HEADERS));
|
||||
mr = r_debug_map_new (me32.szModule,
|
||||
(ut64)(size_t) (me32.modBaseAddr),
|
||||
(ut64)(size_t) (me32.modBaseAddr + \
|
||||
SectionHeader->VirtualAddress),
|
||||
SectionHeader->Characteristics,
|
||||
0);
|
||||
if (nt_headers->FileHeader.Machine == 0x014c) { // check for x32 pefile
|
||||
nt_headers32 = (IMAGE_NT_HEADERS32 *)((char *)dos_header + dos_header->e_lfanew);
|
||||
NumSections = nt_headers32->FileHeader.NumberOfSections;
|
||||
SectionHeader = (IMAGE_SECTION_HEADER *)((char *)nt_headers32 + sizeof (IMAGE_NT_HEADERS32));
|
||||
|
||||
} else {
|
||||
NumSections = nt_headers->FileHeader.NumberOfSections;
|
||||
SectionHeader = (IMAGE_SECTION_HEADER *)((char *)nt_headers + sizeof (IMAGE_NT_HEADERS));
|
||||
}
|
||||
mr = r_debug_map_new (me32.szModule, (ut64)(size_t) (me32.modBaseAddr), (ut64)(size_t) (me32.modBaseAddr + SectionHeader->VirtualAddress), SectionHeader->Characteristics, 0);
|
||||
if (mr != NULL) r_list_append (list, mr);
|
||||
if (NumSections <= 0) continue;
|
||||
mapname = (char *)malloc(MAX_PATH);
|
||||
@ -93,17 +90,8 @@ static RList *w32_dbg_maps(RDebug *dbg) {
|
||||
for (i = 0; i < NumSections; i++) {
|
||||
if (SectionHeader->Misc.VirtualSize <= 0)
|
||||
continue;
|
||||
sprintf(mapname,"%s | %s",
|
||||
me32.szModule,
|
||||
SectionHeader->Name);
|
||||
|
||||
mr = r_debug_map_new (mapname,
|
||||
(ut64)(size_t)(SectionHeader->VirtualAddress +\
|
||||
me32.modBaseAddr),
|
||||
(ut64)(size_t)(SectionHeader->VirtualAddress + \
|
||||
me32.modBaseAddr + SectionHeader->Misc.VirtualSize),
|
||||
SectionHeader->Characteristics, // XXX?
|
||||
0);
|
||||
sprintf(mapname,"%s | %s", me32.szModule, SectionHeader->Name);
|
||||
mr = r_debug_map_new (mapname, (ut64)(size_t)(SectionHeader->VirtualAddress + me32.modBaseAddr), (ut64)(size_t)(SectionHeader->VirtualAddress + me32.modBaseAddr + SectionHeader->Misc.VirtualSize), SectionHeader->Characteristics, 0);
|
||||
if (mr != NULL) r_list_append (list, mr);
|
||||
SectionHeader++;
|
||||
}
|
||||
|
@ -646,6 +646,7 @@ static int w32_dbg_wait(RDebug *dbg, int pid) {
|
||||
if (exited_already == pid) {
|
||||
return -1;
|
||||
}
|
||||
memset (&de, 0, sizeof (DEBUG_EVENT));
|
||||
if (WaitForDebugEvent (&de, INFINITE) == 0) {
|
||||
print_lasterr ((char *)__FUNCTION__, "WaitForDebugEvent");
|
||||
return -1;
|
||||
@ -729,6 +730,9 @@ static int w32_dbg_wait(RDebug *dbg, int pid) {
|
||||
break;
|
||||
case EXCEPTION_DEBUG_EVENT:
|
||||
switch (de.u.Exception.ExceptionRecord.ExceptionCode) {
|
||||
#if __MINGW64__
|
||||
case 0x4000001f:
|
||||
#endif
|
||||
case EXCEPTION_BREAKPOINT:
|
||||
ret = R_DEBUG_REASON_BREAKPOINT;
|
||||
next_event = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user