home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 4 / hacker04 / 04_HACK04.ISO / darwin / darwinx86.iso / usr / local / include / mach-o / kld.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-09-14  |  3.1 KB  |  100 lines

  1. /*
  2.  * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
  3.  *
  4.  * @APPLE_LICENSE_HEADER_START@
  5.  * 
  6.  * Portions Copyright (c) 1999 Apple Computer, Inc.  All Rights
  7.  * Reserved.  This file contains Original Code and/or Modifications of
  8.  * Original Code as defined in and that are subject to the Apple Public
  9.  * Source License Version 1.1 (the "License").  You may not use this file
  10.  * except in compliance with the License.  Please obtain a copy of the
  11.  * License at http://www.apple.com/publicsource and read it before using
  12.  * this file.
  13.  * 
  14.  * The Original Code and all software distributed under the License are
  15.  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  16.  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  17.  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
  18.  * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT.  Please see the
  19.  * License for the specific language governing rights and limitations
  20.  * under the License.
  21.  * 
  22.  * @APPLE_LICENSE_HEADER_END@
  23.  */
  24.  
  25. #ifndef _MACHO_KLD_H_
  26. #define _MACHO_KLD_H_
  27.  
  28. #include <mach-o/loader.h>
  29. #include <stdarg.h>
  30.  
  31. /*
  32.  * These API's are in libkld.  Both kmodload(8) and /mach_kernel should
  33.  * link with -lkld and then ld(1) will expand -lkld to libkld.dylib or
  34.  * libkld.a depending on if -dynamic or -static is in effect.
  35.  *
  36.  * Note: we are using the __DYNAMIC__ flag to indicate user space kernel
  37.  * linking and __STATIC__ as a synonym of KERNEL.
  38.  */
  39.  
  40. /*
  41.  * Note that you must supply the following function for error reporting when
  42.  * using any of the functions listed here.
  43.  */
  44. extern void kld_error_vprintf(const char *format, va_list ap);
  45.  
  46. /*
  47.  * These two are only in libkld.dylib for use by kmodload(8) (user code compiled
  48.  * with the default -dynamic).
  49.  */
  50. #ifdef __DYNAMIC__
  51. __private_extern__ long kld_load_basefile(
  52.     const char *base_filename);
  53.  
  54. __private_extern__ long kld_load_basefile_from_memory(
  55.     const char *base_filename,
  56.     char *base_addr,
  57.     long base_size);
  58.  
  59. /* Note: this takes only one object file name */
  60. __private_extern__ long kld_load(
  61.     struct mach_header **header_addr,
  62.     const char *object_filename,
  63.     const char *output_filename);
  64.  
  65. __private_extern__ long kld_load_from_memory(
  66.     struct mach_header **header_addr,
  67.     const char *object_name,
  68.     char *object_addr,
  69.     long object_size,
  70.     const char *output_filename);
  71. #endif /* __DYNAMIC__ */
  72.  
  73. /*
  74.  * This two are only in libkld.a use by /mach_kernel (kernel code compiled with
  75.  * -static).
  76.  */
  77. #ifdef __STATIC__
  78. /* Note: this api does not write an output file */
  79. __private_extern__ long kld_load_from_memory(
  80.     struct mach_header **header_addr,
  81.     const char *object_name,
  82.     char *object_addr,
  83.     long object_size);
  84. #endif /* __STATIC__ */
  85.  
  86. __private_extern__ long kld_unload_all(
  87.     long deallocate_sets);
  88.  
  89. __private_extern__ long kld_lookup(
  90.     const char *symbol_name,
  91.     unsigned long *value);
  92.  
  93. __private_extern__ long kld_forget_symbol(
  94.     const char *symbol_name);
  95.  
  96. __private_extern__ void kld_address_func(
  97.     unsigned long (*func)(unsigned long size, unsigned long headers_size));
  98.  
  99. #endif /* _MACHO_KLD_H_ */
  100.