I can't have a long int as the index into an array of chars?
Of course you can.
This sounds like stack corruption. Switch back to using WriteIndex and change that line to this:
unsigned long int romoff, testtest, WriteIndex, testtesttest;
Does it work? If yes, you have stack corruption. Most likely you are stepping out of bounds of an array somewhere -- and that array is resting on the stack.
It *might* be DataBuffer ... like maybe you're using a negative index or something by mistake.
This, of course, is not a fix. It's just diagnostic. If you want further diagnostics, you can try replacing your arrays with some kind of container class so you have bounds checking. Or add your own bounds checking since you don't appear to be checking at all, which -- unless you know the exact size or a strict upper-bound of the size of the data you're working with, is an extremely bad idea.
Really... since this is C++ and not C, you should be using a container class like vector anyway for DataBuffer. And instead of having a WriteIndex, you should just push_back the values into your vector. Then you never have to worry about out of bounds writes -- and your buffer is not unnecessarily large.
And, if you compile with debug settings, you also get bound checking on read-accesses as well.