What I want to do is read the content of a binary file to memory... edit the content.. and pass it to an external program as a parameter.
Basically I have an app that should read a file, but I want to modify the content of this file first and then pass it directly to the app without writing it to a file again.
Modifying the content will include encrypting/decrypting.
So I read my file to memory, modified it.. now how do I export it directly?
I need something like std:system("myexternalapp") << memory content
Typically you'd do this by passing the data as a command line parameter:
1 2 3 4
WhateverFunction( "theotherprogram passed_information" );
// system would work for 'WhateverFunction' but you might be better off with ShellExecute
// or something similar.
'passed_information' would wind up in the argv[] of the other program.
If the program doesn't use argv, then you're used and the only option would be to modify whatever file that program uses.
If you own the code of both programs, you could set up interprocess communication between the executables. I know the Windows ones: pipes, shared memory, WM_COPYDATA, the clipboard, and external file, and a few others I'm probably forgetting.
Actually I'm thinking of going a completely different way now...
The point of my program is mainly encryption.
Originally I was thinking of modifying the external app but since it's going to constantly get updated and changed by someone else I need to make my solution as dynamic/modular as possible.
So I don't want to modify the external app and as it only accepts input from a file I'm thinking of creating another file, which will act as a sort of encrypted data storage unit. And save the external file, which I want to encrypt, into my file, decrypting it inside the program and passing it's location to the external app just like it was normally located on the disk...
or something along these lines.. but I have no idea how to actually pull this off...
I don't fully understand what it is exactly that I'm looking for at this point. I have no experience here.
I am looking into Embedded File System (EFS), or something similar maybe.. that would allow me to encrypt a file and access it on-the-fly somehow from within my program so I can give only the external app access to the data.
I suppose this isn't a topic for these forums anymore. However, if anyone has any pointers as to which projects/libs I should be looking at... I would be extremely grateful!
I managed to pass the file to the external app using stdin(modifying the external app)
But I do have one more question now. Would it be possible to load both - the external app and the file to memory - modify the data in memory as it needs to be and then execute the app from memory(so load the app and the file and execute the app from memory)?
this would probably be platform specific right? Any hints :)?