Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

W3Protect - Jass and Lua map optimizer

Discussion in 'Warcraft Editing Tools' started by Frotty, Sep 26, 2019.

  1. Frotty

    Frotty

    Wurst Reviewer

    Joined:
    Jan 1, 2009
    Messages:
    1,479
    Resources:
    11
    Models:
    3
    Tools:
    1
    Maps:
    5
    Tutorials:
    1
    Wurst:
    1
    Resources:
    11
    I'm not really active in wc3 anymore, just posting a short heads up.

    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.

    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.
     
  2. lolreported

    lolreported

    Joined:
    Aug 16, 2007
    Messages:
    841
    Resources:
    13
    Tools:
    1
    Maps:
    6
    Spells:
    6
    Resources:
    13
    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!
     
  3. JaysProjex

    JaysProjex

    Joined:
    Mar 17, 2007
    Messages:
    418
    Resources:
    4
    Maps:
    4
    Resources:
    4
    Edit: 7zip worked, windows & winrar did not work.
     
    Last edited: Aug 27, 2020
  4. Frotty

    Frotty

    Wurst Reviewer

    Joined:
    Jan 1, 2009
    Messages:
    1,479
    Resources:
    11
    Models:
    3
    Tools:
    1
    Maps:
    5
    Tutorials:
    1
    Wurst:
    1
    Resources:
    11
    Sounds more like something you would add after optimization?

    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.
     
  5. YTZI

    YTZI

    Joined:
    May 28, 2020
    Messages:
    2
    Resources:
    0
    Resources:
    0
    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: May 28, 2020
  6. Macadamia

    Macadamia

    Joined:
    Jan 30, 2020
    Messages:
    876
    Resources:
    0
    Resources:
    0
    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.
     
  7. Frotty

    Frotty

    Wurst Reviewer

    Joined:
    Jan 1, 2009
    Messages:
    1,479
    Resources:
    11
    Models:
    3
    Tools:
    1
    Maps:
    5
    Tutorials:
    1
    Wurst:
    1
    Resources:
    11
    Thanks for the kind feedback. Does this mean the custom charmap option isn't working for you?


    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.
     
  8. TriggerHappy

    TriggerHappy

    Code Moderator

    Joined:
    Jun 23, 2007
    Messages:
    3,793
    Resources:
    22
    Spells:
    11
    Tutorials:
    2
    JASS:
    9
    Resources:
    22
    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.
     
  9. Macadamia

    Macadamia

    Joined:
    Jan 30, 2020
    Messages:
    876
    Resources:
    0
    Resources:
    0
    @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.
     
  10. YTZI

    YTZI

    Joined:
    May 28, 2020
    Messages:
    2
    Resources:
    0
    Resources:
    0
    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.
     
  11. Daethz

    Daethz

    Joined:
    Mar 25, 2008
    Messages:
    255
    Resources:
    1
    Maps:
    1
    Resources:
    1
    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 either but i keep developing my map, have been for 13 years now :infl_thumbs_up:
     
    Last edited: Jun 4, 2020
  12. beastwars

    beastwars

    Joined:
    Aug 25, 2020
    Messages:
    7
    Resources:
    0
    Resources:
    0
    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.
     
  13. Azureusl

    Azureusl

    Joined:
    Jul 30, 2014
    Messages:
    16
    Resources:
    1
    Maps:
    1
    Resources:
    1
    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).
     
  14. Azureusl

    Azureusl

    Joined:
    Jul 30, 2014
    Messages:
    16
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Please allow program to be more customizable when launching from console.
    Launching as follows always invokes every mean of protection:
    Code (Bash):

    java -jar ./W3Protect-0.6.1.jar $TA_ROOT/TimeAbyssWC3.Builds/compiled_TimeAbyssWC3.w3x
     
    including said broken LuaMinifier
     
  15. Macadamia

    Macadamia

    Joined:
    Jan 30, 2020
    Messages:
    876
    Resources:
    0
    Resources:
    0
    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.
     
  16. Frotty

    Frotty

    Wurst Reviewer

    Joined:
    Jan 1, 2009
    Messages:
    1,479
    Resources:
    11
    Models:
    3
    Tools:
    1
    Maps:
    5
    Tutorials:
    1
    Wurst:
    1
    Resources:
    11
    You can thank blizzard for that..

    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.

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

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

    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
     
  17. Macadamia

    Macadamia

    Joined:
    Jan 30, 2020
    Messages:
    876
    Resources:
    0
    Resources:
    0
    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 !
     
  18. SinisterLuffy

    SinisterLuffy

    Joined:
    Apr 8, 2020
    Messages:
    99
    Resources:
    0
    Resources:
    0
    @Frotty Do you have any plans in adding that option Transform Objects to Slk any time soon?