Advertisement
imk0tter
Oct 13th, 2023
121
0
Never
This is comment for paste Kernel Port Code by Imk0tter
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "PORT_IO.h"
  2.  
  3. // NAME OF PORT OPENING FUNCTION FROM PORT_IO.h
  4. #define OPEN_PORT_FUNCTION print_open
  5. // NAME OF PORT CLOSING FUNCTION FROM PORT_IO.h
  6. #define CLOSE_PORT_FUNCTION print_close
  7. // NAME OF PORT CONNECTING FUNCTION FROM PORT_IO.h
  8. #define CONNECT_PORT_FUNCTION print_connect
  9.  
  10. void handle_open_port(unsigned int x, void *(*open_port)(unsigned int port));
  11. void handle_close_port(unsigned int x, void *(*close_port)(unsigned int port));
  12. void handle_connect_to_port(unsigned int x,
  13.                             void *(*connect_to_port)(unsigned int port));
  14.  
  15. #define PREVIOUS_FRAME(x, y) *(unsigned int *)(x + y)
  16.  
  17. long gap_between_x = 0;
  18.  
  19. void kernel_recursion(unsigned int x) {
  20.   long current_offset = gap_between_x - (long)(char *)&x;
  21.   gap_between_x = (long)(char *)&x;
  22.  
  23.   unsigned int previous_x = PREVIOUS_FRAME((char *)&x, current_offset);
  24.  
  25.   if (x < previous_x) {
  26.     handle_open_port(x, (void *(*)(unsigned int))OPEN_PORT_FUNCTION);
  27.     ++x;
  28.     kernel_recursion(previous_x);
  29.     --x;
  30.     handle_close_port(x, (void *(*)(unsigned int))CLOSE_PORT_FUNCTION);
  31.   } else if (previous_x < x) {
  32.     handle_open_port(previous_x, (void *(*)(unsigned int))OPEN_PORT_FUNCTION);
  33.     kernel_recursion(previous_x + 1);
  34.     --x;
  35.     handle_close_port(previous_x, (void *(*)(unsigned int))CLOSE_PORT_FUNCTION);
  36.   } else {
  37.     handle_open_port(previous_x, (void *(*)(unsigned int))OPEN_PORT_FUNCTION);
  38.     handle_close_port(previous_x, (void *(*)(unsigned int))CLOSE_PORT_FUNCTION);
  39.   }
  40. }
  41. void kernel(unsigned int x) {
  42.   gap_between_x = (long)&x;
  43.   kernel_recursion(0);
  44. }
  45.  
  46. int main() { kernel(1337); }
  47.  
  48. void handle_open_port(unsigned int x, void *(*open_port)(unsigned int port)) {
  49.   open_port(x);
  50. }
  51. void handle_close_port(unsigned int x, void *(*close_port)(unsigned int port)) {
  52.   handle_connect_to_port(x, (void *(*)(unsigned int))CONNECT_PORT_FUNCTION);
  53.   close_port(x);
  54. }
  55. void handle_connect_to_port(unsigned int x,
  56.                             void *(*connect_to_port)(unsigned int port)) {
  57.   connect_to_port(x);
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement