Rev 456 | Rev 496 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 456 | Rev 492 | ||
---|---|---|---|
Line 36... | Line 36... | ||
36 | return false; // we only want the first one |
36 | return false; // we only want the first one |
37 | } |
37 | } |
38 | else return true; |
38 | else return true; |
39 | } |
39 | } |
40 | 40 | ||
41 | Boolean readPARMresource(HMODULE hm, char** reason) { |
41 | Boolean readPARMresource(HMODULE hm, TCHAR** reason) { |
42 | HRSRC resinfo; |
42 | HRSRC resinfo; |
43 | HANDLE h; |
43 | HANDLE h; |
44 | Ptr pparm; |
44 | Ptr pparm; |
45 | 45 | ||
46 | UINT16 parm_id = 1; |
46 | UINT16 parm_id = 1; |
Line 67... | Line 67... | ||
67 | if (!copy) return false; |
67 | if (!copy) return false; |
68 | memcpy(copy, pparm, resSize); |
68 | memcpy(copy, pparm, resSize); |
69 | deobfusc(copy); |
69 | deobfusc(copy); |
70 | res = readPARM(&gdata->parm, (Ptr)copy); |
70 | res = readPARM(&gdata->parm, (Ptr)copy); |
71 | if (!res) { |
71 | if (!res) { |
72 | *reason = _strdup("Incompatible obfuscation."); |
72 | *reason = FF_GetMsg_Cpy(MSG_INCOMPATIBLE_OBFUSCATION_ID); |
73 | } |
73 | } |
74 | free(copy); |
74 | free(copy); |
75 | gdata->obfusc = true; |
75 | gdata->obfusc = true; |
76 | return res; |
76 | return res; |
77 | } |
77 | } |
Line 83... | Line 83... | ||
83 | } |
83 | } |
84 | } |
84 | } |
85 | return false; |
85 | return false; |
86 | } |
86 | } |
87 | 87 | ||
88 | Boolean loadfile(StandardFileReply* sfr, char** reason) { |
88 | Boolean loadfile(StandardFileReply* sfr, TCHAR** reason) { |
89 | HMODULE hm; |
89 | HMODULE hm; |
90 | 90 | ||
91 | // The different read-functions will return true if the resource was successfully loaded, |
91 | // The different read-functions will return true if the resource was successfully loaded, |
92 | // or false otherwise. If *reason is set, then the answer is clearly "No". If the result |
92 | // or false otherwise. If *reason is set, then the answer is clearly "No". If the result |
93 | // is just false, it means that the program should continue with the next read-function. |
93 | // is just false, it means that the program should continue with the next read-function. |
Line 105... | Line 105... | ||
105 | // If that didn't work, try to load as Windows image file (Resource API for 8BF/PRM files) |
105 | // If that didn't work, try to load as Windows image file (Resource API for 8BF/PRM files) |
106 | if (*reason == NULL) { |
106 | if (*reason == NULL) { |
107 | if (hm = LoadLibraryEx(sfr->sfFile.szName, NULL, LOAD_LIBRARY_AS_DATAFILE)) { |
107 | if (hm = LoadLibraryEx(sfr->sfFile.szName, NULL, LOAD_LIBRARY_AS_DATAFILE)) { |
108 | if (readPARMresource(hm, reason)) { |
108 | if (readPARMresource(hm, reason)) { |
109 | if (gdata->parm.iProtected) { |
109 | if (gdata->parm.iProtected) { |
110 | *reason = _strdup("The filter is protected."); |
110 | *reason = FF_GetMsg_Cpy(MSG_FILTER_PROTECTED_ID); |
111 | //gdata->parmloaded = false; |
111 | //gdata->parmloaded = false; |
112 | } |
112 | } |
113 | else { |
113 | else { |
114 | gdata->parmloaded = true; |
114 | gdata->parmloaded = true; |
115 | FreeLibrary(hm); |
115 | FreeLibrary(hm); |
Line 140... | Line 140... | ||
140 | // Note that we cannot detect obfuscated filters here! |
140 | // Note that we cannot detect obfuscated filters here! |
141 | if (*reason == NULL) { |
141 | if (*reason == NULL) { |
142 | if (readfile_8bf(sfr, reason)) { |
142 | if (readfile_8bf(sfr, reason)) { |
143 | if (gdata->parm.iProtected) { |
143 | if (gdata->parm.iProtected) { |
144 | // This is for purely protected filters before the time when obfuscation and protection was merged |
144 | // This is for purely protected filters before the time when obfuscation and protection was merged |
145 | *reason = _strdup("The filter is protected."); |
145 | *reason = FF_GetMsg_Cpy(MSG_FILTER_PROTECTED_ID); |
146 | } |
146 | } |
147 | else { |
147 | else { |
148 | gdata->parmloaded = true; |
148 | gdata->parmloaded = true; |
149 | return true; |
149 | return true; |
150 | } |
150 | } |
Line 152... | Line 152... | ||
152 | } |
152 | } |
153 | 153 | ||
154 | // We didn't had success. If we have a clear reason, return false and the reason. |
154 | // We didn't had success. If we have a clear reason, return false and the reason. |
155 | // If we don't have a clear reason, set a generic reason and return false. |
155 | // If we don't have a clear reason, set a generic reason and return false. |
156 | if (*reason == NULL) { |
156 | if (*reason == NULL) { |
157 | *reason = _strdup("It is not a text parameter file, nor a standalone Mac/PC filter created by Filter Factory/Filter Foundry."); |
157 | *reason = FF_GetMsg_Cpy(MSG_LOADFILE_UNKNOWN_FORMAT_ID); |
158 | } |
158 | } |
159 | return false; |
159 | return false; |
160 | } |
160 | } |