Increased Thread Limit for Compile Tools
The maximum amount of threads used by both VVIS and VRAD is limited to 16 as they are both implementing the same class; threads.cpp. This limitation has been part of the Source SDK since 2006 and derives from the processors common for that era. If you run an older version of Source (2013 or older), you can compile these tools with a new limit yourself as the source code is available. If you want to adapt the tools for a newer version, you will need to patch them. Warning: Spawning more threads will not necessarily decrease your compile time, these dlls are meant to be used for machines that have more than 8 physical cores!
Patched DLLs for CS:GO SDK
If you require more threads for compiling CS:GO maps, then you can download the patched dlls below. Please take notice of the disclaimer and back up your original vvis_dll.dll and vrad_dll.dll before you replace them:
Replace your vvis_dll.dll and vrad_dll.dll in SteamApps\common\Counter-Strike Global Offensive\bin. The inner workings are explained in the section below, if one is interested.
Patching the DLLs
The maximum amount of threads used by both VVIS and VRAD is limited to 16 using preprocessor directives.
#define MAX_TOOL_THREADS 16
#include "threads.h" #define MAX_THREADS 16 CRunThreadsData g_RunThreadsData[MAX_THREADS]; HANDLE g_ThreadHandles[MAX_THREADS]; if ( numthreads > MAX_TOOL_THREADS ) numthreads = MAX_TOOL_THREADS;
This means we will need to change 3 things:
- Find and replace the if statement to check for > 32 instead of > 16 (easy)
- Increase the size of the .data memory segment to make room for a bigger g_RunThreadsData array.
- Replace all calls to point towards the new memory addresses.
We can use the previous memory address of g_RunThreadsData (16 * (12 + 4) bytes) for g_ThreadHandles. Start off by increasing the .data segment size with CFF Explorer (luckily there is some space between .data and _RDATA).
Now launch IDA Free/Pro and find all cross-references to 'CreateThread'. Search for the subroutine that looks like Figure 1 (g_RunThreadsData & g_ThreadHandles will not be named that way).
Leave the graph mode (Space) and enable op codes. The line marked in Figure 2 is our register used for the if statement from the C++ code, using your favorite Hex editor find and replace the BE 10 00 00 00 (Warning: NOT unique) with BE 20 00 00 00 (0x20 = 32 decimal). Congrats, we have now completed our first task.
Now jump to the memory address provided by g_RunThreadsData (doubleclick ukn_XXXXXXX) copy and save the memory address (for example .data:12461E50). Go to the end of the old .data memory segment (you should have increased the size of .data with CFF Explorer some steps before) and copy that memory address. Find all cross-references to 'g_RunThreadsData' (ukn_XXXXXXX) and replace all calls to point to the new memory address using the Hex editor and the op codes.
Replace each call to 'g_ThreadHandles' you can find via cross-references with the old memory address of g_RunThreadsData. After this you are done.
Theses dlls are based upon their respective dlls from the CS:GO SDK (vvis_dll.dll & vrad_dll.dll), which we all know and trust not to destroy our PCs. That said, use these at your own risk. No responsibility is claimed for damage to your computer or games that may occur while using these patched dlls.