/* The main C-source of the nocare patch 

  AUTHOR  Erwin van Breemen & Raymond Hoving,
	The Orega Programming Group Holland.
	P.o.box 499, 2280 AL Rijswijk, The Netherlands.
	Phone 071 - 14 49 71.

  COPYRIGHT NOTES
	NoCare V1.2 is public domain. However, it is not allowed to
	use NoCare V1.2 as part of a commercial product without the
	written permission of the author.
  
  COMPILATION

DevPac:
	GenIm2 nocaresup.asm -Iinclude: -l

Compiler Lattice-C 5.05:
	lc -Lt+nocaresup.o -crs -v nocare


*/

#include <exec/types.h>
#include <exec/libraries.h>
#include <exec/memory.h>
#include <proto/all.h>

#define VERSION 1

struct Resource {
	struct Library ResourceLib;
	APTR	ServiceCall;
	APTR	CleanupCode;
	char	name[30];
	};

struct Resource *resource;
int err;

void do_patch(),undo_patch();


void install_patch()
{
resource=(struct Resource *)AllocMem(sizeof(struct Resource),MEMF_PUBLIC|MEMF_CLEAR);
if (resource==0)
	{
	Write(Output(),"Not enough memory!\n",strlen("Not enough memory!\n"));
	err=1;
	return;
	}
strcpy(resource->name,"windowpatch.resource");
resource->ResourceLib.lib_Node.ln_Type=NT_RESOURCE;
resource->ResourceLib.lib_Node.ln_Name=resource->name;
resource->ResourceLib.lib_Version=VERSION;
resource->ResourceLib.lib_OpenCnt=0;

AddResource(resource);
do_patch();
}

void uninstall_patch()
{
RemResource(resource);
FreeMem(resource,sizeof(struct Resource));
undo_patch();
}



void _main()
{
err=0;
Write(Output(),"Windowpatch V1.2.1\n" ,strlen("Windowpatch V1.2.1\n"));
Write(Output(),"By The Orega Programming Group Holland (c)1991\n",strlen("By The Orega Programming Group Holland (c)1991\n"));

resource=(struct Resource *)OpenResource("windowpatch.resource");
if (resource==0)
	{
	install_patch();
	if (err!=1) 
	Write(Output(),"Window installed!\n",strlen("Window installed!\n"));
	goto out;
	}
uninstall_patch();
Write(Output(),"Window patch removed!\n",strlen("Window patch removed!\n"));
out:
}


