Unreal Engine
Unreal Plugin
This document was written to provide an easier application way than the existing SDK application method in Unreal Engine 4, 5 development environment using the plug-in method.
Download & Install Plugin
Here's how to install the Unreal Plugin and configure the project in Unreal Engine 4, 5;
-
Connect to AppGuard Manager server and select Download > Unreal Pluings to download the latest version.
-
There is a folder called /AppGuardSDK in the downloaded
AppGuardUnrealPlugin.zipfile. Copy the AppGuardSDK folder into the Project/Plugins/ path. -
You can install AppGuard SDK in your Unreal project by opening the
APPNAME.Build.csfile in the Project/Source/ProjectName/ path and adding"AppGuardSDK"as shown below.
PublicDependencyModuleNames.AddRange(new string[]
{
"Core", "CoreUObject", "Engine", "InputCore", "AppGuardSDK"
});
AppGuard Config File Download & Setting
-
Connect to AppGuard manager server and select Applying Security > Download > CHAPTER 2. nProtect AppGuard CONFIG file download > CONFIG FILE DOWNLOAD to download.
-
When unzipping the downloaded Config file, the AppGuard Config file consists of four files:
appguard,appguard.crt,appguard.mf, andappguard106000. -
Copy the above 4 files to the path below.
Copy To: Project/Binaries/IOS/Payload/APPNAME.app/
If you have not yet performed an iOS build in the Unreal Editor, Project/Binaries/IOS folder may not exist. In this case, please perform the iOS build once before the above actions.
Apply AppGuardSDK Unreal Plugin
Registering a callback in Delegate and calling the AppGuard initialization function
If a security policy violation is detected when running the app, you must register a callback in Delegate to receive the event through a callback.
Additionally, you must call UAppGuardSDKBlueprintLibrary::Start(); function to initialize AppGuard.
At this time, the calling time of the function must be applied at the first time it is executed when running the app.
#include “AppGuardSDKPlugin.h”
#include “AppGuardSDKBlueprintLibrary.h”
void ASampleProjectGameMode::InitGame(const FString& MapName, const FString& Options, FString& ErrorMessage) {
//. Register callback function for security detection
FAppGuardSDKModule::OnDetected.AddUObject(this, &ASampleProject::OnDetected); // Register callback
//. Register callback function for server-side authentication
FAppGuardSDKModule::OnS2AuthCompleted.AddUObject(this, &ASampleProject::OnS2AuthCompleted);
//. Initializing AppGuard to use AppGuardCore.framework
UAppGuardSDKBlueprintLibrary::Start();
}
/* Sample callback function for security detection */
void ASampleProjectGameMode::OnDetected (int data) {
bool killed = data > 0;
int code = data > 0 ? data : data * -1;
/*
If the value of Data is positive, Appguard terminates after 30 seconds.
You must use the sample code below to display it on the screen that will be exposed to the user.
*/
if (killed) {
//. Notifies the user that the game is ending by exposing an termination notification window.
//. The termination notification window must be configured to terminate the app when the OK button is clicked.
}
}
/* Sample callback function for server-side authentication */
void ASampleProjectGameMode::OnS2AuthCompleted (int value, FString data) {
//. Please refer to the [Apply Server-side Authentication] step for the implementation of the callback function for server authentication.
}
When releasing the actual service, please be sure to remove the log output function in the security detection callback function and server authentication callback function above.
UserID Setting
AppGuard provide SetUserId() method to send User ID to the log server when a policy violation is detected.
As shown in the sample code below, you can use the actual user ID of the session in the userID part by passing it as data in FString format.
#include “AppGuardSDKPlugin.h”
#include “AppGuardSDKBlueprintLibrary.h”
UAppGuardSDKBlueprintLibrary::SetUserId(TEXT("userID"));
Apply Server-side Authentication (Optional)
This content is required when using server-side authentication, and the content below is irrelevant when server-side authentication is not used.
Implementing a callback function for server-side authentication
Callback function for server-side authentication is passed through OnS2AuthCompleted() callback method written at Registering a callback in Delegate and calling the AppGuard initialization function.
As shown in the sample code below, you can check the server authentication status result through the OnS2AuthCompleted() callback method.
#include “AppGuardSDKPlugin.h”
#include “AppGuardSDKBlueprintLibrary.h”
// Sample of callback function for server-side authentication
void ASampleProjectGameMode::OnS2AuthCompleted (int value, FString data)
{
switch (value)
{
case AppGuardEventType::S2Auth::S2AUTH_RESULT_SUCCESS:
/*
Server-side authentication was successful, and authentication was completed normally.
*/
break;
case AppGuardEventType::S2Auth::S2AUTH_RESULT_RETRY:
/*
Server-side authentication failed and retry to authenticate will be attempted.
This may be a temporary client network failure or server failure, and the retry may take up to 3 minutes depending on internal mechanisms.
*/
break;
case AppGuardEventType::S2Auth::S2AUTH_RESULT_FAIL:
/*
Server-side authentication has completely failed, and no further server-side authentication attempts will be made.
*/
break;
}
}
As shown in Starting Server-side Authentication below,
if you call the UAppGuardSDKBlueprintLibrary::SetUniqueClientId() method,
AppGuard security module will perform server-side authentication from that point on, and three status codes will be passed to the callback method as illustrated in the sample code above.
When releasing the actual service, please be sure to remove the log output function in the server-side authentication callback function above.
Starting Server-side Authentication
To start server-side authentication on the client, you can use the UniqueClientID for the user's session received from the server using the method below, as shown in the sample code below.
#include “AppGuardSDKPlugin.h”
#include “AppGuardSDKBlueprintLibrary.h”
UAppGuardSDKBlueprintLibrary::SetUniqueClientId(TEXT("Formatted-Unique-Client-Id", 180));
Please refer to [Main API] for the rules and creation method of Formatted-Unique-Client-Id given as the first argument of the above function.