Advertisement
samicrusader

Untitled

Jun 9th, 2023
798
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.06 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <string>
  3. #include <stdio.h>
  4. #include <process.h>
  5. #include <windows.h>
  6. #define len(array) ((sizeof(array) / sizeof(array[0])))
  7.  
  8. const char* nconvertArgs[] = { "-ratio", "-resize", "longest", "<width>", "-canvas", "<width>", "<height>", "center", "-quiet", "-overwrite", "-out", "bmp", "-o", "<destfn>", "<sourcefn>", "\0"};
  9. const char* bsetrootArgs[] = { "-full", "<destfn>", "\0"};
  10. char nconvertPath[64];
  11. char bsetrootPath[64];
  12.  
  13. DWORD RunSilent(char* BinPath, const char* ParamArray[]) {
  14.     STARTUPINFO StartupInfo;
  15.     PROCESS_INFORMATION ProcessInfo;
  16.     ULONG ReturnCode;
  17.     char Args[1024];
  18.     memset(&StartupInfo, 0, sizeof(StartupInfo));
  19.     StartupInfo.cb = sizeof(STARTUPINFO);
  20.     StartupInfo.dwFlags = STARTF_USESHOWWINDOW;
  21.     //StartupInfo.wShowWindow = SW_HIDE;
  22.     strcpy(Args, ParamArray[0]);
  23.     for (int i = 1; ParamArray[i] != "\0"; i++) {
  24.         strcat(Args, " ");
  25.         strcat(Args, ParamArray[i]);
  26.     }
  27.     char launchCmdline[4096];
  28.     char launchLog[4096];
  29.     sprintf(launchCmdline, "\"%s\" %s", BinPath, Args);
  30.     sprintf(launchLog, "Launching process %s with parameters %s...\n", BinPath, Args);
  31.     OutputDebugString(launchLog);
  32.     if (!CreateProcess(NULL, launchCmdline, NULL, NULL, FALSE, CREATE_NEW_CONSOLE, NULL, NULL, &StartupInfo, &ProcessInfo)) {
  33.         DWORD err = GetLastError();
  34.         char errorText[64];
  35.         sprintf(errorText, "Process launch failed with error code: %d\n", err);
  36.         OutputDebugString(errorText);
  37.         return err;
  38.     }
  39.     OutputDebugString("Launched process!\n");
  40.     WaitForSingleObject(ProcessInfo.hProcess, INFINITE);
  41.     if (!GetExitCodeProcess(ProcessInfo.hProcess, &ReturnCode))
  42.         ReturnCode = 0;
  43.  
  44.     CloseHandle(ProcessInfo.hThread);
  45.     CloseHandle(ProcessInfo.hProcess);
  46.     OutputDebugString("Process returned!\n");
  47.     return ReturnCode;
  48. }
  49.  
  50. LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
  51.     char width[10];
  52.     char height[10];
  53.     const char** args = nconvertArgs;
  54.     switch (message) {
  55.         case WM_DISPLAYCHANGE:
  56.             _itoa(GetSystemMetrics(SM_CXSCREEN), width, 10);
  57.             _itoa(GetSystemMetrics(SM_CYSCREEN), height, 10);
  58.             OutputDebugString("Resolution changed!\n");
  59.             args[3] = width;
  60.             args[5] = width;
  61.             args[6] = height;
  62.             //_spawnv(_P_WAIT, nconvertPath, args);
  63.             //_spawnv(_P_NOWAIT, bsetrootPath, bsetrootArgs);
  64.             RunSilent(nconvertPath, nconvertArgs);
  65.             RunSilent(bsetrootPath, bsetrootArgs);
  66.             break;
  67.         case WM_DESTROY:
  68.             PostQuitMessage(0);
  69.             break;
  70.         default:
  71.             return DefWindowProc(hwnd, message, wParam, lParam);
  72.     }
  73.     return 0;
  74. }
  75.  
  76. int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil) {
  77.     char sourcefn[39];
  78.     char destfn[39];
  79.     //sprintf(nconvertPath, "%s\\Program Files\\NConvert\\nconvert.exe", getenv("systemdrive"));
  80.     //sprintf(bsetrootPath, "%s\\Program Files\\blackbox\\bsetroot.exe", getenv("systemdrive"));
  81.     sprintf(nconvertPath, "%s\\Users\\Sami\\Desktop\\NConvert\\nconvert.exe", getenv("systemdrive"));
  82.     sprintf(bsetrootPath, "%s\\Users\\Sami\\Desktop\\warez\\blackbox\\bsetroot.exe", getenv("systemdrive"));
  83.     sprintf(sourcefn, "%s\\Users\\Sami\\Desktop\\venus.jpg", getenv("systemdrive"));
  84.     sprintf(destfn, "%s\\Windows\\Temp\\bg.bmp", getenv("systemdrive"));
  85.     nconvertArgs[13] = destfn;
  86.     bsetrootArgs[1] = destfn;
  87.     nconvertArgs[14] = sourcefn;
  88.     WNDCLASSEX wc = { sizeof(WNDCLASSEX),0,WindowProcedure,0,0,hThisInstance,NULL,NULL,0,NULL,"bbwalld",NULL };
  89.     if (!RegisterClassEx(&wc)) {
  90.         return 0;
  91.     }
  92.  
  93.     CreateWindowEx(0, "bbwalld", 0, WS_OVERLAPPEDWINDOW, 0, 0, 0, 0, HWND_DESKTOP, NULL, hThisInstance, NULL);
  94.  
  95.     MSG messages;
  96.     while (GetMessage(&messages, NULL, 0, 0)) {
  97.         TranslateMessage(&messages);
  98.         DispatchMessage(&messages);
  99.     }
  100.  
  101.     return messages.wParam;
  102. }
  103.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement