Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C++ - data serialization

Name: Anonymous 2011-07-06 7:44

I needed to serialize some simple data structures in C++ code and remembered how to do it in C#. It was like 9001 lines of code of boilerplate crap in .NET environment.

Well, in C++ it was of course hard because C++ is such crappy language, rite?


template<typename T>
bool serializeData(const T &data, std::ostream &os)
{
    os.write(reinterpret_cast<const char*>(&data), sizeof(data));
    return os.good();
}

template<typename T>
bool deserializeData(T &data, std::istream &is)
{
    is.read(reinterpret_cast<char*>(&data), sizeof(data));
    return is.good();
}

Name: Anonymous 2011-07-07 8:41

>>31
Show me how you can fuck aan non-existing (>>29) call stack.


unsigned char payload[256] = { /* some malicious data with function addresses at the correct offset*/ };

void hax_my_stack() {
    unsigned char buffer[16];
    memcpy(buffer, payload, 256);
    // return address is now seriously ``fucked'' on most architectures with descending call stacks
}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List