View Source Code on GitHub


How it works

SimStreetsX patches various game functions by overwriting assembly instructions in the Windows PE (portable executable). Since the game was made before the ASLR standard, the patching process is straight-forward in converting relative virtual addresses to file offsets. Supporting various versions of Streets of SimCity with a single patcher however is a somewhat complicated process, namely I can't just open a disassembler such as IDA and run a diff patcher. Instead each function must be compared amongst all the versions and a commonality must be identified. When patching the function there is a space limitation to what I can accomplish "inline", if my patch is too big then a detour is written to an area in the PE which is free. Since I support multiple versions, the addresses where I keep my detour can't be the same so I added a new section to the PE called ".detour". This detour section is a safe and reliable space where I can write my detour code for functions that are too small to hold that data normally.

Having this dynamic detour section is only one component of having dynamic assembly patcher code. As you'll see below, I created a pseudo assembly class to help write-up my patches. Each function will have a brief descripion of what it does, their virtual addresses, and of course my code. View the source code on GitHub by following the link at the top of the page.

Patched Function List

Below is a list of identified functions, a brief description, and a before-and-after graph view. I use Streets of SimCity 1.0 (1997, 1998/Classics) as the basis for the graph views (and generally as my starting point for disassembly). Please see the source code for corresponding function address entries (virtual).

Main loop
Description: This is where I added a Sleep after the PeekMessage routine. It loads in the Sleep time (ms) based on the option submitted through the SimStreetsX Launcher - which stores that variable in the .detour section.
Original Graph: Click to view
Patched Graph: Click to view


CD Check
Description: Only one instruction was changed to avoid CD checks, this was done because both the game CDs and CD-ROM drives themselves are getting very scarce.
Original Graph: Click to view
Patched Graph: Click to view


Renderer Patch
Description: The GitHub page has a full description of the issue; long-story short when you start the game in "software rendering" mode, a call is still made to glide which will crash the game. This patch removes any call to glide while in software rendering mode.
Original Graph: Click to view
Patched Graph: Click to view