Altering memory directly with C is easy; can it be done in C#?
Posted on 2014-02-28
I started thinking about how to make applications more secure, and a question popped into my head. I've looked into working with unsafe pointers in C#, but mostly that just deals with the reading of information.
Given this piece of code:
string a = "one";
string b = a;
Could you code ChangeTheMiddleLetter such that the message box would show "oXe" the first time and "one" the second?
In other words, assuming that a and b both point to the same memory location, could you alter one character of what is being pointed to without altering the pointer address? Or is that no longer possible with managed code?