From d6771b133388762d21256bb914075245c7005fc1 Mon Sep 17 00:00:00 2001 From: Eric Pouech Date: Mon, 12 Jan 2004 21:05:53 +0000 Subject: [PATCH] Implemented Toolhelp32ReadProcessMemory. --- dlls/kernel/kernel32.spec | 2 +- dlls/kernel/toolhelp.c | 20 ++++++++++++++++++++ include/tlhelp32.h | 1 + 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/dlls/kernel/kernel32.spec b/dlls/kernel/kernel32.spec index 505bd13bc4b..5d6dcff7557 100644 --- a/dlls/kernel/kernel32.spec +++ b/dlls/kernel/kernel32.spec @@ -818,7 +818,7 @@ @ stub TlsFreeInternal @ stdcall TlsGetValue(long) @ stdcall TlsSetValue(long ptr) -@ stub Toolhelp32ReadProcessMemory +@ stdcall Toolhelp32ReadProcessMemory(long ptr ptr long ptr) @ stdcall TransactNamedPipe(long ptr long ptr long ptr ptr) @ stdcall TransmitCommChar(long long) @ stdcall TzSpecificLocalTimeToSystemTime(ptr ptr ptr) diff --git a/dlls/kernel/toolhelp.c b/dlls/kernel/toolhelp.c index 2524f0f9338..d37f0a80c9d 100644 --- a/dlls/kernel/toolhelp.c +++ b/dlls/kernel/toolhelp.c @@ -441,3 +441,23 @@ BOOL WINAPI Heap32ListFirst(HANDLE hSnapshot, LPHEAPLIST32 lphl) FIXME(": stub\n"); return FALSE; } + +/****************************************************************** + * Toolhelp32ReadProcessMemory (KERNEL.@) + * + * + */ +BOOL WINAPI Toolhelp32ReadProcessMemory(DWORD pid, const void* base, + void* buf, SIZE_T len, SIZE_T* r) +{ + HANDLE h; + BOOL ret = FALSE; + + h = (pid) ? OpenProcess(PROCESS_VM_READ, FALSE, pid) : GetCurrentProcess(); + if (h != NULL) + { + ret = ReadProcessMemory(h, base, buf, len, r); + if (pid) CloseHandle(h); + } + return ret; +} diff --git a/include/tlhelp32.h b/include/tlhelp32.h index 3a6d5bda388..fa657472b0a 100644 --- a/include/tlhelp32.h +++ b/include/tlhelp32.h @@ -154,6 +154,7 @@ typedef struct tagHEAPLIST32 { } HEAPLIST32, *PHEAPLIST32, *LPHEAPLIST32; BOOL WINAPI Heap32ListFirst(HANDLE,LPHEAPLIST32); +BOOL WINAPI Toolhelp32ReadProcessMemory(DWORD,LPCVOID,LPVOID,SIZE_T,SIZE_T*); #ifdef __cplusplus } /* extern "C" */ -- 2.11.4.GIT