| M E M _ I L O A D S E G ( )
| | | | | SOURCE: qdev_autodocs.txt 1.163 (12/09/2014) English
AMIGA - MEM_#?
----------------------------------------------------------------------------
NAME
mem_iloadseg() - Allows to load executable off of memory.
SYNOPSIS
segs = mem_iloadseg(objptr, objlen);
LONG mem_iloadseg(void *, LONG);
FUNCTION
This function can be very helpful when there is a need to
load/run something that was hexdumped typically without
the need of restoring it on the medium first.
INPUTS
objptr - Pointer to (hexdumped) data.
objlen - Size of that data.
RETURNS
Function returns standard seglist, that can be freed with
OS 'UnLoadSeg()'. NULL will indicate loading error.
BASES
SysBase, DOSBase
NOTES
Dont do 'Forbid()' or 'Disable()' before using this func.
or it will block! Also never put your data on stack!
Follow 'SEE ALSO' to find out why.
SEE ALSO
mem_uniloadseg(), mem_openifh(), mem_closeifh()
EXAMPLE
...
#define datasize 172
static UBYTE databuf[] = {0x00, 0x00, 0x03, 0xF3, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00,
0x00, 0x07, 0x00, 0x00, 0x03, 0xE9, 0x00, 0x00, 0x00, 0x12,
0x48, 0xE7, 0x20, 0x1E, 0x49, 0xF9, 0x00, 0x00, 0x00, 0x00,
0x2A, 0x78, 0x00, 0x04, 0x43, 0xEC, 0x00, 0x00, 0x70, 0x24,
0x2C, 0x4D, 0x4E, 0xAE, 0xFD, 0xD8, 0x26, 0x40, 0x4A, 0x80,
0x67, 0x1A, 0x2C, 0x4B, 0x4E, 0xAE, 0xFF, 0xC4, 0x22, 0x00,
0x41, 0xEC, 0x00, 0x0C, 0x24, 0x08, 0x4E, 0xAE, 0xFE, 0xAA,
0x22, 0x4B, 0x2C, 0x4D, 0x4E, 0xAE, 0xFE, 0x62, 0x70, 0x00,
0x4C, 0xDF, 0x78, 0x04, 0x4E, 0x75, 0x4E, 0x71, 0x4E, 0x75,
0x4E, 0x71, 0x00, 0x00, 0x03, 0xEC, 0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x03, 0xF2, 0x00, 0x00, 0x03, 0xEA,
0x00, 0x00, 0x00, 0x07, 0x64, 0x6F, 0x73, 0x2E, 0x6C, 0x69,
0x62, 0x72, 0x61, 0x72, 0x79, 0x00, 0x48, 0x65, 0x6C, 0x6C,
0x6F, 0x20, 0x77, 0x6F, 0x72, 0x6C, 0x64, 0x21, 0x0A, 0x00,
0x00, 0x00, 0x00, 0x00, 0x03, 0xF2};
...
struct Task *task;
BPTR output;
LONG segs;
output = Open("CONSOLE:", MODE_OLDFILE);
if ((segs = mem_iloadseg(databuf, datasize)) != NULL)
{
task = (struct Task *)CreateNewProcTags(
NP_Seglist , (ULONG)segs,
NP_FreeSeglist, TRUE,
NP_Cli , TRUE,
NP_CommandName, (ULONG)"helloworld",
NP_Name , (ULONG)"mytask",
NP_StackSize , 4096,
NP_Output , output,
NP_CloseOutput, TRUE,
NP_CloseInput , TRUE,
TAG_DONE , NULL);
if (task == NULL)
{
mem_uniloadseg(segs);
}
}
BUGS
None known.
----------------------------------------------------------------------------
| |
| |