Advertisement
Guest User

Untitled

a guest
Nov 20th, 2011
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.61 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdio.h>
  3.  
  4. using namespace std;
  5.  
  6. struct HackByte
  7. {
  8.     public:
  9.         bool _0:1;
  10.         bool _1:1;
  11.         bool _2:1;
  12.         bool _3:1;
  13.         bool _4:1;
  14.         bool _5:1;
  15.         bool _6:1;
  16.         bool _7:1;
  17. };
  18.  
  19. int main(int argc, char** argv)
  20. {
  21.     cout << sizeof(HackByte) << endl;
  22.     cout << sizeof(unsigned char) << endl;
  23.     HackByte* H;
  24.     unsigned char* P;
  25.     //Segfault here, confirmed with GDB
  26.     H->_0 = true;
  27.     H->_1 = false;
  28.     H->_2 = true;
  29.     H->_3 = false;
  30.     H->_4 = true;
  31.     H->_5 = false;
  32.     H->_6 = true;
  33.     H->_7 = false;
  34.     P = (unsigned char*)H;
  35.     FILE* F = fopen("Test", "w");
  36.     fwrite(P, 1, sizeof(P), F);
  37. }
  38.  
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement