The Kernel Kit Table of Contents | The Kernel Kit Index |
Declared in: be/kernel/image.h
Library: libroot.so
This isn't about graphics. An image is compiled code, of which there are three types: app images, library images, and add-on images. An app image is executable code that can be launched. A library image is a collection of shared code that you link against when you're compiling your application. An add-on image is code that an app can load and run while the app itself is running. Note that an add-on can also be an app; in other words, you can create an image that can be launched by itself, or that can be loaded into another application.
For more information on creating and using images, see "Image Concepts".
|
These functions copy, into the info argument, the image_info structure for a particular image. The get_image_info() function gets the information for the image identified by image.
The get_next_image_info() function lets you step through the list of a team's images through iterated calls. The team argument identifies the team you want to look at; a team value of 0 means the team of the calling thread. The cookie argument is a placemark; you set it to 0 on your first call, and let the function do the rest. The function returns B_BAD_VALUE when there are no more images to visit:
/* Get the image_info for every image in this team. */ image_info info; int32 cookie = 0; while (get_next_image_info(0, &cookie, &info) == B_OK) ...
The image_info structure is:
|
The fields are:
The self-explanatory image_type constants are:
image_type Constants |
---|
B_APP_IMAGE |
B_LIBRARY_IMAGE |
B_ADD_ON_IMAGE |
RETURN CODES
B_OK. The image was found; info contains valid information.
|
get_image_symbol() returns, in location, a pointer to the address of the symbol that's identified by the image, symbol_name, and symbol_type arguments. An example demonstrating the use of this function is given in "Symbols."
get_nth_image_symbol() returns information about the n'th symbol in the given image. The information is returned in the arguments:
Keep in mind that name_length is reset each time you call get_nth_image_symbol(). If you're calling the function iteratively (to retrieve all the symbols in an image), you need to reset the name_length value between calls.
To retrieve image_id numbers on which these functions can act, use the get_next_image_info() function. Such numbers are also returned directly when you load an add-on image through the load_add_on() function.
RETURN CODES
B_OK. The symbol was found.
|
load_add_on() loads an add-on image, identified by pathname, into your application's address space.
An example that demonstrates the use of load_add_on() is given in "Loading an Add-on Image."
You can load the same add-on image twice; each time you load the add-on a new, unique image_id is created and returned.
unload_add_on() removes the add-on image identified by the argument. The image's symbols are removed, and the memory that they represent is freed. If the argument doesn't identify a valid image, the function returns B_ERROR. Otherwise, it returns B_OK.
RETURN CODES
Positive image_id value (load) or B_OK (unload). Success.
|
Loads an app image into the system (it doesn't load the image into the caller's address space), creates a separate team for the new application, and spawns and returns the ID of the team's main thread. The image is identified by the pathname given in argv[0].
The arguments are passed to the image's main() function (they show up there as the function's similarly named arguments):
extern char **environ; load_image(..., environ);
The argv and envp arrays are copied into the new thread's address space. If you allocated either of these arrays, it's safe to free them immediately after load_image() returns.
The thread that's returned by load_image() is in a suspended state. To start the thread running, you pass the thread_id to resume_thread() or wait_for_thread().
An example that demonstrates the use of load_image() is given in "Loading an App Image."
RETURN CODES
. Success.
The Kernel Kit Table of Contents | The Kernel Kit Index |
Copyright © 2000 Be, Inc. All rights reserved..