FANDOM


/*
 * Copyright (c) 2011 mb http://forums.wiredforwar.org/index.php?action=profile;u=2064
 * All rights reserved.
 * 
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 * 
 */

#include <windows.h>
#include <commctrl.h>
#include <strsafe.h>

#pragma comment(lib, "user32")
#pragma comment(lib, "gdi32")

/* ret */
unsigned char __433b14[] = {0xc3};

/* mov dword ptr [eax+50h],50h */
int __68bcf6[] = {0x50};

/* mov dword ptr [eax+54h],28h */
int __68bcff[] = {0x28};

/* cmp eax,5 */
unsigned char __87dc8a[] = {0x5};

/* cmp eax,5 */
unsigned char __87dca7[] = {0x5};

/* mov ebx,5 */
int __87dd58[] = {0x5};

HINSTANCE g_hInstance;
LPSTR wndcname = "machldr";
LPSTR appname = "Machines Loader";

PROCESS_INFORMATION pi;
STARTUPINFOA si;

enum	{
	ID_BLAUNCH,
	ID_BSETUPY,
	ID_BA5BMUS,
	ID_UDSLIM,
	ID_ETSLIM,
	ID_UDCLIM,
	ID_ETCLIM
};

BOOL CALLBACK EnumSetFont(HWND hwnd, LPARAM lParam)	{
	SendMessage(hwnd, WM_SETFONT, lParam, MAKELPARAM(TRUE, 0));
	return TRUE;
}
 
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)	{
	switch (msg)	{
	case WM_CREATE:

		CreateWindow(WC_BUTTON, "Gameplay", WS_CHILD | WS_VISIBLE | BS_GROUPBOX,
			16, 10, 197, 121, hwnd, NULL, g_hInstance, NULL);
		CreateWindow(WC_STATIC, "Scenario unit limit:", WS_CHILD | WS_VISIBLE | SS_LEFT,
			24, 31, 150, 23, hwnd, NULL, g_hInstance, NULL);
		CreateWindowEx(WS_EX_CLIENTEDGE, WC_EDIT, NULL, WS_CHILD | WS_VISIBLE | 
			ES_NUMBER | ES_LEFT, 
			130, 27, 75, 23, hwnd, (HMENU) ID_ETSLIM, g_hInstance, NULL);
		CreateWindow(UPDOWN_CLASS, NULL, WS_CHILD | WS_VISIBLE | UDS_AUTOBUDDY | 
			UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_ARROWKEYS | UDS_HOTTRACK | UDS_NOTHOUSANDS, 
			0, 0, 0, 0, hwnd, (HMENU) ID_UDSLIM, g_hInstance, NULL);
		SendDlgItemMessage(hwnd, ID_UDSLIM, UDM_SETRANGE32, 0, INT_MAX);
		SendDlgItemMessage(hwnd, ID_UDSLIM, UDM_SETPOS32, 0, 80);

		CreateWindow(WC_STATIC, "Campaign extra units:", WS_CHILD | WS_VISIBLE | SS_LEFT,
			24, 61, 150, 23, hwnd, NULL, g_hInstance, NULL);
		CreateWindowEx(WS_EX_CLIENTEDGE, WC_EDIT, NULL, WS_CHILD | WS_VISIBLE | 
			ES_NUMBER | ES_LEFT, 
			130, 57, 75, 23, hwnd, (HMENU) ID_ETCLIM, g_hInstance, NULL);
		CreateWindow(UPDOWN_CLASS, NULL, WS_CHILD | WS_VISIBLE | UDS_AUTOBUDDY | 
			UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_ARROWKEYS | UDS_HOTTRACK | UDS_NOTHOUSANDS, 
			0, 0, 0, 0, hwnd, (HMENU) ID_UDCLIM, g_hInstance, NULL);
		SendDlgItemMessage(hwnd, ID_UDCLIM, UDM_SETRANGE32, 0, INT_MAX);
		SendDlgItemMessage(hwnd, ID_UDCLIM, UDM_SETPOS32, 0, 40);
		
		CreateWindow(WC_BUTTON, "Abolish 5 BMUs required to place construction", 
			WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX | BS_MULTILINE | BS_TOP,
			24, 89, 160, 30, hwnd, (HMENU) ID_BA5BMUS, g_hInstance, NULL);
		
		CreateWindow(WC_BUTTON, "Advanced", WS_CHILD | WS_VISIBLE | BS_GROUPBOX,
			16, 144, 197, 54, hwnd, NULL, g_hInstance, NULL);
		CreateWindow(WC_BUTTON, "Disable setupy.bin checking", 
			WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX | BS_MULTILINE | BS_TOP,
			24, 165, 160, 23, hwnd, (HMENU) ID_BSETUPY, g_hInstance, NULL);
		CheckDlgButton(hwnd, ID_BSETUPY, BST_CHECKED);
	
		CreateWindow(WC_BUTTON, "Play", WS_CHILD | WS_VISIBLE,
			16, 214, 197, 23, hwnd, (HMENU) ID_BLAUNCH, g_hInstance, NULL);

		EnumChildWindows(hwnd, (WNDENUMPROC) EnumSetFont, (LPARAM) GetStockObject(DEFAULT_GUI_FONT));
		return DefWindowProc(hwnd, msg, wParam, lParam);
	case WM_CLOSE:
		DestroyWindow(hwnd);
		break;
	case WM_COMMAND:
		switch (wParam)	{
			case ID_BLAUNCH:

				if (IsDlgButtonChecked(hwnd, ID_BSETUPY) == BST_CHECKED)
					WriteProcessMemory(pi.hProcess, (DWORD *) 0x433b14, __433b14, 0x1, NULL);
				if (IsDlgButtonChecked(hwnd, ID_BA5BMUS) == BST_CHECKED)	{
					__87dc8a[0] = 0x0;
					__87dca7[0] = 0x0;
					__87dd58[0] = 0x0;
				}

				__68bcf6[0] = GetDlgItemInt(hwnd, ID_ETSLIM, NULL, FALSE);
				__68bcff[0] = GetDlgItemInt(hwnd, ID_ETCLIM, NULL, FALSE);

				WriteProcessMemory(pi.hProcess, (DWORD *) 0x68bcf6, __68bcf6, sizeof(__68bcf6[0]), NULL);
				WriteProcessMemory(pi.hProcess, (DWORD *) 0x68bcff, __68bcff, sizeof(__68bcff[0]), NULL);

				WriteProcessMemory(pi.hProcess, (DWORD *) 0x87dc8a, __87dc8a, sizeof(__87dc8a[0]), NULL);
				WriteProcessMemory(pi.hProcess, (DWORD *) 0x87dca7, __87dca7, sizeof(__87dca7[0]), NULL);
				WriteProcessMemory(pi.hProcess, (DWORD *) 0x87dd58, __87dd58, sizeof(__87dd58[0]), NULL);

				ResumeThread(pi.hThread);

				CloseHandle (pi.hProcess);
				CloseHandle (pi.hThread);

				PostQuitMessage(0);
			break;
		}
		break;
	case WM_DESTROY:
		TerminateThread(pi.hThread, 0x0);

		CloseHandle (pi.hProcess);
		CloseHandle (pi.hThread);

		PostQuitMessage(0);
		break;
	default:
		return DefWindowProc(hwnd, msg, wParam, lParam);
	}

	return 0;
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)	{
	WNDCLASS wndc = {0, WndProc, 0, 0, hInstance, NULL, NULL,
		(HBRUSH) COLOR_3DSHADOW, NULL, wndcname};
	HWND hwnd;
	MSG wndmsg;
	g_hInstance = hInstance;

	if (!RegisterClass(&wndc))	{
		return 1;
	}

	ZeroMemory(&si, sizeof (si));
	si.cb = sizeof (si);
	ZeroMemory(&pi, sizeof (pi));
	if (! CreateProcessA("machines.exe",
		NULL, NULL, NULL, TRUE, CREATE_SUSPENDED, NULL, NULL, &si, &pi))	{
		char emsg[128] = "Machines loader cannot find machines.exe."; 
 
		if (GetLastError() != ERROR_FILE_NOT_FOUND)
			StringCchPrintf(emsg, 128, "CreateProcessA failed with error code 0x%x.", GetLastError());

		MessageBox(NULL, emsg, appname, MB_OK | MB_ICONERROR);
		
		return 1;
	}

    hwnd = CreateWindowEx(WS_EX_DLGMODALFRAME, wndcname, appname,
		WS_VISIBLE | WS_SYSMENU | WS_CAPTION,
		(GetSystemMetrics(SM_CXSCREEN) - 235) / 2, (GetSystemMetrics(SM_CYSCREEN) - 283) / 2,
		235, 283, NULL, NULL, g_hInstance, NULL);

	while (GetMessage(&wndmsg, NULL, 0, 0))	{
		TranslateMessage(&wndmsg);
		DispatchMessage(&wndmsg);
    }

    return wndmsg.wParam;
}

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.