diff options
author | Christopher Faylor <me+cygwin@cgf.cx> | 2003-02-21 02:29:18 +0000 |
---|---|---|
committer | Christopher Faylor <me+cygwin@cgf.cx> | 2003-02-21 02:29:18 +0000 |
commit | 6f17862b8112995a2b045804eea264d4a451fae5 (patch) | |
tree | 7c70ff37c82a56dc116d73f3d98c8793ff4bfe0b | |
parent | 3decd77d89d2bcdc38a46b1ee37d74a7d7c66f3f (diff) | |
download | gdb-6f17862b8112995a2b045804eea264d4a451fae5.zip gdb-6f17862b8112995a2b045804eea264d4a451fae5.tar.gz gdb-6f17862b8112995a2b045804eea264d4a451fae5.tar.bz2 |
* win32-nat.c (get_image_name): Check return value from ReadProcessMemory.
(child_xfer_memory): Ditto.
-rw-r--r-- | gdb/ChangeLog | 6 | ||||
-rw-r--r-- | gdb/win32-nat.c | 27 | ||||
-rw-r--r-- | gdb/windows-nat.c | 27 |
3 files changed, 30 insertions, 30 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index e655032..32966ac 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2003-02-20 Christopher Faylor <cgf@redhat.com> + + * win32-nat.c (get_image_name): Check return value from + ReadProcessMemory. + (child_xfer_memory): Ditto. + 2003-02-20 Alexandre Oliva <aoliva@redhat.com> * configure.in (TARGET_SYSTEM_ROOT): Set default to diff --git a/gdb/win32-nat.c b/gdb/win32-nat.c index 103a3f2..72e8c3f 100644 --- a/gdb/win32-nat.c +++ b/gdb/win32-nat.c @@ -635,21 +635,16 @@ get_image_name (HANDLE h, void *address, int unicode) if (address == NULL) return NULL; - ReadProcessMemory (h, address, &address_ptr, sizeof (address_ptr), &done); - /* See if we could read the address of a string, and that the address isn't null. */ - - if (done != sizeof (address_ptr) || !address_ptr) + if (!ReadProcessMemory (h, address, &address_ptr, sizeof (address_ptr), &done) + || done != sizeof (address_ptr) || !address_ptr) return NULL; /* Find the length of the string */ - do - { - ReadProcessMemory (h, address_ptr + len * size, &b, size, &done); - len++; - } - while ((b[0] != 0 || b[size - 1] != 0) && done == size); + while (ReadProcessMemory (h, address_ptr + len++ * size, &b, size, &done) + && (b[0] != 0 || b[size - 1] != 0) && done == size) + continue; if (!unicode) ReadProcessMemory (h, address_ptr, buf, len, &done); @@ -1863,21 +1858,23 @@ child_xfer_memory (CORE_ADDR memaddr, char *our, int len, int write, struct mem_attrib *mem, struct target_ops *target) { - DWORD done; + DWORD done = 0; if (write) { DEBUG_MEM (("gdb: write target memory, %d bytes at 0x%08lx\n", len, (DWORD) memaddr)); - WriteProcessMemory (current_process_handle, (LPVOID) memaddr, our, - len, &done); + if (!WriteProcessMemory (current_process_handle, (LPVOID) memaddr, our, + len, &done)) + done = 0; FlushInstructionCache (current_process_handle, (LPCVOID) memaddr, len); } else { DEBUG_MEM (("gdb: read target memory, %d bytes at 0x%08lx\n", len, (DWORD) memaddr)); - ReadProcessMemory (current_process_handle, (LPCVOID) memaddr, our, len, - &done); + if (!ReadProcessMemory (current_process_handle, (LPCVOID) memaddr, our, + len, &done)) + done = 0; } return done; } diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index 103a3f2..72e8c3f 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -635,21 +635,16 @@ get_image_name (HANDLE h, void *address, int unicode) if (address == NULL) return NULL; - ReadProcessMemory (h, address, &address_ptr, sizeof (address_ptr), &done); - /* See if we could read the address of a string, and that the address isn't null. */ - - if (done != sizeof (address_ptr) || !address_ptr) + if (!ReadProcessMemory (h, address, &address_ptr, sizeof (address_ptr), &done) + || done != sizeof (address_ptr) || !address_ptr) return NULL; /* Find the length of the string */ - do - { - ReadProcessMemory (h, address_ptr + len * size, &b, size, &done); - len++; - } - while ((b[0] != 0 || b[size - 1] != 0) && done == size); + while (ReadProcessMemory (h, address_ptr + len++ * size, &b, size, &done) + && (b[0] != 0 || b[size - 1] != 0) && done == size) + continue; if (!unicode) ReadProcessMemory (h, address_ptr, buf, len, &done); @@ -1863,21 +1858,23 @@ child_xfer_memory (CORE_ADDR memaddr, char *our, int len, int write, struct mem_attrib *mem, struct target_ops *target) { - DWORD done; + DWORD done = 0; if (write) { DEBUG_MEM (("gdb: write target memory, %d bytes at 0x%08lx\n", len, (DWORD) memaddr)); - WriteProcessMemory (current_process_handle, (LPVOID) memaddr, our, - len, &done); + if (!WriteProcessMemory (current_process_handle, (LPVOID) memaddr, our, + len, &done)) + done = 0; FlushInstructionCache (current_process_handle, (LPCVOID) memaddr, len); } else { DEBUG_MEM (("gdb: read target memory, %d bytes at 0x%08lx\n", len, (DWORD) memaddr)); - ReadProcessMemory (current_process_handle, (LPCVOID) memaddr, our, len, - &done); + if (!ReadProcessMemory (current_process_handle, (LPCVOID) memaddr, our, + len, &done)) + done = 0; } return done; } |