C# - Modify what IntPtr is pointing to (replace a string)
<p>Code:</p>

<p>...</p>

<p>IntPtr buff</p>

<p>...</p>

<p>buff can be pointing to something pretty large. This buff will contain a string, lets say "XYZ123", that I want to replace with "ABC456". Unfortunately, the remainder of data is not a string. This is preventing me from doing something like the following:</p>

<p>..Marshal.PtrToStringAnsi(buff)</p>

<p>//do string replace here</p>

<p>..Marshal.StringToHGlobalAnsi(..)</p>

<p>As it would screw up the other "non-string" binary data. Given the large size and my inability to do the conversion above, what is the best way to go about doing this?</p>

<p>Do a Marshal.Copy into a byte[] in a loop, looking for a character sequence?</p>

<p>Thanks!</p>
