PDA

View Full Version : Hook Maya Export to Encrypt Files


Joviex
10-27-2010, 07:19 PM
Wondering if anyone has any experience in this?

On a review of the export/import mechanisms in the API it does not seem possible to simply hook into the .MA/.MB load/save and encrypt/decrypt before letting Maya parse the file.

I wanted to make it easy:

On a save/export, let maya generate the output, re-directing the stream in memory, then encrypt the result and write it out to the filesystem.

On a reference/load, before Maya parses, grab the file handle, decrypt it in memory, then feed that memory stream to Maya to load.

This does not seem possible with the exposed elements of the MFileObject class.

If they provided a handle to the file, and a way to re-feed their loaders....

Alas, I really dislike the taste in my mouth because it seems I will have to write a complete .MA loader and saver with the only extra step of having it spit out / parse encrypted MEL commands.

....

Anyone have experience or suggestions?

NateH
10-27-2010, 07:32 PM
MSceneMessage.addCheckCallback

kBeforeOpenCheck
kBeforeSaveCheck

If you set the callback result to False, it will block the Maya save. you can write your file out manually here instead, and encrypt it before disk-write. Same for open.

Joviex
10-27-2010, 08:17 PM
MSceneMessage.addCheckCallback

kBeforeOpenCheck
kBeforeSaveCheck

If you set the callback result to False, it will block the Maya save. you can write your file out manually here instead, and encrypt it before disk-write. Same for open.

First off, brilliant. Thanks - seriously.

Problems I have encountered:

addCheckCallback has no file? in the associated callback parameters.

Perhaps you meant:

addCheckFileCallback

which does seem to have at least an MFileObject object.

Am maybe I over complicating this somehow? Is the MFileObject itself a stream that I can then re-parse to encrypt? I just did not see any functionality of it exposed as a stream object.

I did try to output it as a stream, but alas, I am sure I am missing the obvious.

Cheers for the heads up ;p

Joviex
10-27-2010, 10:32 PM
Indeed I still can not find a way to get the information Maya has gathered i.e. the in memory .MA file respresentation.

The example code in the devkit i.e. maTranslator shows that it writes it out line by line at save time, and does not really gather it before hand.

Honestly the writting out part is easy enough because we can create temp files in-house and then encrypt those, line by line.

Its on the other side that I would need something to interrupt the process, especially during referencing.

Ideally, the files are assets. Those assets can only be loaded via a reference, and those reference files use the encrypted format.

I have it working 100% by using temp files for the reading and the writting, but obviously if something fails, or the cleanup process is halted, those raw .MA temp files are exposed, and thus defeats the entire purpose of encrypting them ;p

Cheers

NateH
10-28-2010, 02:19 AM
Yeah, sorry I meant addCheckFileCallback. Glad you figured it out.

Sadly, the only interface to file translators that I have been able to find is the mel file command. You will probably just have to stick with temp files and just make sure to clean any up if the open/close fails for some reason.

I really wish the MFileIO class had some way to read/write some sort of file/buffer object, rather than to disk. But it doesn't seem to :(

Joviex
10-28-2010, 07:21 PM
I really wish the MFileIO class had some way to read/write some sort of file/buffer object, rather than to disk. But it doesn't seem to :(

Yeah this is something I am kinda like, wtf? Obviously all they need to do is expose the handle for the stream and you could re-direct accordingly, but o well....

Looks like I gotta fire them off a few more dev emails.

Cheers!

CGTalk Moderation
10-28-2010, 07:21 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.