Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdio.h>
- using namespace std;
- struct HackByte
- {
- public:
- bool _0:1;
- bool _1:1;
- bool _2:1;
- bool _3:1;
- bool _4:1;
- bool _5:1;
- bool _6:1;
- bool _7:1;
- };
- int main(int argc, char** argv)
- {
- cout << sizeof(HackByte) << endl;
- cout << sizeof(unsigned char) << endl;
- HackByte* H;
- unsigned char* P;
- //Segfault here, confirmed with GDB
- H->_0 = true;
- H->_1 = false;
- H->_2 = true;
- H->_3 = false;
- H->_4 = true;
- H->_5 = false;
- H->_6 = true;
- H->_7 = false;
- P = (unsigned char*)H;
- FILE* F = fopen("Test", "w");
- fwrite(P, 1, sizeof(P), F);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement