Jump to content

How To Implementing HackShield SDK on Metin2


Recommended Posts

  • Former Staff

Note: This tutorial was originally written on 26-01-2017 for a pserver.

Note: I don't have the SDK, I'll notify the admins if I manage to find one (it's missing on the temp forum)

Note: AhnLab HackShield is deprecated, it has not received any update since 2013 or similar

 

1. Extern

Go to Extern/include and create a new folder called hackshield
(If you already have some files inside that remove all of them)
Put the files from (Your HackShield SDK Zip)/Include to Extern/include/hackshield
This step must be done on both Client and Server Extern

Copy from (Your HackShield SDK Zip)/Lib/Win/x86/MultiThreaded to Extern/lib the following files: (Client only)

HShield/HShield.lib

AntiCrack/AntiCpXSvr.lib

Copy (Your HackShield SDK Zip)/Developer/Lib/Win/x86/Multithreaded/HShield.lib to Extern/lib/HShield_d.lib (Yes you have to rename this)
Copy from (Your HackShield SDK Zip)/Lib/FreeBSD/x86/AntiCrack/LibAntiCpXSvr_st.a to Extern/lib (Server only)

Create a new file called hshieldLibLink.h in Extern/include/hackshield (Both Client and Server) and put this:

#ifndef _HACKSHIELD_INCLUDE_LIBLINK_H_
#define _HACKSHIELD_INCLUDE_LIBLINK_H_
	#ifdef _MSC_VER
		#ifdef _DEBUG
			#pragma comment(lib,"hshield_d.lib")
		#else
			#pragma comment(lib,"hshield.lib")
		#endif
		
		#pragma comment(lib,"HsUserUtil.lib")
	#endif	
#endif

 

2- Client source: Adding /CLR

-- Speaicl note: you need to rebuild libjpeg, lzo, cryptopp with /MD and /MDd (defaults are /MT for CryptoPP, /MD for libjpeg and lzo if cmake is being used)

You have to edit the VCXProjects
Go to C/C++ -> All Options and find /M
In Distribute/Release you have to set the "Runtime Library" value to /MD
In Debug you have to set that to /MDd

Now you have to go on General (In the project settings) and add "Support with Common Language Runtime" to 1 (/clr)

Now go on C/C++ -> All Options and find /RTC and change that to "Default"
Now go to All Options and write in command line: "/RTC:NO"

 

--- Special note: this step was intended for an old CryptoPP version (I think v5.x?) follow this step only if you receive issues

Spoiler

Now you need to rebuild all modules with the Runtime Library change that you do before
But Crypto++ need another adjustment, open config.h and change this:


// synchronization: MS at VS2012 (17.00); GCC at 4.4; Clang at 3.3; Xcode 5.0; Intel 12.0; SunCC 12.4.
// TODO: verify Clang and Intel versions; find __has_feature(x) extension for Clang
#if (CRYPTOPP_MSC_VERSION >= 1700)
#  define CRYPTOPP_CXX11_SYNCHRONIZATION 1
#elif (__INTEL_COMPILER >= 1200)
#  define CRYPTOPP_CXX11_SYNCHRONIZATION 1
#elif (CRYPTOPP_LLVM_CLANG_VERSION >= 30300) || (CRYPTOPP_APPLE_CLANG_VERSION >= 50000)
#  define CRYPTOPP_CXX11_SYNCHRONIZATION 1
#elif (CRYPTOPP_GCC_VERSION >= 40400)
#  define CRYPTOPP_CXX11_SYNCHRONIZATION 1
#elif (__SUNPRO_CC >= 0x5130)
#  define CRYPTOPP_CXX11_SYNCHRONIZATION 1
#endif // synchronization

With this:


// synchronization: MS at VS2012 (17.00); GCC at 4.4; Clang at 3.3; Xcode 5.0; Intel 12.0; SunCC 12.4.
// TODO: verify Clang and Intel versions; find __has_feature(x) extension for Clang
/*#if (CRYPTOPP_MSC_VERSION >= 1700)
#  define CRYPTOPP_CXX11_SYNCHRONIZATION 1
#elif (__INTEL_COMPILER >= 1200)
#  define CRYPTOPP_CXX11_SYNCHRONIZATION 1
#elif (CRYPTOPP_LLVM_CLANG_VERSION >= 30300) || (CRYPTOPP_APPLE_CLANG_VERSION >= 50000)
#  define CRYPTOPP_CXX11_SYNCHRONIZATION 1
#elif (CRYPTOPP_GCC_VERSION >= 40400)
#  define CRYPTOPP_CXX11_SYNCHRONIZATION 1
#elif (__SUNPRO_CC >= 0x5130)
#  define CRYPTOPP_CXX11_SYNCHRONIZATION 1
#endif*/ // synchronization
#undef CRYPTOPP_CXX11_SYNCHRONIZATION
	

 

 

Now rebuild everything and you don't have "mutex is not supported in CLR" error

 

3. Client source: Adding hackshield

Open UserInterface/HackShield.cpp
You will find the following lines: (Or something similar at the beginning of the file)

#if defined(LOCALE_SERVICE_EUROPE)
	#define METIN2HS_MONITORING_SERVER_ADDR "79.110.88.84"
#elif
	#define METIN2HS_MONITORING_SERVER_ADDR "79.110.88.84" // GF
#endif
//#define METIN2HS_MONITORING_SERVER_ADDR "119.192.130.160"  //±è¿ë¿í pc

Replace all with this:

#define METIN2HS_MONITORING_SERVER_ADDR "YOUR IP OF THE MONITOR SERVER"

 

-- Extra note: the monitoring server should be a server used to monitor running instances of HackShield, I never went deeply into this, perhaps you can find some extra information on the HackShield SDK docs

 

Ok now open UserInterface/Locale_inc.h and add this:

#define USE_AHNLAB_HACKSHIELD						// HackShield
#define METIN2HS_INCLUDE	hackshield
		

Open HackShield.h and replace:

#include "HackshieldLicense.h"

with:

#include "HackshieldLicense_metin2client.h"

 

Open UserInterface/HackshieldLicense_metin2client.h and replace:

#define METIN2HS_EXE_FILE_NAME        "metin2client.bin"
		

With:

#define METIN2HS_EXE_FILE_NAME        "NAME OF THE METIN2 CLIENT.EXTENSION"

Example:

#define METIN2HS_EXE_FILE_NAME		  "testclient_arves100.exe"

 

Now you need to setup your project for compile and use without error
Open UserInterface Properties page:
When you see Common Language Runtime Support (CLR) set it to /clr (If you use anyother it wont compile\link properly)
Now go on C/C++ -> Enable C++ exception (sorry for bad translate <.<)
Change "Yes (/EHsc)" to "Yes with SEH exceptions (/EHa)"

 

Extra:
If you get error on "DEFAULT_HSMS_TIME_OUT not defined" you have to do this:

Open Extern/include/hackshield/hshield.h and delete:

 

DEFAULT_HSMS_TIME_OUT
				


Add after:

#ifndef _HSHIELD_H_INC
#define _HSHIELD_H_INC            

    
this:

// Fix for compilation error
#ifndef DEFAULT_HSMS_TIME_OUT
    #define    DEFAULT_HSMS_TIME_OUT        (5 * 1000)   // 5ÃÊ
#endif

 

- 3. Server

Open game/src/Makefile and change this:

# HackShield
INCDIR += -I../../libhackshield/include
LIBDIR += -L../../libhackshield/lib
LIBS += -lanticpxsvr


        to:

 

 

# HackShield *New* INCDIR += -I../../../Extern/include/hackshield LIBS += -lanticpxsvr_st

Open game/src/HackShield_Impl.cpp and edit this line:

handle_ = _AhnHS_CreateServerObject("metin2client.bin.hsb");


           

with this:
handle_ = _AhnHS_CreateServerObject("data/<client file name.extension>.hsb");

Open your Auth and Game CONFIGs and add this:
hackshield_enable: 1
Extra:

 

"hackshield_first_check_time" and "hackshield_check_cycle_time" are 2 CONFIG variables
First check time: it tells after what second the server should ask the first heartbeat of the hackshield

Cycle time:  it tells after what second the server should ask a heartbeat of the hackshield

 

4. Client binary

You have to copy from (HackShield SDK Zip)/Bin/Win/x86/HShield to Client Binary Folder
If you want to use development hackshield (raccomended for Debug or QA) you have all content from (HackShield SDK Zip)/Developer/Bin to (Client Binary Folder)/HShield
Remember: Do not distribute the development file (/Developer/Bin/), always use the release (/Bin/)

If you want to periodically release updates for your HackShield you have to copy all content from (HackShield SDK Zip)/Bin/Win/x86/Update to your HShield folder on Client Binary Folder

 

5. Configuring Hackshield

We will work on (HackShield SDK Zip)/Bin/Win/x86:
We must setup the AntiCrack that will check if the Client integrity is ok
AntiCrack/HSBGen.exe will generate our HSB file
AntiCrack/HSBHelper.exe will check if the files are ok
Explanation:

spacer.pngspacer.png

 

The Output file will be the same name as we setted in HackShield_Impl.cpp before
If you had to sign your exe make sure you do that after you used HSBGenerator
If you use any other packer than UPX you must have to select "Execute Packet Exe File"
Now it will generate a hsb file, put this file on (Server Binary Folder)/data/
You can now check the hsb file with the client to see if everything match

We need to tell hackshield witch server he uses to update our HShield files (Only if you want HSUpdate.exe)
Open Util/HSUpSetEnv.exe

 

-- Extra note: this is used for updating HackShield content from a remote server, you might want to ship it and do not use HSUpdate.exe
Let me explain this application:

spacer.pngspacer.png

 

After you save it will create a HSUpdate.env file witch you have to put on (Client Binary Folder)/HShield

 

Extra: Configuring HSUpdate server

If you want to use FTP trasfer method you have to configure a ftp server with username and password you want to use (i won't explain this)

You have to copy the folder PatchSet to your webserver
Normally when you update your HackShield SDK you will get the update PatchSet for updating your client's HackShield to lateset version
Everytime you get an HackShield SDK Update (mine is from 2012) you have to put the new PatchSet and distribute the new client (.exe)

 

Extra: Disabling HS Monitor

HackShield.cpp, change the _AhnHS_StartMonitor function to this:

        #ifdef ENABLE_HACKSHIELD_MONITOR
        DWORD dwRet = _AhnHS_StartMonitor (HsExtError, szInterfaceFilePath);
        if( dwRet != ERROR_SUCCESS )
        {
            MessageBox(NULL, MA_T("START_MONITORING_SERVICE_ERROR"), "HACK_SHIELD", MB_OK);
        }
        #endif

 

Extra: Customizing names

We see before how to customize .hsb file name for Server, Check out Server part if you miss out

HSMonitor Client Name and Version can be setted in UserInterface/HackShield.cpp by editing this:

 

strcpy(HsExtError.szGameVersion, "1.0.0.0"); //Game ë²„ì „
strcpy(HsExtError.szUserId, "Metin2User_test"); //ìœ ì € ID

 

If you changed the locale/ folder you also have to edit this:

#define PREFIX_LOCALE        "locale/"

If you want to edit the EhSvc.dll Name and Folder you have to edit this:

#ifdef _DEBUG MA_PathMerge(szInterfaceFilePath, MA_ARRAYCOUNT(szInterfaceFilePath), szModuleDirPath, "hshield\\EHsvc.dll"); #else MA_PathMerge(szInterfaceFilePath, MA_ARRAYCOUNT(szInterfaceFilePath), szModuleDirPath, "hshield\\EHsvc.dll"); #endif

If you want to change the HShield folder you have to edit this:

MA_PathMerge(szFullFilePath, MA_ARRAYCOUNT(szFullFilePath), szModuleDirPath, "hshield");

 

 

I don't have any working image or anything to show, I think I can confirm that it should work fine.
       

Edited by Metin2 Dev
Core X - External 2 Internal
  • Metin2 Dev 1
  • Good 3
  • Love 9

Everyday you wake up as a Metin2 developer is a bad day...

METIN1 src when

Link to comment
Share on other sites

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.