comparison src/w32.c @ 72286:95d41ccb4448

(w32_valid_pointer_p): New function.
author Eli Zaretskii <eliz@gnu.org>
date Sat, 05 Aug 2006 13:01:10 +0000
parents 7b3a19a8bfdb
children acfcb86a7b5e 7f3f771c85fa
comparison
equal deleted inserted replaced
72285:01c53aa90ed3 72286:95d41ccb4448
319 error_no, 319 error_no,
320 0, /* choose most suitable language */ 320 0, /* choose most suitable language */
321 buf, sizeof (buf), NULL)) 321 buf, sizeof (buf), NULL))
322 sprintf (buf, "w32 error %u", error_no); 322 sprintf (buf, "w32 error %u", error_no);
323 return buf; 323 return buf;
324 }
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. */
330 int
331 w32_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;
324 } 346 }
325 347
326 static char startup_dir[MAXPATHLEN]; 348 static char startup_dir[MAXPATHLEN];
327 349
328 /* Get the current working directory. */ 350 /* Get the current working directory. */