stoneage8.5/石器时代8.5客户端最新源代码/石器源码/system/main.cpp

1631 lines
38 KiB
C++
Raw Normal View History

2020-06-22 17:49:02 +08:00
/**** SYSTEM INCLUDE ****/
#include "../systeminc/version.h"
#include "../systeminc/system.h"
#include <winnls32.h>
#include <ime.h>
#include <imm.h>
#include <tlhelp32.h>
#include "../other/caryIme.h"
#include "../resource.h"
#include "../systeminc/netmain.h"
#include "../systeminc/battleMap.h"
#include "../systeminc/battleProc.h"
#include "../systeminc/netmain.h"
#include "../systeminc/login.h"
#include "../systeminc/map.h"
#ifdef _REMAKE_20
#include "../MMOGprotect.h"
#endif
#ifdef _TALK_WINDOW
#include "../systeminc/talkwindow.h"
#endif
#include "../wgs/message.h"
#ifdef _STONDEBUG_
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
#endif
#include "../systeminc/VMProtectSDK.h"
2020-06-23 15:27:59 +08:00
#ifdef _SAHOOK //Syu ADD Hook<6F><6B>ʽ
2020-06-22 17:49:02 +08:00
#include "..\Sa_Hk.h"
#include "../sahook.h"
#define UM_KEYEVENT (WM_APP + 0)
#endif
#include "../systeminc/pc.h"
#include <io.h>
#include <direct.h>
#include <Nb30.h>
#pragma comment(lib,"netapi32.lib")
#include <dbghelp.h>
#pragma comment(lib, "dbghelp.lib")
#include <Psapi.h>
#pragma comment(lib,"psapi.lib")
#ifdef _NEWDEBUG_
#include "../cguixmain.h"
#pragma comment(lib,"xcgui_115.lib")
#endif
#ifdef _AIDENGLU_
Landed PcLanded;
2020-06-23 15:27:59 +08:00
int <EFBFBD>Ƿ<EFBFBD><EFBFBD>ص<EFBFBD> = FALSE;
int <EFBFBD>Ƿ<EFBFBD><EFBFBD>ص<EFBFBD>ս<EFBFBD><EFBFBD><EFBFBD><EFBFBD> = FALSE;
int <EFBFBD>Ƿ<EFBFBD><EFBFBD>ص<EFBFBD>AIģʽ = FALSE;
int <EFBFBD>Ƿ<EFBFBD><EFBFBD>ص<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = FALSE;
int <EFBFBD>Ƿ<EFBFBD><EFBFBD>صǺ<EFBFBD><EFBFBD><EFBFBD> = FALSE;
int <EFBFBD>Ƿ<EFBFBD><EFBFBD>ص<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = FALSE;
int <EFBFBD>Ƿ<EFBFBD><EFBFBD>ؿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = FALSE;
int <EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD>½<EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = 0;
2020-06-22 17:49:02 +08:00
#endif
int DISPLACEMENT_X = 160;
int DISPLACEMENT_Y = 120;
int DEF_APPSIZEX = 800;
int DEF_APPSIZEY = 600;
int SCREEN_WIDTH_CENTER = DEF_APPSIZEX / 2;
int SCREEN_HEIGHT_CENTER = DEF_APPSIZEY / 2;
2020-06-23 15:27:59 +08:00
#define REALBIN_DIR "data\\real_136.bin" // REAL.BIN?<3F><>?
#define ADRNBIN_DIR "data\\adrn_136.bin" // ADRN.BIN?<3F><>?
#define SPRBIN_DIR "data\\spr_115.bin" // SPR.BIN?<3F><>?
#define SPRADRNBIN_DIR "data\\spradrn_115.bin" // SPRADRN.BIN?<3F><>?
2020-06-22 17:49:02 +08:00
#ifdef _READ16BITBMP
#define REALTRUEBIN_DIR "data/realtrue_13.bin"
#define ADRNTRUEBIN_DIR "data/adrntrue_5.bin"
#endif
//-------------------------------------------END------------------------
2020-06-23 15:27:59 +08:00
extern int <EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
2020-06-22 17:49:02 +08:00
extern char* GB2312ToBIG5(const char* szGBString);
int MessageBoxNew(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType)
{
2020-06-23 15:27:59 +08:00
if (<EFBFBD><EFBFBD><EFBFBD><EFBFBD> == 950){
char <EFBFBD><EFBFBD><EFBFBD><EFBFBD>[1024] = { 0 };
char <EFBFBD><EFBFBD><EFBFBD><EFBFBD>1[1024] = { 0 };
LCMapString(0x804, 0x4000000, lpText, strlen(lpText), <EFBFBD><EFBFBD><EFBFBD><EFBFBD>, 1024);
LCMapString(0x804, 0x4000000, lpCaption, strlen(lpCaption), <EFBFBD><EFBFBD><EFBFBD><EFBFBD>1, 1024);
return MessageBox(hWnd, GB2312ToBIG5((const char *)<EFBFBD><EFBFBD><EFBFBD><EFBFBD>), GB2312ToBIG5((const char *)<EFBFBD><EFBFBD><EFBFBD><EFBFBD>1), uType);
2020-06-22 17:49:02 +08:00
}
else{
return MessageBox(hWnd, lpText, lpCaption, uType);
}
}
//---------------------------------------------------------------------------//
2020-06-23 15:27:59 +08:00
// ?? <20><>?????<3F><>?<3F>e? //
2020-06-22 17:49:02 +08:00
//---------------------------------------------------------------------------//
2020-06-23 15:27:59 +08:00
HINSTANCE hInst; // ??????????<3F>e?
2020-06-22 17:49:02 +08:00
HWND hWnd; // ?????????
int CmdShow; // WinMain??????????????
LPSTR CmdLine; // WinMain?????????????????????
2020-06-23 15:27:59 +08:00
HANDLE hMutex; // <20>i??<3F>h???????????????
HANDLE hCheckMutex = NULL; // <20><><EFBFBD><EFBFBD><EFBFBD>³<EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>
2020-06-22 17:49:02 +08:00
//BOOL WindowMode = TRUE; // ????????
BOOL WindowMode = TRUE; // ??????????
// TRUE : WindowMode
// FALSE : FullScreen
2020-06-23 15:27:59 +08:00
BOOL NoDelay = FALSE; // TCP_NODELAY ?<3F><>??????add by ringo
2020-06-22 17:49:02 +08:00
#ifdef _NEW_RESOMODE
2020-06-23 15:27:59 +08:00
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ( 0 : 640 * 480 , 1 : 320 * 240 ,2 : 640 * 480, 3 : 800 * 600 , 4 : 1024 * 768 )
2020-06-22 17:49:02 +08:00
int ResoMode = 3;
#else
int ResoMode = 0;
#endif
2020-06-23 15:27:59 +08:00
int LowResoCmdFlag = 0; // ??<3F>T<EFBFBD><54>????????
2020-06-22 17:49:02 +08:00
RECT g_clientRect;
POINT g_clientPoint;
RECT g_moveRect;
BOOL offlineFlag = FALSE; // ????????
char DebugKey0[256]; // ???????
char DebugKey1[256]; // ???????
char DebugKey2[256]; // ???????
int g_iMallocCount = 0;
char realBinName[256];
char adrnBinName[256];
char sprBinName[256];
char sprAdrnBinName[256];
#ifdef _READ16BITBMP
char realtrueBinName[256];
char adrntrueBinName[256];
extern BOOL g_bUseAlpha;
#endif
#ifdef _TALK_WINDOW
extern int MouseCursorFlag;
#endif
void GetSettings();
2020-06-23 15:27:59 +08:00
/* ????????<3F><> */
2020-06-22 17:49:02 +08:00
void AnalyzeCmdLine(void);
2020-06-23 15:27:59 +08:00
// ????????<3F><>?<3F>v???<3F>L?
2020-06-22 17:49:02 +08:00
void ChangeWindowMode(void);
2020-06-23 15:27:59 +08:00
// ??<3F>T???<3F>@<40>e??
2020-06-22 17:49:02 +08:00
void SetResoMode(int Mode);
2020-06-23 15:27:59 +08:00
// ?????????<3F>B<EFBFBD>l
2020-06-22 17:49:02 +08:00
WNDCLASS wndclass;
HANDLE hProcessSnap = NULL, hParentProcess = NULL;
DWORD dwPID;
PROCESSENTRY32 pe32;
#ifdef _TIME_GET_TIME
extern LARGE_INTEGER tickCount;
extern LARGE_INTEGER CurrentTick;
#endif
#ifdef _TALK_WINDOW
CTalkWindow TalkWindow;
#endif
2020-06-23 15:27:59 +08:00
char <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>[256];
2020-06-22 17:49:02 +08:00
int getMAC(char * mac)
{
NCB ncb;
typedef struct _ASTAT_
{
ADAPTER_STATUS adapt;
NAME_BUFFER NameBuff[30];
}ASTAT, *PASTAT;
ASTAT Adapter;
typedef struct _LANA_ENUM
{
UCHAR length;
UCHAR lana[MAX_LANA];
}LANA_ENUM;
LANA_ENUM lana_enum;
UCHAR uRetCode;
memset(&ncb, 0, sizeof(ncb));
memset(&lana_enum, 0, sizeof(lana_enum));
ncb.ncb_command = NCBENUM;
ncb.ncb_buffer = (unsigned char *)&lana_enum;
ncb.ncb_length = sizeof(LANA_ENUM);
uRetCode = Netbios(&ncb);
if (uRetCode != NRC_GOODRET)
return uRetCode;
for (int lana = 0; lana < lana_enum.length; lana++)
{
ncb.ncb_command = NCBRESET;
ncb.ncb_lana_num = lana_enum.lana[lana];
uRetCode = Netbios(&ncb);
if (uRetCode == NRC_GOODRET)
break;
}
if (uRetCode != NRC_GOODRET)
return uRetCode;
memset(&ncb, 0, sizeof(ncb));
ncb.ncb_command = NCBASTAT;
ncb.ncb_lana_num = lana_enum.lana[0];
strcpy((char*)ncb.ncb_callname, "*");
ncb.ncb_buffer = (unsigned char *)&Adapter;
ncb.ncb_length = sizeof(Adapter);
uRetCode = Netbios(&ncb);
if (uRetCode != NRC_GOODRET)
return uRetCode;
sprintf(mac, "%02X-%02X-%02X-%02X-%02X-%02X",
Adapter.adapt.adapter_address[0],
Adapter.adapt.adapter_address[1],
Adapter.adapt.adapter_address[2],
Adapter.adapt.adapter_address[3],
Adapter.adapt.adapter_address[4],
Adapter.adapt.adapter_address[5]);
return 0;
}
2020-06-23 15:27:59 +08:00
char <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>[512];
2020-06-22 17:49:02 +08:00
2020-06-23 15:27:59 +08:00
void <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>()
2020-06-22 17:49:02 +08:00
{
2020-06-23 15:27:59 +08:00
HANDLE m_hMapFile = OpenFileMapping( //<2F><><EFBFBD>ù<EFBFBD><C3B9><EFBFBD><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD>
2020-06-22 17:49:02 +08:00
FILE_MAP_READ | FILE_MAP_WRITE,
FALSE,
#ifdef _SA_VERSION_25
"shiqies");
#endif
if (m_hMapFile == NULL){
2020-06-23 15:27:59 +08:00
HANDLE m_hMapFile = CreateFileMapping( //<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĺ<EFBFBD><C4B9><EFBFBD><EFBFBD>ڴ<EFBFBD>
(HANDLE)0xFFFFFFFF, //0xFFFFFFFF<46><46>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>̼乲<CCBC><E4B9B2><EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD>
2020-06-22 17:49:02 +08:00
NULL,
2020-06-23 15:27:59 +08:00
PAGE_READWRITE, //<2F><>д<EFBFBD><D0B4><EFBFBD><EFBFBD>
2020-06-22 17:49:02 +08:00
0,
2020-06-23 15:27:59 +08:00
1032, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С4096
2020-06-22 17:49:02 +08:00
#ifdef _SA_VERSION_25
"shiqies");
#endif
2020-06-23 15:27:59 +08:00
char *str = (char *)MapViewOfFile( //ӳ<><EFBFBD><E4B5BD><EFBFBD><EFBFBD><EFBFBD>̵ĵ<CCB5>ַ<EFBFBD>ռ<EFBFBD>
2020-06-22 17:49:02 +08:00
m_hMapFile,
FILE_MAP_ALL_ACCESS,
0,
0,
0);
memset(str, 0, 1032);
2020-06-23 15:27:59 +08:00
memset(<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, 0, 512);
2020-06-22 17:49:02 +08:00
char userName[MAX_PATH];
DWORD size = MAX_PATH;
char mac[64];
GetComputerName(userName, &size);
getMAC(mac);
2020-06-23 15:27:59 +08:00
sprintf_s(<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, "%s%s", mac, userName);
memcpy(str, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, 512);
2020-06-22 17:49:02 +08:00
}
else{
2020-06-23 15:27:59 +08:00
char *str = (char *)MapViewOfFile( //ӳ<><EFBFBD><E4B5BD><EFBFBD><EFBFBD><EFBFBD>̵ĵ<CCB5>ַ<EFBFBD>ռ<EFBFBD>
2020-06-22 17:49:02 +08:00
m_hMapFile,
FILE_MAP_ALL_ACCESS,
0,
0,
0);
2020-06-23 15:27:59 +08:00
memcpy(<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, str, 512);
2020-06-22 17:49:02 +08:00
}
}
2020-06-23 15:27:59 +08:00
BOOL <EFBFBD>ļ<EFBFBD><EFBFBD>ж<EFBFBD>(char * path,char * name)
2020-06-22 17:49:02 +08:00
{
2020-06-23 15:27:59 +08:00
char <EFBFBD>ļ<EFBFBD>·<EFBFBD><EFBFBD>[256];
sprintf(<EFBFBD>ļ<EFBFBD>·<EFBFBD><EFBFBD>,"%s%s",path,name);
BOOL ret = (access(<EFBFBD>ļ<EFBFBD>·<EFBFBD><EFBFBD>,0)==0?TRUE:FALSE);
2020-06-22 17:49:02 +08:00
if(ret){
2020-06-23 15:27:59 +08:00
;//MessageBox(NULL,<2C>ļ<EFBFBD>·<EFBFBD><C2B7>,"ʯ<><CAAF>ʱ<EFBFBD><CAB1>",0);
2020-06-22 17:49:02 +08:00
}
return ret;
}
2020-06-23 15:27:59 +08:00
BOOL <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(char *path)
2020-06-22 17:49:02 +08:00
{
2020-06-23 15:27:59 +08:00
if(<EFBFBD>ļ<EFBFBD><EFBFBD>ж<EFBFBD>(path,"QMScript") ||
<EFBFBD>ļ<EFBFBD><EFBFBD>ж<EFBFBD>(path,"Recorder.exe") ||
<EFBFBD>ļ<EFBFBD><EFBFBD>ж<EFBFBD>(path,"QMColorActionCtl.ocx") ||
<EFBFBD>ļ<EFBFBD><EFBFBD>ж<EFBFBD>(path,"ShieldModule.dat") ||
<EFBFBD>ļ<EFBFBD><EFBFBD>ж<EFBFBD>(path,"qmacro.ini") ||
<EFBFBD>ļ<EFBFBD><EFBFBD>ж<EFBFBD>(path,"wqm.exe") ||
<EFBFBD>ļ<EFBFBD><EFBFBD>ж<EFBFBD>(path,"Fairy_Ape")||
<EFBFBD>ļ<EFBFBD><EFBFBD>ж<EFBFBD>(path,"LAScriptX.dll")||
<EFBFBD>ļ<EFBFBD><EFBFBD>ж<EFBFBD>(path,"mly.dll")||<EFBFBD>ļ<EFBFBD><EFBFBD>ж<EFBFBD>(path,"v5_hook.dll")||<EFBFBD>ļ<EFBFBD><EFBFBD>ж<EFBFBD>(path,"v5_Log.dll")||<EFBFBD>ļ<EFBFBD><EFBFBD>ж<EFBFBD>(path,"v5_Process_Manager.dll")
2020-06-22 17:49:02 +08:00
){
return TRUE;
}else{
return FALSE;
}
}
2020-06-23 15:27:59 +08:00
void <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>()
2020-06-22 17:49:02 +08:00
{
char szProcessName[MAX_PATH];
HMODULE hMods[4096];
HANDLE hProcess;
DWORD aProcesses[4096], cbNeeded, cbMNeeded;
2020-06-23 15:27:59 +08:00
char ·<EFBFBD><EFBFBD>[256];
2020-06-22 17:49:02 +08:00
int j;
if ( !EnumProcesses( aProcesses, sizeof(aProcesses), &cbNeeded ) ) return;
for(int i=0; i< (int) (cbNeeded / sizeof(DWORD)); i++)
{
hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, aProcesses[i]);
BOOL bret=EnumProcessModules(hProcess, hMods, sizeof(hMods), &cbMNeeded);
if(bret){
DWORD dwret=GetModuleFileNameEx( hProcess, hMods[0], szProcessName,sizeof(szProcessName));
CloseHandle(hProcess);
if(dwret==0){
break;
}else{
int i=strlen(szProcessName);
for(i;i>=0;i--){
if(szProcessName[i]== '\\' ){
break;
}
}
2020-06-23 15:27:59 +08:00
memcpy(·<EFBFBD><EFBFBD>,szProcessName,i+1);
·<EFBFBD><EFBFBD>[i+1]=0;
if(<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(·<EFBFBD><EFBFBD>)){
2020-06-22 17:49:02 +08:00
ExitProcess(NULL);
}
}
}
}
return;
}
2020-06-23 15:27:59 +08:00
BOOL IsContainsProcess(char* strProName, BOOL <EFBFBD>ж<EFBFBD> = 1)
2020-06-22 17:49:02 +08:00
{
2020-06-23 15:27:59 +08:00
PROCESSENTRY32 pe32; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E1B9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̵<EFBFBD><CCB5><EFBFBD>Ϣ
pe32.dwSize = sizeof(pe32); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С
2020-06-22 17:49:02 +08:00
2020-06-23 15:27:59 +08:00
HANDLE hProcessSnap = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2020-06-22 17:49:02 +08:00
if (hProcessSnap == INVALID_HANDLE_VALUE)
{
2020-06-23 15:27:59 +08:00
//MessageBox("<22><><EFBFBD>̿<EFBFBD><CCBF><EFBFBD>ʧ<EFBFBD><CAA7>","<22><>ʾ",MB_OK);
2020-06-22 17:49:02 +08:00
exit(1);
}
2020-06-23 15:27:59 +08:00
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>п<EFBFBD><D0BF><EFBFBD>
2020-06-22 17:49:02 +08:00
BOOL bMore = ::Process32First(hProcessSnap, &pe32);
while (bMore)
{
2020-06-23 15:27:59 +08:00
if (<EFBFBD>ж<EFBFBD> == 1){
2020-06-22 17:49:02 +08:00
if (strcmp(strProName, pe32.szExeFile) == 0)
{
2020-06-23 15:27:59 +08:00
return TRUE; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڸý<DAB8><C3BD>̣<EFBFBD><CCA3>򷵻<EFBFBD>TRUE
bMore = FALSE;//ֹͣѭ<D6B9><D1AD>
2020-06-22 17:49:02 +08:00
}
else
{
bMore = ::Process32Next(hProcessSnap, &pe32);
}
}
else{
if (strstr(pe32.szExeFile, strProName))
{
2020-06-23 15:27:59 +08:00
return TRUE; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڸý<DAB8><C3BD>̣<EFBFBD><CCA3>򷵻<EFBFBD>TRUE
bMore = FALSE;//ֹͣѭ<D6B9><D1AD>
2020-06-22 17:49:02 +08:00
}
else
{
bMore = ::Process32Next(hProcessSnap, &pe32);
}
}
}
2020-06-23 15:27:59 +08:00
//ɨβ
2020-06-22 17:49:02 +08:00
CloseHandle(hProcessSnap);
return FALSE;
}
DWORD __forceinline IsInsideVPC_exceptionFilter(LPEXCEPTION_POINTERS ep)
{
PCONTEXT ctx = ep->ContextRecord;
ctx->Ebx = -1; // Not running VPC
ctx->Eip += 4; // skip past the "call VPC" opcodes
return EXCEPTION_CONTINUE_EXECUTION; // we can safely resume execution since we skipped faulty instruction
}
// high level language friendly version of IsInsideVPC()
bool IsInsideVPC()
{
bool rc = false;
__try
{
_asm push ebx
_asm mov ebx, 0 // Flag
_asm mov eax, 1
_asm __emit 0Fh
_asm __emit 3Fh
_asm __emit 07h
_asm __emit 0Bh
_asm test ebx, ebx
_asm setz[rc]
_asm pop ebx
}
__except (IsInsideVPC_exceptionFilter(GetExceptionInformation()))
{
}
return rc;
}
2020-06-23 15:27:59 +08:00
BOOL <EFBFBD><EFBFBD><EFBFBD><EFBFBD>WARE()
2020-06-22 17:49:02 +08:00
{
HKEY key;
unsigned char buffer[512];
DWORD len;
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SYSTEM\\ControlSet001\\Services\\Disk\\Enum", 0, KEY_READ, &key) == ERROR_SUCCESS){
memset(buffer, 0, 512);
len = 512;
DWORD lpReserved = 0;
DWORD lpType = REG_SZ;
if (RegQueryValueEx(key, "0", NULL, &lpType, buffer, &len) == 0){
extern int strncmpi(char *s1, char *s2, int len);
_strlwr_s((char *)buffer, strlen((char *)buffer) + 1);
if (strstr((char *)buffer, "virtual") || strstr((char *)buffer, "vmware") || strstr((char *)buffer, "vbox")){
return TRUE;
}
}
RegCloseKey(key);
}
return FALSE;
}
class A;
void fcn(A*);
class A
{
public:
virtual void f() = 0;
A() { fcn(this); }
};
class B : A
{
void f() { }
};
void fcn(A* p)
{
p->f();
}
int PureVirtualFunc()
{
B b;
int n = 0;
return 0;
}
BOOL IsTheSelfRun(char *str)
{
HANDLE m_hMutex = CreateMutex(NULL,FALSE, str);
if(m_hMutex)
{
if(GetLastError() == ERROR_ALREADY_EXISTS)
{
CloseHandle(m_hMutex);
return TRUE;
}
}
return FALSE;
}
void CreateCompatibleDEVMODE(DEVMODE* pdm, DWORD BitsPerPixel, DWORD Width, DWORD Height, DWORD Frequency)
{
ZeroMemory(pdm, sizeof(DEVMODE));
pdm->dmSize = sizeof(DEVMODE);
if (BitsPerPixel)
{
pdm->dmBitsPerPel = BitsPerPixel;
pdm->dmFields |= DM_BITSPERPEL;
}
if (Width)
{
pdm->dmPelsWidth = Width;
pdm->dmFields |= DM_PELSWIDTH;
}
if (Height)
{
pdm->dmPelsHeight = Height;
pdm->dmFields |= DM_PELSHEIGHT;
}
if (Frequency)
{
pdm->dmDisplayFrequency = Frequency;
pdm->dmFields |= DM_DISPLAYFREQUENCY;
}
}
int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
#ifdef _NEWDEBUG_
HMODULE hMod ;
hMod = GetModuleHandle("xcgui_115.dll");
if(!hMod)
{
hMod= LoadLibrary("xcgui_115.dll");
if(!hMod){
exit(0);
}
}
cguixmain("cmdstrtw",123);
#endif
#ifdef _NEWFONT_
AddFontResource("./data/font/msjh.ttf");
#else
// AddFontResource("./data/font/msjh.ttf");
#endif
#ifdef _CMD_MODE
extern void InitConsoleWindow(void) ;
InitConsoleWindow();
#endif
#ifndef SWITCH_MODE
extern int displayBpp;
HDC hDcDest = GetDC(hWnd);
displayBpp = GetDeviceCaps(hDcDest, BITSPIXEL);
ReleaseDC(hWnd, hDcDest);
if(displayBpp != 32){
DEVMODE dm;
CreateCompatibleDEVMODE(&dm, 32, GetDeviceCaps(hDcDest, HORZRES),GetDeviceCaps(hDcDest, VERTRES), GetDeviceCaps(hDcDest, VREFRESH));
ChangeDisplaySettings(&dm, 0);
char buf[256];
GetModuleFileName(NULL,buf,sizeof(buf));
STARTUPINFO StartInfo;
PROCESS_INFORMATION procStruct;
memset(&StartInfo, 0, sizeof(STARTUPINFO));
StartInfo.cb = sizeof(STARTUPINFO);
CreateProcess(buf," OpenClient",NULL,NULL,FALSE,NORMAL_PRIORITY_CLASS,NULL,NULL,&StartInfo,&procStruct);
Sleep(3000);
return FALSE;
}
#endif
SetErrorMode(SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX);
CreateMutex(NULL,FALSE, SA_MUTE);
#ifdef _SA_VERSION_25
if (_access(".\\data", 6) == -1)
_mkdir(".\\data");
if (_access(".\\data\\chardata", 6) == -1)
_mkdir(".\\data\\chardata");
#endif
#ifdef _NODEBUG_
VMProtectBegin("jiance111");
2020-06-23 15:27:59 +08:00
extern void <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>();
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>();
2020-06-22 17:49:02 +08:00
if (
(IsContainsProcess("VBoxTray.exe")) ||
(IsContainsProcess("SbieSvc.exe")) ||
(IsContainsProcess("SbieCtrl.exe")) ||
(IsContainsProcess("VBoxService.exe")) ||
(IsContainsProcess("VMwareUser.exe")) ||
(IsContainsProcess("VMwareTray.exe")) ||
(IsContainsProcess("VMUpgradeHelper.exe"))||
(IsContainsProcess("vmtoolsd.exe")) ||
(IsContainsProcess("vmacthlp.exe")) ||
IsInsideVPC()||
2020-06-23 15:27:59 +08:00
IsContainsProcess("<EFBFBD><EFBFBD><EFBFBD>", 0) ||
IsContainsProcess("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>", 0)||
IsContainsProcess("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>", 0)
2020-06-22 17:49:02 +08:00
){
return FALSE;
}
2020-06-23 15:27:59 +08:00
if (<EFBFBD><EFBFBD><EFBFBD><EFBFBD>WARE()){
2020-06-22 17:49:02 +08:00
return FALSE;
}
VMProtectEnd();
#endif
2020-06-23 15:27:59 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> = GetACP();
if (<EFBFBD><EFBFBD><EFBFBD><EFBFBD> == 950)
2020-06-22 17:49:02 +08:00
{
2020-06-23 15:27:59 +08:00
strcpy(<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, GB2312ToBIG5(DEF_APPNAME));
2020-06-22 17:49:02 +08:00
}
2020-06-23 15:27:59 +08:00
<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>();
2020-06-22 17:49:02 +08:00
hInst = hInstance;
CmdShow = nCmdShow;
CmdLine = lpCmdLine;
#ifdef _REMAKE_20
#ifndef _STONDEBUG_
2020-06-23 15:27:59 +08:00
if(<EFBFBD><EFBFBD><EFBFBD><EFBFBD>==950)
hMutex = CreateMutex( NULL, TRUE, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> );
2020-06-22 17:49:02 +08:00
else
hMutex = CreateMutex( NULL, TRUE, DEF_APPNAME );
if(GetLastError() == ERROR_ALREADY_EXISTS){
2020-06-23 15:27:59 +08:00
MessageBoxNew(hWnd,"StoneAge<EFBFBD>Ѿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˣ<EFBFBD>","ȷ<EFBFBD><EFBFBD>",MB_OK | MB_ICONSTOP);
2020-06-22 17:49:02 +08:00
return FALSE;
}
#endif
#endif
2020-06-23 15:27:59 +08:00
// <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C>ø<EFBFBD><C3B8>³<EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7><EFBFBD>ʯ<EFBFBD><CAAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4>
2020-06-22 17:49:02 +08:00
hCheckMutex = CreateMutex(NULL, FALSE, "CheckForUpdate");
#ifdef _STONDEBUG_
_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
#endif
#ifdef __NEW_CLIENT
dwPID = GetCurrentProcessId();
if( INVALID_HANDLE_VALUE == (hProcessSnap=CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, NULL)))
return 0;
{
pe32.dwSize = sizeof(PROCESSENTRY32);
if( Process32First( hProcessSnap, &pe32)){
do{
if( pe32.th32ProcessID == dwPID){
dwPID = pe32.th32ParentProcessID;
break;
}
}while( Process32Next( hProcessSnap, &pe32));
}
}
#endif
#ifdef _DEFENSETOOENNUM_
#ifdef _VMP_
VMProtectBegin("xiankai");
#endif
FILE* tempfile=NULL;
int ds=0;
char strname[128];
BOOL checkclientflg=FALSE;
char *pathvar;
pathvar = getenv("TEMP");
for(ds=0;ds<_DEFENSETOOENNUM_;ds++){
#ifdef _SA_VERSION_25
sprintf(strname,"%s\\Etemp%d",pathvar,ds);
#endif
tempfile = fopen(strname,"w");
if(tempfile) fclose(tempfile);
HANDLE file_handle;
file_handle = CreateFile(strname,
GENERIC_READ,
0,
NULL,
OPEN_EXISTING,
NULL,
NULL);
if(INVALID_HANDLE_VALUE != file_handle){
if(INVALID_FILE_SIZE != (DWORD)file_handle){
checkclientflg=TRUE;
break;
}
}
}
// int xiangeshu=0;
// int ds=0;
// char strname[127];
// for(ds=0;ds <_DEFENSETOOENNUM_ ;ds++){
// sprintf(strname,"%s%d",SA_MUTE,ds);
// if(IsTheSelfRun(strname)) xiangeshu++;
// else break;
// }
if(!checkclientflg) {
2020-06-23 15:27:59 +08:00
// sprintf_s(strname, "<22><>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD>%d<><64><EFBFBD><EFBFBD>", _DEFENSETOOENNUM_);
sprintf_s(strname, "<EFBFBD><EFBFBD>Ϸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>2<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
2020-06-22 17:49:02 +08:00
#ifdef _VMP_
MessageBoxNew(NULL,VMProtectDecryptStringA(strname), DEF_APPNAME, MB_OK | MB_ICONSTOP);
#else
MessageBoxNew(NULL,strname, DEF_APPNAME, MB_OK | MB_ICONSTOP);
#endif
return FALSE;
}
#ifdef _VMP_
VMProtectEnd();
#endif
#endif
if (!hPrevInstance){
wndclass.style = CS_BYTEALIGNCLIENT | CS_DBLCLKS;
wndclass.lpfnWndProc = WindMsgProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(SA_ICON));
wndclass.hCursor = LoadCursor(hInstance, MAKEINTRESOURCE(SA_MOUSE1));
wndclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wndclass.lpszMenuName = NULL;
2020-06-23 15:27:59 +08:00
if (<EFBFBD><EFBFBD><EFBFBD><EFBFBD> == 950)
wndclass.lpszClassName = <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
2020-06-22 17:49:02 +08:00
else
wndclass.lpszClassName = DEF_APPNAME;
if (!RegisterClass(&wndclass)){
2020-06-23 15:27:59 +08:00
MessageBoxNew(NULL, "<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD>Ӵ<EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>°<EFBFBD>װ<EFBFBD><EFBFBD>Ǣѯ<EFBFBD>ͷ<EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD>",
"ȷ<EFBFBD><EFBFBD>", MB_OK | MB_ICONSTOP);
2020-06-22 17:49:02 +08:00
return FALSE;
}
}
#ifdef _TIME_GET_TIME
QueryPerformanceFrequency(&tickCount);
tickCount.QuadPart = tickCount.QuadPart / 1000;
#endif
strcpy(realBinName, REALBIN_DIR);
strcpy(adrnBinName, ADRNBIN_DIR);
strcpy(sprBinName, SPRBIN_DIR);
strcpy(sprAdrnBinName, SPRADRNBIN_DIR);
#ifdef _READ16BITBMP
strcpy(realtrueBinName,REALTRUEBIN_DIR);
strcpy(adrntrueBinName,ADRNTRUEBIN_DIR);
#endif
AnalyzeCmdLine();
memset(lpCmdLine, 0, strlen(lpCmdLine));
SetResoMode(ResoMode);
ChangeWindowMode();
#ifdef _TALK_WINDOW
TalkWindow.Init(hWnd,hInstance);
if(g_bTalkWindow) TalkWindow.Create();
#endif
#ifdef _NEWSHOP_
2020-06-23 15:27:59 +08:00
extern void <EFBFBD>̳dz<EFBFBD>ʼ<EFBFBD><EFBFBD>();
<EFBFBD>̳dz<EFBFBD>ʼ<EFBFBD><EFBFBD>();
2020-06-22 17:49:02 +08:00
#endif
#ifdef _AIDENGLU_
2020-06-23 15:27:59 +08:00
PcLanded.<EFBFBD><EFBFBD><EFBFBD><EFBFBD> = PcLanded.<EFBFBD><EFBFBD><EFBFBD><EFBFBD> = PcLanded.С<EFBFBD><EFBFBD> = PcLanded.<EFBFBD><EFBFBD>ģ = -1;
PcLanded.<EFBFBD>Ƿ<EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = PcLanded.<EFBFBD>Ƿ<EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = PcLanded.<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = PcLanded.<EFBFBD><EFBFBD>½<EFBFBD><EFBFBD>ʱʱ<EFBFBD><EFBFBD> = FALSE;
memset(PcLanded.<EFBFBD><EFBFBD>½<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, 0, 4 * 32);
2020-06-22 17:49:02 +08:00
#endif
GameMain();
#ifdef __NEW_CLIENT
CloseHandle( hProcessSnap);
#endif
#ifdef SWITCH_MODE
extern DEVMODE g_OriginalMode;
if( g_OriginalMode.dmSize != 0){
DEVMODE DevMode;
DevMode.dmSize = sizeof(DEVMODE);
EnumDisplaySettings( NULL, ENUM_CURRENT_SETTINGS, &DevMode);
if( DevMode.dmPelsWidth!=g_OriginalMode.dmPelsWidth || DevMode.dmPelsHeight!=g_OriginalMode.dmPelsHeight || DevMode.dmBitsPerPel!=g_OriginalMode.dmBitsPerPel){
g_OriginalMode.dmFields = DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT;
ChangeDisplaySettingsEx( NULL, &g_OriginalMode, NULL, CDS_UPDATEREGISTRY, NULL);
}
}
#endif
#ifdef _REMAKE_20
#ifndef _STONDEBUG_
QuitingInputScript();
#endif
QuitRestore();
#endif
#ifdef _STONDEBUG_
if(g_iMallocCount != 0){
char MSG[256];
sprintf_s(MSG,"g_iMallocCount = %d",g_iMallocCount);
2020-06-23 15:27:59 +08:00
MessageBoxNew( NULL,MSG,"ȷ<EFBFBD><EFBFBD>", MB_OK | MB_ICONSTOP );
2020-06-22 17:49:02 +08:00
}
#endif
ReleaseMutex(hCheckMutex);
return FALSE;
}
2020-06-23 15:27:59 +08:00
// ???????<3F><> ***********************************************************/
2020-06-22 17:49:02 +08:00
void DebugKey(char *str)
{
char *work;
int i = 0;
// ????????????? key0: ?????
if ((work = strstr(str, "KEY0:")))
{
2020-06-23 15:27:59 +08:00
work += 5; // <20><>??????????????<3F><>??
2020-06-22 17:49:02 +08:00
// : ????????
while (*work != ':'){
DebugKey0[i] = *work++;
i++;
if (i == 255){
i = 0;
break;
}
}
}
2020-06-23 15:27:59 +08:00
DebugKey0[i] = NULL; // <20><><EFBFBD>Z??
2020-06-22 17:49:02 +08:00
i = 0;
// ????????????? key1: ?????
if ((work = strstr(str, "KEY1:")))
{
2020-06-23 15:27:59 +08:00
work += 5; // <20><>??????????????<3F><>??
2020-06-22 17:49:02 +08:00
// : ????????
while (*work != ':'){
DebugKey1[i] = *work++;
i++;
if (i == 255){
i = 0;
break;
}
}
}
2020-06-23 15:27:59 +08:00
DebugKey1[i] = NULL; // <20><><EFBFBD>Z??
2020-06-22 17:49:02 +08:00
i = 0;
// ????????????? key1: ?????
if ((work = strstr(str, "KEY2:")))
{
2020-06-23 15:27:59 +08:00
work += 5; // <20><>??????????????<3F><>??
2020-06-22 17:49:02 +08:00
// : ????????
while (*work != ':'){
DebugKey2[i] = *work++;
i++;
if (i == 255){
i = 0;
break;
}
}
}
2020-06-23 15:27:59 +08:00
DebugKey2[i] = NULL; // <20><><EFBFBD>Z??
2020-06-22 17:49:02 +08:00
}
void AnalyzeCmdLine(void)
{
char *addr;
#ifdef _ZHENGSHIKAIFU_
#ifdef _VMP_
VMProtectBegin("AnalyzeCmdLine");
#endif
if (!(addr = strstr(CmdLine, "OpenClient"))){
2020-06-23 15:27:59 +08:00
MessageBoxNew(NULL, "<EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>½<EFBFBD><EFBFBD>Ϸ", "ȷ<EFBFBD><EFBFBD>", MB_OK | MB_ICONSTOP);
2020-06-22 17:49:02 +08:00
exit(0);
}
#ifdef _VMP_
VMProtectEnd();
#endif
#endif
if (addr = strstr(CmdLine, "realbin:"))
sprintf_s(realBinName, "data\\real_%d.bin", atoi(addr + strlen("realbin:")));
if (addr = strstr(CmdLine, "adrnbin:"))
sprintf_s(adrnBinName, "data\\adrn_%d.bin", atoi(addr + strlen("adrnbin:")));
if (addr = strstr(CmdLine, "sprbin:"))
sprintf_s(sprBinName, "data\\spr_%d.bin", atoi(addr + strlen("sprbin:")));
if (addr = strstr(CmdLine, "spradrnbin:"))
sprintf_s(sprAdrnBinName, "data\\spradrn_%d.bin", atoi(addr + strlen("spradrnbin:")));
#ifdef _READ16BITBMP
if(addr = strstr(CmdLine,"realtrue:"))
sprintf_s(realtrueBinName,"data\\realtrue_%d.bin",atoi(addr+strlen("realtrue:")));
if(addr = strstr(CmdLine,"adrntrue:"))
sprintf_s(adrntrueBinName, "data\\adrntrue_%d.bin", atoi(addr+strlen("adrntrue:")) );
if(strstr(CmdLine,"usealpha")) g_bUseAlpha = TRUE;
#endif
#ifdef _REMAKE_20
#ifdef _STONDEBUG_
if( strstr( CmdLine, "windowmode" ) ) WindowMode = TRUE;
#endif
#else
if (strstr(CmdLine, "windowmode")) WindowMode = TRUE;
#endif
if (strstr(CmdLine, "nodelay"))
NoDelay = FALSE;
if (strstr(CmdLine, "offline")){
ProcNo = PROC_GAME;
offlineFlag = TRUE;
}
else{
#ifndef _80_LOGIN_PLAY
ProcNo = PROC_ID_PASSWORD;
#else
ProcNo = PROC_80_LOGIN;
#endif
offlineFlag = FALSE;
}
if (strstr(CmdLine, "PROC_OHTA_TEST")){
ProcNo = PROC_OHTA_TEST;
offlineFlag = TRUE;
}
if (strstr(CmdLine, "PROC_TAKE_TEST")){
ProcNo = PROC_TAKE_TEST;
offlineFlag = TRUE;
}
if (strstr(CmdLine, "PROC_DWAF_TEST")){
ProcNo = PROC_DWAF_TEST;
offlineFlag = TRUE;
}
if (strstr(CmdLine, "PROC_BATTLE")){
ProcNo = PROC_BATTLE;
offlineFlag = TRUE;
}
if (strstr(CmdLine, "sprview")){
ProcNo = PROC_SPR_VIEW;
offlineFlag = TRUE;
}
if (strstr(CmdLine, "animview")){
ProcNo = PROC_ANIM_VIEW;
offlineFlag = TRUE;
}
if (strstr(CmdLine, "setest")){
ProcNo = PROC_SE_TEST;
offlineFlag = TRUE;
}
// if( strstr( CmdLine, "encountoff" ) ){
// EncountOffFlag = TRUE;
// }
if (strstr(CmdLine, "lowreso")){
ResoMode = 1;
}
#ifdef _LOG_MSG
if( strstr( CmdLine, "RECVDATA:" ) ){
char *pt = strstr( CmdLine, "RECVDATA:" )+9;
char *name;
int i;
name = debugLogFileName;
for( i = 0; i < 255; i++ ){
if( *pt != ' ' && *pt != '\0' && *pt != '\t' )
*name++ = *pt++;
else
break;
}
*name = '\0';
}
#endif
DebugKey(CmdLine);
}
void ChangeWindowMode(void)
{
RECT clientRect;
DWORD windowStyle;
ChangeMode(WindowMode);
if (WindowMode){
windowStyle = WS_MINIMIZEBOX | WS_SYSMENU |
//WS_THICKFRAME |
WS_CAPTION | WS_OVERLAPPED;
}
else{
windowStyle = WS_VISIBLE | WS_POPUP;
}
SetRect(&clientRect, 0, 0, lpDraw->xSize, lpDraw->ySize);
AdjustWindowRectEx(&clientRect, windowStyle, FALSE, NULL);
if (hWnd == NULL){
2020-06-23 15:27:59 +08:00
if (<EFBFBD><EFBFBD><EFBFBD><EFBFBD> == 950)
2020-06-22 17:49:02 +08:00
hWnd = CreateWindowEx(NULL,
2020-06-23 15:27:59 +08:00
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,
2020-06-22 17:49:02 +08:00
windowStyle,
//CW_USEDEFAULT,
//CW_USEDEFAULT,
0,
0,
clientRect.right - clientRect.left,
clientRect.bottom - clientRect.top,
NULL,
NULL,
hInst,
NULL);
else
hWnd = CreateWindowEx(NULL,
DEF_APPNAME,
DEF_APPNAME,
windowStyle,
//CW_USEDEFAULT,
//CW_USEDEFAULT,
0,
0,
clientRect.right - clientRect.left,
clientRect.bottom - clientRect.top,
NULL,
NULL,
hInst,
NULL);
}
else{
2020-06-23 15:27:59 +08:00
// ??????????<3F><>?
2020-06-22 17:49:02 +08:00
SetWindowLong(hWnd, GWL_STYLE, windowStyle);
2020-06-23 15:27:59 +08:00
// ?<3F><>????????<3F><><EFBFBD><EFBFBD>
2020-06-22 17:49:02 +08:00
ShowWindow(hWnd, CmdShow);
2020-06-23 15:27:59 +08:00
// ???????<3F>t?????<3F><>?
2020-06-22 17:49:02 +08:00
SetWindowPos(hWnd,
HWND_NOTOPMOST,
0,
0,
clientRect.right - clientRect.left,
clientRect.bottom - clientRect.top,
//SWP_SHOWWINDOW );
SWP_FRAMECHANGED);
}
2020-06-23 15:27:59 +08:00
// ?<3F><>????????<3F><><EFBFBD><EFBFBD>
2020-06-22 17:49:02 +08:00
ShowWindow(hWnd, CmdShow);
2020-06-23 15:27:59 +08:00
// ??????<3F><><EFBFBD><EFBFBD>?<3F><>
2020-06-22 17:49:02 +08:00
UpdateWindow(hWnd);
}
// ?????????????? **********************************************************/
void RecoverDirectDraw(void)
{
2020-06-23 15:27:59 +08:00
// DirectDraw ?<3F><>
2020-06-22 17:49:02 +08:00
ReleaseDirectDraw();
2020-06-23 15:27:59 +08:00
// ??<3F>T???<3F>@<40>e
2020-06-22 17:49:02 +08:00
SetResoMode(ResoMode);
// DirectDraw ???
if (InitDirectDraw() == FALSE){
2020-06-23 15:27:59 +08:00
MessageBoxNew(hWnd, "Direct <20><>ʼ<EFBFBD><CABC>ʧ<EFBFBD>ܣ<EFBFBD>", "ȷ<EFBFBD><EFBFBD>", MB_OK | MB_ICONSTOP);
2020-06-22 17:49:02 +08:00
// ???????? WM_CLOSE ??????????
PostMessage(hWnd, WM_CLOSE, 0, 0L);
}
2020-06-23 15:27:59 +08:00
// ????????<3F><>?<3F>v?
2020-06-22 17:49:02 +08:00
//ChangeWindowMode();
2020-06-23 15:27:59 +08:00
// ??????????????<3F><>
2020-06-22 17:49:02 +08:00
InitOffScreenSurface();
// ???????
if (InitPalette() == FALSE){
2020-06-23 15:27:59 +08:00
MessageBoxNew(hWnd, "ɫ<EFBFBD><EFBFBD> <20><>ʼ<EFBFBD><CABC>ʧ<EFBFBD>ܣ<EFBFBD>", "ȷ<EFBFBD><EFBFBD>", MB_OK | MB_ICONSTOP);
2020-06-22 17:49:02 +08:00
PostMessage(hWnd, WM_CLOSE, 0, 0L);
}
2020-06-23 15:27:59 +08:00
// ??????<3F><>????????????????<3F><>
2020-06-22 17:49:02 +08:00
if (ProcNo == PROC_BATTLE){
// ???????
DispBuffer.DispCnt = 0;
FontCnt = 0;
#ifdef _NEW_RESOMODE
//drawMap();
ReadBattleMap(BattleMapNo);
#else
ReadBattleMap( BattleMapNo );
#endif
// ???????????????
ClearBackSurface();
// ????????????????
#ifdef __SKYISLAND
fastDrawTileFlag = 0;
PutBmp();
fastDrawTileFlag = 1;
#else
PutBmp();
// ??????????????????????
lpBattleSurface->BltFast( 0, 0, lpDraw->lpBACKBUFFER, NULL, DDBLTFAST_WAIT );
#endif
// ???????
DispBuffer.DispCnt = 0;
FontCnt = 0;
// ????????
NowTime = TimeGetTime();
}
else
if (fastDrawTile && ProcNo == PROC_GAME)
{
2020-06-23 15:27:59 +08:00
repairMap(); // ????<3F><>?<3F><>?
2020-06-22 17:49:02 +08:00
}
// ??????????????
if (lpDraw->lpPALETTE != NULL){
// ??????????
if (WindowMode){
2020-06-23 15:27:59 +08:00
// ?<3F><>??????????<3F><>??
2020-06-22 17:49:02 +08:00
lpDraw->lpPALETTE->SetEntries(0, 0, 256, Palette);
}
}
2020-06-23 15:27:59 +08:00
// ???????<3F>V?????
2020-06-22 17:49:02 +08:00
mouse.state = MOUSE_NO_CRICK;
mouse.onceState = MOUSE_NO_CRICK;
2020-06-23 15:27:59 +08:00
// ???<3F>w?<3F><>????
2020-06-22 17:49:02 +08:00
NowTime = TimeGetTime();
}
//---------------------------------------------------------------------------//
2020-06-23 15:27:59 +08:00
// ?? <20><>???????????? //
// ?? <20><>?? //
2020-06-22 17:49:02 +08:00
//---------------------------------------------------------------------------//
BOOL SystemTask(void)
{
MSG msg;
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)){
if (msg.message == WM_QUIT)
return FALSE;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return TRUE;
}
//---------------------------------------------------------------------------//
2020-06-23 15:27:59 +08:00
// ?? <20><>?????????????? //
// ?? <20><>HWND hWnd: ??????<3F><><EFBFBD><EFBFBD>???? //
// UINT Message: ????<3F><>?????? //
// WPARAM wParam: ????<3F><>??????<3F><><EFBFBD>K<EFBFBD>ѩ<EFBFBD>? //
// LPARAM lParam: ????<3F><>??????<3F><><EFBFBD>K<EFBFBD>ѩ<EFBFBD>? //
2020-06-22 17:49:02 +08:00
//---------------------------------------------------------------------------//
#ifdef _REMAKE_20
extern short mouseCursorMode;
#endif
LRESULT CALLBACK WindMsgProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
switch (Message){
#ifdef _REMAKE_20
case WM_TIMER:
2020-06-23 15:27:59 +08:00
// <20><><EFBFBD><EFBFBD>8253<35><33>Ƭ<EFBFBD><C6AC>clock
2020-06-22 17:49:02 +08:00
RestoreCounter(1196);
break;
#endif
/** ??????????? *****************************************************/
2020-06-23 15:27:59 +08:00
case WM_ACTIVATE: // ??????????????????<3F><>??????????
2020-06-22 17:49:02 +08:00
#ifdef SA_25
static BOOL bInactive = FALSE;
if( bInactive && (LOWORD(wParam) == WA_ACTIVE || LOWORD(wParam) == WA_CLICKACTIVE)){
SetWindowPos( hWnd, NULL, 0, -100, 0, 0, NULL);
ShowWindow( hWnd, SW_MINIMIZE);
if( lpDraw && lpDraw->lpDD2){
lpDraw->lpDD2->SetCooperativeLevel( hWnd ,DDSCL_NORMAL);
ReleaseDirectDraw();
}
}
if( LOWORD(wParam) == WA_INACTIVE){
bInactive = TRUE;
cleanupNetwork();
PostQuitMessage( 0);
}
break;
#endif
// ?????????????????
if ((wParam == WA_ACTIVE || wParam == WA_CLICKACTIVE) && lpDraw != NULL){
// ?????? LOST ?????
if (CheckSurfaceLost() == TRUE){
// ??????????????
RecoverDirectDraw();
}
// ??????????????
if (lpDraw->lpPALETTE != NULL){
// ??????????
if (WindowMode){
2020-06-23 15:27:59 +08:00
// ?<3F><>??????????<3F><>??
2020-06-22 17:49:02 +08:00
lpDraw->lpPALETTE->SetEntries(0, 0, 256, Palette);
}
}
}
2020-06-23 15:27:59 +08:00
//???????????<3F><><EFBFBD><EFBFBD>
//?????<3F>ϣ<EFBFBD>??
if (keyboad_flg == TRUE){ //?????<3F>ϣ<EFBFBD>??
2020-06-22 17:49:02 +08:00
// ????????????????
if (pDInputDevice != NULL){
2020-06-23 15:27:59 +08:00
// ??????<3F><>???????????
2020-06-22 17:49:02 +08:00
if (wParam == WA_INACTIVE){
2020-06-23 15:27:59 +08:00
// DInput <20>_<EFBFBD><5F>
2020-06-22 17:49:02 +08:00
DInputActiveFlag = FALSE;
// ??????????
for (int i = 0; i < 256; i++) di_key[i] = 0;
pDInputDevice->Unacquire();
}
else{
// DInput ??
DInputActiveFlag = TRUE;
pDInputDevice->Acquire();
}
}
}
2020-06-23 15:27:59 +08:00
//????????<3F>ϣ<EFBFBD>??
2020-06-22 17:49:02 +08:00
if (joy_flg == TRUE){
// ???????????????????
if (pDInputDevice2 == NULL)
break;
2020-06-23 15:27:59 +08:00
// ??????<3F><>???????????
2020-06-22 17:49:02 +08:00
if (wParam == WA_INACTIVE){
2020-06-23 15:27:59 +08:00
// DInput <20>_<EFBFBD><5F>
2020-06-22 17:49:02 +08:00
DInputActiveFlag = FALSE;
pDInputDevice2->Unacquire();
}
else{
// DInput ??
DInputActiveFlag = TRUE;
pDInputDevice2->Acquire();
}
}
break;
2020-06-23 15:27:59 +08:00
case WM_CLOSE: // ?????<3F><>????
DestroyWindow(hWnd); // ??????<3F><>????<3F>i??
2020-06-22 17:49:02 +08:00
// WM_DESTROY ??????????
break;
2020-06-23 15:27:59 +08:00
case WM_DESTROY: // ??????<3F><>??????
2020-06-22 17:49:02 +08:00
2020-06-23 15:27:59 +08:00
PostQuitMessage(0); // WM_QUIT ???????? ( ???<3F><>? )
2020-06-22 17:49:02 +08:00
break;
#ifdef _REMAKE_20
#ifndef _STONDEBUG_
case WM_ACTIVATEAPP:
2020-06-23 15:27:59 +08:00
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӵ<EFBFBD>,<2C><EFBFBD><EBBFAA>Ϸ
2020-06-22 17:49:02 +08:00
if(!wParam){
SendMessage(hWnd,WM_CLOSE,0,0);
}
break;
#endif
#endif
#if 0
2020-06-23 15:27:59 +08:00
case WM_PALETTECHANGED: // ?????<3F><>??????
2020-06-22 17:49:02 +08:00
// DirectDraw??????????
if( lpDraw == NULL ) break;
// ??????????????
if( lpDraw->lpPALETTE == NULL ) break;
// ??????????
//if( WindowMode ){
2020-06-23 15:27:59 +08:00
// ?<3F><>??????????<3F><>??
2020-06-22 17:49:02 +08:00
lpDraw->lpPALETTE->SetEntries( 0, 0, 256, Palette );
//}
break;
//if( (HWND)wParam == hWnd ) break;
2020-06-23 15:27:59 +08:00
case WM_PALETTEISCHANGING: // ?????<3F><>??????
2020-06-22 17:49:02 +08:00
// DirectDraw??????????
if( lpDraw == NULL ) break;
// ??????????????
if( lpDraw->lpPALETTE == NULL ) break;
// ??????????
//if( WindowMode ){
2020-06-23 15:27:59 +08:00
// ?<3F><>??????????<3F><>??
2020-06-22 17:49:02 +08:00
lpDraw->lpPALETTE->SetEntries( 0, 0, 256, Palette );
//}
break;
2020-06-23 15:27:59 +08:00
case WM_QUERYNEWPALETTE: // ????<3F><>????????????????????
2020-06-22 17:49:02 +08:00
// DirectDraw??????????
if( lpDraw == NULL ) break;
// ??????????????
if( lpDraw->lpPALETTE == NULL ) break;
// ??????????
//if( WindowMode ){
2020-06-23 15:27:59 +08:00
// ?<3F><>??????????<3F><>??
2020-06-22 17:49:02 +08:00
lpDraw->lpPALETTE->SetEntries( 0, 0, 256, Palette );
//}
break;
#endif
2020-06-23 15:27:59 +08:00
/** ??<3F>V?????? *****************************************************/
2020-06-22 17:49:02 +08:00
2020-06-23 15:27:59 +08:00
case WM_KEYDOWN: // ??<3F>V???
2020-06-22 17:49:02 +08:00
if (SurfaceBusyFlag == TRUE){
SurfaceBusyFlag = FALSE;
RecoverDirectDraw();
}
switch (wParam){
case VK_LEFT:
KeyboardLeft();
break;
case VK_RIGHT:
KeyboardRight();
break;
case VK_RETURN:
KeyboardReturn();
break;
case VK_BACK:
if (joy_con[1] & JOY_RSHIFT || joy_con[1] & JOY_LSHIFT){
if (pNowStrBuffer != NULL){
pNowStrBuffer->cnt = 0;
pNowStrBuffer->buffer[0] = NULL;
}
}
else{
KeyboardBackSpace();
}
break;
case VK_DELETE:
ClearChatBuffer();
#ifdef _TALK_WINDOW
TalkWindow.ClearChatBuffer();
TalkWindow.Update();
#endif
break;
case VK_ESCAPE:
break;
}
#ifdef _TALK_WINDOW
if(g_bTalkWindow) TalkWindow.Update();
#endif
break;
#ifdef _REMAKE_20
case WM_HOTKEY:
2020-06-23 15:27:59 +08:00
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӵ<EFBFBD>,<2C><EFBFBD><EBBFAA>Ϸ
2020-06-22 17:49:02 +08:00
SendMessage(hWnd,WM_CLOSE,0,0);
break;
#endif
case WM_SYSKEYDOWN: // ALT????????
// ???????????
if (SurfaceBusyFlag == TRUE){
SurfaceBusyFlag = FALSE;
2020-06-23 15:27:59 +08:00
MessageBoxNew(hWnd, "SurfaceBusyFlag error!", "ȷ<EFBFBD><EFBFBD>", MB_OK | MB_ICONSTOP);
2020-06-22 17:49:02 +08:00
RecoverDirectDraw();
}
switch (wParam){
case VK_RETURN:
#ifdef _REMAKE_20
#ifndef _STONDEBUG_
2020-06-23 15:27:59 +08:00
// <20><><EFBFBD><EFBFBD><EFBFBD>Ӵ<EFBFBD>ģʽ<C4A3><EFBFBD><EBBFAA>Ϸ
2020-06-22 17:49:02 +08:00
SendMessage(hWnd,WM_CLOSE,0,0);
break;
#endif
#else
2020-06-23 15:27:59 +08:00
// ?<3F><>??<3F>I??
2020-06-22 17:49:02 +08:00
if (BackBufferDrawType == DRAW_BACK_PRODUCE) break;
// DirectDraw??????????
if (lpDraw == NULL) break;
2020-06-23 15:27:59 +08:00
// ???????????<3F><>?
2020-06-22 17:49:02 +08:00
if (WindowMode == TRUE) WindowMode = FALSE;
else WindowMode = TRUE;
#ifdef _TALK_WINDOW
if(g_bTalkWindow){
g_bTalkWindow = FALSE;
TalkWindow.Visible(FALSE);
}
#endif
ChangeMode(WindowMode);
2020-06-23 15:27:59 +08:00
// DirectDraw ?<3F><>
2020-06-22 17:49:02 +08:00
ReleaseDirectDraw();
2020-06-23 15:27:59 +08:00
// ??<3F>T???<3F>@<40>e
2020-06-22 17:49:02 +08:00
SetResoMode(ResoMode);
// DirectDraw ???
InitDirectDraw();
2020-06-23 15:27:59 +08:00
// ??????????????<3F><>
2020-06-22 17:49:02 +08:00
InitOffScreenSurface();
2020-06-23 15:27:59 +08:00
// ????????<3F><>?<3F>v?
2020-06-22 17:49:02 +08:00
ChangeWindowMode();
2020-06-23 15:27:59 +08:00
// <20>u???????<3F><>???
2020-06-22 17:49:02 +08:00
//SendMessage( HWND_BROADCAST, WM_PAINT, NULL, NULL );
// ???????
if (InitPalette() == FALSE){
//PostMessage( hWnd, WM_CLOSE, 0, 0L );
PostMessage(hWnd, WM_SYSKEYDOWN, VK_RETURN, 0L);
}
2020-06-23 15:27:59 +08:00
// ??????<3F><>????????????????<3F><>
2020-06-22 17:49:02 +08:00
if (ProcNo == PROC_BATTLE){
// ???????
DispBuffer.DispCnt = 0;
FontCnt = 0;
#ifdef _NEW_RESOMODE
//drawMap();
ReadBattleMap(BattleMapNo);
#else
ReadBattleMap( BattleMapNo );
#endif
// ???????????????
ClearBackSurface();
// ????????????????
#ifdef __SKYISLAND
fastDrawTileFlag = 0;
PutBmp();
fastDrawTileFlag = 1;
#else
PutBmp();
// ??????????????????????
lpBattleSurface->BltFast( 0, 0, lpDraw->lpBACKBUFFER, NULL, DDBLTFAST_WAIT );
#endif
// ???????
DispBuffer.DispCnt = 0;
FontCnt = 0;
// ????????
NowTime = TimeGetTime();
}
else
if (fastDrawTile && ProcNo == PROC_GAME)
{
2020-06-23 15:27:59 +08:00
repairMap(); // ????<3F><>?<3F><>?
2020-06-22 17:49:02 +08:00
}
// ??????????????
if (lpDraw->lpPALETTE != NULL){
// ??????????
if (WindowMode){
2020-06-23 15:27:59 +08:00
// ?<3F><>??????????<3F><>??
2020-06-22 17:49:02 +08:00
lpDraw->lpPALETTE->SetEntries(0, 0, 256, Palette);
}
}
2020-06-23 15:27:59 +08:00
// ???????<3F>V?????
2020-06-22 17:49:02 +08:00
mouse.state = MOUSE_NO_CRICK;
mouse.onceState = MOUSE_NO_CRICK;
2020-06-23 15:27:59 +08:00
// ???<3F>w?<3F><>????
2020-06-22 17:49:02 +08:00
NowTime = TimeGetTime();
break;
#endif
break;
default:
if (wParam != VK_F10){
return DefWindowProc(hWnd, Message, wParam, lParam);
}
break;
}
break;
2020-06-23 15:27:59 +08:00
case WM_CHAR: // <20><>?<3F>V???
// <20><>?????????
2020-06-22 17:49:02 +08:00
StockStrBufferChar((char)wParam);
break;
2020-06-23 15:27:59 +08:00
case WM_MOUSEMOVE: // ????<3F>h????
2020-06-22 17:49:02 +08:00
//SetCursor( wndclass.hCursor );
2020-06-23 15:27:59 +08:00
// ????????<3F>t?????
2020-06-22 17:49:02 +08:00
MouseNowPoint(LOWORD(lParam), HIWORD(lParam));
#ifndef _TALK_WINDOW
if (mouse.flag == TRUE){
2020-06-23 15:27:59 +08:00
ShowCursor(FALSE); // ????????<3F><>?
2020-06-22 17:49:02 +08:00
mouse.flag = FALSE;
}
#else
if(MouseCursorFlag == FALSE && g_iCursorCount > -1){
while(g_iCursorCount > -1) g_iCursorCount = ShowCursor( FALSE );
mouse.flag = FALSE;
}
else if(MouseCursorFlag == TRUE && g_iCursorCount < 0){
while(g_iCursorCount < 0) g_iCursorCount = ShowCursor( TRUE );
}
#endif
// ???????????
if (SurfaceBusyFlag == TRUE){
SurfaceBusyFlag = FALSE;
// ??????????????
RecoverDirectDraw();
}
break;
2020-06-23 15:27:59 +08:00
case WM_NCMOUSEMOVE: // ?????????????<3F><>??
// ???????<3F>V?????
2020-06-22 17:49:02 +08:00
mouse.state = MOUSE_NO_CRICK;
mouse.onceState = MOUSE_NO_CRICK;
if (mouse.flag == FALSE){
#ifdef _TALK_WINDOW
g_iCursorCount = ShowCursor( TRUE );
#else
2020-06-23 15:27:59 +08:00
ShowCursor(TRUE); // ????????<3F><><EFBFBD><EFBFBD>
2020-06-22 17:49:02 +08:00
#endif
mouse.flag = TRUE;
}
break;
case WM_LBUTTONDOWN: // ?????(????)
#ifdef _80_LOGIN_PLAY
if (ProcNo == PROC_80_LOGIN)
break;
#endif
#ifdef _REMAKE_20
2020-06-23 15:27:59 +08:00
// <20><><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>İ<EFBFBD><C4B0>»<EFBFBD><C2BB><EFBFBD>
2020-06-22 17:49:02 +08:00
if(!IsLMouseButtonDown()) mouseCursorMode = 0;
else
#endif
2020-06-23 15:27:59 +08:00
// ???????????????<3F>t?????
2020-06-22 17:49:02 +08:00
MouseCrickLeftDownPoint(LOWORD(lParam), HIWORD(lParam));
break;
case WM_LBUTTONUP: // ?????(????)
2020-06-23 15:27:59 +08:00
// ???????????????<3F>t?????
2020-06-22 17:49:02 +08:00
MouseCrickLeftUpPoint(LOWORD(lParam), HIWORD(lParam));
break;
case WM_LBUTTONDBLCLK: // ????????
#ifdef _80_LOGIN_PLAY
if (ProcNo == PROC_80_LOGIN)
break;
#endif
2020-06-23 15:27:59 +08:00
// ??????????????????<3F>t?????
2020-06-22 17:49:02 +08:00
MouseDblCrickLeftUpPoint(LOWORD(lParam), HIWORD(lParam));
break;
case WM_RBUTTONDOWN: // ?????(????)
#ifdef _REMAKE_20
2020-06-23 15:27:59 +08:00
// <20><><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>İ<EFBFBD><C4B0>»<EFBFBD><C2BB><EFBFBD>
2020-06-22 17:49:02 +08:00
if(!IsRMouseButtonDown()) mouseCursorMode = 0;
else
#endif
2020-06-23 15:27:59 +08:00
// ???????????????<3F>t?????
2020-06-22 17:49:02 +08:00
MouseCrickRightDownPoint(LOWORD(lParam), HIWORD(lParam));
break;
case WM_RBUTTONUP: // ?????(????)
2020-06-23 15:27:59 +08:00
// ???????????????<3F>t?????
2020-06-22 17:49:02 +08:00
MouseCrickRightUpPoint(LOWORD(lParam), HIWORD(lParam));
break;
case WM_RBUTTONDBLCLK: // ????????
2020-06-23 15:27:59 +08:00
// ??????????????????<3F>t?????
2020-06-22 17:49:02 +08:00
MouseDblCrickRightUpPoint(LOWORD(lParam), HIWORD(lParam));
break;
case WM_MBUTTONDOWN: // ?????(????)
break;
case WM_MOVE:
{
g_clientPoint.x = g_clientPoint.y = 0;
GetClientRect(hWnd, &g_clientRect);
ClientToScreen(hWnd, &g_clientPoint);
OffsetRect(&g_clientRect, g_clientPoint.x, g_clientPoint.y);
SetRect(&g_moveRect, 0, 0, lpDraw->xSize, lpDraw->ySize);
#ifdef _TALK_WINDOW
if(g_bTalkWindow) SendMessage(TalkWindow.GetTalkWindowWND(),WM_MOVE,0,0);
#endif
}
break;
2020-06-23 15:27:59 +08:00
//<2F>Զ<EFBFBD>Hook Msg<73><67><EFBFBD><EFBFBD>Type
#ifdef _SAHOOK //Syu ADD Hook<6F><6B>ʽ
2020-06-22 17:49:02 +08:00
case UM_KEYEVENT:
TCHAR ac[2];
BYTE bKeyState[256];
GetKeyboardState(bKeyState);
if (ToAscii(wParam, (HIWORD(lParam) & (0x00FF | KF_UP)), bKeyState, (PWORD) ac, 0) == 1)
{
extern int HOOK_PASSWD_NUM;
if((HOOK_PASSWD_NUM < 12) && (wParam != 13) && (wParam != 9) && (wParam != 27))
HOOK_PASSWD_NUM++;
}
if (wParam == 8 )
if(HOOK_PASSWD_NUM >0 )
HOOK_PASSWD_NUM--;
#endif
default:
if (ImeMessage(Message, wParam, lParam))
return 0;
return DefWindowProc(hWnd, Message, wParam, lParam);
}
return 0;
}
void SetResoMode(int Mode){
ResoMode = Mode;
lpDraw = (DIRECT_DRAW *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (DWORD)sizeof(DIRECT_DRAW));
if (lpDraw == NULL){
2020-06-23 15:27:59 +08:00
MessageBoxNew(hWnd, "HeapAlloc Error ( DIRECT_DRAW )", "ȷ<EFBFBD><EFBFBD>", MB_OK | MB_ICONSTOP);
2020-06-22 17:49:02 +08:00
return;
}
switch (Mode){
case 0:
//460*480
lpDraw->xSize = 640;
lpDraw->ySize = 480;
SurfaceSizeX = 64;
SurfaceSizeY = 48;
DISPLACEMENT_X = 0;
DISPLACEMENT_Y = 0;
break;
case 1:
//320*240
lpDraw->xSize = 320;
lpDraw->ySize = 240;
SurfaceSizeX = 64;
SurfaceSizeY = 48;
DISPLACEMENT_X = 0;
DISPLACEMENT_Y = 0;
break;
case 2:
2020-06-23 15:27:59 +08:00
//<2F>ɱ<EFBFBD>
2020-06-22 17:49:02 +08:00
lpDraw->xSize = 640;
lpDraw->ySize = 480;
SurfaceSizeX = 64;
SurfaceSizeY = 48;
DISPLACEMENT_X = 0;
DISPLACEMENT_Y = 0;
break;
#ifdef _NEW_RESOMODE
case 3:
lpDraw->xSize = 800;
lpDraw->ySize = 600;
SurfaceSizeX = 64;
SurfaceSizeY = 48;
DISPLACEMENT_X = 160;
DISPLACEMENT_Y = 120;
break;
case 4:
lpDraw->xSize = 1024;
lpDraw->ySize = 768;
SurfaceSizeX = 64;
SurfaceSizeY = 48;
DISPLACEMENT_X = 384;
DISPLACEMENT_Y = 288;
break;
#endif
}
DEF_APPSIZEX = lpDraw->xSize;
DEF_APPSIZEY = lpDraw->ySize;
SCREEN_WIDTH_CENTER = DEF_APPSIZEX / 2;
SCREEN_HEIGHT_CENTER = DEF_APPSIZEY / 2;
viewOffsetX = SCREEN_WIDTH_CENTER;
viewOffsetY = SCREEN_HEIGHT_CENTER;
PostMessage(hWnd, WM_MOVE, 0, 0L);
}