Add something to my *.rbs file
-
As in title, can I add some command (something like
@@a="my text" run_my_function(@@a) end end
to my already scrambled plugin?
-
The question is not asked using the proper terms.
(1) DISKFILE:
The scrambled file cannot be modified after encryption. File encryption (aka scrambling,) is a disk file protection only. With SketchUp version 2016 and higher, a signature hash is generated for most executable files in the plugin sub-folder. This hash is checked against the files for any changes, and if the files have been changed, then the plugin may not load, depending upon the user's extension load security policy setting.
During extension load, the rbs file is decrypted into plain text Ruby code in memory, and then passed to Ruby for evaluation, IF the extension load policy check was verified.
(2) RUBY OBJECTS:
Ruby is a dynamic programming language.
This means that Ruby objects (like modules and classes,) can be opened for editing during runtime, and modified. Such modifications can be adding, overriding or deleting methods; adding, changing or removing constants pointing at other objects of various kinds; adding or changing variables (instance or class vars); defining entirely new classes and modules, etc.
SO, your plugin is loaded from a scrambled rbs file, which creates some plugin sub-module inside your author/company toplevel module. Inside this there is some functionality accessed via a method call.
Later on, some other file (scrambled or not,) from another one of your plugins, or some statements executed in the Ruby Console, CAN modify the Ruby objects in memory that the previous rbs file created.
But, the modifying code should be sure to first test the Ruby ObjectSpace, for the presence of the Ruby object (usually a module) to modified. A simple
if
block can do it.if defined?(BomaStudio;;SomePlugin) BomaStudio;;SomePlugin.module_eval { # code to evaluate within your submodule @@a="my text" run_my_function(@@a) } end
Okay?
There is one caveat. Module and Class definitions can be
frozen
to prevent runtime modifications, and there is no way to unfreeze objects at runtime. So objects to be modified must not have been frozen.Follow proper etiquette !
Do not modify the classes and modules of: the Ruby core or standard Libraries; of other authors or companies; and especially the Trimble SketchUp Ruby API.
-
Dan you are definitely the best teacher on Programming I've ever meet! "Show why to do something rather than show HOW to do it!"
OK. So I can modify a lots of in-memory stuff from my main *.rbs "on runtime".
-
Answering your question as it is phrased, the answer is 'No'.
How would you write it into an encrypted RBS file's code?
However, answering the question which I believe you are really asking - 'Can I set a class variable in my RB, then encrypt it as RBS, then change its value later - in a method each time that class's code 'runs'... ?'
Then the answer is 'Yes'.module TomaStudio class SomeTool @@a = "my text" ### which is reusable/set-able when used later... ### some methods ? def run_my_function(a) puts a ### etc end run_my_function(@@a) ### if desired, but it can be called in another method too... end end
-
Thanks for reply. I'm a bit confused ... resuming everythings:
I have my ruby *.rb extension. I want to protect it form piracy. So I scramble it (I discovered with my surprise that SU>2015+ has new APIs for it.....waiting for Trimble approval of my Developer status).....
But meanwhile, using the "old" *.rbs files..... each user needs to get a personalized, with its own datas (personal and hardware), rbs file.
So, I think to use my personal server, hosting the Scrambler.exe, and using PHP+POST methods retrieve user infos, send it to the server, work on it somewhat, scramble the extension and finally return it to the user ONE-PER-USER....
Theorically it seems to be good (to me) but my trouble starts as I have a Linux server and the Scrambler is and *.exe..... but.... Linux+Wine works like a charm (tested by me)..... so the final question was "How I can build everythings in PHP?".... making it simple.... RaspberryPI can use Wine ONLY into a chrooted environment....and PHP seems not to like it.....
So I'm looking for a different strategy....
I have read all your suggestions and ..... I'm trying to design a way to work.....
Why I decided to be a software developer?..... I have to design airplane.....I have to design airplane....
-
So to recap my understanding.
You hope[d] to somehow edit a copy of your main RB file, and from that make individually customized scrambled RBS files.
This is actually possible.
But your RBS files, put within your distributed RBZ archive cannot be 'signed' for use in >=v2016 [all loading-policies]... unless you actually submit each one of the RBZ files separately and on receipt then send it to your individual user.Here's an idea...
RBZ contents as follows...
MyLovelyTool.rb == the 'loader' MyLovelyTool == the subfolder containing... MyLovelyTool_main_code.rb == compiled by the signing process to RBS or RBE if limited to >=v2016 MyLovelyTool.hash == the signed file referencing all .rb/rbs/rbe/js.htm.html.css files in the RBZ AND MyLovelyTool_user_data.rbs == which you make from an RB on a per user basis - containing the individual details you want... It contains the same module/class set up as the main_code and simply sets the @@a or whatever. The main_code uses Sketchup;;require('MyLovely_user_data') as it initially loads, so that the customized details are used...
This way the main IP relevant main)code can be RBS or RBE and incorporated in the signing hash, and the user_data can be somewhat obfuscated in your own RBS which is added to the signed RBZ later on...
It will still be loaded by the signed file, while containing individual details.Be aware that RBS made by your old scrambler exe is readily crack-able, but probably sufficient obfuscation in your case - certainly better than a plain RB - which'd be easily editable.
You can't make a securely encrypted RBE version without going through the signing/encryption process via the web-site.
You could have course make mock RBZs for each user with a matching MyLovelyTool_user_data subfolder and submit those for signing/RBEing, then use just the RBE... adding it to the main RBZ before giving it to the user...
BUT this route seems too much effort for little benefit...There must be an easier way to do this !
Advertisement