CacheParser¶
CacheParser as the name implies is a record made to parse information from certain files that are part of the game cache.
preferences.dat is where most client settings are stored.
preferences2.dat I have no idea? some values in address 00000020 seem to change after some times has passed randomly. (related to 6h log maybe!?!?)
random.dat in the user home directory seems to be a random identifier generated the first time you open a client if it doesn’t exist. while it exists, it seems to never change unless the user deletes it.
Note
For more information check this file: https://github.com/open-osrs/runelite/blob/dd4478eff7d90fcb3e85584171d5836809eb150a/runescape-client/src/main/java/ClientPreferences.java
TCacheParser¶
Type responsible for handling cache parsing.
CacheParser.Setup¶
procedure TCacheParser.Setup();
Internal method responsible for setting up the TCacheParser.
This is automatically called for you on the CacheParser variable.
Preferences¶
This section is about reading the game preferences that get cached. There’s 2 preferences files:
preferences.datpreferences2.dat
The second file is actually not used for anything at the moment but the first one specifically has a lot of useful client information, things such as:
Brightness level
Roofs state
Window mode (fixed or resizable)
Sound volumes
…
All this information is stored in binary, but with the following methods you can read it easily and this is very useful because you can do things like:
Check brightness level without opening the options gametab nor the display tab.
Know if the roofs are hidden, this is something that can break scripts big time and is notoriously hard to know with color alone.
CacheParser.ReadPreference¶
function TCacheParser.ReadPreference(pref: Integer = 1): TByteArray;
Internal method to returns the bytes of the preferences file. Returns the bytes of the preferences file which can only be 1 or 2. It’s also useful for debugging
Example:
WriteLn CacheParser.ReadPreference(1);
CacheParser.CountOptions¶
function TCacheParser.CountOptions(bytes: TByteArray = []): Integer;
Returns the number of options saved in the cache. Only used for debugging, you probably don’t need this at all.
This is not very useful, AFAIK there’s only 2 possible values for this: 0 and 11. 0 is only if you haven’t accepted the EULA in the client.
Example:
WriteLn CacheParser.CountOptions();
CacheParser.LoginMusicDisabled¶
function TCacheParser.LoginMusicDisabled(bytes: TByteArray = []): Boolean;
Checks if the music is enabled on the login screen.
Example:
WriteLn CacheParser.LoginMusicDisabled();
CacheParser.WindowMode¶
function TCacheParser.WindowMode(bytes: TByteArray = []): Integer;
Returns 1 for fixed mode and 2 for resizable mode. Resizable modern and resizable classic make no difference here.
Example:
WriteLn CacheParser.WindowMode();
CacheParser.CountAuthenticators¶
function TCacheParser.CountAuthenticators(bytes: TByteArray = []): Integer;
Internal helper method that returns the number of authenticators saved for the next 30 days.
If this is more than 0, you will have 8 bytes for each of the saved authenticators.
This is important to know so we know how many bytes we have to skip to continue reading the preferences file.
Example:
WriteLn CacheParser.CountAuthenticators();
CacheParser.GetAuthenticators¶
function TCacheParser.GetAuthenticators(): TStringArray;
No real use other than debugging.
Returns each authenticator saved in a TStringArray.
Each string is 8 bytes like mentioned in CacheParser.CountAuthenticators documentation.
Also, you can’t just use this to login as someone, don’t bother trying.
Example:
WriteLn CacheParser.GetAuthenticators();
CacheParser.GetUsernameIndex¶
function TCacheParser.GetUsernameIndex(bytes: TByteArray = []): Integer;
Internal helper function that returns byte index where the saved username starts.
This is required because depending on whether we have authenticators saved or not, the bytes shift like mentioned in CacheParser.CountAuthenticators.
CacheParser.GetUsername¶
function TCacheParser.GetUsername(bytes: TByteArray = []): String;
Returns the saved username in the game cache. This is the username you clicked to save on the client when logging in.
Example:
WriteLn CacheParser.GetUsername();
CacheParser.UsernameEndIndex¶
function TCacheParser.UsernameEndIndex(bytes: TByteArray = []): Int32;
Internal helper function used to get the index of the byte of where the username ends.
We can know the index of the byte by know where it starts with
CacheParser.GetUsernameIndex and iterating all next bytes until we
find one that is 0 which marks the end of the username.
This is required so we can keep reading the preferences file.
CacheParser.LoginHideUsername¶
function TCacheParser.LoginHideUsername(bytes: TByteArray = []): Boolean;
Returns true or false if we have the username hidden on the loginscreen.
Example:
WriteLn CacheParser.LoginHideUsername();
CacheParser.Brightness¶
function TCacheParser.Brightness(bytes: TByteArray = []): Integer;
Returns the brightness value converted to a 0-100 value (the value in cache is between 50-100 in a byte format).
Example:
WriteLn CacheParser.Brightness();
CacheParser.MusicVolume¶
function TCacheParser.MusicVolume(bytes: TByteArray = []): Integer;
Returns the music volume value converted to a 0-100 value.
Example:
WriteLn CacheParser.MusicVolume();
CacheParser.SoundEffectsVolume¶
function TCacheParser.SoundEffectsVolume(bytes: TByteArray = []): Integer;
Returns the sound effects volume value converted to a 0-100 value.
Example:
WriteLn CacheParser.SoundEffectsVolume();
CacheParser.AreaSoundVolume¶
function TCacheParser.AreaSoundVolume(bytes: TByteArray = []): Integer;
Returns the area sound volume value converted to a 0-100 value.
Example:
WriteLn CacheParser.AreaSoundVolume();
CacheParser.Field1247¶
function TCacheParser.Field1247(bytes: TByteArray = []): Integer;
I have absolutely no idea what this is. It’s supposedly something, but AFAIK it’s always 0.
Example:
WriteLn CacheParser.Field1247();
CacheParser Indices¶
This section is dedicated at reading the cache idx files.
This has no use yet and might not be working properly but does seem like it is.
There’s very little resources online about this but some useful ones can be found here:
idx files are basically pointers to data on the main_file_cache.dat2 where
pretty much all the game cache information is stored.
An idx file will tell you where on that file the data you want is, and it’s size.
CacheParser.ReadMediumInt¶
function TCacheParser.ReadMediumInt(const bytes: TByteArray; offset: Integer): Integer;
Internal helper method to partially read a sector of an idx file that are stored in big endian format.
CacheParser.DecodeIndexSector¶
function TCacheParser.DecodeIndexSector(const bytes: TByteArray; offset: Integer): TIndexData;
Internal helper method to read a sector of an idx file.
idx files are split into “sectors” of 6 bytes each. Each sector contains information about:
size of the data this sector points to
where that data starts.
CacheParser.ReadIdx¶
function TCacheParser.ReadIdx(idx: Integer): TIndex;
Read an idx file and return it’s information as a TIndex.
Example:
WriteLn CacheParser.ReadIndex(255);
CacheParser variable¶
Global TCacheParser variable.