aboutsummaryrefslogtreecommitdiffstats
path: root/src/w32.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/w32.c')
-rw-r--r--src/w32.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/w32.c b/src/w32.c
index c093eab599e..0da908ff932 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -323,6 +323,28 @@ w32_strerror (int error_no)
323 return buf; 323 return buf;
324} 324}
325 325
326/* Return 1 if P is a valid pointer to an object of size SIZE. Return
327 0 if P is NOT a valid pointer. Return -1 if we cannot validate P.
328
329 This is called from alloc.c:valid_pointer_p. */
330int
331w32_valid_pointer_p (void *p, int size)
332{
333 SIZE_T done;
334 HANDLE h = OpenProcess (PROCESS_VM_READ, FALSE, GetCurrentProcessId ());
335
336 if (h)
337 {
338 unsigned char *buf = alloca (size);
339 int retval = ReadProcessMemory (h, p, buf, size, &done);
340
341 CloseHandle (h);
342 return retval;
343 }
344 else
345 return -1;
346}
347
326static char startup_dir[MAXPATHLEN]; 348static char startup_dir[MAXPATHLEN];
327 349
328/* Get the current working directory. */ 350/* Get the current working directory. */