Code:
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
g_cCustomOptimizer.AutoLauncher();
// 2010-09-29 by jskim, ´ýÇÁ ³²±âµµ·Ï ¼öÁ¤
SetUnhandledExceptionFilter(Exception_Minidump);
// end 2010-09-29 by jskim, ´ýÇÁ ³²±âµµ·Ï ¼öÁ¤
if (g_hMutexMonoInstance)
{
MessageBox(NULL, "Debug g_hMutexMonoInstance != NULL", NULL, MB_OK);
return 0;
}
g_hMutexMonoInstance = CreateMutex(NULL, TRUE, WINDOWTEXT_NAME_CLIENT);
if (NULL == g_hMutexMonoInstance)
{
MessageBox(NULL, "Debug g_hMutexMonoInstance == NULL", NULL, MB_OK);
return 0;
}
#ifdef MULTI_LOADER_HSSON
#else // MULTI_LOADER_HSSON
if(ERROR_ALREADY_EXISTS == ::GetLastError())
{
MessageBox(NULL, "ERROR : \nApplication is running already...", WINDOWTEXT_NAME_CLIENT, MB_OK);
return 0;
}
#endif // MULTI_LOADER_HSSON
// 2007-07-26 by bhsohn ¿¹´ç À©µµ¿ì ¸ðµå¸¸ µÇ´Â ¹ö±× ¼öÁ¤
//if(__argc != 12 && __argc != 16 && __argc != 11 && __argc != 14)
if(__argc != 12 && __argc != 16 && __argc != 11 && __argc != 15)
{
DBGOUT("[Error] Parameter Count Error, Count(%d)(%s)\n", __argc, lpCmdLine);
MessageBox(NULL, "Debug Parameter Count Error", NULL, MB_OK);
return FALSE;
}
char szTemp[20];
CAtumApplication pD3dApp;
if( __argc == 12 )
{
#ifdef MULTI_LOADER_HSSON
sscanf(lpCmdLine,"%s %d %s %d %s %s %d %d %d %d %s", pD3dApp.m_strFieldIP, &pD3dApp.m_nFieldPort, pD3dApp.m_strChatIP, &pD3dApp.m_nChatPort, pD3dApp.m_strUserID,
pD3dApp.m_strUserPassword, &pD3dApp.m_IsFullMode, &pD3dApp.m_nWidth, &pD3dApp.m_nHeight, &pD3dApp.m_bDegree, szTemp);
if (strcmp(szTemp, "DEVELOP") != 0)
{
MessageBox(NULL, "Debug wrong parameter call", NULL, MB_OK);
return 0;
}
#else // MULTI_LOADER_HSSON
MessageBox(NULL, "Debug Invalid parameter count", NULL, MB_OK);
return 0;
#endif // MULTI_LOADER_HSSON
}
else if(__argc == 11) // 2005-08-05 by cmkwon, for JPN release
{
sscanf(lpCmdLine,"%s %d %s %d %s %s %d %d %d %d", pD3dApp.m_strFieldIP, &pD3dApp.m_nFieldPort, pD3dApp.m_strChatIP, &pD3dApp.m_nChatPort, pD3dApp.m_strUserID,
pD3dApp.m_strUserPassword, &pD3dApp.m_IsFullMode, &pD3dApp.m_nWidth, &pD3dApp.m_nHeight, &pD3dApp.m_bDegree);
}
#ifdef KOR_YEDANG_WEB_LAUNCHER_HSSON
// 2006-10-02 by ispark, Çѱ¹ À¥ ·±Ã³
// 2007-07-26 by bhsohn ¿¹´ç À©µµ¿ì ¸ðµå¸¸ µÇ´Â ¹ö±× ¼öÁ¤
//else if(__argc == 14)
else if(__argc == 15)
{
int nSeed = 0;
int nType = 0;
char Reserve1[20] = {0,};
char Reserve2[20] = {0,};
char strMutexID[1024] = {0,};
DbgOut("%s\n", lpCmdLine);
sscanf(lpCmdLine,"%s %d %s %d %d %d %d %d %s %s %d %d %s %s", pD3dApp.m_strFieldIP, &pD3dApp.m_nFieldPort, pD3dApp.m_strChatIP, &pD3dApp.m_nChatPort,
&pD3dApp.m_nWidth, &pD3dApp.m_nHeight, &pD3dApp.m_bDegree,
&pD3dApp.m_IsFullMode, // 2007-07-26 by bhsohn ¿¹´ç À©µµ¿ì ¸ðµå¸¸ µÇ´Â ¹ö±× ¼öÁ¤
pD3dApp.m_strUserID, pD3dApp.m_strUserPassword, &nSeed, &nType, Reserve1, Reserve2);
HANDLE hMutex = NULL;
sprintf(strMutexID, "%s%d", pD3dApp.m_strUserPassword, nSeed);
hMutex = ::OpenMutex(MUTEX_ALL_ACCESS, TRUE, (LPTSTR)strMutexID);
if(hMutex == NULL)
{
DbgOut("[Error] Mutex Error\n");
MessageBox(NULL, "Debug Mutex error", NULL, MB_OK);
return FALSE;
}
// 2006-10-18 by ispark, ReleaseMutex() -> CloseHandle()·Î º¯°æ
CloseHandle(hMutex);
}
#endif //YEDANG_WEB_LAUNCHER
else
{
int nSeed = 0;
char szAccount[SIZE_MAX_ACCOUNT_NAME];
char szEncAccount[MGAME_MAX_PARAM_STRING_SIZE];
char szEncPassword[MGAME_MAX_PARAM_STRING_SIZE];
sscanf(lpCmdLine,"%s %d %s %d %s %s %d %d %d %d %s %d %s %s %s", pD3dApp.m_strFieldIP, &pD3dApp.m_nFieldPort, pD3dApp.m_strChatIP, &pD3dApp.m_nChatPort,
pD3dApp.m_strUserID, pD3dApp.m_strUserPassword, &pD3dApp.m_IsFullMode, &pD3dApp.m_nWidth, &pD3dApp.m_nHeight, &pD3dApp.m_bDegree,
szTemp, &nSeed, szAccount, szEncAccount, szEncPassword);
// Mutex Check
HANDLE hMutex = NULL;
hMutex = ::OpenMutex(MUTEX_ALL_ACCESS, TRUE, (LPTSTR)szEncPassword); // ¾ÏÈ£ÈµÈÆÐ½º¿öµå°ªÀ» ³Ö´Â´Ù
if(hMutex == NULL)
{
DBGOUT("[Error] Mutex Error\n");
MessageBox(NULL, "Debug Mutex error", NULL, MB_OK);
return FALSE;
}
// 2006-10-18 by ispark, ReleaseMutex() -> CloseHandle()·Î º¯°æ
CloseHandle(hMutex);
// ExcuteType Check
if(strcmp(szTemp, "INET"))
{
DBGOUT("[Error] Excute Type Error, Type(%s)\n", szTemp);
MessageBox(NULL, "Execute type error", NULL, MB_OK);
return FALSE;
}
char szDecryptedID[MGAME_MAX_PARAM_STRING_SIZE];
strncpy(szDecryptedID, (char *)decrypt((unsigned char*)szEncAccount, nSeed), MGAME_MAX_PARAM_STRING_SIZE);
// ID Check
if(strcmp(szAccount, szDecryptedID))
{
DBGOUT("[Error] Decryption ID Error, DecryptedID(%s)\n", szDecryptedID);
MessageBox(NULL, "Debug Decryption ID Error", NULL, MB_OK);
return FALSE;
}
}
#ifdef ONLY_FULL_WINDOW_HSSON
pD3dApp.m_IsFullMode = TRUE;
#endif // ONLY_FULL_WINDOW_HSSON
// 2009-01-22 by bhsohn Xign Code½Ã, Sleep(3000)Ãß°¡
if(!pD3dApp.StartGameGuard())
{
pD3dApp.CloseGameGuard();
MessageBox(NULL, "Debug Failed to start game guard", NULL, MB_OK);
return FALSE;
}
// end 2009-01-22 by bhsohn Xign Code½Ã, Sleep(3000)Ãß°¡
// 2007-12-21 by dgwoo â¸ðµå Áö¿ø
DbgOut("FullMode = %d\n",pD3dApp.m_IsFullMode);
if (FAILED(pD3dApp.Create(hInstance)))
{
MessageBox(NULL, "Debug Failed to initialize the game", NULL, MB_OK);
return 0;
}
// 2008-11-28 by bhsohn XignCodeÃß°¡
///////// °ÔÀÓ °¡µå ¼³Á¤/////////
//#if defined(_DEBUG) || defined(GAMEFORGE_RELEASE) || defined(WORLD_RELEASE) || defined(LANGUAGE_RUSSIA)// 2008-04-30 by bhsohn ű¹ ¹öÀü Ãß°¡
//#if defined(_DEBUG) || defined(LANGUAGE_RUSSIA)
//#else
// // 2006-06-05 by ispark
// if(!pD3dApp.HS_Start())
// {
// DBGOUT("HShield Error\n");
// pD3dApp.HS_Close();
// return FALSE;
// }
//#endif
// 2009-01-22 by bhsohn Xign Code½Ã, Sleep(3000)Ãß°¡
// if(!pD3dApp.StartGameGuard())
// {
// pD3dApp.CloseGameGuard();
// return FALSE;
// }
// end 2008-11-28 by bhsohn XignCodeÃß°¡
// end 2009-01-22 by bhsohn Xign Code½Ã, Sleep(3000)Ãß°¡
// 2009-01-28 by bhsohn nProtector °ÔÀÓ °¡µå Ãß°¡
if(!pD3dApp.SetGameGuardHWND())
{
pD3dApp.CloseGameGuard();
MessageBox(NULL, "Debug Failed to initialize Game Guard", NULL, MB_OK);
return FALSE;
}
// end 2009-01-28 by bhsohn nProtector °ÔÀÓ °¡µå Ãß°¡
g_input.InitInput();
INT nResult;
// 2010-09-29 by jskim, ´ýÇÁ ³²±âµµ·Ï ¼öÁ¤
// #ifdef _DEBUG
// nResult = pD3dApp.Run();
// #else
// try
// {
// nResult = pD3dApp.Run();
// }
//
// catch(...)
// {
// DBGOUT("Extations Error\n");
// // 2008-11-28 by bhsohn XignCodeÃß°¡
// //pD3dApp.HS_Close();
// pD3dApp.CloseGameGuard();
// // end 2008-11-28 by bhsohn XignCodeÃß°¡
// }
// #endif
//#ifdef _DEBUG
nResult = pD3dApp.Run();
//#else
// try
// {
// nResult = pD3dApp.Run();
// }
// catch(...)
// {
DBGOUT("Extations Error\n");
// 2008-11-28 by bhsohn XignCodeÃß°¡
//pD3dApp.HS_Close();
pD3dApp.CloseGameGuard();
// end 2008-11-28 by bhsohn XignCodeÃß°¡
// }
//#endif
// end 2010-09-29 by jskim, ´ýÇÁ ³²±âµµ·Ï ¼öÁ¤
CloseHandle(g_hMutexMonoInstance);
// 2008-11-28 by bhsohn XignCodeÃß°¡
// 2008-09-19 by bhsohn Canada HackShield
//#if defined(_DEBUG) || defined(GAMEFORGE_RELEASE) || defined(WORLD_RELEASE)|| defined(LANGUAGE_RUSSIA)// 2008-04-30 by bhsohn ű¹ ¹öÀü Ãß°¡
//#if defined(_DEBUG) || defined(LANGUAGE_RUSSIA)// 2008-04-30 by bhsohn ű¹ ¹öÀü Ãß°¡
//#else
// // 2006-06-05 by ispark
// pD3dApp.HS_Close();
//#endif
pD3dApp.CloseGameGuard();
// end 2008-11-28 by bhsohn XignCodeÃß°¡
// 2006-07-06 by ispark, °Á¦ Á¾·áÀÌ¸é¼ ¿¡·¯ ¸Þ¼¼Áö¸¦ °¡Áö°í ÀÖ´Ù¸é
if(pD3dApp.m_bShutDown && strlen(pD3dApp.m_strMsgLastError))
{
MessageBox(NULL, pD3dApp.m_strMsgLastError,STRMSG_WINDOW_TEXT, MB_OK);
}
return nResult;
}