Skip to main content
Inspiring
July 22, 2021
Answered

Plugin development: How to use the buffer suite?

  • July 22, 2021
  • 1 reply
  • 347 views

Hello,

 

I am developing a Photoshop Filter plugin and I try to figure out how to update the deprecated buffer procs (gFilterRecord->bufferProcs) to the non-deprecated buffer suite.

 

I made a small test plugin, but it doesn't work as expected.

What am I doing wrong?

 

DLLEXPORT MACPASCAL
void ENTRYPOINT(short selector, FilterRecordPtr pb, intptr_t *data, short *result){
......

	if (selector != filterSelectorAbout) {
		char* xx = (char*)malloc(200);

		// ======== 32 Bit ========
		PSBufferSuite1* gPSBufferSuite32 = NULL;
		if (pb->sSPBasic->AcquireSuite(kPSBufferSuite, kPSBufferSuiteVersion1, (const void**)&gPSBufferSuite32)) {
			simplealert("no buffer suite 32"); // does not happen in Photoshop 7 and Photoshop CS 2
			*result = errPlugInHostInsufficient;
			return;
		}
		// Photoshop 7   on a 16GB system => 844,238,416 = 805 MiB?!
		// Photoshop CS2 on a 16GB system => 1,600,846,272 = 1.53 GiB
		unsigned32 free32 = gPSBufferSuite32->GetSpace();
		sprintf(xx, "Space32 = %u", free32); simplealert(xx);
		pb->sSPBasic->ReleaseSuite(kPSBufferSuite, kPSBufferSuiteVersion1);

		// ======== 64 Bit ========
		PSBufferSuite2* gPSBufferSuite64 = NULL;
		if (pb->sSPBasic->AcquireSuite(kPSBufferSuite, kPSBufferSuiteVersion2, (const void**)&gPSBufferSuite64)) {
			simplealert("no buffer suite 64"); // does not happen in Photoshop 7 and Photoshop CS 2
			*result = errPlugInHostInsufficient;
			return;
		}
		// Photoshop 7 on a 16GB system => 19,216,129 = 18 MiB?!
		// Photoshop CS2 => Crash
		unsigned64 free64 = gPSBufferSuite64->GetSpace();
		sprintf(xx, "Space64 = %llu", free64); simplealert(xx);
		pb->sSPBasic->ReleaseSuite(kPSBufferSuite, kPSBufferSuiteVersion2);
	}

...........................

The 64 bit suite crashes with Photoshop CS2, and outputs a very low value on Photoshop 7.

I wonder why CS2/7 have the 64 bit suites at all, since they are 32 bit apps.

 

The SDK does not state the Unit-Of-Measure for the Space methods. I guess the result is measured in bytes?

 

 Thank you for your help!

 

This topic has been closed for replies.
Correct answer dracenmarx

I don't have experience with plugins, all the more wrote in non extendscript language, but I used to work with CS2 and once looked into CS documentation. There's very smart r-bin who played with old Photoshops, but I doubt it's a problem he can solve. Anyway let's see if he'll be willing to say anything 😉

 

Ps. Say which SDK files and docs paragraphs may be helpful to localize the problem 🙂

 

btw. are you trying to understand how modern Photoshop works by tinkering in old releases which were I guess much less complex to get to know how they were programmed?


Thank you for your reply.

 

Backwards compatibility is very important for me, so the plugins I develop are compatible with Windows 95 through Windows 10 and Photoshop 3.0 through Photoshop CC2019.

 

(Actually, at home I work with Photoshop 7, because it has all functionality I need, and I want a product that I can buy and own. I dislike the renting model of CC. If it was for purchase, I would have bought it someday.)

 

Anway, I found the issue! 🙂

It is actually a bug in these old versions of Photoshop:

Windows Photoshop 7 and CS 2 accepts kPSBufferSuiteVersion2, but doesn't correctly implement it:
The symbols "New" and "GetSpace64" point to memory memory addresses outside the Photoshop.exe address range. (Other Photoshop versions were not tested.)
64-bit support for Windows was established in Photoshop CS 4, and PSBufferSuite2 was first documented in SDK CS 6. So, kPSBufferSuiteVersion2 probably was partically implemented as hidden "Work in progress" version before it was publicly documented.
Side note: pb->bufferSpace64/pb->maxSpace64 was documented in SDK CC 2017.
pb->bufferProcs->allocateProc64/spaceProc64 was documented in SDK CS 6.

1 reply

Kukurykus
Legend
July 22, 2021

May you link us to documentation you use?

Inspiring
July 22, 2021

Hello,

I am referring to the document "photoshop_sdk/pluginsdk/documentation/html/group___pica_buffer_suite.html" of the Adobe Photoshop SDK CC2017 (Adobe Photoshop SDK)

Kukurykus
Legend
July 22, 2021

I don't have experience with plugins, all the more wrote in non extendscript language, but I used to work with CS2 and once looked into CS documentation. There's very smart r-bin who played with old Photoshops, but I doubt it's a problem he can solve. Anyway let's see if he'll be willing to say anything 😉

 

Ps. Say which SDK files and docs paragraphs may be helpful to localize the problem 🙂

 

btw. are you trying to understand how modern Photoshop works by tinkering in old releases which were I guess much less complex to get to know how they were programmed?