B4J Question #If Obfuscated?

jmon

Well-Known Member
Licensed User
Longtime User
Hello,

Is there was a way to know -by code- if the application has been obfuscated or not?

I would like to execute a customBuildAction when the code is obfuscated and not if it's just compiled in release mode:

B4X:
#If OBFUSCATED
    #CustomBuildAction: 2, myobfuscated.exe,
#End If

#If NOT OBFUSCATED
    #CustomBuildAction: 2, myNOTobfuscated.exe,
#End If

My current alternative option is to run an exe that reads the code and tries to figure out if the code has been obfuscated or not :confused: after compiling...

Thanks for your help
Jmon
 

Daestrum

Expert
Licensed User
Longtime User
Could you check if the ObfuscatorMap.txt file exists ?
 
Upvote 0

jmon

Well-Known Member
Licensed User
Longtime User
I thought about that, but if I obfuscate, then compile normally, the obfuscator map is not deleted (even if I compile in debug it's still there)
 
Upvote 0

Roycefer

Well-Known Member
Licensed User
Longtime User
You can write a little utility that looks at the last time the ObfuscatorMap.txt file was modified. The B4J File Object and the jFileWatcher library allow you to check that info. This utility would run in step 2.

Alternatively, you can write a little utility that is activated in step 1 of the custom build action and runs for (say) 20 seconds. If it observes (using the jFileWatcher library) a modification in the ObfuscatorMap.txt file, it can take some action (like creating an indicator file that some utility running during step 2 will read).
 
Upvote 0

jmon

Well-Known Member
Licensed User
Longtime User
looks at the last time the ObfuscatorMap.txt file was modified
Yes that could be a good techinque.

At the moment I read the main.java file in the src/b4j/example/main.java and see if there is anything named "_vvv*" in it. If yes, then it means it has been obfuscated.
 
Upvote 0
Top