GkkAuto

出自ProgWiki

跳轉到: 導航, 搜尋

目錄

用途

注意事項

開發環境
原理

程式碼

AUTO.EXE

stdafx.h

#pragma once
 
#define VC_EXTRALEAN		// Exclude rarely-used stuff from Windows headers
 
#include <afxwin.h>         // MFC core and standard components
#include <afxext.h>         // MFC extensions
#include <afxdtctl.h>		// MFC support for Internet Explorer 4 Common Controls
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h>			// MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
 
 
//{{AFX_INSERT_LOCATION}}

stdafx.cpp

#include "stdafx.h"

auto.h

#pragma once
 
#ifndef __AFXWIN_H__
	#error include 'stdafx.h' before including this file for PCH
#endif
 
#include "resource.h"		// main symbols
 
char UserID[];
 
/////////////////////////////////////////////////////////////////////////////
// CAutoApp:
// See auto.cpp for the implementation of this class
//
 
class CAutoApp : public CWinApp
{
public:
	CAutoApp();
 
// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAutoApp)
	public:
	virtual BOOL InitInstance();
	//}}AFX_VIRTUAL
 
// Implementation
 
	//{{AFX_MSG(CAutoApp)
		// NOTE - the ClassWizard will add and remove member functions here.
		//    DO NOT EDIT what you see in these blocks of generated code !
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
protected:
	void catpath( LPSTR dst, LPSTR src );
	BOOL CheckPlayer();
	BOOL GetRegistry(LPSTR key1, LPSTR key2, LPSTR SubKey, LPSTR Vname, LPBYTE ptr);
};
 
//{{AFX_INSERT_LOCATION}}

auto.cpp

#include "stdafx.h"
#include "auto.h"
#include "autoDlg.h"
#include "GKKAUTO.h"
 
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
 
/////////////////////////////////////////////////////////////////////////////
// CAutoApp
 
BEGIN_MESSAGE_MAP(CAutoApp, CWinApp)
	//{{AFX_MSG_MAP(CAutoApp)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG
	ON_COMMAND(ID_HELP, CWinApp::OnHelp)
END_MESSAGE_MAP()
 
/////////////////////////////////////////////////////////////////////////////
// CAutoApp construction
 
CAutoApp::CAutoApp()
{
	// TODO: add construction code here,
	// Place all significant initialization in InitInstance
}
 
/////////////////////////////////////////////////////////////////////////////
// The one and only CAutoApp object
 
CAutoApp theApp;
char UserID[64];
 
/////////////////////////////////////////////////////////////////////////////
// CAutoApp initialization
 
BOOL CAutoApp::InitInstance()
{
#ifdef _AFXDLL
	Enable3dControls();			// Call this when using MFC in a shared DLL
#else
	Enable3dControlsStatic();	// Call this when linking to MFC statically
#endif
 
	if (CheckPlayer() != TRUE) {
		::MessageBox( NULL, "您被認定不是合法授權的使用者\n\n請經由提供者向上游洽詢", "警告", MB_ICONEXCLAMATION | MB_OK );
		return FALSE;
	}
 
	CAutoDlg dlg;
	m_pMainWnd = &dlg;
	int nResponse = dlg.DoModal();
	if (nResponse == IDOK)
	{
	}
	else if (nResponse == IDCANCEL)
	{
	}
 
	return FALSE;
}
 
BOOL CAutoApp::CheckPlayer()
{
	static char	playerID[2][64]={"playercd8@hotmail.com","playercd8@hotmail.com"};
	char	key1[]="Microsoft";
	char	key2[]="Internet Account Manager";
	char	Subkey[256];
	char	Vname[256];
	char	ptr[256];
 
	lstrcpy( Vname, "Default Mail Account" );
 
	if (GetRegistry(key1, key2, NULL, Vname, (LPBYTE) &ptr) != TRUE)
		return FALSE;
 
	lstrcpy( Subkey, "Accounts" );
	catpath( Subkey, ptr);
	lstrcpy( Vname, "SMTP Email Address" );
	if (GetRegistry(key1, key2, Subkey, Vname, (LPBYTE) &ptr) != TRUE)
		return FALSE;
 
	lstrcpy( UserID, playerID[0] );
	for (int i=0; i<lstrlen(playerID[1]); i++)
		UserID[i] ^= playerID[1][i];
	if (lstrcmp(UserID, ptr) != 0)
		return FALSE;
 
	return TRUE;
}
 
BOOL CAutoApp::GetRegistry(LPSTR key1, LPSTR key2, LPSTR SubKey, LPSTR Vname, LPBYTE ptr)
{
	char buf[256];
	HKEY key;
	DWORD size;
 
	lstrcpy( buf, "Software" );
	if(   key1 != NULL &&   *key1 != '\0' )  catpath( buf,   key1 );
	if(   key2 != NULL &&   *key2 != '\0' )  catpath( buf,   key2 );
	if( SubKey != NULL && *SubKey != '\0' )  catpath( buf, SubKey );
 
	if( RegOpenKeyEx( HKEY_CURRENT_USER, buf, 0, KEY_ALL_ACCESS, &key ) != ERROR_SUCCESS ) return FALSE;
 
	if( RegQueryValueEx( key, Vname, NULL, NULL, NULL, &size ) != ERROR_SUCCESS ){
		RegCloseKey(key);
		return FALSE;
	}
 
	RegQueryValueEx( key, Vname, NULL, NULL, ptr, &size );
	RegCloseKey(key);
 
	return TRUE;
 
}
 
void CAutoApp::catpath(LPSTR dst, LPSTR src)
{
    int		len;
 
	len = lstrlen(dst);
 
	if( (len>0) && (dst[len-1]!='\\') && (dst[len-1]!='/') ) lstrcat( dst, "\\");
 
    lstrcat( dst, src );
    dst[lstrlen(dst)+1] = '\0';
}


auto.rc

//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
 
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
 
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
 
/////////////////////////////////////////////////////////////////////////////
// Chinese (Taiwan) resources
 
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHT)
#ifdef _WIN32
LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_TRADITIONAL
#pragma code_page(950)
#endif //_WIN32
 
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
 
1 TEXTINCLUDE DISCARDABLE 
BEGIN
    "resource.h\0"
END
 
2 TEXTINCLUDE DISCARDABLE 
BEGIN
    "#include ""afxres.h""\r\n"
    "\0"
END
 
3 TEXTINCLUDE DISCARDABLE 
BEGIN
    "#define _AFX_NO_SPLITTER_RESOURCES\r\n"
    "#define _AFX_NO_OLE_RESOURCES\r\n"
    "#define _AFX_NO_TRACKER_RESOURCES\r\n"
    "#define _AFX_NO_PROPERTY_RESOURCES\r\n"
    "\r\n"
    "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHT)\r\n"
    "#ifdef _WIN32\r\n"
    "LANGUAGE 4, 1\r\n"
    "#pragma code_page(950)\r\n"
    "#endif //_WIN32\r\n"
    "#include ""res\\auto.rc2""  // non-Microsoft Visual C++ edited resources\r\n"
    "#include ""l.cht\\afxres.rc""          // Standard components\r\n"
    "#endif\r\n"
    "\0"
END
 
#endif    // APSTUDIO_INVOKED
 
 
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
 
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDR_MAINFRAME           ICON    DISCARDABLE     "res\\auto.ico"
 
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
 
IDD_ABOUTBOX DIALOG DISCARDABLE  0, 0, 235, 97
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "關於 GKK Auto Command"
FONT 9, "新細明體"
BEGIN
    ICON            IDR_MAINFRAME,IDC_STATIC,11,17,20,20
    LTEXT           "GKK Auto Command Version 1.0.0.1",IDC_STATIC,40,10,119,
                    8,SS_NOPREFIX
    LTEXT           "Copyright (C) 2000",IDC_STATIC,40,25,119,8
    DEFPUSHBUTTON   "確定",IDOK,178,7,50,14,WS_GROUP
    LTEXT           "作者:\tplayercd8@hotmail.com\n\thttp://www.player.idv.tw/prog",
                    IDC_STATIC,38,41,190,24
    LTEXT           "使用者:\t秘密",IDC_UserID,38,71,190,13
END
 
IDD_AUTO_DIALOG DIALOGEX 0, 0, 283, 215
STYLE DS_MODALFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP | 
    WS_VISIBLE | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_APPWINDOW
CAPTION "GKK Auto Command"
FONT 9, "新細明體"
BEGIN
    GROUPBOX        "要重複執行的GKK指令",IDC_STATIC,7,7,269,91
    EDITTEXT        IDC_GKK_Commands,13,17,257,77,ES_MULTILINE | 
                    ES_WANTRETURN | WS_VSCROLL | WS_HSCROLL
    GROUPBOX        "執行參數",IDC_STATIC,7,102,126,51
    LTEXT           "每行延遲(5~99)秒:",IDC_STATIC,13,113,67,12
    LTEXT           "循還延遲(5~99)秒:",IDC_STATIC,13,131,67,12
    EDITTEXT        IDC_N_SEC,83,111,40,14,ES_AUTOHSCROLL
    EDITTEXT        IDC_M_SEC,84,129,40,14,ES_AUTOHSCROLL
    GROUPBOX        "範例命令",IDC_STATIC,141,103,135,50
    PUSHBUTTON      "到處跑(騎士)",IDC_BUTTON_RUN,147,115,50,14
    PUSHBUTTON      "到處跑(遊俠)",IDC_BUTTON_RUN2,147,133,50,14
    GROUPBOX        "狀態",IDC_STATIC,7,157,269,29
    LTEXT           "",IDC_Description,13,171,255,8
    PUSHBUTTON      "開始",IDC_BUTTON_START,7,194,50,14
    PUSHBUTTON      "暫停",IDC_BUTTON_STOP,62,194,50,14
    PUSHBUTTON      "儲存",IDC_BUTTON_SAVE,116,194,50,14
    PUSHBUTTON      "載入",IDC_BUTTON_LOAD,169,194,50,14
    PUSHBUTTON      "結束",IDOK,226,194,50,14
END
 
 
#ifndef _MAC
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
 
VS_VERSION_INFO VERSIONINFO
 FILEVERSION 1,0,0,2
 PRODUCTVERSION 1,0,0,2
 FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
 FILEFLAGS 0x1L
#else
 FILEFLAGS 0x0L
#endif
 FILEOS 0x4L
 FILETYPE 0x1L
 FILESUBTYPE 0x0L
BEGIN
    BLOCK "StringFileInfo"
    BEGIN
        BLOCK "040404b0"
        BEGIN
            VALUE "Comments", "\0"
            VALUE "CompanyName", "\0"
            VALUE "FileDescription", "GKK auto Command\0"
            VALUE "FileVersion", "1, 0, 0, 2\0"
            VALUE "InternalName", "auto\0"
            VALUE "LegalCopyright", "Copyright (C) 2000\0"
            VALUE "LegalTrademarks", "\0"
            VALUE "OriginalFilename", "auto.EXE\0"
            VALUE "PrivateBuild", "\0"
            VALUE "ProductName", "GKK auto Command\0"
            VALUE "ProductVersion", "1, 0, 0, 2\0"
            VALUE "SpecialBuild", "\0"
        END
    END
    BLOCK "VarFileInfo"
    BEGIN
        VALUE "Translation", 0x404, 1200
    END
END
 
#endif    // !_MAC
 
 
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
 
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE 
BEGIN
    IDD_ABOUTBOX, DIALOG
    BEGIN
        LEFTMARGIN, 7
        RIGHTMARGIN, 228
        TOPMARGIN, 7
        BOTTOMMARGIN, 90
    END
 
    IDD_AUTO_DIALOG, DIALOG
    BEGIN
        LEFTMARGIN, 7
        RIGHTMARGIN, 276
        TOPMARGIN, 7
        BOTTOMMARGIN, 208
    END
END
#endif    // APSTUDIO_INVOKED
 
 
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
 
STRINGTABLE DISCARDABLE 
BEGIN
    IDS_ABOUTBOX            "關於 GKK Auto command(&A)..."
END
 
#endif    // Chinese (Taiwan) resources
/////////////////////////////////////////////////////////////////////////////
 
 
 
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
#define _AFX_NO_SPLITTER_RESOURCES
#define _AFX_NO_OLE_RESOURCES
#define _AFX_NO_TRACKER_RESOURCES
#define _AFX_NO_PROPERTY_RESOURCES
 
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHT)
#ifdef _WIN32
LANGUAGE 4, 1
#pragma code_page(950)
#endif //_WIN32
#include "res\auto.rc2"  // non-Microsoft Visual C++ edited resources
#include "l.cht\afxres.rc"          // Standard components
#endif
 
/////////////////////////////////////////////////////////////////////////////
#endif    // not APSTUDIO_INVOKED

RESOURCE.H

//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by auto.rc
//
#define IDM_ABOUTBOX                    0x0010
#define IDD_ABOUTBOX                    100
#define IDS_ABOUTBOX                    101
#define IDD_AUTO_DIALOG                 102
#define IDR_MAINFRAME                   128
#define IDC_GKK_Commands                1000
#define IDC_BUTTON_START                1001
#define IDC_BUTTON_STOP                 1002
#define IDC_N_SEC                       1003
#define IDC_M_SEC                       1004
#define IDC_Description                 1005
#define IDC_BUTTON_RUN                  1006
#define IDC_BUTTON_SAVE                 1007
#define IDC_BUTTON_LOAD                 1008
#define IDC_BUTTON_RUN2                 1009
#define IDC_UserID                      1010
 
// Next default values for new objects
// 
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE        129
#define _APS_NEXT_COMMAND_VALUE         32771
#define _APS_NEXT_CONTROL_VALUE         1011
#define _APS_NEXT_SYMED_VALUE           101
#endif
#endif

autoDlg.h

#include "GKKAUTO.h"
 
#pragma once
 
/////////////////////////////////////////////////////////////////////////////
// CAutoDlg dialog
 
class CAutoDlg : public CDialog
{
// Construction
public:
	CGKKAUTO GKKAUTO;
	CAutoDlg(CWnd* pParent = NULL);	// standard constructor
// Dialog Data
	//{{AFX_DATA(CAutoDlg)
	enum { IDD = IDD_AUTO_DIALOG };
		// NOTE: the ClassWizard will add data members here
	//}}AFX_DATA
 
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAutoDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support
	//}}AFX_VIRTUAL
 
// Implementation
protected:
	HICON m_hIcon;
 
	// Generated message map functions
	//{{AFX_MSG(CAutoDlg)
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	afx_msg void OnButtonStart();
	afx_msg void OnButtonStop();
	afx_msg void OnButtonRun();
	afx_msg void OnTimer(UINT nIDEvent);
	afx_msg void OnButtonSave();
	afx_msg void OnButtonLoad();
	afx_msg void OnButtonRun2();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};
 
//{{AFX_INSERT_LOCATION}}

autoDlg.cpp

#include "stdafx.h"
#include "afxdlgs.h"
#include "auto.h"
#include "autoDlg.h"
#include "GKKAUTO.h"
 
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
 
/////////////////////////////////////////////////////////////////////////////
// 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)
	virtual BOOL OnInitDialog();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};
 
BOOL CAboutDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
 
	// TODO: Add extra initialization here
	char	OutStr[256];
	wsprintf(OutStr ,"使用者:\t%s", UserID);//"秘密"
	CAboutDlg::SetDlgItemText(IDC_UserID, OutStr);
 
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
 
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)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()
 
/////////////////////////////////////////////////////////////////////////////
// CAutoDlg dialog
 
CAutoDlg::CAutoDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CAutoDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CAutoDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
 
void CAutoDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAutoDlg)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}
 
BEGIN_MESSAGE_MAP(CAutoDlg, CDialog)
	//{{AFX_MSG_MAP(CAutoDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(IDC_BUTTON_START, OnButtonStart)
	ON_BN_CLICKED(IDC_BUTTON_STOP, OnButtonStop)
	ON_BN_CLICKED(IDC_BUTTON_RUN, OnButtonRun)
	ON_WM_TIMER()
	ON_BN_CLICKED(IDC_BUTTON_SAVE, OnButtonSave)
	ON_BN_CLICKED(IDC_BUTTON_LOAD, OnButtonLoad)
	ON_BN_CLICKED(IDC_BUTTON_RUN2, OnButtonRun2)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()
 
/////////////////////////////////////////////////////////////////////////////
// CAutoDlg message handlers
 
BOOL CAutoDlg::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
	CAutoDlg::SetDlgItemInt(IDC_N_SEC, 15, TRUE );
	CAutoDlg::SetDlgItemInt(IDC_M_SEC, 15, TRUE );
 
	return TRUE;  // return TRUE  unless you set the focus to a control
}
 
void CAutoDlg::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 CAutoDlg::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 CAutoDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}
 
void CAutoDlg::OnButtonStart() 
{
	// TODO: Add your control notification handler code here
 
	GKKAUTO.N_SEC = CAutoDlg::GetDlgItemInt(IDC_N_SEC, NULL, TRUE );
	GKKAUTO.M_SEC = CAutoDlg::GetDlgItemInt(IDC_M_SEC, NULL, TRUE );
	CAutoDlg::GetDlgItemText(IDC_GKK_Commands, GKKAUTO.GKK_Command, sizeof(GKKAUTO.GKK_Command));
	CAutoDlg::SetDlgItemText(IDC_Description, "開始送出自動GKK指令");
 
	SetTimer(1, 250, NULL);
	GKKAUTO.Start();
}
 
void CAutoDlg::OnButtonStop() 
{
	// TODO: Add your control notification handler code here
	CAutoDlg::SetDlgItemText(IDC_Description, "停止送出自動GKK指令");
	GKKAUTO.Stop();
}
 
void CAutoDlg::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default
 
	CDialog::OnTimer(nIDEvent);
	GKKAUTO.Work();
}
 
void CAutoDlg::OnButtonSave() 
{
	// TODO: Add your control notification handler code here
	char	buf[16 * 1024];
	CString	fileName = "GKK_Cmd.txt";
	char	filters[] = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*|";
	HANDLE Handle;
 
	CFileDialog	fileDlg (FALSE, "*.txt" , fileName, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, filters , NULL );
	fileDlg.DoModal();
	fileName = fileDlg.GetPathName();
 
	Handle = CreateFile( fileName, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
	if( Handle == INVALID_HANDLE_VALUE ){
		CAutoDlg::SetDlgItemText(IDC_Description, "檔案無法寫入");
		return;
	}
	if( Handle == NULL ){
		CAutoDlg::SetDlgItemText(IDC_Description, "檔案無法寫入");
		return;
	}
 
	CAutoDlg::GetDlgItemText(IDC_GKK_Commands, buf, sizeof(buf));
	DWORD	WriteSize = lstrlen( buf );
	WriteFile( Handle, (LPVOID)buf, WriteSize, &WriteSize, NULL ); 
 	CloseHandle( Handle );
 
	CAutoDlg::SetDlgItemText(IDC_Description, "指令檔案已寫入");
}
 
void CAutoDlg::OnButtonLoad() 
{
	// TODO: Add your control notification handler code here
	char	buf[16 * 1024];
	CString	fileName = "GKK_Cmd.txt";
	char	filters[] = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*|";
	HANDLE Handle;
 
	CFileDialog	fileDlg (TRUE, "*.txt" , fileName, NULL , filters , NULL );
	fileDlg.DoModal();
	fileName = fileDlg.GetPathName();
 
	Handle = CreateFile( fileName, GENERIC_READ, FILE_SHARE_READ, (LPSECURITY_ATTRIBUTES)NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, (HANDLE)NULL );
	if( Handle == INVALID_HANDLE_VALUE ){
		CAutoDlg::SetDlgItemText(IDC_Description, "檔案無法讀取");
		return;
	}
 
	if( Handle == NULL ){
		CAutoDlg::SetDlgItemText(IDC_Description, "檔案無法讀取");
		return;
	}
 
	DWORD	ReadSize = GetFileSize( Handle, NULL );
	ReadFile( Handle, (LPVOID)buf, ReadSize, &ReadSize, NULL ); 
	CloseHandle( Handle );
 
	buf[ReadSize] = 0;
	CAutoDlg::SetDlgItemText(IDC_Description, "指令檔案已載入");
	CAutoDlg::SetDlgItemText(IDC_GKK_Commands, buf);
}
 
void CAutoDlg::OnButtonRun() //騎士到處跑
{
	// TODO: Add your control notification handler code here
	char OutStr[]={
			"run e\r\n"
			"run n\r\n"
			"run w\r\n"
			"run s\r\n"
	};
 
	CAutoDlg::SetDlgItemText(IDC_GKK_Commands, OutStr);
	CAutoDlg::SetDlgItemInt(IDC_N_SEC, 45, TRUE );
	CAutoDlg::SetDlgItemInt(IDC_M_SEC, 5, TRUE );
}
 
void CAutoDlg::OnButtonRun2() //遊俠到處跑
{
	// TODO: Add your control notification handler code here
	char OutStr[]={
			"cast holy_spirit on \r\n"
			"cast heroism on \r\n"
			"cast bless on \r\n"
			"cast pure_blade on \r\n"
			"run e\r\n\r\n"
			"run n\r\n\r\n"
			"run w\r\n\r\n"
			"run s\r\n\r\n"
	};
 
	CAutoDlg::SetDlgItemText(IDC_GKK_Commands, OutStr);
	CAutoDlg::SetDlgItemInt(IDC_N_SEC, 15, TRUE );
	CAutoDlg::SetDlgItemInt(IDC_M_SEC, 5, TRUE );
}

GKKAUTO.h

#pragma once
 
class CGKKAUTO
{
public:
	int TimerCounter;
	int TimerStep;
	int KeyinCharCounter;
	int KeyinCharLen;
	void Work();
	char GKK_Command[16 * 1024];
	void Start();
	void Stop();
	int M_SEC;
	int N_SEC;
	int M_SEC_MAX;
	int N_SEC_MAX;
	int AUTO_Keyin;
	HWND GKK_HWND;
	CGKKAUTO();
	virtual ~CGKKAUTO();
 
};

GKKAUTO.cpp

#include "stdafx.h"
#include "auto.h"
#include "GKKAUTO.h"
 
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
 
CGKKAUTO::CGKKAUTO()
{
}
 
CGKKAUTO::~CGKKAUTO()
{
}
 
void CGKKAUTO::Stop()
{
	AUTO_Keyin = 0;
}
 
void CGKKAUTO::Start()
{
	KeyinCharLen = lstrlen(GKK_Command);
 
	if (N_SEC < 5)			N_SEC_MAX = 5 * 4;
	else if (N_SEC > 99)	N_SEC_MAX = 99 * 4;
	else					N_SEC_MAX = N_SEC * 4;
 
	if (M_SEC < 5)			M_SEC_MAX = 5 * 4;
	else if (M_SEC > 99)	M_SEC_MAX = 99 * 4;
	else					M_SEC_MAX = N_SEC * 4;
 
	KeyinCharCounter = 0;
	TimerStep = 0;
	AUTO_Keyin = 1;
}
 
void CGKKAUTO::Work()
{
	char	KeyinChar;
 
	if (AUTO_Keyin) {
		GKK_HWND = FindWindow( NULL, "King_Client" );
		if (GKK_HWND != 0) {
			switch( TimerStep ){
				case 0:
					KeyinChar = GKK_Command[KeyinCharCounter];
					SendMessage(GKK_HWND, WM_CHAR  , KeyinChar , 0);
					KeyinCharCounter++;
					if (KeyinCharCounter >= KeyinCharLen) {
						KeyinCharCounter = 0;
						TimerStep = 2;
						TimerCounter = 0;
					} else if (KeyinChar == '\n') {
						TimerStep = 1;
						TimerCounter = 0;
					}
					break;
				case 1:
					TimerCounter++;
					if (TimerCounter >= N_SEC_MAX) 
							TimerStep = 0;
					break;
				case 2:
					TimerCounter++;
					if (TimerCounter >= M_SEC_MAX) 
							TimerStep = 0;
					break;
			}
		}
	}
}

Setup.exe

stdafx.h

#pragma once
 
#define VC_EXTRALEAN		// Exclude rarely-used stuff from Windows headers
 
#include <afxwin.h>         // MFC core and standard components
#include <afxext.h>         // MFC extensions
#include <afxdtctl.h>		// MFC support for Internet Explorer 4 Common Controls
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h>			// MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
 
//{{AFX_INSERT_LOCATION}}

stdafx.cpp

#include "stdafx.h"

setup.rc

//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
 
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
 
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
 
/////////////////////////////////////////////////////////////////////////////
// Chinese (Taiwan) resources
 
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHT)
#ifdef _WIN32
LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_TRADITIONAL
#pragma code_page(950)
#endif //_WIN32
 
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
 
1 TEXTINCLUDE DISCARDABLE 
BEGIN
    "resource.h\0"
END
 
2 TEXTINCLUDE DISCARDABLE 
BEGIN
    "#include ""afxres.h""\r\n"
    "\0"
END
 
3 TEXTINCLUDE DISCARDABLE 
BEGIN
    "#define _AFX_NO_SPLITTER_RESOURCES\r\n"
    "#define _AFX_NO_OLE_RESOURCES\r\n"
    "#define _AFX_NO_TRACKER_RESOURCES\r\n"
    "#define _AFX_NO_PROPERTY_RESOURCES\r\n"
    "\r\n"
    "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHT)\r\n"
    "#ifdef _WIN32\r\n"
    "LANGUAGE 4, 1\r\n"
    "#pragma code_page(950)\r\n"
    "#endif //_WIN32\r\n"
    "#include ""res\\setup.rc2""  // non-Microsoft Visual C++ edited resources\r\n"
    "#include ""l.cht\\afxres.rc""          // Standard components\r\n"
    "#endif\r\n"
    "\0"
END
 
#endif    // APSTUDIO_INVOKED
 
 
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
 
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDR_MAINFRAME           ICON    DISCARDABLE     "res\\setup.ico"
 
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
 
IDD_ABOUTBOX DIALOG DISCARDABLE  0, 0, 235, 55
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "關於 GAC setup"
FONT 9, "新細明體"
BEGIN
    ICON            IDR_MAINFRAME,IDC_STATIC,11,17,20,20
    LTEXT           "GAC setup Version 1.0",IDC_STATIC,40,10,119,8,
                    SS_NOPREFIX
    LTEXT           "Copyright (C) 2000",IDC_STATIC,40,25,119,8
    DEFPUSHBUTTON   "確定",IDOK,178,7,50,14,WS_GROUP
END
 
IDD_SETUP_DIALOG DIALOGEX 0, 0, 222, 123
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_APPWINDOW
CAPTION "GAC setup"
FONT 9, "新細明體"
BEGIN
    DEFPUSHBUTTON   "結束",IDOK,165,102,50,14
    EDITTEXT        IDC_UserID,87,17,128,14,ES_AUTOHSCROLL
    LTEXT           "使用者的e-mail:",IDC_STATIC,14,21,59,8
    PUSHBUTTON      "產生執行檔",IDC_BUTTON_SAVE,7,102,50,14
    GROUPBOX        "狀態",IDC_STATIC,7,57,208,40
    GROUPBOX        "設定",IDC_STATIC,7,7,208,40
    LTEXT           "",IDC_Description,17,75,169,8
END
 
 
#ifndef _MAC
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
 
VS_VERSION_INFO VERSIONINFO
 FILEVERSION 1,0,0,1
 PRODUCTVERSION 1,0,0,1
 FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
 FILEFLAGS 0x1L
#else
 FILEFLAGS 0x0L
#endif
 FILEOS 0x4L
 FILETYPE 0x1L
 FILESUBTYPE 0x0L
BEGIN
    BLOCK "StringFileInfo"
    BEGIN
        BLOCK "040404B0"
        BEGIN
            VALUE "CompanyName", "\0"
            VALUE "FileDescription", "setup MFC Application\0"
            VALUE "FileVersion", "1, 0, 0, 1\0"
            VALUE "InternalName", "setup\0"
            VALUE "LegalCopyright", "Copyright (C) 2000\0"
            VALUE "LegalTrademarks", "\0"
            VALUE "OriginalFilename", "setup.EXE\0"
            VALUE "ProductName", "setup Application\0"
            VALUE "ProductVersion", "1, 0, 0, 1\0"
        END
    END
    BLOCK "VarFileInfo"
    BEGIN
        VALUE "Translation", 0x404, 1200
    END
END
 
#endif    // !_MAC
 
 
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
 
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE 
BEGIN
    IDD_ABOUTBOX, DIALOG
    BEGIN
        LEFTMARGIN, 7
        RIGHTMARGIN, 228
        TOPMARGIN, 7
        BOTTOMMARGIN, 48
    END
 
    IDD_SETUP_DIALOG, DIALOG
    BEGIN
        LEFTMARGIN, 7
        RIGHTMARGIN, 215
        TOPMARGIN, 7
        BOTTOMMARGIN, 116
    END
END
#endif    // APSTUDIO_INVOKED
 
 
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
 
STRINGTABLE DISCARDABLE 
BEGIN
    IDS_ABOUTBOX            "關於 setup(&A)..."
END
 
#endif    // Chinese (Taiwan) resources
/////////////////////////////////////////////////////////////////////////////
 
 
 
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
#define _AFX_NO_SPLITTER_RESOURCES
#define _AFX_NO_OLE_RESOURCES
#define _AFX_NO_TRACKER_RESOURCES
#define _AFX_NO_PROPERTY_RESOURCES
 
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHT)
#ifdef _WIN32
LANGUAGE 4, 1
#pragma code_page(950)
#endif //_WIN32
#include "res\setup.rc2"  // non-Microsoft Visual C++ edited resources
#include "l.cht\afxres.rc"          // Standard components
#endif
 
/////////////////////////////////////////////////////////////////////////////
#endif    // not APSTUDIO_INVOKED

RESOURCE.H

//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by setup.rc
//
#define IDM_ABOUTBOX                    0x0010
#define IDD_ABOUTBOX                    100
#define IDS_ABOUTBOX                    101
#define IDD_SETUP_DIALOG                102
#define IDR_MAINFRAME                   128
#define IDC_UserID                      1000
#define IDC_BUTTON_SAVE                 1001
#define IDC_Description                 1002
 
// Next default values for new objects
// 
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE        129
#define _APS_NEXT_COMMAND_VALUE         32771
#define _APS_NEXT_CONTROL_VALUE         1003
#define _APS_NEXT_SYMED_VALUE           101
#endif
#endif

setup.h

#pragma once
 
#ifndef __AFXWIN_H__
	#error include 'stdafx.h' before including this file for PCH
#endif
 
#include "resource.h"		// main symbols
 
/////////////////////////////////////////////////////////////////////////////
// CSetupApp:
// See setup.cpp for the implementation of this class
//
 
class CSetupApp : public CWinApp
{
public:
	CSetupApp();
 
// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CSetupApp)
	public:
	virtual BOOL InitInstance();
	//}}AFX_VIRTUAL
 
// Implementation
 
	//{{AFX_MSG(CSetupApp)
		// NOTE - the ClassWizard will add and remove member functions here.
		//    DO NOT EDIT what you see in these blocks of generated code !
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};
 
//{{AFX_INSERT_LOCATION}}

setup.cpp

#include "stdafx.h"
#include "setup.h"
#include "setupDlg.h"
 
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
 
/////////////////////////////////////////////////////////////////////////////
// CSetupApp
 
BEGIN_MESSAGE_MAP(CSetupApp, CWinApp)
	//{{AFX_MSG_MAP(CSetupApp)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG
	ON_COMMAND(ID_HELP, CWinApp::OnHelp)
END_MESSAGE_MAP()
 
CSetupApp::CSetupApp()
{
}
 
CSetupApp theApp;
 
BOOL CSetupApp::InitInstance()
{
#ifdef _AFXDLL
	Enable3dControls();			// Call this when using MFC in a shared DLL
#else
	Enable3dControlsStatic();	// Call this when linking to MFC statically
#endif
 
	CSetupDlg dlg;
	m_pMainWnd = &dlg;
	int nResponse = dlg.DoModal();
	if (nResponse == IDOK)
	{
	}
	else if (nResponse == IDCANCEL)
	{
	}
 
	return FALSE;
}

setupDlg.h

#pragma once
 
class CSetupDlg : public CDialog
{
// Construction
public:
	CSetupDlg(CWnd* pParent = NULL);	// standard constructor
 
// Dialog Data
	//{{AFX_DATA(CSetupDlg)
	enum { IDD = IDD_SETUP_DIALOG };
		// NOTE: the ClassWizard will add data members here
	//}}AFX_DATA
 
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CSetupDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support
	//}}AFX_VIRTUAL
 
// Implementation
protected:
	HICON m_hIcon;
 
	// Generated message map functions
	//{{AFX_MSG(CSetupDlg)
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	afx_msg void OnButtonSave();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};
 
//{{AFX_INSERT_LOCATION}}

setupDlg.cpp

#include "stdafx.h"
#include "setup.h"
#include "setupDlg.h"
 
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
 
/////////////////////////////////////////////////////////////////////////////
// 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()
 
/////////////////////////////////////////////////////////////////////////////
// CSetupDlg dialog
 
CSetupDlg::CSetupDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CSetupDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CSetupDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
 
void CSetupDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSetupDlg)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}
 
BEGIN_MESSAGE_MAP(CSetupDlg, CDialog)
	//{{AFX_MSG_MAP(CSetupDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(IDC_BUTTON_SAVE, OnButtonSave)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()
 
/////////////////////////////////////////////////////////////////////////////
// CSetupDlg message handlers
 
BOOL CSetupDlg::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 CSetupDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
	{
		CAboutDlg dlgAbout;
		dlgAbout.DoModal();
	}
	else
	{
		CDialog::OnSysCommand(nID, lParam);
	}
}
 
void CSetupDlg::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 CSetupDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}
 
void CSetupDlg::OnButtonSave() 
{
	// TODO: Add your control notification handler code here
//第一步載入
	char	buf[256 * 1024];
	CString	fileName = "auto.dat";
	HANDLE Handle;
 
	Handle = CreateFile( fileName, GENERIC_READ, FILE_SHARE_READ, (LPSECURITY_ATTRIBUTES)NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, (HANDLE)NULL );
	if( Handle == INVALID_HANDLE_VALUE ){
		CSetupDlg::SetDlgItemText(IDC_Description, "檔案無法讀取");
		return;
	}
 
	if( Handle == NULL ){
		CSetupDlg::SetDlgItemText(IDC_Description, "檔案無法讀取");
		return;
	}
 
	DWORD	ReadSize = GetFileSize( Handle, NULL );
	ReadFile( Handle, (LPVOID)buf, ReadSize, &ReadSize, NULL ); 
	CloseHandle( Handle );
 
	CSetupDlg::SetDlgItemText(IDC_Description, "auto.exe製作用的模組檔案已載入");
 
//第2步置換資料
	char	playerID[4][64];
	int		Len;
	char	*ptr1;
	char	*ptr2;
	int i;
	DWORD	counter=0;
 
	lstrcpy(playerID[0], "playercd8@hotmail.com");
 
	CSetupDlg::GetDlgItemText(IDC_UserID, playerID[1], sizeof(playerID[1]));
	Len = lstrlen(playerID[1])+1;
 
	srand( (unsigned)time( NULL ) );
	for	(i=0; i<64; i++) {
		do {
			playerID[2][i]=rand() % 253 + 1;
			playerID[3][i]=rand() % 253 + 1;
		} while (playerID[2][i] == playerID[1][i]);
	}
	playerID[2][Len] = 0;
	for	(i=0; i<Len; i++) {
		playerID[3][i] = playerID[1][i] ^ playerID[2][i];
	}
	playerID[3][Len] = 0;
 
	ptr1=&buf[0x190b0];		//這裡的兩個記憶體位置, 視實際修改位置而定
	ptr2=&buf[0x190f0];
	for (i =0 ; i< 64; i++) {
		ptr1[i]=playerID[2][i];
		ptr2[i]=playerID[3][i];
	}
 
 
//第三步寫入
	fileName = "auto.exe";
	char	filters[] = "執行檔 (*.exe)|*.exe|";
 
	CFileDialog	fileDlg (FALSE, "*.exe" , fileName, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, filters , NULL );
	fileDlg.DoModal();
	fileName = fileDlg.GetPathName();
 
	Handle = CreateFile( fileName, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
	if( Handle == INVALID_HANDLE_VALUE ){
		CSetupDlg::SetDlgItemText(IDC_Description, "檔案無法寫入");
		return;
	}
	if( Handle == NULL ){
		CSetupDlg::SetDlgItemText(IDC_Description, "檔案無法寫入");
		return;
	}
 
	DWORD	WriteSize = ReadSize;
	WriteFile( Handle, (LPVOID)buf, WriteSize, &WriteSize, NULL ); 
 	CloseHandle( Handle );
 
	CSetupDlg::SetDlgItemText(IDC_Description, "個人專用執行檔已產生");
 
}
個人工具
名字空間
變換
動作
導航
分類
其他
技術類News或部落格
工具箱