Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <unistd.h>
- #include <stdint.h>
- using namespace std;
- int main(int argc, char *argv[])
- {
- if (argc < 2)
- {
- const int s_argc = 137; // ¯\_(ツ)_/¯
- char **s_argv = (char **)malloc(sizeof(char *) * (s_argc + 1));
- s_argv[s_argc - 1] = NULL; // nullptr;
- const string arg_text = "the quick brown fox n stuff" +
- string(sysconf(_SC_PAGESIZE), 'A') +
- string(1, '\0');
- for (int i = 0; i < (s_argc - 1); ++i)
- {
- char *tmp = (char *)malloc(arg_text.size());
- arg_text.copy(tmp, arg_text.size());
- s_argv[i] = tmp;
- }
- // for(int i=0;i<s_argc;++i){cout << s_argv[i] << endl;}
- cout << __FILE__ << ":" << __LINE__ << endl;
- execv(argv[0], s_argv);
- cout << __FILE__ << ":" << __LINE__ << endl;
- }
- else
- {
- uintptr_t lowest_p = UINTPTR_MAX;
- int lowest_argc = -1;
- cout << "argc: " << argc << " argument positions from lowest to highest: ";
- for (int i = 1; i < argc; ++i)
- {
- for (int i = 1; i < argc; ++i)
- {
- if (argv[i] == NULL)
- {
- continue;
- }
- if (uintptr_t(argv[i]) < lowest_p)
- {
- lowest_p = uintptr_t(argv[i]);
- lowest_argc = i;
- }
- }
- cout << lowest_argc << " - " << std::flush;
- argv[lowest_argc] = NULL;
- lowest_p = UINTPTR_MAX;
- lowest_argc = -1;
- }
- }
- }
Add Comment
Please, Sign In to add comment