中级玩家
 
- 贡献度
- 7
- 金元
- 1170
- 积分
- 145
- 精华
- 0
- 注册时间
- 2010-2-20
|
刚刚有人发这个了 不过他的文件压缩的有问题 我给整理了下
GFX Rebuild environment.
READ ALL OF THIS BEFORE YOU EVEN THINK OF USING THIS!!!
*** 0. What is the rebuild environment
The rebuild environment can be used for applying sofisticated
patches to the GFX files. It allows for both FLM patches and
for Actionscript function replaces (yes, you can code in
Actionscript, add new functions, etc).
So, if you would like to change the scripts in the GFX, the
rebuild environment will come in handy.
*** I. Prerequists
1. Reverse engineering and programming skills 
2. PHP (for the FLM decompiler)
3. MinGW GCC, especially CPP (the preprocessor for AS)
4. GAWK for Windows (http://gnuwin32.sourceforge.net/)
*** II. How does it work?
There are 3 SAMPLE source files attached.
1. battle.net.swf - this is the gfx file with the changed magic
(see Appendix A)
2. battle.net.flm - disassembled .swf file
3. sc2.atl - the Actionscript file with two example functions:
- GetBuildType - the original method is replaced by this function,
it enables the debug console at ctrl+F12
- var_dump - this is an added function that works like a php var_dump
(it's recursive); the function is mapped as:
_global.LIBRARY.Debug.WindowDebug.VarDump
(see Appendix B)
To use the functions from the ATL file in the FLM file, these parts
of code had to be changed:
legend: NC - No Change
ADD - Added
CM - Removed/Commented out
1. GetBuildType
NC setMember
NC push r:0, 'GetBuildType'
NC function2 () (r:1='this')
ADD <?php GetFullFuncBody("sc2", "GetBuildType"); ?>
CM /*push 'BattlenetAPI_GetBuildType', 1, '_global'
CM getVariable
CM push 'Native'
CM getMember
CM push 'Call'
CM callMethod
CM setRegister r:2
CM pop
CM push r:2*/
NC end // of function
2. var_dump
NC label17:
NC end // of function
NC
ADD // PATCH VarDump
ADD setMember
ADD
ADD push r:0, 'VarDump'
ADD function2 (r:2='_obj', r:3='level') (r:1='this')
ADD <?php GetFullFuncBody("sc2", "var_dump"); ?>
ADD end // of function
ADD // END OF PATCH
NC
NC setMember
NC push r:0, 'SortedFields'
NC function2 (r:2='object') (r:1='this')
NC push 0, 'Array'
OK, now how does the compilation go:
1. You type go.bat (EDIT IT before the first run to set the paths)
2. The CPP preprocessor is used to preproces the Actionscript
(yes, you can use #include #define etc you know from C/C++)
3. The Actionsript is compiled to SWF
4. It's disassembled to FLM
5. The PHP is run on the battle.net.flm; it executes the above
<?php GetFullFuncBody("FILENAME_WITHOUT_EXT", "FUNCNAME"); ?>
(e.g. our Actionscript file is sc2.atl, so I place "sc2" in
place of FILENAME_WITHOUT_EXT)
This function will use an (G)AWK script to cut out the function
body from the disassembled FLM file and insert it in the place
where it's located.
6. The battle.net.flm is compiled to SWF
7. It's uncompressed
8. The magic is changed to GFX
9. It's copied to the SC2Battle.net directory
10. Now you can run the SC2 and have fun with your new patch.
The sc2.atl contains some class declaration and some function at the
end. Do not touch it - it has to be there to please the mtasc compiler.
*** III. How to change a GFX function?
Follow these steps:
1. You probably have a flash decompiler (sothink for example). So,
get the function you want to change from it and copy it to the
sc2.atl file.
It will look sth like this:
.FunctionName = function (Argument)
{
SomeClass.SomeChild.SomeMethod(Argument);
this.m_LocalField = 1;
var _loc3 = 0;
while (++_loc3, _loc3 < Argument)
{
// Some code
} // end while
};
2. You have to change the form to (I'll mark the changes with /*HERE*/):
/*HERE*/ var m_LocalField;
/*HERE*/ function FunctionName(Argument)
{
/*HERE*/ _global.SomeClass.SomeChild.SomeMethod(Argument);
/*HERE*/ this.m_LocalField = 1;
var _loc3 = 0;
/*HERE*/ while (_loc3 < Argument)
{
// Some code
/*HERE*/ ++_loc3;
} // end while
};
3. Find the function in the battle.net.flm file, it will look sth like this:
push r:1, 'FunctionName'
function2 (r:2='Argument') (r:1='this')
push r:Argument, 1, '_global'
getVariable
...
branch label4
label5:
end // of function
4. Change the above to:
push r:1, 'FunctionName'
function2 (r:2='Argument') (r:1='this')
<?php GetFullFuncBody("sc2", "FunctionName"); ?>
/* COMMENT OUT THIS
push r:Argument, 1, '_global'
getVariable
...
branch label4
label5:
END OF COMMENT */
end // of function
5. Thats it. Now you can modify the AS script and add whatever
debug message you want.
*** IV. FAQ
Q: Do I really need MinGW CPP ?
A: No, just turn off C/C++ preprocessor in the go.bat file.
It comes in very handy with large patches.
Q: Do I really need PHP and GAWK
A: Yes. It's essential!
Q: The mtasc says some local method / variable is missing. What do I do?
A: Create the method in the ATL file. It doesn't make any difference anyway.
Q: What is the ATL file? Actionscript should be AS?
A: Yeah yeah, never mind it. It's because of the CPP step, and I didn't want
to mess the file names. Just treat the ATL files as normal AS.
Q: Is there any flash compiler that doesn't need to change the function
form (step 2) and will compile the AS I've got from sothink?
A: Yes, Macromedia Flash compiles it OK, so, if you can get it working from
the console, it will be very useful 
Q: Was this framework tested?
A: Yes, it was used to make really large patches to the battle.net.gfx.
Q: It says that PHP/CPP is "command not found". Wtf?
A: Add the PHP/CPP/whatever paths to the PATH environment variable; use
set path=%path% ATH1 ATH2 ATH3;etc
*** A. Appendix A
The GFX and SWF files are identical, except for the magic (first
three bytes). The magic is:
SWF | GFX
--------+--------
compressed CWS | CFX
uncompressed FWS | GFX
Change the magic accordingly, and the file is converted. You can
use a hex editor, or the dd.exe attached to this build env.
See the go.bat file to check how to use dd.exe.
*** B. Appendix B
The added function var_dump is mapped as the VarDump method for
the LIBRARY.Debug.WindowDebug class. It works similar to "dump"
command in the console, except that it's RECURSIVE (so be careful
when using this function on large and deep objects like _global ;>)
Using the _global.LIBRARY.Debug.WindowDebug.VarDump function:
In the debug console:
eval LIBRARY.Debug.WindowDebug.VarDump(object, 0)
object - any object
0 - this HAS to be 0
In the AS script:
_global.LIBRARY.Debug.WindowDebug.VarDump(object, 0); |
|