Originally I posted this elsewhere, but figured I would put it here too. An out of date tool that might be able to be useful to someone.
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.
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.