This page explains how to integrate Receigen with a .NET application running on Mono. Note that this guide only covers the initial Receipt Validation.
The integration is similar to the standard embedding. Here is a sample code for the integration:
#include <stdlib.h>
#include <zlib.h>
#include <mono/metadata/assembly.h>
// Receigen inclusion
#define RUNNER mono_main // <= This is the function called when validation succeeds
#include "receipt.h" // <= Receigen generated code
// Symbols for assemblies
extern const unsigned char mscorlib_dll[];
extern const unsigned char System_Configuration_dll[];
extern const unsigned char System_Core_dll[];
extern const unsigned char System_dll[];
extern const unsigned char System_Security_dll[];
extern const unsigned char System_Xml_dll[];
extern const unsigned char MyApplication.exe[];
// Symbol for machine configuration
extern const char machine_config[];
// Bundle for assemblies
static MonoBundledAssembly bundle_mscorlib_dll = { "mscorlib.dll", mscorlib_dll, 2938880 };
static MonoBundledAssembly bundle_System_Configuration_dll = { "System.Configuration.dll", System_Configuration_dll, 127488 };
static MonoBundledAssembly bundle_System_Core_dll = { "System.Core.dll", System_Core_dll, 738816 };
static MonoBundledAssembly bundle_System_dll = { "System.dll", System_dll, 1734144, };
static MonoBundledAssembly bundle_System_Security_dll = { "System.Security.dll", System_Security_dll, 132096 };
static MonoBundledAssembly bundle_System_Xml_dll = { "System.Xml.dll", System_Xml_dll, 1303040 };
static MonoBundledAssemblyExt bundle_MyApplication_exe = { "MyApplication.exe", MyApplication_exe, 69120 };
static char *image_name = "MyApplication.exe";
int main(int argc, char* argv[]) {
int i;
MonoBundledAssembly *bundled[8];
bundled[0] = &bundle_mscorlib_dll;
bundled[1] = &bundle_System_Configuration_dll;
bundled[2] = &bundle_System_Core_dll;
bundled[3] = &bundle_System_dll;
bundled[4] = &bundle_System_Security_dll;
bundled[5] = &bundle_System_Xml_dll;
bundled[6] = &bundle_MyApplication_exe;
bundled[7] = NULL;
// Shift the arguments to include the image name
char **newargs = (char **) malloc (sizeof(char *) * (argc + 2));
newargs [0] = argv[0];
newargs [1] = image_name;
for(i = 1; i < argc; i++) {
newargs[i+1] = argv [i];
}
newargs[++i] = NULL;
// Registers the configurations and the assemblies
mono_register_machine_config(machine_config);
mono_register_bundled_assemblies((const MonoBundledAssembly **) bundled);
// Invoke the Mono runtime
return CheckReceiptAndRun(argc + 1, newargs);
}