Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- void handle_open_port(unsigned int x);
- void handle_close_port(unsigned int x);
- #define PREVIOUS_FRAME(x, y) *(unsigned int *)(x + y)
- long gap_between_x = 0;
- void kernel_recursion(unsigned int x) {
- long current_offset = gap_between_x - (long)(char *)&x;
- gap_between_x = (long)(char *)&x;
- unsigned int previous_x = PREVIOUS_FRAME((char *)&x, current_offset);
- if (x < previous_x) {
- handle_open_port(x); ++x;
- kernel_recursion(previous_x);--x;
- handle_close_port(x);
- } else if (previous_x < x) {
- handle_open_port(previous_x);
- kernel_recursion(previous_x + 1); --x;
- handle_close_port(previous_x);
- } else {
- handle_open_port(previous_x);
- handle_close_port(previous_x);
- }
- }
- void kernel(unsigned int x) {
- gap_between_x = (long)&x;
- kernel_recursion(0);
- }
- int main() { kernel(666); }
- void handle_open_port(unsigned int x) { printf("OPENING: %u\n", x); }
- void handle_close_port(unsigned int x) { printf("CLOSING: %u\n", x); }
Advertisement
Comments
-
- #include <stdio.h>
- template<typename T>
- void handle_open_port(unsigned int x, T (*open_port)(unsigned int port));
- template<typename T>
- void handle_close_port(unsigned int x, T (*close_port)(unsigned int port));
- template<typename T>
- void handle_connect_to_port(unsigned int x,
- T (*connect_to_port)(unsigned int port));
- void print_open(unsigned int x);
- void print_close(unsigned int x);
- void print_connect(unsigned int x);
- #define PREVIOUS_FRAME(x, y) *(unsigned int *)(x + y)
- long gap_between_x = 0;
- void kernel_recursion(unsigned int x) {
- long current_offset = gap_between_x - (long)(char *)&x;
- gap_between_x = (long)(char *)&x;
- unsigned int previous_x = PREVIOUS_FRAME((char *)&x, current_offset);
- if (x < previous_x) {
- handle_open_port(x, print_open);
- ++x;
- kernel_recursion(previous_x);
- --x;
- handle_close_port(x, print_close);
- } else if (previous_x < x) {
- handle_open_port(previous_x, print_open);
- kernel_recursion(previous_x + 1);
- --x;
- handle_close_port(previous_x, print_close);
- } else {
- handle_open_port(previous_x, print_open);
- handle_close_port(previous_x, print_close);
- }
- }
- void kernel(unsigned int x) {
- gap_between_x = (long)&x;
- kernel_recursion(0);
- }
- int main() { kernel(22000); }
- template<typename T>
- void handle_open_port(unsigned int x, T (*open_port)(unsigned int port)) {
- open_port(x);
- }
- template<typename T>
- void handle_close_port(unsigned int x, T (*close_port)(unsigned int port)) {
- handle_connect_to_port(x, print_connect);
- close_port(x);
- }
- template<typename T>
- void handle_connect_to_port(unsigned int x,
- T (*connect_to_port)(unsigned int port)) {
- connect_to_port(x);
- }
- void print_open(unsigned int x) { printf("Opened port %u\n", x); }
- void print_close(unsigned int x) { printf("Closed port %u\n", x); }
- void print_connect(unsigned int x) { printf("Connected port %u\n", x); }
-
- #include <stdio.h>
- #define OPEN_PORT_FUNCTION print_open
- #define CLOSE_PORT_FUNCTION print_close
- #define CONNECT_PORT_FUNCTION print_connect
- void handle_open_port(unsigned int x, void *(*open_port)(unsigned int port));
- void handle_close_port(unsigned int x, void *(*close_port)(unsigned int port));
- void handle_connect_to_port(unsigned int x, void *(*connect_to_port)(unsigned int port));
- void print_open(unsigned int x);
- void print_close(unsigned int x);
- void print_connect(unsigned int x);
- #define PREVIOUS_FRAME(x, y) *(unsigned int *)(x + y)
- long gap_between_x = 0;
- void kernel_recursion(unsigned int x) {
- long current_offset = gap_between_x - (long)(char *)&x;
- gap_between_x = (long)(char *)&x;
- unsigned int previous_x = PREVIOUS_FRAME((char *)&x, current_offset);
- if (x < previous_x) {
- handle_open_port(x, (void*(*)(unsigned int))OPEN_PORT_FUNCTION);
- ++x;
- kernel_recursion(previous_x);
- --x;
- handle_close_port(x, (void*(*)(unsigned int))CLOSE_PORT_FUNCTION);
- } else if (previous_x < x) {
- handle_open_port(previous_x, (void*(*)(unsigned int))OPEN_PORT_FUNCTION);
- kernel_recursion(previous_x + 1);
- --x;
- handle_close_port(previous_x, (void*(*)(unsigned int))CLOSE_PORT_FUNCTION);
- } else {
- handle_open_port(previous_x, (void*(*)(unsigned int))OPEN_PORT_FUNCTION);
- handle_close_port(previous_x, (void*(*)(unsigned int))CLOSE_PORT_FUNCTION);
- }
- }
- void kernel(unsigned int x) {
- gap_between_x = (long)&x;
- kernel_recursion(0);
- }
- int main() { kernel(22000); }
- void handle_open_port(unsigned int x, void *(*open_port)(unsigned int port)) {
- open_port(x);
- }
- void handle_close_port(unsigned int x, void *(*close_port)(unsigned int port)) {
- handle_connect_to_port(x, (void*(*)(unsigned int))CONNECT_PORT_FUNCTION);
- close_port(x);
- }
- void handle_connect_to_port(unsigned int x,
- void *(*connect_to_port)(unsigned int port)) {
- connect_to_port(x);
- }
- void print_open(unsigned int x) { printf("Opened port %u\n", x); }
- void print_close(unsigned int x) { printf("Closed port %u\n", x); }
- void print_connect(unsigned int x) { printf("Connected port %u\n", x); }
-
- #include "PORT_IO.h"
- // NAME OF PORT OPENING FUNCTION FROM PORT_IO.h
- #define OPEN_PORT_FUNCTION print_open
- // NAME OF PORT CLOSING FUNCTION FROM PORT_IO.h
- #define CLOSE_PORT_FUNCTION print_close
- // NAME OF PORT CONNECTING FUNCTION FROM PORT_IO.h
- #define CONNECT_PORT_FUNCTION print_connect
- void handle_open_port(unsigned int x, void *(*open_port)(unsigned int port));
- void handle_close_port(unsigned int x, void *(*close_port)(unsigned int port));
- void handle_connect_to_port(unsigned int x,
- void *(*connect_to_port)(unsigned int port));
- #define PREVIOUS_FRAME(x, y) *(unsigned int *)(x + y)
- long gap_between_x = 0;
- void kernel_recursion(unsigned int x) {
- long current_offset = gap_between_x - (long)(char *)&x;
- gap_between_x = (long)(char *)&x;
- unsigned int previous_x = PREVIOUS_FRAME((char *)&x, current_offset);
- if (x < previous_x) {
- handle_open_port(x, (void *(*)(unsigned int))OPEN_PORT_FUNCTION);
- ++x;
- kernel_recursion(previous_x);
- --x;
- handle_close_port(x, (void *(*)(unsigned int))CLOSE_PORT_FUNCTION);
- } else if (previous_x < x) {
- handle_open_port(previous_x, (void *(*)(unsigned int))OPEN_PORT_FUNCTION);
- kernel_recursion(previous_x + 1);
- --x;
- handle_close_port(previous_x, (void *(*)(unsigned int))CLOSE_PORT_FUNCTION);
- } else {
- handle_open_port(previous_x, (void *(*)(unsigned int))OPEN_PORT_FUNCTION);
- handle_close_port(previous_x, (void *(*)(unsigned int))CLOSE_PORT_FUNCTION);
- }
- }
- void kernel(unsigned int x) {
- gap_between_x = (long)&x;
- kernel_recursion(0);
- }
- int main() { kernel(1337); }
- void handle_open_port(unsigned int x, void *(*open_port)(unsigned int port)) {
- open_port(x);
- }
- void handle_close_port(unsigned int x, void *(*close_port)(unsigned int port)) {
- handle_connect_to_port(x, (void *(*)(unsigned int))CONNECT_PORT_FUNCTION);
- close_port(x);
- }
- void handle_connect_to_port(unsigned int x,
- void *(*connect_to_port)(unsigned int port)) {
- connect_to_port(x);
- }
-
- //PORT_IO.h
- #include <stdio.h>
- void print_open(unsigned int x) { printf("Opened port %u\n", x); }
- void print_close(unsigned int x) { printf("Closed port %u\n", x); }
- void print_connect(unsigned int x) { printf("Connected port %u\n", x); }
Add Comment
Please, Sign In to add comment
Advertisement