Skip to content

Instantly share code, notes, and snippets.

@duncanmak
Created November 21, 2012 16:19
Show Gist options
  • Save duncanmak/4125780 to your computer and use it in GitHub Desktop.
Save duncanmak/4125780 to your computer and use it in GitHub Desktop.
/* This source code was produced by mkbundle, do not edit */
#include <mono/metadata/assembly.h>
typedef struct _compressed_data {
MonoBundledAssembly assembly;
int compressed_size;
} CompressedAssembly;
extern const unsigned char assembly_data_license_check_win_exe [];
static CompressedAssembly assembly_bundle_license_check_win_exe = {{"license-check-win.exe", assembly_data_license_check_win_exe, 28672}, 13872};
extern const unsigned char assembly_data_mscorlib_dll [];
static CompressedAssembly assembly_bundle_mscorlib_dll = {{"mscorlib.dll", assembly_data_mscorlib_dll, 2861568}, 1000929};
extern const unsigned char assembly_data_Mono_Touch_Common_dll [];
static CompressedAssembly assembly_bundle_Mono_Touch_Common_dll = {{"Mono.Touch.Common.dll", assembly_data_Mono_Touch_Common_dll, 13824}, 5581};
extern const unsigned char assembly_data_System_dll [];
static CompressedAssembly assembly_bundle_System_dll = {{"System.dll", assembly_data_System_dll, 1744384}, 654175};
extern const unsigned char assembly_data_Mono_Security_dll [];
static CompressedAssembly assembly_bundle_Mono_Security_dll = {{"Mono.Security.dll", assembly_data_Mono_Security_dll, 291840}, 117119};
extern const unsigned char assembly_data_System_Configuration_dll [];
static CompressedAssembly assembly_bundle_System_Configuration_dll = {{"System.Configuration.dll", assembly_data_System_Configuration_dll, 123904}, 49819};
extern const unsigned char assembly_data_System_Xml_dll [];
static CompressedAssembly assembly_bundle_System_Xml_dll = {{"System.Xml.dll", assembly_data_System_Xml_dll, 1267712}, 431053};
extern const unsigned char assembly_data_System_Security_dll [];
static CompressedAssembly assembly_bundle_System_Security_dll = {{"System.Security.dll", assembly_data_System_Security_dll, 133120}, 52276};
extern const unsigned char assembly_data_Mono_Touch_Client_dll [];
static CompressedAssembly assembly_bundle_Mono_Touch_Client_dll = {{"Mono.Touch.Client.dll", assembly_data_Mono_Touch_Client_dll, 14336}, 5052};
extern const unsigned char assembly_data_System_Web_Services_dll [];
static CompressedAssembly assembly_bundle_System_Web_Services_dll = {{"System.Web.Services.dll", assembly_data_System_Web_Services_dll, 350720}, 122494};
extern const unsigned char assembly_data_System_EnterpriseServices_dll [];
static CompressedAssembly assembly_bundle_System_EnterpriseServices_dll = {{"System.EnterpriseServices.dll", assembly_data_System_EnterpriseServices_dll, 47104}, 18170};
extern const unsigned char assembly_data_System_Transactions_dll [];
static CompressedAssembly assembly_bundle_System_Transactions_dll = {{"System.Transactions.dll", assembly_data_System_Transactions_dll, 31232}, 11912};
extern const unsigned char assembly_data_System_Web_dll [];
static CompressedAssembly assembly_bundle_System_Web_dll = {{"System.Web.dll", assembly_data_System_Web_dll, 2409984}, 834723};
extern const unsigned char assembly_data_System_Drawing_dll [];
static CompressedAssembly assembly_bundle_System_Drawing_dll = {{"System.Drawing.dll", assembly_data_System_Drawing_dll, 444928}, 157490};
extern const unsigned char assembly_data_System_Core_dll [];
static CompressedAssembly assembly_bundle_System_Core_dll = {{"System.Core.dll", assembly_data_System_Core_dll, 794112}, 271330};
extern const unsigned char assembly_data_Mono_Posix_dll [];
static CompressedAssembly assembly_bundle_Mono_Posix_dll = {{"Mono.Posix.dll", assembly_data_Mono_Posix_dll, 187392}, 74985};
extern const unsigned char assembly_data_System_Data_dll [];
static CompressedAssembly assembly_bundle_System_Data_dll = {{"System.Data.dll", assembly_data_System_Data_dll, 851456}, 299439};
extern const unsigned char assembly_data_Mono_Data_Tds_dll [];
static CompressedAssembly assembly_bundle_Mono_Data_Tds_dll = {{"Mono.Data.Tds.dll", assembly_data_Mono_Data_Tds_dll, 98304}, 37808};
extern const unsigned char assembly_data_System_Web_ApplicationServices_dll [];
static CompressedAssembly assembly_bundle_System_Web_ApplicationServices_dll = {{"System.Web.ApplicationServices.dll", assembly_data_System_Web_ApplicationServices_dll, 27136}, 10428};
extern const unsigned char assembly_data_Mono_Web_dll [];
static CompressedAssembly assembly_bundle_Mono_Web_dll = {{"Mono.Web.dll", assembly_data_Mono_Web_dll, 20992}, 7717};
extern const unsigned char assembly_data_Mono_Data_Sqlite_dll [];
static CompressedAssembly assembly_bundle_Mono_Data_Sqlite_dll = {{"Mono.Data.Sqlite.dll", assembly_data_Mono_Data_Sqlite_dll, 169472}, 53429};
extern const unsigned char assembly_data_System_Xml_Linq_dll [];
static CompressedAssembly assembly_bundle_System_Xml_Linq_dll = {{"System.Xml.Linq.dll", assembly_data_System_Xml_Linq_dll, 107520}, 39825};
extern const unsigned char machine_config;
static const CompressedAssembly *compressed [] = {
&assembly_bundle_license_check_win_exe,
&assembly_bundle_mscorlib_dll,
&assembly_bundle_Mono_Touch_Common_dll,
&assembly_bundle_System_dll,
&assembly_bundle_Mono_Security_dll,
&assembly_bundle_System_Configuration_dll,
&assembly_bundle_System_Xml_dll,
&assembly_bundle_System_Security_dll,
&assembly_bundle_Mono_Touch_Client_dll,
&assembly_bundle_System_Web_Services_dll,
&assembly_bundle_System_EnterpriseServices_dll,
&assembly_bundle_System_Transactions_dll,
&assembly_bundle_System_Web_dll,
&assembly_bundle_System_Drawing_dll,
&assembly_bundle_System_Core_dll,
&assembly_bundle_Mono_Posix_dll,
&assembly_bundle_System_Data_dll,
&assembly_bundle_Mono_Data_Tds_dll,
&assembly_bundle_System_Web_ApplicationServices_dll,
&assembly_bundle_Mono_Web_dll,
&assembly_bundle_Mono_Data_Sqlite_dll,
&assembly_bundle_System_Xml_Linq_dll,
NULL
};
static char *image_name = "license-check-win.exe";
static void install_dll_config_files (void) {
mono_register_machine_config (&machine_config);
}
static const char *config_dir = NULL;
static MonoBundledAssembly **bundled;
#include <stdlib.h>
#include <string.h>
#include <zlib.h>
static int
my_inflate (const Byte *compr, uLong compr_len, Byte *uncompr, uLong uncompr_len)
{
int err;
z_stream stream;
memset (&stream, 0, sizeof (z_stream));
stream.next_in = (Byte *) compr;
stream.avail_in = (uInt) compr_len;
err = inflateInit (&stream);
if (err != Z_OK)
return 1;
for (;;) {
stream.next_out = uncompr;
stream.avail_out = (uInt) uncompr_len;
err = inflate (&stream, Z_NO_FLUSH);
if (err == Z_STREAM_END) break;
if (err != Z_OK) {
printf ("%d\n", err);
return 2;
}
}
err = inflateEnd (&stream);
if (err != Z_OK)
return 3;
if (stream.total_out != uncompr_len)
return 4;
return 0;
}
void mono_mkbundle_init ()
{
CompressedAssembly **ptr;
MonoBundledAssembly **bundled_ptr;
Bytef *buffer;
int nbundles;
install_dll_config_files ();
ptr = (CompressedAssembly **) compressed;
nbundles = 0;
while (*ptr++ != NULL)
nbundles++;
bundled = (MonoBundledAssembly **) malloc (sizeof (MonoBundledAssembly *) * (nbundles + 1));
bundled_ptr = bundled;
ptr = (CompressedAssembly **) compressed;
while (*ptr != NULL) {
uLong real_size;
uLongf zsize;
int result;
MonoBundledAssembly *current;
real_size = (*ptr)->assembly.size;
zsize = (*ptr)->compressed_size;
buffer = (Bytef *) malloc (real_size);
result = my_inflate ((*ptr)->assembly.data, zsize, buffer, real_size);
if (result != 0) {
fprintf (stderr, "Error %d decompresing data for %s\n", result, (*ptr)->assembly.name);
exit (1);
}
(*ptr)->assembly.data = buffer;
current = (MonoBundledAssembly *) malloc (sizeof (MonoBundledAssembly));
memcpy (current, *ptr, sizeof (MonoBundledAssembly));
current->name = (*ptr)->assembly.name;
*bundled_ptr = current;
bundled_ptr++;
ptr++;
}
*bundled_ptr = NULL;
mono_register_bundled_assemblies((const MonoBundledAssembly **) bundled);
}
int mono_main (int argc, char* argv[]);
#include <stdlib.h>
#include <string.h>
#ifdef _WIN32
#include <windows.h>
#include <stdio.h>
#include <wchar.h>
#endif
static char **mono_options = NULL;
static int count_mono_options_args (void)
{
const char *e = getenv ("MONO_BUNDLED_OPTIONS");
const char *p, *q;
int i, n;
if (e == NULL)
return 0;
/* Don't bother with any quoting here. It is unlikely one would
* want to pass options containing spaces anyway.
*/
p = e;
n = 1;
while ((q = strchr (p, ' ')) != NULL) {
n++;
p = q + 1;
}
mono_options = malloc (sizeof (char *) * (n + 1));
p = e;
i = 0;
while ((q = strchr (p, ' ')) != NULL) {
mono_options[i] = malloc ((q - p) + 1);
memcpy (mono_options[i], p, q - p);
mono_options[i][q - p] = '\0';
i++;
p = q + 1;
}
mono_options[i++] = strdup (p);
mono_options[i] = NULL;
return n;
}
#ifdef _WIN32
char *utf16_to_utf8 (wchar_t *utf16)
{
size_t req = WideCharToMultiByte (CP_UTF8, 0, utf16, -1, NULL, 0, NULL, NULL);
char *utf8 = (char *) malloc (req);
WideCharToMultiByte (CP_UTF8, 0, utf16, -1, utf8, wcslen (utf16), NULL, NULL);
utf8 [req - 1] = 0;
return utf8;
}
#endif
int
mono_bundle_init (void)
{
int dw;
__asm (" \
mov %%fs:0x18, %%eax; \
mov 0x30(%%eax), %%eax; \
mov (%%eax), %0;"
:
: "r" (dw)
: "eax");
return (dw & 0x00010000) != 0;
}
int main (int argc, char* argv[])
{
char **newargs;
int i, k = 0;
#ifdef _WIN32
/* CommandLineToArgvW() might return a different argc than the
* one passed to main(), so let it overwrite that, as we won't
* use argv[] on Windows anyway.
*/
wchar_t **wargv = CommandLineToArgvW (GetCommandLineW (), &argc);
#endif
newargs = (char **) malloc (sizeof (char *) * (argc + 2) + count_mono_options_args ());
#ifdef _WIN32
newargs [k++] = utf16_to_utf8 (wargv [0]);
#else
newargs [k++] = argv [0];
#endif
if (mono_options != NULL) {
i = 0;
while (mono_options[i] != NULL)
newargs[k++] = mono_options[i++];
}
newargs [k++] = image_name;
for (i = 1; i < argc; i++) {
#ifdef _WIN32
newargs [k++] = utf16_to_utf8 (wargv [i]);
#else
newargs [k++] = argv [i];
#endif
}
#ifdef _WIN32
LocalFree (wargv);
#endif
newargs [k] = NULL;
if (config_dir != NULL && getenv ("MONO_CFG_DIR") == NULL)
mono_set_dirs (getenv ("MONO_PATH"), config_dir);
mono_mkbundle_init();
if (mono_bundle_init ())
return 231;
return mono_main (k, newargs);
}
@pjbeaman
Copy link

gcc -mno-cygwin -o license-check.exe -Wall pkg-config --cflags mono-2|dos2unix temp.c pkg-config --libs-only-L mono-2|dos2unix -Wl,-Bstatic -lmono-2.0 -Wl,-Bdynamic -lws2_32 -lwsock32 -liphlpapi pkg-config --libs-only-l mono-2 | sed -e "s/\-lmono-2.0 //"|dos2unix temp.o tools/scripts/libz-win32.a -Itools/scripts/include-win32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment