I've spent quite some time trying to track down a problem with Photoshop
plugins built for Windows. (I am running Metrowerks CodeWarrior 7 in OS
X and testing with VirtualPC 5.)
I have source to plugins which build and run perfectly under MacOS, and
build for Win32 with CW7. On invoking the plugin in Photoshop 5.0.2 for
Windows (tested on both VPC and a real PC), the plugin is entered and
exited several times as expected, after which an invalid page fault
invariably occurs in Photoshop. I have created a simple test case for
this problem and fruitlessly combed its code for bugs which might cause
this. My conclusion is that build settings are probably at fault, my
test case has a bug (the same trivial code runs perfectly under MacOS
though), or Photoshop 5.0 has a bug - I've not yet been able to test
with other versions.
Can anyone provide a complete working example of a CW7 Photoshop/Windows
plugin project?
N.B. I have read *in detail* the PS SDK docs, the sample code, and the
rare plugin sources available on the web, none of which has helped solve
this. Also, it's probably not a CodeWarrior specific problem; building
the same plugin with mingw (free GNU-based Win32 development toolset,
http://www.mingw.org/ ) produces the same result.
regards
Toby
> Hi,
>
> I've spent quite some time trying to track down a problem with Photoshop
> plugins built for Windows. (I am running Metrowerks CodeWarrior 7 in OS
> X and testing with VirtualPC 5.)
> ...
> On invoking the plugin in Photoshop 5.0.2 for
> Windows (tested on both VPC and a real PC), the plugin is entered and
> exited several times as expected, after which an invalid page fault
> invariably occurs in Photoshop. I have created a simple test case for
> this problem
The problem was due to my *mistaken* use of stdcall calling conventions
on the main function. It must NOT use stdcall! (I'm not sure where I got
the silly idea.) After removing this directive, and rebuilding, my test
plugin runs perfectly.
As a penance to USENET for this faux pas, I've published source code to
an minimal example plugin that builds with mingw* (a Photoshop SDK is
also required, this can be found on a pre-7.0 Photoshop CD):
http://www.telegraphics.com.au/sw/exporttest.zip
Toby
* mingw is a *free* toolset to build plugins - or anything - for Win32
(see http://www.mingw.org/ ). You can download Win32 binaries from
http://sourceforge.net/project/showfiles.php?group_id=2435 , or sources
which can be used to set up a Win32 cross-development environment for
Linux or UNIX.
--marc
What kind of plug-in are you writing?
Tony G. Smith
Vizros - Real 3D page-curl plug-ins and more
Demo at http://www.vizros.com/vphelp/vpgallery.html
Thanks for the suggestion. Looks like my follow-up missed this group;
the problem turned out to be function calling conventions. I had
spuriously modified the entry point to use stdcall, where in fact
default Win32 calling conventions are called for.
Re: alignment,
The Photoshop APIs seem to be smothered in enough alignment-setting
pragmae to prevent this issue (even with Metrowerks). Nevertheless, I
did check structure field offsets under different alignment settings
(CodeWarrior offers 1,2,4,8,16 byte alignment) and they were always
the same, so I ruled this out as the cause.
Toby