<!--
 Copyright (c) 2019 Emilian Roman
 
 This software is provided 'as-is', without any express or implied
 warranty. In no event will the authors be held liable for any damages
 arising from the use of this software.
 
 Permission is granted to anyone to use this software for any purpose,
 including commercial applications, and to alter it and redistribute it
 freely, subject to the following restrictions:
 
 1. The origin of this software must not be misrepresented; you must not
    claim that you wrote the original software. If you use this software
    in a product, an acknowledgment in the product documentation would be
    appreciated but is not required.
 2. Altered source versions must be plainly marked as such, and must not be
    misrepresented as being the original software.
 3. This notice may not be removed or altered from any source distribution.
-->

LASTPROF.TXT FILE
=================

The lastprof.txt file stores the path of the last used profile in HCE.
Given the predictable nature of its contents, combined with its static
location, the lastprof.txt is the perfect candidate for permitting
profile auto-detection.

Versions prior to SPV3.2 relied on the end-user to manually specify
their HCE profile name into the launcher. Version 3.2 eliminates that
requirement in favour of the aforementioned auto-detection.

ANALYSIS
--------

The following hex dump is that of a typical lastprof.txt file.

    00000000: 443a 5c4d 6972 6973 5c44 6f63 756d 656e  D:\Miris\Documen
    00000010: 7473 5c4d 7920 4761 6d65 735c 4861 6c6f  ts\My Games\Halo
    00000020: 2043 455c 7361 7665 6761 6d65 735c 4e65   CE\savegames\Ne
    00000030: 7730 3031 5c00 6c61 6d2e 7361 7600 0000  w001\.lam.sav...
    00000040: 0000 0000 0000 0000 0000 0000 0000 0000  ................
    00000050: 0000 0000 0000 0000 0000 0000 0000 0000  ................
    00000060: 0000 0000 0000 0000 0000 0000 0000 0000  ................
    00000070: 0000 0000 0000 0000 0000 0000 0000 0000  ................
    00000080: 0000 0000 0000 0000 0000 0000 0000 0000  ................
    00000090: 0000 0000 0000 0000 0000 0000 0000 0000  ................
    000000a0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
    000000b0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
    000000c0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
    000000d0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
    000000e0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
    000000f0: 0000 0000 0000 0000 0000 0000 0000 0000  ................

From its contents, we can infer the following facts:

-   the string represents the directory path of the last used profile;
-   the length is always 256 bytes, through the use of whitespace
    padding;
-   the `\ lam.sav` string at the end is the only constant in the file.

VALIDATION
----------

Considering that the `\ lam.sav` string is a constant in each
lastprof.txt file, we can use it as a "signature": if the string isn't
present in the given file, then the file is not a valid lastprof.txt
file.

DETECTION
---------

Given that the paths members are separated with `\`, we can use the
symbol as a delimiter when splitting the string into an array.

The `\ lam.sav` string will always contain the profile name before it,
thereby allowing us to conclude that the profile name will always be the
second-last member of a string array that's delimited by `\`.
