Move git root from Client/ to src/ to track all source code: - Client: Game client source (moved to Client/Client/) - Server: Game server source - GameTools: Development tools - CryptoSource: Encryption utilities - database: Database scripts - Script: Game scripts - rylCoder_16.02.2008_src: Legacy coder tools - GMFont, Game: Additional resources 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
556 lines
15 KiB
C++
556 lines
15 KiB
C++
// AuthHanDlg.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "AuthHan.h"
|
|
#include "AuthHanDlg.h"
|
|
|
|
|
|
extern "C"
|
|
{
|
|
#include <stdio.h>
|
|
#include "global.h"
|
|
#include "md5.h"
|
|
}
|
|
|
|
#include <DB/DBComponent.h>
|
|
#include <DB/AuthDBComponent.h>
|
|
#include ".\authhandlg.h"
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
static void MD5Print (unsigned char digest[16], char *output)
|
|
{
|
|
|
|
unsigned int i;
|
|
for (i = 0; i < 16; i++)
|
|
{
|
|
sprintf (output + i * 2, "%02x", digest[i]);
|
|
}
|
|
}
|
|
|
|
static void MD5String (char *string, char *output)
|
|
{
|
|
MD5_CTX context;
|
|
unsigned char digest[16];
|
|
unsigned int len = strlen (string);
|
|
|
|
MD5Init (&context);
|
|
MD5Update (&context, reinterpret_cast<unsigned char*>(string), len);
|
|
MD5Final (digest, &context);
|
|
MD5Print (digest, output);
|
|
}
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CAboutDlg dialog used for App About
|
|
class CAboutDlg : public CDialog
|
|
{
|
|
public:
|
|
CAboutDlg();
|
|
|
|
// Dialog Data
|
|
//{{AFX_DATA(CAboutDlg)
|
|
enum { IDD = IDD_ABOUTBOX };
|
|
//}}AFX_DATA
|
|
|
|
// ClassWizard generated virtual function overrides
|
|
//{{AFX_VIRTUAL(CAboutDlg)
|
|
protected:
|
|
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
|
//}}AFX_VIRTUAL
|
|
|
|
// Implementation
|
|
protected:
|
|
//{{AFX_MSG(CAboutDlg)
|
|
//}}AFX_MSG
|
|
DECLARE_MESSAGE_MAP()
|
|
};
|
|
|
|
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
|
|
{
|
|
//{{AFX_DATA_INIT(CAboutDlg)
|
|
//}}AFX_DATA_INIT
|
|
}
|
|
|
|
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(CAboutDlg)
|
|
//}}AFX_DATA_MAP
|
|
}
|
|
|
|
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
|
|
//{{AFX_MSG_MAP(CAboutDlg)
|
|
// No message handlers
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CAuthHanDlg dialog
|
|
|
|
CAuthHanDlg::CAuthHanDlg(CWnd* pParent /*=NULL*/)
|
|
: CDialog(CAuthHanDlg::IDD, pParent)
|
|
, m_AccountIn(_T(""))
|
|
, m_bBattleRylAuth(FALSE)
|
|
, m_szMD5Password(_T(""))
|
|
, m_szMD5HashValue(_T(""))
|
|
{
|
|
//{{AFX_DATA_INIT(CAuthHanDlg)
|
|
m_Log = _T("");
|
|
m_Account = _T("");
|
|
m_Password = _T("");
|
|
m_ID = _T("");
|
|
m_UID_IN = _T("");
|
|
m_Account_Out = _T("");
|
|
//}}AFX_DATA_INIT
|
|
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
|
|
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
|
|
}
|
|
|
|
void CAuthHanDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(CAuthHanDlg)
|
|
DDX_Text(pDX, IDC_LOG, m_Log);
|
|
DDX_Text(pDX, IDC_ACCOUNT, m_Account);
|
|
DDX_Text(pDX, IDC_PASSWORD, m_Password);
|
|
DDX_Text(pDX, IDC_ID, m_ID);
|
|
DDX_Text(pDX, IDC_UID_IN, m_UID_IN);
|
|
DDX_Text(pDX, IDC_ACCOUNT_OUT, m_Account_Out);
|
|
//}}AFX_DATA_MAP
|
|
DDX_Text(pDX, IDC_ACCOUNT_IN, m_AccountIn);
|
|
DDX_Check(pDX, IDC_BATTLERYL_CHECK, m_bBattleRylAuth);
|
|
DDX_Text(pDX, IDC_MD5_PASSWORD, m_szMD5Password);
|
|
DDX_Text(pDX, IDC_MD5_HASHVAL, m_szMD5HashValue);
|
|
}
|
|
|
|
BEGIN_MESSAGE_MAP(CAuthHanDlg, CDialog)
|
|
//{{AFX_MSG_MAP(CAuthHanDlg)
|
|
ON_WM_SYSCOMMAND()
|
|
ON_WM_PAINT()
|
|
ON_WM_QUERYDRAGICON()
|
|
ON_BN_CLICKED(IDC_CONNECT, OnConnect)
|
|
ON_BN_CLICKED(IDC_AUTH, OnAuth)
|
|
ON_BN_CLICKED(IDC_UPDATE, OnUpdate)
|
|
ON_BN_CLICKED(IDC_FIND, OnFind)
|
|
//}}AFX_MSG_MAP
|
|
ON_BN_CLICKED(IDC_REG, OnBnClickedReg)
|
|
ON_BN_CLICKED(IDC_FIND_UID_LIST, OnBnClickedFindUidList)
|
|
ON_BN_CLICKED(IDC_FIND_ACCOUNT_LIST, OnBnClickedFindAccountList)
|
|
ON_BN_CLICKED(IDC_MD5_CONVERT, OnBnClickedMd5Convert)
|
|
END_MESSAGE_MAP()
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CAuthHanDlg message handlers
|
|
|
|
BOOL CAuthHanDlg::OnInitDialog()
|
|
{
|
|
CDialog::OnInitDialog();
|
|
|
|
// Add "About..." menu item to system menu.
|
|
|
|
// IDM_ABOUTBOX must be in the system command range.
|
|
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
|
|
ASSERT(IDM_ABOUTBOX < 0xF000);
|
|
|
|
CMenu* pSysMenu = GetSystemMenu(FALSE);
|
|
if (pSysMenu != NULL)
|
|
{
|
|
CString strAboutMenu;
|
|
strAboutMenu.LoadString(IDS_ABOUTBOX);
|
|
if (!strAboutMenu.IsEmpty())
|
|
{
|
|
pSysMenu->AppendMenu(MF_SEPARATOR);
|
|
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
|
|
}
|
|
}
|
|
|
|
// Set the icon for this dialog. The framework does this automatically
|
|
// when the application's main window is not a dialog
|
|
SetIcon(m_hIcon, TRUE); // Set big icon
|
|
SetIcon(m_hIcon, FALSE); // Set small icon
|
|
|
|
// TODO: Add extra initialization here
|
|
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
|
}
|
|
|
|
void CAuthHanDlg::OnSysCommand(UINT nID, LPARAM lParam)
|
|
{
|
|
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
|
|
{
|
|
CAboutDlg dlgAbout;
|
|
dlgAbout.DoModal();
|
|
}
|
|
else
|
|
{
|
|
CDialog::OnSysCommand(nID, lParam);
|
|
}
|
|
}
|
|
|
|
// If you add a minimize button to your dialog, you will need the code below
|
|
// to draw the icon. For MFC applications using the document/view model,
|
|
// this is automatically done for you by the framework.
|
|
|
|
void CAuthHanDlg::OnPaint()
|
|
{
|
|
if (IsIconic())
|
|
{
|
|
CPaintDC dc(this); // device context for painting
|
|
|
|
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
|
|
|
|
// Center icon in client rectangle
|
|
int cxIcon = GetSystemMetrics(SM_CXICON);
|
|
int cyIcon = GetSystemMetrics(SM_CYICON);
|
|
CRect rect;
|
|
GetClientRect(&rect);
|
|
int x = (rect.Width() - cxIcon + 1) / 2;
|
|
int y = (rect.Height() - cyIcon + 1) / 2;
|
|
|
|
// Draw the icon
|
|
dc.DrawIcon(x, y, m_hIcon);
|
|
}
|
|
else
|
|
{
|
|
CDialog::OnPaint();
|
|
}
|
|
}
|
|
|
|
// The system calls this to obtain the cursor to display while the user drags
|
|
// the minimized window.
|
|
HCURSOR CAuthHanDlg::OnQueryDragIcon()
|
|
{
|
|
return (HCURSOR) m_hIcon;
|
|
}
|
|
|
|
void CAuthHanDlg::OnConnect()
|
|
{
|
|
// TODO: Add your control notification handler code here
|
|
if(CDBSingleObject::GetInstance().Connect(CDBSingleObject::Class_AuthDB))
|
|
{
|
|
m_Log = "Connected";
|
|
}
|
|
else
|
|
{
|
|
m_Log = "Connected failed";
|
|
}
|
|
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
typedef struct _ACCOUNT
|
|
{
|
|
char Account[16];
|
|
char Password[16];
|
|
}ACCOUNT, *LPACCOUNT;
|
|
|
|
void CAuthHanDlg::OnAuth()
|
|
{
|
|
UpdateData();
|
|
|
|
AuthUserHangame();
|
|
}
|
|
|
|
void CAuthHanDlg::AuthUserHangame(void)
|
|
{
|
|
UpdateData();
|
|
|
|
HAN_UID hanUID;
|
|
|
|
char szPassword[33];
|
|
memset(szPassword, 0, sizeof(char) * 33);
|
|
MD5String(m_Password.GetBuffer(0), szPassword);
|
|
|
|
bool bResult = !m_bBattleRylAuth ?
|
|
DBComponent::AuthDB::LoginAuthHan(CDBSingleObject::GetInstance(),
|
|
m_Account.GetBuffer(0), szPassword, hanUID) :
|
|
DBComponent::AuthDB::LoginBattleAuthHan(CDBSingleObject::GetInstance(),
|
|
m_Account.GetBuffer(0), szPassword, hanUID);
|
|
|
|
if(bResult)
|
|
{
|
|
unsigned long UserID = hanUID.hUID;
|
|
|
|
if(UserID > 100)
|
|
{
|
|
m_ID.Format("%d", UserID);
|
|
m_Log.Format("H:0x%08x L:0x%08x", hanUID.hUID, hanUID.lUID);
|
|
}
|
|
else
|
|
{
|
|
switch(UserID)
|
|
{
|
|
case 1: m_Log = "password mismatch"; break;
|
|
case 2: m_Log = "한게임 사용자가 아니거나 비정상적인 사용자"; break;
|
|
case 3: m_Log = "동의한 사용자가 아님"; break;
|
|
case 4: m_Log = "연령 미달"; break;
|
|
case 5: m_Log = "3회 이상 로그인 실패"; break;
|
|
case 6: m_Log = "동의한 사용자이지만 게임을 할 수 없는 상태"; break;
|
|
default:
|
|
m_Log.Format("기타 에러 : %u : H:0x%08x L:0x%08x", UserID, hanUID.hUID, hanUID.lUID);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
m_Log = CDBSingleObject::GetInstance().GetErrorString();
|
|
}
|
|
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
void CAuthHanDlg::OnUpdate()
|
|
{
|
|
UpdateData();
|
|
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
void CAuthHanDlg::OnFind()
|
|
{
|
|
UpdateData();
|
|
|
|
DWORD UserID = 0;
|
|
char UID[16] = "";
|
|
char Account[16] = "";
|
|
|
|
if(0 != m_AccountIn.GetLength())
|
|
{
|
|
bool bResult = !m_bBattleRylAuth ?
|
|
DBComponent::AuthDB::GetUIDByAccount(CDBSingleObject::GetInstance(), m_AccountIn.GetBuffer(0), UID)
|
|
: DBComponent::AuthDB::GetBattleUIDByAccount(CDBSingleObject::GetInstance(), m_AccountIn.GetBuffer(0), UID);
|
|
|
|
if(bResult)
|
|
{
|
|
m_ID = UID;
|
|
m_Account_Out = "";
|
|
}
|
|
else
|
|
{
|
|
m_Log = CDBSingleObject::GetInstance().GetErrorString();
|
|
}
|
|
}
|
|
else if(0 != m_UID_IN.GetLength())
|
|
{
|
|
bool bResult = !m_bBattleRylAuth ?
|
|
DBComponent::AuthDB::GetAccountByUID(CDBSingleObject::GetInstance(), atoi(m_UID_IN.GetBuffer(0)), Account)
|
|
: DBComponent::AuthDB::GetBattleAccountByUID(CDBSingleObject::GetInstance(), atoi(m_UID_IN.GetBuffer(0)), Account);
|
|
|
|
if(bResult)
|
|
{
|
|
m_ID = "";
|
|
m_Account_Out = Account;
|
|
}
|
|
else
|
|
{
|
|
m_Log = CDBSingleObject::GetInstance().GetErrorString();
|
|
}
|
|
}
|
|
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
void CAuthHanDlg::OnBnClickedReg()
|
|
{
|
|
UpdateData();
|
|
|
|
|
|
bool bResult = !m_bBattleRylAuth ?
|
|
DBComponent::AuthDB::RegRylGameHan(CDBSingleObject::GetInstance(), m_Account.GetBuffer(0), "Y")
|
|
: DBComponent::AuthDB::RegBattleRylGameHan(CDBSingleObject::GetInstance(), m_Account.GetBuffer(0), "Y");
|
|
|
|
m_Log = bResult ? "Query Ok..." : CDBSingleObject::GetInstance().GetErrorString();
|
|
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
void CAuthHanDlg::OnBnClickedFindUidList()
|
|
{
|
|
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
|
|
|
|
// 1. 읽을 파일을 연다
|
|
// 2. 쓸 파일이름을 받아서 연다.
|
|
|
|
// 3. GetAccountByUID 를 사용하여 하나씩 읽어 온다
|
|
// 4. 리스트에 읽어온 결과를 기록한다
|
|
// 5. 파일을 닫는다.
|
|
|
|
UpdateData();
|
|
|
|
OPENFILENAME openfile;
|
|
OPENFILENAME savefile;
|
|
|
|
char szOpenFileName[MAX_PATH * MAX_PATH] = "";
|
|
char szSaveFileName[MAX_PATH] = "";
|
|
|
|
memset(&openfile, 0, sizeof(OPENFILENAME));
|
|
memset(&savefile, 0, sizeof(OPENFILENAME));
|
|
|
|
openfile.lStructSize = sizeof(OPENFILENAME);
|
|
openfile.hwndOwner = m_hWnd;
|
|
openfile.lpstrFilter = "All Files(*.*)\0*.*\0";
|
|
openfile.lpstrFile = szOpenFileName;
|
|
|
|
openfile.nMaxFile = MAX_PATH * MAX_PATH;
|
|
openfile.Flags = OFN_FILEMUSTEXIST | OFN_LONGNAMES | OFN_EXPLORER;
|
|
|
|
savefile.lStructSize = sizeof(OPENFILENAME);
|
|
savefile.hwndOwner = m_hWnd;
|
|
savefile.lpstrFilter = "All Files(*.*)\0*.*\0";
|
|
savefile.lpstrFile = szSaveFileName;
|
|
savefile.nMaxFile = MAX_PATH;
|
|
savefile.Flags = OFN_LONGNAMES | OFN_EXPLORER;
|
|
|
|
bool bResult = false;
|
|
|
|
if(GetOpenFileName(&openfile))
|
|
{
|
|
if(GetSaveFileName(&savefile))
|
|
{
|
|
FILE* readfile = fopen(szOpenFileName, "rt");
|
|
|
|
if(NULL != readfile)
|
|
{
|
|
FILE* writefile = fopen(szSaveFileName, "wt");
|
|
|
|
if(NULL != writefile)
|
|
{
|
|
const int MAX_BUFFER = 4000;
|
|
char szUID[MAX_BUFFER];
|
|
char Account[16] = "";
|
|
|
|
while(fgets(szUID, MAX_BUFFER, readfile))
|
|
{
|
|
char* stopstring = NULL;
|
|
unsigned long dwUID = strtoul(szUID, &stopstring, 10);
|
|
|
|
if(0 < dwUID)
|
|
{
|
|
bool bResult = !m_bBattleRylAuth ? DBComponent::AuthDB::GetAccountByUID(CDBSingleObject::GetInstance(), dwUID, Account)
|
|
: DBComponent::AuthDB::GetBattleAccountByUID(CDBSingleObject::GetInstance(), dwUID, Account);
|
|
|
|
if(bResult)
|
|
{
|
|
fprintf(writefile, "%10d\t%s\n", dwUID, Account);
|
|
}
|
|
else
|
|
{
|
|
fprintf(writefile, "%10d\t%s\n", dwUID, CDBSingleObject::GetInstance().GetErrorString());
|
|
}
|
|
}
|
|
|
|
Sleep(50);
|
|
}
|
|
|
|
bResult = true;
|
|
fclose(writefile);
|
|
}
|
|
|
|
fclose(readfile);
|
|
}
|
|
}
|
|
}
|
|
|
|
MessageBox(bResult ? "변환이 완료되었습니다." : "변환을 실패하였습니다");
|
|
}
|
|
|
|
void CAuthHanDlg::OnBnClickedFindAccountList()
|
|
{
|
|
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
|
|
|
|
UpdateData();
|
|
|
|
OPENFILENAME openfile;
|
|
OPENFILENAME savefile;
|
|
|
|
char szOpenFileName[MAX_PATH * MAX_PATH] = "";
|
|
char szSaveFileName[MAX_PATH] = "";
|
|
|
|
memset(&openfile, 0, sizeof(OPENFILENAME));
|
|
memset(&savefile, 0, sizeof(OPENFILENAME));
|
|
|
|
openfile.lStructSize = sizeof(OPENFILENAME);
|
|
openfile.hwndOwner = m_hWnd;
|
|
openfile.lpstrFilter = "All Files(*.*)\0*.*\0";
|
|
openfile.lpstrFile = szOpenFileName;
|
|
|
|
openfile.nMaxFile = MAX_PATH * MAX_PATH;
|
|
openfile.Flags = OFN_FILEMUSTEXIST | OFN_LONGNAMES | OFN_EXPLORER;
|
|
|
|
savefile.lStructSize = sizeof(OPENFILENAME);
|
|
savefile.hwndOwner = m_hWnd;
|
|
savefile.lpstrFilter = "All Files(*.*)\0*.*\0";
|
|
savefile.lpstrFile = szSaveFileName;
|
|
savefile.nMaxFile = MAX_PATH;
|
|
savefile.Flags = OFN_LONGNAMES | OFN_EXPLORER;
|
|
|
|
bool bResult = false;
|
|
|
|
if(GetOpenFileName(&openfile))
|
|
{
|
|
if(GetSaveFileName(&savefile))
|
|
{
|
|
FILE* readfile = fopen(szOpenFileName, "rt");
|
|
|
|
if(NULL != readfile)
|
|
{
|
|
FILE* writefile = fopen(szSaveFileName, "wt");
|
|
|
|
if(NULL != writefile)
|
|
{
|
|
const int MAX_BUFFER = 4000;
|
|
char szAccount[MAX_BUFFER];
|
|
char szUID[16] = "";
|
|
|
|
while(fgets(szUID, MAX_BUFFER, readfile))
|
|
{
|
|
char* stopstring = NULL;
|
|
|
|
bool bResult = !m_bBattleRylAuth ? DBComponent::AuthDB::GetUIDByAccount(CDBSingleObject::GetInstance(), szAccount, szUID)
|
|
: DBComponent::AuthDB::GetBattleUIDByAccount(CDBSingleObject::GetInstance(), szAccount, szUID);
|
|
|
|
if(bResult)
|
|
{
|
|
fprintf(writefile, "%s\t%s\n", szUID, szAccount);
|
|
}
|
|
else
|
|
{
|
|
fprintf(writefile, "%s\t%s\n", szUID, CDBSingleObject::GetInstance().GetErrorString());
|
|
}
|
|
|
|
Sleep(50);
|
|
}
|
|
|
|
bResult = true;
|
|
fclose(writefile);
|
|
}
|
|
|
|
fclose(readfile);
|
|
}
|
|
}
|
|
}
|
|
|
|
MessageBox(bResult ? "변환이 완료되었습니다." : "변환을 실패하였습니다");
|
|
}
|
|
|
|
void CAuthHanDlg::OnBnClickedMd5Convert()
|
|
{
|
|
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
|
|
UpdateData();
|
|
|
|
char szPassword[33];
|
|
memset(szPassword, 0, sizeof(char) * 33);
|
|
MD5String(m_szMD5Password.GetBuffer(0), szPassword);
|
|
|
|
m_szMD5HashValue = szPassword;
|
|
|
|
UpdateData(FALSE);
|
|
}
|