Mercurial > emacs
changeset 72286:95d41ccb4448
(w32_valid_pointer_p): New function.
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Sat, 05 Aug 2006 13:01:10 +0000 |
parents | 01c53aa90ed3 |
children | 875a47d81ba5 |
files | src/w32.c |
diffstat | 1 files changed, 22 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/w32.c Sat Aug 05 12:33:22 2006 +0000 +++ b/src/w32.c Sat Aug 05 13:01:10 2006 +0000 @@ -323,6 +323,28 @@ return buf; } +/* Return 1 if P is a valid pointer to an object of size SIZE. Return + 0 if P is NOT a valid pointer. Return -1 if we cannot validate P. + + This is called from alloc.c:valid_pointer_p. */ +int +w32_valid_pointer_p (void *p, int size) +{ + SIZE_T done; + HANDLE h = OpenProcess (PROCESS_VM_READ, FALSE, GetCurrentProcessId ()); + + if (h) + { + unsigned char *buf = alloca (size); + int retval = ReadProcessMemory (h, p, buf, size, &done); + + CloseHandle (h); + return retval; + } + else + return -1; +} + static char startup_dir[MAXPATHLEN]; /* Get the current working directory. */