<trclass="memdesc:a89fd9c08d2644ffb4331e33a09e80b67"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Reads the segment load command from another process. <ahref="#a89fd9c08d2644ffb4331e33a09e80b67">More...</a><br/></td></tr>
<trclass="memdesc:a4c31878c0cac883d27bf212c9a616385"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Returns the segment’s name. <ahref="#a4c31878c0cac883d27bf212c9a616385">More...</a><br/></td></tr>
<trclass="memdesc:aa801e05da01e40484e0fcc08b861282d"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Returns the segment’s size as mapped into memory. <ahref="#aa801e05da01e40484e0fcc08b861282d">More...</a><br/></td></tr>
<trclass="memdesc:ab3b139fd095a7187294f05d0780af81c"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Returns the file offset of the mapped segment in the file from which it was mapped. <ahref="#ab3b139fd095a7187294f05d0780af81c">More...</a><br/></td></tr>
<trclass="memdesc:af5ec4fad5cedad192ba8ca92728dd928"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Returns the number of sections in the segment. <ahref="#af5ec4fad5cedad192ba8ca92728dd928">More...</a><br/></td></tr>
<trclass="memdesc:a2f2f06905518f693178e52ee14c57e9e"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Obtain section information by section name. <ahref="#a2f2f06905518f693178e52ee14c57e9e">More...</a><br/></td></tr>
<trclass="memdesc:a370e8711294ba506de99e093ac879357"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Obtain section information by section index. <ahref="#a370e8711294ba506de99e093ac879357">More...</a><br/></td></tr>
<trclass="memdesc:ad00d9acfb6f78cd0c5e640d667e8b746"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Returns a segment name string. <ahref="#ad00d9acfb6f78cd0c5e640d667e8b746">More...</a><br/></td></tr>
<trclass="memdesc:ad9357dc5d34a7f09219f6e850694014b"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Returns a section name string. <ahref="#ad9357dc5d34a7f09219f6e850694014b">More...</a><br/></td></tr>
<trclass="memdesc:a3f607c8cc16a960a6638bf4b91965397"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Returns a segment and section name string. <ahref="#a3f607c8cc16a960a6638bf4b91965397">More...</a><br/></td></tr>
<divclass="textblock"><p>A reader for <code>LC_SEGMENT</code> or <code>LC_SEGMENT_64</code> load commands in Mach-O images mapped into another process. </p>
<p>This class is capable of reading both <code>LC_SEGMENT</code> and <code>LC_SEGMENT_64</code> based on the bitness of the remote process.</p>
<p>A <aclass="el"href="classcrashpad_1_1MachOImageSegmentReader.html"title="A reader for LC_SEGMENT or LC_SEGMENT_64 load commands in Mach-O images mapped into another process...">MachOImageSegmentReader</a> will normally be instantiated by a <aclass="el"href="classcrashpad_1_1MachOImageReader.html"title="A reader for Mach-O images mapped into another process. ">MachOImageReader</a>. </p>
</div><h2class="groupheader">Member Function Documentation</h2>
<dlclass="section note"><dt>Note</dt><dd>For the segment’s preferred load address, not adjusted for slide, use <aclass="el"href="classcrashpad_1_1MachOImageSegmentReader.html#a6cbf169de4e86aed8fc7d3f00ddcf302"title="The segment’s preferred load address. ">vmaddr()</a>. </dd></dl>
<p>Returns the file offset of the mapped segment in the file from which it was mapped. </p>
<p>The file offset is the difference between the beginning of the <code>mach_header</code> or <code>mach_header_64</code> and the beginning of the segment’s mapped region. For segments that are not mapped from a file (such as <code>__PAGEZERO</code> segments), this will be <code>0</code>. </p>
<tr><tdclass="paramdir">[in]</td><tdclass="paramname">index</td><td>The index of the section to return, in the order that it appears in the segment load command. Unlike <aclass="el"href="classcrashpad_1_1MachOImageReader.html#ac9a2388f42c8d4c5c01ca007e93079fc"title="Obtain section information by section index. ">MachOImageReader::GetSectionAtIndex()</a>, this is a 0-based index. This parameter must be in the range of valid indices aas reported by <aclass="el"href="classcrashpad_1_1MachOImageSegmentReader.html#af5ec4fad5cedad192ba8ca92728dd928"title="Returns the number of sections in the segment. ">nsects()</a>. </td></tr>
<tr><tdclass="paramdir">[out]</td><tdclass="paramname">address</td><td>The actual address that the section was loaded at in memory, taking any “slide” into account if the section did not load at its preferred address as stored in the Mach-O image file. This parameter can be <code>nullptr</code>.</td></tr>
</table>
</dd>
</dl>
<dlclass="section return"><dt>Returns</dt><dd>A pointer to the section information. If <em>index</em> is out of range, execution is aborted. The caller does not take ownership; the lifetime of the returned object is scoped to the lifetime of this <aclass="el"href="classcrashpad_1_1MachOImageSegmentReader.html"title="A reader for LC_SEGMENT or LC_SEGMENT_64 load commands in Mach-O images mapped into another process...">MachOImageSegmentReader</a> object.</dd></dl>
<dlclass="section note"><dt>Note</dt><dd>The process_types::section::addr field gives the section’s preferred load address as stored in the Mach-O image file, and is not adjusted for any “slide” that may have occurred when the image was loaded. </dd>
Unlike <aclass="el"href="classcrashpad_1_1MachOImageReader.html#ac9a2388f42c8d4c5c01ca007e93079fc"title="Obtain section information by section index. ">MachOImageReader::GetSectionAtIndex()</a>, this method does not accept out-of-range values for <em>index</em>, and aborts execution instead of returning <code>nullptr</code> upon encountering an out-of-range value. This is because this method is expected to be used in a loop that can be limited to <aclass="el"href="classcrashpad_1_1MachOImageSegmentReader.html#af5ec4fad5cedad192ba8ca92728dd928"title="Returns the number of sections in the segment. ">nsects()</a> iterations, so an out-of-range error can be treated more harshly as a logic error, as opposed to a data error.</dd></dl>
<dlclass="section see"><dt>See also</dt><dd><aclass="el"href="classcrashpad_1_1MachOImageReader.html#ac9a2388f42c8d4c5c01ca007e93079fc"title="Obtain section information by section index. ">MachOImageReader::GetSectionAtIndex()</a></dd></dl>
<p>Obtain section information by section name. </p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramdir">[in]</td><tdclass="paramname">section_name</td><td>The name of the section to search for, without the leading segment name. For example, use <code>"__text"</code>, not <code>"__TEXT,__text"</code> or <code>"__TEXT.__text"</code>. </td></tr>
<tr><tdclass="paramdir">[out]</td><tdclass="paramname">address</td><td>The actual address that the section was loaded at in memory, taking any “slide” into account if the section did not load at its preferred address as stored in the Mach-O image file. This parameter can be <code>nullptr</code>.</td></tr>
</table>
</dd>
</dl>
<dlclass="section return"><dt>Returns</dt><dd>A pointer to the section information if it was found, or <code>nullptr</code> if it was not found. The caller does not take ownership; the lifetime of the returned object is scoped to the lifetime of this <aclass="el"href="classcrashpad_1_1MachOImageSegmentReader.html"title="A reader for LC_SEGMENT or LC_SEGMENT_64 load commands in Mach-O images mapped into another process...">MachOImageSegmentReader</a> object.</dd></dl>
<dlclass="section note"><dt>Note</dt><dd>The process_types::section::addr field gives the section’s preferred load address as stored in the Mach-O image file, and is not adjusted for any “slide” that may have occurred when the image was loaded.</dd></dl>
<dlclass="section see"><dt>See also</dt><dd><aclass="el"href="classcrashpad_1_1MachOImageReader.html#a1917ca481052f1d2de7163cb6f8701cc"title="Obtain section information by segment and section name. ">MachOImageReader::GetSectionByName()</a></dd></dl>
<p>Reads the segment load command from another process. </p>
<p>This method must only be called once on an object. This method must be called successfully before any other method in this class may be called.</p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramdir">[in]</td><tdclass="paramname">process_reader</td><td>The reader for the remote process. </td></tr>
<tr><tdclass="paramdir">[in]</td><tdclass="paramname">load_command_address</td><td>The address, in the remote process’ address space, where the <code>LC_SEGMENT</code> or <code>LC_SEGMENT_64</code> load command to be read is located. This address is determined by a Mach-O image reader, such as <aclass="el"href="classcrashpad_1_1MachOImageReader.html"title="A reader for Mach-O images mapped into another process. ">MachOImageReader</a>, as it walks Mach-O load commands. </td></tr>
<tr><tdclass="paramdir">[in]</td><tdclass="paramname">load_command_info</td><td>A string to be used in logged messages. This string is for diagnostic purposes only, and may be empty. </td></tr>
<tr><tdclass="paramdir">[in]</td><tdclass="paramname">module_name</td><td>The path used to load the module. This string is used to relax otherwise strict parsing rules for common modules with known defects. </td></tr>
<tr><tdclass="paramdir">[in]</td><tdclass="paramname">file_type</td><td>The module’s Mach-O file type. This is used to relax otherwise strict parsing rules for common modules with known defects.</td></tr>
</table>
</dd>
</dl>
<dlclass="section return"><dt>Returns</dt><dd><code>true</code> if the load command was read successfully. <code>false</code> otherwise, with an appropriate message logged. </dd></dl>
<p>The segment’s name is taken from the load command’s <code>segname</code> field. Common segment names are <code>"__TEXT"</code>, <code>"__DATA"</code>, and <code>"__LINKEDIT"</code>. Symbolic constants for these common names are defined in <code><mach-o/loader.h></code>. </p>
<p>Returns the number of sections in the segment. </p>
<p>This will return <code>0</code> for a segment without any sections, typical for <code>__PAGEZERO</code> and <code>__LINKEDIT</code> segments.</p>
<p>Although the Mach-O file format uses a <code>uint32_t</code> for this field, there is an overall limit of 255 sections in an entire Mach-O image file (not just in a single segment) imposed by the symbol table format. Symbols will not be able to reference anything in a section beyond the first 255 in a Mach-O image file. </p>
<p>Section names may be 16 characters long, and are not necessarily <code>NUL</code>-terminated. This function will return a section name based on up to the first 16 characters found at <em>section_name_c</em>. </p>
<p>Returns a segment and section name string. </p>
<p>A segment and section name string is composed of a segment name string (see <aclass="el"href="classcrashpad_1_1MachOImageSegmentReader.html#ad00d9acfb6f78cd0c5e640d667e8b746"title="Returns a segment name string. ">SegmentNameString()</a>) and a section name string (see <aclass="el"href="classcrashpad_1_1MachOImageSegmentReader.html#ad9357dc5d34a7f09219f6e850694014b"title="Returns a section name string. ">SectionNameString()</a>) separated by a comma. An example is <code>"__TEXT,__text"</code>. </p>
<p>Segment names may be 16 characters long, and are not necessarily <code>NUL</code>-terminated. This function will return a segment name based on up to the first 16 characters found at <em>segment_name_c</em>. </p>
<p>Most segments slide, but the <code>__PAGEZERO</code> segment does not, it grows instead. This method identifies non-sliding segments in the same way that the kernel does. </p>
<p>This method must only be called once on an object, after <aclass="el"href="classcrashpad_1_1MachOImageSegmentReader.html#a89fd9c08d2644ffb4331e33a09e80b67"title="Reads the segment load command from another process. ">Initialize()</a> is called successfully. It must be called before <aclass="el"href="classcrashpad_1_1MachOImageSegmentReader.html#a873ee4e1206c53ba15faa3fcae684d2e">Address()</a>, <aclass="el"href="classcrashpad_1_1MachOImageSegmentReader.html#a0d1d9a429f5f3ef9bc8cff02f90c3374">Size()</a>, <aclass="el"href="classcrashpad_1_1MachOImageSegmentReader.html#a2f2f06905518f693178e52ee14c57e9e"title="Obtain section information by section name. ">GetSectionByName()</a>, or <aclass="el"href="classcrashpad_1_1MachOImageSegmentReader.html#a370e8711294ba506de99e093ac879357"title="Obtain section information by section index. ">GetSectionAtIndex()</a> can be called.</p>
<p>This method is provided because slide is a property of the image that cannot be determined until at least some segments have been read. As such, it is not necessarily known at the time that <aclass="el"href="classcrashpad_1_1MachOImageSegmentReader.html#a89fd9c08d2644ffb4331e33a09e80b67"title="Reads the segment load command from another process. ">Initialize()</a> is called. </p>
<dlclass="section return"><dt>Returns</dt><dd>The segment’s actual size address in memory, adjusted for any growth in the case of a nonsliding segment.</dd></dl>
<dlclass="section note"><dt>Note</dt><dd>For the segment’s preferred size, not adjusted for growth, use <aclass="el"href="classcrashpad_1_1MachOImageSegmentReader.html#aa801e05da01e40484e0fcc08b861282d"title="Returns the segment’s size as mapped into memory. ">vmsize()</a>. </dd></dl>
<dlclass="section note"><dt>Note</dt><dd>This value is not adjusted for any “slide” that may have occurred when the image was loaded. Use <aclass="el"href="classcrashpad_1_1MachOImageSegmentReader.html#a873ee4e1206c53ba15faa3fcae684d2e">Address()</a> for a value adjusted for slide.</dd></dl>
<dlclass="section see"><dt>See also</dt><dd><aclass="el"href="classcrashpad_1_1MachOImageReader.html#a687d6ad610407967e283d8ba8b6e2db4"title="Obtain segment information by segment name. ">MachOImageReader::GetSegmentByName()</a></dd></dl>
<dlclass="section note"><dt>Note</dt><dd>For non-sliding segments, this value is not adjusted for any growth that may have occurred when the image was loaded. Use <aclass="el"href="classcrashpad_1_1MachOImageSegmentReader.html#a0d1d9a429f5f3ef9bc8cff02f90c3374">Size()</a> for a value adjusted for growth. </dd></dl>