illustrate plug-in -- AI plug-in -- Prepress plug-in -- CADTools -- export table analysis -- interface detection

  this article is a section of a series of articles. Readers in need can go to the previous chapter if they encounter sudden symbols and terms.

1. Export table

   the illustrate plug-in is essentially a dynamic link library. In addition to the import table, there are naturally export tables for the host software to call. Here, you can open it with ida and go to the export table to see it. As shown in the figure below:

   it can be seen that there are three export functions: PluginMain, plug-in entry function and DllEntryPoint entry point function. From the illustrator SDK, we found the calling form of the entry point function PluginMain, as follows:

extern "C" ASAPI ASErr PluginMain(char* caller, char* selector, void* message)
{
	ASErr error = kNoErr;
	SPMessageData *msgData = (SPMessageData *)message;
	
	Plugin *plugin = (Plugin *)msgData->globals;
	
	sSPBasic = msgData->basic;
	
	if (strcmp(caller, kSPInterfaceCaller) == 0) 
	{	
		if (strcmp( selector, kSPInterfaceStartupSelector) == 0)
		{
			plugin = AllocatePlugin(msgData->self);
			if (plugin)
			{
				msgData->globals = (void *)plugin;
				error = plugin->StartupPlugin((SPInterfaceMessage *)message);

				if (error != kNoErr)
				{
					// Make sure to delete in case startup failed
					delete plugin;
					plugin = nil;
					msgData->globals = nil;
				}
			}
			else
			{
				error = kOutOfMemoryErr;
			}
		}
		else if (strcmp(selector, kSPInterfaceShutdownSelector) == 0)
		{
			if (plugin)
			{
				error = plugin->ShutdownPlugin((SPInterfaceMessage *)message);				
				delete plugin;
				plugin = nil;
				msgData->globals = nil;
			}
		}
	}
	
	if (plugin)
	{
		if (Plugin::IsReloadMsg(caller, selector))
		{
			// Call this before calling any virtual functions (like Message)
			FixupReload(plugin);
			error = plugin->ReloadPlugin((SPInterfaceMessage *)message);
		}
		else
		{
			// If a load or reload failed because the suites could not be acquired, we released
			// any partially acquired suites and returned an error.  However, SuitePea still might
			// call us, so protect against this situation.
			if (plugin->SuitesAcquired())
				error = plugin->Message(caller, selector, message);
			else
				error = kNoErr;
		}

		if (error == kUnhandledMsgErr)
		{
			error = kNoErr;
#ifndef NDEBUG
#ifdef MAC_ENV
			fprintf(stderr, "Warning: Unhandled plugin message: caller \"%s\" selector \"%s\"\n", caller, selector);
#else
			char buf[1024];
			
			sprintf(buf+1, "Warning: Unhandled plugin message: caller \"%s\" selector \"%s\"\n", caller, selector);
			OutputDebugStringA(buf+1);
#endif
#endif
		}
	}	

	if (error)
	{
		if (plugin)
			plugin->ReportError(error, caller, selector, message);
		else
			Plugin::DefaultError(msgData->self, error);
	}
	
	return error;
}

   this function consists of three parameters, one is the caller name, one is the selector selection string, and the last is the information carried by the message. It is the interface with the host software call plug-in.

2. Interface detection

   the interface includes native window interface and DirectUI drawing interface. Test it with spy + +, as shown in the figure below:

   select the icon indicated by the arrow, and then move it on the CAD interface (left), and the corresponding reference information will appear on the right. The description is drawn with windows native window handle.

  next, analyze the implementation of the specific functions of CADTools.

  reasonable script code can effectively improve work efficiency and reduce repetitive work.

   welcome to Zhiyou software development network platform. Our company develops all kinds of customized software, mainly focusing on desktop professional software development and plug-in customization development. Desktop software mainly includes text and graphics recognition software, information management software, 3D printing software, video software and other professional graphics and image processing software. The plug-ins include AE plug-ins, AI plug-ins, PS plug-ins, PDF plug-ins, 3DMAX plug-ins and Office plug-ins such as Word and Excel. For details, please consult wechat QQ:312117271, mobile phone: 18928899728. Company website: http://www.zhiliaos.com

Added by freeme on Mon, 21 Feb 2022 03:48:59 +0200