1

Is this even possible?

I realize that asking them to enter data when the program runs and saving it in the executable file itself is out. (Or is it?)

Right now I'm considering trying to build the program server-side with php and have it incorporate a separate text file which would contain the information. This seems marginally feasible, though I would have quite a bit of learning to accomplish it.

I was hoping for some other ideas of how I might accomplish this.

I am not interested in separate configuration or text files or putting data in windows registry. I am only looking for solutions where it can be quite-solidly a part of the executable.

Does anybody have any experience with this?

Thank you.

Winston Ewert
  • 44,070
  • 10
  • 68
  • 83
emragins
  • 4,607
  • 2
  • 33
  • 48
  • You definitely don't save it in the EXE itself. Writing to an application when it is running is extremely difficult, if possible at all. Beyond the technical limitations, every virus scanner known to man will throw a fit if you start trying to modify binaries like this. What's wrong with putting the data in the registry or configuration files? That's exactly what they're designed for. – Cody Gray - on strike Apr 26 '11 at 15:43
  • Use the App.config, and utilize it though the standard System.Configuration namespace. Better than registry, and still works like magic, without you having to worry. – Claus Jørgensen Apr 26 '11 at 15:44
  • @Claus going to have to look into that one – emragins Apr 26 '11 at 15:45
  • @Cody hah! I hadn't even thought about virus scanners. Quite right. – emragins Apr 26 '11 at 15:45

3 Answers3

1

How about using Settings within your app? It depends on what you mean by "storing the user registration" as to how you would best achieve this, though. If you could give some more information about what you actually want to store, that would be useful.

An example would be to save a username, or an authentication token, and use that each time you need to check a "registration". As I say, though, the details of what to store would depend entirely on what you want to do it that data...

ZombieSheep
  • 29,603
  • 12
  • 67
  • 114
  • Could you elaborate on that a little, please? – emragins Apr 26 '11 at 15:44
  • "This copy registered by ___ for ___ use" more or less. At a long glance, settings seem worth looking into more. – emragins Apr 26 '11 at 15:52
  • Ah, right, I see what you're after now. I guess Settings would still work for this, but be aware that they are stored in an editable file, so it may not be what you need. If you're only bothered about it for display purposes, and not any kind of security, then it would work fine for you. – ZombieSheep Apr 26 '11 at 15:55
  • I'm leaning more and more towards guilt-security since I've accepted any real security gets cracked. However, I still really want just one file--the executable. It's just a small utility thing and asking people to keep carry around a config file with them is just hassle they don't need (in my opinion.) – emragins Apr 26 '11 at 16:00
1

Its perfectly possible, that's how self-extracting zip files work.

Basically, you can add as much stuff to the end of the executable file as you want. Your program can then open its own file up on disk and read it back.

Winston Ewert
  • 44,070
  • 10
  • 68
  • 83
  • Eh? Do forgive me, but you lost me around "you can add as much stuff to the end of the executable file as you want." – emragins Apr 26 '11 at 15:55
  • Your .exe is a file. You can open the file and append as much data you want to the end of the file. It won't affect the running of the the program; however, you'll be able to open the file and read it during execution. – Winston Ewert Apr 26 '11 at 16:41
  • You can zip file(s) and set it to be self-extracting. There is not a limit to the number of files only the size of the file itself. – Security Hound Apr 26 '11 at 16:42
  • This seems like a good solution, but I am struggling to "open the file and append as much data as a I want". I quickly learned that simply appending a string does not work (since it breaks the exe) and have done more research on PE files since then. Much of what I see implies that the process is rather complicated. I am also not discovering much in the way of an API for this. What am I missing? – emragins Apr 26 '11 at 18:12
  • Just tried appending bytes, too, with no luck. At least it gives me a different error message. – emragins Apr 26 '11 at 18:28
  • started a new question: http://stackoverflow.com/questions/5795446/appending-data-to-an-exe – emragins Apr 26 '11 at 19:30
  • @emragins, okay its more complicated then I thought. But this is the general approach. – Winston Ewert Apr 26 '11 at 19:45
0

You could use it to embed in the unmanaged resources.

Daniel A. White
  • 187,200
  • 47
  • 362
  • 445