Advertisement
This is comment for paste
Kernel Port Code by Imk0tter
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #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);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement