wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Warcraft III Modding > Developer's Corner > Warcraft Editing Tools
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 05-27-2017, 04:41 PM   #1
Krysho
User
 
Krysho's Avatar
 
Join Date: Jan 2007
Posts: 53

Krysho will become famous soon enough (45)Krysho will become famous soon enough (45)

Default fail project

I wrote a simple jass debugger for fun. But first I will mention some important things:

- this will only work on game version 1.28.2
- you should not play online with this tool running, as it modifies memory and can get you banned
- the tool will try to disconnect you if you are in a multiplayer game, so do not use it online
- the tool is quite unstable, and can crash / fail at several points of use


A beginner's guide to failing successfully:
- download and extract the archive
- verify you can run fail.exe in the /fail directory; if you are missing dependencies you may need whatever runtime matches VS 2017
- copy your common.j and Blizzard.j files into the /fail/script directory.
- start the game in windowed mode (you should really only try using this tool in windowed mode)
- make sure you are not online (ideally be at the main menu screen)
- run EMS.exe as an admin
- in the ems console that pops up, type in "start" (without quotation marks) and then press enter
- if it all works out, the ems console should start spitting out a bunch of text and wc3 should still be running properly; if things do not work out, wc3 will probably crash - and you may need to kill the process (war3.exe) in your task manager (try running the game again if it fails - and kill the War3.exe task if it says it cannot initialize).
- the bottom few lines in the ems console should mention something about debugutility loading
- now start fail.exe
- type the game process ID (find it in your task manager) into the text box in the test window in the bottom right pane, then press enter
- press F9 to resume the game after attaching
- the log window in the bottom left of fail.exe should have a "test print lua call" message, and the status bar at the bottom left should say "RUNNING"
- now try running your map in single player or in LAN (alone)
- once you are in game and past the loading screen, try pressing Alt-G (or generate symbols in the debug menu) while fail.exe is focused; only do this once
- at this point fail.exe will attempt to recompile the map script (hope you are not using any common.ai functionality); if it succeeds then the ems console should mention replacing functions; if it fails, the log window in fail.exe should mention what it failed to do
- if you reached this far, everything should be setup to fully use the debugger's functionality


Some other things to try after doing the above steps...

Viewing a function's code:
- open the symbol list viewer (Alt-F, or find the option in the debug menu)
- narrow the search using the search text box at the top if desired; search works by separating the search field into words (words are separated by spaces); each word must be part of the symbol name for it to match; search is case insensitive if all search terms are lower case
- double click a symbol you want to view; this should put it in the symbol viewer in the center
- optionally, you may press Alt-B in the symbol viewer to show the "assembly" of the function

Setting a breakpoint:
- do the "Viewing a function's code" steps, then select a line in the symbol viewer
- press F2 to set the breakpoint (or find the option in the debug menu); this will put a red dot in the margin of the line
- the next time that line is executed, the game should pause and the debugger will show a yellow arrow on the line with the breakpoint
- from there you can step through the code using F10 and F11 (step over / step in)

Modifying a function at runtime:
- do the "Viewing a function's code" steps, then press Alt-S
- when the editor window pops up, press Alt-C while it has focus
- modify the function to your liking (note that you cannot change the parameters and return type)
- press Alt-B to compile and put it in the game
- note: each time functions are replaced, some memory is "leaked," and only reclaimed after playing through another game and quitting that game

Travel up the stack when at a breakpoint:
- do the "Setting a breakpoint" steps, then when you are paused at a breakpoint:
- double click one of the stack frames in the stack window, this will change the active stack frame
- the top stack value might be a function, if it is you can double click it to switch it to be the active frame (this also changes the symbol viewer code to match that context)
- note: each function's execution has its own stack frame
- press Alt-V to view active instances; if there is more than one, that means that the script started another instance (commonly known as a thread in the jassing community); you can double click instance entries to switch to them
- at any time while the game is paused, press F1 to switch back to the currently executing function

Viewing referenced globals:
- press Alt-W to open the referenced globals window

Detaching:
- generally speaking you should probably not detach, but if you do, make sure the game is not paused when you try, then click detach
- note that if the debugger is closed while attached, the game will be closed too

Some other features:
- if the op limit is hit while fail.exe is attached with symbols generated, the game will be paused and the debugger will show the active script that hit the op limit
- if the game crashes due to script execution, the active script might be shown (a crash such as by calling CinematicFadeBJ with a bad path)
- the status bar at the lower right will show how many ops have been used so far, when the game is paused by the debugger (the default limit is 300000)

Miscellaneous:
- probably requires running on 64 bit windows (it is a 32 bit exe, but there is one particular winapi call that assumes the system is 64 bit; most of the functionality might still work on a 32 bit system)
- may require running as an admin, I would try without it first


Finally, some things to keep in mind:

- symbol generation works by recompiling the map script; the compiler is not the same as the game's compiler, so it will have different behavior in numerous cases ... it can fail to compile, or generate the wrong code, etc
- the game can crash at numerous points while using this tool (most often at the ems.exe hooking the game step in my experience)
- do not try to use it while online (battle.net and others)
- since the tool has stability issues, I do not recommend it for any serious use
- since the tool is just for fun on my part, I probably will not support it


In any case, give it a try if you are curious. Check out the screenshot I attached.

06-02-2017
- added break command (probably useful for interrupting an infinite loop and seeing what it is doing)
- fixed (hopefully) ems trying to attach to the world editor (causing the editor to not start up)
- locals/globals views should not collapse expanded arrays while stepping in the same function
- jasstool should now handle octal literals
- changed file to .7z to reduce the file size (and attach it to the post)
Attached Images
File Type: png faildebug.PNG (560.3 KB, 17 views)
Attached Files
File Type: 7z publicems-17.0602-3.7z (3.93 MB, 8 views)

Last edited by Krysho : 06-03-2017 at 10:19 AM.
Krysho is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 03:00 PM.


Affiliates
The Hubb The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2018, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services