RSCacheParser

RSCacheParser as the name implies is a record made to parse information from certain files that are part of the OSRS 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.


TRSCacheParser

Type responsible for handling osrs cache parsing.


RSCacheParser.Setup

procedure TRSCacheParser.Setup();

Internal method responsible for setting up the TRSCacheParser.

This is automatically called for you on the RSCacheParser variable.


Preferences

This section is about reading the game preferences that get cached. There’s 2 preferences files:

  • jagexcache/oldschool/LIVE/preferences.dat

  • jagexcache/oldschool/LIVE/preferences2.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.


RSCacheParser.ReadPreference

function TRSCacheParser.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 RSCacheParser.ReadPreference(1);

RSCacheParser.CountOptions

function TRSCacheParser.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 RSCacheParser.CountOptions();

RSCacheParser.RoofsHidden

function TRSCacheParser.RoofsHidden(bytes: TByteArray = []): Boolean;

Returns whether the roofs are hidden or not.

Example:

WriteLn RSCacheParser.RoofsHidden();

RSCacheParser.LoginMusicDisabled

function TRSCacheParser.LoginMusicDisabled(bytes: TByteArray = []): Boolean;

Checks if the music is enabled on the login screen.

Example:

WriteLn RSCacheParser.LoginMusicDisabled();

RSCacheParser.WindowMode

function TRSCacheParser.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 RSCacheParser.WindowMode();

RSCacheParser.CountAuthenticators

function TRSCacheParser.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 RSCacheParser.CountAuthenticators();

RSCacheParser.GetAuthenticators

function TRSCacheParser.GetAuthenticators(): TStringArray;

No real use other than debugging.

Returns each authenticator saved in a TStringArray.

Each string is 8 bytes like mentioned in RSCacheParser.CountAuthenticators documentation.

Also, you can’t just use this to login as someone, don’t bother trying.

Example:

WriteLn RSCacheParser.GetAuthenticators();

RSCacheParser.GetUsernameIndex

function TRSCacheParser.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 RSCacheParser.CountAuthenticators.


RSCacheParser.GetUsername

function TRSCacheParser.GetUsername(bytes: TByteArray = []): String;

Returns the saved username in the osrs cache. This is the username you clicked to save on the client when logging in.

Example:

WriteLn RSCacheParser.GetUsername();

RSCacheParser.UsernameEndIndex

function TRSCacheParser.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 RSCacheParser.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.


RSCacheParser.LoginHideUsername

function TRSCacheParser.LoginHideUsername(bytes: TByteArray = []): Boolean;

Returns true or false if we have the username hidden on the loginscreen.

Example:

WriteLn RSCacheParser.LoginHideUsername();

RSCacheParser.Brightness

function TRSCacheParser.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 RSCacheParser.Brightness();

RSCacheParser.MusicVolume

function TRSCacheParser.MusicVolume(bytes: TByteArray = []): Integer;

Returns the music volume value converted to a 0-100 value.

Example:

WriteLn RSCacheParser.MusicVolume();

RSCacheParser.SoundEffectsVolume

function TRSCacheParser.SoundEffectsVolume(bytes: TByteArray = []): Integer;

Returns the sound effects volume value converted to a 0-100 value.

Example:

WriteLn RSCacheParser.SoundEffectsVolume();

RSCacheParser.AreaSoundVolume

function TRSCacheParser.AreaSoundVolume(bytes: TByteArray = []): Integer;

Returns the area sound volume value converted to a 0-100 value.

Example:

WriteLn RSCacheParser.AreaSoundVolume();

RSCacheParser.Field1247

function TRSCacheParser.Field1247(bytes: TByteArray = []): Integer;

I have absolutely no idea what this is. It’s supposedly something, but AFAIK it’s always 0.

Example:

WriteLn RSCacheParser.Field1247();

RSCacheParser 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.


RSCacheParser.ReadMediumInt

function TRSCacheParser.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.


RSCacheParser.DecodeIndexSector

function TRSCacheParser.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.


RSCacheParser.ReadIdx

function TRSCacheParser.ReadIdx(idx: Integer): TIndex;

Read an idx file and return it’s information as a TIndex.

Example:

WriteLn RSCacheParser.ReadIndex(255);

RSCacheParser variable

Global TRSCacheParser variable.