13 const int page_size = 0x1000;
14 from = ((
from + page_size) / page_size) * page_size;
24 if (!ReadProcessMemory(
dbg->pi.hProcess, (
void *)(
size_t)
addr,
buf,
len, &ret) && GetLastError() == ERROR_PARTIAL_COPY) {
26 if (!ReadProcessMemory(
dbg->pi.hProcess, (
void *)(
size_t)
addr,
buf, 1, &ret)) {
32 skipped = valid_addr -
addr;
38 int read_len =
len - skipped;
39 int totRead = skipped;
40 while (totRead <
len) {
41 while (!ReadProcessMemory(
dbg->pi.hProcess, (
void *)(
size_t)
addr,
buf, read_len, &ret)) {
46 ut64 valid_addr = __find_next_valid_addr(
dbg->pi.hProcess,
addr,
addr +
len - totRead);
50 skipped = valid_addr -
addr;
55 read_len =
len - totRead;
61 read_len =
RZ_MIN(read_len,
len - totRead);
68 return debug_os_read_at(
fd->data,
buf,
len, io->
off);
73 return 0 != WriteProcessMemory(
dbg->pi.hProcess, (
void *)(
size_t)
addr,
buf,
len, &ret) ?
len : 0;
77 return w32dbg_write_at(
fd->data,
buf,
len, io->
off);
81 if (!strncmp(
file,
"attach://", 9)) {
84 return !strncmp(
file,
"w32dbg://", 9);
87 static inline bool current_handle_valid(
W32DbgWInst *wrap,
int pid) {
91 static int __open_proc(
RzIO *io,
int pid,
bool attach) {
96 if (current_handle_valid(wrap,
pid)) {
101 CloseHandle(wrap->
pi.hProcess);
116 wrap->
pi.dwProcessId =
pid;
117 wrap->
pi.hProcess = h_proc;
128 if (__open_proc(io, atoi(
file + 9), !strncmp(
file,
"attach://", 9)) == -1) {
165 if (!strcmp(
cmd,
"")) {
167 }
else if (!strncmp(
cmd,
"pid", 3)) {
180 return wrap->
pi.dwProcessId;
185 return wrap ? wrap->
pi.dwThreadId : -1;
199 .desc =
"w32 debugger io plugin",
201 .uris =
"w32dbg://,attach://",
211 .getbase = __getbase,
220 #ifndef RZ_PLUGIN_INCORE
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags cmd
static int __read(RzIO *io, RzIODesc *fd, ut8 *buf, int count)
static bool __plugin_open(RzIO *io, const char *pathname, bool many)
static RzIODesc * __open(RzIO *io, const char *pathname, int rw, int mode)
static int __write(RzIO *io, RzIODesc *fd, const ut8 *buf, int count)
static ut64 __lseek(RzIO *io, RzIODesc *fd, ut64 offset, int whence)
static int __close(RzIODesc *fd)
static char * __system(RzIO *io, RzIODesc *fd, const char *cmd)
static int __gettid(RzIODesc *fd)
static int __getpid(RzIODesc *fd)
RzIOPlugin rz_io_plugin_w32dbg
RZ_API RzLibStruct rizin_plugin
#define INVALID_HANDLE_VALUE
return memset(p, 0, total)
static static fork const void static count static fd const char const char static newpath char char char static envp time_t static t const char static mode static whence const char static dir time_t static t unsigned static seconds const char struct utimbuf static buf static inc pid
RZ_API RzIODesc * rz_io_desc_new(RzIO *io, RzIOPlugin *plugin, const char *uri, int flags, int mode, void *data)
RZ_API char * rz_str_newf(const char *fmt,...) RZ_PRINTF_CHECK(1
RZ_API bool rz_str_startswith(RZ_NONNULL const char *str, RZ_NONNULL const char *needle)
Checks if a string starts with a specifc sequence of characters (case sensitive)
RZ_API char * rz_sys_pid_to_path(int pid)
static struct sockaddr static addrlen static backlog const void static flags void struct sockaddr from
static struct sockaddr static addrlen static backlog const void static flags void struct sockaddr socklen_t static fromlen const void const struct sockaddr to
int(* attach)(RzDebug *dbg, int pid)
struct rz_debug_plugin_t * cur
int w32dbg_wrap_wait_ret(W32DbgWInst *inst)
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
static const z80_opcode fd[]