• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

W3Protect - Jass and Lua map optimizer

Level 3
Joined
Apr 25, 2013
Messages
38
I couldn't extract the .jar file because the operation would break everytime (even tried open with) so I had someone send me the .jar file which worked fine.

If you can't extract a .zip archive I'm not sure how to help you :/

I'm having the same problem champ.

If I hit Try Again it just repeats, if I hit skip I get an empty folder. I am looking forward to trying out the program though.

*Solved*: Had to download 7zip to unzip the file. The Windows Extract All when you right click wont work.
 
Last edited:
Level 23
Joined
Jan 1, 2009
Messages
1,608
*Solved*: Had to download 7zip to unzip the file. The Windows Extract All when you right click wont work.

Looks like windows doesn't support the .zip format properly then :/ I never expected ppl to use that tbh.
Thanks for the report tho, it works with other tools (winrar, unzip) which I tried, so I will probably pack it differently in the future.
 
Level 14
Joined
Feb 7, 2020
Messages
386
-with/without extreme compression
-remove world editor data
-inline trigger strings
-Minify Lua

Edit, if I use "Inline Trigger Strings" it gets stuck on Parsing Script. Everything Else works

Using only "Minify Lua" I can open in the editor but in map lobby when I select it I get the error "There was an error reading the map file"

I get the same issue with minify/inline but the rest seems to work. Didn't think I'd find a tool that actually works with Lua maps!
+rep to author
 
Level 10
Joined
Mar 25, 2008
Messages
339
I couldn't extract the .jar file because the operation would break everytime (even tried open with) so I had someone send me the .jar file which worked fine.
Same I had to use 7zip to extract, windows kept failing.

After the recent wc3 update the old wc3 optimizer i use now increases map file size by 20,000% from a 5mb file to a 1gb file.

--This protector seems to get stuck on Parsing Script...
it could be because my map has a ridiculous amount of GUI code (the entire game minus like one or two small ability scripts are GUI)
Using Extreme Compression, Optimize Code, Obfuscate Script, remove world editor data and inline trigger strings, turned off lua minify as with almost no lua in my game theres no reason to do anything to it.

The old protector would give me a w3x.j file that would contain all gui code, it was 46 thousand lines.

Disabling obfuscate script still seems to get stuck on parsing, really hard to tell if its actually working on it or frozen.
 
Last edited:
my map has a ridiculous amount of GUI code
turned off lua minify as with almost no lua in my game theres no reason to do anything to it.

If your maps scripting mode is set to Lua have you have a ton of GUI code, then you also have a ton of Lua as GUI is compiled to whatever scripting language you have set.

After the recent wc3 update the old wc3 optimizer i use now increases map file size by 20,000% from a 5mb file to a 1gb file

If you are talking about Vexorian's map optimizer then with the right settings it should work.
 
Level 19
Joined
Aug 16, 2007
Messages
881
Hey, I've found an issue with this tool.

The following code will result in "Code has Errors!" when protecting the map.
JASS:
function b takes string s returns nothing
  call ExecuteFunc(s)
endfunction

function a takes nothing returns nothing
    call b("string argument to use with ExecuteFunc doesn't work")
endfunction
Would a fix be possible?

Thanks.
 
Last edited:
Level 23
Joined
Jan 1, 2009
Messages
1,608
I'm not really active in wc3 anymore, just posting a short heads up.

Disabling obfuscate script still seems to get stuck on parsing, really hard to tell if its actually working on it or frozen.

Run from console and you will get additional error logging. Also any step taking more than 1-2 minutes is broken unless u have super slow pc or a giant map.

Hey, I've found an issue with this tool.

The following code will result in "Code has Errors!" when protecting the map.
JASS:
function b takes string s returns nothing
  call ExecuteFunc(s)
endfunction

function a takes nothing returns nothing
    call b("string argument to use with ExecuteFunc doesn't work")
endfunction
Would a fix be possible?

Thanks.

The snippet you posted works if the ExecuteFunc parameter is constant and references an existing function.
Everything else can not be analyzed/optimized and is therefore invalid input.
 
Level 19
Joined
Aug 16, 2007
Messages
881
I'm not really active in wc3 anymore, just posting a short heads up.

The snippet you posted works if the ExecuteFunc parameter is constant and references an existing function.
Everything else can not be analyzed/optimized and is therefore invalid input.
I'm using ExecuteFunc in order to prevent dumb injections for cheat packs. If the injected function doesn't exist nothing will happen, but if it does, I can detect the injection.

The optimizer will remove the call if the function doesn't exist unfortunately; so my workaround was to read ability tooltips as an argument to ExecuteFunc, but this resulted in the error.

I'll look for another solution instead, thanks for the hard work, it's a great tool!
 
Level 23
Joined
Jan 1, 2009
Messages
1,608
I'm using ExecuteFunc in order to prevent dumb injections for cheat packs. If the injected function doesn't exist nothing will happen, but if it does, I can detect the injection.

The optimizer will remove the call if the function doesn't exist unfortunately; so my workaround was to read ability tooltips as an argument to ExecuteFunc, but this resulted in the error.

I'll look for another solution instead, thanks for the hard work, it's a great tool!

Sounds more like something you would add after optimization?

It was only a matter of time, frotty never really examined my issue

Either I can't extract zip files or someone can't archive them properly

I already examined and answered your issue. Windows' "Extract All" function does not support the ultra compression used for creating the archive.
If you use that junk it really is your problem. If that stops you from using w3p that's probably for the best.
 
Level 1
Joined
May 28, 2020
Messages
3
Hey Frotty, I really appreciate working on this.
It seems like the map is inoperable when using xdep, but I managed to get the wc3map.j and even though I set the obfuscation and custom charmap to Il0O it does nothing. I can see all the function/variable names as if nothing happened. Please let me know what you think

Edit: Seems like the the custom charmap was the problem. Use less readable and it works
 
Last edited:
Level 12
Joined
Jan 30, 2020
Messages
875
Hello there and thanks for this great tool.

Is there any change we could get a few more options available for Lua based maps?
More specifically inlining trigger strings and Obfuscate script like in Jass ?

Also, will the option to convert objects to SLK be implemented one day (or is this not working anymore with Reforged?)

Thanks again for the hard work and for this irreplaceable tool.
Take care.
 
Level 23
Joined
Jan 1, 2009
Messages
1,608
Hey Frotty, I really appreciate working on this.
It seems like the map is inoperable when using xdep, but I managed to get the wc3map.j and even though I set the obfuscation and custom charmap to Il0O it does nothing. I can see all the function/variable names as if nothing happened. Please let me know what you think

Edit: Seems like the the custom charmap was the problem. Use less readable and it works

Thanks for the kind feedback. Does this mean the custom charmap option isn't working for you?


Hello there and thanks for this great tool.

Is there any change we could get a few more options available for Lua based maps?
More specifically inlining trigger strings and Obfuscate script like in Jass ?

Also, will the option to convert objects to SLK be implemented one day (or is this not working anymore with Reforged?)

Thanks again for the hard work and for this irreplaceable tool.
Take care.

Thanks, I'm glad you like it.
Further lua opts are not likely to happen, because it would need to be written from scratch using some lua parser.
As far as I know even the minification using luamin is somewhat lacking right now.
If you would offer to do some tests, perhaps could work on it a bit.
SLK opt needs much testing as well, but in theory it could work and should still work with reforged.
 
Lua obfuscation is kind of tricky. The language is pretty flexible so it can be somewhat difficult without breaking code. Maybe if we had a way to run bytecode it would make the process a bit easier.

There are various techniques that can be used to prevent tampering but in the end someone will eventually be able to modify your script. It's probably not worth the time/effort.
 
Level 12
Joined
Jan 30, 2020
Messages
875
@Frotty :
I understand making requests is easy while making them real means a lot of work in the background.
In that context, if you ever find the time and the motivation to work on these features and need someone to help with the testing, I'm definitely in !

@TriggerHappy :
Yes, I found the old thread mentioning bytecode, and I partially understand what it could potentially offer. I have no idea if this is still possible and simply has not been made, or if patches since have completely buried all hopes in the matter.



Now, in the scope of protection, don't get me wrong : I am not obsessed with it. I also have no pretension there is anything special with my script, and I even believe most of the experienced programmers in the community could do a far better job than everything I came up with.
Also, for any map maker eventually interested in seeing how I made things, I would never refuse to share my unprotected map.

After a lot of thinking, I just consider protection as a small barrier to filter out anyone who is dumb enough to want to change the map in stupid ways (if the map ever gets success, but that is not even my goal). I am well aware that anyone with enough knowledge and motivation can break nearly all possible protection. But I have the feeling that beyond a certain point, it just isn't worth it. Especially when it would probably be easier for such a person to create better code than the map brings to the table.

In the end, unlike what many people seemed to think in the past years when I was away, Warcraft 3 is not ready to die, whatever stupid things Blizzard has done (or might do in the near future). The ideas behind the several requests I issued around is just in the perspective of giving the community more potential tools.

It seems that many of the talented tool makers in this community have lost motivation or even left the boat.
It would be nice to see those who stayed (or even new ones) keep being passionate and keep expressing their talent just for the beauty of it.
Same goes with map makers, many seem to be taken down when they realize success is not what they expected, and feel like there is no recognition of their hard work.

It might also be caused by the fragmentation of the community, but I tend to believe this is not really such of a big issue once you keep an open mind.

As far as I am concerned, there is so much I still need to learn to catch up, but I'm back in the boat now, and will support the community as much as I can with my limited abilities.
 
Level 1
Joined
May 28, 2020
Messages
3
Thanks for the kind feedback. Does this mean the custom charmap option isn't working for you?
Exactly. I've extracted the w3.j and it was not obfuscated when attempting a custom charmap of Il0O.

Another suggestion, since this program is called "W3Protect"...How about incorporating MPQ damage to further enhance the protection? I've got a python script that does that, but as it's just a script, people just wrote the opposite of what it does to reverse the damage. It overwrites certain HEX values in specific locations to make the map unreadable by anything except for WC3. I have no knowledge of python or file headers, only some high-school C++ from 10 years ago, otherwise, I'd make something of my own.

I'd be happy if you could work on it, as it's only a few lines of code :) PM me if you want the script.
 
Level 10
Joined
Mar 25, 2008
Messages
339
It worked on my map now (loap ascension)

However, somehow this application mixed strings together, im literally getting the wrong Game - Text Message's in the wrong triggers, like in my NPC respond trigger im getting prompts from my custom player kick system which isn't anywhere near that trigger, they share Nothing, no variables, they aren't even in the same folder in the gui triggers.

I used Extreme Compression, Optimize Code, Obfuscate Script, Remove World Editor Data, Inline Trigger Strings and apparently lua minify was still checked.

Going to try again without string inlining and lua minify.

Edit: Disabling String Inlining Worked. but note that string inlining will mix together all of the strings in GUI Triggers, not sure if intended or a bug, if its intended prehaps a big red warning?
I don't even want to know what would happen if i did globals and function inlining...

map is 100% gui by the way.

I'm not really active in wc3 anymore, just posting a short heads up.
I'm not either but i keep developing my map, have been for 13 years now :infl_thumbs_up:
 
Last edited:
Level 1
Joined
Aug 25, 2020
Messages
6
It was only a matter of time, frotty never really examined my issue

Either I can't extract zip files or someone can't archive them properly
Hi Jay, I know I replied in wrong place, but could you pls advise which Editor can open and edit Cowicula's Wilderness Survival 1.2b, ? Thank you.

I don't quite understand the script thing. So, will all Sinple stuff be moved in Approved? The problem with Simple now is that it contains both borderline good stuff and bad stuff. So moving it all will cause drama when we'd manually move the bad stuff back to Simple.
" If resource is useful / simple, then mark as "Approved" and give rating "(2) Useful / simple. "

But it kinda is a problem since some useful / simple resources aren't really working or bug free....
 
Level 4
Joined
Jul 30, 2014
Messages
18
Lua minifier renders map broken and doesn't even let it launch.
Tested multiple times, result is pretty much always the same - compiled map works just fine. Protected map completely breaks (most of the time it even won't let you create it).
 
Level 4
Joined
Jul 30, 2014
Messages
18
Please allow program to be more customizable when launching from console.
Launching as follows always invokes every mean of protection:
Bash:
java -jar ./W3Protect-0.6.1.jar $TA_ROOT/TimeAbyssWC3.Builds/compiled_TimeAbyssWC3.w3x
including said broken LuaMinifier
 
Level 12
Joined
Jan 30, 2020
Messages
875
Just want to add a note.

On the latest refactor of my map Lua script, I noticed the Lua minifier indeed brought some issues that were not there before.
I haven't yet had time to find out what went wrong, but last time I tried (very recently), some features of my map went AWOL or half broken.

In my refactor, I use Lua root for non handle globals declaration, replace some natives, and use _G metatable alterations to run my own main and config functions, but I am not sure the issues are related to this.

Once I finish my current refactoring, I plan to do some more tests with Lua minifier and try to see how things got broken.
 
Level 23
Joined
Jan 1, 2009
Messages
1,608
It seems that many of the talented tool makers in this community have lost motivation or even left the boat.

You can thank blizzard for that..

Another suggestion, since this program is called "W3Protect"...How about incorporating MPQ damage to further enhance the protection?

As mentioned in the first post, the catchy name is mostly for fun. The "read-only" option basically does what spazzler does (the python script you mean) but all of them can easily be circumvented with ladik's mpq editor and reassembling the mpq. Thus I don't see much sense in it.

However, somehow this application mixed strings together, im literally getting the wrong Game - Text Message's in the wrong triggers, like in my NPC respond trigger im getting prompts from my custom player kick system which isn't anywhere near that trigger, they share Nothing, no variables, they aren't even in the same folder in the gui triggers.

Of course it's not intended and there can be some bugs with TRIGSTRs, can't say much without seeing the map.

Please allow program to be more customizable when launching from console.

It uses the same config you set in the UI when running from console (config file).

Lua minifier renders map broken and doesn't even let it launch.

On the latest refactor of my map Lua script, I noticed the Lua minifier indeed brought some issues that were not there before.
I haven't yet had time to find out what went wrong, but last time I tried (very recently), some features of my map went AWOL or half broken.

I am using an external library mathiasbynens/luamin for the lua minification. It hasn't been updated for a while and has some known issues with operator & bracket precendence, which can cause strange problems.
Can't really do much about it, and I never did much testing on it since I didn't use lua much.

Cheers
 
Level 12
Joined
Jan 30, 2020
Messages
875
Thanks for these precisions !

I guess I don't need to do any further test :)
I suppose I should find other means to minify my code, although there are already easy ways to achieve this, even in a basic editor like Notepad++.

Nevertheless, this tool of yours still remains a precious asset, and I don't think there is any viable alternative currently.

As for your response to my older comment, yes I have figured this out by now, although I think there is still hope.
Wc3 remains a formidable way for learning scripting, and although many things are really wrong currently, I have absolutely no regret coming back after 16 years.

Lastly, I surprisingly fell in love with Lua for some reason, after a first painful and disgusted approach to it.
I would probably never have tried it if it wasn't for Reforged. I suppose I would have felt the same with Wurst if I came back a few years earlier :)

Thanks for the work you have put into this tool !
 
Level 23
Joined
Jan 1, 2009
Messages
1,608
Version 0.6.2 released. See first post for download & changelog.

I fixed a bug in the lua minification lib and updated .j files to latest (thx @BLOKKADE).
@Macadamia Perhaps you could check whether this resolves the lua-issue for your map.

@Frotty Do you have any plans in adding that option Transform Objects to Slk any time soon?

It's still planned but takes longest to implement and test properly.
 
Level 23
Joined
Jan 1, 2009
Messages
1,608
Version 0.7.0 released. See first post for download & changelog.

I added a new major feature, 'String Encryption'. Unlike the previous 'Encrypt Strings' option, which only affected comparisons, the new 'String Encryption' encrypts every string value in the Jass script.
Thus there are now two options:
  • 'String Hashing': Turns constant string comparisons (e.g. GetPlayerName(p) == "Local Player") into precomputed hash comparisons (e.g. StringHash(GetPlayerName(p))==$7e9e52f6). This hides e.g. player name checks and command activators from plain sight.
  • 'String Encryption': Encrypts every string value in the map (e.g. call DisplayTimedTextToPlayer(p,0.,0.,15.,"Hello this is a test")) and replaces them with calls to a decrypt function (e.g. call DisplayTimedTextToPlayer(p,0.,0.,15.,decrypt("f\\@bf`DU[sSWLsFPTYQ"))) which lazily decrypts the string and caches it in a hashtable. This obfuscation allows retaining debug information, i.e. stacktraces, without leaking plaintext information in the code.

Both options can be used in conjunction, since the hashing takes place before the encryption and those strings will therefore not be affected by the encryption.

I have tested string encryption successfully in my map, but it is still regarded experimental and could use some testing.

e: Hotfix 0.7.1 released to fix some string encryption issues discovered by @LeP .
 
Last edited:
Level 1
Joined
Nov 15, 2021
Messages
1
Info

Jass and Lua map optimizer. Most of the special "protections" are only available for Jass maps.

View attachment 382534

The main reason for this tool was/is to have an all in one solution for map finalization.
(If Water and me fix SLK transform at some point)

Install

Requires an installation of Java 8 (Java 8 | AdoptOpenJDK)
If you have Java installed, just download the .zip file from this post and extract the .jar file from it.

Usage

Run the .jar from the downloaded archive with no arguments to start open the graphical interface.
Use the "Browse" button or drag & drop a map onto the app window to load it.
If the load was successful, you should see the preview image.
Otherwise the map is already protected or otherwise unreadable.
(If you think it's unprotected but not working, please report the map)

You can use w3protect from the commandline by passing a map path as first and only argument.
The config will be read from the .wpc file next to the .jar .

In both cases w3protect will generate a copy of your input map with the suffix "_w3pro" in the same location.

Options explained

  • "Extreme Compression" - re-compresses every file in the mpq with best settings. (optionally zopfli)
  • "Lua minify" - uses 'luamin' to minify the map's lua script.
  • 'String Hashing': Turns constant string comparisons (e.g. GetPlayerName(p) == "Local Player") into precomputed hash comparisons (e.g. StringHash(GetPlayerName(p))==$7e9e52f6). This hides e.g. player name checks and command activators from plain sight.
  • 'String Encryption': Encrypts every string value in the map (e.g. call DisplayTimedTextToPlayer(p,0.,0.,15.,"Hello this is a test")) and replaces them with calls to a decrypt function (e.g. call DisplayTimedTextToPlayer(p,0.,0.,15.,decrypt("f\\@bf`DU[sSWLsFPTYQ"))) which lazily decrypts the string and caches it in a hashtable. This obfuscation allows retaining debug information, i.e. stacktraces, without leaking plaintext information in the code.

Feedback

Please let me know if there are any problems with maps after being processes by w3p, but make sure the map can be opened in the world editor.
You can also suggest cool features to implement.
Reporting Maps: Please make sure your maps runs and is openable with the world editor.

0.5.2
  • Initial release
0.5.3
  • TriggerRegisterVariableEvent is now allowed. Referenced variables will be kept unchanged.
  • Added second inliner pass after local optimizations to get rid of functions which were shortened significantly
  • Added rewrites for Jass "ternary" functions and equality comparisons with constant booleans
0.5.4
  • Trigger string replacement in plain text files doesn't stop after the first match any more
  • Trigger strings that are not inlined are now kept intact correctly
  • Trigger strings with quotes are now properly escaped in script files
  • Disabled experimental function rewrite
0.5.5
  • Variables used in TriggerRegisterVariableEvent are now also protected during optimization.
  • Charmap used for obfuscation is now customizable
  • Default charmap now uses all characters
  • Re-enabled experimental rewrites
  • Fixed program hang when output map not writable
0.5.6
  • Added more files for WTS inlining and fixed objmod inlining
  • Fixed WTS inliner normalization of line breaks and max length
  • Fixed war3map.wct not being removed
  • Fixed uppercase color codes not being displayed
  • Fixed variable protection for TriggerRegisterVariableEvent hooks
0.5.7
  • Fixed WTS parser bug in underlying lib
0.5.8
  • Fixed useless ExecuteFunction calls stopping script optimization. They now get removed.
  • Fixed .wav files getting corrupted with extreme compression option
  • Fixed input map getting modified after load
0.5.9
  • Fixed WTS inliner corruption bug
0.5.10
  • Improved Local Variable merging
  • Fixed WTS inliner not keeping newlines intact
  • Fixed parsing multiline strings
0.5.11
  • Fixed bug in integer to hex transformation
0.6.0
  • Updated to 1.32 common.j & blizzard.j for reforged support
  • WIP: Allow specifying custom common.j & blizzard.j files
  • Fixed incorrectly detecting agent type comparisons as errors
  • Added github profile link
0.6.1
  • Fixed lua minification for reforged and improved execution speed (thanks @BradPittlord)
  • Added extra step indication for lua minfication after parsing
  • Fixed expressions like (0 - 100) being rewritten to 100 instead of -100 and swallowing other optimizations (thanks @BLOKKADE)
0.6.2
  • Fixed a bug with lua minification regarding operator precendece
  • Updated common.j and blizzard.j to work with latest patches
0.6.3
  • Re-enabled string encryption (only fails on edge cases)
  • Split up compression into recompress and extreme, with extreme now using zopfli to even better compress the mpq
  • Fixed issues with loadingscreen being removed when Trigger string inlining was enabled
0.6.4
  • Added 'Remove Error Logs' option which removes error messages from vJass and Wurst code
  • Default charsets now have a randomized order
  • Added rewrites to replace EVENT_* variable references with equivalent conversion function calls
  • Fixed lua minification bug with scripts containing strings with semicolons
0.7.0
  • Fixed two issues with string hashing
  • Split up string comparison hashing and encryption into their own options
  • 'String Hashing' is what 'Encrypt Strings' was before - turning comparisons between strings into precomputed hash comparisons
  • Added new 'String Encryption' option that obfuscates all original strings in the map by encrypting them with a secret key
  • 'Remove World Editor Data' now removes the war3mapMap.blp file if war3mapMap.dds is present
0.7.0
  • Fixed 'Encrypt Strings' only working with other optimizations enabled
  • Using random encryption key for 'Encrypt Strings'
1/ how to use "Xdep" without revealing the model? "Xdep" reveals the model when using
2/ is it possible to integrate other software like "j2som" (Hex)? "MPQ" can still add cheats or modify files
New Bitmap Image (2)k.png
 
Last edited:
Level 31
Joined
Aug 6, 2015
Messages
635
So i have Java 17 installed buy i cannot acces this soft , is there any way to fix that? (this is the error i am getting when opening the program)
JASS:
Please report the following:
java.lang.IllegalAccessError: class Pe (in unnamed module @0x1d81eb93) cannot access class sun.swing.FilePane (in module java.desktop) because module java.desktop does not export sun.swing to unnamed module @0x1d81eb93
    at Pe.a(Unknown Source)
    at Pe.updateUI(Unknown Source)
    at java.desktop/javax.swing.JFileChooser.setup(JFileChooser.java:396)
    at java.desktop/javax.swing.JFileChooser.<init>(JFileChooser.java:362)
    at java.desktop/javax.swing.JFileChooser.<init>(JFileChooser.java:309)
    at Pe.<init>(Unknown Source)
    at MU.<init>(Unknown Source)
    at Km.g(Unknown Source)
    at Km.a(Unknown Source)
    at main.WAppMain.a(Unknown Source)
    at main.WAppMain.a(Unknown Source)
    at Kq.a(Unknown Source)
    at main.WAppMain.main(Unknown Source)
 
Level 23
Joined
Jan 1, 2009
Messages
1,608
Is map protection supposed to take a long time with this? I'm at like 15 mins now and it still says it's parsing the script :'(
If it takes longer than 5min no. you can run in terminal for more output. Some options require other options to be present, such as string encryption requires script optimization.
Try tinkering with the settings.
For example this is what im using.
Please stop it with the misleading suggestions. Disabling all options that actually do something obviously stop errors from happening. But then you might as well not use the program in the first place.
 
you can run in terminal for more output

Found something that may be useful to you. The tool was stuck at parsing my map's script, and running it in the terminal gave me this error message:
output.PNG
line.PNG


I guess the parser's integer limit is set lower than what the world editor accepts.

EDIT: After lowering this number to something less ludicrous it successfully obfuscated my script which it didn't do previously :wink:
 
Last edited:
Level 12
Joined
Dec 2, 2016
Messages
733
Info

Jass and Lua map optimizer. Most of the special "protections" are only available for Jass maps.

View attachment 382534

W3Protect.eu

The main reason for this tool was/is to have an all in one solution for map finalization.
(If Water and me fix SLK transform at some point)

Install

Requires an installation of Java 8 (Java 8 | AdoptOpenJDK)
If you have Java installed, just download the .zip file from this post and extract the .jar file from it.

Usage

Run the .jar from the downloaded archive with no arguments to start open the graphical interface.
Use the "Browse" button or drag & drop a map onto the app window to load it.
If the load was successful, you should see the preview image.
Otherwise the map is already protected or otherwise unreadable.
(If you think it's unprotected but not working, please report the map)

You can use w3protect from the commandline by passing a map path as first and only argument.
The config will be read from the .wpc file next to the .jar .

In both cases w3protect will generate a copy of your input map with the suffix "_w3pro" in the same location.

Options explained

  • "Extreme Compression" - re-compresses every file in the mpq with best settings. (optionally zopfli)
  • "Lua minify" - uses 'luamin' to minify the map's lua script.
  • 'String Hashing': Turns constant string comparisons (e.g. GetPlayerName(p) == "Local Player") into precomputed hash comparisons (e.g. StringHash(GetPlayerName(p))==$7e9e52f6). This hides e.g. player name checks and command activators from plain sight.
  • 'String Encryption': Encrypts every string value in the map (e.g. call DisplayTimedTextToPlayer(p,0.,0.,15.,"Hello this is a test")) and replaces them with calls to a decrypt function (e.g. call DisplayTimedTextToPlayer(p,0.,0.,15.,decrypt("f\\@bf`DU[sSWLsFPTYQ"))) which lazily decrypts the string and caches it in a hashtable. This obfuscation allows retaining debug information, i.e. stacktraces, without leaking plaintext information in the code.

Feedback

Please let me know if there are any problems with maps after being processes by w3p, but make sure the map can be opened in the world editor.
You can also suggest cool features to implement.
Reporting Maps: Please make sure your maps runs and is openable with the world editor.

0.5.2
  • Initial release
0.5.3
  • TriggerRegisterVariableEvent is now allowed. Referenced variables will be kept unchanged.
  • Added second inliner pass after local optimizations to get rid of functions which were shortened significantly
  • Added rewrites for Jass "ternary" functions and equality comparisons with constant booleans
0.5.4
  • Trigger string replacement in plain text files doesn't stop after the first match any more
  • Trigger strings that are not inlined are now kept intact correctly
  • Trigger strings with quotes are now properly escaped in script files
  • Disabled experimental function rewrite
0.5.5
  • Variables used in TriggerRegisterVariableEvent are now also protected during optimization.
  • Charmap used for obfuscation is now customizable
  • Default charmap now uses all characters
  • Re-enabled experimental rewrites
  • Fixed program hang when output map not writable
0.5.6
  • Added more files for WTS inlining and fixed objmod inlining
  • Fixed WTS inliner normalization of line breaks and max length
  • Fixed war3map.wct not being removed
  • Fixed uppercase color codes not being displayed
  • Fixed variable protection for TriggerRegisterVariableEvent hooks
0.5.7
  • Fixed WTS parser bug in underlying lib
0.5.8
  • Fixed useless ExecuteFunction calls stopping script optimization. They now get removed.
  • Fixed .wav files getting corrupted with extreme compression option
  • Fixed input map getting modified after load
0.5.9
  • Fixed WTS inliner corruption bug
0.5.10
  • Improved Local Variable merging
  • Fixed WTS inliner not keeping newlines intact
  • Fixed parsing multiline strings
0.5.11
  • Fixed bug in integer to hex transformation
0.6.0
  • Updated to 1.32 common.j & blizzard.j for reforged support
  • WIP: Allow specifying custom common.j & blizzard.j files
  • Fixed incorrectly detecting agent type comparisons as errors
  • Added github profile link
0.6.1
  • Fixed lua minification for reforged and improved execution speed (thanks @BradPittlord)
  • Added extra step indication for lua minfication after parsing
  • Fixed expressions like (0 - 100) being rewritten to 100 instead of -100 and swallowing other optimizations (thanks @BLOKKADE)
0.6.2
  • Fixed a bug with lua minification regarding operator precendece
  • Updated common.j and blizzard.j to work with latest patches
0.6.3
  • Re-enabled string encryption (only fails on edge cases)
  • Split up compression into recompress and extreme, with extreme now using zopfli to even better compress the mpq
  • Fixed issues with loadingscreen being removed when Trigger string inlining was enabled
0.6.4
  • Added 'Remove Error Logs' option which removes error messages from vJass and Wurst code
  • Default charsets now have a randomized order
  • Added rewrites to replace EVENT_* variable references with equivalent conversion function calls
  • Fixed lua minification bug with scripts containing strings with semicolons
0.7.0
  • Fixed two issues with string hashing
  • Split up string comparison hashing and encryption into their own options
  • 'String Hashing' is what 'Encrypt Strings' was before - turning comparisons between strings into precomputed hash comparisons
  • Added new 'String Encryption' option that obfuscates all original strings in the map by encrypting them with a secret key
  • 'Remove World Editor Data' now removes the war3mapMap.blp file if war3mapMap.dds is present
0.7.0
  • Fixed 'Encrypt Strings' only working with other optimizations enabled
  • Using random encryption key for 'Encrypt Strings'
Download link doesn't work
 
Level 3
Joined
Mar 16, 2011
Messages
21
Could you return old w3p attachment until website link is fixed?
Or was it removed because some of the functions will not be free anymore?
 
I tried to run the old w3p because the website could not analyze my map.
In the command line it says "Invalid escape sequence: b" and I indeed have a string "\b". This happens when checking "Obfuscate Script".

I don't know if this was fixed for the website version, but could be the same problem.

Opinion: A website with account login, ticket support, "ultimate plan" to protect maps feels overkill.
 
Last edited:
Level 6
Joined
May 29, 2013
Messages
126
I am looking forward to this project.
I also like the subscription plan that can be maintained continuously.
Is Ultimate not available yet? When will it be released?

And do you have any plans to release it in the form of a program? Uploading original maps to the internet is a bit reluctant.
If it's based on the internet, wouldn't it be possible for many users to share a single account like Netflix?
 
Top