annotate win95kggui.c @ 63:bdcdd9c42043

Create win95kggui.c committer: GitHub <noreply@github.com>
author Paper <37962225+mrpapersonic@users.noreply.github.com>
date Sat, 23 Apr 2022 05:57:34 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
63
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
1 /**
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
2 * Windows 95 Keygen (Win32 version)
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
3 * Copyright (c) Paper 2022
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
4 *
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
6 * of this software and associated documentation files (the "Software"), to deal
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
7 * in the Software without restriction, including without limitation the rights
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
9 * copies of the Software, and to permit persons to whom the Software is
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
10 * furnished to do so, subject to the following conditions:
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
11 *
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
12 * The above copyright notice and this permission notice shall be included in all
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
13 * copies or substantial portions of the Software.
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
14 *
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
21 * SOFTWARE.
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
22 **/
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
23 #include <stdio.h>
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
24 #include <windows.h>
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
25 #include <stdint.h>
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
26 #include <stdbool.h>
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
27 #include <commdlg.h>
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
28 #include <math.h>
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
29 #include <time.h>
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
30 #define _WIN32_WINNT 0x0400
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
31 #define ARRAYSIZE(a) \
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
32 sizeof(a)/sizeof(a[0])
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
33 #define CONCAT_INTS(x, y) \
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
34 x * pow(10, log10(y)+1) + y
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
35 #ifdef _MSC_VER
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
36 #define strdup(p) _strdup(p)
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
37 #endif
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
38 #define GENERATE_KEY 1
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
39 #define LISTBOX 2
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
40 #define KEY 3
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
41 int type;
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
42 HWND hWndListBox, key_box;
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
43
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
44 int get_sum(int n) {
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
45 int sum;
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
46 for (sum = 0; n > 0; sum += n % 10, n /= 10); // copied this from google. sorry not sorry
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
47 return sum;
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
48 }
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
49
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
50 int win95_nt4_prefix() {
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
51 int num = rand() % 1000;
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
52 while ((num == 333) || (num == 444) || (num == 555) || (num == 666) || (num == 777) || (num == 888) || (num == 999)) {
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
53 num = num + 1;
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
54 }
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
55 return num;
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
56 }
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
57
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
58 int win95_suffix(bool isoem) {
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
59 int first_digits, last_digit, second_segment = 5;
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
60 while (get_sum(second_segment) % 7 != 0) {
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
61 if (isoem == false) {
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
62 first_digits = rand() % 1000000;
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
63 } else {
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
64 first_digits = rand() % 10000;
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
65 }
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
66 last_digit = rand() % 10;
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
67 while ((last_digit == 0) || (last_digit >= 8)) {
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
68 last_digit = rand() % 10;
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
69 }
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
70 second_segment = CONCAT_INTS(first_digits, last_digit);
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
71 }
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
72 return second_segment;
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
73 }
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
74
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
75 int office_prefix() {
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
76 int new_site = 0;
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
77 int ez_pwned = 0;
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
78 while (CONCAT_INTS(new_site, ez_pwned) == 0) {
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
79 new_site = rand() % 100;
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
80 ez_pwned = (new_site % 10) + 2;
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
81 if (ez_pwned >= 10) {
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
82 ez_pwned -= 10;
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
83 }
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
84 }
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
85 return CONCAT_INTS(new_site, ez_pwned);
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
86 }
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
87
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
88 int oem_prefix() {
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
89 const char* years[] = {
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
90 "95",
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
91 "96",
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
92 "97",
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
93 "98",
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
94 "99",
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
95 "00",
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
96 "01",
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
97 "02",
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
98 "03"
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
99 };
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
100 char buf[6];
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
101 sprintf(buf, "%03d", (rand() % 366) + 1);
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
102 strcat(buf, years[rand() % 9]);
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
103 int buf2 = atoi(buf);
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
104 return buf2;
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
105 }
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
106
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
107 void AddControls(HWND hWnd) {
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
108 int i = 0;
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
109 /* Open File */
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
110 HWND gen_button = CreateWindowA("Button", "Generate Key", WS_VISIBLE | WS_CHILD, (int)((225 - 100)/2), 5, 100, 20, hWnd, (HMENU)GENERATE_KEY, NULL, NULL);
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
111 /* Type */
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
112 TCHAR listbox_items[][7] = {"Normal", "OEM", "Office"};
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
113 hWndListBox = CreateWindowA("Listbox", NULL, WS_VISIBLE | WS_CHILD | LBS_STANDARD | LBS_NOTIFY, (int)((225 - 100)/2), 55, 100, 40, hWnd, (HMENU)LISTBOX, NULL, NULL);
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
114 for (i = 0; i < ARRAYSIZE(listbox_items); i++) {
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
115 int pos = (int)SendMessage(hWndListBox, LB_ADDSTRING, i, (LPARAM) listbox_items[i]);
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
116 SendMessage(hWndListBox, LB_SETITEMDATA, pos, (LPARAM) i);
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
117 }
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
118 SendMessage(hWndListBox, LB_SETCURSEL, (WPARAM)0, (LPARAM)0);
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
119 // idk
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
120 key_box = CreateWindowA("Edit", "", WS_VISIBLE | WS_CHILD | ES_READONLY | ES_CENTER | ES_MULTILINE, (int)((225 - 150)/2), 100, 150, 40, hWnd, (HMENU)KEY, NULL, NULL);
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
121 if (gen_button == NULL || hWndListBox == NULL || key_box == NULL)
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
122 MessageBoxA(hWnd, "how did you even trigger this", "GUI could not be initialized!", MB_ICONEXCLAMATION);
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
123 }
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
124
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
125 bool CALLBACK SetFont(HWND child, LPARAM font) {
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
126 SendMessage(child, WM_SETFONT, font, true);
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
127 return true;
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
128 }
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
129
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
130 LRESULT CALLBACK WindowProcedure(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) {
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
131 switch(msg) {
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
132 case WM_COMMAND:
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
133 if(HIWORD(wParam) == CBN_SELCHANGE) {
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
134 if (LOWORD(wParam) == LISTBOX)
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
135 type = SendMessageA((HWND) lParam, (UINT) LB_GETCURSEL, (WPARAM) 0, (LPARAM) 0);
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
136 }
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
137 switch(wParam) {
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
138 case GENERATE_KEY: {
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
139 char* p = calloc(24, sizeof(char));
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
140 switch(type) {
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
141 case 2:
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
142 snprintf(p, 24, "%04d-%07d", office_prefix(), win95_suffix(false));
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
143 SendMessageA(key_box, WM_SETTEXT, (WPARAM)0, (LPARAM)p);
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
144 break;
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
145 case 1:
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
146 snprintf(p, 24, "%05d-OEM-%07d-%05d", oem_prefix(), win95_suffix(true), (rand() % 100000));
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
147 SendMessageA(key_box, WM_SETTEXT, (WPARAM)0, (LPARAM)p);
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
148 break;
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
149 case 0:
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
150 snprintf(p, 24, "%03d-%07d", win95_nt4_prefix(), win95_suffix(false));
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
151 SendMessageA(key_box, WM_SETTEXT, (WPARAM)0, (LPARAM)p);
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
152 break;
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
153 }
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
154 }
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
155 case LISTBOX:
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
156 break;
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
157 case KEY:
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
158 break;
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
159 }
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
160 break;
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
161 case WM_CREATE: {
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
162 AddControls(hWnd);
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
163 EnumChildWindows(hWnd, (WNDENUMPROC)SetFont, (LPARAM)GetStockObject(DEFAULT_GUI_FONT));
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
164 break;
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
165 }
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
166 case WM_DESTROY:
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
167 PostQuitMessage(0);
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
168 break;
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
169 default:
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
170 return DefWindowProcA(hWnd, msg, wParam, lParam);
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
171 }
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
172 return false;
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
173 }
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
174
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
175 int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR args, int ncmdshow) {
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
176 srand((unsigned) time(NULL)); // magic rand() stuff :p
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
177 WNDCLASSA wc = {0};
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
178
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
179 wc.hbrBackground = (HBRUSH)COLOR_WINDOW;
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
180 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
181 wc.hInstance = hInstance;
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
182 wc.lpszClassName = "win95kg";
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
183 wc.lpfnWndProc = WindowProcedure;
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
184
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
185 if (!RegisterClassA(&wc)) return -1;
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
186
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
187 CreateWindowA("win95kg", "Windows 95 Keygen", WS_OVERLAPPED | WS_VISIBLE | WS_MINIMIZEBOX | WS_SYSMENU, 100, 100, 225, 200, NULL, NULL, hInstance, NULL);
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
188
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
189 MSG msg = {0};
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
190
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
191 while (GetMessage(&msg, NULL, 0, 0)) {
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
192 TranslateMessage(&msg);
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
193 DispatchMessage(&msg);
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
194 }
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
195 return 0;
bdcdd9c42043 Create win95kggui.c
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
diff changeset
196 }