|
NAMEcrackhdr, uncrackhdr, mapfile, unmapfile, mapproc, unmapproc, detachproc, ctlproc, procnotes - machine-independent access to exectuable files and running processesSYNOPSIS#include <u.h>#include <libc.h> #include <mach.h> int crackhdr(int fd, Fhdr *hdr)
int mapfile(Fhdr *hdr, ulong base, Map *map, Regs **regs)
DESCRIPTIONThese functions parse executable files and provide access to those files and to running processes.Crackhdr opens and parses the named executable file. The returned data structure hdr is initialized with a machine-independent description of the header information. The following fields are the most commonly used:
Mapfile adds the segments found in hdr to map. If hdr is an executable file, there are typically three segments: text, data, and a zero-backed bss. If hdr is a dynamic shared library, its segments are relocated by base before being mapping. If hdr is a core file, there is one segment named core for each contiguous section of memory recorded in the core file. There are often quite a few of these, as most operating systems omit clean memory pages when writing core files (Mac OS X is the only exception among the supported systems). Because core files have such holes, it is typically necessary to construct the core map by calling mapfile on the executable and then calling it again on the core file. Newly-added segments are mapped on top of existing segments, so this arrangement will use the core file for the segments it contains but fall back to the executable for the rest. Unmapfile removes the mappings in map corresponding to hdr. Mapproc attaches to a running program and adds its segments to the given map. It adds one segment for each contiguous section of mapped memory. On systems where this information cannot be determined, it adds a single segment covering the entire address space. Accessing areas of this segment that are actually not mapped in the process address space will cause the get/put routines to return errors. Unmapproc removes the mappings in map corresponding to pid. Detachproc detaches from all previously attached processes. Ctlproc manipulates the process with id pid according to the message msg. Valid messages include:
Procnotes fills *notes with a pointer to an array of strings representing pending notes waiting for the process. (On Unix, these notes are textual descriptions of any pending signals.) Procnotes returns the number of pending notes. The memory at *notes should be freed via free (see when no longer needed. SOURCE/src/libmachSEE ALSO Visit the GSP FreeBSD Man Page Interface. |