Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Launches the game with a .dll injected, and minimizes the game with a set hotkey
- #include <windows.h>
- #include <tlhelp32.h>
- #include <shlwapi.h>
- #include <conio.h>
- #include <stdio.h>
- #include "detours.h"
- #include "ini.h"
- #define WIN32_LEAN_AND_MEAN
- #include <shellapi.h>
- #include <string>
- #define HOTKEY_ID 40022
- #define SHELL_ICON_ID 101
- #define SHELL_CALLBACK WM_USER+14
- #include "resource.h"
- //#include "main.h"
- using namespace std;
- LRESULT CALLBACK winProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp);
- HMENU hmenu;
- string check = "Enemy Territory";
- int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmdLine, int nCmdShow)
- {
- HWND hwnd;
- WNDCLASSEX wc;
- wc.cbSize = sizeof(WNDCLASSEX);
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.hbrBackground = (HBRUSH)WHITE_BRUSH+1;
- wc.hCursor = NULL;
- wc.hIcon = NULL;
- wc.hIconSm = NULL;
- wc.hInstance = hInst;
- wc.lpfnWndProc = winProc;
- wc.lpszClassName = "zodiac";
- wc.style = CS_DBLCLKS;
- wc.lpszMenuName = NULL;
- if (!RegisterClassEx(&wc)) { return -1; }
- hwnd = CreateWindow("zodiac", "zodiac", NULL, 0, 0, 50, 50, NULL, NULL, hInst, NULL);
- if (!hwnd)
- {
- MessageBox(0, "try again", NULL, NULL);
- return -1;
- }
- //register hot key
- if (!RegisterHotKey(NULL, HOTKEY_ID, MOD_ALT, 'Z'))
- {
- MessageBox(0, "try again", NULL, NULL);
- return -1;
- }
- // ShowWindow(hwnd, SW_SHOW);
- //create tray icon
- NOTIFYICONDATA nid;
- ZeroMemory(&nid, sizeof(NOTIFYICONDATA));
- nid.cbSize = sizeof(NOTIFYICONDATA);
- nid.hWnd = hwnd;
- nid.uID = SHELL_ICON_ID;
- nid.uFlags = NIF_ICON | NIF_TIP | NIF_MESSAGE;
- nid.uCallbackMessage = SHELL_CALLBACK;
- nid.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_ICON1));
- strcpy_s(nid.szTip, "Zodiac Minimizer");
- Shell_NotifyIcon(NIM_ADD, &nid);
- //get menu
- hmenu = GetSubMenu(LoadMenu(hInst, MAKEINTRESOURCE(IDR_MENU1)), 0);
- //message loop
- MSG msg;
- while (GetMessage(&msg, NULL, NULL, NULL) != 0)
- {
- if (msg.message == WM_HOTKEY)
- msg.hwnd = hwnd;
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- //cleanup
- Shell_NotifyIcon(NIM_DELETE, &nid);
- UnregisterHotKey(NULL, HOTKEY_ID);
- return 0;
- }
- void tryMin()
- {
- string::size_type f = 0;
- string::size_type r = 0;
- string curWin;
- HWND hwet;
- while (f != string::npos)
- {
- r = check.find('\t', r+1);
- if (r == string::npos)
- {
- curWin = check.substr(f);
- f = r;
- }
- else
- {
- curWin = check.substr(f,r);
- f=r+1;
- }
- hwet = FindWindow(curWin.c_str(), NULL);
- if (hwet)
- {
- WINDOWPLACEMENT wp;
- GetWindowPlacement(hwet, &wp);
- if (wp.showCmd == SW_SHOWMINIMIZED) {
- ShowWindow(hwet, SW_RESTORE);
- HWND hWnd = FindWindowExA(FindWindow(0, "ET Console"), NULL, "Edit", 0);
- SendMessage(hWnd, WM_SETTEXT, 0, (LPARAM) "vid_restart");
- SendMessage(hWnd, WM_CHAR, 13, 0);
- } else {
- ShowWindow(hwet, SW_MINIMIZE);
- ChangeDisplaySettings(NULL,0);
- }
- }
- }
- }
- LRESULT CALLBACK winProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
- {
- switch(msg)
- {
- case WM_CREATE:
- // ..
- break;
- case WM_HOTKEY:
- if (wp == HOTKEY_ID)
- tryMin();
- break;
- case SHELL_CALLBACK:
- switch(lp)
- {
- case WM_RBUTTONDOWN:
- {
- if (hmenu != 0)
- {
- SetForegroundWindow(hwnd);
- POINT p;
- GetCursorPos(&p);
- TrackPopupMenu(hmenu, 0, p.x, p.y, 0, hwnd, 0);
- PostMessage(hwnd, WM_NULL, 0,0);
- }
- }
- break;
- case WM_LBUTTONDBLCLK:
- tryMin();
- break;
- }
- return TRUE;
- break;
- case WM_COMMAND:
- switch(LOWORD(wp))
- {
- case ID_YOLO_EXIT:
- PostQuitMessage(0);
- break;
- case ID_YOLO_PLAY:
- char buffer[MAX_PATH];
- GetModuleFileName( NULL, buffer, MAX_PATH );
- string::size_type pos = string( buffer ).find_last_of( "\\/" );
- char path[MAX_PATH];
- char path2[MAX_PATH];
- GetPrivateProfileStringA("settings", "path", "C:\\Program Files (x86)\\Wolfenstein - Enemy Territory\\ET.exe", path, MAX_PATH, string( buffer ).substr( 0, pos).append("\\file.ini").c_str());
- GetPrivateProfileStringA("settings", "path2", "C:\\Program Files (x86)\\Wolfenstein - Enemy Territory", path2, MAX_PATH, string( buffer ).substr( 0, pos).append("\\file.ini").c_str());
- STARTUPINFOA _StartupInfo;
- PROCESS_INFORMATION _Information;
- ZeroMemory( &_StartupInfo, sizeof( STARTUPINFOA ) );
- _StartupInfo.cb = sizeof( STARTUPINFOA );
- ZeroMemory( &_Information, sizeof( PROCESS_INFORMATION ) );
- DetourCreateProcessWithDllA( path, NULL, NULL, NULL, TRUE, CREATE_DEFAULT_ERROR_MODE, NULL, path2, &_StartupInfo, &_Information, string( buffer ).substr( 0, pos).append("\\RInput.dll").c_str(), NULL );
- break;
- }
- default:
- return DefWindowProc(hwnd, msg, wp, lp);
- }
- return TRUE;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement