四月初在即將離開我的上一家公司--東大阿爾派深圳分公司的時候新來一位同事嚷著要和我下圍棋. 找來找去發現只有用"竹影棋友圍棋程式"可在區域網下棋.
當時在"盜亦有道"上下載了破解版, 在軟體中也可以看到"dyyd"字樣. 可是當下到250手時, 軟體彈出"共享版, 只能下250手, 然後中斷連線".
讓我一盤大優的棋沒有下完. 如此"有道":(
只得祭起wdasm8.93, (順便解決了wdam不能正確顯示種文字串的一個小bug) 結合SoftIce發現了竹影棋友的註冊演算法. 考慮到這程式有2年沒有更新,
為此貼出其序號產生器的完整程式. 這也正是當時我離開論壇時答應要做的
#include <windows.h>
#include <tchar.h>
#include "resource.h"
BOOL CALLBACK DlgProc(HWND, UINT, WPARAM, LPARAM);
BOOL CALLBACK AboutDlgProc(HWND, UINT, WPARAM, LPARAM);
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE, LPTSTR, int)
{
DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL,
DlgProc, (LPARAM)hInstance);
return 0;
}
BOOL CALLBACK AboutDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
case WM_COMMAND:
if (LOWORD(wParam) == IDCANCEL) {
EndDialog(hWnd, 0);
return TRUE;
}
}
return FALSE;
}
void CalcKey(HWND);
BOOL CALLBACK DlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
HICON hIcon;
HMENU hSysMenu;
switch (msg)
{
case WM_INITDIALOG:
hIcon = LoadIcon((HINSTANCE)lParam, MAKEINTRESOURCE(MAINICON));
SendMessage(hWnd, WM_SETICON, TRUE, (LPARAM)hIcon);
SendMessage(hWnd, WM_SETICON, FALSE, (LPARAM)hIcon);
SendMessage(GetDlgItem(hWnd, IDC_EDIT1),
EM_LIMITTEXT, 8, 0L);
SendMessage(GetDlgItem(hWnd, IDC_EDIT2),
EM_LIMITTEXT, 8, 0L);
hSysMenu = GetSystemMenu(hWnd, FALSE);
if (hSysMenu != NULL) {
AppendMenu(hSysMenu,
MF_SEPARATOR, NULL, NULL);
AppendMenu(hSysMenu,
MF_STRING, IDM_ABOUT, TEXT("關於..."));
}
return TRUE;
case WM_COMMAND:
if (LOWORD(wParam) == IDCANCEL) {
EndDialog(hWnd, 0);
return TRUE;
}
else if (LOWORD(wParam) == IDOK) {
CalcKey(hWnd);
return TRUE;
}
break;
case WM_SYSCOMMAND:
if (LOWORD(wParam) == IDM_ABOUT) {
DialogBoxParam(GetModuleHandle(NULL),
MAKEINTRESOURCE(IDD_ABOUT), NULL, AboutDlgProc, 0);
return TRUE;
}
}
return FALSE;
}
void CalcKey(HWND hWnd)
{
TCHAR Buf[9];
TCHAR* StopString;
GetDlgItemText(hWnd, IDC_EDIT1, Buf, sizeof(Buf));
if (_tcslen(Buf) != 8) {
MessageBox(hWnd, TEXT("標識號應為8位數字"), TEXT("竹影棋友序號產生器"),
MB_OK | MB_ICONEXCLAMATION);
SetFocus(GetDlgItem(hWnd, IDC_EDIT1));
return;
}
int ID = _tcstoul(Buf, &StopString, 16);
int key;
*((BYTE *)&key + 0) = *((BYTE*)&ID + 2) * *((BYTE*)&ID
+ 1) % 0xff;
*((BYTE *)&key + 1) = *((BYTE*)&ID + 3) * *((BYTE*)&ID
+ 0) % 0xfc;
*((BYTE *)&key + 2) = *((BYTE*)&ID + 1) * *((BYTE*)&ID
+ 3) % 0xfe;
*((BYTE *)&key + 3) = *((BYTE*)&ID + 0) * *((BYTE*)&ID
+ 2) % 0xfd;
wsprintf(Buf, "%08x", key);
SetDlgItemText(hWnd, IDC_EDIT2, Buf);
}