Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Bill-Robinson · Aug 21, 2013 at 04:55 PM · c#androidloadingstartupassembly

Hook before Assembly-CSharp.dll is loaded?

A question mainly for Android - is there any way to get some code to run before the main Assembly-CSharp.dll is loaded. We need to encrypt the DLL to dissuade reverse-engineering. I'm reticent to dismantle the bootstrapping code that Unity generates, but this is the only other option I can think of. Has anyone else been here? Needing to do some processing before Mono starts up properly?

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ArkaneX · Aug 21, 2013 at 06:14 PM 0
Share

Do you want to encrypt compiled dll? How is Unity supposed to load it then?

If you meant obfuscation, then it should be done prior to deployment of your app to target device.

avatar image Bill-Robinson · Aug 21, 2013 at 06:26 PM 0
Share

No, the idea is to modify the DLL in the AP$$anonymous$$, encrypt it before we distribute and then decrypt it when the app is started.

3 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by Bill-Robinson · Aug 22, 2013 at 08:20 AM

It looks like this is the way to hook into the startup on android:

http://docs.unity3d.com/Documentation/Manual/PluginsForAndroid.html

Extending the UnityPlayerActivity Java Code

With Unity Android it is possible to extend the standard UnityPlayerActivity class (the primary Java class for the Unity Player on Android, similar to AppController.mm on Unity iOS).

An application can override any and all of the basic interaction between Android OS and Unity Android. You can enable this by creating a new Activity which derives from UnityPlayerActivity

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Bill-Robinson · Aug 22, 2013 at 11:16 AM 0
Share

Except the problem here is that Unity seems to directly access the package code path to get the assets (or via Asset$$anonymous$$anager). $$anonymous$$aybe you can override the getPackageCodePath and specify an alternate location to load assets from, but then you'd have to emulate the entire package and maybe screw with some other systems.... seems very fragile. I've pushed back on this and am looking at obfuscation

avatar image
1

Answer by yurijgera · Nov 12, 2013 at 01:30 AM

if you are going to decrypt entire dll image at runtime (what you normally do) then forget it and dont waste your and time and your customers money with encryption. snapsots of dll images can be easily taken directly from process memory and flushed to file.

obfuscation is definitely the best way to go. I have even seen obfuscator which embeds custom native stubs in nearly all managed routines, making them absolutely invisible to reflector.

Comment
Add comment · Show 5 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image tao.tao · Jun 02, 2015 at 01:59 AM 0
Share

I don't think is so easy, could you tell me how to do this? "snapsots of dll images can be easily taken directly from process memory and flushed to file."

avatar image yurij2 · Jun 02, 2015 at 06:29 AM 0
Share

Is easy and can be done in many ways. For example get "process explorer", start and select target process. Under view enable DLL in lower pane view, add "Base" and "Size" columns. In the dll list find the dll youre looking for. Now you have virtual address base and size of your decrypted dll image. Now you can dump that memory block to dll file with arbitrary memory hex editor, or make your own memory dumper using Win API OpenProcess and ReadProcess$$anonymous$$emory.

avatar image Bill-Robinson · Jun 02, 2015 at 09:20 AM 0
Share

The original question was asking about android.

avatar image yurij2 · Jun 02, 2015 at 02:18 PM 0
Share

sorry missed that. I don't know exact procedure for android (im coding mostly win/linux/qnx). But I read about rooted android memory editos, so accessing external process memory seems possible. The general principle should be applicable to arbitrary XYZ OS: open process memory, locate dll image base and size, dump.

You can also dump the entire process virtual memory. In most OSes with paged memory dll images are loaded at page boundaries (4096 byte) and are protected by guard pages. You just need to scan for ELF signature at boundaries and either parse elf header or dump everything until you hit guard page. And voila - you have images of all loaded dlls of that process.

To cut long story short: look at linux_proc_maps in googles volatility framework. This is the closest android answer I could find.

avatar image thenity yurij2 · Mar 04, 2017 at 03:23 PM 0
Share

that trick doesn't work with Android emulator. The Android emulator does temporary store dll files if you play Unity games

avatar image
0

Answer by Xtro · Aug 21, 2013 at 06:32 PM

if app can decrypt it, people can too. Obfuscation is the only way.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Bill-Robinson · Aug 21, 2013 at 06:55 PM 0
Share

Yes I'm also planning to do this, but we can only obfuscate so far, because we have to maintain the interface between $$anonymous$$ono and the events/methods/classes the scene expects to be there. I do realise that there is no holy grail for protecting code that ultimately has to run on a client's device, and if you really take this seriously, you'll only end up with an arms race, but I have been charged to protect the code. I believe encrypting/fragmenting/encoding/cyphering/hiding the DLL should at least deter many of the more light-weight tamperers.

avatar image Xtro · Aug 21, 2013 at 07:00 PM 0
Share

I'm also interested in if someone can suggest anything other than obfuscation.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

20 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Android game does not load fully sometimes 1 Answer

A lot of time taken by AttributeHelperEngine.GetDefaultExecutionOrderFor() at Android app startup 0 Answers

Load file on Android 1 Answer

Buttons take time to be fully charged at startup 0 Answers

How to change assembly name of Assembly-CSharp.dll 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges