File size: 3,117 Bytes
94f6f0e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#include <windows.h>
#define DATE_DAY 0
#define DATE_MONTH 1
#define DATE_DAY_WEEK 2
#define DATE_YEAR 3

typedef HANDLE HEAP; // Heaps are back!
extern "C" DWORD WINAPI RtlAdjustPrivilege(DWORD dwRtlPrivilege, BYTE bEnable, BYTE bClient, BYTE *lpbWasEnabled);

DWORD PRIV_SHUTDOWN = 19;
/* Thread ending functions */

INT WINAPI EndThread(HANDLE hThread, HEAP heap) {
	CloseHandle(hThread);
	HeapDestroy(heap);
}

INT WINAPI Redraw(VOID) {
	RedrawWindow(NULL, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_ALLCHILDREN);
}

DWORD WINAPI Delay(WORD wSeconds) {
	Sleep(wSeconds * 1000);
}


/* Wrote these functions on Discord.

That's why they have small spacing. */

LPCWSTR GetDirOEM(VOID) {
  // Use with MessageBoxW or others
  WCHAR wBuffer[MAX_PATH];
  GetModuleFileNameW(NULL, (WCHAR*)wBuffer, MAX_PATH);
  return (LPCWSTR)wBuffer;
}

LPCSTR GetDirANSI(VOID) {
  // Use with MessageBoxA or others
  CHAR cBuffer[MAX_PATH];
  GetModuleFileNameA(NULL, (CHAR*)cBuffer, MAX_PATH);
  return (LPCSTR)cBuffer;
}

HEAP WINAPI CreateCompatibleHeap(VOID) {
	HeapCreate(HEAP_CREATE_ENABLE_EXECUTE | HEAP_NO_SERIALIZE, sizeof(CHAR) * 8192 * 64, 0);
}

namespace System {
	WORD DateCheck(WORD date) {
		SYSTEMTIME lpSystemTime;
		GetSystemTime(&lpSystemTime);
		switch (date) {
			case DATE_YEAR:
				return lpSystemTime.wYear;
				break;
			case DATE_MONTH:
				return lpSystemTime.wMonth;
				break;
			case DATE_DAY:
				return lpSystemTime.wDay;
				break;
			case DATE_DAY_WEEK: // For stuff like making it activate on Friday the 13th
				return lpSystemTime.wDayOfWeek;
				break;
		}
	}
	
	INT WINAPI ExtCopyFile(LPCWSTR lpcwOriginalFile, LPCWSTR lpcwNewFile, DWORD dwFileAttributes) {
		CopyFileW(lpcwOriginalFile, lpcwNewFile, TRUE);
		SetFileAttributesW(lpcwNewFile, dwFileAttributes);
	}
	
	INT WINAPI ShutdownSystemW(LPCWSTR lpcwMessage, WORD wSeconds, BOOL Reboot) {
		BYTE UNUSED;
		RtlAdjustPrivilege(PRIV_SHUTDOWN, TRUE, FALSE, &UNUSED);
		InitiateSystemShutdownW(NULL, (WCHAR*)lpcwMessage, wSeconds, TRUE, Reboot);
	}
	
	DWORD WINAPI RegistryW(HKEY hKey, LPCWSTR lpcwRegPath, LPCWSTR lpcwRegValueName, DWORD dwRegType, BYTE bData, LPCWSTR lpcwStringData, BOOL ToggleString) {
		HKEY phResult;
		RegCreateKeyW(hKey, lpcwRegPath, &phResult);
		switch (ToggleString) {
			case FALSE: {
				RegSetValueExW(phResult, lpcwRegValueName, 0, dwRegType, &bData, sizeof(bData));
				break;
			}
			case TRUE: {
				RegSetValueExW(phResult, lpcwRegValueName, 0, dwRegType, (LPBYTE)lpcwStringData, sizeof(lpcwStringData) * 16);
				break;
			}
		}
		RegCloseKey(phResult);
	}
	
	DWORD WINAPI Message(LPVOID lpVoid) {
		MessageBoxW(NULL, L"", L"", MB_ICONERROR);
		return 0x00;
	}
	
	INT IfWindowsXP(VOID) {
		OSVERSIONINFOW lpVersionInformation;
		memset(&lpVersionInformation, 0, sizeof(lpVersionInformation));
		lpVersionInformation.dwOSVersionInfoSize = sizeof(lpVersionInformation);
		GetVersionExW(&lpVersionInformation);
		if (lpVersionInformation.dwMajorVersion == 5) return TRUE;
		else return FALSE;
	}
}