ipsBruno

(Plugin) UrlDownloadToFile

Jul 21st, 2012
308
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.28 KB | None | 0 0
  1.  
  2. //-------------------------------------------------
  3. //     URL DOWNLOAD TO FILE
  4. //  Por Bruno da Silva @ [iPs]TeaM 2012
  5. //-------------------------------------------------
  6.  
  7. #include "main.h"
  8. #include "malloc.h"
  9.  
  10. #include <windows.h>
  11. #include <urlmon.h>
  12. #include <stdio.h>
  13.  
  14. #include <iostream>
  15. #include <fstream>
  16.  
  17. #pragma comment(lib, "urlmon.lib")
  18.  
  19. logprintf_t logprintf;
  20.  
  21. void **ppPluginData;
  22. using namespace std;
  23.  
  24. extern void *pAMXFunctions;
  25.  
  26. PLUGIN_EXPORT unsigned int PLUGIN_CALL Supports()
  27. {
  28.     return SUPPORTS_VERSION | SUPPORTS_AMX_NATIVES;
  29. }
  30.  
  31.  
  32. PLUGIN_EXPORT bool PLUGIN_CALL Load(void **ppData)
  33. {
  34.     pAMXFunctions = ppData[PLUGIN_DATA_AMX_EXPORTS];
  35.     logprintf = (logprintf_t)ppData[PLUGIN_DATA_LOGPRINTF];
  36.  
  37.     logprintf("URLDownloadToFile Por Bruno da Silva");
  38.     return true;
  39. }
  40.  
  41.  
  42. PLUGIN_EXPORT void PLUGIN_CALL Unload()
  43. {
  44.     logprintf("URLDownloadToFile Por Bruno da Silva");
  45. }
  46.  
  47.  
  48. /********************************************************************************/
  49.  
  50. char    *parametro[2];
  51. int      processar;
  52.  
  53. void WINAPI processoAlternativo(LPVOID parames);
  54. void WINAPI processoAlternativo(LPVOID parames)
  55. {
  56.  
  57.     char string[64] = "scriptfiles/";
  58.     strcat_s(string, (LPCSTR)parametro[1]);
  59.     processar = 1;
  60.     HRESULT hr = URLDownloadToFile( NULL, (LPCSTR)parametro[0], (LPCSTR)string, 0, NULL );
  61.  
  62.     char append[05] = "_OX_";
  63.     strcat_s(string, append);
  64.  
  65.     FILE * pFile;
  66.  
  67.     pFile = fopen (string, "w+");
  68.  
  69.     if (pFile != NULL) {
  70.         fclose (pFile);
  71.     }
  72. }
  73.  
  74.  
  75. static cell AMX_NATIVE_CALL n_URLDownloadToFile(AMX *amx, cell *params)
  76. {
  77.     if(params[0] == 8) {
  78.  
  79.         amx_StrParam(amx, params[1], parametro[0]);
  80.         amx_StrParam(amx, params[2], parametro[1]);
  81.  
  82.         DWORD dwXuxaTHR;
  83.  
  84.         processar = 0;
  85.  
  86.         HANDLE hThread = CreateThread(0,0,(LPTHREAD_START_ROUTINE)processoAlternativo, (LPVOID)0, 0,&dwXuxaTHR);
  87.  
  88.         while(!processar) continue;
  89.  
  90.         return 1;
  91.     }
  92.     return 0;
  93. }
  94.  
  95.  
  96. AMX_NATIVE_INFO nvoNatives[] =
  97. {
  98.     { "URLDownloadToFileInterno", n_URLDownloadToFile},
  99.     { 0, 0 }
  100. };
  101.  
  102. PLUGIN_EXPORT int PLUGIN_CALL AmxLoad(AMX *amx)
  103. {
  104.     return amx_Register(amx, nvoNatives, -1);
  105. }
  106.  
  107.  
  108. PLUGIN_EXPORT int PLUGIN_CALL AmxUnload(AMX *amx)
  109. {
  110.     return AMX_ERR_NONE;
  111. }
Add Comment
Please, Sign In to add comment