Autergame2

Untitled

Sep 26th, 2020
834
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. typedef struct champ
  2. {
  3.     char alias[32];
  4.     uint8_t id;
  5. } champ;    
  6.  
  7. server side:
  8.  
  9. HANDLE pipe = CreateNamedPipeA("\\\\.\\pipe\\testpipe", PIPE_ACCESS_OUTBOUND, PIPE_TYPE_BYTE, 1, 0, 0, 0, NULL);
  10. if (pipe == NULL || pipe == INVALID_HANDLE_VALUE)
  11. {
  12.     printf("Failed to CreateNamedPipe: %d.\n", GetLastError());
  13.     scanf("press enter to exit.");
  14.     return 1;
  15. }
  16.  
  17. uint8_t num = 0;
  18. memcpy(champi->alias, nameida[choose]->alias, strlen(nameida[choose]->alias));
  19. while (1)
  20. {
  21.     printf("Type skin number or 0 to exit: ");
  22.     scanf("%hhu", &num);
  23.     if (num == 0)
  24.         break;
  25.     else if (num > sknn[choose]->size)
  26.     {
  27.         printf("Skin number not found, try again.\n");
  28.         continue;
  29.     }
  30.  
  31.     champi->id = num;
  32.     printf("Waiting process.\n");
  33.     while (ConnectNamedPipe(pipe, NULL) == FALSE)
  34.     {
  35.         Sleep(1000);
  36.     }
  37.  
  38.     result = WriteFile(pipe, champi, sizeof(champ), NULL, NULL);
  39.     if (!result)
  40.     {
  41.         printf("Failed to send data: %d.\n", GetLastError());
  42.         scanf("press enter to exit.");
  43.         CloseHandle(pipe);
  44.         return 1;
  45.     }
  46. }
  47.  
  48. client size:
  49.  
  50. HANDLE pipe = CreateFileA("\\\\.\\pipe\\testpipe",
  51.     GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
  52.     NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
  53. if (pipe == INVALID_HANDLE_VALUE)
  54. {
  55.     FreeLibraryAndExitThread(mymodule, 0);
  56.     return 1;
  57. }
  58.  
  59. champ champi;
  60. while (pipe != INVALID_HANDLE_VALUE)
  61. {
  62.     if (ConnectNamedPipe(pipe, NULL) == TRUE)
  63.     {
  64.         while (ReadFile(pipe, &champi, sizeof(champ), NULL, NULL) == TRUE)
  65.         {
  66.             printf("%s %d\n", champi.alias, champi.id);
  67.         }
  68.     }
  69.     printf("test\n");
  70.     if (GetAsyncKeyState(VK_F7) & 1)
  71.         break;
  72.     Sleep(1000);
  73. }
RAW Paste Data