Not really.  Most executable formats have a way to include extra data
that's not used by the loader.  You could store a count in such data
and have the program modify the executable every time it runs.  Not
recommended, though.  A separate file is a much better idea.

You could also play games by actually changing the BSS area (or
equivalent) of the executable.  You must assume the binary isn't
compressed or encyrpted in any manner (a big assumption), then do
something very ugly like:

char magic[256] = "run number is here -->0000000000";

then open  the program's own executable (argv[0] is helpful for this)
in read-write mode, scan it to find the string "run number is here --
>", print the count stored after it, then write back the same bytes
after incrementing the number.

Back in the day this kind of trick was used for various things like
copy protection.  Today it's likely to cause some security program or
the OS to get very upset.  (Some OS's lock the executable of a running
program (for paging purposes), so this won't work at all.)



On Oct 18, 5:24 am, sravanreddy001 <[email protected]> wrote:
> @don
> Do you mean read the source and modify the hard coded value..
> This will involve the the compile and linking steps right?
>
> Did you mean some thing else?

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to