home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / os / mach / 1052 < prev    next >
Encoding:
Text File  |  1992-08-18  |  1.5 KB  |  56 lines

  1. Newsgroups: comp.os.mach
  2. Path: sparky!uunet!mcsun!sun4nl!utrcu1!infnews!infnews!matena
  3. From: matena@cs.utwente.nl (Wim Matena)
  4. Subject: wiring down memory
  5. Message-ID: <1992Aug18.161726@cs.utwente.nl>
  6. Keywords: privileged host port
  7. Sender: usenet@cs.utwente.nl
  8. Nntp-Posting-Host: eufraat
  9. Organization: University of Twente, Dept. of Computer Science
  10. Date: Tue, 18 Aug 1992 14:17:26 GMT
  11. Lines: 43
  12.  
  13. Dear reader,
  14.  
  15. In our attempts to allocate a piece of user-space memory that can be WIRED DOWN
  16. we have stumbled upon the 'task_by_pid(-1)' system call of the BSD server.
  17. This call returns the much needed 'privileged_host_port'. However, the 
  18. vm_wire system call still doesn't work properly. It returns the well known
  19. 'KERN_FAILURE' error message. Could anyone help us out here?
  20. Our test program follows below. Any other solutions to wiring down a piece of
  21. memory are also VERY welcome!
  22.  
  23. Thanks in advance...
  24.  
  25.     Wim & Kees
  26.  
  27.  
  28.  
  29. #include <mach.h>
  30. #include <stdio.h>
  31. #include <mach_error.h>
  32. #include <mach/message.h>
  33.  
  34. void main() {
  35. mach_port_t host_priv_port;
  36. kern_return_t kr;
  37. int *ptr;
  38.  
  39.     host_priv_port = task_by_pid(-1);
  40.     printf("host_priv_port = 0x%X\n", host_priv_port);
  41.     if (vm_allocate(mach_task_self(), &ptr, 4096, TRUE) !=
  42.         KERN_SUCCESS) {
  43.         printf("vm_allocate failed \n");
  44.     }
  45.     if (vm_protect(mach_task_self(), ptr, 4096, TRUE, VM_PROT_ALL) != KERN_SUCCESS) {
  46.         printf("vm_protect failed\n");
  47.     }
  48.     if ((kr=vm_wire(host_priv_port, mach_task_self(), ptr, 4096, VM_PROT_ALL))
  49.         != KERN_SUCCESS) {
  50.         mach_error("vm_wire failed", kr);
  51.     }
  52.  
  53.  
  54.  
  55.