Anonymous Monk:

Aside from the info you've already received from the other residents of the monastery, here's what I do.

I used to occasionally have to ship executables with a serial number and licensee name in it. I'd never compile it in, as that would be a nuisance. Also, you never know how many (unintentional) cases of the string appear that you want to change.

So, what I used to do is to:

(a) precede the block of strings to patch with a preamble, and

(b) set each string to a known value, and

(c) provide plenty of expansion room in strings with variable length.

So if my fellow brethren will forgive me, here's the kind of code I'd use in C to hold my strings:

const char z_patchable_start[]="Start of patchable area"; const char serial_number[]="$$serial_number.....$$"; const char licensee[]="$$licensee..............................." "........................................." ".......................................$$"; const char z_patchable_end[]="End of patchable area";
Then, in my patcher program (written in Perl!), I'd scan for the location of the $$variable_name.$$ strings found between the markers, and then replace them with the appropriate values (not to exceed the boundaries of the $$..$$.).

Hope this helps...

--roboticus


In reply to Re: Change Binary File by roboticus
in thread Change Binary File by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.