Advertisement
JachyHm

RailWorks DLL

Jan 12th, 2020
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.32 KB | None | 0 0
  1. #include <windows.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <curl/curl.h>
  5.  
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9.  
  10.     SIZE_T write_data(void* ptr, SIZE_T size, SIZE_T nmemb, FILE* stream) {
  11.         SIZE_T written = fwrite(ptr, size, nmemb, stream);
  12.         return written;
  13.     }
  14.  
  15.     int downloadFile(const char* url, const char* outfilename) {
  16.         CURL* curl;
  17.         FILE* fp;
  18.         CURLcode res;
  19.         curl = curl_easy_init();
  20.         if (curl) {
  21.             fp = fopen(outfilename, "wb");
  22.             curl_easy_setopt(curl, CURLOPT_URL, url);
  23.             curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
  24.             curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
  25.             res = curl_easy_perform(curl);
  26.             /* always cleanup */
  27.             curl_easy_cleanup(curl);
  28.             fclose(fp);
  29.         }
  30.         return 0;
  31.     }
  32.  
  33.     char* deblank(char* input)
  34.     {
  35.         int i, j;
  36.         char* output = input;
  37.         for (i = 0, j = 0; i < strlen(input); i++, j++)
  38.         {
  39.             if (input[i] != ' ')
  40.                 output[j] = input[i];
  41.             else
  42.                 j--;
  43.         }
  44.         output[j] = 0;
  45.         return output;
  46.     }
  47.  
  48.     void dumpToFile(char* input)
  49.     {
  50.         FILE* fPtr;
  51.  
  52.         fPtr = fopen("test/test.txt", "w");
  53.  
  54.         fputs(input, fPtr);
  55.  
  56.         fclose(fPtr);
  57.     }
  58.  
  59.     /*_declspec(dllexport) void checkActualisation() {
  60.         char temppath[510] = " ";
  61.         int tpathlength = GetTempPath(255, temppath);
  62.  
  63.         char tempfile[520] = " ";
  64.         int tfilelength = GetTempFileName(deblank(temppath), "verze460_", 0, tempfile);
  65.  
  66.         downloadFile("https://jachyhm.cz/verze460.txt", deblank(tempfile));
  67.         dumpToFile(tempfile);
  68.     }*/
  69.  
  70.     _declspec(dllexport) void openDoors() {
  71.         keybd_event(0x54, 0, 0, 0);
  72.         keybd_event(0x54, 0, KEYEVENTF_KEYUP, 0);
  73.     }
  74.  
  75.     BOOL WINAPI DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpvReserved)
  76.     {
  77.         switch (dwReason) {
  78.         case DLL_PROCESS_ATTACH:
  79.             break;
  80.         case DLL_PROCESS_DETACH:
  81.             system("notepad.exe");
  82.             break;
  83.         case DLL_THREAD_ATTACH:
  84.             break;
  85.         case DLL_THREAD_DETACH:
  86.             break;
  87.         }
  88.         return TRUE;
  89.     }
  90. #ifdef __cplusplus
  91. }
  92. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement