[Mono-dev] Create a 'MonoImage' from a byte array.

Thiago Padilha tpadilha84 at gmail.com
Wed Jun 16 11:42:18 EDT 2010


  I'm trying to create a MonoImage/MonoAssembly from a byte array like this :


//body omited, this is a simple function that return contents of a
binary file and returns the file size in bytes as an out parameter
static char *read_file_contents(char *fullpath, int *outfilesize);

static MonoImage *get_image(char *data, char *name, char *size)
{
	return  mono_image_open_from_data_with_name (data, size, 0,
MONO_IMAGE_OK, 0, name);
}

MonoAssembly *get_assembly_from_file(char *name)
{	
	int size = 0;


	
	MonoAssembly *ret = NULL;
	MonoImage *image = get_image_from_file(fullpath);
	
	if(image != NULL)
		ret = mono_assembly_load_from_full(image, fullpath, MONO_IMAGE_OK, 0);

	
	free(fullpath);
	return ret;
}


More information about the Mono-devel-list mailing list