Files
libaaruformat/docs/html/lfg_8h.html

345 lines
19 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.16.1"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>libaaruformat: src/ngcw/lfg.h File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<script type="text/javascript" src="clipboard.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript" src="cookie.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr id="projectrow">
<td id="projectalign">
<div id="projectname">libaaruformat<span id="projectnumber">&#160;1.0</span>
</div>
<div id="projectbrief">Aaru Data Preservation Suite - Format Library</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.16.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search/",'.html');
</script>
<script type="text/javascript">
$(function() { codefold.init(); });
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
initMenu('',true,false,'search.php','Search',true);
$(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
$(function(){initNavTree('lfg_8h.html','',''); });
</script>
<div id="container">
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>
<div class="header">
<div class="headertitle"><div class="title">lfg.h File Reference</div></div>
</div><!--header-->
<div class="contents">
<div class="textblock"><code>#include &lt;stdbool.h&gt;</code><br />
<code>#include &lt;stddef.h&gt;</code><br />
<code>#include &lt;stdint.h&gt;</code><br />
</div>
<p><a href="lfg_8h_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 id="header-nested-classes" class="groupheader"><a id="nested-classes" name="nested-classes"></a>
Data Structures</h2></td></tr>
<tr class="memitem:ngc_5Flfg_5Fctx" id="r_ngc_5Flfg_5Fctx"><td class="memItemLeft">struct &#160;</td><td class="memItemRight"><a class="el" href="structngc__lfg__ctx.html">ngc_lfg_ctx</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">LFG context holding the 521-word circular buffer and byte position. <a href="structngc__lfg__ctx.html#details">More...</a><br /></td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 id="header-define-members" class="groupheader"><a id="define-members" name="define-members"></a>
Macros</h2></td></tr>
<tr class="memitem:a16edb4e9c0a519cb423979b38d8f132a" id="r_a16edb4e9c0a519cb423979b38d8f132a"><td class="memItemLeft">#define&#160;</td><td class="memItemRight"><a class="el" href="#a16edb4e9c0a519cb423979b38d8f132a">NGC_LFG_K</a>&#160;&#160;&#160;521</td></tr>
<tr class="memdesc:a16edb4e9c0a519cb423979b38d8f132a"><td class="mdescLeft">&#160;</td><td class="mdescRight">LFG buffer size (number of uint32 words in state). <br /></td></tr>
<tr class="memitem:a865dc66e4ab8ae46527b88c2c119807a" id="r_a865dc66e4ab8ae46527b88c2c119807a"><td class="memItemLeft">#define&#160;</td><td class="memItemRight"><a class="el" href="#a865dc66e4ab8ae46527b88c2c119807a">NGC_LFG_J</a>&#160;&#160;&#160;32</td></tr>
<tr class="memdesc:a865dc66e4ab8ae46527b88c2c119807a"><td class="mdescLeft">&#160;</td><td class="mdescRight">LFG second tap. <br /></td></tr>
<tr class="memitem:a2c4db3d8d295f706dcacc8a4d039beed" id="r_a2c4db3d8d295f706dcacc8a4d039beed"><td class="memItemLeft">#define&#160;</td><td class="memItemRight"><a class="el" href="#a2c4db3d8d295f706dcacc8a4d039beed">NGC_LFG_SEED_SIZE</a>&#160;&#160;&#160;17</td></tr>
<tr class="memdesc:a2c4db3d8d295f706dcacc8a4d039beed"><td class="mdescLeft">&#160;</td><td class="mdescRight">Number of uint32 words needed to seed the LFG. <br /></td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 id="header-func-members" class="groupheader"><a id="func-members" name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:abc583da3bb66cab3eafc3496bc46e193" id="r_abc583da3bb66cab3eafc3496bc46e193"><td class="memItemLeft">void&#160;</td><td class="memItemRight"><a class="el" href="#abc583da3bb66cab3eafc3496bc46e193">ngc_lfg_set_seed</a> (struct <a class="el" href="structngc__lfg__ctx.html">ngc_lfg_ctx</a> *ctx, const uint32_t seed[17])</td></tr>
<tr class="memdesc:abc583da3bb66cab3eafc3496bc46e193"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initialize the LFG from a 17-word big-endian seed. <br /></td></tr>
<tr class="memitem:a25e6df5ee051a324d943185f193d3418" id="r_a25e6df5ee051a324d943185f193d3418"><td class="memItemLeft">void&#160;</td><td class="memItemRight"><a class="el" href="#a25e6df5ee051a324d943185f193d3418">ngc_lfg_get_bytes</a> (struct <a class="el" href="structngc__lfg__ctx.html">ngc_lfg_ctx</a> *ctx, uint8_t *out, size_t count)</td></tr>
<tr class="memdesc:a25e6df5ee051a324d943185f193d3418"><td class="mdescLeft">&#160;</td><td class="mdescRight">Generate count bytes of junk data into out. <br /></td></tr>
<tr class="memitem:aef1434f019902caf30f1d4fe577267ba" id="r_aef1434f019902caf30f1d4fe577267ba"><td class="memItemLeft">size_t&#160;</td><td class="memItemRight"><a class="el" href="#aef1434f019902caf30f1d4fe577267ba">ngc_lfg_get_seed</a> (const uint8_t *data, size_t size, size_t data_offset, uint32_t seed_out[17])</td></tr>
<tr class="memdesc:aef1434f019902caf30f1d4fe577267ba"><td class="mdescLeft">&#160;</td><td class="mdescRight">Try to extract the LFG seed from a chunk of data. <br /></td></tr>
</table>
<a name="doc-define-members" id="doc-define-members"></a><h2 id="header-doc-define-members" class="groupheader">Macro Definition Documentation</h2>
<a id="a865dc66e4ab8ae46527b88c2c119807a" name="a865dc66e4ab8ae46527b88c2c119807a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a865dc66e4ab8ae46527b88c2c119807a">&#9670;&#160;</a></span>NGC_LFG_J</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define NGC_LFG_J&#160;&#160;&#160;32</td>
</tr>
</table>
</div><div class="memdoc">
<p>LFG second tap. </p>
<p class="definition">Definition at line <a class="el" href="lfg_8h_source.html#l00035">35</a> of file <a class="el" href="lfg_8h_source.html">lfg.h</a>.</p>
<p class="reference">Referenced by <a class="el" href="lfg_8c_source.html#l00036">lfg_backward()</a>, and <a class="el" href="lfg_8c_source.html#l00029">lfg_forward()</a>.</p>
</div>
</div>
<a id="a16edb4e9c0a519cb423979b38d8f132a" name="a16edb4e9c0a519cb423979b38d8f132a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a16edb4e9c0a519cb423979b38d8f132a">&#9670;&#160;</a></span>NGC_LFG_K</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define NGC_LFG_K&#160;&#160;&#160;521</td>
</tr>
</table>
</div><div class="memdoc">
<p>LFG buffer size (number of uint32 words in state). </p>
<p class="definition">Definition at line <a class="el" href="lfg_8h_source.html#l00034">34</a> of file <a class="el" href="lfg_8h_source.html">lfg.h</a>.</p>
<p class="reference">Referenced by <a class="el" href="lfg_8c_source.html#l00036">lfg_backward()</a>, <a class="el" href="lfg_8c_source.html#l00029">lfg_forward()</a>, <a class="el" href="lfg_8c_source.html#l00048">lfg_initialize()</a>, <a class="el" href="lfg_8c_source.html#l00103">lfg_reinitialize()</a>, <a class="el" href="lfg_8c_source.html#l00082">ngc_lfg_get_bytes()</a>, and <a class="el" href="lfg_8c_source.html#l00121">ngc_lfg_get_seed()</a>.</p>
</div>
</div>
<a id="a2c4db3d8d295f706dcacc8a4d039beed" name="a2c4db3d8d295f706dcacc8a4d039beed"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a2c4db3d8d295f706dcacc8a4d039beed">&#9670;&#160;</a></span>NGC_LFG_SEED_SIZE</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define NGC_LFG_SEED_SIZE&#160;&#160;&#160;17</td>
</tr>
</table>
</div><div class="memdoc">
<p>Number of uint32 words needed to seed the LFG. </p>
<p class="definition">Definition at line <a class="el" href="lfg_8h_source.html#l00036">36</a> of file <a class="el" href="lfg_8h_source.html">lfg.h</a>.</p>
<p class="reference">Referenced by <a class="el" href="lfg_8c_source.html#l00048">lfg_initialize()</a>, <a class="el" href="lfg_8c_source.html#l00103">lfg_reinitialize()</a>, <a class="el" href="lfg_8c_source.html#l00121">ngc_lfg_get_seed()</a>, <a class="el" href="lfg_8c_source.html#l00073">ngc_lfg_set_seed()</a>, <a class="el" href="ngcw__junk_8c_source.html#l00104">ngcw_deserialize_junk_map()</a>, <a class="el" href="ngcw__junk_8c_source.html#l00154">ngcw_regenerate_junk_sector()</a>, <a class="el" href="ngcw__junk_8c_source.html#l00075">ngcw_serialize_junk_map()</a>, and <a class="el" href="read_8c_source.html#l00044">wii_reconstruct_group_junk()</a>.</p>
</div>
</div>
<a name="doc-func-members" id="doc-func-members"></a><h2 id="header-doc-func-members" class="groupheader">Function Documentation</h2>
<a id="a25e6df5ee051a324d943185f193d3418" name="a25e6df5ee051a324d943185f193d3418"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a25e6df5ee051a324d943185f193d3418">&#9670;&#160;</a></span>ngc_lfg_get_bytes()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void ngc_lfg_get_bytes </td>
<td>(</td>
<td class="paramtype">struct <a class="el" href="structngc__lfg__ctx.html">ngc_lfg_ctx</a> *</td> <td class="paramname"><span class="paramname"><em>ctx</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint8_t *</td> <td class="paramname"><span class="paramname"><em>out</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">size_t</td> <td class="paramname"><span class="paramname"><em>count</em></span>&#160;)</td>
</tr>
</table>
</div><div class="memdoc">
<p>Generate count bytes of junk data into out. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">ctx</td><td>LFG context (must be initialized via ngc_lfg_set_seed). </td></tr>
<tr><td class="paramname">out</td><td>Output buffer to fill. </td></tr>
<tr><td class="paramname">count</td><td>Number of bytes to generate. </td></tr>
</table>
</dd>
</dl>
<p>&lt; LFG buffer size (number of uint32 words in state).</p>
<p>&lt; LFG buffer size (number of uint32 words in state).</p>
<p class="definition">Definition at line <a class="el" href="lfg_8c_source.html#l00082">82</a> of file <a class="el" href="lfg_8c_source.html">lfg.c</a>.</p>
<p class="reference">References <a class="el" href="lfg_8h_source.html#l00043">ngc_lfg_ctx::buffer</a>, <a class="el" href="lfg_8c_source.html#l00029">lfg_forward()</a>, <a class="el" href="lfg_8h_source.html#l00034">NGC_LFG_K</a>, and <a class="el" href="lfg_8h_source.html#l00044">ngc_lfg_ctx::position_bytes</a>.</p>
<p class="reference">Referenced by <a class="el" href="ngcw__junk_8c_source.html#l00154">ngcw_regenerate_junk_sector()</a>, and <a class="el" href="read_8c_source.html#l00044">wii_reconstruct_group_junk()</a>.</p>
</div>
</div>
<a id="aef1434f019902caf30f1d4fe577267ba" name="aef1434f019902caf30f1d4fe577267ba"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aef1434f019902caf30f1d4fe577267ba">&#9670;&#160;</a></span>ngc_lfg_get_seed()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">size_t ngc_lfg_get_seed </td>
<td>(</td>
<td class="paramtype">const uint8_t *</td> <td class="paramname"><span class="paramname"><em>data</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">size_t</td> <td class="paramname"><span class="paramname"><em>size</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">size_t</td> <td class="paramname"><span class="paramname"><em>data_offset</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint32_t</td> <td class="paramname"><span class="paramname"><em>seed_out</em></span>[17]&#160;)</td>
</tr>
</table>
</div><div class="memdoc">
<p>Try to extract the LFG seed from a chunk of data. </p>
<p>Attempts to reverse-engineer the 17-word seed from a buffer of suspected PRNG output. Requires at least NGC_LFG_K * 4 = 2084 bytes of contiguous PRNG output aligned to uint32 boundaries.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">data</td><td>Pointer to the data to test. </td></tr>
<tr><td class="paramname">size</td><td>Number of bytes available. </td></tr>
<tr><td class="paramname">data_offset</td><td>Byte offset of data[0] within its LFG block (0x8000-aligned for Wii, arbitrary for GC). </td></tr>
<tr><td class="paramname">seed_out</td><td>If successful, receives the 17-word seed (big-endian).</td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The number of consecutive bytes from data[0] that match the LFG. Returns 0 if the data does not look like junk. </dd></dl>
<p>&lt; LFG buffer size (number of uint32 words in state).</p>
<p>&lt; LFG buffer size (number of uint32 words in state).</p>
<p>&lt; LFG buffer size (number of uint32 words in state).</p>
<p>&lt; LFG buffer size (number of uint32 words in state).</p>
<p>&lt; LFG buffer size (number of uint32 words in state).</p>
<p>&lt; LFG buffer size (number of uint32 words in state).</p>
<p>&lt; LFG buffer size (number of uint32 words in state).</p>
<p>&lt; LFG buffer size (number of uint32 words in state).</p>
<p>&lt; LFG buffer size (number of uint32 words in state).</p>
<p>&lt; LFG buffer size (number of uint32 words in state).</p>
<p>&lt; LFG buffer size (number of uint32 words in state).</p>
<p class="definition">Definition at line <a class="el" href="lfg_8c_source.html#l00121">121</a> of file <a class="el" href="lfg_8c_source.html">lfg.c</a>.</p>
<p class="reference">References <a class="el" href="lfg_8h_source.html#l00043">ngc_lfg_ctx::buffer</a>, <a class="el" href="lfg_8c_source.html#l00036">lfg_backward()</a>, <a class="el" href="lfg_8c_source.html#l00029">lfg_forward()</a>, <a class="el" href="lfg_8c_source.html#l00103">lfg_reinitialize()</a>, <a class="el" href="lfg_8h_source.html#l00034">NGC_LFG_K</a>, <a class="el" href="lfg_8h_source.html#l00036">NGC_LFG_SEED_SIZE</a>, <a class="el" href="lfg_8h_source.html#l00044">ngc_lfg_ctx::position_bytes</a>, and <a class="el" href="lfg_8c_source.html#l00026">swap32()</a>.</p>
</div>
</div>
<a id="abc583da3bb66cab3eafc3496bc46e193" name="abc583da3bb66cab3eafc3496bc46e193"></a>
<h2 class="memtitle"><span class="permalink"><a href="#abc583da3bb66cab3eafc3496bc46e193">&#9670;&#160;</a></span>ngc_lfg_set_seed()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void ngc_lfg_set_seed </td>
<td>(</td>
<td class="paramtype">struct <a class="el" href="structngc__lfg__ctx.html">ngc_lfg_ctx</a> *</td> <td class="paramname"><span class="paramname"><em>ctx</em></span>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const uint32_t</td> <td class="paramname"><span class="paramname"><em>seed</em></span>[17]&#160;)</td>
</tr>
</table>
</div><div class="memdoc">
<p>Initialize the LFG from a 17-word big-endian seed. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">ctx</td><td>LFG context to initialize. </td></tr>
<tr><td class="paramname">seed</td><td>Array of 17 uint32 seed words (big-endian). </td></tr>
</table>
</dd>
</dl>
<p>&lt; Number of uint32 words needed to seed the LFG.</p>
<p class="definition">Definition at line <a class="el" href="lfg_8c_source.html#l00073">73</a> of file <a class="el" href="lfg_8c_source.html">lfg.c</a>.</p>
<p class="reference">References <a class="el" href="lfg_8h_source.html#l00043">ngc_lfg_ctx::buffer</a>, <a class="el" href="lfg_8c_source.html#l00048">lfg_initialize()</a>, <a class="el" href="lfg_8h_source.html#l00036">NGC_LFG_SEED_SIZE</a>, <a class="el" href="lfg_8h_source.html#l00044">ngc_lfg_ctx::position_bytes</a>, and <a class="el" href="lfg_8c_source.html#l00026">swap32()</a>.</p>
<p class="reference">Referenced by <a class="el" href="ngcw__junk_8c_source.html#l00154">ngcw_regenerate_junk_sector()</a>, and <a class="el" href="read_8c_source.html#l00044">wii_reconstruct_group_junk()</a>.</p>
</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<div id="page-nav" class="page-nav-panel">
<div id="page-nav-resize-handle"></div>
<div id="page-nav-tree">
<div id="page-nav-contents">
</div><!-- page-nav-contents -->
</div><!-- page-nav-tree -->
</div><!-- page-nav -->
</div><!-- container -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li><li class="navelem"><a href="dir_366d6a3889b2c1ca7d50351540a67e4b.html">ngcw</a></li><li class="navelem"><a href="lfg_8h.html">lfg.h</a></li>
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.16.1 </li>
</ul>
</div>
</body>
</html>