Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- void set_stack_limit(size_t mb) {
- size_t bytes = mb * 1024 * 1024;
- void* old_rsp = NULL;
- asm volatile ("mov %%esp, %0;" : "=r" ( old_rsp ));
- void* fake_stack = (void*)((char*)std::calloc(bytes,1)+bytes-1);
- asm volatile ("mov %0, %%esp" : : "r" (fake_stack));
- asm volatile ("mov %0, %%esp" : : "r" (old_rsp));
- }
- int main() {
- set_stack_limit(511);
- std::array<char, 300 * 1024 * 1024> arr;
- std::cout << arr[5];
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement