├── .gitattributes
├── .gitignore
├── .gitmodules
├── App.config
├── CSharpObjectForLogin.lua
├── LICENSE
├── Program.cs
├── Properties
└── AssemblyInfo.cs
├── README.md
├── ROMDesCipher.cs
├── ROMEncryption.csproj
├── ROMUnityXor.cs
├── ROMUnlua.cs
└── rom.lua
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.rsuser
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Build results
17 | [Dd]ebug/
18 | [Dd]ebugPublic/
19 | [Rr]elease/
20 | [Rr]eleases/
21 | x64/
22 | x86/
23 | bld/
24 | [Bb]in/
25 | [Oo]bj/
26 | [Ll]og/
27 |
28 | # Visual Studio 2015/2017 cache/options directory
29 | .vs/
30 | # Uncomment if you have tasks that create the project's static files in wwwroot
31 | #wwwroot/
32 |
33 | # Visual Studio 2017 auto generated files
34 | Generated\ Files/
35 |
36 | # MSTest test Results
37 | [Tt]est[Rr]esult*/
38 | [Bb]uild[Ll]og.*
39 |
40 | # NUNIT
41 | *.VisualState.xml
42 | TestResult.xml
43 |
44 | # Build Results of an ATL Project
45 | [Dd]ebugPS/
46 | [Rr]eleasePS/
47 | dlldata.c
48 |
49 | # Benchmark Results
50 | BenchmarkDotNet.Artifacts/
51 |
52 | # .NET Core
53 | project.lock.json
54 | project.fragment.lock.json
55 | artifacts/
56 |
57 | # StyleCop
58 | StyleCopReport.xml
59 |
60 | # Files built by Visual Studio
61 | *_i.c
62 | *_p.c
63 | *_h.h
64 | *.ilk
65 | *.meta
66 | *.obj
67 | *.iobj
68 | *.pch
69 | *.pdb
70 | *.ipdb
71 | *.pgc
72 | *.pgd
73 | *.rsp
74 | *.sbr
75 | *.tlb
76 | *.tli
77 | *.tlh
78 | *.tmp
79 | *.tmp_proj
80 | *_wpftmp.csproj
81 | *.log
82 | *.vspscc
83 | *.vssscc
84 | .builds
85 | *.pidb
86 | *.svclog
87 | *.scc
88 |
89 | # Chutzpah Test files
90 | _Chutzpah*
91 |
92 | # Visual C++ cache files
93 | ipch/
94 | *.aps
95 | *.ncb
96 | *.opendb
97 | *.opensdf
98 | *.sdf
99 | *.cachefile
100 | *.VC.db
101 | *.VC.VC.opendb
102 |
103 | # Visual Studio profiler
104 | *.psess
105 | *.vsp
106 | *.vspx
107 | *.sap
108 |
109 | # Visual Studio Trace Files
110 | *.e2e
111 |
112 | # TFS 2012 Local Workspace
113 | $tf/
114 |
115 | # Guidance Automation Toolkit
116 | *.gpState
117 |
118 | # ReSharper is a .NET coding add-in
119 | _ReSharper*/
120 | *.[Rr]e[Ss]harper
121 | *.DotSettings.user
122 |
123 | # JustCode is a .NET coding add-in
124 | .JustCode
125 |
126 | # TeamCity is a build add-in
127 | _TeamCity*
128 |
129 | # DotCover is a Code Coverage Tool
130 | *.dotCover
131 |
132 | # AxoCover is a Code Coverage Tool
133 | .axoCover/*
134 | !.axoCover/settings.json
135 |
136 | # Visual Studio code coverage results
137 | *.coverage
138 | *.coveragexml
139 |
140 | # NCrunch
141 | _NCrunch_*
142 | .*crunch*.local.xml
143 | nCrunchTemp_*
144 |
145 | # MightyMoose
146 | *.mm.*
147 | AutoTest.Net/
148 |
149 | # Web workbench (sass)
150 | .sass-cache/
151 |
152 | # Installshield output folder
153 | [Ee]xpress/
154 |
155 | # DocProject is a documentation generator add-in
156 | DocProject/buildhelp/
157 | DocProject/Help/*.HxT
158 | DocProject/Help/*.HxC
159 | DocProject/Help/*.hhc
160 | DocProject/Help/*.hhk
161 | DocProject/Help/*.hhp
162 | DocProject/Help/Html2
163 | DocProject/Help/html
164 |
165 | # Click-Once directory
166 | publish/
167 |
168 | # Publish Web Output
169 | *.[Pp]ublish.xml
170 | *.azurePubxml
171 | # Note: Comment the next line if you want to checkin your web deploy settings,
172 | # but database connection strings (with potential passwords) will be unencrypted
173 | *.pubxml
174 | *.publishproj
175 |
176 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
177 | # checkin your Azure Web App publish settings, but sensitive information contained
178 | # in these scripts will be unencrypted
179 | PublishScripts/
180 |
181 | # NuGet Packages
182 | *.nupkg
183 | # The packages folder can be ignored because of Package Restore
184 | **/[Pp]ackages/*
185 | # except build/, which is used as an MSBuild target.
186 | !**/[Pp]ackages/build/
187 | # Uncomment if necessary however generally it will be regenerated when needed
188 | #!**/[Pp]ackages/repositories.config
189 | # NuGet v3's project.json files produces more ignorable files
190 | *.nuget.props
191 | *.nuget.targets
192 |
193 | # Microsoft Azure Build Output
194 | csx/
195 | *.build.csdef
196 |
197 | # Microsoft Azure Emulator
198 | ecf/
199 | rcf/
200 |
201 | # Windows Store app package directories and files
202 | AppPackages/
203 | BundleArtifacts/
204 | Package.StoreAssociation.xml
205 | _pkginfo.txt
206 | *.appx
207 |
208 | # Visual Studio cache files
209 | # files ending in .cache can be ignored
210 | *.[Cc]ache
211 | # but keep track of directories ending in .cache
212 | !*.[Cc]ache/
213 |
214 | # Others
215 | ClientBin/
216 | ~$*
217 | *~
218 | *.dbmdl
219 | *.dbproj.schemaview
220 | *.jfm
221 | *.pfx
222 | *.publishsettings
223 | orleans.codegen.cs
224 |
225 | # Including strong name files can present a security risk
226 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
227 | #*.snk
228 |
229 | # Since there are multiple workflows, uncomment next line to ignore bower_components
230 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
231 | #bower_components/
232 |
233 | # RIA/Silverlight projects
234 | Generated_Code/
235 |
236 | # Backup & report files from converting an old project file
237 | # to a newer Visual Studio version. Backup files are not needed,
238 | # because we have git ;-)
239 | _UpgradeReport_Files/
240 | Backup*/
241 | UpgradeLog*.XML
242 | UpgradeLog*.htm
243 | ServiceFabricBackup/
244 | *.rptproj.bak
245 |
246 | # SQL Server files
247 | *.mdf
248 | *.ldf
249 | *.ndf
250 |
251 | # Business Intelligence projects
252 | *.rdl.data
253 | *.bim.layout
254 | *.bim_*.settings
255 | *.rptproj.rsuser
256 |
257 | # Microsoft Fakes
258 | FakesAssemblies/
259 |
260 | # GhostDoc plugin setting file
261 | *.GhostDoc.xml
262 |
263 | # Node.js Tools for Visual Studio
264 | .ntvs_analysis.dat
265 | node_modules/
266 |
267 | # Visual Studio 6 build log
268 | *.plg
269 |
270 | # Visual Studio 6 workspace options file
271 | *.opt
272 |
273 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
274 | *.vbw
275 |
276 | # Visual Studio LightSwitch build output
277 | **/*.HTMLClient/GeneratedArtifacts
278 | **/*.DesktopClient/GeneratedArtifacts
279 | **/*.DesktopClient/ModelManifest.xml
280 | **/*.Server/GeneratedArtifacts
281 | **/*.Server/ModelManifest.xml
282 | _Pvt_Extensions
283 |
284 | # Paket dependency manager
285 | .paket/paket.exe
286 | paket-files/
287 |
288 | # FAKE - F# Make
289 | .fake/
290 |
291 | # JetBrains Rider
292 | .idea/
293 | *.sln.iml
294 |
295 | # CodeRush personal settings
296 | .cr/personal
297 |
298 | # Python Tools for Visual Studio (PTVS)
299 | __pycache__/
300 | *.pyc
301 |
302 | # Cake - Uncomment if you are using it
303 | # tools/**
304 | # !tools/packages.config
305 |
306 | # Tabs Studio
307 | *.tss
308 |
309 | # Telerik's JustMock configuration file
310 | *.jmconfig
311 |
312 | # BizTalk build output
313 | *.btp.cs
314 | *.btm.cs
315 | *.odx.cs
316 | *.xsd.cs
317 |
318 | # OpenCover UI analysis results
319 | OpenCover/
320 |
321 | # Azure Stream Analytics local run output
322 | ASALocalRun/
323 |
324 | # MSBuild Binary and Structured Log
325 | *.binlog
326 |
327 | # NVidia Nsight GPU debugger configuration file
328 | *.nvuser
329 |
330 | # MFractors (Xamarin productivity tool) working folder
331 | .mfractor/
332 |
333 | # Local History for Visual Studio
334 | .localhistory/
335 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "UtinyRipper"]
2 | path = UtinyRipper
3 | url = https://github.com/zehaoh/UtinyRipper
4 |
--------------------------------------------------------------------------------
/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/CSharpObjectForLogin.lua:
--------------------------------------------------------------------------------
1 | CSharpObjectForLogin = class('CSharpObjectForLogin')
2 |
3 | CSharpObjectForLogin.ins = nil
4 | function CSharpObjectForLogin:Ins()
5 | if CSharpObjectForLogin.ins == nil then
6 | CSharpObjectForLogin.ins = CSharpObjectForLogin.new()
7 | end
8 | return CSharpObjectForLogin
9 | end
10 |
11 | local goGameRoleReadyForLogin = nil
12 | local transCamera = nil
13 | local cameraController = nil
14 |
15 | function CSharpObjectForLogin:Initialize(completeCallback)
16 | self:GetObjects()
17 |
18 | if ObjectsIsGetted then
19 | if completeCallback ~= nil then
20 | completeCallback()
21 | end
22 | else
23 | if self.tick == nil then
24 | self.tick = TimeTickManager.Me():CreateTick(0, 500, self.OnTick, self, 1)
25 | end
26 | self.completeCallback = completeCallback
27 | end
28 | end
29 |
30 | function CSharpObjectForLogin:GetCameraController()
31 | return cameraController
32 | end
33 |
34 | function CSharpObjectForLogin:GetTransCamera()
35 | return transCamera
36 | end
37 |
38 | function CSharpObjectForLogin:Release()
39 | transCamera = nil
40 | cameraController = nil
41 |
42 | GameObject.Destroy(goGameRoleReadyForLogin)
43 | goGameRoleReadyForLogin = nil
44 | end
45 |
46 | function CSharpObjectForLogin:Reset()
47 | self:Release()
48 | end
49 |
50 | function CSharpObjectForLogin:OnTick()
51 | self:GetObjects()
52 |
53 | if self:ObjectsIsGetted() then
54 | TimeTickManager.Me():ClearTick(self, 1)
55 | self.tick = nil
56 |
57 | if self.completeCallback ~= nil then
58 | self.completeCallback()
59 | end
60 | end
61 | end
62 |
63 | function CSharpObjectForLogin:GetObjects()
64 | goGameRoleReadyForLogin = GameObject.Find('GameRoleReadyForLogin(Clone)')
65 | if goGameRoleReadyForLogin ~= nil then
66 | transCamera = goGameRoleReadyForLogin.transform:Find('Camera')
67 | local transCameraController = goGameRoleReadyForLogin.transform:Find('CameraController')
68 | cameraController = transCameraController:GetComponent('CameraControllerForLoginScene')
69 | end
70 | end
71 |
72 | function CSharpObjectForLogin:ObjectsIsGetted()
73 | return goGameRoleReadyForLogin
74 | end
75 |
76 | function resetForLoginUnity()
77 |
78 | end
79 |
80 | autoImport("Table_MainViewButton")
81 | Table_MainViewButton[#Table_MainViewButton + 1] = {
82 | id = #Table_MainViewButton + 1,
83 | name = "Shalzuth",
84 | icon = "setup",
85 | panelid = 630,
86 | redtiptype = _EmptyTable,
87 | Enterhide = _EmptyTable
88 | }
89 |
90 | TEXT_COMMANDS = TEXT_COMMANDS or {}
91 | TEXT_COMMANDS["@test"] = function(params)
92 | local f = io.open("/data/local/tmp/script/rom.lua")
93 | local s = f:read("*a")
94 | f:close()
95 | local f2 = loadstring(s);
96 | if f2~=nil then
97 | local status, err = pcall(f2);
98 | if status == false then
99 | if UIUtil ~= nil then
100 | UIUtil.FloatMsgByText(err);
101 | end;
102 | return false;
103 | else
104 | if UIUtil ~= nil then
105 | UIUtil.FloatMsgByText("Success");
106 | end;
107 | return true;
108 | end;
109 | else
110 | if UIUtil ~= nil then
111 | UIUtil.FloatMsgByText("File failed to load");
112 | end;
113 | return false;
114 | end;
115 | return
116 | end
117 |
118 | autoImport("ChatSystemManager")
119 | function ChatSystemManager:CheckChatContent_Hook(msg)
120 | if msg == "" then
121 | return
122 | end
123 | local is_command = false
124 | local commands = StringUtil.Split(msg, ";")
125 | for k, v in pairs(commands) do
126 | local first_char = string.sub(v, 1, 1)
127 | if first_char == "@" or first_char == "#" or first_char == "/" then
128 | v = string.lower(v)
129 | local params = StringUtil.Split(v, " ")
130 | local cmd = string.gsub(params[1], "[#|/]", "@", 1)
131 | local status, error = pcall(TEXT_COMMANDS[cmd], params)
132 | if not status then
133 | local err = string.format("ERROR EXECUTING CMD: %s\n\nERROR CODE: %s", cmd, error)
134 | TipsView.Me():ShowGeneralHelp(err, "Information")
135 | else
136 | pcall(SETTINGS_SAVE)
137 | end
138 | is_command = true
139 | end
140 | end
141 | return is_command and true or self:CheckChatContent_Orig(msg)
142 | end
143 | ChatSystemManager.CheckChatContent_Orig = ChatSystemManager.CheckChatContent_Orig or ChatSystemManager.CheckChatContent
144 | ChatSystemManager.CheckChatContent = ChatSystemManager.CheckChatContent_Hook
145 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 shalzuth
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Collections.Generic;
4 | namespace ROMEncryption
5 | {
6 | class Program
7 | {
8 | static void DumpFromUnity3d()
9 | {
10 | var files = Directory.EnumerateFiles(@"script2");
11 | foreach (var file in files)
12 | {
13 | UtinyRipper.GameStructure gs = new UtinyRipper.GameStructure();
14 | gs.Load(new List { file });
15 | gs.Export(file.Replace(".unity3d", ""), (a) => { return true; });
16 | Directory.CreateDirectory(@"rawlua\" + Path.GetFileNameWithoutExtension(file));
17 | var innerfiles = Directory.EnumerateFiles(file.Replace(".unity3d", "") + @"\Assets\TextAsset\", "*.bytes");
18 | foreach (var innerFile in innerfiles)
19 | File.Copy(innerFile, @"rawlua\" + Path.GetFileNameWithoutExtension(file) + @"\" + Path.GetFileName(innerFile), true);
20 | Directory.Delete(file.Replace(".unity3d", ""), true);
21 | }
22 | }
23 | static void Main(string[] args)
24 | {
25 | //DumpFromUnity3d(); // takes about 40 seconds.
26 | new System.Net.WebClient().DownloadFile("https://managedway.dl.sourceforge.net/project/unluac/Unstable/unluac_2015_06_13.jar", "unluac_2015_06_13.jar");
27 | // converting all files takes about 10 minutes.
28 | var files = Directory.EnumerateFiles(@"rawlua", "*.bytes", SearchOption.AllDirectories);
29 | foreach (var file in files)
30 | ROMUnlua.Unlua(file);
31 |
32 | ROMUnityXor.DecryptFile(@"com.gravity.romg_1.0.3-308\assets\bin\Data\Managed\Assembly-CSharp-firstpass.dll");
33 | ROMUnityXor.DecryptFile(@"com.gravity.romg_1.0.3-308\assets\bin\Data\Managed\Assembly-CSharp.dll");
34 |
35 | //ROMDesCipher.DecryptFile("CSharpObjectForLogin.bytes");
36 | //ROMDesCipher.EncryptFile("CSharpObjectForLogin.lua");
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("ROMEncryption")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("ROMEncryption")]
13 | [assembly: AssemblyCopyright("Copyright © 2019")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("2ca31889-2cdb-4144-924a-e7bea0fb9c94")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ROMEncryption
2 |
3 | The Unity dll's are XOR'd, and then the main one has some weird encryption on the .text section. I didn't care to figure it out, but you can hardcode the pointer to correct it, and then decompile it with a .NET decompiler.
4 |
5 | The Lua scripts are within the .unity3d files - you will need a .unity3d extractor to dump the raw blobs. The binary blobs can then be decrypted with ROM's custom DES cipher as seen in ROMDesCipher.cs
6 |
7 | All the Lua scripts were also dumped to https://github.com/shalzuth/rom_files
8 |
9 | This can be used to decrypt/re-encrypt the main login Lua script at login/CSharpObjectForLogin.lua, then re-encrypt with the same function, push it back into the unity3d file, then voila! You have Lua scripting within ROM.
10 |
11 | I also included an example modified [CSharpObjectForLogin.lua](https://github.com/shalzuth/ROMEncryption/blob/master/CSharpObjectForLogin.lua#L90-L144) that will load whatever Lua script is at "/data/local/tmp/script/rom.lua" and execute it. Additionally, I've included a [rom.lua](https://github.com/shalzuth/ROMEncryption/blob/master/rom.lua) to show basic functionality of zoom hack, removing fog, and setting the FPS.
12 |
--------------------------------------------------------------------------------
/ROMDesCipher.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Text;
6 |
7 | namespace ROMEncryption
8 | {
9 | public class ROMDesCipher
10 | {
11 | public static Byte[] ROMKey = new Byte[] { 2, 5, 9, 3, 6, 1, 0, 1 };
12 | public static String ROMSig = "czjzgqde";
13 | // without unity header
14 | public static void DecryptFile(String file)
15 | {
16 | var fileBytes = File.ReadAllBytes(file);
17 | var header = fileBytes.Take(12);
18 | var signature = header.Take(8);
19 | if (Encoding.ASCII.GetString(signature.ToArray()) != ROMSig)
20 | throw new Exception("not a valid ROM payload");
21 | var size = BitConverter.ToInt32(header.Skip(8).ToArray(), 0);
22 | var encryptedBytes = fileBytes.Skip(12).ToArray();
23 | var cipher = new ROMDesCipher(ROMKey, 8);
24 | var decryptedBytes = cipher.Decrypt(encryptedBytes);
25 | File.WriteAllBytes(file.Replace(".bytes","") + ".lua", decryptedBytes.Take(size).ToArray());
26 | }
27 | // with unity header
28 | public static void EncryptFile(String file)
29 | {
30 | var fileName = Path.GetFileNameWithoutExtension(file);
31 | var unityBlob = new List();
32 | unityBlob.AddRange(BitConverter.GetBytes(fileName.Length));
33 | unityBlob.AddRange(Encoding.ASCII.GetBytes(fileName));
34 | var pad = 8 - ((unityBlob.Count - 1) % 8) - 1;
35 | unityBlob.AddRange(Enumerable.Range(0, pad).Select(i => (Byte)0).ToList());
36 |
37 | var bytes = File.ReadAllBytes(file).ToList();
38 | var size = bytes.Count;
39 | pad = 8 - ((bytes.Count - 1) % 8) - 1;
40 | bytes.AddRange(Enumerable.Range(0, pad).Select(i => (Byte)0).ToList());
41 | var cipher = new ROMDesCipher(ROMKey, 8);
42 | var encryptedBytes = cipher.Encrypt(bytes.ToArray());
43 | var payload = new List();
44 | payload.AddRange(Encoding.ASCII.GetBytes(ROMSig));
45 | payload.AddRange(BitConverter.GetBytes(size));
46 | payload.AddRange(encryptedBytes);
47 |
48 | unityBlob.AddRange(BitConverter.GetBytes(payload.Count));
49 | unityBlob.AddRange(payload);
50 |
51 | File.WriteAllBytes(file.Replace(".lua","") + ".bytes", unityBlob.ToArray());
52 | }
53 | private UInt32[] EncryptionKey;
54 | private UInt32[] DecryptionKey;
55 | public Byte[] Key;
56 | public UInt16 BlockSize;
57 | private static readonly Byte[] PermutatedChoice1 =
58 | {
59 | 0x38, 0x30, 0x28, 0x20, 0x18, 0x10, 0x08, 0x00, 0x39, 0x31, 0x29, 0x21, 0x19, 0x11, 0x09, 0x01,
60 | 0x3A, 0x32, 0x2A, 0x22, 0x1A, 0x12, 0x0A, 0x02, 0x3B, 0x33, 0x2B, 0x23, 0x3E, 0x36, 0x2E, 0x26,
61 | 0x1E, 0x16, 0x0E, 0x06, 0x3D, 0x35, 0x2D, 0x25, 0x1D, 0x15, 0x0D, 0x05, 0x3C, 0x34, 0x2C, 0x24,
62 | 0x1C, 0x14, 0x0C, 0x04, 0x1B, 0x13, 0x0B, 0x03
63 | };
64 |
65 | private static readonly Byte[] NumLeftRotations =
66 | {
67 | 0x01, 0x02, 0x04, 0x06, 0x08, 0x0a, 0x0c, 0x0e,
68 | 0x0f, 0x11, 0x13, 0x15, 0x17, 0x19, 0x1b, 0x1c
69 | };
70 |
71 | private static readonly Byte[] PermutatedChoice2 =
72 | {
73 | 0x0D, 0x10, 0x0A, 0x17, 0x00, 0x04, 0x02, 0x1B, 0x0E, 0x05, 0x14, 0x09, 0x16, 0x12, 0x0B, 0x03,
74 | 0x19, 0x07, 0x0F, 0x06, 0x1A, 0x13, 0x0C, 0x01, 0x28, 0x33, 0x1E, 0x24, 0x2E, 0x36, 0x1D, 0x27,
75 | 0x32, 0x2C, 0x20, 0x2F, 0x2B, 0x30, 0x26, 0x37, 0x21, 0x34, 0x2D, 0x29, 0x31, 0x23, 0x1C, 0x1F
76 | };
77 | private static readonly UInt32[,] SPBox =
78 | { {
79 | 0x01010400, 0x00000000, 0x00010000, 0x01010404, 0x01010004, 0x00010404, 0x00000004, 0x00010000,
80 | 0x00000400, 0x01010400, 0x01010404, 0x00000400, 0x01000404, 0x01010004, 0x01000000, 0x00000004,
81 | 0x00000404, 0x01000400, 0x01000400, 0x00010400, 0x00010400, 0x01010000, 0x01010000, 0x01000404,
82 | 0x00010004, 0x01000004, 0x01000004, 0x00010004, 0x00000000, 0x00000404, 0x00010404, 0x01000000,
83 | 0x00010000, 0x01010404, 0x00000004, 0x01010000, 0x01010400, 0x01000000, 0x01000000, 0x00000400,
84 | 0x01010004, 0x00010000, 0x00010400, 0x01000004, 0x00000400, 0x00000004, 0x01000404, 0x00010404,
85 | 0x01010404, 0x00010004, 0x01010000, 0x01000404, 0x01000004, 0x00000404, 0x00010404, 0x01010400,
86 | 0x00000404, 0x01000400, 0x01000400, 0x00000000, 0x00010004, 0x00010400, 0x00000000, 0x01010004
87 | },{
88 | 0x80108020, 0x80008000, 0x00008000, 0x00108020, 0x00100000, 0x00000020, 0x80100020, 0x80008020,
89 | 0x80000020, 0x80108020, 0x80108000, 0x80000000, 0x80008000, 0x00100000, 0x00000020, 0x80100020,
90 | 0x00108000, 0x00100020, 0x80008020, 0x00000000, 0x80000000, 0x00008000, 0x00108020, 0x80100000,
91 | 0x00100020, 0x80000020, 0x00000000, 0x00108000, 0x00008020, 0x80108000, 0x80100000, 0x00008020,
92 | 0x00000000, 0x00108020, 0x80100020, 0x00100000, 0x80008020, 0x80100000, 0x80108000, 0x00008000,
93 | 0x80100000, 0x80008000, 0x00000020, 0x80108020, 0x00108020, 0x00000020, 0x00008000, 0x80000000,
94 | 0x00008020, 0x80108000, 0x00100000, 0x80000020, 0x00100020, 0x80008020, 0x80000020, 0x00100020,
95 | 0x00108000, 0x00000000, 0x80008000, 0x00008020, 0x80000000, 0x80100020, 0x80108020, 0x00108000
96 | },{
97 | 0x00000208, 0x08020200, 0x00000000, 0x08020008, 0x08000200, 0x00000000, 0x00020208, 0x08000200,
98 | 0x00020008, 0x08000008, 0x08000008, 0x00020000, 0x08020208, 0x00020008, 0x08020000, 0x00000208,
99 | 0x08000000, 0x00000008, 0x08020200, 0x00000200, 0x00020200, 0x08020000, 0x08020008, 0x00020208,
100 | 0x08000208, 0x00020200, 0x00020000, 0x08000208, 0x00000008, 0x08020208, 0x00000200, 0x08000000,
101 | 0x08020200, 0x08000000, 0x00020008, 0x00000208, 0x00020000, 0x08020200, 0x08000200, 0x00000000,
102 | 0x00000200, 0x00020008, 0x08020208, 0x08000200, 0x08000008, 0x00000200, 0x00000000, 0x08020008,
103 | 0x08000208, 0x00020000, 0x08000000, 0x08020208, 0x00000008, 0x00020208, 0x00020200, 0x08000008,
104 | 0x08020000, 0x08000208, 0x00000208, 0x08020000, 0x00020208, 0x00000008, 0x08020008, 0x00020200
105 | },{
106 | 0x00802001, 0x00002081, 0x00002081, 0x00000080, 0x00802080, 0x00800081, 0x00800001, 0x00002001,
107 | 0x00000000, 0x00802000, 0x00802000, 0x00802081, 0x00000081, 0x00000000, 0x00800080, 0x00800001,
108 | 0x00000001, 0x00002000, 0x00800000, 0x00802001, 0x00000080, 0x00800000, 0x00002001, 0x00002080,
109 | 0x00800081, 0x00000001, 0x00002080, 0x00800080, 0x00002000, 0x00802080, 0x00802081, 0x00000081,
110 | 0x00800080, 0x00800001, 0x00802000, 0x00802081, 0x00000081, 0x00000000, 0x00000000, 0x00802000,
111 | 0x00002080, 0x00800080, 0x00800081, 0x00000001, 0x00802001, 0x00002081, 0x00002081, 0x00000080,
112 | 0x00802081, 0x00000081, 0x00000001, 0x00002000, 0x00800001, 0x00002001, 0x00802080, 0x00800081,
113 | 0x00002001, 0x00002080, 0x00800000, 0x00802001, 0x00000080, 0x00800000, 0x00002000, 0x00802080
114 | },{
115 | 0x00000100, 0x02080100, 0x02080000, 0x42000100, 0x00080000, 0x00000100, 0x40000000, 0x02080000,
116 | 0x40080100, 0x00080000, 0x02000100, 0x40080100, 0x42000100, 0x42080000, 0x00080100, 0x40000000,
117 | 0x02000000, 0x40080000, 0x40080000, 0x00000000, 0x40000100, 0x42080100, 0x42080100, 0x02000100,
118 | 0x42080000, 0x40000100, 0x00000000, 0x42000000, 0x02080100, 0x02000000, 0x42000000, 0x00080100,
119 | 0x00080000, 0x42000100, 0x00000100, 0x02000000, 0x40000000, 0x02080000, 0x42000100, 0x40080100,
120 | 0x02000100, 0x40000000, 0x42080000, 0x02080100, 0x40080100, 0x00000100, 0x02000000, 0x42080000,
121 | 0x42080100, 0x00080100, 0x42000000, 0x42080100, 0x02080000, 0x00000000, 0x40080000, 0x42000000,
122 | 0x00080100, 0x02000100, 0x40000100, 0x00080000, 0x00000000, 0x40080000, 0x02080100, 0x40000100
123 | },{
124 | 0x20000010, 0x20400000, 0x00004000, 0x20404010, 0x20400000, 0x00000010, 0x20404010, 0x00400000,
125 | 0x20004000, 0x00404010, 0x00400000, 0x20000010, 0x00400010, 0x20004000, 0x20000000, 0x00004010,
126 | 0x00000000, 0x00400010, 0x20004010, 0x00004000, 0x00404000, 0x20004010, 0x00000010, 0x20400010,
127 | 0x20400010, 0x00000000, 0x00404010, 0x20404000, 0x00004010, 0x00404000, 0x20404000, 0x20000000,
128 | 0x20004000, 0x00000010, 0x20400010, 0x00404000, 0x20404010, 0x00400000, 0x00004010, 0x20000010,
129 | 0x00400000, 0x20004000, 0x20000000, 0x00004010, 0x20000010, 0x20404010, 0x00404000, 0x20400000,
130 | 0x00404010, 0x20404000, 0x00000000, 0x20400010, 0x00000010, 0x00004000, 0x20400000, 0x00404010,
131 | 0x00004000, 0x00400010, 0x20004010, 0x00000000, 0x20404000, 0x20000000, 0x00400010, 0x20004010
132 | },{
133 | 0x00200000, 0x04200002, 0x04000802, 0x00000000, 0x00000800, 0x04000802, 0x00200802, 0x04200800,
134 | 0x04200802, 0x00200000, 0x00000000, 0x04000002, 0x00000002, 0x04000000, 0x04200002, 0x00000802,
135 | 0x04000800, 0x00200802, 0x00200002, 0x04000800, 0x04000002, 0x04200000, 0x04200800, 0x00200002,
136 | 0x04200000, 0x00000800, 0x00000802, 0x04200802, 0x00200800, 0x00000002, 0x04000000, 0x00200800,
137 | 0x04000000, 0x00200800, 0x00200000, 0x04000802, 0x04000802, 0x04200002, 0x04200002, 0x00000002,
138 | 0x00200002, 0x04000000, 0x04000800, 0x00200000, 0x04200800, 0x00000802, 0x00200802, 0x04200800,
139 | 0x00000802, 0x04000002, 0x04200802, 0x04200000, 0x00200800, 0x00000000, 0x00000002, 0x04200802,
140 | 0x00000000, 0x00200802, 0x04200000, 0x00000800, 0x04000002, 0x04000800, 0x00000800, 0x00200002
141 | },{
142 | 0x10001040, 0x00001000, 0x00040000, 0x10041040, 0x10000000, 0x10001040, 0x00000040, 0x10000000,
143 | 0x00040040, 0x10040000, 0x10041040, 0x00041000, 0x10041000, 0x00041040, 0x00001000, 0x00000040,
144 | 0x10040000, 0x10000040, 0x10001000, 0x00001040, 0x00041000, 0x00040040, 0x10040040, 0x10041000,
145 | 0x00001040, 0x00000000, 0x00000000, 0x10040040, 0x10000040, 0x10001000, 0x00041040, 0x00040000,
146 | 0x00041040, 0x00040000, 0x10041000, 0x00001000, 0x00000040, 0x10040040, 0x00001000, 0x00041040,
147 | 0x10001000, 0x00000040, 0x10000040, 0x10040000, 0x10040040, 0x10000000, 0x00040000, 0x10001040,
148 | 0x00000000, 0x10041040, 0x00040040, 0x10000040, 0x10040000, 0x10001000, 0x10001040, 0x00000000,
149 | 0x10041040, 0x00041000, 0x00041000, 0x00001040, 0x00001040, 0x00040040, 0x10000000, 0x10041000
150 | } };
151 | public ROMDesCipher(Byte[] key, UInt16 blockSize)
152 | {
153 | Key = key;
154 | BlockSize = blockSize;
155 | EncryptionKey = GenerateKey(true, Key);
156 | DecryptionKey = GenerateKey(false, Key);
157 | }
158 | public Byte[] Decrypt(Byte[] data)
159 | {
160 | return Crypt(data, false);
161 | }
162 | public Byte[] Encrypt(Byte[] data)
163 | {
164 | return Crypt(data, true);
165 | }
166 | public Byte[] Crypt(Byte[] data, Boolean encrypt)
167 | {
168 | var CryptedData = new Byte[data.Length];
169 | var CryptKey = encrypt ? EncryptionKey : DecryptionKey;
170 | for (int i = 0; i < data.Length / BlockSize; i++)
171 | DesFunc(CryptKey, data, i * BlockSize, CryptedData, i * BlockSize);
172 | return CryptedData;
173 | }
174 | protected UInt32[] GenerateKey(Boolean encrypt, Byte[] key)
175 | {
176 | var newKey = new UInt32[32];
177 | var pc1m = new Boolean[56];
178 | var pcr = new Boolean[56];
179 |
180 | for (var j = 0; j < 56; j++)
181 | {
182 | var l = PermutatedChoice1[j];
183 | pc1m[j] = (key[l >> 3] & (1 << (l & 7))) != 0;
184 | }
185 |
186 | for (var i = 0; i < 16; i++)
187 | {
188 | var m = (15 - i) << 1;
189 | if (encrypt)
190 | m = i << 1;
191 | var n = m + 1;
192 | newKey[m] = newKey[n] = 0;
193 | var l = 0u + NumLeftRotations[i];
194 | for (var j = 0u; j < 28; j++)
195 | {
196 | l = j + NumLeftRotations[i];
197 | if (l < 28)
198 | pcr[j] = pc1m[l];
199 | else
200 | pcr[j] = pc1m[l - 28];
201 | }
202 |
203 | for (var j = 28u; j < 56; j++)
204 | {
205 | l = j + NumLeftRotations[i];
206 | if (l < 56)
207 | pcr[j] = pc1m[l];
208 | else
209 | pcr[j] = pc1m[l - 28];
210 | }
211 |
212 | for (var j = 0; j < 24; j++)
213 | {
214 | if (pcr[PermutatedChoice2[j]])
215 | newKey[m] |= 0x800000u >> j;
216 | if (pcr[PermutatedChoice2[j + 24]])
217 | newKey[n] |= 0x800000u >> j;
218 | }
219 | }
220 | for (var i = 0; i != 32; i += 2)
221 | {
222 | var i1 = newKey[i];
223 | var i2 = newKey[i + 1];
224 |
225 | newKey[i] = ((i1 & 0x00fc0000) << 6) |
226 | ((i1 & 0x00000fc0) << 10) |
227 | ((i2 & 0x00fc0000) >> 10) |
228 | ((i2 & 0x00000fc0) >> 6);
229 |
230 | newKey[i + 1] = ((i1 & 0x0003f000) << 12) |
231 | ((i1 & 0x0000003f) << 16) |
232 | ((i2 & 0x0003f000) >> 4) |
233 | (i2 & 0x0000003f);
234 | }
235 | return newKey;
236 | }
237 | protected static void DesFunc(UInt32[] wKey, Byte[] input, Int32 inOff, Byte[] outBytes, Int32 outOff)
238 | {
239 | Array.Reverse(input, inOff, 4);
240 | var left = BitConverter.ToUInt32(input, inOff);
241 | Array.Reverse(input, inOff + 4, 4);
242 | var right = BitConverter.ToUInt32(input, inOff + 4);
243 |
244 | var work = (right ^ (left >> 4)) & 0x0f0f0f0f;
245 | right = work ^ right;
246 | left = left ^ 16 * work;
247 | work = (right ^ (left >> 16)) & 0x0000ffff;
248 | right = work ^ right;
249 | left = left ^ (work << 16);
250 | work = (left ^ (right >> 2)) & 0x33333333;
251 | left = work ^ left;
252 | right = right ^ 4 * work;
253 | work = (left ^ (right >> 8)) & 0x00ff00ff;
254 | left = work ^ left;
255 | right = right ^ (work << 8);
256 | right = (right << 1) | (right >> 31);
257 | work = (left ^ right) & 0xaaaaaaaa;
258 | right = right ^ work;
259 | left = work ^ left;
260 | left = (left << 1) | (left >> 31);
261 | for (var round = 0; round < 8; round++)
262 | {
263 | work = (right << 28) | (right >> 4);
264 | work = wKey[round * 4 + 0] ^ work;
265 | var fval = SPBox[6, work & 0x3f];
266 | fval |= SPBox[4, (work >> 8) & 0x3f];
267 | fval |= SPBox[2, (work >> 16) & 0x3f];
268 | fval |= SPBox[0, (work >> 24) & 0x3f];
269 | work = wKey[round * 4 + 1] ^ right;
270 | fval |= SPBox[7, work & 0x3f];
271 | fval |= SPBox[5, (work >> 8) & 0x3f];
272 | fval |= SPBox[3, (work >> 16) & 0x3f];
273 | fval |= SPBox[1, (work >> 24) & 0x3f];
274 | left ^= fval;
275 | work = (left << 28) | (left >> 4);
276 | work = wKey[round * 4 + 2] ^ work;
277 | fval = SPBox[6, work & 0x3f];
278 | fval |= SPBox[4, (work >> 8) & 0x3f];
279 | fval |= SPBox[2, (work >> 16) & 0x3f];
280 | fval |= SPBox[0, (work >> 24) & 0x3f];
281 | work = wKey[round * 4 + 3] ^ left;
282 | fval |= SPBox[7, work & 0x3f];
283 | fval |= SPBox[5, (work >> 8) & 0x3f];
284 | fval |= SPBox[3, (work >> 16) & 0x3f];
285 | fval |= SPBox[1, (work >> 24) & 0x3f];
286 | right ^= fval;
287 | }
288 |
289 | right = (right << 31) | (right >> 1);
290 | work = (left ^ right) & 0xaaaaaaaa;
291 | right = work ^ right;
292 | left = work ^ left;
293 | left = (left << 31) | (left >> 1);
294 | work = (right ^ (left >> 8)) & 0x00ff00ff;
295 | right = work ^ right;
296 | left = left ^ (work << 8);
297 | work = (right ^ (left >> 2)) & 0x33333333;
298 | right = work ^ right;
299 | left = left ^ 4 * work;
300 | work = (left ^ (right >> 16)) & 0x0000ffff;
301 | left = work ^ left;
302 | right = right ^ (work << 16);
303 | work = (left ^ (right >> 4)) & 0x0f0f0f0f;
304 | left = work ^ left;
305 | right = right ^ 16 * work;
306 |
307 | Array.Copy(BitConverter.GetBytes(right), 0, outBytes, outOff, 4);
308 | Array.Reverse(outBytes, outOff, 4);
309 | Array.Copy(BitConverter.GetBytes(left), 0, outBytes, outOff + 4, 4);
310 | Array.Reverse(outBytes, outOff + 4, 4);
311 | }
312 | }
313 | }
314 |
--------------------------------------------------------------------------------
/ROMEncryption.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {2CA31889-2CDB-4144-924A-E7BEA0FB9C94}
8 | Exe
9 | ROMEncryption
10 | ROMEncryption
11 | v4.7
12 | 512
13 | true
14 | true
15 |
16 |
17 | AnyCPU
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 |
26 |
27 | AnyCPU
28 | pdbonly
29 | true
30 | bin\Release\
31 | TRACE
32 | prompt
33 | 4
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 | {ca9420f4-4b54-4727-91e6-cce20916d795}
58 | UtinyRipperCore
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/ROMUnityXor.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Text;
6 |
7 | namespace ROMEncryption
8 | {
9 | public static class ROMUnityXor
10 | {
11 | public static Byte[] ROMXorKey = new Byte[] { 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87 };
12 | public static void XorChain(Byte[] input, Byte[] xorChain)
13 | {
14 | for (int i = 0; i < input.Length; i++)
15 | {
16 | var xorChainOffset = i % xorChain.Length;
17 | input[i] = (Byte)(input[i] ^ xorChain[xorChainOffset]);
18 | }
19 | }
20 | public static void FixHeader(Byte[] fileBytes)
21 | {
22 | // not sure, correct header? still partially encrypted, but hardcoding this hack...
23 | fileBytes[0] = 0x4d;
24 | fileBytes[1] = 0x5a;
25 | fileBytes[2] = 0x90;
26 | fileBytes[3] = 0;
27 | fileBytes[4] = 3;
28 | fileBytes[5] = 0;
29 |
30 | var sigIndex = 0;
31 | for (int i = 0; i < fileBytes.Length - 4; i++)
32 | {
33 | if (Encoding.ASCII.GetString(fileBytes, i, 4) == "BSJB")
34 | {
35 | sigIndex = i;
36 | break;
37 | }
38 | }
39 | var cor20Header = BitConverter.ToUInt32(fileBytes, 0x18c);
40 | var virtualAddress = BitConverter.ToUInt32(fileBytes, 0x184);
41 | var metadataAddr = sigIndex + virtualAddress - cor20Header;
42 | var metadataAddrBytes = BitConverter.GetBytes(metadataAddr);
43 | var oldMetadataAddr = BitConverter.ToUInt32(fileBytes, (int)cor20Header + 0x10);
44 | Array.Copy(metadataAddrBytes, 0, fileBytes, cor20Header + 0x10, 4);
45 | }
46 | public static void DecryptFile(String file)
47 | {
48 | var fileBytes = File.ReadAllBytes(file).Skip(0x10).ToArray();
49 | XorChain(fileBytes, ROMXorKey);
50 | FixHeader(fileBytes);
51 | File.WriteAllBytes(file.Replace(".dll", ".fixed.dll"), fileBytes);
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/ROMUnlua.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using System.IO;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 |
9 | namespace ROMEncryption
10 | {
11 | public static class ROMUnlua
12 | {
13 | public static void Unlua(String file)
14 | {
15 | Console.WriteLine(file);
16 | var origFile = File.ReadAllBytes(file);
17 | if (origFile[0] != 0x2a)
18 | throw new Exception("2a file header not found");
19 | var luac = new List { 0x1B, 0x4C, 0x75, 0x61, 0x53, 0x00, 0x19, 0x93,
20 | 0x0D, 0x0A, 0x1A, 0x0A, 0x04, 0x04, 0x04, 0x08,
21 | 0x08, 0x78, 0x56, 0x00, 0x00, 0x00, 0x00, 0x00,
22 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x77, 0x40, 0x01, 0x00 };
23 | var path = Encoding.ASCII.GetString(origFile.Skip(1).Skip(0x100).TakeWhile(b => b != 0).ToArray()).Substring(1).Replace("/", @"\");
24 | luac.AddRange(origFile.Skip(1).Skip(0x100).SkipWhile(b=>b != 0));
25 | var luacFile = file.Replace(".bytes", "") + ".luac";
26 | File.WriteAllBytes(luacFile, luac.ToArray());
27 | var p = new Process();
28 | p.StartInfo = new ProcessStartInfo(@"java.exe", "-jar unluac_2015_06_13.jar " + luacFile);
29 | p.StartInfo.UseShellExecute = false;
30 | p.StartInfo.RedirectStandardOutput = true;
31 | p.Start();
32 | //p.WaitForExit();
33 | var lua = p.StandardOutput.ReadToEnd();
34 | File.WriteAllText(luacFile.Replace("luac", "lua"), lua);
35 | //Directory.CreateDirectory(Path.GetDirectoryName(path));
36 | //File.WriteAllText(path, o);
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/rom.lua:
--------------------------------------------------------------------------------
1 | -- CameraController.singletonInstance.zoomMin = 0.1;
2 | -- UnityEngine.Application.targetFrameRate = 60.0;
3 | -- RenderSettings.fog = false;
4 |
5 | if DebugLog == nil then
6 | DebugLog = {};
7 | DebugLog.File = io.open("/data/local/tmp/script/rom.log", "a");
8 | DebugLog.Write = function(data)
9 | DebugLog.File:write(os.date("%x %X") .. ' ' .. data .. "\n");
10 | DebugLog.File:flush();
11 | end;
12 | end;
13 | if Game~=nil and Game.me~=nil then
14 | DebugLog.Write(tostring(Game.me));
15 | end;
16 |
17 | function SetFrameRate(fps)
18 | UnityEngine.Application.targetFrameRate = fps;
19 | end;
20 |
21 | function ZoomHack(apply)
22 | if apply then
23 | CameraController.singletonInstance.zoomMin = 0.1;
24 | else
25 | CameraController.singletonInstance.zoomMin = 0.7;
26 | end
27 | end;
28 |
29 | function RemoveFog()
30 | RenderSettings.fog = false;
31 | end;
32 |
33 | ZoomHack(true);
34 | RemoveFog();
35 | SetFrameRate(60.0);
36 |
37 |
38 | DebugLog.Write("loaded");
39 |
40 |
--------------------------------------------------------------------------------