Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //-------------------------------------------------
- // URL DOWNLOAD TO FILE
- // Por Bruno da Silva @ [iPs]TeaM 2012
- //-------------------------------------------------
- #include "main.h"
- #include "malloc.h"
- #include <windows.h>
- #include <urlmon.h>
- #include <stdio.h>
- #include <iostream>
- #include <fstream>
- #pragma comment(lib, "urlmon.lib")
- logprintf_t logprintf;
- void **ppPluginData;
- using namespace std;
- extern void *pAMXFunctions;
- PLUGIN_EXPORT unsigned int PLUGIN_CALL Supports()
- {
- return SUPPORTS_VERSION | SUPPORTS_AMX_NATIVES;
- }
- PLUGIN_EXPORT bool PLUGIN_CALL Load(void **ppData)
- {
- pAMXFunctions = ppData[PLUGIN_DATA_AMX_EXPORTS];
- logprintf = (logprintf_t)ppData[PLUGIN_DATA_LOGPRINTF];
- logprintf("URLDownloadToFile Por Bruno da Silva");
- return true;
- }
- PLUGIN_EXPORT void PLUGIN_CALL Unload()
- {
- logprintf("URLDownloadToFile Por Bruno da Silva");
- }
- /********************************************************************************/
- char *parametro[2];
- int processar;
- void WINAPI processoAlternativo(LPVOID parames);
- void WINAPI processoAlternativo(LPVOID parames)
- {
- char string[64] = "scriptfiles/";
- strcat_s(string, (LPCSTR)parametro[1]);
- processar = 1;
- HRESULT hr = URLDownloadToFile( NULL, (LPCSTR)parametro[0], (LPCSTR)string, 0, NULL );
- char append[05] = "_OX_";
- strcat_s(string, append);
- FILE * pFile;
- pFile = fopen (string, "w+");
- if (pFile != NULL) {
- fclose (pFile);
- }
- }
- static cell AMX_NATIVE_CALL n_URLDownloadToFile(AMX *amx, cell *params)
- {
- if(params[0] == 8) {
- amx_StrParam(amx, params[1], parametro[0]);
- amx_StrParam(amx, params[2], parametro[1]);
- DWORD dwXuxaTHR;
- processar = 0;
- HANDLE hThread = CreateThread(0,0,(LPTHREAD_START_ROUTINE)processoAlternativo, (LPVOID)0, 0,&dwXuxaTHR);
- while(!processar) continue;
- return 1;
- }
- return 0;
- }
- AMX_NATIVE_INFO nvoNatives[] =
- {
- { "URLDownloadToFileInterno", n_URLDownloadToFile},
- { 0, 0 }
- };
- PLUGIN_EXPORT int PLUGIN_CALL AmxLoad(AMX *amx)
- {
- return amx_Register(amx, nvoNatives, -1);
- }
- PLUGIN_EXPORT int PLUGIN_CALL AmxUnload(AMX *amx)
- {
- return AMX_ERR_NONE;
- }
Add Comment
Please, Sign In to add comment