2002-09-21 20:59:13 +00:00
|
|
|
#include "stdafx.h"
|
|
|
|
#include "Plugin.h"
|
|
|
|
#include "System.h"
|
|
|
|
#include "Buffers.h"
|
|
|
|
|
2002-10-23 17:53:09 +00:00
|
|
|
PLUGINFUNCTIONSHORT(Alloc)
|
|
|
|
{
|
2002-09-21 20:59:13 +00:00
|
|
|
int size;
|
2002-10-23 17:53:09 +00:00
|
|
|
if ((size = popint()) == 0)
|
2002-09-21 20:59:13 +00:00
|
|
|
{
|
|
|
|
pushint(0);
|
|
|
|
return;
|
|
|
|
}
|
2002-10-23 17:53:09 +00:00
|
|
|
pushint((int) GlobalAlloc(GPTR, size));
|
|
|
|
}
|
2002-09-21 20:59:13 +00:00
|
|
|
PLUGINFUNCTIONEND
|
|
|
|
|
2002-10-23 17:53:09 +00:00
|
|
|
PLUGINFUNCTIONSHORT(Copy)
|
|
|
|
{
|
|
|
|
int size = 0;
|
|
|
|
HANDLE source, dest;
|
|
|
|
char *str;
|
|
|
|
// Get the string
|
|
|
|
if ((str = popstring()) == NULL) return;
|
|
|
|
|
|
|
|
// Check for size option
|
|
|
|
if (str[0] == '/')
|
|
|
|
{
|
|
|
|
size = (int) myatoi(str+1);
|
|
|
|
dest = popint();
|
|
|
|
}
|
|
|
|
else dest = (HANDLE) myatoi(str+1);
|
|
|
|
source = popint();
|
|
|
|
|
|
|
|
// Ok, check the size
|
|
|
|
if (size == 0) size = (int) GlobalSize(source);
|
|
|
|
// and the destinantion
|
|
|
|
if ((int) dest == 0) dest = GlobalAlloc((GPTR), size);
|
|
|
|
|
|
|
|
// COPY!
|
|
|
|
copymem(dest, source, size);
|
|
|
|
|
|
|
|
GlobalFree(str);
|
|
|
|
}
|
2002-09-21 20:59:13 +00:00
|
|
|
PLUGINFUNCTIONEND
|
|
|
|
|
2002-10-23 17:53:09 +00:00
|
|
|
PLUGINFUNCTIONSHORT(Free)
|
|
|
|
{
|
|
|
|
char *str;
|
|
|
|
// Get the string
|
|
|
|
if ((str = popstring()) == NULL) return;
|
|
|
|
// Check for callback clear
|
|
|
|
if (lstrcmpi(str,"/callback") == 0)
|
|
|
|
{
|
|
|
|
SystemProc *proc, *next;
|
|
|
|
next = (SystemProc*) popint();
|
|
|
|
// Clear all the clone queue of callback
|
|
|
|
while ((proc = next) != NULL)
|
2002-09-21 20:59:13 +00:00
|
|
|
{
|
2002-10-23 17:53:09 +00:00
|
|
|
next = proc->Clone;
|
|
|
|
GlobalFree((HANDLE)proc);
|
2002-09-21 20:59:13 +00:00
|
|
|
}
|
2002-10-23 17:53:09 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
GlobalFree((HANDLE) myatoi(str));
|
|
|
|
GlobalFree(str);
|
|
|
|
}
|
|
|
|
PLUGINFUNCTIONEND
|
2002-09-21 20:59:13 +00:00
|
|
|
|
2002-10-23 17:53:09 +00:00
|
|
|
char *copymem(char *output, char *input, int size)
|
|
|
|
{
|
|
|
|
char *out = output;
|
|
|
|
while (size-- > 0) *(out++) = *(input++);
|
|
|
|
return output;
|
|
|
|
}
|
2002-09-21 20:59:13 +00:00
|
|
|
|
|
|
|
HANDLE GlobalCopy(HANDLE Old)
|
|
|
|
{
|
2002-10-23 17:53:09 +00:00
|
|
|
SIZE_T size = GlobalSize(Old);
|
|
|
|
return copymem(GlobalAlloc(GPTR, size), Old, (int) size);
|
2002-09-21 20:59:13 +00:00
|
|
|
}
|