Rev 271 | Rev 276 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 271 | Rev 274 | ||
---|---|---|---|
Line 25... | Line 25... | ||
25 | #include "versioninfo_modify_win.h" |
25 | #include "versioninfo_modify_win.h" |
26 | #include "version.h" |
26 | #include "version.h" |
27 | 27 | ||
28 | extern HINSTANCE hDllInstance; |
28 | extern HINSTANCE hDllInstance; |
29 | 29 | ||
30 | Boolean doresources(HMODULE srcmod,char *dstname); |
30 | Boolean doresources(HMODULE srcmod,char *dstname, int bits); |
31 | 31 | ||
32 | void dbglasterror(char *func){ |
32 | void dbglasterror(char *func){ |
33 | char s[0x100]; |
33 | char s[0x100]; |
34 | 34 | ||
35 | strcpy(s,func); |
35 | strcpy(s,func); |
Line 46... | Line 46... | ||
46 | dbg(s); |
46 | dbg(s); |
47 | return TRUE; |
47 | return TRUE; |
48 | } |
48 | } |
49 | */ |
49 | */ |
50 | 50 | ||
51 | int domanifest(char *newmanifest, const char *manifestp, PARM_T* pparm) { |
51 | int domanifest(char *newmanifest, const char *manifestp, PARM_T* pparm, int bits) { |
52 | char name[1024]; |
52 | char name[1024]; |
53 | char description[1024]; |
53 | char description[1024]; |
54 | size_t i; |
54 | size_t i; |
55 | int iname = 0; |
55 | int iname = 0; |
56 | int idescription = 0; |
56 | int idescription = 0; |
Line 89... | Line 89... | ||
89 | name[iname++] = c; |
89 | name[iname++] = c; |
90 | } |
90 | } |
91 | } |
91 | } |
92 | name[iname++] = '\0'; |
92 | name[iname++] = '\0'; |
93 | 93 | ||
94 | #ifdef _WIN64 |
94 | if (bits == 64) { |
95 | return sprintf(newmanifest, manifestp, (char*)name, "amd64", VERSION_STR, (char*)description); |
95 | return sprintf(newmanifest, manifestp, (char*)name, "amd64", VERSION_STR, (char*)description); |
- | 96 | } |
|
96 | #else |
97 | else { |
97 | return sprintf(newmanifest, manifestp, (char*)name, "x86", VERSION_STR, (char*)description); |
98 | return sprintf(newmanifest, manifestp, (char*)name, "x86", VERSION_STR, (char*)description); |
98 | #endif |
99 | } |
99 | } |
100 | } |
100 | 101 | ||
101 | void changeVersionInfo(char* dstname, PARM_T* pparm, HGLOBAL hupdate) { |
102 | void changeVersionInfo(char* dstname, PARM_T* pparm, HGLOBAL hupdate) { |
102 | char* soleFilename; |
103 | char* soleFilename; |
103 | LPWSTR changeRequestStr, tmp; |
104 | LPWSTR changeRequestStr, tmp; |
Line 169... | Line 170... | ||
169 | } |
170 | } |
170 | 171 | ||
171 | free(changeRequestStr); |
172 | free(changeRequestStr); |
172 | } |
173 | } |
173 | 174 | ||
174 | Boolean doresources(HMODULE srcmod,char *dstname){ |
175 | Boolean doresources(HMODULE srcmod,char *dstname, int bits){ |
175 | HRSRC datarsrc,aetersrc,manifestsrc; |
176 | HRSRC datarsrc,aetersrc,manifestsrc; |
176 | HGLOBAL datah,aeteh,hupdate,manifesth; |
177 | HGLOBAL datah,aeteh,hupdate,manifesth; |
177 | Ptr newpipl = NULL, newaete = NULL; |
178 | Ptr newpipl = NULL, newaete = NULL; |
178 | LPVOID datap, aetep, manifestp; |
179 | LPVOID datap, aetep, manifestp; |
179 | PARM_T *pparm = NULL; |
180 | PARM_T *pparm = NULL; |
Line 239... | Line 240... | ||
239 | for (i = 0; i < 4; ++i) |
240 | for (i = 0; i < 4; ++i) |
240 | myp2cstr(pparm->map[i]); |
241 | myp2cstr(pparm->map[i]); |
241 | for (i = 0; i < 8; ++i) |
242 | for (i = 0; i < 8; ++i) |
242 | myp2cstr(pparm->ctl[i]); |
243 | myp2cstr(pparm->ctl[i]); |
243 | 244 | ||
244 | manifestsize = domanifest(newmanifest, (const char*)manifestp, pparm); |
245 | manifestsize = domanifest(newmanifest, (const char*)manifestp, pparm, bits); |
245 | 246 | ||
246 | // ====== Change version attributes |
247 | // ====== Change version attributes |
247 | 248 | ||
248 | changeVersionInfo(dstname, pparm, hupdate); |
249 | changeVersionInfo(dstname, pparm, hupdate); |
249 | 250 | ||
Line 262... | Line 263... | ||
262 | 263 | ||
263 | /* Attention: The resource we have found using FindResource() might have a different |
264 | /* Attention: The resource we have found using FindResource() might have a different |
264 | language than the resource we are saving (Neutral), so we might end up having |
265 | language than the resource we are saving (Neutral), so we might end up having |
265 | multiple languages for the same resource. Therefore, the language "Neutral" was |
266 | multiple languages for the same resource. Therefore, the language "Neutral" was |
266 | set in the Scripting.rc file for the resource AETE and PIPL.rc for the resources PIPL. */ |
267 | set in the Scripting.rc file for the resource AETE and PIPL.rc for the resources PIPL. */ |
- | 268 | ||
- | 269 | if(_UpdateResource(hupdate, "TPLT" /* note: caps!! */, MAKEINTRESOURCE(50), MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), NULL, 0) |
|
- | 270 | && _UpdateResource(hupdate, "TPLT" /* note: caps!! */, MAKEINTRESOURCE(16000), MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), NULL, 0) |
|
- | 271 | && _UpdateResource(hupdate, RT_DIALOG, MAKEINTRESOURCE(ID_BUILDDLG), MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NULL, 0) |
|
267 | if( _UpdateResource(hupdate,"PIPL" /* note: caps!! */,MAKEINTRESOURCE(16000), MAKELANGID(LANG_NEUTRAL,SUBLANG_NEUTRAL),newpipl,(DWORD)piplsize) |
272 | && _UpdateResource(hupdate,"PIPL" /* note: caps!! */,MAKEINTRESOURCE(16000), MAKELANGID(LANG_NEUTRAL,SUBLANG_NEUTRAL),newpipl,(DWORD)piplsize) |
268 | && _UpdateResource(hupdate, "AETE" /* note: caps!! */, MAKEINTRESOURCE(16000), MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), newaete, (DWORD)aetesize) |
273 | && _UpdateResource(hupdate, "AETE" /* note: caps!! */, MAKEINTRESOURCE(16000), MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), newaete, (DWORD)aetesize) |
269 | && _UpdateResource(hupdate, RT_MANIFEST, MAKEINTRESOURCE(1), MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), newmanifest, (DWORD)manifestsize) |
274 | && _UpdateResource(hupdate, RT_MANIFEST, MAKEINTRESOURCE(1), MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), newmanifest, (DWORD)manifestsize) |
270 | && _UpdateResource(hupdate,parm_type,MAKEINTRESOURCE(parm_id), MAKELANGID(LANG_NEUTRAL,SUBLANG_NEUTRAL),pparm,sizeof(PARM_T)) ) |
275 | && _UpdateResource(hupdate,parm_type,MAKEINTRESOURCE(parm_id), MAKELANGID(LANG_NEUTRAL,SUBLANG_NEUTRAL),pparm,sizeof(PARM_T)) ) |
271 | { |
276 | { |
272 | discard = false; |
277 | discard = false; |
Line 286... | Line 291... | ||
286 | }else |
291 | }else |
287 | dbglasterror(_strdup("BeginUpdateResource")); |
292 | dbglasterror(_strdup("BeginUpdateResource")); |
288 | return !discard; |
293 | return !discard; |
289 | } |
294 | } |
290 | 295 | ||
- | 296 | BOOL remove_64_filename_prefix(char* dstname) { |
|
- | 297 | // foobar.8bf => foobar.8bf |
|
- | 298 | // foobar64.8bf => foobar.8bf |
|
- | 299 | int i; |
|
- | 300 | for (i = strlen(dstname); i > 2; i--) { |
|
- | 301 | if (dstname[i] == '.') { |
|
- | 302 | if ((dstname[i - 2] == '6') && (dstname[i - 1] == '4')) { |
|
- | 303 | int tmp = strlen(dstname); |
|
- | 304 | memcpy(&dstname[i - 2], &dstname[i], strlen(dstname) - i + 1); |
|
- | 305 | dstname[tmp - 2] = 0; |
|
- | 306 | return true; |
|
- | 307 | } |
|
- | 308 | } |
|
- | 309 | } |
|
- | 310 | return false; |
|
- | 311 | } |
|
- | 312 | ||
- | 313 | BOOL add_64_filename_prefix(char* dstname) { |
|
- | 314 | // foobar.8bf => foobar64.8bf |
|
- | 315 | int i; |
|
- | 316 | for (i = strlen(dstname); i > 2; i--) { |
|
- | 317 | if (dstname[i] == '.') { |
|
- | 318 | int tmp = strlen(dstname); |
|
- | 319 | memcpy(&dstname[i + 2], &dstname[i], strlen(dstname) - i + 1); |
|
- | 320 | dstname[i] = '6'; |
|
- | 321 | dstname[i + 1] = '4'; |
|
- | 322 | dstname[tmp + 2] = 0; |
|
- | 323 | return true; |
|
- | 324 | } |
|
- | 325 | } |
|
- | 326 | return false; |
|
- | 327 | } |
|
- | 328 | ||
- | 329 | BOOL FileExists(LPCTSTR szPath) { |
|
- | 330 | DWORD dwAttrib = GetFileAttributes(szPath); |
|
- | 331 | return (dwAttrib != INVALID_FILE_ATTRIBUTES && |
|
- | 332 | !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY)); |
|
- | 333 | } |
|
- | 334 | ||
- | 335 | BOOL Is32BitOperatingSystem() { |
|
- | 336 | #ifdef _WIN64 |
|
- | 337 | return false; |
|
- | 338 | #else |
|
- | 339 | SYSTEM_INFO info; |
|
- | 340 | _GetNativeSystemInfo(&info); |
|
- | 341 | return info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL; |
|
- | 342 | #endif |
|
- | 343 | } |
|
- | 344 | ||
291 | OSErr make_standalone(StandardFileReply *sfr){ |
345 | OSErr do_make_standalone(char* srcname, char* dstname, int bits) { |
292 | Boolean res; |
346 | Boolean res; |
- | 347 | ||
- | 348 | //DeleteFile(dstname); |
|
- | 349 | if (CopyFile(srcname, dstname, false)) { |
|
- | 350 | HMODULE hSrcmod; |
|
- | 351 | hSrcmod = LoadLibraryEx(srcname, NULL, LOAD_LIBRARY_AS_DATAFILE); |
|
- | 352 | if (hSrcmod) { |
|
- | 353 | res = doresources(hSrcmod, dstname, bits); |
|
- | 354 | if (!res) { |
|
- | 355 | DeleteFile(dstname); |
|
- | 356 | } |
|
- | 357 | FreeLibrary(hSrcmod); |
|
- | 358 | } |
|
- | 359 | else { |
|
- | 360 | res = false; |
|
- | 361 | } |
|
- | 362 | } |
|
- | 363 | else { |
|
- | 364 | res = false; |
|
- | 365 | } |
|
- | 366 | ||
- | 367 | if (!res) { |
|
- | 368 | char err[MAX_PATH + 200]; |
|
- | 369 | sprintf(err, "Could not create %d bit standalone plugin.", bits); |
|
- | 370 | alertuser(_strdup(&err[0]), _strdup("")); |
|
- | 371 | } |
|
- | 372 | ||
- | 373 | return res ? noErr : ioErr; |
|
- | 374 | } |
|
- | 375 | ||
- | 376 | OSErr make_standalone(StandardFileReply *sfr){ |
|
- | 377 | OSErr tmpErr, outErr; |
|
293 | char dstname[0x100],srcname[MAX_PATH+1]; |
378 | char dstname[0x100],srcname[MAX_PATH+1]; |
294 | 379 | ||
295 | if (!isWin32NT()) { |
380 | if (!isWin32NT()) { |
296 | HMODULE hLib; |
381 | HMODULE hLib; |
297 | 382 | ||
Line 309... | Line 394... | ||
309 | else { |
394 | else { |
310 | FreeLibrary(hLib); |
395 | FreeLibrary(hLib); |
311 | } |
396 | } |
312 | } |
397 | } |
313 | 398 | ||
- | 399 | outErr = noErr; |
|
- | 400 | ||
- | 401 | #ifdef _WIN64 |
|
- | 402 | ||
- | 403 | //64 bit DLL makes 64 bit: |
|
- | 404 | // Source file = module filename |
|
- | 405 | GetModuleFileName(hDllInstance, srcname, MAX_PATH); |
|
- | 406 | // Destfile = no64_or_32(chosenname) + 64 |
|
314 | //FSpDelete(&sfr->sfFile); |
407 | myp2cstrcpy(dstname, sfr->sfFile.name); |
- | 408 | remove_64_filename_prefix(dstname); |
|
- | 409 | add_64_filename_prefix(dstname); |
|
- | 410 | tmpErr = do_make_standalone(&srcname[0], &dstname[0], 64); |
|
- | 411 | if (tmpErr != noErr) |
|
- | 412 | outErr = tmpErr; |
|
- | 413 | else |
|
- | 414 | showmessage(_strdup("64 bit standalone filter was successfully created")); |
|
- | 415 | ||
- | 416 | //64 bit DLL makes 32 bit: |
|
- | 417 | // Source file = no32(modulefilename) |
|
- | 418 | GetModuleFileName(hDllInstance, srcname, MAX_PATH); |
|
- | 419 | if (!remove_64_filename_prefix(srcname)) { |
|
- | 420 | char err[MAX_PATH + 200]; |
|
- | 421 | sprintf(err, "Cannot create the %d bit version of this filter, because the 32-bit variant of this plugin could not be found", 32); |
|
- | 422 | alertuser(_strdup(&err[0]), _strdup("")); |
|
- | 423 | } |
|
- | 424 | else if (!FileExists(srcname)) { |
|
- | 425 | char err[MAX_PATH + 200]; |
|
- | 426 | sprintf(err, "%s was not found. Therefore, the %d bit version of the standalone filter could not be created!", srcname, 32); |
|
- | 427 | alertuser(_strdup(&err[0]), _strdup("")); |
|
- | 428 | } |
|
- | 429 | else { |
|
- | 430 | // Destfile = no64_or_32(chosenname) |
|
315 | myp2cstrcpy(dstname,sfr->sfFile.name); |
431 | myp2cstrcpy(dstname, sfr->sfFile.name); |
316 | res = GetModuleFileName(hDllInstance,srcname,MAX_PATH) |
432 | remove_64_filename_prefix(dstname); |
317 | && CopyFile(srcname,dstname,false) |
433 | tmpErr = do_make_standalone(&srcname[0], &dstname[0], 32); |
- | 434 | if (tmpErr != noErr) |
|
- | 435 | outErr = tmpErr; |
|
- | 436 | else |
|
318 | && doresources(hDllInstance,dstname); |
437 | showmessage(_strdup("32 bit standalone filter was successfully created")); |
- | 438 | } |
|
319 | 439 | ||
320 | if(!res) { |
440 | #else |
- | 441 | ||
- | 442 | //32 bit DLL makes 32 bit: |
|
- | 443 | // Source file = module filename |
|
- | 444 | GetModuleFileName(hDllInstance, srcname, MAX_PATH); |
|
- | 445 | // Destfile = no64_or_32(chosenname) |
|
- | 446 | myp2cstrcpy(dstname, sfr->sfFile.name); |
|
- | 447 | remove_64_filename_prefix(dstname); |
|
321 | alertuser(_strdup("Could not create standalone plugin."),_strdup("")); |
448 | tmpErr = do_make_standalone(&srcname[0], &dstname[0], 32); |
- | 449 | if (tmpErr != noErr) |
|
- | 450 | outErr = tmpErr; |
|
322 | } else { |
451 | else |
323 | showmessage(_strdup("Filter was sucessfully created")); |
452 | showmessage(_strdup("32 bit standalone filter was successfully created")); |
- | 453 | ||
- | 454 | if (!Is32BitOperatingSystem()) { |
|
- | 455 | //32 bit DLL makes 64 bit: |
|
- | 456 | // Source file = module filename + 64 |
|
- | 457 | GetModuleFileName(hDllInstance, srcname, MAX_PATH); |
|
- | 458 | add_64_filename_prefix(srcname); |
|
- | 459 | if (!FileExists(srcname)) { |
|
- | 460 | char err[MAX_PATH + 200]; |
|
- | 461 | sprintf(err, "%s was not found. Therefore, the %d bit version of the standalone filter could not be created!", srcname, 64); |
|
- | 462 | alertuser(_strdup(&err[0]), _strdup("")); |
|
324 | } |
463 | } |
- | 464 | else { |
|
- | 465 | // Destfile = no64_or_32(chosenname) + 64 |
|
- | 466 | myp2cstrcpy(dstname, sfr->sfFile.name); |
|
- | 467 | remove_64_filename_prefix(dstname); |
|
- | 468 | add_64_filename_prefix(dstname); |
|
- | 469 | tmpErr = do_make_standalone(&srcname[0], &dstname[0], 64); |
|
- | 470 | if (tmpErr != noErr) |
|
- | 471 | outErr = tmpErr; |
|
- | 472 | else |
|
- | 473 | showmessage(_strdup("64 bit standalone filter was successfully created")); |
|
- | 474 | } |
|
- | 475 | } |
|
- | 476 | #endif |
|
325 | 477 | ||
326 | return res ? ioErr : noErr; |
478 | return outErr; |
327 | } |
479 | } |