gmcl_downloadfilter - Filter for the resource queue

‬This module gives you the ability to decide which files you want to download from the downloadables string table. It works in a similar way to the cl_downloadfilter ConVar, except it’s not restricted to just sounds and all/none.

You will need to load your code in the menu environment to access the hook.

Return true or nil to let the download through.



hook.Add(“ShouldDownload”, “DownloadFilter”, function(filename)
local ext = string.GetExtensionFromFilename(filename)

if ((ext != "bsp") && (ext != "dua")) then --Filter out everything except the map and the datapack
	return false

end )[/lua]

Changes (GMT):

[07/06/10, 22:23] - Added Detours/SigScan wrappers to tidy up code a bit


How many awesome modules are you still gonna make?

Oh wow, this is really useful, thank you!

Holy shit, awsome!


Holy shit, that’s awesome.

We get nothing new from your for a month or two then out of no where you blow us away with 2 epic modules


Now I can make a menu to select the filetypes I don’t wanna download.
Not just “No Sounds” or “Nothing”.

Ah thank you very much for listening to my request, great work :slight_smile:

ShouldDownload_Sig.Init((unsigned char *)"\xF7\x05\x54\xCB\xD2\x0D\x00\x10\x00\x00\x74\x16\x8B\x4C\x24\x04", “xx???xxxxx?xxxx”, 16);

How do you find the hex/?x patterns and get at referencing things that aren’t exposed normally?

Well, first of all I tried hooking to INetChannel::RequestFile, a function that is exposed publicly. This seemed to work fine, except I ran into a major problem - downloads that were filtered stayed in the queue, therefore rendering it useless. I found a hacky workaround by changing the file name requested to something that didn’t exist on the client, but if the server didn’t have the file it would be spammed with errors + this was pretty dumb anyway.

After that, I tried hooking to the function that processes string table updates (which is also exposed) to prevent filtered files going through. However, I couldn’t find an easy way of doing this as the buffer given in the update function was compressed, therefore useless to me. Technically I could have gone through the update function and worked out how it extracted the data, but this would have been a lot more complex than the final result.

I ended up following the use of the cl_downloadfilter ConVar around as I figured this is where the download queue is processed. Eventually I came into a function which returned 1/0 (true/false) and took a file name as its only argument. This isn’t ideal and I would have preferred the second attempt to have succeeded, but it works in the same way as cl_downloadfilter and gets the job done without any hacky code.


Mind telling how you get the sigs though?

Through a debugger - I use OllyDbg.



NOTE: if you can’t see it well on my shitty computer’s resolution, to open the menu, go to Extensions in your garrysmod main menu. Also please notify me if I forgot an extension that is important (it allows unknown extensions by default).

Thanks, you saved me the work.

My god. I took the EXACT path you did, except I stopped at paragraph 2 because paragraph 3 never passed my mind back when I tried to accomplish this.

I’m glad you figured it out :smile:

This stopped working after a map change. Just fyi :confused: Still really good for those loaded sandbox servers.