I was wondering how I would go about saving data within an executable, I'm not exactly sure If I happen to be wording this right so I will elaborate.

For example lets say I had an application that would ftp upload specified files, but I did not want to use the registry, configuration files, databases etc to store the user's credentials, which then saving it inside itself, or having an external program to edit the said uploader would be resolve that problem.

If I had not stated my problem in enough detail, or anything related to that please tell me and I will attempt to write it out better :)

Thanks, Fallen

Recommended Answers

All 12 Replies

Well why not just save it in a encrypted file? Keeps everything separate from getting lost.

Well why not just save it in a encrypted file? Keeps everything separate from getting lost.

True, but im looking for a PoC in a weird way, I need to do it in that specific way, no alternatives

What you're asking for really is advanced programming, using an encrypted file (like MosaicFuneral said) will probably a much more simpler and less error-prone way to achieve the same thing ...

True, but im looking for a PoC in a weird way, I need to do it in that specific way, no alternatives

Okay, but what OS are you on?
You could append the data to the end of the file, spread it through out unused header crap, or:
create your own section and declare a variable(preferably a string) inside of there, look up the section and overwrite the values with the new values.

What you're asking for really is advanced programming, using an encrypted file (like MosaicFuneral said) will probably a much more simpler and less error-prone way to achieve the same thing ...

Yeah, that would be but in this situation I cant have any external files like an encrypted text file, the executable has to be completely standalone and self contained without the registry etc.

I have a relative example in VB but thats about all

Okay, but what OS are you on?
You could append the data to the end of the file, spread it through out unused header carp, or:
create your own section and declare a variable(preferably a string) inside of there, look up the section and overwrite the values with the new values.

Im on linux atm but its for Windows

Its not possible to write to an executable file while it is executing -- the operating system will forbid it.

commented: That was an answer right to the point ! +1

Its not possible to write to an executable file while it is executing -- the operating system will forbid it.

Yeah I'm aware of that, Im talking about for example

2 executables

exe a and exe b
exe a will configure/edit values of exe b
exe b will retain them and use them will running self contained

Why are you making it so difficult if you can keep it easy?
> Just use a simple configuration file ...

Why do you want to store some configuration options inside the program's exe? That's ridiculous !

Yeah I'm aware of that, Im talking about for example

2 executables

exe a and exe b
exe a will configure/edit values of exe b
exe b will retain them and use them will running self contained

Best tut on the Windows 32 PE("exe") format
http://webster.cs.ucr.edu/Page_TechDocs/pe.txt

Exe A gets B's DOS header, with the PE offset it gets the IMAGE_NT_HEADERS, right afterwards is the section headers find your section, jump to that section and.... the rest is up to you.

Why are you making it so difficult if you can keep it easy?
> Just use a simple configuration file ...

Why do you want to store some configuration options inside the program's exe? That's ridiculous !

its not ridiculous, I have my reasons, why do you feel the need to keep repeating yourself? I need to do it this way I wish I could use a configuration file but I cant...

Thank you MosaicFuneral :)

Yeah I'm aware of that, Im talking about for example

2 executables

exe a and exe b
exe a will configure/edit values of exe b
exe b will retain them and use them will running self contained

That might work as long as exe b is not running while exe a is writing to the file. Running executables can be opened for reading, but not for writing.

That might work as long as exe b is not running while exe a is writing to the file. Running executables can be opened for reading, but not for writing.

Quick fix, just have A wait till B isn't running, since most likely B would quit after it opens and passes data to A.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.