diff options
Diffstat (limited to 'src/w32.c')
| -rw-r--r-- | src/w32.c | 22 |
1 files changed, 22 insertions, 0 deletions
| @@ -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. */ | ||
| 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; | ||
| 346 | } | ||
| 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. */ |