Rev 408 | Rev 536 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 408 | Rev 440 | ||
---|---|---|---|
Line 22... | Line 22... | ||
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){ |
28 | Boolean res = false; |
28 | Boolean res = false; |
29 | Handle h; |
29 | Handle h; |
30 | 30 | ||
31 | if( !(h = Get1Resource(PARM_TYPE,PARM_ID_NEW)) |
31 | if( (h = Get1Resource(PARM_TYPE,PARM_ID_NEW)) || |
32 | && !(h = Get1Resource(PARM_TYPE,PARM_ID_OLD)) |
32 | (h = Get1Resource(PARM_TYPE,PARM_ID_OLD)) ) |
- | 33 | { |
|
- | 34 | HLock(h); |
|
- | 35 | if(GetHandleSize(h) == sizeof(PARM_T)) { |
|
- | 36 | res = readPARM(*h, &gdata->parm, reason, 0 /*Mac format resource*/); |
|
- | 37 | gdata->obfusc = false; |
|
- | 38 | ReleaseResource(h); |
|
- | 39 | } else { |
|
- | 40 | // PARM has wrong size. Should not happen |
|
- | 41 | gdata->obfusc = false; |
|
- | 42 | ReleaseResource(h); |
|
33 | && readobfusc |
43 | return false; |
- | 44 | } |
|
- | 45 | } |
|
34 | && ((h = Get1Resource(OBFUSCDATA_TYPE_NEW,OBFUSCDATA_ID_NEW)) || |
46 | else if( ((h = Get1Resource(OBFUSCDATA_TYPE_NEW,OBFUSCDATA_ID_NEW)) || |
35 | (h = Get1Resource(OBFUSCDATA_TYPE_OLD,OBFUSCDATA_ID_OLD))) ){ |
47 | (h = Get1Resource(OBFUSCDATA_TYPE_OLD,OBFUSCDATA_ID_OLD))) ) |
- | 48 | { |
|
36 | HLock(h); |
49 | HLock(h); |
37 | if(GetHandleSize(h) == sizeof(PARM_T)) { |
50 | if(GetHandleSize(h) == sizeof(PARM_T)) { |
38 | deobfusc((PARM_T*)*h); |
51 | deobfusc((PARM_T*)*h); |
- | 52 | res = readPARM(*h, &gdata->parm, reason, 0 /*Mac format resource*/); |
|
39 | gdata->obfusc = true; |
53 | gdata->obfusc = true; |
- | 54 | ReleaseResource(h); |
|
40 | } else { |
55 | } else { |
41 | // Obfuscated PARM has wrong size. Should not happen |
56 | // Obfuscated PARM has wrong size. Should not happen |
42 | gdata->obfusc = false; |
57 | gdata->obfusc = false; |
43 | ReleaseResource(h); |
58 | ReleaseResource(h); |
44 | return false; |
59 | return false; |
45 | } |
60 | } |
46 | } |
61 | } |
47 | if(h){ |
- | |
48 | HLock(h); |
- | |
49 | res = readPARM(*h, &gdata->parm, reason, 0 /*Mac format resource*/); |
- | |
50 | ReleaseResource(h); |
- | |
51 | gdata->obfusc = false; |
- | |
52 | } |
- | |
53 | if (!res) { |
62 | if (!res) { |
54 | gdata->obfusc = false; |
63 | gdata->obfusc = false; |
55 | } |
64 | } |
56 | return res; |
65 | return res; |
57 | } |
66 | } |
Line 59... | Line 68... | ||
59 | static Boolean readmacplugin(StandardFileReply *sfr,char **reason){ |
68 | static Boolean readmacplugin(StandardFileReply *sfr,char **reason){ |
60 | Boolean res = false; |
69 | Boolean res = false; |
61 | short rrn = FSpOpenResFile(&sfr->sfFile,fsRdPerm); |
70 | short rrn = FSpOpenResFile(&sfr->sfFile,fsRdPerm); |
62 | 71 | ||
63 | if(rrn != -1){ |
72 | if(rrn != -1){ |
64 | if(readPARMresource(NULL,reason,0)) |
73 | if(readPARMresource(NULL,reason)) |
65 | res = true; |
74 | res = true; |
66 | CloseResFile(rrn); |
75 | CloseResFile(rrn); |
67 | }else |
76 | }else |
68 | *reason = "Could not open file."; |
77 | *reason = "Could not open file."; |
69 | return res; |
78 | return res; |
Line 85... | Line 94... | ||
85 | gdata->parmloaded = false; |
94 | gdata->parmloaded = false; |
86 | gdata->obfusc = false; |
95 | gdata->obfusc = false; |
87 | return true; |
96 | return true; |
88 | } |
97 | } |
89 | } |
98 | } |
90 | 99 | ||
91 | // then try "Filters Unlimited" file (FFX) |
100 | // then try "Filters Unlimited" file (FFX) |
92 | if (*reason == NULL) { |
101 | if (*reason == NULL) { |
93 | if (readfile_ffx(sfr,reason)) { |
102 | if (readfile_ffx(sfr,reason)) { |
94 | gdata->parmloaded = true; |
103 | gdata->parmloaded = true; |
95 | gdata->obfusc = false; |
104 | gdata->obfusc = false; |
96 | return true; |
105 | return true; |
97 | } |
106 | } |
98 | } |
107 | } |
99 | 108 | ||
100 | // then try "PluginCommander TXT" file (TXT) |
109 | // then try "PluginCommander TXT" file (TXT) |
101 | if (*reason == NULL) { |
110 | if (*reason == NULL) { |
102 | if (readfile_picotxt(sfr,reason)) { |
111 | if (readfile_picotxt(sfr,reason)) { |
103 | gdata->parmloaded = true; |
112 | gdata->parmloaded = true; |
104 | gdata->obfusc = false; |
113 | gdata->obfusc = false; |
105 | return true; |
114 | return true; |
106 | } |
115 | } |
107 | } |
116 | } |
108 | 117 | ||
109 | // Try Mac plugin resource |
118 | // Try Mac plugin resource |
110 | if (*reason == NULL) { |
119 | if (*reason == NULL) { |
111 | if (readmacplugin(sfr,reason)) { |
120 | if (readmacplugin(sfr,reason)) { |
112 | if (gdata->parm.iProtected) { |
121 | if (gdata->parm.iProtected) { |
113 | *reason = "The filter is protected."; |
122 | *reason = "The filter is protected."; |
Line 115... | Line 124... | ||
115 | gdata->parmloaded = true; |
124 | gdata->parmloaded = true; |
116 | return true; |
125 | return true; |
117 | } |
126 | } |
118 | } |
127 | } |
119 | } |
128 | } |
120 | 129 | ||
121 | // Try Windows resources (we need to do a binary scan) |
130 | // Try Windows resources (we need to do a binary scan) |
122 | // Note that we cannot detect obfuscated filters here! |
131 | // Note that we cannot detect obfuscated filters here! |
123 | if (*reason == NULL) { |
132 | if (*reason == NULL) { |
124 | if (readfile_8bf(sfr,reason)) { |
133 | if (readfile_8bf(sfr,reason)) { |
125 | if (gdata->parm.iProtected) { |
134 | if (gdata->parm.iProtected) { |
Line 131... | Line 140... | ||
131 | } |
140 | } |
132 | } |
141 | } |
133 | 142 | ||
134 | // We didn't had success. If we have a clear reason, return false and the reason. |
143 | // We didn't had success. If we have a clear reason, return false and the reason. |
135 | // If we don't have a clear reason, set a generic reason and return false. |
144 | // If we don't have a clear reason, set a generic reason and return false. |
136 | if (*reason == NULL) { |
145 | if (*reason == NULL) { |
137 | *reason = "It is not a text parameter file, nor a standalone Mac/PC filter created by Filter Factory/Filter Foundry."; |
146 | *reason = "It is not a text parameter file, nor a standalone Mac/PC filter created by Filter Factory/Filter Foundry."; |
138 | } |
147 | } |
139 | return false; |
148 | return false; |
140 | } else { |
149 | } else { |
141 | *reason = "File cannot be opened"; |
150 | *reason = "File cannot be opened"; |