Rev 256 | Rev 271 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 256 | Rev 259 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | /* |
1 | /* |
2 | This file is part of "Filter Foundry", a filter plugin for Adobe Photoshop |
2 | This file is part of "Filter Foundry", a filter plugin for Adobe Photoshop |
3 | Copyright (C) 2003-2009 Toby Thain, toby@telegraphics.com.au |
3 | Copyright (C) 2003-2009 Toby Thain, toby@telegraphics.com.au |
4 | Copyright (C) 2018-2021 Daniel Marschall, ViaThinkSoft |
4 | Copyright (C) 2018-2021 Daniel Marschall, ViaThinkSoft |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify |
6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by |
7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or |
8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. |
9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, |
11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. |
14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License |
16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software |
17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 | */ |
19 | */ |
20 | 20 | ||
21 | #include "ff.h" |
21 | #include "ff.h" |
22 | 22 | ||
23 | #include <Resources.h> |
23 | #include <Resources.h> |
24 | 24 | ||
25 | #include "file_compat.h" |
25 | #include "file_compat.h" |
26 | 26 | ||
27 | Boolean readPARMresource(HMODULE hm,char **reason,int readobfusc){ |
27 | Boolean readPARMresource(HMODULE hm,char **reason,int readobfusc){ |
28 | Boolean res = false; |
28 | Boolean res = false; |
29 | Handle h; |
29 | Handle h; |
30 | 30 | ||
31 | if( !(h = Get1Resource(PARM_TYPE,PARM_ID)) |
31 | if( !(h = Get1Resource(PARM_TYPE,PARM_ID)) |
32 | && readobfusc |
32 | && readobfusc |
33 | && (h = Get1Resource('DATA',OBFUSCDATA_ID)) ){ |
33 | && (h = Get1Resource('DATA',OBFUSCDATA_ID)) ){ |
34 | HLock(h); |
34 | HLock(h); |
35 | deobfusc((unsigned char*)*h,GetHandleSize(h),OBFUSC_SEED_POS); |
35 | deobfusc((unsigned char*)*h,GetHandleSize(h),OBFUSC_SEED_POS); |
36 | gdata->obfusc = true; |
36 | gdata->obfusc = true; |
37 | } |
37 | } |
38 | if(h){ |
38 | if(h){ |
39 | HLock(h); |
39 | HLock(h); |
40 | res = readPARM(*h, &gdata->parm, reason, 0 /*Mac format resource*/); |
40 | res = readPARM(*h, &gdata->parm, reason, 0 /*Mac format resource*/); |
41 | ReleaseResource(h); |
41 | ReleaseResource(h); |
42 | gdata->obfusc = false; |
42 | gdata->obfusc = false; |
43 | } |
43 | } |
44 | if (!res) { |
44 | if (!res) { |
45 | gdata->obfusc = false; |
45 | gdata->obfusc = false; |
46 | } |
46 | } |
47 | return res; |
47 | return res; |
48 | } |
48 | } |
49 | 49 | ||
50 | static Boolean readmacplugin(StandardFileReply *sfr,char **reason){ |
50 | static Boolean readmacplugin(StandardFileReply *sfr,char **reason){ |
51 | Boolean res = false; |
51 | Boolean res = false; |
52 | short rrn = FSpOpenResFile(&sfr->sfFile,fsRdPerm); |
52 | short rrn = FSpOpenResFile(&sfr->sfFile,fsRdPerm); |
53 | 53 | ||
54 | if(rrn != -1){ |
54 | if(rrn != -1){ |
55 | if(readPARMresource(NULL,reason,0)) |
55 | if(readPARMresource(NULL,reason,0)) |
56 | res = true; |
56 | res = true; |
57 | CloseResFile(rrn); |
57 | CloseResFile(rrn); |
58 | }else |
58 | }else |
59 | *reason = "Could not open file."; |
59 | *reason = "Could not open file."; |
60 | return res; |
60 | return res; |
61 | } |
61 | } |
62 | 62 | ||
63 | Boolean loadfile(StandardFileReply *sfr,char **reason){ |
63 | Boolean loadfile(StandardFileReply *sfr,char **reason){ |
64 | Boolean readok = false; |
64 | Boolean readok = false; |
65 | FInfo fndrInfo; |
65 | FInfo fndrInfo; |
66 | 66 | ||
67 | if(FSpGetFInfo(&sfr->sfFile,&fndrInfo) == noErr){ |
67 | if(FSpGetFInfo(&sfr->sfFile,&fndrInfo) == noErr){ |
68 | // first try to read text parameters (AFS, TXT, PFF) |
68 | // first try to read text parameters (AFS, TXT, PFF) |
69 | if( (readok = readfile(sfr,reason)) ) { |
69 | if( (readok = readfile(sfr,reason)) ) { |
70 | gdata->parmloaded = false; |
70 | gdata->parmloaded = false; |
71 | gdata->obfusc = false; |
71 | gdata->obfusc = false; |
72 | // then try plugin formats (Mac first, then Windows .8bf or .prm DLL) |
72 | // then try plugin formats (Mac first, then Windows .8bf or .prm DLL) |
73 | }else if( (readok = readmacplugin(sfr,reason) || read8bfplugin(sfr,reason)) ){ |
73 | }else if( (readok = readmacplugin(sfr,reason) || read8bfplugin(sfr,reason)) ){ |
74 | if ((gdata->parm.cbSize != PARM_SIZE) && (gdata->parm.cbSize != PARM_SIZE_PREMIERE) && (gdata->parm.cbSize != PARM_SIG_MAC)) { |
74 | if ((gdata->parm.cbSize != PARM_SIZE) && (gdata->parm.cbSize != PARM_SIZE_PREMIERE) && (gdata->parm.cbSize != PARM_SIG_MAC)) { |
75 | *reason = "Incompatible obfuscation."; |
75 | *reason = "Incompatible obfuscation."; |
76 | return false; // Stop! We know the issue now. |
76 | return false; // Stop! We know the issue now. |
77 | }else if(gdata->parm.iProtected){ |
77 | }else if(gdata->parm.iProtected){ |
78 | *reason = "The filter is protected."; |
78 | *reason = "The filter is protected."; |
79 | return false; |
79 | return false; |
80 | }else |
80 | }else |
81 | gdata->parmloaded = true; |
81 | gdata->parmloaded = true; |
82 | }else |
82 | }else |
83 | *reason = "It is not a text parameter (AFS) file, nor a standalone Mac/PC filter made by Filter Factory/Filter Foundry."; |
83 | *reason = "It is not a text parameter (AFS) file, nor a standalone Mac/PC filter made by Filter Factory/Filter Foundry."; |
84 | } |
84 | } |
85 | 85 | ||
86 | return readok; |
86 | return readok; |
87 | } |
87 | } |