first commit

This commit is contained in:
admin
2026-08-10 23:13:58 +08:00
commit a025f66aea
993 changed files with 90285 additions and 0 deletions
+7
View File
@@ -0,0 +1,7 @@
@echo off
call "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvars64.bat"
cd /d "%~dp0"
rc keygen_res.rc
cl configen.c /Feconfigen.exe /utf-8 keygen_res.res user32.lib gdi32.lib comdlg32.lib dwmapi.lib advapi32.lib /link /SUBSYSTEM:WINDOWS
del configen.obj keygen_res.res 2>nul
echo Done.
+7
View File
@@ -0,0 +1,7 @@
@echo off
call "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvars64.bat"
cd /d "%~dp0"
rc keygen_res.rc
cl keygen_lic.c /Fekeygen_lic.exe /utf-8 keygen_res.res user32.lib gdi32.lib comdlg32.lib winmm.lib dwmapi.lib /link /SUBSYSTEM:WINDOWS
del keygen_lic.obj keygen_res.res 2>nul
echo Done.
+223
View File
@@ -0,0 +1,223 @@
#define _CRT_SECURE_NO_WARNINGS
#include <windows.h>
#include <stdio.h>
#include <string.h>
#pragma comment(lib, "winmm.lib")
#define IDI_MAIN 1
#define ID_GEN 101
#define ID_PREV 102
#define ID_NEW 103
#define ID_ENV 104
static HFONT hfTitle, hfBody, hfMono;
static HBRUSH hbrDark, hbrDarker, hbrAccent;
static HWND hEnvCheck;
static void ReadProtk(char* buf, int sz)
{
buf[0] = 0;
FILE* f = fopen("protk.dat", "r");
if (!f) { snprintf(buf, sz, "protk.dat not found in current directory"); return; }
int total = 0; char ln[512];
while (fgets(ln, sizeof(ln), f) && total < sz - 4) {
int len = (int)strlen(ln);
memcpy(buf + total, ln, len); total += len;
}
fclose(f); buf[total] = 0;
}
static void GetExeDir(char* buf, int sz)
{
GetModuleFileNameA(NULL, buf, sz);
char* slash = strrchr(buf, '\\');
if (slash) *slash = '\0';
}
static void GenerateProtk(char* buf, int sz)
{
char dir[MAX_PATH]; GetExeDir(dir, sizeof(dir));
snprintf(buf, sz,
"NAME Resource_Library\r\n"
"EXEC_FILE %s\\Res_center_80.dll\r\n"
"TEXT_DIR %s\\text\r\n"
"STARTUP dll\r\n"
"REVISION 36\r\n"
"END\r\n",
dir, dir);
}
static void SetEnvVar(const char* name, const char* value)
{
HKEY hKey;
if (RegCreateKeyExA(HKEY_CURRENT_USER,
"Environment", 0, NULL, REG_OPTION_NON_VOLATILE,
KEY_SET_VALUE, NULL, &hKey, NULL) == ERROR_SUCCESS) {
RegSetValueExA(hKey, name, 0, REG_SZ,
(const BYTE*)value, (DWORD)(strlen(value) + 1));
RegCloseKey(hKey);
SendMessageTimeoutW(HWND_BROADCAST, WM_SETTINGCHANGE,
0, (LPARAM)L"Environment", SMTO_ABORTIFHUNG, 2000, NULL);
}
}
static void DeleteEnvVar(const char* name)
{
HKEY hKey;
if (RegOpenKeyExA(HKEY_CURRENT_USER, "Environment", 0,
KEY_SET_VALUE, &hKey) == ERROR_SUCCESS) {
RegDeleteValueA(hKey, name);
RegCloseKey(hKey);
SendMessageTimeoutW(HWND_BROADCAST, WM_SETTINGCHANGE,
0, (LPARAM)L"Environment", SMTO_ABORTIFHUNG, 2000, NULL);
}
}
static void InitTheme(void)
{
hbrDark = CreateSolidBrush(RGB(32, 32, 32));
hbrDarker = CreateSolidBrush(RGB(22, 22, 22));
hbrAccent = CreateSolidBrush(RGB(0, 120, 212));
NONCLIENTMETRICSW nm = {sizeof(nm)};
SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, sizeof(nm), &nm, 0);
nm.lfMenuFont.lfHeight = -22; nm.lfMenuFont.lfWeight = FW_SEMIBOLD;
hfTitle = CreateFontIndirectW(&nm.lfMenuFont);
nm.lfMenuFont.lfHeight = -14; nm.lfMenuFont.lfWeight = FW_NORMAL;
hfBody = CreateFontIndirectW(&nm.lfMenuFont);
nm.lfMenuFont.lfHeight = -13;
nm.lfMenuFont.lfPitchAndFamily = FIXED_PITCH;
hfMono = CreateFontIndirectW(&nm.lfMenuFont);
}
static void DrawMetroButton(HWND hBtn, LPDRAWITEMSTRUCT dis)
{
wchar_t txt[64]; GetWindowTextW(hBtn, txt, 64);
int pressed = (dis->itemState & ODS_SELECTED);
int hot = (dis->itemState & ODS_HOTLIGHT);
HBRUSH br = pressed ? CreateSolidBrush(RGB(0, 90, 170))
: hot ? CreateSolidBrush(RGB(0, 105, 190)) : hbrAccent;
FillRect(dis->hDC, &dis->rcItem, br);
if (!pressed && !hot) DeleteObject(br);
SetBkMode(dis->hDC, TRANSPARENT);
SetTextColor(dis->hDC, RGB(255,255,255));
SelectObject(dis->hDC, hfTitle);
DrawTextW(dis->hDC, txt, -1, &dis->rcItem, DT_CENTER|DT_VCENTER|DT_SINGLELINE);
}
static LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM w, LPARAM l)
{
static HWND hPrev, hNew, hGen;
switch (msg) {
case WM_CREATE: {
InitTheme();
SetClassLongPtrW(hWnd, GCLP_HBRBACKGROUND, (LONG_PTR)hbrDark);
HWND h = CreateWindowW(L"STATIC", L"Protk.dat Configurator",
WS_CHILD|WS_VISIBLE|SS_CENTER, 10, 8, 580, 28, hWnd, NULL, NULL, NULL);
SendMessageW(h, WM_SETFONT, (WPARAM)hfTitle, 1);
CreateWindowW(L"STATIC", L"Current protk.dat:",
WS_CHILD|WS_VISIBLE, 15, 48, 150, 20, hWnd, NULL, NULL, NULL);
hPrev = CreateWindowExW(WS_EX_CLIENTEDGE, L"EDIT", L"",
WS_CHILD|WS_VISIBLE|WS_BORDER|ES_MULTILINE|ES_READONLY|
ES_AUTOVSCROLL|WS_VSCROLL,
15, 68, 570, 100, hWnd, (HMENU)ID_PREV, NULL, NULL);
SendMessageW(hPrev, WM_SETFONT, (WPARAM)hfMono, 1);
CreateWindowW(L"STATIC", L"New protk.dat (auto-detected):",
WS_CHILD|WS_VISIBLE, 15, 178, 250, 20, hWnd, NULL, NULL, NULL);
hNew = CreateWindowExW(WS_EX_CLIENTEDGE, L"EDIT", L"",
WS_CHILD|WS_VISIBLE|WS_BORDER|ES_MULTILINE|ES_READONLY|
ES_AUTOVSCROLL|WS_VSCROLL,
15, 198, 570, 120, hWnd, (HMENU)ID_NEW, NULL, NULL);
SendMessageW(hNew, WM_SETFONT, (WPARAM)hfMono, 1);
/* Checkbox for env var */
hEnvCheck = CreateWindowW(L"BUTTON",
L"Set RES_CENTER_DIR to current path",
WS_CHILD|WS_VISIBLE|BS_AUTOCHECKBOX,
15, 328, 300, 22, hWnd, (HMENU)ID_ENV, NULL, NULL);
SendMessageW(hEnvCheck, WM_SETFONT, (WPARAM)hfBody, 1);
SendMessageW(hEnvCheck, BM_SETCHECK, BST_CHECKED, 0);
hGen = CreateWindowW(L"BUTTON", L"GENERATE protk.dat",
WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON|BS_FLAT|BS_OWNERDRAW,
150, 360, 300, 36, hWnd, (HMENU)ID_GEN, NULL, NULL);
char old[4096] = {0}; ReadProtk(old, sizeof(old));
SetWindowTextA(hPrev, old);
char newp[4096] = {0}; GenerateProtk(newp, sizeof(newp));
SetWindowTextA(hNew, newp);
return 0;
}
case WM_DRAWITEM:
if (w == ID_GEN) DrawMetroButton(hGen, (LPDRAWITEMSTRUCT)l);
return 0;
case WM_COMMAND:
if (LOWORD(w) == ID_GEN) {
char newp[4096] = {0}; GenerateProtk(newp, sizeof(newp));
FILE* f = fopen("protk.dat", "wb");
if (f) {
fputs(newp, f); fclose(f);
SetWindowTextA(hPrev, newp);
/* handle env var */
if (SendMessageW(hEnvCheck, BM_GETCHECK, 0, 0) == BST_CHECKED) {
char dir[MAX_PATH]; GetExeDir(dir, sizeof(dir));
SetEnvVar("RES_CENTER_DIR", dir);
SetWindowTextW(hNew, L"protk.dat written.\r\nRES_CENTER_DIR set.\r\nRestart Creo.");
} else {
DeleteEnvVar("RES_CENTER_DIR");
SetWindowTextW(hNew, L"protk.dat written.\r\nRES_CENTER_DIR removed.\r\nRestart Creo.");
}
FlashWindow(hWnd, TRUE);
} else {
SetWindowTextW(hNew, L"ERROR: Cannot write.\r\nClose Creo if running.");
}
}
return 0;
case WM_CTLCOLORSTATIC:
case WM_CTLCOLOREDIT:
SetBkColor((HDC)w, RGB(45, 45, 45));
SetTextColor((HDC)w, RGB(255, 255, 255));
return (LRESULT)hbrDarker;
case WM_DESTROY:
if (hfTitle) DeleteObject(hfTitle);
if (hfBody) DeleteObject(hfBody);
if (hfMono) DeleteObject(hfMono);
if (hbrDark) DeleteObject(hbrDark);
if (hbrDarker) DeleteObject(hbrDarker);
if (hbrAccent) DeleteObject(hbrAccent);
PostQuitMessage(0);
return 0;
}
return DefWindowProcW(hWnd, msg, w, l);
}
int WINAPI WinMain(HINSTANCE hi, HINSTANCE hp, LPSTR cmd, int show)
{
(void)hp; (void)cmd; (void)show;
WNDCLASSW wc = {0};
wc.lpfnWndProc = WndProc; wc.hInstance = hi;
wc.hCursor = LoadCursorW(NULL, (LPCWSTR)IDC_ARROW);
wc.hbrBackground = CreateSolidBrush(RGB(32, 32, 32));
wc.lpszClassName = L"RCConfigen"; wc.hIcon = LoadIconW(hi, MAKEINTRESOURCEW(IDI_MAIN));
wc.style = CS_HREDRAW|CS_VREDRAW;
RegisterClassW(&wc);
int sw = GetSystemMetrics(SM_CXSCREEN), sh = GetSystemMetrics(SM_CYSCREEN);
int ww = 620, wh = 440;
HWND hWnd = CreateWindowExW(0, L"RCConfigen", L"Protk.dat Configurator",
WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_VISIBLE,
(sw-ww)/2, (sh-wh)/2, ww, wh, NULL, NULL, hi, NULL);
BOOL dark = TRUE;
DwmSetWindowAttribute(hWnd, 19, &dark, sizeof(dark));
DwmSetWindowAttribute(hWnd, 20, &dark, sizeof(dark));
MSG msg;
while (GetMessageW(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessageW(&msg); }
return 0;
}
Binary file not shown.
+230
View File
@@ -0,0 +1,230 @@
#define _CRT_SECURE_NO_WARNINGS
#include <windows.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <process.h>
#pragma comment(lib, "winmm.lib")
#define IDI_MAIN 1
#define ID_MAC 101
#define ID_GEN 102
#define ID_STATUS 103
static void StartBGM(void)
{
mciSendStringW(L"open poemstear.mp3 type mpegvideo alias bgm", NULL, 0, NULL);
mciSendStringW(L"play bgm repeat", NULL, 0, NULL);
}
static void StopBGM(void)
{
mciSendStringW(L"close bgm", NULL, 0, NULL);
}
static void generate(const char* mac, char* out, int sz)
{
char conv[256]; memset(conv,0,sizeof(conv));
int ci = 0, i;
for (i = 0; mac[i] && ci < 250; i++) {
char c = (char)toupper(mac[i]);
if (c == '-' || c == ' ') continue;
if (c >= 'A' && c <= 'Z') {
int v = c - 'A' + 1;
conv[ci++] = (v / 10) + '0';
conv[ci++] = (v % 10) + '0';
} else if (c >= '0' && c <= '9') {
conv[ci++] = c;
}
}
int len = (int)strlen(conv);
for (i = 0; i < len && i < sz - 1; i++)
out[i] = conv[len - 1 - i];
out[(len < sz) ? len : sz - 1] = 0;
}
static BOOL CALLBACK SetChildFont(HWND hh, LPARAM ff)
{
SendMessageW(hh, WM_SETFONT, (WPARAM)ff, 1);
return 1;
}
static HFONT hfTitle, hfBody;
static HBRUSH hbrDark, hbrDarker, hbrAccent;
static HPEN hpBorder;
static void InitTheme(void)
{
hbrDark = CreateSolidBrush(RGB(32, 32, 32));
hbrDarker = CreateSolidBrush(RGB(22, 22, 22));
hbrAccent = CreateSolidBrush(RGB(0, 120, 212));
hpBorder = CreatePen(PS_SOLID, 1, RGB(0, 120, 212));
NONCLIENTMETRICSW nm = {sizeof(nm)};
SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, sizeof(nm), &nm, 0);
nm.lfMenuFont.lfHeight = -22;
nm.lfMenuFont.lfWeight = FW_SEMIBOLD;
hfTitle = CreateFontIndirectW(&nm.lfMenuFont);
nm.lfMenuFont.lfHeight = -15;
nm.lfMenuFont.lfWeight = FW_NORMAL;
hfBody = CreateFontIndirectW(&nm.lfMenuFont);
}
static HWND CreateMetroButton(HWND parent, LPCWSTR text, int x, int y, int w, int h, int id)
{
return CreateWindowW(L"BUTTON", text,
WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON|BS_FLAT|BS_OWNERDRAW,
x, y, w, h, parent, (HMENU)id, NULL, NULL);
}
static void DrawMetroButton(HWND hBtn, LPDRAWITEMSTRUCT dis)
{
wchar_t txt[64];
GetWindowTextW(hBtn, txt, 64);
int pressed = (dis->itemState & ODS_SELECTED);
int hot = (dis->itemState & ODS_HOTLIGHT);
HBRUSH br = pressed ? CreateSolidBrush(RGB(0, 90, 170))
: hot ? CreateSolidBrush(RGB(0, 105, 190))
: hbrAccent;
FillRect(dis->hDC, &dis->rcItem, br);
if (!pressed && !hot) DeleteObject(br);
SetBkMode(dis->hDC, TRANSPARENT);
SetTextColor(dis->hDC, RGB(255,255,255));
SelectObject(dis->hDC, hfTitle);
DrawTextW(dis->hDC, txt, -1, &dis->rcItem, DT_CENTER|DT_VCENTER|DT_SINGLELINE);
}
static LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM w, LPARAM l)
{
static HWND hm, hg, hs;
switch (msg) {
case WM_CREATE: {
InitTheme();
/* Metro dark background */
SetClassLongPtrW(hWnd, GCLP_HBRBACKGROUND, (LONG_PTR)hbrDark);
HWND h = CreateWindowW(L"STATIC", L"Resource Center License Generator",
WS_CHILD|WS_VISIBLE|SS_CENTER, 20, 20, 400, 36, hWnd, NULL, NULL, NULL);
SendMessageW(h, WM_SETFONT, (WPARAM)hfTitle, 1);
CreateWindowW(L"STATIC", L"MAC ADDRESS",
WS_CHILD|WS_VISIBLE, 25, 75, 120, 22, hWnd, NULL, NULL, NULL);
hm = CreateWindowExW(WS_EX_CLIENTEDGE, L"EDIT", L"",
WS_CHILD|WS_VISIBLE|WS_BORDER|ES_UPPERCASE|ES_AUTOHSCROLL|ES_CENTER,
150, 72, 250, 30, hWnd, (HMENU)ID_MAC, NULL, NULL);
hg = CreateMetroButton(hWnd, L"GENERATE LICENSE", 90, 125, 260, 38, ID_GEN);
hs = CreateWindowW(L"STATIC", L"",
WS_CHILD|WS_VISIBLE|SS_CENTER,
20, 180, 400, 50, hWnd, (HMENU)ID_STATUS, NULL, NULL);
SendMessageW(hm, WM_SETFONT, (WPARAM)hfBody, 1);
SendMessageW(hs, WM_SETFONT, (WPARAM)hfBody, 1);
SetFocus(hm);
StartBGM();
return 0;
}
case WM_DRAWITEM:
if (w == ID_GEN) DrawMetroButton(hg, (LPDRAWITEMSTRUCT)l);
return 0;
case WM_COMMAND:
if (LOWORD(w) == ID_GEN) {
char mac[64] = {0};
GetWindowTextA(hm, mac, sizeof(mac));
if (!mac[0]) {
SetWindowTextW(hs, L"Please enter a MAC address");
FlashWindow(hWnd, TRUE);
return 0;
}
char lic[256];
generate(mac, lic, sizeof(lic));
if (!lic[0]) {
SetWindowTextW(hs, L"Invalid MAC address");
FlashWindow(hWnd, TRUE);
return 0;
}
FILE* f = fopen("res_center.lic", "w");
if (f) {
fprintf(f, "%s", lic);
fclose(f);
wchar_t wlic[380];
swprintf(wlic, 380, L"LICENSE GENERATED\nCopy res_center.lic to config\\lic\\\nKey: %hs", lic);
SetWindowTextW(hs, wlic);
} else {
SetWindowTextW(hs, L"ERROR: Cannot write file");
}
}
return 0;
case WM_CTLCOLORSTATIC:
case WM_CTLCOLOREDIT:
case WM_CTLCOLORBTN: {
HDC hdc = (HDC)w;
SetBkColor(hdc, RGB(45, 45, 45));
SetTextColor(hdc, RGB(255, 255, 255));
return (LRESULT)hbrDarker;
}
case WM_DESTROY:
StopBGM();
Sleep(200);
if (hfTitle) DeleteObject(hfTitle);
if (hfBody) DeleteObject(hfBody);
if (hbrDark) DeleteObject(hbrDark);
if (hbrDarker) DeleteObject(hbrDarker);
if (hbrAccent) DeleteObject(hbrAccent);
if (hpBorder) DeleteObject(hpBorder);
PostQuitMessage(0);
return 0;
case WM_NCHITTEST:
return DefWindowProcW(hWnd, msg, w, l);
}
return DefWindowProcW(hWnd, msg, w, l);
}
int WINAPI WinMain(HINSTANCE hi, HINSTANCE hp, LPSTR cmd, int show)
{
(void)hp; (void)cmd; (void)show;
WNDCLASSW wc = {0};
wc.lpfnWndProc = WndProc;
wc.hInstance = hi;
wc.hCursor = LoadCursorW(NULL, (LPCWSTR)IDC_ARROW);
wc.hbrBackground = CreateSolidBrush(RGB(32, 32, 32));
wc.lpszClassName = L"RCKeygenWnd";
wc.hIcon = LoadIconW(hi, MAKEINTRESOURCEW(IDI_MAIN));
wc.style = CS_HREDRAW|CS_VREDRAW;
RegisterClassW(&wc);
int sw = GetSystemMetrics(SM_CXSCREEN), sh = GetSystemMetrics(SM_CYSCREEN);
int ww = 480, wh = 270;
/* Enable drop shadow (Win10+) */
HMODULE dui = LoadLibraryW(L"user32.dll");
if (dui) {
typedef BOOL (WINAPI *SetWindowCompositionAttribute_t)(HWND, void*);
SetWindowCompositionAttribute_t fn = (SetWindowCompositionAttribute_t)
GetProcAddress(dui, "SetWindowCompositionAttribute");
if (fn) {
/* dark mode support */
}
FreeLibrary(dui);
}
HWND hWnd = CreateWindowExW(0, L"RCKeygenWnd", L"ResCenter Keygen v2.0",
WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_VISIBLE,
(sw-ww)/2, (sh-wh)/2, ww, wh, NULL, NULL, hi, NULL);
/* dark title bar (Win10 1809+) */
BOOL dark = TRUE;
DwmSetWindowAttribute(hWnd, 19 /*DWMWA_USE_IMMERSIVE_DARK_MODE*/,
&dark, sizeof(dark));
DwmSetWindowAttribute(hWnd, 20 /*DWMWA_USE_IMMERSIVE_DARK_MODE before 20H1*/,
&dark, sizeof(dark));
MSG msg;
while (GetMessageW(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessageW(&msg);
}
return 0;
}
Binary file not shown.
+2
View File
@@ -0,0 +1,2 @@
#include <windows.h>
IDI_MAIN ICON "..\\folder.ico"
Binary file not shown.