Contents

  • 1 Overview
  • 2 Applications and Instruments
  • 3 SWF Decompilers
  • 4 Video
  • 5 Particulars
  • 6 Separate Content material
    • 6.1 Edit Course of
    • 6.2 Hex Code
    • 6.3 Null Ops
    • 6.4 Rapidly producing hex code
    • 6.5 Getting UI Inputs to UnrealScript
  • 7 Code Breakdown
  • 8 Compiled Code
  • 9 Examples
    • 9.1 Resize-in-Place
  • 10 References

Overview

recordsdata (extensions of and ) include code within the type of which might management the , and are referred to as and generally are referred to as in code as . They will additionally include graphic sprites and icons utilized in these interfaces or elsewhere.

Within the case of these recordsdata are embedded in numerous , however primarily in recordsdata and . From the sport developer and modders perspective, an enormous benefit to utilizing SWF recordsdata is that they don’t have to be of recognized or fastened lengths.

This text describe the at the moment recognized details about modifying recordsdata, , and .

Applications and Instruments

  • Modding_Tools_-_XCOM:EU_2012
    • JPEXS_Flash_Decompiler
    • UPK-Modder

With the intention to look at or alter recordsdata, they have to first be extracted from the recordsdata they reside in. For that are helpful. There may be, nonetheless, and confirmed guide methodology described beneath within the Separate Content material part.

SWF Decompilers

  • The Open Supply JPEXS Decompiler has efficiently been used on SWF recordsdata extracted from XCOM upk recordsdata. It could possibly save the modified ActionScript again into the extracted SWF file. Hex substitute inside the upk file continues to be required on the present time.
  • The weblog [Free SWF Decompilers List ] has a .
  • is a free On-line decode/decompiler that may:
    • Decompile flash ActionScript from the swf flash file. Use this on-line flash swf decompiler to get the supply code of the swf file.
    • Decompile java CLASS recordsdata and save supply code in textual content. Reconstruct the unique supply code from the compiled binary.
    • Decompile .NET software and get it supply code. Now you may get near authentic supply code of C# (c sharp), Visible Fundamental .NET (VB.NET.), Visible C++ .NET (VC++.NET) and J# (jay-sharp).
    • Decode and get supply of php recordsdata encoded with Zend Guard. This course of additionally referred to as dezending and this system referred to as dezender (de-zender). So, dezend php recordsdata and get the supply code!
    • QR-code Reader. Decode a QR Code and get textual content! It is a two-dimensional bar code. The “QR” is derived from “Quick Response”. Most present cellphones can learn this code with their digicam. UTF-8 is supported.

Video

Up to now, nobody has discovered tips on how to alter or change the video games texture of AVI recordsdata. Nonetheless, the next instruments could also be of help, even when merely for recording issues for evaluation or replay.

  • (FREE) is ready to report all display and audio exercise in your pc and create industry-standard AVI video recordsdata and utilizing its built-in SWF Producer can flip these AVIs into lean, imply, bandwidth-friendly Streaming Flash movies (SWFs).
  • Anybody trying to work with video is suggested to take a look at the Video_capture_and_edit_tools web page on the Nexus Wiki.

Particulars

Icons are situated in file Command1.upk, within the portion recognized as gfxXComIconsXComIcons.swf.
Flag and Perk icons have been present in file GlobalPersistentCookerData.upk.
All of the SWF recordsdata in have been extracted and posted within the Mod Miscellaneous Recordsdata part.

It is doable to make use of the generic resizing functionality inside the instrument [UPKmodder] on an object so as to add extra with out having to take away code from different parts. I believe that is positively a case the place the “expand-in-place” strategy is superior as a few of the flash objects (as in UPK-level objects) are fairly massive.

For instance, the SWF file (when extracted) is 135k, whereas the SWF file is 153k. These SWF recordsdata comprise the majority of the UPK-level object containing them, though not fairly all of it.

Utilizing “resize-in-place” it is doable to rewrite a small portion of the SWF file (like a single flash-level object) and resize it accordingly, which permits for a lot simpler modifying of the embedded SWF recordsdata. There are literally decompile/recompile instruments for SWF recordsdata, which makes creating new code right here simpler than within the UPK itself (since we do not have a re-compile instrument that can use current object data from an current UPK).

Not solely does this enable for simpler modifying of the elements, but additionally for including extra information. This methodology may even be used so as to add extra picture / icon information, or to switch compressed imagery (the place the substitute will not be the identical dimension as the unique).

See #Resize-in-Place within the #Examples part for an illustration of this resizing approach, in addition to dialogue of the precise accompanying adjustments that should be made to the flash-level object block header.

Separate Content material

Edit Course of

Right here is the guide course of for modifying SWF recordsdata, from the XCOM Modding thread :

  1. Get the identify of the you wish to edit. In UE Explorer, it is the textual content string referred to as from an “ActionScriptVoid” or different operate beginning with “ActionScript,” like . These look like referred to as from unreal features starting with “AS_” in numerous lessons.
  2. Work out which UPK the seems in. I lastly began utilizing grep to textual content search your entire uncompressed set of UPKs. You will should hunt round, as you may discover operate calls slightly than the operate itself. For interface modifying, Command1.UPK seems to have a lot of sections, though XComGame.UPK has one or two, as properly.
  3. Now you need to excise the containing the file from inside the .UPK. “UPKs” can maintain a number of SWF recordsdata.
    • Handbook Methodology:
    1. SWF recordsdata start with the three letters “GFX” (all uppercase) inside the UPK. In your hex editor, do an ANSI seek for the operate identify you wish to edit. Then, search the ANSI *UP* from there for the letters “GFX”. Take a look at the context by which “GFX” seems — if it seems to be prefer it’s a part of a operate identify, and never a standalone code, then search upward once more.
    2. Delete each single byte within the file BEFORE the letters “GFX”, all the best way to the start.
    Word this may increasingly depart different SWF recordsdata than one by which you have an interest beneath it. Simply repeat the method within the different path, however be sure you seek for “GFX” BELOW the operate identify you wish to edit.
    • Programmable Methodology:
    1. Seek for GFX (all caps).
    2. Skip the subsequent byte — it is the model quantity.
    3. The subsequent 4 bytes are the SWF file dimension.
    4. Add the file dimension to the hex location of the “G” in GFX.
    5. Resultant place is the top of the embedded SWF file.
    6. As a double verify, the 4 bytes instantly following the embedded SWF file must be FF FF FF FF.
    7. Extract the recognized block of hex code (from the “GFX” to the calculated finish of the embedded SWF file) to a ‘short-term workspace’.
  4. Change the letters “GFX” to “FWS”. These must be the primary three bytes of your new file. This permits decompilers to deal with it as a definite file (Due to Dumbo111 for this trick)
  5. Save the end result as an .SWF file — do NOT save as a UPK, as you have already ruined this file as a UPK, and also you wish to maintain your authentic file intact. There could also be extra in separate SWFs beneath the SWF you wish to edit, however you will not have the ability to get at it with out excising every one individually.
  6. Open your new .SWF file in an decompiler, comparable to SoThink’s decompiler, which has a 30-day trial restrict, or JPEXS decompiler (free, hyperlink within the ‘Modding Instruments’ wiki article). However I used to be capable of translate the instructions to hex (by trying on the “raw data” possibility and matching the assembler instructions to the ) and make adjustments to in Notepad++ to the hex UPK. (In different phrases, extract the SWF part for remark functions, however make your edits to the unique UPK.)
See also  How to Crack RAR/WinRAR File Password If You Forgot

Hex Code

A reasonably complete set of hex codes may be discovered right here: SWF Actions

Scripts in are thought of a specialised kind of ACTION, and are all the time wrapped in an motion tag. Scripts will not be procedural (like in UE hex code), however is stack-based, which can require some adjustment.

Null Ops

would not immediately have a null-op (just like the 0B in UE hex), however you’ll be able to create null ops of assorted sizes. Merely PUSH a string onto the stack, then POP it again off. The string may be variable size so a variable size null-op may be created. The PUSH, POP, and the string terminator require 6 bytes, so that is the smallest null-op that may be created this fashion.

Rapidly producing hex code

The JPEXS decompiler helps a restricted quantity of modifying. Presently it’s restricted to modifying the stack-level instructions (push, pop, and so forth) versus the higher-level C/java model code (there’s beta model of that modifying functionality, but it surely is not working but).

The next sequence that lets me edit the scripts pretty rapidly:

  1. Open , work out what code I wish to change.
  2. From the JPEXS hex-view, determine the main hex blocks for the unique operate and the NEXT operate.
  3. Utilizing HxD (or any hex editor), copy out the hex of the operate from the unique SWF.
  4. Again in JPEXS, edit the operate within the “stack view”.
  5. “Save as” the adjustments to a brand new file (JPEXS cannot save a lot of the info within the authentic SWF, however it will possibly accurately save the entire scripts).
  6. From JPEXS hex-view, determine the main hex blocks for the edited operate and the NEXT operate.
  7. Open the newly saved SWF file in HxD (or different hex editor) and discover the block of modified hex.
  8. Copy out the modified hex from the modified copy of the SWF.
  9. Check the brand new hex by search and change in a replica of the SWF, and attempt to decompile in JPEXS.

That is MUCH MUCH sooner than making an attempt to manually edit the hex codes. Because of the stack-based construction, MANY of the instructions are 1 byte. Utilizing the above methodology I used to be capable of rewrite a 1014 byte SWF operate in about an hour.

Getting UI Inputs to UnrealScript

[Thanks to tracktwo in the “R&D XCOM UI/Flash modding” thread in the Nexus XCOM “Mod Talk” forum for the following:]

Getting mouse enter again into UnrealScript from Flash turned out to be not so large of a deal as soon as I discovered tips on how to arrange issues in Firaxis’ system. When utilizing the in-built display/panel system, mouse enter is managed by the interface supervisor, . To speak between your Flash film and your or sub-class, you simply want the next:

  1. The s_package, s_screenId, and s_name fields in your or subclass should be set accurately: s_package to the bundle and object containing your Flash, s_screenId to a novel Id to determine your display, and s_name to call the “main” movieclip (MC) in your film.
  2. On the Flash facet, your principal MC occasion must be exported for ActionScript within the first body.
  3. Register and show your display by means of the interface supervisor: The conference is to have some “manager” class spawn and initialize your UI class by calling Init() and passing the because the supervisor and a interface supervisor occasion (e.g. PRES().GetHUD() for the ) because the 2nd. Your Init() operate ought to name LoadScreen() on the supervisor you handed in, passing self. This may set your film up as a toddler display of the interface supervisor.
  4. After finishing any setup on the Flash facet, name the “FlashRaiseInit”, passing alongside the total path to your MC (i.e. . That is required to inform each the interface supervisor and your UI object that your Flash code has accomplished any initialization. This name can be dealt with by the occasion supervisor, which can name the OnInit operate in your subclass. It seems to be up the proper UI object to invoke by trying on the first argument to “FlashRaiseInit”. Because of this the total path as returned by string() in Flash must match the s_screenID and s_name fields in your UI subclass, in any other case it will not discover the best object to name. Failing to name “FlashRaiseInit” will forestall the interface supervisor from forwarding any mouse enter to your UI because it thinks it isn’t but initialized and prepared for enter processing.
  5. are raised by the exterior interface name “FlashRaiseMouseEvent”. This name is dealt with by the interface supervisor and dispatches to the OnMouseEvent operate in your UI class. The Flash exterior name takes three extra arguments. The primary is the principle MC of the clip once more (as for “FlashRaiseInit”, that is how the interface supervisor finds the proper UI occasion to name). The second is an integer which represents the . The third is an arbitrary string “args”. The conference utilized by most vanilla UIs is to cross the total path to the movieclip that generated the occasion right here. The interface supervisor will break up this string on “.” and cross the array of strings that make up the argument to your OnMouseEvent operate. In UnrealScript, OnMouseEvent takes 2 arguments: the integer (int) command and the “args” array of strings.
  6. All of the Flash exterior interface calls should be generated by means of a movieclip uncovered to ActionScript and exported within the first body of your film, or will not course of them.
See also  Logitech SetPoint Mac

Keyboard/Gamepad enter is pretty simple to handle, as anticipated. Simply present the OnUnrealCommand(int Cmd, int Arg) operate in your UI class and you will get keyboard and gamepad occasions every time your UI aspect is concentrated. Mouse occasions additionally are available in by means of right here, however usually you are in all probability higher off dealing with this on the Flash stage so it’s simpler to determine what was clicked on.

  • The listing of enter constants is within the class UI_FxsInput. For instance, many UI screens will reply to the entire choices:
    • the <Escape> key
    • the gamepad < B/Circle > button
    • the best mouse button
to shut the UI. These correspond to entries for instructions 301, 405, and 510 respectively.

Additionally a neat trick: by utilizing the usual display/panel system, the UI components all coexist in the identical film occasion as sub-clips. Because of this in case your UI is layered on prime of one other UI (because the marketing campaign supervisor is at the moment layered on prime of the scenario room) you’ll be able to truly entry the entire flash components of the opposite UI from ActionScript. For instance, the principle textual content field within the scenario room may be accessed by means of . ” is the main interface movie (UIInterfaceMgr). You can derive the rest of the path by looking at the UI class in question ( is the s_screenId field in UISituationRoom and ” is the s_name discipline) and the precise Flash itself (” is a child element of ” whenever you have a look at the Flash file in JPEXS). So one doable method so as to add new Flash to an current UI is to layer an invisible flash display on prime of it and tinker with the display “below” by means of ActionScript.

Code Breakdown

Compiled Code

Examples

Resize-in-Place

Altering the State of affairs Room: Written to be used with UPK-Modder, and it is going to be essential to take away the road breaks within the “[BEFORE_HEX]” and “[AFTER_HEX]” sections. Feedback are preceded by double slashes (//) and may be ignored by UPK-Modder.


MODFILEVERSION=4
UPKFILE=UICollection_Strategy_SF.upk
GUID=7B 52 25 96 F3 8E 7C 48 8F 11 3B 40 43 3F BD 3F
FUNCTION=SituationRoom@gfxSituationRoom
RESIZE=18
//
[BEFORE_HEX]
FF 09 A4 00 00 00 39 00 14 00 FF 0A 03 00 00 00
5F 31 00 89 06 06 01 00 38 00 16 92 39 80 40 00
40 00 40 00 40 00 3F 03 02 00 00 00 07 00 40 00
FF 0A 03 00 00 00 5F 32 00 8B 06 16 03 00 38 00
16 EE 39 80 05 00 40 00 40 00 40 00 40 00 3F 03
02 00 00 00 07 00 40 00 FF 0A 03 00 00 00 5F 33
00 8B 06 16 05 00 38 00 16 C0 30 C0 0A 00 40 00
40 00 40 00 40 00 3F 03 02 00 00 00 07 00 40 00
FF 0A 03 00 00 00 5F 34 00 8B 06 16 07 00 38 00
18 8F 5C 2E 0F 00 40 00 40 00 40 00 40 00 3F 03
02 00 00 00 07 00 40 00 00 00
[/BEFORE_HEX]
//
[AFTER_HEX]
FF 09 BC 00 00 00 39 00 06 00 FF 0A 03 00 00 00
5F 31 00 89 06 06 01 00 38 00 16 92 39 80 40 00
3F 03 02 00 00 00 07 00 FF 0A 03 00 00 00 5F 32
00 8B 06 16 03 00 38 00 16 EE 39 80 01 00 40 00
3F 03 02 00 00 00 07 00 FF 0A 03 00 00 00 5F 33
00 8B 06 16 05 00 38 00 16 C0 30 C0 02 00 40 00
3F 03 02 00 00 00 07 00 FF 0A 03 00 00 00 5F 34
00 8B 06 16 07 00 38 00 18 8F 5C 30 03 00 40 00
3F 03 02 00 00 00 07 00 FF 0A 03 00 00 00 5F 35
00 8B 06 16 09 00 38 00 16 C0 02 40 04 00 40 00
3F 03 02 00 00 00 07 00 FF 0A 03 00 00 00 5F 36
00 8B 06 16 0B 00 38 00 18 8F 40 90 05 00 40 00
00 00
[/AFTER_HEX]

In case you are acquainted with hex, you may acknowledge that the FF 09 in the beginning marks the start of a flash-level object block, and the subsequent 4 bytes are the scale of the article, which is altering from A4 to BC. This matches with the RESIZE operation quantity of 18, as 0xA4 + 0x18 == 0xBC.

The thing containing an SWF object has a reasonably lengthy and variable-sized “header” previous the precise embedded SWF file (which has the “FWS” main string changed with “GFX”).

The objectlist entry for “SituationRoom” seems to be like so:

FC FF FF FF             // kind -- Core:SwfMovie@GFxUI
00 00 00 00             // father or mother - none
2A 00 00 00             // proprietor (gfxSituationRoom)
3D 02 00 00 00 00 00 00 // namelist reference ("SituationRoom")
00 00 00 00 00 00 00 00 // unknown
04 00 0F 00             // flags
2B 69 02 00             // object dimension
53 11 69 00             // object place
01 00 00 00             // unknown
00 00 00 00
00 00 00 00
00 00 00 00
00 00 00 00
00 00 00 00
00 00 00 00

Of specific word are the article’s file dimension and file place, that are 0x2692B and 0x691153.

The embedded SWF file begins with:

47 46 58 08 30 67 02 00

47 46 58 in ASCII is “GFX”, the 08 is the model, and the subsequent 4 bytes are (in little endian) the SWF filesize, 0x26730. That is 0x1FB = 507 bytes smaller than the total object. This further 0x1FB bytes is totally contained inside a “header” previous the SWF embedded file inside the object.

The whole hex header is variable dimension, because it comprises string components:

FF FF FF FF 46 00 00 00 00 00 00 00 2D 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 01 C6 01 00
00 00 00 00 00 69 01 00 00 00 00 00 00 04 00 00
00 00 00 00 00 00 04 00 00 94 02 00 00 00 00 00
00 47 00 00 00 00 00 00 00 08 00 00 00 00 00 00
00 D7 00 00 00 00 00 00 00 D8 00 00 00 00 00 00
00 90 02 00 00 00 00 00 00 7E 02 00 00 00 00 00
00 08 00 00 00 00 00 00 00 04 00 00 00 54 47 41
00 0B 02 00 00 00 00 00 00 10 00 00 00 00 00 00
00 8A 00 00 00 00 00 00 00 04 00 00 00 19 00 00
00 67 66 78 63 6F 6D 70 6F 6E 65 6E 74 73 2E 63
6F 6D 70 6F 6E 65 6E 74 73 00 1D 00 00 00 67 66
78 47 61 6D 65 70 61 64 49 63 6F 6E 73 2E 47 61
6D 65 70 61 64 49 63 6F 6E 73 00 29 00 00 00 67
66 78 53 74 72 61 74 65 67 79 43 6F 6D 70 6F 6E
65 6E 74 73 2E 53 74 72 61 74 65 67 79 43 6F 6D
70 6F 6E 65 6E 74 73 00 17 00 00 00 67 66 78 58
43 6F 6D 49 63 6F 6E 73 2E 58 43 6F 6D 49 63 6F
6E 73 00 0C 02 00 00 00 00 00 00 10 00 00 00 00
00 00 00 B4 00 00 00 00 00 00 00 2C 00 00 00 9A
01 00 00 9B 01 00 00 9C 01 00 00 9D 01 00 00 9E
01 00 00 9F 01 00 00 A1 01 00 00 A0 01 00 00 A2
01 00 00 A3 01 00 00 A4 01 00 00 A5 01 00 00 A6
01 00 00 A7 01 00 00 A8 01 00 00 A9 01 00 00 AA
01 00 00 AB 01 00 00 AC 01 00 00 AD 01 00 00 AE
01 00 00 AF 01 00 00 B0 01 00 00 B1 01 00 00 B2
01 00 00 B3 01 00 00 B4 01 00 00 B5 01 00 00 B6
01 00 00 B7 01 00 00 B8 01 00 00 B9 01 00 00 BA
01 00 00 BB 01 00 00 BC 01 00 00 BD 01 00 00 BE
01 00 00 BF 01 00 00 C0 01 00 00 C1 01 00 00 45
00 00 00 4B 00 00 00 70 00 00 00 75 00 00 00 B0
01 00 00 00 00 00 00 30 67 02 00
//
// The above hex shows as the next printable characters:
ÿÿÿÿF.......-...
.............Æ..
.....i..........
.........”......
.G..............
.×.......Ø......
.........~......
.............TGA
................
.Š..............
.gfxcomponents.c
omponents.....gf
xGamepadIcons.Ga
mepadIcons.)...g
fxStrategyCompon
ents.StrategyCom
ponents.....gfxX
ComIcons.XComIco
ns..............
...´.......,...š
...›...œ.......ž
...Ÿ...¡... ...¢
...£...¤...¥...¦
...§...¨...©...ª
...«...¬.......®
...¯...°...±...²
...³...´...µ...¶
...·...¸...¹...º
...»...¼...½...¾
...¿...À...Á...E
...Ok...p...u...°
.......0g..

I am certain there are a number of fascinating parts right here, however what I’m thinking about is the final 4-byte phrase of this “header” : 30 67 02 00, which is the scale of the SWF object inside the UPK-level object.

Therefore there SWF object dimension is definitely declared twice (and instantly adjoining):

30 67 02 00  // finish of upk-object header -- file dimension of SWF film
47 46 58     // starting of SWF file, ASCII "GFX"
08           // model quantity
30 67 02 00  // dimension of SWF film object

The positioning of the file dimension is per the place of an unrealscript filesize — once more it is the ultimate 4-byte phrase of the header. The second occasion of the scale is for the flash interpreter with a view to conform with Flash file specification.

Barely later within the Flash file is a few embedded XML:

<rdf:RDF xmlns_rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> 
<rdf:Description rdf_about=" xmlns_xmp="http://ns.adobe.com/xap/1.0/"> 
<xmp:CreatorTool>Adobe Flash Skilled CS5</xmp:CreatorTool> 
<xmp:CreateDate>2011-11-15T11:20:44-05:00</xmp:CreateDate>

Right here we are able to see that Firaxis is utilizing Adobe Flash Skilled CS5 to create the Flash recordsdata, that are later cooked into the UPK.

At any fee, with a view to resize an object each of those values should be adjusted. For the reason that present RESIZE operation in UPKmodder solely permits a single hex change, if this header is separate from the change (fairly probably), it will require a second-pass modification.

References

Referred to by this text:

  • Modding_Tools_-_XCOM:EU_2012
    • JPEXS_Flash_Decompiler
    • UPK-Modder
  • Open Supply JPEXS Decompiler
  • Checklist of Free SWF Decompilers
  • Present My Code
  • Video_capture_and_edit_tools
  • SWF Actions
  • Assist:Managing_files

That seek advice from this text:

  • Modding_Tools_-_XCOM:EU_2012
  • XComGame.exe
  • Guidelines_for_new_posts_-_XCOM:EU_2012
  • How_to_post_a_new_wiki_page

 


Leave a Reply

Your email address will not be published.