| 670 return 0; |
671 return 0; |
| 671 } |
672 } |
| 672 |
673 |
| 673 /* Load exception handler if we have it */ |
674 /* Load exception handler if we have it */ |
| 674 if (GetModuleFileName(NULL, pidgin_dir, MAX_PATH) != 0) { |
675 if (GetModuleFileName(NULL, pidgin_dir, MAX_PATH) != 0) { |
| 675 char *prev = NULL; |
|
| 676 tmp = pidgin_dir; |
|
| 677 |
676 |
| 678 /* primitive dirname() */ |
677 /* primitive dirname() */ |
| 679 while ((tmp = strchr(tmp, '\\'))) { |
678 tmp = strrchr(pidgin_dir, '\\'); |
| 680 prev = tmp; |
679 |
| 681 tmp++; |
680 if (tmp) { |
| 682 } |
|
| 683 |
|
| 684 if (prev) { |
|
| 685 HMODULE hmod; |
681 HMODULE hmod; |
| 686 prev[0] = '\0'; |
682 tmp[0] = '\0'; |
| 687 |
683 |
| 688 /* prev++ will now point to the executable file name */ |
684 /* tmp++ will now point to the executable file name */ |
| 689 strcpy(exe_name, prev + 1); |
685 strcpy(exe_name, tmp + 1); |
| 690 |
686 |
| 691 strcat(pidgin_dir, "\\exchndl.dll"); |
687 strcat(pidgin_dir, "\\exchndl.dll"); |
| 692 if ((hmod = LoadLibrary(pidgin_dir))) { |
688 if ((hmod = LoadLibrary(pidgin_dir))) { |
| |
689 FARPROC proc; |
| |
690 char debug_dir[MAX_PATH]; |
| 693 printf("Loaded exchndl.dll\n"); |
691 printf("Loaded exchndl.dll\n"); |
| 694 } |
692 /* Temporarily override exchndl.dll's logfile |
| 695 |
693 * to something sane (Pidgin will override it |
| 696 prev[0] = '\0'; |
694 * again when it initializes) */ |
| |
695 proc = GetProcAddress(hmod, "SetLogFile"); |
| |
696 if (proc) { |
| |
697 if (GetTempPath(sizeof(debug_dir), debug_dir) != 0) { |
| |
698 strcat(debug_dir, "pidgin.RPT"); |
| |
699 printf(" Setting exchndl.dll LogFile to %s\n", |
| |
700 debug_dir); |
| |
701 (proc)(debug_dir); |
| |
702 } |
| |
703 } |
| |
704 proc = GetProcAddress(hmod, "SetDebugInfoDir"); |
| |
705 if (proc) { |
| |
706 tmp[0] = '\0'; |
| |
707 _snprintf(debug_dir, sizeof(debug_dir), |
| |
708 "%s\\pidgin-%s-dbgsym", |
| |
709 pidgin_dir, VERSION); |
| |
710 debug_dir[sizeof(debug_dir) - 1] = '\0'; |
| |
711 printf(" Setting exchndl.dll DebugInfoDir to %s\n", |
| |
712 debug_dir); |
| |
713 (proc)(debug_dir); |
| |
714 } |
| |
715 |
| |
716 } |
| |
717 |
| |
718 tmp[0] = '\0'; |
| 697 } |
719 } |
| 698 } else { |
720 } else { |
| 699 DWORD dw = GetLastError(); |
721 DWORD dw = GetLastError(); |
| 700 const char *err_msg = get_win32_error_message(dw); |
722 const char *err_msg = get_win32_error_message(dw); |
| 701 _snprintf(errbuf, 512, |
723 _snprintf(errbuf, 512, |