]> git.eshelyaron.com Git - emacs.git/commitdiff
(w32_valid_pointer_p): New function.
authorEli Zaretskii <eliz@gnu.org>
Sat, 5 Aug 2006 13:01:10 +0000 (13:01 +0000)
committerEli Zaretskii <eliz@gnu.org>
Sat, 5 Aug 2006 13:01:10 +0000 (13:01 +0000)
src/w32.c

index c093eab599e35b583f33beef234d380db21cc34f..0da908ff93216863a55a274a18d0c04cb2484abb 100644 (file)
--- a/src/w32.c
+++ b/src/w32.c
@@ -323,6 +323,28 @@ w32_strerror (int error_no)
   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.  */