Assume I have a chunk of binary data in memory, I would like to turn it into an istream. How is this done? I've been thinking of using an std::stringstream first, but since the data is binary it's a bit risky I guess.

Something along these lines:
Code:
void fun(char* data, int dataSize)
{
   std::istream s(data, dataSize);

   stuff = s.get();
   s.read(&junk, sizeof(junk));
}