fork download
  1. struct DontHeapMeBro {
  2.  
  3. // Uncomment this and watch explosions
  4. //byte buffer[( 2048 ) + sizeof(USN)];
  5.  
  6. void Scan () {
  7. std::unique_ptr<void, HandleReleaseLambda> scanhandle(
  8. CreateFileW( api,
  9. GENERIC_READ | GENERIC_WRITE,
  10. FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
  11. null,
  12. OPEN_ALWAYS,
  13. FILE_FLAG_NO_BUFFERING | ( isfile ? 0 : FILE_FLAG_BACKUP_SEMANTICS ),
  14. null ) );
  15.  
  16. if ( scanhandle.get() == INVALID_HANDLE_VALUE )
  17. return;
  18.  
  19. bool success = false;
  20. //ZeroMemory(buffer, 2048 + sizeof(USN))
  21. // Comment this out and use the above to watch Windows explode
  22. byte buffer[( 2048 ) + sizeof(USN)] = { 0 };
  23. USN_JOURNAL_DATA journalquery = { 0 };
  24. READ_USN_JOURNAL_DATA journaldata = { 0 };
  25. ulong journaldatabuffersize = 0, journalquerybuffersize = 0, readbuffersize = 0;
  26. ullong targetreference = 0;
  27. USN usn;
  28. JournalRecord* record = null;
  29. byte* recordaddress = null;
  30.  
  31. success = DeviceIoControl( scanhandle.get(),
  32. FSCTL_QUERY_USN_JOURNAL,
  33. NULL,
  34. 0,
  35. &journalquery,
  36. sizeof( journalquery ),
  37. &journalquerybuffersize, NULL ) != 0;
  38.  
  39. if (!success)
  40. return;
  41.  
  42. // Put you buffer in the struct definition, this will fail, heap or non-heap.
  43. // However, if the buffer is defined here, this call will not fail,
  44. // Even if you have the same parameters
  45. success = DeviceIoControl( scanhandle.get(),
  46. FSCTL_READ_FILE_USN_DATA,
  47. null,
  48. 0,
  49. (void*)buffer,
  50. 2048 + sizeof( USN ),
  51. &readbuffersize,
  52. null ) != 0;
  53.  
  54. if ( !success )
  55. throw "Fuck your shit";
  56. }
  57. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In member function 'void DontHeapMeBro::Scan()':
prog.cpp:7:9: error: 'unique_ptr' is not a member of 'std'
prog.cpp:7:25: error: expected primary-expression before 'void'
prog.cpp:7:25: error: expected ';' before 'void'
prog.cpp:16:8: error: 'scanhandle' was not declared in this scope
prog.cpp:16:28: error: 'INVALID_HANDLE_VALUE' was not declared in this scope
prog.cpp:22:9: error: 'byte' was not declared in this scope
prog.cpp:22:14: error: expected ';' before 'buffer'
prog.cpp:23:3: error: 'USN_JOURNAL_DATA' was not declared in this scope
prog.cpp:23:20: error: expected ';' before 'journalquery'
prog.cpp:24:3: error: 'READ_USN_JOURNAL_DATA' was not declared in this scope
prog.cpp:24:25: error: expected ';' before 'journaldata'
prog.cpp:25:3: error: 'ulong' was not declared in this scope
prog.cpp:25:9: error: expected ';' before 'journaldatabuffersize'
prog.cpp:26:3: error: 'ullong' was not declared in this scope
prog.cpp:26:10: error: expected ';' before 'targetreference'
prog.cpp:27:3: error: 'USN' was not declared in this scope
prog.cpp:27:7: error: expected ';' before 'usn'
prog.cpp:28:3: error: 'JournalRecord' was not declared in this scope
prog.cpp:28:18: error: 'record' was not declared in this scope
prog.cpp:28:27: error: 'null' was not declared in this scope
prog.cpp:29:9: error: 'recordaddress' was not declared in this scope
prog.cpp:31:30: error: 'scanhandle' was not declared in this scope
prog.cpp:32:4: error: 'FSCTL_QUERY_USN_JOURNAL' was not declared in this scope
prog.cpp:33:4: error: 'NULL' was not declared in this scope
prog.cpp:35:5: error: 'journalquery' was not declared in this scope
prog.cpp:37:5: error: 'journalquerybuffersize' was not declared in this scope
prog.cpp:37:34: error: 'DeviceIoControl' was not declared in this scope
prog.cpp:46:4: error: 'FSCTL_READ_FILE_USN_DATA' was not declared in this scope
prog.cpp:49:11: error: 'buffer' was not declared in this scope
prog.cpp:51:5: error: 'readbuffersize' was not declared in this scope
prog.cpp: At global scope:
prog.cpp:56:5: error: expected unqualified-id at end of input
stdout
Standard output is empty