From a089c8f17cca1cdf688e91be38ec315803168ed8 Mon Sep 17 00:00:00 2001 From: Vadim Dashevskiy Date: Mon, 16 Jul 2012 20:35:50 +0000 Subject: Svc_dbepp is renamed to DbeditorPP Svc_crshdmp is renamed to CrashDumper Svc_vi is renamed to VersionInfo git-svn-id: http://svn.miranda-ng.org/main/trunk@992 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- bin10/mir_full.sln | 60 +- bin10/mir_full_pro.sln | 66 +- plugins/CrashDumper/Vi show.ico | Bin 0 -> 2550 bytes plugins/CrashDumper/Vi to clipboard.ico | Bin 0 -> 2550 bytes plugins/CrashDumper/Vi to file.ico | Bin 0 -> 2550 bytes plugins/CrashDumper/Vi upload.ico | Bin 0 -> 2550 bytes plugins/CrashDumper/Vi.ico | Bin 0 -> 6830 bytes plugins/CrashDumper/bkstring.cpp | 188 + plugins/CrashDumper/bkstring.h | 276 ++ plugins/CrashDumper/crshdmp.cpp | 434 ++ plugins/CrashDumper/crshdmp.rc | 192 + plugins/CrashDumper/crshdmp_10.vcxproj | 220 + plugins/CrashDumper/crshdmp_icons.cpp | 88 + plugins/CrashDumper/crshdmp_readme.txt | 379 ++ plugins/CrashDumper/dumper.cpp | 745 ++++ plugins/CrashDumper/exhndlr.cpp | 207 + plugins/CrashDumper/resource.h | 34 + plugins/CrashDumper/sdkstuff.h | 124 + plugins/CrashDumper/svc_crshdmp-translation.txt | 54 + plugins/CrashDumper/ui.cpp | 327 ++ plugins/CrashDumper/upload.cpp | 292 ++ plugins/CrashDumper/utils.cpp | 836 ++++ plugins/CrashDumper/utils.h | 177 + plugins/CrashDumper/vc6/dbghelp.h | 4532 ++++++++++++++++++++ plugins/CrashDumper/vc6/dbghelp.lib | Bin 0 -> 48054 bytes plugins/CrashDumper/version.h | 3 + plugins/DbeditorPP/Res/Contacts.ico | Bin 0 -> 1406 bytes plugins/DbeditorPP/Res/Icon_1.ico | Bin 0 -> 1078 bytes plugins/DbeditorPP/Res/Icon_14.ico | Bin 0 -> 318 bytes plugins/DbeditorPP/Res/Icon_15.ico | Bin 0 -> 318 bytes plugins/DbeditorPP/Res/Icon_16.ico | Bin 0 -> 318 bytes plugins/DbeditorPP/Res/Icon_17.ico | Bin 0 -> 318 bytes plugins/DbeditorPP/Res/Icon_18.ico | Bin 0 -> 318 bytes plugins/DbeditorPP/Res/Icon_4.ico | Bin 0 -> 1406 bytes plugins/DbeditorPP/Res/Red.ico | Bin 0 -> 1406 bytes plugins/DbeditorPP/Res/Red_open.ico | Bin 0 -> 1406 bytes plugins/DbeditorPP/Res/UserMenu.ico | Bin 0 -> 1406 bytes plugins/DbeditorPP/Res/Yellow.ico | Bin 0 -> 1406 bytes plugins/DbeditorPP/Res/Yellow_open.ico | Bin 0 -> 1406 bytes plugins/DbeditorPP/Res/dbepp.ico | Bin 0 -> 318 bytes plugins/DbeditorPP/Res/handle.ico | Bin 0 -> 318 bytes plugins/DbeditorPP/Res/handle1.ico | Bin 0 -> 318 bytes plugins/DbeditorPP/Res/ico_RegEdit.ico | Bin 0 -> 2550 bytes plugins/DbeditorPP/Res/offline2.ico | Bin 0 -> 1406 bytes plugins/DbeditorPP/Res/online2.ico | Bin 0 -> 1406 bytes plugins/DbeditorPP/Res/unicode.ico | Bin 0 -> 318 bytes plugins/DbeditorPP/Version.h | 20 + plugins/DbeditorPP/Version.rc | 42 + plugins/DbeditorPP/addeditsettingsdlg.cpp | 458 ++ plugins/DbeditorPP/copymodule.cpp | 197 + plugins/DbeditorPP/dbeditorpp_10.vcxproj | 231 + plugins/DbeditorPP/dbeditorpp_10.vcxproj.filters | 142 + plugins/DbeditorPP/dbeditorpp_readme.txt | 143 + plugins/DbeditorPP/dbeditorpp_translation.txt | 38 + plugins/DbeditorPP/deletemodule.cpp | 148 + plugins/DbeditorPP/exportimport.cpp | 745 ++++ plugins/DbeditorPP/findwindow.cpp | 725 ++++ plugins/DbeditorPP/headers.h | 257 ++ plugins/DbeditorPP/icons.cpp | 143 + plugins/DbeditorPP/knownmodules.cpp | 84 + plugins/DbeditorPP/main.cpp | 669 +++ plugins/DbeditorPP/main_window.cpp | 673 +++ plugins/DbeditorPP/modsettingenum.cpp | 88 + plugins/DbeditorPP/modsettingenum.h | 17 + plugins/DbeditorPP/modules.cpp | 109 + plugins/DbeditorPP/moduletree.cpp | 1132 +++++ plugins/DbeditorPP/options.cpp | 94 + plugins/DbeditorPP/resource.h | 157 + plugins/DbeditorPP/resource.rc | 516 +++ plugins/DbeditorPP/settinglist.cpp | 1261 ++++++ plugins/DbeditorPP/svc_dbepp-translation.txt | 219 + plugins/DbeditorPP/threads.cpp | 48 + plugins/DbeditorPP/watchedvars.cpp | 358 ++ plugins/Svc_crshdmp/Vi show.ico | Bin 2550 -> 0 bytes plugins/Svc_crshdmp/Vi to clipboard.ico | Bin 2550 -> 0 bytes plugins/Svc_crshdmp/Vi to file.ico | Bin 2550 -> 0 bytes plugins/Svc_crshdmp/Vi upload.ico | Bin 2550 -> 0 bytes plugins/Svc_crshdmp/Vi.ico | Bin 6830 -> 0 bytes plugins/Svc_crshdmp/bkstring.cpp | 188 - plugins/Svc_crshdmp/bkstring.h | 276 -- plugins/Svc_crshdmp/crshdmp.cpp | 434 -- plugins/Svc_crshdmp/crshdmp.rc | 192 - plugins/Svc_crshdmp/crshdmp_10.vcxproj | 220 - plugins/Svc_crshdmp/crshdmp_icons.cpp | 88 - plugins/Svc_crshdmp/crshdmp_readme.txt | 379 -- plugins/Svc_crshdmp/dumper.cpp | 745 ---- plugins/Svc_crshdmp/exhndlr.cpp | 207 - plugins/Svc_crshdmp/resource.h | 34 - plugins/Svc_crshdmp/sdkstuff.h | 124 - plugins/Svc_crshdmp/svc_crshdmp-translation.txt | 54 - plugins/Svc_crshdmp/ui.cpp | 327 -- plugins/Svc_crshdmp/upload.cpp | 292 -- plugins/Svc_crshdmp/utils.cpp | 836 ---- plugins/Svc_crshdmp/utils.h | 177 - plugins/Svc_crshdmp/vc6/dbghelp.h | 4532 -------------------- plugins/Svc_crshdmp/vc6/dbghelp.lib | Bin 48054 -> 0 bytes plugins/Svc_crshdmp/version.h | 3 - plugins/Svc_dbepp/Res/Contacts.ico | Bin 1406 -> 0 bytes plugins/Svc_dbepp/Res/Icon_1.ico | Bin 1078 -> 0 bytes plugins/Svc_dbepp/Res/Icon_14.ico | Bin 318 -> 0 bytes plugins/Svc_dbepp/Res/Icon_15.ico | Bin 318 -> 0 bytes plugins/Svc_dbepp/Res/Icon_16.ico | Bin 318 -> 0 bytes plugins/Svc_dbepp/Res/Icon_17.ico | Bin 318 -> 0 bytes plugins/Svc_dbepp/Res/Icon_18.ico | Bin 318 -> 0 bytes plugins/Svc_dbepp/Res/Icon_4.ico | Bin 1406 -> 0 bytes plugins/Svc_dbepp/Res/Red.ico | Bin 1406 -> 0 bytes plugins/Svc_dbepp/Res/Red_open.ico | Bin 1406 -> 0 bytes plugins/Svc_dbepp/Res/UserMenu.ico | Bin 1406 -> 0 bytes plugins/Svc_dbepp/Res/Yellow.ico | Bin 1406 -> 0 bytes plugins/Svc_dbepp/Res/Yellow_open.ico | Bin 1406 -> 0 bytes plugins/Svc_dbepp/Res/dbepp.ico | Bin 318 -> 0 bytes plugins/Svc_dbepp/Res/handle.ico | Bin 318 -> 0 bytes plugins/Svc_dbepp/Res/handle1.ico | Bin 318 -> 0 bytes plugins/Svc_dbepp/Res/ico_RegEdit.ico | Bin 2550 -> 0 bytes plugins/Svc_dbepp/Res/offline2.ico | Bin 1406 -> 0 bytes plugins/Svc_dbepp/Res/online2.ico | Bin 1406 -> 0 bytes plugins/Svc_dbepp/Res/unicode.ico | Bin 318 -> 0 bytes plugins/Svc_dbepp/Version.h | 20 - plugins/Svc_dbepp/Version.rc | 42 - plugins/Svc_dbepp/addeditsettingsdlg.cpp | 458 -- plugins/Svc_dbepp/copymodule.cpp | 197 - plugins/Svc_dbepp/dbeditorpp_10.vcxproj | 231 - plugins/Svc_dbepp/dbeditorpp_10.vcxproj.filters | 142 - plugins/Svc_dbepp/dbeditorpp_readme.txt | 143 - plugins/Svc_dbepp/dbeditorpp_translation.txt | 38 - plugins/Svc_dbepp/deletemodule.cpp | 148 - plugins/Svc_dbepp/exportimport.cpp | 745 ---- plugins/Svc_dbepp/findwindow.cpp | 725 ---- plugins/Svc_dbepp/headers.h | 257 -- plugins/Svc_dbepp/icons.cpp | 143 - plugins/Svc_dbepp/knownmodules.cpp | 84 - plugins/Svc_dbepp/main.cpp | 669 --- plugins/Svc_dbepp/main_window.cpp | 673 --- plugins/Svc_dbepp/modsettingenum.cpp | 88 - plugins/Svc_dbepp/modsettingenum.h | 17 - plugins/Svc_dbepp/modules.cpp | 109 - plugins/Svc_dbepp/moduletree.cpp | 1132 ----- plugins/Svc_dbepp/options.cpp | 94 - plugins/Svc_dbepp/resource.h | 157 - plugins/Svc_dbepp/resource.rc | 516 --- plugins/Svc_dbepp/settinglist.cpp | 1261 ------ plugins/Svc_dbepp/svc_dbepp-translation.txt | 219 - plugins/Svc_dbepp/threads.cpp | 48 - plugins/Svc_dbepp/watchedvars.cpp | 358 -- plugins/Svc_vi/AggressiveOptimize.h | 58 - plugins/Svc_vi/CPlugin.cpp | 137 - plugins/Svc_vi/CPlugin.h | 73 - plugins/Svc_vi/CVersionInfo.cpp | 1198 ------ plugins/Svc_vi/CVersionInfo.h | 115 - plugins/Svc_vi/VersionInfo.html | 11 - plugins/Svc_vi/VersionInfo.ico | Bin 2550 -> 0 bytes plugins/Svc_vi/VersionInfo_10.vcxproj | 210 - plugins/Svc_vi/VersionInfo_10.vcxproj.filters | 67 - plugins/Svc_vi/common.h | 96 - plugins/Svc_vi/dlgHandlers.cpp | 589 --- plugins/Svc_vi/dlgHandlers.h | 43 - plugins/Svc_vi/docs/readme_versioninfo.txt | 433 -- plugins/Svc_vi/docs/rebase_versioninfo.txt | 33 - plugins/Svc_vi/docs/versioninfo.gif | Bin 100803 -> 0 bytes plugins/Svc_vi/hooked_events.cpp | 80 - plugins/Svc_vi/hooked_events.h | 33 - plugins/Svc_vi/main.cpp | 135 - plugins/Svc_vi/resource.h | 71 - plugins/Svc_vi/resource.rc | 225 - plugins/Svc_vi/services.cpp | 76 - plugins/Svc_vi/services.h | 31 - plugins/Svc_vi/svc_vi-translation.txt | 56 - plugins/Svc_vi/utils.cpp | 526 --- plugins/Svc_vi/utils.h | 49 - plugins/Svc_vi/version.h | 44 - plugins/Svc_vi/version.rc | 104 - plugins/VersionInfo/AggressiveOptimize.h | 58 + plugins/VersionInfo/CPlugin.cpp | 137 + plugins/VersionInfo/CPlugin.h | 73 + plugins/VersionInfo/CVersionInfo.cpp | 1198 ++++++ plugins/VersionInfo/CVersionInfo.h | 115 + plugins/VersionInfo/VersionInfo.html | 11 + plugins/VersionInfo/VersionInfo.ico | Bin 0 -> 2550 bytes plugins/VersionInfo/VersionInfo_10.vcxproj | 210 + plugins/VersionInfo/VersionInfo_10.vcxproj.filters | 67 + plugins/VersionInfo/common.h | 96 + plugins/VersionInfo/dlgHandlers.cpp | 589 +++ plugins/VersionInfo/dlgHandlers.h | 43 + plugins/VersionInfo/docs/readme_versioninfo.txt | 433 ++ plugins/VersionInfo/docs/rebase_versioninfo.txt | 33 + plugins/VersionInfo/docs/versioninfo.gif | Bin 0 -> 100803 bytes plugins/VersionInfo/hooked_events.cpp | 80 + plugins/VersionInfo/hooked_events.h | 33 + plugins/VersionInfo/main.cpp | 135 + plugins/VersionInfo/resource.h | 71 + plugins/VersionInfo/resource.rc | 225 + plugins/VersionInfo/services.cpp | 76 + plugins/VersionInfo/services.h | 31 + plugins/VersionInfo/svc_vi-translation.txt | 56 + plugins/VersionInfo/utils.cpp | 526 +++ plugins/VersionInfo/utils.h | 49 + plugins/VersionInfo/version.h | 44 + plugins/VersionInfo/version.rc | 104 + 198 files changed, 22378 insertions(+), 22378 deletions(-) create mode 100644 plugins/CrashDumper/Vi show.ico create mode 100644 plugins/CrashDumper/Vi to clipboard.ico create mode 100644 plugins/CrashDumper/Vi to file.ico create mode 100644 plugins/CrashDumper/Vi upload.ico create mode 100644 plugins/CrashDumper/Vi.ico create mode 100644 plugins/CrashDumper/bkstring.cpp create mode 100644 plugins/CrashDumper/bkstring.h create mode 100644 plugins/CrashDumper/crshdmp.cpp create mode 100644 plugins/CrashDumper/crshdmp.rc create mode 100644 plugins/CrashDumper/crshdmp_10.vcxproj create mode 100644 plugins/CrashDumper/crshdmp_icons.cpp create mode 100644 plugins/CrashDumper/crshdmp_readme.txt create mode 100644 plugins/CrashDumper/dumper.cpp create mode 100644 plugins/CrashDumper/exhndlr.cpp create mode 100644 plugins/CrashDumper/resource.h create mode 100644 plugins/CrashDumper/sdkstuff.h create mode 100644 plugins/CrashDumper/svc_crshdmp-translation.txt create mode 100644 plugins/CrashDumper/ui.cpp create mode 100644 plugins/CrashDumper/upload.cpp create mode 100644 plugins/CrashDumper/utils.cpp create mode 100644 plugins/CrashDumper/utils.h create mode 100644 plugins/CrashDumper/vc6/dbghelp.h create mode 100644 plugins/CrashDumper/vc6/dbghelp.lib create mode 100644 plugins/CrashDumper/version.h create mode 100644 plugins/DbeditorPP/Res/Contacts.ico create mode 100644 plugins/DbeditorPP/Res/Icon_1.ico create mode 100644 plugins/DbeditorPP/Res/Icon_14.ico create mode 100644 plugins/DbeditorPP/Res/Icon_15.ico create mode 100644 plugins/DbeditorPP/Res/Icon_16.ico create mode 100644 plugins/DbeditorPP/Res/Icon_17.ico create mode 100644 plugins/DbeditorPP/Res/Icon_18.ico create mode 100644 plugins/DbeditorPP/Res/Icon_4.ico create mode 100644 plugins/DbeditorPP/Res/Red.ico create mode 100644 plugins/DbeditorPP/Res/Red_open.ico create mode 100644 plugins/DbeditorPP/Res/UserMenu.ico create mode 100644 plugins/DbeditorPP/Res/Yellow.ico create mode 100644 plugins/DbeditorPP/Res/Yellow_open.ico create mode 100644 plugins/DbeditorPP/Res/dbepp.ico create mode 100644 plugins/DbeditorPP/Res/handle.ico create mode 100644 plugins/DbeditorPP/Res/handle1.ico create mode 100644 plugins/DbeditorPP/Res/ico_RegEdit.ico create mode 100644 plugins/DbeditorPP/Res/offline2.ico create mode 100644 plugins/DbeditorPP/Res/online2.ico create mode 100644 plugins/DbeditorPP/Res/unicode.ico create mode 100644 plugins/DbeditorPP/Version.h create mode 100644 plugins/DbeditorPP/Version.rc create mode 100644 plugins/DbeditorPP/addeditsettingsdlg.cpp create mode 100644 plugins/DbeditorPP/copymodule.cpp create mode 100644 plugins/DbeditorPP/dbeditorpp_10.vcxproj create mode 100644 plugins/DbeditorPP/dbeditorpp_10.vcxproj.filters create mode 100644 plugins/DbeditorPP/dbeditorpp_readme.txt create mode 100644 plugins/DbeditorPP/dbeditorpp_translation.txt create mode 100644 plugins/DbeditorPP/deletemodule.cpp create mode 100644 plugins/DbeditorPP/exportimport.cpp create mode 100644 plugins/DbeditorPP/findwindow.cpp create mode 100644 plugins/DbeditorPP/headers.h create mode 100644 plugins/DbeditorPP/icons.cpp create mode 100644 plugins/DbeditorPP/knownmodules.cpp create mode 100644 plugins/DbeditorPP/main.cpp create mode 100644 plugins/DbeditorPP/main_window.cpp create mode 100644 plugins/DbeditorPP/modsettingenum.cpp create mode 100644 plugins/DbeditorPP/modsettingenum.h create mode 100644 plugins/DbeditorPP/modules.cpp create mode 100644 plugins/DbeditorPP/moduletree.cpp create mode 100644 plugins/DbeditorPP/options.cpp create mode 100644 plugins/DbeditorPP/resource.h create mode 100644 plugins/DbeditorPP/resource.rc create mode 100644 plugins/DbeditorPP/settinglist.cpp create mode 100644 plugins/DbeditorPP/svc_dbepp-translation.txt create mode 100644 plugins/DbeditorPP/threads.cpp create mode 100644 plugins/DbeditorPP/watchedvars.cpp delete mode 100644 plugins/Svc_crshdmp/Vi show.ico delete mode 100644 plugins/Svc_crshdmp/Vi to clipboard.ico delete mode 100644 plugins/Svc_crshdmp/Vi to file.ico delete mode 100644 plugins/Svc_crshdmp/Vi upload.ico delete mode 100644 plugins/Svc_crshdmp/Vi.ico delete mode 100644 plugins/Svc_crshdmp/bkstring.cpp delete mode 100644 plugins/Svc_crshdmp/bkstring.h delete mode 100644 plugins/Svc_crshdmp/crshdmp.cpp delete mode 100644 plugins/Svc_crshdmp/crshdmp.rc delete mode 100644 plugins/Svc_crshdmp/crshdmp_10.vcxproj delete mode 100644 plugins/Svc_crshdmp/crshdmp_icons.cpp delete mode 100644 plugins/Svc_crshdmp/crshdmp_readme.txt delete mode 100644 plugins/Svc_crshdmp/dumper.cpp delete mode 100644 plugins/Svc_crshdmp/exhndlr.cpp delete mode 100644 plugins/Svc_crshdmp/resource.h delete mode 100644 plugins/Svc_crshdmp/sdkstuff.h delete mode 100644 plugins/Svc_crshdmp/svc_crshdmp-translation.txt delete mode 100644 plugins/Svc_crshdmp/ui.cpp delete mode 100644 plugins/Svc_crshdmp/upload.cpp delete mode 100644 plugins/Svc_crshdmp/utils.cpp delete mode 100644 plugins/Svc_crshdmp/utils.h delete mode 100644 plugins/Svc_crshdmp/vc6/dbghelp.h delete mode 100644 plugins/Svc_crshdmp/vc6/dbghelp.lib delete mode 100644 plugins/Svc_crshdmp/version.h delete mode 100644 plugins/Svc_dbepp/Res/Contacts.ico delete mode 100644 plugins/Svc_dbepp/Res/Icon_1.ico delete mode 100644 plugins/Svc_dbepp/Res/Icon_14.ico delete mode 100644 plugins/Svc_dbepp/Res/Icon_15.ico delete mode 100644 plugins/Svc_dbepp/Res/Icon_16.ico delete mode 100644 plugins/Svc_dbepp/Res/Icon_17.ico delete mode 100644 plugins/Svc_dbepp/Res/Icon_18.ico delete mode 100644 plugins/Svc_dbepp/Res/Icon_4.ico delete mode 100644 plugins/Svc_dbepp/Res/Red.ico delete mode 100644 plugins/Svc_dbepp/Res/Red_open.ico delete mode 100644 plugins/Svc_dbepp/Res/UserMenu.ico delete mode 100644 plugins/Svc_dbepp/Res/Yellow.ico delete mode 100644 plugins/Svc_dbepp/Res/Yellow_open.ico delete mode 100644 plugins/Svc_dbepp/Res/dbepp.ico delete mode 100644 plugins/Svc_dbepp/Res/handle.ico delete mode 100644 plugins/Svc_dbepp/Res/handle1.ico delete mode 100644 plugins/Svc_dbepp/Res/ico_RegEdit.ico delete mode 100644 plugins/Svc_dbepp/Res/offline2.ico delete mode 100644 plugins/Svc_dbepp/Res/online2.ico delete mode 100644 plugins/Svc_dbepp/Res/unicode.ico delete mode 100644 plugins/Svc_dbepp/Version.h delete mode 100644 plugins/Svc_dbepp/Version.rc delete mode 100644 plugins/Svc_dbepp/addeditsettingsdlg.cpp delete mode 100644 plugins/Svc_dbepp/copymodule.cpp delete mode 100644 plugins/Svc_dbepp/dbeditorpp_10.vcxproj delete mode 100644 plugins/Svc_dbepp/dbeditorpp_10.vcxproj.filters delete mode 100644 plugins/Svc_dbepp/dbeditorpp_readme.txt delete mode 100644 plugins/Svc_dbepp/dbeditorpp_translation.txt delete mode 100644 plugins/Svc_dbepp/deletemodule.cpp delete mode 100644 plugins/Svc_dbepp/exportimport.cpp delete mode 100644 plugins/Svc_dbepp/findwindow.cpp delete mode 100644 plugins/Svc_dbepp/headers.h delete mode 100644 plugins/Svc_dbepp/icons.cpp delete mode 100644 plugins/Svc_dbepp/knownmodules.cpp delete mode 100644 plugins/Svc_dbepp/main.cpp delete mode 100644 plugins/Svc_dbepp/main_window.cpp delete mode 100644 plugins/Svc_dbepp/modsettingenum.cpp delete mode 100644 plugins/Svc_dbepp/modsettingenum.h delete mode 100644 plugins/Svc_dbepp/modules.cpp delete mode 100644 plugins/Svc_dbepp/moduletree.cpp delete mode 100644 plugins/Svc_dbepp/options.cpp delete mode 100644 plugins/Svc_dbepp/resource.h delete mode 100644 plugins/Svc_dbepp/resource.rc delete mode 100644 plugins/Svc_dbepp/settinglist.cpp delete mode 100644 plugins/Svc_dbepp/svc_dbepp-translation.txt delete mode 100644 plugins/Svc_dbepp/threads.cpp delete mode 100644 plugins/Svc_dbepp/watchedvars.cpp delete mode 100644 plugins/Svc_vi/AggressiveOptimize.h delete mode 100644 plugins/Svc_vi/CPlugin.cpp delete mode 100644 plugins/Svc_vi/CPlugin.h delete mode 100644 plugins/Svc_vi/CVersionInfo.cpp delete mode 100644 plugins/Svc_vi/CVersionInfo.h delete mode 100644 plugins/Svc_vi/VersionInfo.html delete mode 100644 plugins/Svc_vi/VersionInfo.ico delete mode 100644 plugins/Svc_vi/VersionInfo_10.vcxproj delete mode 100644 plugins/Svc_vi/VersionInfo_10.vcxproj.filters delete mode 100644 plugins/Svc_vi/common.h delete mode 100644 plugins/Svc_vi/dlgHandlers.cpp delete mode 100644 plugins/Svc_vi/dlgHandlers.h delete mode 100644 plugins/Svc_vi/docs/readme_versioninfo.txt delete mode 100644 plugins/Svc_vi/docs/rebase_versioninfo.txt delete mode 100644 plugins/Svc_vi/docs/versioninfo.gif delete mode 100644 plugins/Svc_vi/hooked_events.cpp delete mode 100644 plugins/Svc_vi/hooked_events.h delete mode 100644 plugins/Svc_vi/main.cpp delete mode 100644 plugins/Svc_vi/resource.h delete mode 100644 plugins/Svc_vi/resource.rc delete mode 100644 plugins/Svc_vi/services.cpp delete mode 100644 plugins/Svc_vi/services.h delete mode 100644 plugins/Svc_vi/svc_vi-translation.txt delete mode 100644 plugins/Svc_vi/utils.cpp delete mode 100644 plugins/Svc_vi/utils.h delete mode 100644 plugins/Svc_vi/version.h delete mode 100644 plugins/Svc_vi/version.rc create mode 100644 plugins/VersionInfo/AggressiveOptimize.h create mode 100644 plugins/VersionInfo/CPlugin.cpp create mode 100644 plugins/VersionInfo/CPlugin.h create mode 100644 plugins/VersionInfo/CVersionInfo.cpp create mode 100644 plugins/VersionInfo/CVersionInfo.h create mode 100644 plugins/VersionInfo/VersionInfo.html create mode 100644 plugins/VersionInfo/VersionInfo.ico create mode 100644 plugins/VersionInfo/VersionInfo_10.vcxproj create mode 100644 plugins/VersionInfo/VersionInfo_10.vcxproj.filters create mode 100644 plugins/VersionInfo/common.h create mode 100644 plugins/VersionInfo/dlgHandlers.cpp create mode 100644 plugins/VersionInfo/dlgHandlers.h create mode 100644 plugins/VersionInfo/docs/readme_versioninfo.txt create mode 100644 plugins/VersionInfo/docs/rebase_versioninfo.txt create mode 100644 plugins/VersionInfo/docs/versioninfo.gif create mode 100644 plugins/VersionInfo/hooked_events.cpp create mode 100644 plugins/VersionInfo/hooked_events.h create mode 100644 plugins/VersionInfo/main.cpp create mode 100644 plugins/VersionInfo/resource.h create mode 100644 plugins/VersionInfo/resource.rc create mode 100644 plugins/VersionInfo/services.cpp create mode 100644 plugins/VersionInfo/services.h create mode 100644 plugins/VersionInfo/svc_vi-translation.txt create mode 100644 plugins/VersionInfo/utils.cpp create mode 100644 plugins/VersionInfo/utils.h create mode 100644 plugins/VersionInfo/version.h create mode 100644 plugins/VersionInfo/version.rc diff --git a/bin10/mir_full.sln b/bin10/mir_full.sln index 9ad48549e0..48ae5b1160 100644 --- a/bin10/mir_full.sln +++ b/bin10/mir_full.sln @@ -140,8 +140,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StartupStatus", "..\plugins EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StopSpam", "..\plugins\StopSpamPlus\stopspam_10.vcxproj", "{3E6CEC79-5E93-4607-B10E-498586ECF6A6}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Svc_dbepp", "..\plugins\Svc_dbepp\dbeditorpp_10.vcxproj", "{9C6040B8-1173-40FA-A3DB-DE044CCD8250}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Tipper", "..\plugins\TipperYM\tipper_ym_10.vcxproj", "{2C818919-A38F-44FF-BD91-A6A204AC592A}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TooltipNotify", "..\plugins\TooltipNotify\ttnotify_10.vcxproj", "{1948EAEA-4C25-4F6B-AD9E-5891F656EADA}" @@ -170,8 +168,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Facebook", "..\protocols\Fa EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Weather", "..\protocols\Weather\weather_10.vcxproj", "{6BFE3E13-BD5D-4C1C-BB29-A82FB51A16CE}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Svc_crshdmp", "..\plugins\Svc_crshdmp\crshdmp_10.vcxproj", "{576EEEFD-E423-482B-879A-F0515D40B8E1}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SpellChecker", "..\plugins\SpellChecker\spellchecker.vcxproj", "{5DB86086-10E9-42E7-AC90-503D2678C2A2}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Alarms", "..\plugins\Alarms\alarms_10.vcxproj", "{5F09C93B-463A-4BF5-A85E-6E4E916AA8F8}" @@ -198,8 +194,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ListeningTo", "..\plugins\L EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Omegle", "..\protocols\Omegle\omegle_10.vcxproj", "{D5E2FEC1-B29A-476C-BD41-469FE282EE0F}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Svc_vi", "..\plugins\Svc_vi\VersionInfo_10.vcxproj", "{3CE5572B-B7B0-4D1C-9D10-4622FBA6198E}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RC4", "..\plugins\Dbx_mmap_SA\Cryptors\RC4\rc4_10.vcxproj", "{E38B4212-53BC-49A7-B821-9A99DB4774C6}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Dbx_tree_ARC4", "..\plugins\Dbx_tree\encryption\ARC4.vcxproj", "{F60935E3-8F27-46E2-8598-013E7D4C90E7}" @@ -289,6 +283,12 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SendSS", "..\plugins\SendSc EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CheckSum", "..\tools\checksum\checksum_10.vcxproj", "{5153CD6C-6041-47CD-8BE3-2772326BB7C5}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DbeditorPP", "..\plugins\DbeditorPP\dbeditorpp_10.vcxproj", "{9C6040B8-1173-40FA-A3DB-DE044CCD8250}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CrashDumper", "..\plugins\CrashDumper\crshdmp_10.vcxproj", "{576EEEFD-E423-482B-879A-F0515D40B8E1}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VersionInfo", "..\plugins\VersionInfo\VersionInfo_10.vcxproj", "{3CE5572B-B7B0-4D1C-9D10-4622FBA6198E}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -857,14 +857,6 @@ Global {3E6CEC79-5E93-4607-B10E-498586ECF6A6}.Release|Win32.Build.0 = Release|Win32 {3E6CEC79-5E93-4607-B10E-498586ECF6A6}.Release|x64.ActiveCfg = Release|x64 {3E6CEC79-5E93-4607-B10E-498586ECF6A6}.Release|x64.Build.0 = Release|x64 - {9C6040B8-1173-40FA-A3DB-DE044CCD8250}.Debug|Win32.ActiveCfg = Debug|Win32 - {9C6040B8-1173-40FA-A3DB-DE044CCD8250}.Debug|Win32.Build.0 = Debug|Win32 - {9C6040B8-1173-40FA-A3DB-DE044CCD8250}.Debug|x64.ActiveCfg = Debug|x64 - {9C6040B8-1173-40FA-A3DB-DE044CCD8250}.Debug|x64.Build.0 = Debug|x64 - {9C6040B8-1173-40FA-A3DB-DE044CCD8250}.Release|Win32.ActiveCfg = Release|Win32 - {9C6040B8-1173-40FA-A3DB-DE044CCD8250}.Release|Win32.Build.0 = Release|Win32 - {9C6040B8-1173-40FA-A3DB-DE044CCD8250}.Release|x64.ActiveCfg = Release|x64 - {9C6040B8-1173-40FA-A3DB-DE044CCD8250}.Release|x64.Build.0 = Release|x64 {2C818919-A38F-44FF-BD91-A6A204AC592A}.Debug|Win32.ActiveCfg = Debug|Win32 {2C818919-A38F-44FF-BD91-A6A204AC592A}.Debug|Win32.Build.0 = Debug|Win32 {2C818919-A38F-44FF-BD91-A6A204AC592A}.Debug|x64.ActiveCfg = Debug|x64 @@ -977,14 +969,6 @@ Global {6BFE3E13-BD5D-4C1C-BB29-A82FB51A16CE}.Release|Win32.Build.0 = Release|Win32 {6BFE3E13-BD5D-4C1C-BB29-A82FB51A16CE}.Release|x64.ActiveCfg = Release|x64 {6BFE3E13-BD5D-4C1C-BB29-A82FB51A16CE}.Release|x64.Build.0 = Release|x64 - {576EEEFD-E423-482B-879A-F0515D40B8E1}.Debug|Win32.ActiveCfg = Debug|Win32 - {576EEEFD-E423-482B-879A-F0515D40B8E1}.Debug|Win32.Build.0 = Debug|Win32 - {576EEEFD-E423-482B-879A-F0515D40B8E1}.Debug|x64.ActiveCfg = Debug|x64 - {576EEEFD-E423-482B-879A-F0515D40B8E1}.Debug|x64.Build.0 = Debug|x64 - {576EEEFD-E423-482B-879A-F0515D40B8E1}.Release|Win32.ActiveCfg = Release|Win32 - {576EEEFD-E423-482B-879A-F0515D40B8E1}.Release|Win32.Build.0 = Release|Win32 - {576EEEFD-E423-482B-879A-F0515D40B8E1}.Release|x64.ActiveCfg = Release|x64 - {576EEEFD-E423-482B-879A-F0515D40B8E1}.Release|x64.Build.0 = Release|x64 {5DB86086-10E9-42E7-AC90-503D2678C2A2}.Debug|Win32.ActiveCfg = Debug|Win32 {5DB86086-10E9-42E7-AC90-503D2678C2A2}.Debug|Win32.Build.0 = Debug|Win32 {5DB86086-10E9-42E7-AC90-503D2678C2A2}.Debug|x64.ActiveCfg = Debug|x64 @@ -1087,14 +1071,6 @@ Global {D5E2FEC1-B29A-476C-BD41-469FE282EE0F}.Release|Win32.Build.0 = Release|Win32 {D5E2FEC1-B29A-476C-BD41-469FE282EE0F}.Release|x64.ActiveCfg = Release|x64 {D5E2FEC1-B29A-476C-BD41-469FE282EE0F}.Release|x64.Build.0 = Release|x64 - {3CE5572B-B7B0-4D1C-9D10-4622FBA6198E}.Debug|Win32.ActiveCfg = Debug|Win32 - {3CE5572B-B7B0-4D1C-9D10-4622FBA6198E}.Debug|Win32.Build.0 = Debug|Win32 - {3CE5572B-B7B0-4D1C-9D10-4622FBA6198E}.Debug|x64.ActiveCfg = Debug|x64 - {3CE5572B-B7B0-4D1C-9D10-4622FBA6198E}.Debug|x64.Build.0 = Debug|x64 - {3CE5572B-B7B0-4D1C-9D10-4622FBA6198E}.Release|Win32.ActiveCfg = Release|Win32 - {3CE5572B-B7B0-4D1C-9D10-4622FBA6198E}.Release|Win32.Build.0 = Release|Win32 - {3CE5572B-B7B0-4D1C-9D10-4622FBA6198E}.Release|x64.ActiveCfg = Release|x64 - {3CE5572B-B7B0-4D1C-9D10-4622FBA6198E}.Release|x64.Build.0 = Release|x64 {E38B4212-53BC-49A7-B821-9A99DB4774C6}.Debug|Win32.ActiveCfg = Debug|Win32 {E38B4212-53BC-49A7-B821-9A99DB4774C6}.Debug|Win32.Build.0 = Debug|Win32 {E38B4212-53BC-49A7-B821-9A99DB4774C6}.Debug|x64.ActiveCfg = Debug|x64 @@ -1437,6 +1413,30 @@ Global {5153CD6C-6041-47CD-8BE3-2772326BB7C5}.Release|Win32.Build.0 = Release|Win32 {5153CD6C-6041-47CD-8BE3-2772326BB7C5}.Release|x64.ActiveCfg = Release|x64 {5153CD6C-6041-47CD-8BE3-2772326BB7C5}.Release|x64.Build.0 = Release|x64 + {9C6040B8-1173-40FA-A3DB-DE044CCD8250}.Debug|Win32.ActiveCfg = Debug|Win32 + {9C6040B8-1173-40FA-A3DB-DE044CCD8250}.Debug|Win32.Build.0 = Debug|Win32 + {9C6040B8-1173-40FA-A3DB-DE044CCD8250}.Debug|x64.ActiveCfg = Debug|x64 + {9C6040B8-1173-40FA-A3DB-DE044CCD8250}.Debug|x64.Build.0 = Debug|x64 + {9C6040B8-1173-40FA-A3DB-DE044CCD8250}.Release|Win32.ActiveCfg = Release|Win32 + {9C6040B8-1173-40FA-A3DB-DE044CCD8250}.Release|Win32.Build.0 = Release|Win32 + {9C6040B8-1173-40FA-A3DB-DE044CCD8250}.Release|x64.ActiveCfg = Release|x64 + {9C6040B8-1173-40FA-A3DB-DE044CCD8250}.Release|x64.Build.0 = Release|x64 + {576EEEFD-E423-482B-879A-F0515D40B8E1}.Debug|Win32.ActiveCfg = Debug|Win32 + {576EEEFD-E423-482B-879A-F0515D40B8E1}.Debug|Win32.Build.0 = Debug|Win32 + {576EEEFD-E423-482B-879A-F0515D40B8E1}.Debug|x64.ActiveCfg = Debug|x64 + {576EEEFD-E423-482B-879A-F0515D40B8E1}.Debug|x64.Build.0 = Debug|x64 + {576EEEFD-E423-482B-879A-F0515D40B8E1}.Release|Win32.ActiveCfg = Release|Win32 + {576EEEFD-E423-482B-879A-F0515D40B8E1}.Release|Win32.Build.0 = Release|Win32 + {576EEEFD-E423-482B-879A-F0515D40B8E1}.Release|x64.ActiveCfg = Release|x64 + {576EEEFD-E423-482B-879A-F0515D40B8E1}.Release|x64.Build.0 = Release|x64 + {3CE5572B-B7B0-4D1C-9D10-4622FBA6198E}.Debug|Win32.ActiveCfg = Debug|Win32 + {3CE5572B-B7B0-4D1C-9D10-4622FBA6198E}.Debug|Win32.Build.0 = Debug|Win32 + {3CE5572B-B7B0-4D1C-9D10-4622FBA6198E}.Debug|x64.ActiveCfg = Debug|x64 + {3CE5572B-B7B0-4D1C-9D10-4622FBA6198E}.Debug|x64.Build.0 = Debug|x64 + {3CE5572B-B7B0-4D1C-9D10-4622FBA6198E}.Release|Win32.ActiveCfg = Release|Win32 + {3CE5572B-B7B0-4D1C-9D10-4622FBA6198E}.Release|Win32.Build.0 = Release|Win32 + {3CE5572B-B7B0-4D1C-9D10-4622FBA6198E}.Release|x64.ActiveCfg = Release|x64 + {3CE5572B-B7B0-4D1C-9D10-4622FBA6198E}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/bin10/mir_full_pro.sln b/bin10/mir_full_pro.sln index 8fc239de98..3de53625f0 100644 --- a/bin10/mir_full_pro.sln +++ b/bin10/mir_full_pro.sln @@ -140,8 +140,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StartupStatus", "..\plugins EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StopSpam", "..\plugins\StopSpamPlus\stopspam_10.vcxproj", "{3E6CEC79-5E93-4607-B10E-498586ECF6A6}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Svc_dbepp", "..\plugins\Svc_dbepp\dbeditorpp_10.vcxproj", "{9C6040B8-1173-40FA-A3DB-DE044CCD8250}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Tipper", "..\plugins\TipperYM\tipper_ym_10.vcxproj", "{2C818919-A38F-44FF-BD91-A6A204AC592A}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TooltipNotify", "..\plugins\TooltipNotify\ttnotify_10.vcxproj", "{1948EAEA-4C25-4F6B-AD9E-5891F656EADA}" @@ -170,8 +168,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Facebook", "..\protocols\Fa EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Weather", "..\protocols\Weather\weather_10.vcxproj", "{6BFE3E13-BD5D-4C1C-BB29-A82FB51A16CE}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Svc_crshdmp", "..\plugins\Svc_crshdmp\crshdmp_10.vcxproj", "{576EEEFD-E423-482B-879A-F0515D40B8E1}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SpellChecker", "..\plugins\SpellChecker\spellchecker.vcxproj", "{5DB86086-10E9-42E7-AC90-503D2678C2A2}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Alarms", "..\plugins\Alarms\alarms_10.vcxproj", "{5F09C93B-463A-4BF5-A85E-6E4E916AA8F8}" @@ -198,8 +194,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ListeningTo", "..\plugins\L EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Omegle", "..\protocols\Omegle\omegle_10.vcxproj", "{D5E2FEC1-B29A-476C-BD41-469FE282EE0F}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Svc_vi", "..\plugins\Svc_vi\VersionInfo_10.vcxproj", "{3CE5572B-B7B0-4D1C-9D10-4622FBA6198E}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RC4", "..\plugins\Dbx_mmap_SA\Cryptors\RC4\rc4_10.vcxproj", "{E38B4212-53BC-49A7-B821-9A99DB4774C6}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Dbx_tree_ARC4", "..\plugins\Dbx_tree\encryption\ARC4.vcxproj", "{F60935E3-8F27-46E2-8598-013E7D4C90E7}" @@ -325,6 +319,12 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SendSS", "..\plugins\SendSc EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CheckSum", "..\tools\checksum\checksum_10.vcxproj", "{5153CD6C-6041-47CD-8BE3-2772326BB7C5}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DbeditorPP", "..\plugins\DbeditorPP\dbeditorpp_10.vcxproj", "{9C6040B8-1173-40FA-A3DB-DE044CCD8250}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CrashDumper", "..\plugins\CrashDumper\crshdmp_10.vcxproj", "{576EEEFD-E423-482B-879A-F0515D40B8E1}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VersionInfo", "..\plugins\VersionInfo\VersionInfo_10.vcxproj", "{3CE5572B-B7B0-4D1C-9D10-4622FBA6198E}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -893,14 +893,6 @@ Global {3E6CEC79-5E93-4607-B10E-498586ECF6A6}.Release|Win32.Build.0 = Release|Win32 {3E6CEC79-5E93-4607-B10E-498586ECF6A6}.Release|x64.ActiveCfg = Release|x64 {3E6CEC79-5E93-4607-B10E-498586ECF6A6}.Release|x64.Build.0 = Release|x64 - {9C6040B8-1173-40FA-A3DB-DE044CCD8250}.Debug|Win32.ActiveCfg = Debug|Win32 - {9C6040B8-1173-40FA-A3DB-DE044CCD8250}.Debug|Win32.Build.0 = Debug|Win32 - {9C6040B8-1173-40FA-A3DB-DE044CCD8250}.Debug|x64.ActiveCfg = Debug|x64 - {9C6040B8-1173-40FA-A3DB-DE044CCD8250}.Debug|x64.Build.0 = Debug|x64 - {9C6040B8-1173-40FA-A3DB-DE044CCD8250}.Release|Win32.ActiveCfg = Release|Win32 - {9C6040B8-1173-40FA-A3DB-DE044CCD8250}.Release|Win32.Build.0 = Release|Win32 - {9C6040B8-1173-40FA-A3DB-DE044CCD8250}.Release|x64.ActiveCfg = Release|x64 - {9C6040B8-1173-40FA-A3DB-DE044CCD8250}.Release|x64.Build.0 = Release|x64 {2C818919-A38F-44FF-BD91-A6A204AC592A}.Debug|Win32.ActiveCfg = Debug|Win32 {2C818919-A38F-44FF-BD91-A6A204AC592A}.Debug|Win32.Build.0 = Debug|Win32 {2C818919-A38F-44FF-BD91-A6A204AC592A}.Debug|x64.ActiveCfg = Debug|x64 @@ -1013,14 +1005,6 @@ Global {6BFE3E13-BD5D-4C1C-BB29-A82FB51A16CE}.Release|Win32.Build.0 = Release|Win32 {6BFE3E13-BD5D-4C1C-BB29-A82FB51A16CE}.Release|x64.ActiveCfg = Release|x64 {6BFE3E13-BD5D-4C1C-BB29-A82FB51A16CE}.Release|x64.Build.0 = Release|x64 - {576EEEFD-E423-482B-879A-F0515D40B8E1}.Debug|Win32.ActiveCfg = Debug|Win32 - {576EEEFD-E423-482B-879A-F0515D40B8E1}.Debug|Win32.Build.0 = Debug|Win32 - {576EEEFD-E423-482B-879A-F0515D40B8E1}.Debug|x64.ActiveCfg = Debug|x64 - {576EEEFD-E423-482B-879A-F0515D40B8E1}.Debug|x64.Build.0 = Debug|x64 - {576EEEFD-E423-482B-879A-F0515D40B8E1}.Release|Win32.ActiveCfg = Release|Win32 - {576EEEFD-E423-482B-879A-F0515D40B8E1}.Release|Win32.Build.0 = Release|Win32 - {576EEEFD-E423-482B-879A-F0515D40B8E1}.Release|x64.ActiveCfg = Release|x64 - {576EEEFD-E423-482B-879A-F0515D40B8E1}.Release|x64.Build.0 = Release|x64 {5DB86086-10E9-42E7-AC90-503D2678C2A2}.Debug|Win32.ActiveCfg = Debug|Win32 {5DB86086-10E9-42E7-AC90-503D2678C2A2}.Debug|Win32.Build.0 = Debug|Win32 {5DB86086-10E9-42E7-AC90-503D2678C2A2}.Debug|x64.ActiveCfg = Debug|x64 @@ -1123,14 +1107,6 @@ Global {D5E2FEC1-B29A-476C-BD41-469FE282EE0F}.Release|Win32.Build.0 = Release|Win32 {D5E2FEC1-B29A-476C-BD41-469FE282EE0F}.Release|x64.ActiveCfg = Release|x64 {D5E2FEC1-B29A-476C-BD41-469FE282EE0F}.Release|x64.Build.0 = Release|x64 - {3CE5572B-B7B0-4D1C-9D10-4622FBA6198E}.Debug|Win32.ActiveCfg = Debug|Win32 - {3CE5572B-B7B0-4D1C-9D10-4622FBA6198E}.Debug|Win32.Build.0 = Debug|Win32 - {3CE5572B-B7B0-4D1C-9D10-4622FBA6198E}.Debug|x64.ActiveCfg = Debug|x64 - {3CE5572B-B7B0-4D1C-9D10-4622FBA6198E}.Debug|x64.Build.0 = Debug|x64 - {3CE5572B-B7B0-4D1C-9D10-4622FBA6198E}.Release|Win32.ActiveCfg = Release|Win32 - {3CE5572B-B7B0-4D1C-9D10-4622FBA6198E}.Release|Win32.Build.0 = Release|Win32 - {3CE5572B-B7B0-4D1C-9D10-4622FBA6198E}.Release|x64.ActiveCfg = Release|x64 - {3CE5572B-B7B0-4D1C-9D10-4622FBA6198E}.Release|x64.Build.0 = Release|x64 {E38B4212-53BC-49A7-B821-9A99DB4774C6}.Debug|Win32.ActiveCfg = Debug|Win32 {E38B4212-53BC-49A7-B821-9A99DB4774C6}.Debug|Win32.Build.0 = Debug|Win32 {E38B4212-53BC-49A7-B821-9A99DB4774C6}.Debug|x64.ActiveCfg = Debug|x64 @@ -1473,6 +1449,30 @@ Global {5153CD6C-6041-47CD-8BE3-2772326BB7C5}.Release|Win32.Build.0 = Release|Win32 {5153CD6C-6041-47CD-8BE3-2772326BB7C5}.Release|x64.ActiveCfg = Release|x64 {5153CD6C-6041-47CD-8BE3-2772326BB7C5}.Release|x64.Build.0 = Release|x64 + {9C6040B8-1173-40FA-A3DB-DE044CCD8250}.Debug|Win32.ActiveCfg = Debug|Win32 + {9C6040B8-1173-40FA-A3DB-DE044CCD8250}.Debug|Win32.Build.0 = Debug|Win32 + {9C6040B8-1173-40FA-A3DB-DE044CCD8250}.Debug|x64.ActiveCfg = Debug|x64 + {9C6040B8-1173-40FA-A3DB-DE044CCD8250}.Debug|x64.Build.0 = Debug|x64 + {9C6040B8-1173-40FA-A3DB-DE044CCD8250}.Release|Win32.ActiveCfg = Release|Win32 + {9C6040B8-1173-40FA-A3DB-DE044CCD8250}.Release|Win32.Build.0 = Release|Win32 + {9C6040B8-1173-40FA-A3DB-DE044CCD8250}.Release|x64.ActiveCfg = Release|x64 + {9C6040B8-1173-40FA-A3DB-DE044CCD8250}.Release|x64.Build.0 = Release|x64 + {576EEEFD-E423-482B-879A-F0515D40B8E1}.Debug|Win32.ActiveCfg = Debug|Win32 + {576EEEFD-E423-482B-879A-F0515D40B8E1}.Debug|Win32.Build.0 = Debug|Win32 + {576EEEFD-E423-482B-879A-F0515D40B8E1}.Debug|x64.ActiveCfg = Debug|x64 + {576EEEFD-E423-482B-879A-F0515D40B8E1}.Debug|x64.Build.0 = Debug|x64 + {576EEEFD-E423-482B-879A-F0515D40B8E1}.Release|Win32.ActiveCfg = Release|Win32 + {576EEEFD-E423-482B-879A-F0515D40B8E1}.Release|Win32.Build.0 = Release|Win32 + {576EEEFD-E423-482B-879A-F0515D40B8E1}.Release|x64.ActiveCfg = Release|x64 + {576EEEFD-E423-482B-879A-F0515D40B8E1}.Release|x64.Build.0 = Release|x64 + {3CE5572B-B7B0-4D1C-9D10-4622FBA6198E}.Debug|Win32.ActiveCfg = Debug|Win32 + {3CE5572B-B7B0-4D1C-9D10-4622FBA6198E}.Debug|Win32.Build.0 = Debug|Win32 + {3CE5572B-B7B0-4D1C-9D10-4622FBA6198E}.Debug|x64.ActiveCfg = Debug|x64 + {3CE5572B-B7B0-4D1C-9D10-4622FBA6198E}.Debug|x64.Build.0 = Debug|x64 + {3CE5572B-B7B0-4D1C-9D10-4622FBA6198E}.Release|Win32.ActiveCfg = Release|Win32 + {3CE5572B-B7B0-4D1C-9D10-4622FBA6198E}.Release|Win32.Build.0 = Release|Win32 + {3CE5572B-B7B0-4D1C-9D10-4622FBA6198E}.Release|x64.ActiveCfg = Release|x64 + {3CE5572B-B7B0-4D1C-9D10-4622FBA6198E}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1490,18 +1490,18 @@ Global {21F6C0E4-DD1A-49E6-82FD-64574BB902BD} = {A93476F5-9C4C-48A6-A8A4-C79D804A3228} {728CF16E-F3FF-4DEB-88C5-E9118F61ACD5} = {A93476F5-9C4C-48A6-A8A4-C79D804A3228} {5A6095F4-B037-4DA8-8410-8004A90C961A} = {A93476F5-9C4C-48A6-A8A4-C79D804A3228} - {9C6040B8-1173-40FA-A3DB-DE044CCD8250} = {A93476F5-9C4C-48A6-A8A4-C79D804A3228} {92E3BDEE-DD17-4619-AD61-70C0ADE04217} = {A93476F5-9C4C-48A6-A8A4-C79D804A3228} {3038EF69-85BE-4D92-9864-CD6A5EBB558A} = {A93476F5-9C4C-48A6-A8A4-C79D804A3228} - {576EEEFD-E423-482B-879A-F0515D40B8E1} = {A93476F5-9C4C-48A6-A8A4-C79D804A3228} {5F09C93B-463A-4BF5-A85E-6E4E916AA8F8} = {A93476F5-9C4C-48A6-A8A4-C79D804A3228} {F2ABCBFB-FEB8-49DF-B166-C2FA5148ACE1} = {A93476F5-9C4C-48A6-A8A4-C79D804A3228} {B57D997C-73E1-D5F7-ECCA-C204345C04A3} = {A93476F5-9C4C-48A6-A8A4-C79D804A3228} - {3CE5572B-B7B0-4D1C-9D10-4622FBA6198E} = {A93476F5-9C4C-48A6-A8A4-C79D804A3228} {F8776664-EFE8-CDD6-ACFD-3136E7FE2724} = {A93476F5-9C4C-48A6-A8A4-C79D804A3228} {7711F563-6473-4ABD-B5E3-477CE8384AD6} = {A93476F5-9C4C-48A6-A8A4-C79D804A3228} {129AC608-06B4-419C-8FEA-7DF5D90CE9D6} = {A93476F5-9C4C-48A6-A8A4-C79D804A3228} {73482497-9F57-4819-A9AB-5D841A9F072D} = {A93476F5-9C4C-48A6-A8A4-C79D804A3228} + {9C6040B8-1173-40FA-A3DB-DE044CCD8250} = {A93476F5-9C4C-48A6-A8A4-C79D804A3228} + {576EEEFD-E423-482B-879A-F0515D40B8E1} = {A93476F5-9C4C-48A6-A8A4-C79D804A3228} + {3CE5572B-B7B0-4D1C-9D10-4622FBA6198E} = {A93476F5-9C4C-48A6-A8A4-C79D804A3228} {B8928210-546C-4AE3-956B-E2B724E6B8E5} = {87D96006-542C-4396-87EF-68E3C3D2797F} {99D26CA1-BFD4-4E77-9A1E-919E54CF33F7} = {87D96006-542C-4396-87EF-68E3C3D2797F} {F47EAB99-C78F-4A92-87D5-B0E16FE5A133} = {87D96006-542C-4396-87EF-68E3C3D2797F} diff --git a/plugins/CrashDumper/Vi show.ico b/plugins/CrashDumper/Vi show.ico new file mode 100644 index 0000000000..55556862f3 Binary files /dev/null and b/plugins/CrashDumper/Vi show.ico differ diff --git a/plugins/CrashDumper/Vi to clipboard.ico b/plugins/CrashDumper/Vi to clipboard.ico new file mode 100644 index 0000000000..6f095b59b1 Binary files /dev/null and b/plugins/CrashDumper/Vi to clipboard.ico differ diff --git a/plugins/CrashDumper/Vi to file.ico b/plugins/CrashDumper/Vi to file.ico new file mode 100644 index 0000000000..abfc196437 Binary files /dev/null and b/plugins/CrashDumper/Vi to file.ico differ diff --git a/plugins/CrashDumper/Vi upload.ico b/plugins/CrashDumper/Vi upload.ico new file mode 100644 index 0000000000..4c562b02b8 Binary files /dev/null and b/plugins/CrashDumper/Vi upload.ico differ diff --git a/plugins/CrashDumper/Vi.ico b/plugins/CrashDumper/Vi.ico new file mode 100644 index 0000000000..371aeb345e Binary files /dev/null and b/plugins/CrashDumper/Vi.ico differ diff --git a/plugins/CrashDumper/bkstring.cpp b/plugins/CrashDumper/bkstring.cpp new file mode 100644 index 0000000000..418cb0bd83 --- /dev/null +++ b/plugins/CrashDumper/bkstring.cpp @@ -0,0 +1,188 @@ +/* +Miranda Crash Dumper Plugin +Copyright (C) 2008 - 2012 Boris Krasnovskiy All Rights Reserved + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation version 2 +of the License. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#include "bkstring.h" + +bkstring::~bkstring() { if (sizeAlloced) free(buf); } + + +void bkstring::reserve(size_type len) +{ + if (len >= sizeAlloced || sizeAlloced == 0) + { + if (sizeAlloced == 0) buf = NULL; + buf = (value_type*)realloc(buf, (len+1) * sizeof(value_type)); + if (sizeAlloced == 0) buf[0] = 0; + sizeAlloced = len+1; + } +} + +void bkstring::appendfmt(const value_type *fmt, ...) +{ + areserve(_tcslen(fmt)*2); + + va_list vararg; + va_start(vararg, fmt); + for (;;) + { + int len = _vsntprintf(buf + lenBuf, sizeAlloced - lenBuf - 1, fmt, vararg); + if (len < 0) + reserve(sizeAlloced + 256); + else + { + lenBuf += len; + buf[lenBuf] = 0; + break; + } + } + va_end(vararg); +} + +bkstring& bkstring::append(const value_type* _Ptr) +{ + size_type len = _tcslen(_Ptr); + areserve(len); + memcpy(buf+lenBuf, _Ptr, (len+1)*sizeof(value_type)); + lenBuf += len; + return *this; +} + +bkstring& bkstring::append(const value_type* _Ptr, size_type _Count) +{ + size_type len = min(_tcslen(_Ptr), _Count); + areserve(len); + memcpy(buf+lenBuf, _Ptr, len*sizeof(value_type)); + lenBuf += len; + buf[lenBuf] = 0; + return *this; +} + +bkstring& bkstring::append(const bkstring& _Str, size_type _Off, size_type _Count) +{ + size_type len = min(_Count, _Str.size() - _Off); + areserve(len); + memcpy(buf+lenBuf, _Str.c_str()+_Off, len*sizeof(value_type)); + lenBuf += len; + buf[lenBuf] = 0; + return *this; +} + +bkstring& bkstring::append(const bkstring& _Str) +{ + size_type len = _Str.size(); + areserve(len); + memcpy(buf+lenBuf, _Str.c_str(), len*sizeof(value_type)); + lenBuf += len; + buf[lenBuf] = 0; + return *this; +} + +bkstring& bkstring::append(size_type _Count, value_type _Ch) +{ + areserve(_Count); + for(size_type i=0; i<_Count; ++i) buf[lenBuf+i] = _Ch; + lenBuf += _Count; + buf[lenBuf] = 0; + return *this; +} + + +bkstring& bkstring::assign(const value_type* _Ptr, size_type _Count) +{ + reserve(_Count); + memcpy(buf, _Ptr, _Count*sizeof(value_type)); + buf[_Count] = 0; + lenBuf = _Count; + return *this; +} + +bkstring& bkstring::assign(const bkstring& _Str, size_type _Off, size_type _Count) +{ + size_type len = min(_Count, _Str.size() - _Off); + reserve(len); + memcpy(buf, _Str.c_str() + _Off, len*sizeof(value_type)); + lenBuf = len; + buf[len] = 0; + return *this; +} + +bkstring& bkstring::assign(size_type _Count, value_type _Ch) +{ + reserve(_Count); + for(size_type i=0; i<_Count; ++i) buf[i] = _Ch; + buf[_Count] = 0; + lenBuf = _Count; + return *this; +} + +bkstring::size_type bkstring::find(value_type _Ch, size_type _Off) const +{ + for (size_type i=_Off; i<=lenBuf; ++i) + if (buf[i] == _Ch) return i; + return (size_type)npos; +} + +bkstring::size_type bkstring::find(const value_type* _Ptr, size_type _Off) const +{ + if (_Off > lenBuf) return (size_type)npos; + + value_type* pstr = _tcsstr(buf+_Off, _Ptr); + return pstr ? pstr - buf : npos; +} + +bkstring::size_type bkstring::find_last_of(value_type _Ch, size_type _Off) const +{ + for (size_type i=(_Off == npos ? lenBuf : _Off); i--;) + if (buf[i] == _Ch) return i; + return (size_type)npos; +} + +bkstring& bkstring::insert(size_type _P0, const value_type* _Ptr, size_type _Count) +{ + size_type len = _tcslen(_Ptr); + if (_Count < len) len = _Count; + areserve(len); + value_type *p = buf + _P0; + memmove(p+len, p, (lenBuf-_P0+1)*sizeof(value_type)); + memcpy(p, _Ptr, _Count*sizeof(value_type)); + lenBuf += len; + return *this; +} + +bkstring& bkstring::insert(size_type _P0, size_type _Count, value_type _Ch) +{ + areserve(_Count); + value_type *p = buf + _P0; + memmove(p+_Count, p, (lenBuf-_P0+1)*sizeof(value_type)); + for(size_type i=0; i<_Count; ++i) p[i] = _Ch; + lenBuf += _Count; + return *this; +} + +bkstring& bkstring::erase(size_type _Pos, size_type _Count) +{ + if (_Pos < lenBuf) + { + const size_type len = min(lenBuf - _Pos, _Count); + value_type *p = buf + _Pos; + lenBuf -= len; + memmove(p, p+len, (lenBuf - _Pos)*sizeof(value_type)); + buf[lenBuf] = 0; + } + return *this; +} diff --git a/plugins/CrashDumper/bkstring.h b/plugins/CrashDumper/bkstring.h new file mode 100644 index 0000000000..a546bb8bc8 --- /dev/null +++ b/plugins/CrashDumper/bkstring.h @@ -0,0 +1,276 @@ +/* +Miranda Crash Dumper Plugin +Copyright (C) 2008 - 2012 Boris Krasnovskiy All Rights Reserved + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation version 2 +of the License. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef _BKSTRING_H_ +#define _BKSTRING_H_ + +#include +#include +#include +#include +#include + +#ifndef min +#define min(A, B) ((A) < (B) ? (A) : (B)) +#endif + +class bkstring +{ +public: + typedef size_t size_type; + typedef TCHAR value_type; + typedef value_type* iterator; + typedef const value_type* const_iterator; + +#if defined(_MSC_VER) && _MSC_VER > 1200 + static const size_type npos = size_type(-1); +#else + enum { npos = -1 }; +#endif + +private: + value_type* buf; + size_type sizeAlloced; + size_type lenBuf; + + void areserve(size_type len) { reserve(lenBuf + len); } + +public: + + explicit bkstring() : buf((TCHAR*)_T("")), sizeAlloced(0), lenBuf(0) + {} + + bkstring(const value_type* _Ptr, size_type _Count) : sizeAlloced(0), lenBuf(0) + { assign(_Ptr, _Count); } + + bkstring(const value_type* _Ptr) : sizeAlloced(0), lenBuf(0) + { assign(_Ptr); } + + bkstring(size_type _Count, value_type _Ch) : sizeAlloced(0), lenBuf(0) + { assign(_Count, _Ch); } + + bkstring(const bkstring& _Str) : sizeAlloced(0), lenBuf(0) + { assign(_Str); } + + bkstring(const bkstring& _Str, size_type _Off, size_type _Count) : sizeAlloced(0), lenBuf(0) + { assign(_Str, _Off, _Count); } + + ~bkstring(); + + size_type size(void) const { return lenBuf; } + const value_type* c_str(void) const { return buf; } + + void clear(void) { if (lenBuf) { lenBuf = 0; buf[0] = 0; } } + void insert(const value_type *txt); + void reserve(size_type len); + + bkstring& assign(const value_type* _Ptr) + { return assign(_Ptr, _tcslen(_Ptr)); } + + bkstring& assign(const bkstring& _Str) + { return assign(_Str, 0, (size_type)npos); } + + bkstring& assign(const value_type* _Ptr, size_type _Count); + bkstring& assign(const bkstring& _Str, size_type off, size_type _Count); + bkstring& assign(size_type _Count, value_type _Ch); + + bkstring& append(const value_type* _Ptr); + bkstring& append(const value_type* _Ptr, size_type _Count); + bkstring& append(const bkstring& _Str, size_type _Off, size_type _Count); + bkstring& append(const bkstring& _Str); + bkstring& append(size_type _Count, value_type _Ch); + + int compare(const bkstring& _Str) const + { return _tcscmp(buf, _Str.c_str()); } + + int compare(size_type _Pos1, size_type _Num1, const bkstring& _Str) const + { return _tcsncmp(&buf[_Pos1], _Str.c_str(), _Num1); } + + int compare(size_type _Pos1, size_type _Num1, const bkstring& _Str, size_type _Off, size_type _Count) const + { return _tcsncmp(&buf[_Pos1], _Str.c_str()+_Off, min(_Num1, _Count)); } + + int compare(const value_type* _Ptr) const + { return _tcscmp(buf, _Ptr); } + + int compare(size_type _Pos1, size_type _Num1, const value_type* _Ptr) const + { return _tcsncmp(&buf[_Pos1], _Ptr, _Num1); } + + int compare(size_type _Pos1, size_type _Num1, const value_type* _Ptr, size_type _Num2) const + { return _tcsncmp(&buf[_Pos1], _Ptr, min(_Num1, _Num2)); } + + int comparei(const bkstring& _Str) const + { return _tcsicmp(buf, _Str.c_str()); } + + int comparei(size_type _Pos1, size_type _Num1, const bkstring& _Str) const + { return _tcsnicmp(&buf[_Pos1], _Str.c_str(), _Num1); } + + int comparei(size_type _Pos1, size_type _Num1, const bkstring& _Str, size_type _Off, size_type _Count) const + { return _tcsnicmp(&buf[_Pos1], _Str.c_str()+_Off, min(_Num1, _Count)); } + + int comparei(const value_type* _Ptr) const + { return _tcsicmp(buf, _Ptr); } + + int comparei(size_type _Pos1, size_type _Num1, const value_type* _Ptr) const + { return _tcsnicmp(&buf[_Pos1], _Ptr, _Num1); } + + int comparei(size_type _Pos1, size_type _Num1, const value_type* _Ptr, size_type _Num2) const + { return _tcsnicmp(&buf[_Pos1], _Ptr, min(_Num1, _Num2)); } + + bool empty(void) const { return lenBuf == 0; }; + bkstring& erase(size_type _Pos = 0, size_type _Count = npos); + + size_type find(value_type _Ch, size_type _Off = 0) const; + size_type find(const value_type* _Ptr, size_type _Off = 0) const; + size_type find(bkstring& _Str, size_type _Off = 0) const + { return find(_Str.c_str(), _Off); } + + size_type find_last_of(value_type _Ch, size_type _Off = npos) const; + + bkstring& insert(size_type _P0, const value_type* _Ptr) + { return insert(_P0, _Ptr, _tcslen(_Ptr)); } + + bkstring& insert(size_type _P0, const bkstring& _Str) + { return insert(_P0, _Str.c_str(), _Str.size()); }; + + bkstring& insert(size_type _P0, const value_type* _Ptr, size_type _Count); + bkstring& insert(size_type _P0, size_type _Count, value_type _Ch); + + bkstring substr(size_type _Off = 0, size_type _Count = npos) const + { return bkstring(*this, _Off, _Count); } + + bkstring& operator = (const bkstring& _Str) + { return assign(_Str); } + + bkstring& operator =(const value_type* _Ptr) + { return assign(_Ptr); } + + bkstring& operator = (const value_type _Ch) + { return assign(1, _Ch); } + + bkstring& operator +=(const bkstring& _Str) + { return append(_Str); } + + bkstring& operator += (const value_type* _Ptr) + { return append(_Ptr); } + + bkstring& operator += (const value_type _Ch) + { return append(1, _Ch); } + + value_type& operator[] (int ind) const + { return buf[ind]; } + + friend bkstring operator+ (const bkstring& _Str1, const bkstring& _Str2) + { bkstring s(_Str1); return s.append(_Str2); } + + friend bkstring operator+ (const bkstring& _Str1, const value_type* _Ptr2) + { bkstring s(_Str1); return s.append(_Ptr2); } + + friend bkstring operator+(const value_type* _Ptr1, const bkstring& _Str2) + { bkstring s(_Ptr1); return s.append(_Str2); } + + friend bkstring operator+ (const bkstring& _Str1, const value_type _Ch) + { bkstring s(_Str1); return s.append(1, _Ch); } + + friend bool operator==(const bkstring& _Str1, const bkstring& _Str2) + { return _Str1.compare(_Str2) == 0; } + + friend bool operator==(const bkstring& _Str1, const value_type* _Ptr2) + { return _Str1.compare(_Ptr2) == 0; } + + friend bool operator==(const value_type* _Ptr1, const bkstring& _Str2) + { return _Str2.compare(_Ptr1) == 0; } + + friend bool operator!=(const bkstring& _Str1, const bkstring& _Str2) + { return _Str1.compare(_Str2) != 0; } + + friend bool operator!=(const bkstring& _Str1, const value_type* _Ptr2) + { return _Str1.compare(_Ptr2) != 0; } + + friend bool operator!=(const value_type* _Ptr1, const bkstring& _Str2) + { return _Str2.compare(_Ptr1) != 0; } + + friend bool operator<(const bkstring& _Str1, const bkstring& _Str2) + { return _Str1.compare(_Str2) < 0; } + + friend bool operator<(const bkstring& _Str1, const value_type* _Ptr2) + { return _Str1.compare(_Ptr2) < 0; } + + friend bool operator<(const value_type* _Ptr1, const bkstring& _Str2) + { return _Str2.compare(_Ptr1) > 0; } + + friend bool operator>(const bkstring& _Str1, const bkstring& _Str2) + { return _Str1.compare(_Str2) > 0; } + + friend bool operator>(const bkstring& _Str1, const value_type* _Ptr2) + { return _Str1.compare(_Ptr2) > 0; } + + friend bool operator>(const value_type* _Ptr1, const bkstring& _Str2) + { return _Str2.compare(_Ptr1) < 0; } + + friend bool operator<=(const bkstring& _Str1, const bkstring& _Str2) + { return _Str1.compare(_Str2) <= 0; } + + friend bool operator<=(const bkstring& _Str1, const value_type* _Ptr2) + { return _Str1.compare(_Ptr2) <= 0; } + + friend bool operator<=(const value_type* _Ptr1, const bkstring& _Str2) + { return _Str2.compare(_Ptr1) >= 0; } + + friend bool operator>=(const bkstring& _Str1, const bkstring& _Str2) + { return _Str1.compare(_Str2) >= 0; } + + friend bool operator>=(const bkstring& _Str1, const value_type* _Ptr2) + { return _Str1.compare(_Ptr2) >= 0; } + + friend bool operator>=(const value_type* _Ptr1, const bkstring& _Str2) + { return _Str2.compare(_Ptr1) <= 0; } + + friend bool operator==(const value_type _Ch1, const bkstring& _Str2) + { return (_Str2.size() == 1) && (_Str2[0] == _Ch1); } + + friend bool operator==(const bkstring& _Str1, const value_type _Ch2) + { return (_Str1.size() == 1) && (_Str1[0] == _Ch2); } + + friend bool operator!=(const value_type _Ch1, const bkstring& _Str2) + { return (_Str2.size() != 1) || (_Str2[0] != _Ch1); } + + friend bool operator!=(const bkstring& _Str1, const value_type _Ch2) + { return (_Str1.size() != 1) || (_Str1[0] != _Ch2); } + + iterator begin(void) + { return buf; } + + const_iterator begin(void) const + { return buf; } + + iterator end(void) + { return buf + lenBuf; } + + const_iterator end(void) const + { return buf + lenBuf; } + + // Custom extentions + + void appendfmt(const value_type *fmt, ...); + + size_type sizebytes(void) const { return lenBuf * sizeof(value_type); } +}; + +//const bkstring::size_type bkstring::npos = -1; + +#endif diff --git a/plugins/CrashDumper/crshdmp.cpp b/plugins/CrashDumper/crshdmp.cpp new file mode 100644 index 0000000000..72ffac7f44 --- /dev/null +++ b/plugins/CrashDumper/crshdmp.cpp @@ -0,0 +1,434 @@ +/* +Miranda Crash Dumper Plugin +Copyright (C) 2008 - 2012 Boris Krasnovskiy All Rights Reserved + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation version 2 +of the License. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#include "utils.h" +#include +#include "m_folders.h" +#include "m_toptoolbar.h" +#include "version.h" + +int hLangpack; + +HINSTANCE hInst; +DWORD mirandaVersion; +LCID packlcid; +HANDLE hCrashLogFolder, hVerInfoFolder; +HMODULE hRichModule; + +TCHAR* vertxt; +TCHAR* profname; +TCHAR* profpath; + +TCHAR CrashLogFolder[MAX_PATH]; +TCHAR VersionInfoFolder[MAX_PATH]; + +bool servicemode; +bool clsdates; +bool dtsubfldr; + +static const PLUGININFOEX pluginInfoEx = +{ + sizeof(PLUGININFOEX), + "Crash Dumper", + __VERSION_DWORD, + "Crash Dumper for Miranda IM.", + "borkra", + "borkra@miranda-im.org", + "Copyright© 2008 - 2012 Boris Krasnovskiy All Rights Reserved", + "http://code.google.com/p/mirandaimplugins/downloads/list", + UNICODE_AWARE, + // {F62C1D7A-FFA4-4065-A251-4C9DD9101CC8} + { 0xf62c1d7a, 0xffa4, 0x4065, { 0xa2, 0x51, 0x4c, 0x9d, 0xd9, 0x10, 0x1c, 0xc8 } } +}; + +const PLUGININFOEX* GetPluginInfoEx(void) { return &pluginInfoEx; } + + +extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirVersion) +{ + ::mirandaVersion = mirVersion; + return (PLUGININFOEX*)&pluginInfoEx; +} + +#define MIID_CRASHDUMP { 0x36a31a50, 0xcb55, 0x46d0, { 0xab, 0x9c, 0x1e, 0xac, 0xfb, 0x24, 0x0, 0x2a } } + +// MirandaInterfaces - returns the protocol interface to the core +extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_SERVICEMODE, MIID_CRASHDUMP, MIID_LAST }; + +HANDLE hHooks[5]; +HANDLE hServices[6]; + + +INT_PTR StoreVersionInfoToFile(WPARAM, LPARAM lParam) +{ + CreateDirectoryTree(VersionInfoFolder); + + TCHAR path[MAX_PATH]; + crs_sntprintf(path, MAX_PATH, TEXT("%s\\VersionInfo.txt"), VersionInfoFolder); + + HANDLE hDumpFile = CreateFile(path, GENERIC_WRITE, 0, NULL, + CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + + if (hDumpFile != INVALID_HANDLE_VALUE) + { + bkstring buffer; + + buffer.reserve(0x1800); + PrintVersionInfo(buffer, (unsigned int)lParam | VI_FLAG_PRNVAR); + + char* bufu = mir_utf8encodeT(buffer.c_str()); + WriteUtfFile(hDumpFile, bufu); + mir_free(bufu); + + CloseHandle(hDumpFile); + + ShowMessage(3, TranslateT("VersionInfo stored into file %s"), path); + } + else + ShowMessage(2, TranslateT("VersionInfo file %s is inaccessible"), path); + + return 0; +} + +INT_PTR StoreVersionInfoToClipboard(WPARAM, LPARAM lParam) +{ + bkstring buffer; + buffer.reserve(0x1800); + + WriteBBFile(buffer, true); + PrintVersionInfo(buffer, (unsigned int)lParam | VI_FLAG_PRNVAR | VI_FLAG_FORMAT); + WriteBBFile(buffer, false); + + StoreStringToClip(buffer); + + return 0; +} + +INT_PTR UploadVersionInfo(WPARAM, LPARAM lParam) +{ + bkstring buffer; + buffer.reserve(0x1800); + PrintVersionInfo(buffer); + + VerTrnsfr *trn = (VerTrnsfr*)mir_alloc(sizeof(VerTrnsfr)); + trn->buf = mir_utf8encodeT(buffer.c_str()); + trn->autot = lParam == 0xa1; + + mir_forkthread(VersionInfoUploadThread, trn); + + return 0; +} + + +INT_PTR ViewVersionInfo(WPARAM wParam, LPARAM) +{ + // unsigned *p = (unsigned*)0x15; + // *p = 324; + + if (hRichModule == NULL && GetModuleHandle(TEXT("Riched20.dll")) == NULL) + hRichModule = LoadLibrary(TEXT("Riched20.dll")); + + CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_VIEWVERSION), NULL, + DlgProcView, wParam ? (VI_FLAG_PRNVAR | VI_FLAG_PRNDLL) : VI_FLAG_PRNVAR); + + return 0; +} + +INT_PTR OpenUrl(WPARAM wParam, LPARAM) +{ + switch (wParam) + { + case 0: + ShellExecute(NULL, TEXT("explore"), CrashLogFolder, NULL, NULL, SW_SHOW); + break; + + case 1: + OpenAuthUrl("http://%s.miranda-vi.org"); + break; + } + return 0; +} + +INT_PTR ServiceModeLaunch(WPARAM, LPARAM) +{ + servicemode = true; + return 0; +} + + +static int FoldersPathChanged(WPARAM, LPARAM) +{ + FOLDERSGETDATA fgd = {0}; + fgd.cbSize = sizeof(FOLDERSGETDATA); + fgd.nMaxPathSize = MAX_PATH; + fgd.szPathT = CrashLogFolder; + CallService(MS_FOLDERS_GET_PATH, (WPARAM) hCrashLogFolder, (LPARAM) &fgd); + + fgd.szPathT = VersionInfoFolder; + CallService(MS_FOLDERS_GET_PATH, (WPARAM) hVerInfoFolder, (LPARAM) &fgd); + return 0; +} + +int OptionsInit(WPARAM wParam, LPARAM) +{ + OPTIONSDIALOGPAGE odp = { 0 }; + + odp.cbSize = sizeof(odp); + odp.position = -790000000; + odp.hInstance = hInst; + odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS); + odp.pszTitle = (char*)PluginName; + odp.pszGroup = LPGEN("Services"); + odp.flags = ODPF_BOLDGROUPS; + odp.pfnDlgProc = DlgProcOptions; + Options_AddPage(wParam, &odp); + + return 0; +} + +static int ToolbarModulesLoaded(WPARAM, LPARAM) +{ + TTBButton tbb = {0}; + tbb.cbSize = sizeof(TTBButton); + + tbb.pszService = MS_CRASHDUMPER_STORETOCLIP; + tbb.name = tbb.pszTooltipUp = LPGEN("Version Information To Clipboard"); + tbb.hIconHandleUp = GetIconHandle("storeToClip"); + tbb.dwFlags = TTBBF_VISIBLE; + TopToolbar_AddButton(&tbb); + + tbb.pszService = MS_CRASHDUMPER_STORETOFILE; + tbb.name = tbb.pszTooltipUp = LPGEN("Version Information To File"); + tbb.hIconHandleUp = GetIconHandle("storeToFile"); + tbb.dwFlags = 0; + TopToolbar_AddButton(&tbb); + + tbb.pszService = MS_CRASHDUMPER_VIEWINFO; + tbb.name = tbb.pszTooltipUp = LPGEN("Show Version Information"); + tbb.hIconHandleUp = GetIconHandle("showInfo"); + TopToolbar_AddButton(&tbb); + + tbb.pszService = MS_CRASHDUMPER_UPLOAD; + tbb.name = tbb.pszTooltipUp = LPGEN("Upload Version Information"); + tbb.hIconHandleUp = GetIconHandle("uploadInfo"); + TopToolbar_AddButton(&tbb); + return 0; +} + +static int ModulesLoaded(WPARAM, LPARAM) +{ + char temp[MAX_PATH]; + CallService(MS_SYSTEM_GETVERSIONTEXT, (WPARAM)SIZEOF(temp), (LPARAM)temp); + crs_a2t(vertxt, temp); + + profname = Utils_ReplaceVarsT(_T("%miranda_profilename%.dat")); + if (ServiceExists(MS_FOLDERS_REGISTER_PATH)) + { + profpath = _T("%miranda_userdata%"); + } + else + { + profpath = Utils_ReplaceVarsT(_T("%miranda_userdata%")); + } + + crs_sntprintf(CrashLogFolder, MAX_PATH, TEXT("%s\\CrashLog"), profpath); + crs_sntprintf(VersionInfoFolder, MAX_PATH, TEXT("%s"), profpath); + + SetExceptionHandler(); + + hCrashLogFolder = FoldersRegisterCustomPathT(PluginName, "Crash Reports", CrashLogFolder); + hVerInfoFolder = FoldersRegisterCustomPathT(PluginName, "Version Information", VersionInfoFolder); + + FoldersPathChanged(0, 0); + + + + hHooks[2] = HookEvent(ME_FOLDERS_PATH_CHANGED, FoldersPathChanged); + if (hHooks[3] == NULL) hHooks[3] = HookEvent(ME_TTB_MODULELOADED, ToolbarModulesLoaded); + + UploadInit(); + + CLISTMENUITEM mi = { 0 }; + + mi.cbSize = sizeof(mi); + + mi.popupPosition = 2000089999; + mi.position = 2000089999; + mi.flags = CMIF_ROOTPOPUP | CMIF_ICONFROMICOLIB | CMIF_TCHAR; + mi.icolibItem = GetIconHandle("versionInfo"); + mi.ptszName = LPGENT("Version Information"); + mi.pszPopupName = (char *)-1; + HANDLE hMenuRoot = Menu_AddMainMenuItem(&mi); + + mi.flags = CMIF_CHILDPOPUP | CMIF_ICONFROMICOLIB | CMIF_TCHAR; + mi.pszPopupName = (char *)hMenuRoot; + mi.popupPosition = 0; + + mi.position = 2000089995; + mi.ptszName = LPGENT("Copy to clipboard"); + mi.icolibItem = GetIconHandle("storeToClip"); + mi.pszService = MS_CRASHDUMPER_STORETOCLIP; + Menu_AddMainMenuItem(&mi); + + mi.position = 2000089996; + mi.ptszName = LPGENT("Store to file"); + mi.icolibItem = GetIconHandle("storeToFile"); + mi.pszService = MS_CRASHDUMPER_STORETOFILE; + Menu_AddMainMenuItem(&mi); + + mi.position = 2000089997; + mi.ptszName = LPGENT("Show"); + mi.icolibItem = GetIconHandle("showInfo"); + mi.pszService = MS_CRASHDUMPER_VIEWINFO; + Menu_AddMainMenuItem(&mi); + + mi.popupPosition = 1; + mi.position = 2000089998; + mi.ptszName = LPGENT("Show with DLLs"); + mi.icolibItem = GetIconHandle("showInfo"); + mi.pszService = MS_CRASHDUMPER_VIEWINFO; + Menu_AddMainMenuItem(&mi); + + mi.popupPosition = 0; + mi.position = 2000089999; + mi.ptszName = LPGENT("Upload"); + mi.icolibItem = GetIconHandle("uploadInfo"); + mi.pszService = MS_CRASHDUMPER_UPLOAD; + Menu_AddMainMenuItem(&mi); + + mi.position = 2000099990; + mi.ptszName = LPGENT("Open crash report directory"); + mi.icolibItem = LoadSkinnedIconHandle(SKINICON_EVENT_FILE); + mi.pszService = MS_CRASHDUMPER_URL; + Menu_AddMainMenuItem(&mi); + + mi.popupPosition = 1; + mi.position = 2000099991; + mi.ptszName = LPGENT("Open miranda-vi.org"); + mi.icolibItem = LoadSkinnedIconHandle(SKINICON_EVENT_URL); + mi.pszService = MS_CRASHDUMPER_URL; + Menu_AddMainMenuItem(&mi); + + HOTKEYDESC hk = {0}; + hk.cbSize = sizeof(hk); + hk.pszSection = PluginName; + + hk.pszDescription = LPGEN("Copy Version Info to clipboard"); + hk.pszName = "CopyVerInfo"; + hk.pszService = MS_CRASHDUMPER_STORETOCLIP; + Hotkey_Register(&hk); + + hk.pszDescription = LPGEN("Show Version Info"); + hk.pszName = "ShowVerInfo"; + hk.pszService = MS_CRASHDUMPER_VIEWINFO; + Hotkey_Register(&hk); + + if (servicemode) ViewVersionInfo(0, 0); + else + { + if (DBGetContactSettingByte(NULL, PluginName, "UploadChanged", 0) && !ProcessVIHash(false)) + UploadVersionInfo(0, 0xa1); + } + + CheckForOtherCrashReportingPlugins(); + return 0; +} + +static int PreShutdown(WPARAM, LPARAM) +{ + unsigned i; + + DestroyAllWindows(); + UploadClose(); + + for (i=0; i + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + Svc_crshdmp + {576EEEFD-E423-482B-879A-F0515D40B8E1} + + + + DynamicLibrary + Unicode + + + DynamicLibrary + Unicode + true + + + DynamicLibrary + Unicode + + + DynamicLibrary + Unicode + true + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.311 + $(SolutionDir)$(Configuration)\Plugins\ + $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)64\Plugins\ + $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)\Plugins\ + $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)64\Plugins\ + $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ + true + + + + Full + Size + true + ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + false + false + false + Fast + Level3 + OnlyExplicitInline + + + dbghelp.lib;%(AdditionalDependencies) + dbghelp.dll;%(DelayLoadDLLs) + true + Windows + true + true + true + $(IntDir)$(TargetName).lib + false + $(SolutionDir)\lib + + + ..\..\include\msapi + NDEBUG;%(PreprocessorDefinitions) + + + + + Full + Size + true + ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + WIN64;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + false + false + false + Fast + Level3 + OnlyExplicitInline + + + dbghelp.lib;%(AdditionalDependencies) + dbghelp.dll;%(DelayLoadDLLs) + true + Windows + true + true + true + $(IntDir)$(TargetName).lib + false + $(SolutionDir)\lib + + + ..\..\include\msapi + NDEBUG;%(PreprocessorDefinitions) + + + + + Disabled + ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + Fast + Level3 + EditAndContinue + + + dbghelp.lib;%(AdditionalDependencies) + dbghelp.dll;%(DelayLoadDLLs) + true + Windows + true + $(IntDir)$(TargetName).lib + false + $(SolutionDir)\lib + + + ..\..\include\msapi + _DEBUG;%(PreprocessorDefinitions) + + + + + Disabled + ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + WIN64;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + Fast + Level3 + + + dbghelp.lib;%(AdditionalDependencies) + dbghelp.dll;%(DelayLoadDLLs) + true + Windows + true + $(IntDir)$(TargetName).lib + false + $(SolutionDir)\lib + + + ..\..\include\msapi + _DEBUG;%(PreprocessorDefinitions) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/plugins/CrashDumper/crshdmp_icons.cpp b/plugins/CrashDumper/crshdmp_icons.cpp new file mode 100644 index 0000000000..1f7106303f --- /dev/null +++ b/plugins/CrashDumper/crshdmp_icons.cpp @@ -0,0 +1,88 @@ +/* +Miranda Crash Dumper Plugin +Copyright (C) 2008 - 2012 Boris Krasnovskiy All Rights Reserved + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation version 2 +of the License. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#include "utils.h" +#include + +struct _tag_iconList +{ + const char* szDescr; + const char* szName; + int defIconID; +} +static const iconList[] = +{ + { "Version Information", "versionInfo", IDI_VI }, + { "Copy To Clipboard", "storeToClip", IDI_VITOCLIP }, + { "Store to file", "storeToFile", IDI_VITOFILE }, + { "Show", "showInfo", IDI_VISHOW }, + { "Upload", "uploadInfo", IDI_VIUPLOAD }, +}; + +static HANDLE hIconLibItem[SIZEOF(iconList)]; + +void InitIcons(void) +{ + char szFile[MAX_PATH]; + char szSettingName[100]; + SKINICONDESC sid = {0}; + + sid.cbSize = sizeof(SKINICONDESC); + sid.pszDefaultFile = szFile; + sid.pszName = szSettingName; + sid.pszSection = (char*)PluginName; + + GetModuleFileNameA(hInst, szFile, MAX_PATH); + + for (unsigned i = 0; i < SIZEOF(iconList); i++) + { + mir_snprintf(szSettingName, sizeof(szSettingName), "%s_%s", PluginName, iconList[i].szName); + + sid.pszDescription = (char*)iconList[i].szDescr; + sid.iDefaultIndex = -iconList[i].defIconID; + hIconLibItem[i] = Skin_AddIcon(&sid); + } +} + +HICON LoadIconEx(const char* name, bool big) +{ + char szSettingName[100]; + mir_snprintf(szSettingName, sizeof(szSettingName), "%s_%s", PluginName, name); + return (HICON)CallService(MS_SKIN2_GETICON, big, (LPARAM)szSettingName); +} + +HANDLE GetIconHandle(const char* name) +{ + unsigned i; + for (i=0; i < SIZEOF(iconList); i++) + if (strcmp(iconList[i].szName, name) == 0) + return hIconLibItem[i]; + return NULL; +} + +void ReleaseIconEx(const char* name) +{ + char szSettingName[100]; + mir_snprintf(szSettingName, sizeof(szSettingName), "%s_%s", PluginName, name); + CallService(MS_SKIN2_RELEASEICON, 0, (LPARAM)szSettingName); +} + +void ReleaseIconEx(HICON hIcon) +{ + CallService(MS_SKIN2_RELEASEICON, (WPARAM)hIcon, 0); +} diff --git a/plugins/CrashDumper/crshdmp_readme.txt b/plugins/CrashDumper/crshdmp_readme.txt new file mode 100644 index 0000000000..f4e1ff92ac --- /dev/null +++ b/plugins/CrashDumper/crshdmp_readme.txt @@ -0,0 +1,379 @@ +Crash Dumper plugin for Miranda IM +===================================================================== +Plugin creates usable Crash Report and Version Information for Miranda IM + +When Miranda crashes plugin ptrovides: +- text representation of crash report +- MiniDump representation of crash report + +On demand plugin provides Version Information report +On demand uploads VersionInfo report to www.miranda-vi.org + +VersionInfo report includes: + +- OS Version information +- Internet Explorer version information +- Miranda version information with build date +- Miranda profile used +- Loaded Miranda plugin list with versions +- Loaded language pack version +- Loaded weather ini files +- Created protocols accounts + +Files stored in {Miranda Profile}\CrashLog directory + +Text version of crash report includes: + +- Guess for plugin responsible for the crash (it printed in the report) +- Stack trace for exception (with function names, source file names + and line numbers, if possible) +- Version Information (see above) +- Loaded modules (dlls) list +- Plugin lists all information you need to submit crash report for Miranda +- Loaded weather ini files + +Plugin works with all current Operating Systems. + +It could be downloaded here: +ANSI: http://addons.miranda-im.org/details.php?action=viewfile&id=3695 +Unicode: http://addons.miranda-im.org/details.php?action=viewfile&id=3806 +x64: http://addons.miranda-im.org/details.php?action=viewfile&id=4114 +All: http://code.google.com/p/mirandaimplugins/downloads/list + +Win9x, WinNT users required to install dbghelp.dll v 5.0 or later. +dbghelp.dll v 5.0 is available here: +http://www.microsoft.com/downloads/details.aspx?FamilyID=cd1fc4b2-0885-47f4-af45-7fd5e14db6c0&DisplayLang=en + + +Author: Boris Krasnovskiy (borkra) + +Licensing terms could be found below. + +Change Log +========== + +0.0.4.20 +-------- +Added Windows 8 detection + +0.0.4.19 +-------- +Improved reporting for MS RTL failures +Fixes for translation + +0.0.4.18 +-------- +Renamed Hotkeys, added Hotkey to open message window +Added support for 32x32 icons +Added proper display of Miranda 0.9 profile path + +0.0.4.17 +-------- +Removed option to ignore crashes that do not cause Miranda to close +Improved protocol reporting +Fixed TopToolbar buttons no show +Added proper handling of Crash Dumper late exit in Miranda 0.9 + +0.0.4.16 +-------- +Added icon pack reporting +Fixed toolbar button for storing to file + +0.0.4.14 +-------- +Fixed options dialog +Changed bug reporting message to popup + +0.0.4.13 +-------- +Changed option to notify only about crashes that stop Miranda +Fixed bug reporting menu + +0.0.4.12 +-------- +Improved accounts reporting +Fixed error messages about inability to store crash report +Added option to disable crash reporting function +Added coping VI into clipboard on Report Bug menu item + +0.0.4.11 +-------- +Allow creating crash report with dbghelp.dll v5.0 +(this adds support for creating crash reports on Windows 95 with extra dbghelp.dll +and on Windows 2000 with built-in dbghelp.dll) + +0.0.4.10 +-------- +Fixed bbcodes for Weather ini +x64 portability +Windows 95 compatibility +Fixed crash in service mode + +0.0.4.9 +-------- +Printing weather only if weather plugin present +Changed alternative date format +Fixed langpack display when non ANSI chars used in the description +Fixed crash in debug version +Fixed langpack display when locale id is bogus +Changed stored file format to UTF-8 +Added opening generated version info file on popup click + +0.0.4.8 +-------- +Changed upload to miranda-vi.org to unicode +Added Windows 7 & Windows Server 2008 R2 detection +Added Weather ini files reporting +Changed Accounts reporting to list enabled and disabled accounts +Changed VI display font to Courier New + +0.0.4.7 +-------- +Made message boxes the topmost window +Added Protocols and Accounts printout + +0.0.4.6 +-------- +Attempt to reduce no-report conditions + +0.0.4.5 +-------- +Added icons to menu items +Added storing crash report in clipboard only by request +Added base address display to VI with DLLs +Fixed buttons in VI view when show VI with DLL + +0.0.4.4 +-------- +Added menu item to open crash log folder in explorer +Added menu item to open miranda-vi.org in web browser +Added automatic login into miranda-vi when open in web browser through Miranda +Added option to display date and time in "traditional" format for all reports + +0.0.4.3 +-------- +Removed Trap all exceptions option + +0.0.4.2 +-------- +Added caution note to Trap All Exceptions option +Restored compatibility of Crash Dumper Unicode with dbghelp.dll distributed with XP +Disabled on startup Trap All Exceptions option on pre Vista OSes + +0.0.4.1 +-------- +Fixed crash in Trap all possible exceptions mode + +0.0.4.0 +-------- +Fixed crash on VI upload +Modified unicode handling +Fixed memory leak +Added option to trap all possible exceptions +Added ability to provide crash reports for crashes in Miranda threads in 0.8 #19 and higher +Added Unicode version distribution + +0.0.3.4 +-------- +Added storing version Information to file to top toolbar +Added storing crash report to clipboard +Attempt to resolve crashes with no report + +0.0.3.3 +-------- +Fix for crash while generating crash report + +0.0.3.2 +-------- +Added VersionInfo buttons to clist_modern toolbar +Fixed crash when dbghelp not installed or wrong version + +0.0.3.0 +-------- +Added option to printout all loaded DLLs as VI +Added printout of dll version and date to dll list + +0.0.2.8 +-------- +Fixed crash with Wine +Added MessageBox with location of Crash Report after every crash + +0.0.2.7 +-------- +Fixed crash with debughlp.dll not available +Fixed unloadable dll diagnostics +Fixed Show VersionInfo under Win9x + +0.0.2.6 +-------- +Fixed translation + +0.0.2.5 +-------- +Improved diagnostics for unloadable dlls +Fixed unloading dbghelp when not needed +Fixed spelling + +0.0.2.4 +-------- +Improved chances of getting crash report for some crashes + +0.0.2.3 +-------- +Fixed unloadable plugin display +Improvements in notifications + +0.0.2.2 +-------- +Added unloadable plugin display in VI +Fixed VI Show under Windows 9x + +0.0.2.1 +-------- +Clarification in options text +Open global compare url on popup click after successful upload +Added outdated plugin indication after successful upload +Moved all db settings onto one group + +0.0.2.0 +-------- +Fixed icolib support +Added new icons by Angeli-Ka +Added printout for profile creation date and size +Added VersionInfo uploading to www.miranda-vi.org +Removed interface to VIUploader plugin + +0.0.1.4 +-------- +Fixed BBCode for uploaded VI + +0.0.1.3 +-------- +Fixed BBCode formatting +Added BBCode to uploaded VI +Added country code to language pack info +Added possibility to add icons for menu items through icolib + +0.0.1.2 +-------- +Fixed Folders support + +0.0.1.1 +-------- +More robustness updates + +0.0.1.0 +-------- +Fixed crashes during VersionInfo reporting +More lang pack info +Moved plugin causing crash reporting earlier + +0.0.0.13 +-------- +More fixes to plugin sorting + +0.0.0.12 +-------- +Made plugin sorting case insensitive + +0.0.0.11 +-------- +Added WOW64 printout +Fixed VIUploader interface +Added explicit plugin sorting + +0.0.0.10 +-------- +Changed printed timestamp +Merged profilename and path +Capturing only unhandled crashes + +0.0.0.9 +------- +Added protection against infinite exception loops +Fixed printing VersionInfo to file +Added context menu for VersionInfo window + +0.0.0.8 +------- +Fixed operation in service mode +Fixed inability to create crash report +Added ability to provide reports when multiple crash report plugins installed (only on XP or later) +Added notification when multiple crash reporting plugins installed +(as this causes conflict among plugins and inability to create crash reports) + +0.0.0.7 +------- +Changed all timestamps to ISO 8061:2004 format +Added keeping of window sizing & position +Changed preview window color +VersionInfo stored in profile directory by default +Added more formatting to VersionInfo +Added service mode support (dll name changed) + +0.0.0.6 +------- +Fixed storing VersionInfo to file +Added ui to show VersionInfo +Added service to retrieve VersionInfo + +0.0.0.5 +------- +Fixed crash reports with older dbghelp.dll +Added Folders plugin support +Added more VersionInfo reporting +Added VersionInfo storage (to file and clipboard) +Improved report formatting +Added ability to get VersionInfo by hotkey + +0.0.0.4 +------- +Added human readable exception code +Added complete description for access violation +Updated sources to compile with older PSDK +More VersionInfo related stuff + +0.0.0.3 +------- +Added reporting for Internet Explorer version +Added reporting for plugin Unicode capability +Added reporting for Miranda profile path and name +Added reporting for miranda.exe build date + +0.0.0.2 +------- +Reduced resource utilization +Allow Unicode compilation + +0.0.0.1 +------- +Initial release of the plugin + + +Miranda IM +========== +Miranda IM is an open source instant messenger framework that +support plugins for many different networks; ICQ, MSN, YAHOO +AIM to mention a few (but not all). Get it at: +http://www.miranda-im.org/ + + +Copyright and license +===================== + +Software: + +Copyright (C) 2008 - 2010 Boris Krasnovskiy All Rights Reserved + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; version 2 +of the License. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . diff --git a/plugins/CrashDumper/dumper.cpp b/plugins/CrashDumper/dumper.cpp new file mode 100644 index 0000000000..bae091a023 --- /dev/null +++ b/plugins/CrashDumper/dumper.cpp @@ -0,0 +1,745 @@ +/* +Miranda Crash Dumper Plugin +Copyright (C) 2008 - 2012 Boris Krasnovskiy All Rights Reserved + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation version 2 +of the License. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#include "utils.h" + +extern TCHAR* vertxt; +extern TCHAR* profname; +extern TCHAR* profpath; + + +void CreateMiniDump(HANDLE hDumpFile, PEXCEPTION_POINTERS exc_ptr) +{ + MINIDUMP_EXCEPTION_INFORMATION exceptionInfo; + exceptionInfo.ThreadId = GetCurrentThreadId(); + exceptionInfo.ExceptionPointers = exc_ptr; + exceptionInfo.ClientPointers = false; + + MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), + hDumpFile, MiniDumpNormal, &exceptionInfo, NULL, NULL); +} + + +void WriteBBFile(bkstring& buffer, bool hdr) +{ + static const TCHAR header[] = TEXT("[quote][size=1]"); + static const TCHAR footer[] = TEXT("[/size][/quote]"); + + buffer.append(hdr ? header : footer); +} + + +void WriteUtfFile(HANDLE hDumpFile, char* bufu) +{ + DWORD bytes; + + static const unsigned char bytemark[] = { 0xEF, 0xBB, 0xBF }; + WriteFile(hDumpFile, bytemark, 3, &bytes, NULL); + WriteFile(hDumpFile, bufu, (DWORD)strlen(bufu), &bytes, NULL); +} + + +BOOL CALLBACK LoadedModules64(LPCSTR, DWORD64 ModuleBase, ULONG ModuleSize, PVOID UserContext) +{ + bkstring& buffer = *(bkstring*)UserContext; + + const HMODULE hModule = (HMODULE)ModuleBase; + + TCHAR path[MAX_PATH]; + GetModuleFileName(hModule, path, MAX_PATH); + + buffer.appendfmt(TEXT("%s %p - %p"), path, (LPVOID)ModuleBase, (LPVOID)(ModuleBase + ModuleSize)); + + GetVersionInfo(hModule, buffer); + + TCHAR timebuf[30] = TEXT(""); + GetLastWriteTime(path, timebuf, 30); + + buffer.appendfmt(TEXT(" [%s]\r\n"), timebuf); + + return TRUE; +} + +typedef struct _FindData +{ + DWORD64 Offset; IMAGEHLP_MODULE64* pModule; +} FindData; + + +BOOL CALLBACK LoadedModulesFind64(LPCSTR ModuleName, DWORD64 ModuleBase, ULONG ModuleSize, PVOID UserContext) +{ + FindData* data = (FindData*)UserContext; + + if ((DWORD)(data->Offset - ModuleBase) < ModuleSize) + { + const size_t len = SIZEOF(data->pModule->ModuleName); + strncpy(data->pModule->ModuleName, ModuleName, len); + data->pModule->ModuleName[len-1] = 0; + + data->pModule->BaseOfImage = ModuleBase; + + const HMODULE hModule = (HMODULE)ModuleBase; + GetModuleFileNameA(hModule, data->pModule->LoadedImageName, SIZEOF(data->pModule->LoadedImageName)); + + return FALSE; + } + return TRUE; +} + + +void GetLinkedModulesInfo(TCHAR *moduleName, bkstring &buffer) +{ + HANDLE hDllFile = CreateFile(moduleName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + if (hDllFile == INVALID_HANDLE_VALUE) return; + + HANDLE hDllMapping = CreateFileMapping(hDllFile, NULL, PAGE_READONLY, 0, 0, NULL); + if (hDllMapping == INVALID_HANDLE_VALUE) + { + CloseHandle(hDllFile); + return; + } + + LPVOID dllAddr = MapViewOfFile(hDllMapping, FILE_MAP_READ, 0, 0, 0); + + + static const TCHAR format[] = TEXT(" Plugin statically linked to missing module: %S\r\n"); + + + __try + { + PIMAGE_NT_HEADERS nthdrs = ImageNtHeader(dllAddr); + + ULONG tableSize; + PIMAGE_IMPORT_DESCRIPTOR importData = (PIMAGE_IMPORT_DESCRIPTOR)ImageDirectoryEntryToData(dllAddr, FALSE, + IMAGE_DIRECTORY_ENTRY_IMPORT, &tableSize); + if (importData) + { + while (importData->Name) + { + char* moduleName = (char*)ImageRvaToVa(nthdrs, dllAddr, importData->Name, NULL); + if (!SearchPathA(NULL, moduleName, NULL, NULL, 0, NULL)) + { + buffer.appendfmt(format, moduleName); + } + importData++; //go to next record + } + } + + bool found = false; + PIMAGE_EXPORT_DIRECTORY exportData = (PIMAGE_EXPORT_DIRECTORY)ImageDirectoryEntryToData(dllAddr, FALSE, + IMAGE_DIRECTORY_ENTRY_EXPORT, &tableSize); + if (exportData) + { + ULONG* funcAddr = (ULONG*)ImageRvaToVa(nthdrs, dllAddr, exportData->AddressOfNames, NULL); + for(unsigned i=0; iNumberOfNames && !found; ++i) + { + char* funcName = (char*)ImageRvaToVa(nthdrs, dllAddr, funcAddr[i], NULL); + found = strcmp(funcName, "MirandaPluginInfoEx") == 0 || strcmp(funcName, "MirandaPluginInfo") == 0; + if (strcmp(funcName, "DatabasePluginInfo") == 0) + { + buffer.append(TEXT(" This dll is a Miranda database plugin, another database is active right now\r\n")); + found = true; + } + } + } + if (!found) + buffer.append(TEXT(" This dll is not a Miranda plugin and should be removed from plugins directory\r\n")); + } + __except(EXCEPTION_EXECUTE_HANDLER) {} + + UnmapViewOfFile(dllAddr); + CloseHandle(hDllMapping); + CloseHandle(hDllFile); +} + + +struct ListItem +{ + ListItem() : str(), next(NULL) {} + + bkstring str; + ListItem *next; +}; + +static void GetPluginsString(bkstring& buffer, unsigned& flags) +{ + buffer.appendfmt(TEXT("Service Mode: %s\r\n"), servicemode ? TEXT("Yes") : TEXT("No")); + + TCHAR path[MAX_PATH]; + GetModuleFileName(NULL, path, MAX_PATH); + + LPTSTR fname = _tcsrchr(path, TEXT('\\')); + if (fname == NULL) fname = path; + crs_sntprintf(fname, MAX_PATH-(fname-path), TEXT("\\plugins\\*.dll")); + + WIN32_FIND_DATA FindFileData; + HANDLE hFind = FindFirstFile(path, &FindFileData); + if (hFind == INVALID_HANDLE_VALUE) return; + + size_t count = 0, ucount = 0; + + bkstring ubuffer; + ListItem* dlllist = NULL; + + + static const TCHAR format[] = TEXT("%c %s v.%s%d.%d.%d.%d%s [%s] - %S %s\r\n"); + + + do + { + bool loaded = false; + crs_sntprintf(fname, MAX_PATH-(fname-path), TEXT("\\plugins\\%s"), FindFileData.cFileName); + HMODULE hModule = GetModuleHandle(path); + if (hModule == NULL && servicemode) + { + hModule = LoadLibrary(path); + loaded = true; + } + if (hModule == NULL) + { + if ((flags & VI_FLAG_PRNVAR) && IsPluginEnabled(FindFileData.cFileName)) + { + TCHAR timebuf[30] = TEXT(""); + GetLastWriteTime(&FindFileData.ftLastWriteTime, timebuf, 30); + + ubuffer.appendfmt(format, TEXT(' '), FindFileData.cFileName, + (flags & VI_FLAG_FORMAT) ? TEXT("[b]") : TEXT(""), + 0, 0, 0, 0, + (flags & VI_FLAG_FORMAT) ? TEXT("[/b]") : TEXT(""), + timebuf, "", TEXT("")); + + GetLinkedModulesInfo(path, ubuffer); + ubuffer.append(TEXT("\r\n")); + + ++ucount; + } + continue; + } + + PLUGININFOEX* pi = GetMirInfo(hModule); + if (pi != NULL) + { + TCHAR timebuf[30] = TEXT(""); + GetLastWriteTime(&FindFileData.ftLastWriteTime, timebuf, 30); + + bool ep = (size_t)pi->cbSize > sizeof(PLUGININFOEX); + const TCHAR *unica = (ep && ((PLUGININFOEX*)pi)->flags & 1) ? TEXT("|Unicode aware|") : TEXT(""); + + ListItem* lst = new ListItem; + DWORD ver = pi->version; + lst->str.appendfmt(format, ep ? TEXT('\xa4') : TEXT(' '), FindFileData.cFileName, + (flags & VI_FLAG_FORMAT) ? TEXT("[b]") : TEXT(""), + HIBYTE(HIWORD(ver)), LOBYTE(HIWORD(ver)), HIBYTE(LOWORD(ver)), LOBYTE(LOWORD(ver)), + (flags & VI_FLAG_FORMAT) ? TEXT("[/b]") : TEXT(""), + timebuf, pi->shortName ? pi->shortName : "", unica); + + ListItem* lsttmp = dlllist; + ListItem* lsttmppv = NULL; + while (lsttmp != NULL) + { + size_t sz = min(lsttmp->str.size(), lst->str.size()) - 2; + if (lsttmp->str.comparei(2, sz, lst->str, 2, sz) > 0) break; + lsttmppv = lsttmp; + lsttmp = lsttmp->next; + } + lst->next = lsttmp; + if (lsttmppv == NULL) + dlllist = lst; + else + lsttmppv->next = lst; + + if (_tcsicmp(FindFileData.cFileName, TEXT("weather.dll")) == 0) + flags |= VI_FLAG_WEATHER; + + ++count; + } + if (loaded) FreeLibrary(hModule); + } + while (FindNextFile(hFind, &FindFileData)); + FindClose(hFind); + + buffer.appendfmt(TEXT("\r\n%sActive Plugins (%u):%s\r\n"), + (flags & VI_FLAG_FORMAT) ? TEXT("[b]") : TEXT(""), count, (flags & VI_FLAG_FORMAT) ? TEXT("[/b]") : TEXT("")); + + ListItem* lsttmp = dlllist; + while (lsttmp != NULL) + { + buffer.append(lsttmp->str); + ListItem* lsttmp1 = lsttmp->next; + delete lsttmp; + lsttmp = lsttmp1; + } + + if (ucount) + { + buffer.appendfmt(TEXT("\r\n%sUnloadable Plugins (%u):%s\r\n"), + (flags & VI_FLAG_FORMAT) ? TEXT("[b]") : TEXT(""), ucount, (flags & VI_FLAG_FORMAT) ? TEXT("[/b]") : TEXT("")); + buffer.append(ubuffer); + } +} + + +struct ProtoCount +{ + char countse; + char countsd; + bool nloaded; +}; + +static void GetProtocolStrings(bkstring& buffer) +{ + PROTOACCOUNT **accList; + int accCount, protoCount; + int i, j; + + PROTOCOLDESCRIPTOR **protoList; + if (ProtoEnumAccounts(&accCount, &accList) == CALLSERVICE_NOTFOUND || (accCount > 0 && accList[0]->cbSize == 0)) + { + CallService(MS_PROTO_ENUMPROTOCOLS, (WPARAM)&protoCount, (LPARAM)&protoList); + for (i = 0; i < protoCount; i++) + { + if (protoList[i]->type != PROTOTYPE_PROTOCOL) continue; + + TCHAR* nm; + crsi_a2t(nm, protoList[i]->szName); + buffer.appendfmt(TEXT(" 1 - %s\r\n"), nm); + } + } + else + { + CallService(MS_PROTO_ENUMPROTOS, (WPARAM)&protoCount, (LPARAM)&protoList); + + int protoCountMy = 0; + char** protoListMy = (char**)alloca((protoCount + accCount) * sizeof(char*)); + + for (i = 0; i < protoCount; i++) + { + if (protoList[i]->type != PROTOTYPE_PROTOCOL) continue; + protoListMy[protoCountMy++] = protoList[i]->szName; + } + + for (j = 0; j < accCount; j++) + { + for (i = 0; i < protoCountMy; i++) + { + if (strcmp(protoListMy[i], accList[j]->szProtoName) == 0) + break; + } + if (i == protoCountMy) + protoListMy[protoCountMy++] = accList[j]->szProtoName; + } + + ProtoCount *protos = (ProtoCount*)alloca(sizeof(ProtoCount) * protoCountMy); + memset(protos, 0, sizeof(ProtoCount) * protoCountMy); + + for (j = 0; j < accCount; j++) + { + for (i = 0; i < protoCountMy; i++) + { + if (strcmp(protoListMy[i], accList[j]->szProtoName) == 0) + { + protos[i].nloaded = accList[j]->bDynDisabled != 0; + if (IsAccountEnabled(accList[j])) + ++protos[i].countse; + else + ++protos[i].countsd; + break; + } + } + } + for (i = 0; i < protoCountMy; i++) + { + TCHAR* nm; + crsi_a2t(nm, protoListMy[i]); + buffer.appendfmt(TEXT("%-24s %d - Enabled %d - Disabled %sLoaded\r\n"), nm, protos[i].countse, + protos[i].countsd, protos[i].nloaded ? _T("Not ") : _T("")); + } + } +} + + +static void GetWeatherStrings(bkstring& buffer, unsigned flags) +{ + TCHAR path[MAX_PATH]; + GetModuleFileName(NULL, path, MAX_PATH); + + LPTSTR fname = _tcsrchr(path, TEXT('\\')); + if (fname == NULL) fname = path; + crs_sntprintf(fname, MAX_PATH-(fname-path), TEXT("\\plugins\\weather\\*.ini")); + + WIN32_FIND_DATA FindFileData; + HANDLE hFind = FindFirstFile(path, &FindFileData); + if (hFind == INVALID_HANDLE_VALUE) return; + + do + { + if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue; + + crs_sntprintf(fname, MAX_PATH-(fname-path), TEXT("\\plugins\\weather\\%s"), FindFileData.cFileName); + HANDLE hDumpFile = CreateFile(path, GENERIC_READ, FILE_SHARE_READ, NULL, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + + if (hDumpFile != INVALID_HANDLE_VALUE) + { + char buf[8192]; + + DWORD bytes = 0; + ReadFile(hDumpFile, buf, 8190, &bytes, NULL); + buf[bytes] = 0; + + char* ver = strstr(buf, "Version="); + if (ver != NULL) + { + char *endid = strchr(ver, '\r'); + if (endid != NULL) *endid = 0; + else + { + endid = strchr(ver, '\n'); + if (endid != NULL) *endid = 0; + } + ver += 8; + } + + char *id = strstr(buf, "Name="); + if (id != NULL) + { + char *endid = strchr(id, '\r'); + if (endid != NULL) *endid = 0; + else + { + endid = strchr(id, '\n'); + if (endid != NULL) *endid = 0; + } + id += 5; + } + + TCHAR timebuf[30] = TEXT(""); + GetLastWriteTime(&FindFileData.ftLastWriteTime, timebuf, 30); + + + static const TCHAR format[] = TEXT(" %s v.%s%S%s [%s] - %S\r\n"); + + buffer.appendfmt(format, FindFileData.cFileName, + (flags & VI_FLAG_FORMAT) ? TEXT("[b]") : TEXT(""), + ver, + (flags & VI_FLAG_FORMAT) ? TEXT("[/b]") : TEXT(""), + timebuf, id); + CloseHandle(hDumpFile); + } + } + while (FindNextFile(hFind, &FindFileData)); + FindClose(hFind); +} + + +static void GetIconStrings(bkstring& buffer) +{ + TCHAR path[MAX_PATH]; + GetModuleFileName(NULL, path, MAX_PATH); + + LPTSTR fname = _tcsrchr(path, TEXT('\\')); + if (fname == NULL) fname = path; + crs_sntprintf(fname, MAX_PATH-(fname-path), TEXT("\\Icons\\*.*")); + + WIN32_FIND_DATA FindFileData; + HANDLE hFind = FindFirstFile(path, &FindFileData); + if (hFind == INVALID_HANDLE_VALUE) return; + + do + { + if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue; + + TCHAR timebuf[30] = TEXT(""); + GetLastWriteTime(&FindFileData.ftLastWriteTime, timebuf, 30); + + buffer.appendfmt(TEXT(" %s [%s]\r\n"), FindFileData.cFileName, timebuf); + } + while (FindNextFile(hFind, &FindFileData)); + FindClose(hFind); +} + + +void PrintVersionInfo(bkstring& buffer, unsigned flags) +{ + GetProcessorString(buffer); + buffer.append(TEXT("\r\n")); + + GetFreeMemoryString(buffer); + buffer.append(TEXT("\r\n")); + + GetOSDisplayString(buffer); + buffer.append(TEXT("\r\n")); + + GetInternetExplorerVersion(buffer); + buffer.append(TEXT("\r\n")); + + GetAdminString(buffer); + buffer.append(TEXT("\r\n")); + + GetLanguageString(buffer); + buffer.append(TEXT("\r\n")); + + TCHAR *profpathfull = Utils_ReplaceVarsT(profpath); + if (flags & VI_FLAG_PRNVAR) + { + GetFreeDiskString(profpathfull, buffer); + buffer.append(TEXT("\r\n")); + } + + buffer.appendfmt(TEXT("\r\nMiranda IM Version: %s"), vertxt); + GetWow64String(buffer); + buffer.append(TEXT("\r\n")); + + TCHAR path[MAX_PATH], mirtime[30]; + GetModuleFileName(NULL, path, MAX_PATH); + GetLastWriteTime(path, mirtime, 30); + buffer.appendfmt(TEXT("Build time: %s\r\n"), mirtime); + + TCHAR profpn[MAX_PATH]; + crs_sntprintf(profpn, SIZEOF(profpn), TEXT("%s\\%s"), profpathfull, profname); + + buffer.appendfmt(TEXT("Profile: %s\r\n"), profpn); + + if (flags & VI_FLAG_PRNVAR) + { + WIN32_FIND_DATA FindFileData; + + HANDLE hFind = FindFirstFile(profpn, &FindFileData); + if (hFind != INVALID_HANDLE_VALUE) + { + FindClose(hFind); + + unsigned __int64 fsize = (unsigned __int64)FindFileData.nFileSizeHigh << 32 | FindFileData.nFileSizeLow; + buffer.appendfmt(TEXT("Profile size: %I64u Bytes\r\n"), fsize), + + GetLastWriteTime(&FindFileData.ftCreationTime, mirtime, 30); + buffer.appendfmt(TEXT("Profile creation date: %s\r\n"), mirtime); + } + } + mir_free(profpathfull); + + GetLanguagePackString(buffer); + buffer.append(TEXT("\r\n")); + + buffer.appendfmt(TEXT("Nightly: %s\r\n"), _tcsstr(vertxt, TEXT("alpha")) ? TEXT("Yes") : TEXT("No")); + buffer.appendfmt(TEXT("Unicode: %s\r\n"), _tcsstr(vertxt, TEXT("Unicode")) ? TEXT("Yes") : TEXT("No")); + + GetPluginsString(buffer, flags); + + if (flags & VI_FLAG_WEATHER) + { + buffer.appendfmt(TEXT("\r\n%sWeather ini files:%s\r\n-------------------------------------------------------------------------------\r\n"), + (flags & VI_FLAG_FORMAT) ? TEXT("[b]") : TEXT(""), + (flags & VI_FLAG_FORMAT) ? TEXT("[/b]") : TEXT("")); + GetWeatherStrings(buffer, flags); + } + + if (flags & VI_FLAG_PRNVAR && !servicemode) + { + buffer.appendfmt(TEXT("\r\n%sProtocols and Accounts:%s\r\n-------------------------------------------------------------------------------\r\n"), + (flags & VI_FLAG_FORMAT) ? TEXT("[b]") : TEXT(""), + (flags & VI_FLAG_FORMAT) ? TEXT("[/b]") : TEXT("")); + GetProtocolStrings(buffer); + } + + if (flags & VI_FLAG_PRNVAR) + { + buffer.appendfmt(TEXT("\r\n%sIcon Packs:%s\r\n-------------------------------------------------------------------------------\r\n"), + (flags & VI_FLAG_FORMAT) ? TEXT("[b]") : TEXT(""), + (flags & VI_FLAG_FORMAT) ? TEXT("[/b]") : TEXT("")); + GetIconStrings(buffer); + } + + if (flags & VI_FLAG_PRNDLL) + { + __try + { + buffer.append(TEXT("\r\nLoaded Modules:\r\n-------------------------------------------------------------------------------\r\n")); + EnumerateLoadedModules64(GetCurrentProcess(), LoadedModules64, &buffer); + } + __except(EXCEPTION_EXECUTE_HANDLER) {} + } + + if (flags & (VI_FLAG_PRNVAR | VI_FLAG_PRNDLL)) UnloadDbgHlp(); +} + + +void CreateCrashReport(HANDLE hDumpFile, PEXCEPTION_POINTERS exc_ptr, const TCHAR* msg) +{ + if (exc_ptr->ContextRecord == NULL || (exc_ptr->ContextRecord->ContextFlags & CONTEXT_CONTROL) == 0) + return; + + CONTEXT context = *exc_ptr->ContextRecord; + + STACKFRAME64 frame = {0}; + +#if defined(_AMD64_) +#define IMAGE_FILE_MACHINE IMAGE_FILE_MACHINE_AMD64 + frame.AddrPC.Offset = context.Rip; + frame.AddrFrame.Offset = context.Rbp; + frame.AddrStack.Offset = context.Rsp; +#elif defined(_IA64_) +#define IMAGE_FILE_MACHINE IMAGE_FILE_MACHINE_IA64 + frame.AddrPC.Offset = context.StIIP; + frame.AddrFrame.Offset = context.AddrBStore; + frame.AddrStack.Offset = context.SP; +#else +#define IMAGE_FILE_MACHINE IMAGE_FILE_MACHINE_I386 + frame.AddrPC.Offset = context.Eip; + frame.AddrFrame.Offset = context.Ebp; + frame.AddrStack.Offset = context.Esp; +#endif + + frame.AddrPC.Mode = AddrModeFlat; + frame.AddrFrame.Mode = AddrModeFlat; + frame.AddrStack.Mode = AddrModeFlat; + + const PLUGININFOEX *pluginInfoEx = GetPluginInfoEx(); + + bkstring buffer; + buffer.reserve(0x5000); + + TCHAR curtime[30]; + GetISO8061Time(NULL, curtime, 30); + + buffer.appendfmt(TEXT("Miranda Crash Report from %s. Crash Dumper v.%d.%d.%d.%d\r\n"), + curtime, + HIBYTE(HIWORD(pluginInfoEx->version)), LOBYTE(HIWORD(pluginInfoEx->version)), + HIBYTE(LOWORD(pluginInfoEx->version)), LOBYTE(LOWORD(pluginInfoEx->version))); + + size_t crashpos = buffer.size(); + + ReadableExceptionInfo(exc_ptr->ExceptionRecord, buffer); + buffer.append(TEXT("\r\n")); + + const HANDLE hProcess = GetCurrentProcess(); + + if (&SymSetOptions) + SymSetOptions(SYMOPT_UNDNAME | SYMOPT_DEFERRED_LOADS | SYMOPT_LOAD_LINES); + SymInitialize(hProcess, NULL, TRUE); + + buffer.append(TEXT("\r\nStack Trace:\r\n---------------------------------------------------------------\r\n")); + + for (int i=81; --i;) + { + /* + char symbuf[sizeof(SYMBOL_INFO) + MAX_SYM_NAME * sizeof(TCHAR) + 4] = {0}; + PSYMBOL_INFO pSym = (PSYMBOL_INFO)symbuf; + pSym->SizeOfStruct = sizeof(SYMBOL_INFO); + pSym->MaxNameLen = MAX_SYM_NAME; + */ + + char symbuf[sizeof(IMAGEHLP_SYMBOL64) + MAX_SYM_NAME * sizeof(TCHAR) + 4] = {0}; + PIMAGEHLP_SYMBOL64 pSym = (PIMAGEHLP_SYMBOL64)symbuf; + pSym->SizeOfStruct = sizeof(IMAGEHLP_SYMBOL64); + pSym->MaxNameLength = MAX_SYM_NAME; + + IMAGEHLP_LINE64 Line = {0}; + Line.SizeOfStruct = sizeof(Line); + + IMAGEHLP_MODULE64 Module = {0}; + Module.SizeOfStruct = sizeof(IMAGEHLP_MODULE64_V2); + + char undName[MAX_SYM_NAME] = ""; + char undFullName[MAX_SYM_NAME] = ""; + + DWORD64 offsetFromSmybol = 0; + DWORD offsetFromLine = 0; + + if (!StackWalk64(IMAGE_FILE_MACHINE, hProcess, GetCurrentThread(), &frame, &context, + NULL, SymFunctionTableAccess64, SymGetModuleBase64, NULL)) break; + + if (frame.AddrPC.Offset == frame.AddrReturn.Offset) break; + + if (frame.AddrPC.Offset != 0) + { + if (SymGetSymFromAddr64(hProcess, frame.AddrPC.Offset, &offsetFromSmybol, pSym)) + // if (SymFromAddr(hProcess, frame.AddrPC.Offset, &offsetFromSmybol, pSym)) + { + UnDecorateSymbolName(pSym->Name, undName, MAX_SYM_NAME, UNDNAME_NAME_ONLY); + UnDecorateSymbolName(pSym->Name, undFullName, MAX_SYM_NAME, UNDNAME_COMPLETE); + } + + SymGetLineFromAddr64(hProcess, frame.AddrPC.Offset, &offsetFromLine, &Line); + SymGetModuleInfo64(hProcess, frame.AddrPC.Offset, &Module); + if (Module.ModuleName[0] == 0) + { + FindData data; + data.Offset = frame.AddrPC.Offset; + data.pModule = &Module; + EnumerateLoadedModules64(hProcess, LoadedModulesFind64, &data); + } + } + + const char* name; + if (undFullName[0] != 0) + name = undFullName; + else if (undName[0] != 0) + name = undName; + else if (pSym->Name[0] != 0) + name = pSym->Name; + else + name = "(function-name not available)"; + + const char *lineFileName = Line.FileName ? Line.FileName : "(filename not available)"; + const char *moduleName = Module.ModuleName[0] ? Module.ModuleName : "(module-name not available)"; + + if (crashpos != 0) + { + HMODULE hModule = (HMODULE)Module.BaseOfImage; + PLUGININFOEX *pi = GetMirInfo(hModule); + if (pi != NULL) + { + + static const TCHAR formatc[] = TEXT("\r\nLikely cause of the crash plugin: %S\r\n\r\n"); + + if (pi->shortName) + { + bkstring crashcause; + crashcause.appendfmt(formatc, pi->shortName); + buffer.insert(crashpos, crashcause); + } + crashpos = 0; + } + } + + + static const TCHAR formatd[] = TEXT("%p (%S %p): %S (%d): %S\r\n"); + + buffer.appendfmt(formatd, + (LPVOID)frame.AddrPC.Offset, moduleName, (LPVOID)Module.BaseOfImage, + lineFileName, Line.LineNumber, name); + } + SymCleanup(hProcess); + buffer.append(TEXT("\r\n")); + + PrintVersionInfo(buffer, VI_FLAG_PRNDLL); + + + int len = WideCharToMultiByte(CP_UTF8, 0, buffer.c_str(), -1, NULL, 0, NULL, NULL); + char* dst = (char*)(len > 8192 ? malloc(len) : alloca(len)); + WideCharToMultiByte(CP_UTF8, 0, buffer.c_str(), -1, dst, len, NULL, NULL); + + WriteUtfFile(hDumpFile, dst); + + if (len > 8192) free(dst); + + + if (msg && MessageBox(NULL, msg, TEXT("Miranda Crash Dumper"), MB_YESNO | MB_ICONERROR | MB_TASKMODAL | MB_DEFBUTTON2 | MB_TOPMOST) == IDYES) + StoreStringToClip(buffer); +} diff --git a/plugins/CrashDumper/exhndlr.cpp b/plugins/CrashDumper/exhndlr.cpp new file mode 100644 index 0000000000..93406efaa8 --- /dev/null +++ b/plugins/CrashDumper/exhndlr.cpp @@ -0,0 +1,207 @@ +#include "utils.h" +#include "crtdbg.h" + +static PVOID exchndlr, exchndlrv; +static pfnExceptionFilter threadfltr; +static PEXCEPTION_POINTERS lastptr; + +static HMODULE hKernel = GetModuleHandle(TEXT("kernel32.dll")); + +tAddVectoredExceptionHandler pAddVectoredExceptionHandler = (tAddVectoredExceptionHandler)GetProcAddress(hKernel, "AddVectoredExceptionHandler"); +tRemoveVectoredExceptionHandler pRemoveVectoredExceptionHandler = (tRemoveVectoredExceptionHandler)GetProcAddress(hKernel, "RemoveVectoredExceptionHandler"); +tRtlCaptureContext pRtlCaptureContext = (tRtlCaptureContext)GetProcAddress(hKernel, "RtlCaptureContext"); + +void SetExceptionHandler(void) +{ + // if (pAddVectoredExceptionHandler && !exchndlrv) + // exchndlrv = pAddVectoredExceptionHandler(0, myfilterv); + /*exchndlr = */ SetUnhandledExceptionFilter(myfilter); +} + +void RemoveExceptionHandler(void) +{ + if (pRemoveVectoredExceptionHandler && exchndlrv) + pRemoveVectoredExceptionHandler(exchndlrv); + SetUnhandledExceptionFilter((LPTOP_LEVEL_EXCEPTION_FILTER)exchndlr); + exchndlr = NULL; + exchndlrv = NULL; +} + +void UnloadDbgHlp(void) +{ +#ifdef _MSC_VER +#if _MSC_VER > 1200 + __FUnloadDelayLoadedDLL2("dbghelp.dll"); +#else + __FUnloadDelayLoadedDLL("dbghelp.dll"); +#endif +#endif +} + +int myDebugFilter(unsigned int code, PEXCEPTION_POINTERS ep) +{ + if (code == VcppException(ERROR_SEVERITY_ERROR, ERROR_MOD_NOT_FOUND) || + code == VcppException(ERROR_SEVERITY_ERROR, ERROR_PROC_NOT_FOUND)) + { + PDelayLoadInfo dlld = (PDelayLoadInfo)ep->ExceptionRecord->ExceptionInformation[0]; + + char str[256]; + int off = mir_snprintf(str, SIZEOF(str), "dbghelp.dll v.5.0 or later required to provide a crash report\n"); + off += mir_snprintf(str+off, SIZEOF(str)-off, "Missing Module: %s ", dlld->szDll); + + if (dlld->dlp.fImportByName) + mir_snprintf(str+off, SIZEOF(str)-off, "Function: %s ", dlld->dlp.szProcName); + else + mir_snprintf(str+off, SIZEOF(str)-off, "Ordinal: %x ", dlld->dlp.dwOrdinal); + + MessageBoxA(NULL, str, "Miranda Crash Dumper", MB_OK | MB_ICONERROR | MB_TASKMODAL | MB_TOPMOST); + } + + return EXCEPTION_EXECUTE_HANDLER; +} + + +void myfilterWorker(PEXCEPTION_POINTERS exc_ptr, bool notify) +{ + TCHAR path[MAX_PATH]; + SYSTEMTIME st; + HANDLE hDumpFile = NULL; + + GetLocalTime(&st); + CreateDirectoryTree(CrashLogFolder); + + __try + { + if (dtsubfldr) + { + crs_sntprintf(path, MAX_PATH, TEXT("%s\\%02d.%02d.%02d"), CrashLogFolder, st.wYear, st.wMonth, st.wDay); + CreateDirectory(path, NULL); + crs_sntprintf(path, MAX_PATH, TEXT("%s\\%02d.%02d.%02d\\crash%02d%02d%02d%02d%02d%02d.mdmp"), CrashLogFolder, + st.wYear, st.wMonth, st.wDay, st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond); + } + else + { + crs_sntprintf(path, MAX_PATH, TEXT("%s\\crash%02d%02d%02d%02d%02d%02d.mdmp"), CrashLogFolder, + st.wYear, st.wMonth, st.wDay, st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond); + } + hDumpFile = CreateFile(path, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL); + if (hDumpFile != INVALID_HANDLE_VALUE) + CreateMiniDump(hDumpFile, exc_ptr); + else if (GetLastError() != ERROR_ALREADY_EXISTS) + MessageBox(NULL, TranslateT("Crash Report write location is inaccesible"), + TEXT("Miranda Crash Dumper"), MB_OK | MB_ICONERROR | MB_TASKMODAL | MB_TOPMOST); + + } + __except(EXCEPTION_EXECUTE_HANDLER) {} + + bool empty = GetFileSize(hDumpFile, NULL) == 0; + CloseHandle(hDumpFile); + if (empty) DeleteFile(path); + + __try + { + if (dtsubfldr) + { + crs_sntprintf(path, MAX_PATH, TEXT("%s\\%02d.%02d.%02d"), CrashLogFolder, st.wYear, st.wMonth, st.wDay); + CreateDirectory(path, NULL); + crs_sntprintf(path, MAX_PATH, TEXT("%s\\%02d.%02d.%02d\\crash%02d%02d%02d%02d%02d%02d.txt"), CrashLogFolder, + st.wYear, st.wMonth, st.wDay, st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond); + } + else + { + crs_sntprintf(path, MAX_PATH, TEXT("%s\\crash%02d%02d%02d%02d%02d%02d.txt"), CrashLogFolder, + st.wYear, st.wMonth, st.wDay, st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond); + } + hDumpFile = CreateFile(path, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL); + + crs_sntprintf(path, MAX_PATH, TranslateT("Miranda crashed. Crash report stored in the folder:\n %s\n\n Would you like store it in the clipboard as well?"), CrashLogFolder); + + if (hDumpFile != INVALID_HANDLE_VALUE) + CreateCrashReport(hDumpFile, exc_ptr, notify ? path : NULL); + } + __except(myDebugFilter(GetExceptionCode(), GetExceptionInformation())) {} + + bool empty1 = GetFileSize(hDumpFile, NULL) == 0; + CloseHandle(hDumpFile); + if (empty1) DeleteFile(path); + + UnloadDbgHlp(); +} + +LONG WINAPI myfilter(PEXCEPTION_POINTERS exc_ptr) +{ + if (exc_ptr == lastptr) return EXCEPTION_EXECUTE_HANDLER; + lastptr = exc_ptr; + + myfilterWorker(exc_ptr, true); + + return exchndlr ? ((LPTOP_LEVEL_EXCEPTION_FILTER)exchndlr)(exc_ptr) : EXCEPTION_CONTINUE_SEARCH; +} + +LONG WINAPI myfilterv(PEXCEPTION_POINTERS exc_ptr) +{ + if (0xC0000000L <= exc_ptr->ExceptionRecord->ExceptionCode && 0xC0000500L >= exc_ptr->ExceptionRecord->ExceptionCode) + { + if (exc_ptr == lastptr) return EXCEPTION_EXECUTE_HANDLER; + lastptr = exc_ptr; + + myfilterWorker(exc_ptr, true); + } + return EXCEPTION_CONTINUE_SEARCH; +} + +DWORD MirandaThreadFilter(DWORD code, EXCEPTION_POINTERS* info) +{ + if (info != lastptr) + { + lastptr = info; + myfilterWorker(info, true); + } + return threadfltr(code, info); +} + +#if _MSC_VER >= 1400 +void InvalidParameterHandler(const wchar_t*, const wchar_t*, const wchar_t*, unsigned int, UINT_PTR) +{ + EXCEPTION_RECORD ExceptionRecord = {0}; + CONTEXT ContextRecord = {0}; + EXCEPTION_POINTERS info = { &ExceptionRecord, &ContextRecord }; + + if (pRtlCaptureContext) + pRtlCaptureContext(&ContextRecord); + else + { + ContextRecord.ContextFlags = CONTEXT_ALL; + GetThreadContext(GetCurrentThread(), &ContextRecord); + } + +#if defined(_AMD64_) + ExceptionRecord.ExceptionAddress = (PVOID)ContextRecord.Rip; +#elif defined(_IA64_) + ExceptionRecord.ExceptionAddress = (PVOID)ContextRecord.BrRp; +#else + ExceptionRecord.ExceptionAddress = (PVOID)ContextRecord.Eip; +#endif + + ExceptionRecord.ExceptionCode = STATUS_INVALID_CRUNTIME_PARAMETER; + ExceptionRecord.ExceptionFlags = EXCEPTION_NONCONTINUABLE; + + myfilterWorker(&info, true); +} +#endif + +void InitExceptionHandler(void) +{ +#if _MSC_VER >= 1400 + _set_invalid_parameter_handler(InvalidParameterHandler); +#endif + threadfltr = Miranda_SetExceptFilter(MirandaThreadFilter); + SetExceptionHandler(); +} + +void DestroyExceptionHandler(void) +{ + Miranda_SetExceptFilter(threadfltr); + RemoveExceptionHandler(); +} + diff --git a/plugins/CrashDumper/resource.h b/plugins/CrashDumper/resource.h new file mode 100644 index 0000000000..83d8a491e4 --- /dev/null +++ b/plugins/CrashDumper/resource.h @@ -0,0 +1,34 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by crshdmp.rc +// +#define IDD_VIEWVERSION 101 +#define IDR_CONTEXT 102 +#define IDI_VI 104 +#define IDI_VISHOW 105 +#define IDI_VITOCLIP 106 +#define IDI_VITOFILE 107 +#define IDI_VIUPLOAD 108 +#define IDD_OPTIONS 109 +#define IDC_VIEWVERSIONINFO 1001 +#define IDC_FILEVER 1003 +#define IDC_CLIPVER 1004 +#define IDC_USERNAME 1006 +#define IDC_PASSWORD 1007 +#define IDC_UPLOADCHN 1008 +#define IDC_CLASSICDATES 1009 +#define IDC_DATESUBFOLDER 1010 +#define IDM_COPY 40002 +#define IDM_COPYALL 40003 +#define IDM_SELECTALL 40004 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 110 +#define _APS_NEXT_COMMAND_VALUE 40005 +#define _APS_NEXT_CONTROL_VALUE 1011 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/plugins/CrashDumper/sdkstuff.h b/plugins/CrashDumper/sdkstuff.h new file mode 100644 index 0000000000..536a00bc40 --- /dev/null +++ b/plugins/CrashDumper/sdkstuff.h @@ -0,0 +1,124 @@ +/* +Miranda Crash Dumper Plugin +Copyright (C) 2008 - 2012 Boris Krasnovskiy All Rights Reserved + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation version 2 +of the License. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#include + + +//#define DBGHELP_TRANSLATE_TCHAR + + +#ifndef __in_bcount_opt +#define __in_bcount_opt(x) +#endif + +#ifndef __out_bcount_opt +#define __out_bcount_opt(x) +#endif + +#include "dbghelp.h" + + +#ifndef PRODUCT_ULTIMATE + +#define PRODUCT_UNDEFINED 0x00000000 + +#define PRODUCT_ULTIMATE 0x00000001 +#define PRODUCT_HOME_BASIC 0x00000002 +#define PRODUCT_HOME_PREMIUM 0x00000003 +#define PRODUCT_ENTERPRISE 0x00000004 +#define PRODUCT_HOME_BASIC_N 0x00000005 +#define PRODUCT_BUSINESS 0x00000006 +#define PRODUCT_STANDARD_SERVER 0x00000007 +#define PRODUCT_DATACENTER_SERVER 0x00000008 +#define PRODUCT_SMALLBUSINESS_SERVER 0x00000009 +#define PRODUCT_ENTERPRISE_SERVER 0x0000000A +#define PRODUCT_STARTER 0x0000000B +#define PRODUCT_DATACENTER_SERVER_CORE 0x0000000C +#define PRODUCT_STANDARD_SERVER_CORE 0x0000000D +#define PRODUCT_ENTERPRISE_SERVER_CORE 0x0000000E +#define PRODUCT_ENTERPRISE_SERVER_IA64 0x0000000F +#define PRODUCT_BUSINESS_N 0x00000010 +#define PRODUCT_WEB_SERVER 0x00000011 +#define PRODUCT_CLUSTER_SERVER 0x00000012 +#define PRODUCT_HOME_SERVER 0x00000013 +#define PRODUCT_STORAGE_EXPRESS_SERVER 0x00000014 +#define PRODUCT_STORAGE_STANDARD_SERVER 0x00000015 +#define PRODUCT_STORAGE_WORKGROUP_SERVER 0x00000016 +#define PRODUCT_STORAGE_ENTERPRISE_SERVER 0x00000017 +#define PRODUCT_SERVER_FOR_SMALLBUSINESS 0x00000018 +#define PRODUCT_SMALLBUSINESS_SERVER_PREMIUM 0x00000019 + +#define PRODUCT_UNLICENSED 0xABCDABCD + +#define SM_TABLETPC 86 +#define SM_MEDIACENTER 87 +#define SM_STARTER 88 +#define SM_SERVERR2 89 + +#endif + +#ifndef VER_SUITE_STORAGE_SERVER +#define VER_SUITE_STORAGE_SERVER 0x00002000 +#define VER_SUITE_COMPUTE_SERVER 0x00004000 +#endif + +#ifndef PF_NX_ENABLED +#define PF_NX_ENABLED 12 +#endif + +typedef struct _IMAGEHLP_MODULE64_V2 { + DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_MODULE64) + DWORD64 BaseOfImage; // base load address of module + DWORD ImageSize; // virtual size of the loaded module + DWORD TimeDateStamp; // date/time stamp from pe header + DWORD CheckSum; // checksum from the pe header + DWORD NumSyms; // number of symbols in the symbol table + SYM_TYPE SymType; // type of symbols loaded + CHAR ModuleName[32]; // module name + CHAR ImageName[256]; // image name + CHAR LoadedImageName[256]; // symbol file name +} IMAGEHLP_MODULE64_V2; + +typedef struct _IMAGEHLP_MODULEW64_V2 { + DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_MODULE64) + DWORD64 BaseOfImage; // base load address of module + DWORD ImageSize; // virtual size of the loaded module + DWORD TimeDateStamp; // date/time stamp from pe header + DWORD CheckSum; // checksum from the pe header + DWORD NumSyms; // number of symbols in the symbol table + SYM_TYPE SymType; // type of symbols loaded + WCHAR ModuleName[32]; // module name + WCHAR ImageName[256]; // image name + WCHAR LoadedImageName[256]; // symbol file name +} IMAGEHLP_MODULEW64_V2; + +#ifdef DBGHELP_TRANSLATE_TCHAR +#define IMAGEHLP_MODULE64_V2 IMAGEHLP_MODULEW64_V2 +#endif + +typedef void (WINAPI *tGetNativeSystemInfo)(LPSYSTEM_INFO); +typedef BOOL (WINAPI *tGetProductInfo)(DWORD, DWORD, DWORD, DWORD, PDWORD); +typedef BOOL (WINAPI *tGlobalMemoryStatusEx)(LPMEMORYSTATUSEX lpBuffer); +typedef BOOL (WINAPI *tGetDiskFreeSpaceEx)(LPCTSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER); +typedef LANGID (WINAPI *tGetUserDefaultUILanguage)(void); +typedef LANGID (WINAPI *tGetSystemDefaultUILanguage)(void); +typedef BOOL (WINAPI *tIsWow64Process)(HANDLE, PBOOL); +typedef PVOID (WINAPI *tAddVectoredExceptionHandler)(ULONG FirstHandler, PVECTORED_EXCEPTION_HANDLER VectoredHandler); +typedef ULONG (WINAPI *tRemoveVectoredExceptionHandler)(PVOID Handler); +typedef BOOL (WINAPI *tIsProcessorFeaturePresent)(DWORD ProcessorFeature); +typedef VOID (WINAPI *tRtlCaptureContext)(PCONTEXT ContextRecord); diff --git a/plugins/CrashDumper/svc_crshdmp-translation.txt b/plugins/CrashDumper/svc_crshdmp-translation.txt new file mode 100644 index 0000000000..18d251f699 --- /dev/null +++ b/plugins/CrashDumper/svc_crshdmp-translation.txt @@ -0,0 +1,54 @@ +; Common strings that belong to many files +;[] + +; ../../plugins/Svc_crshdmp/crshdmp.cpp +;[Copy Version Info to clipboard] +;[Copy to clipboard] +;[Open crash report directory] +;[Open miranda-vi.org] +;[Services] +;[Show] +;[Show Version Info] +;[Show Version Information] +;[Show with DLLs] +;[Store to file] +;[Upload] +;[Upload Version Information] +;[Version Information] +;[Version Information To Clipboard] +;[Version Information To File] +;[VersionInfo file %s is inaccessible] +;[VersionInfo stored into file %s] + +; ../../plugins/Svc_crshdmp/crshdmp.rc +;[&Copy] +;[Close] +;[Co&py All] +;[Copy To Clipboard] +;[Create reports in subfolders naming as current date] +;[General] +;[Password] +;[Select &All] +;[Support for miranda-vi.org] +;[To File] +;[Upload automatically when changed] +;[Use classic dates] +;[Username] +;[View] +;[View Version Information ] + +; ../../plugins/Svc_crshdmp/exhndlr.cpp +;[Crash Report write location is inaccesible] +;[Miranda crashed. Crash report stored in the folder:\n %s\n\n Would you like store it in the clipboard as well?] + +; ../../plugins/Svc_crshdmp/upload.cpp +;[Cannot upload VersionInfo. Daily upload limit exceeded] +;[Cannot upload VersionInfo. Host unreachable.] +;[Cannot upload VersionInfo. Incorrect username or password] +;[Cannot upload VersionInfo. Unknown error] +;[Cannot upload VersionInfo. User is banned] +;[Crash Dumper HTTP connections] +;[VersionInfo upload successful,\n %d old plugins] + +; ../../plugins/Svc_crshdmp/utils.cpp +;[More then one crash reporting plugin installed. This will result in inability of creating crash reports] diff --git a/plugins/CrashDumper/ui.cpp b/plugins/CrashDumper/ui.cpp new file mode 100644 index 0000000000..00cf9c26cd --- /dev/null +++ b/plugins/CrashDumper/ui.cpp @@ -0,0 +1,327 @@ +/* +Miranda Crash Dumper Plugin +Copyright (C) 2008 - 2012 Boris Krasnovskiy All Rights Reserved + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation version 2 +of the License. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#include "utils.h" +#include +#include +#include + +HWND hViewWnd; +extern HINSTANCE hInst; + + +HDWP MyResizeWindow (HDWP hDwp, HWND hwndDlg, HWND hwndCtrl, int nHorizontalOffset, int nVerticalOffset, + int nWidthOffset, int nHeightOffset) +{ + POINT pt; + RECT rcinit; + + // get current bounding rectangle + GetWindowRect(hwndCtrl, &rcinit); + + // get current top left point + pt.x = rcinit.left; + pt.y = rcinit.top; + ScreenToClient(hwndDlg, &pt); + + return DeferWindowPos(hDwp, hwndCtrl, NULL, + pt.x + nHorizontalOffset, + pt.y + nVerticalOffset, + rcinit.right - rcinit.left + nWidthOffset, + rcinit.bottom - rcinit.top + nHeightOffset, + SWP_NOZORDER); +} + +BOOL MyResizeGetOffset(HWND hwndCtrl, int nWidth, int nHeight, int* nDx, int* nDy) +{ + RECT rcinit; + + // get current bounding rectangle + GetWindowRect(hwndCtrl, &rcinit); + + // calculate offsets + *nDx = nWidth - (rcinit.right - rcinit.left); + *nDy = nHeight - (rcinit.bottom - rcinit.top); + + return rcinit.bottom != rcinit.top && nHeight > 0; +} + +INT_PTR CALLBACK DlgProcView(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch (msg) + { + case WM_INITDIALOG: + if (hViewWnd == NULL) + { + hViewWnd = hwndDlg; + TranslateDialogDefault(hwndDlg); + SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)LoadIconEx("versionInfo", true)); + SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)LoadIconEx("versionInfo")); + + CHARFORMAT2 chf; + chf.cbSize = sizeof(chf); + SendDlgItemMessage(hwndDlg, IDC_VIEWVERSIONINFO, EM_GETCHARFORMAT, SCF_DEFAULT, (LPARAM)&chf); + _tcscpy(chf.szFaceName, TEXT("Courier New")); + SendDlgItemMessage(hwndDlg, IDC_VIEWVERSIONINFO, EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&chf); + + bkstring buffer; + buffer.reserve(0x1800); + PrintVersionInfo(buffer, (unsigned int)lParam); + SetDlgItemText(hwndDlg, IDC_VIEWVERSIONINFO, buffer.c_str()); + SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); + + Utils_RestoreWindowPositionNoMove(hwndDlg, NULL, PluginName, "ViewInfo_"); + ShowWindow(hwndDlg, SW_SHOW); + } + else + DestroyWindow(hwndDlg); + break; + + case WM_SIZE: + { + int dx, dy, bsz; + HDWP hDwp; + RECT rc; + + GetWindowRect(GetDlgItem(hwndDlg, IDC_FILEVER), &rc); + bsz = rc.bottom - rc.top; + + if (MyResizeGetOffset(GetDlgItem(hwndDlg, IDC_VIEWVERSIONINFO), + LOWORD(lParam)-20, HIWORD(lParam)-30-bsz, &dx, &dy)) + { + hDwp = BeginDeferWindowPos(4); + hDwp = MyResizeWindow(hDwp, hwndDlg, GetDlgItem(hwndDlg, IDC_FILEVER), 0, dy, 0, 0); + hDwp = MyResizeWindow(hDwp, hwndDlg, GetDlgItem(hwndDlg, IDC_CLIPVER), dx/2, dy, 0, 0); + hDwp = MyResizeWindow(hDwp, hwndDlg, GetDlgItem(hwndDlg, IDCANCEL), dx, dy, 0, 0); + hDwp = MyResizeWindow(hDwp, hwndDlg, GetDlgItem(hwndDlg, IDC_VIEWVERSIONINFO), 0, 0, dx, dy); + EndDeferWindowPos(hDwp); + } + } + break; + + case WM_GETMINMAXINFO: + { + LPMINMAXINFO mmi = (LPMINMAXINFO)lParam; + + // The minimum width in points + mmi->ptMinTrackSize.x = 350; + // The minimum height in points + mmi->ptMinTrackSize.y = 300; + } + break; + + case WM_COMMAND: + switch(LOWORD(wParam)) + { + case IDC_CLIPVER: + CallService(MS_CRASHDUMPER_STORETOCLIP, 0, GetWindowLongPtr(hwndDlg, GWLP_USERDATA)); + break; + + case IDC_FILEVER: + CallService(MS_CRASHDUMPER_STORETOFILE, 0, GetWindowLongPtr(hwndDlg, GWLP_USERDATA)); + break; + + case IDCANCEL: + DestroyWindow(hwndDlg); + break; + } + break; + + case WM_CONTEXTMENU: + { + HWND hView = GetDlgItem(hwndDlg, IDC_VIEWVERSIONINFO); + RECT rc; + GetWindowRect(hView, &rc); + + POINT pt; + pt.x = LOWORD(lParam); + pt.y = HIWORD(lParam); + if (PtInRect(&rc, pt)) + { + static const CHARRANGE all = { 0, -1 }; + + HMENU hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_CONTEXT)); + HMENU hSubMenu = GetSubMenu(hMenu, 0); + TranslateMenu(hSubMenu); + + CHARRANGE sel; + SendMessage(hView, EM_EXGETSEL, 0, (LPARAM)&sel); + if (sel.cpMin == sel.cpMax) + EnableMenuItem(hSubMenu, IDM_COPY, MF_BYCOMMAND | MF_GRAYED); + + switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL)) + { + case IDM_COPY: + SendMessage(hView, WM_COPY, 0, 0); + break; + + case IDM_COPYALL: + SendMessage(hView, EM_EXSETSEL, 0, (LPARAM)&all); + SendMessage(hView, WM_COPY, 0, 0); + SendMessage(hView, EM_EXSETSEL, 0, (LPARAM)&sel); + break; + + case IDM_SELECTALL: + SendMessage(hView, EM_EXSETSEL, 0, (LPARAM)&all); + break; + } + DestroyMenu(hMenu); + } + } + break; + + case WM_DESTROY: + hViewWnd = NULL; + ReleaseIconEx((HICON)SendMessage(hwndDlg, WM_SETICON, ICON_BIG, 0)); + ReleaseIconEx((HICON)SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, 0)); + Utils_SaveWindowPosition(hwndDlg, NULL, PluginName, "ViewInfo_"); + if (servicemode) PostQuitMessage(0); + break; + } + return FALSE; +} + + +void DestroyAllWindows(void) +{ + if (hViewWnd != NULL) DestroyWindow(hViewWnd); + hViewWnd = NULL; +} + + +INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch (msg) + { + case WM_INITDIALOG: + { + TranslateDialogDefault(hwndDlg); + + DBVARIANT dbv; + if (DBGetContactSettingString(NULL, PluginName, "Username", &dbv) == 0) + { + SetDlgItemTextA(hwndDlg, IDC_USERNAME, dbv.pszVal); + DBFreeVariant(&dbv); + } + if (DBGetContactSettingString(NULL, PluginName, "Password", &dbv) == 0) + { + CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal)+1, (LPARAM)dbv.pszVal); + SetDlgItemTextA(hwndDlg, IDC_PASSWORD, dbv.pszVal); + DBFreeVariant(&dbv); + } + CheckDlgButton(hwndDlg, IDC_UPLOADCHN, DBGetContactSettingByte(NULL, PluginName, "UploadChanged", 0)); + CheckDlgButton(hwndDlg, IDC_CLASSICDATES, clsdates); + CheckDlgButton(hwndDlg, IDC_DATESUBFOLDER, dtsubfldr); + } + break; + + case WM_COMMAND: + if ((HIWORD(wParam) == EN_CHANGE || HIWORD(wParam) == BN_CLICKED) && (HWND)lParam == GetFocus()) + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; + + case WM_NOTIFY: + if (((LPNMHDR)lParam)->code == (unsigned)PSN_APPLY) + { + char szSetting[100]; + GetDlgItemTextA(hwndDlg, IDC_USERNAME, szSetting, SIZEOF(szSetting)); + DBWriteContactSettingString(NULL, PluginName, "Username", szSetting); + + GetDlgItemTextA(hwndDlg, IDC_PASSWORD, szSetting, SIZEOF(szSetting)); + CallService(MS_DB_CRYPT_ENCODESTRING, SIZEOF(szSetting), (LPARAM)szSetting); + DBWriteContactSettingString(NULL, PluginName, "Password", szSetting); + + DBWriteContactSettingByte(NULL, PluginName, "UploadChanged", + (BYTE)IsDlgButtonChecked(hwndDlg, IDC_UPLOADCHN)); + + clsdates = IsDlgButtonChecked(hwndDlg, IDC_CLASSICDATES) == BST_CHECKED; + if (clsdates) + DBWriteContactSettingByte(NULL, PluginName, "ClassicDates", 1); + else + DBDeleteContactSetting(NULL, PluginName, "ClassicDates"); + dtsubfldr = IsDlgButtonChecked(hwndDlg, IDC_DATESUBFOLDER) == BST_CHECKED; + if (dtsubfldr) + DBWriteContactSettingByte(NULL, PluginName, "SubFolders", 1); + else + DBDeleteContactSetting(NULL, PluginName, "SubFolders"); + } + break; + } + return FALSE; +} + + +LRESULT CALLBACK DlgProcPopup(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch (msg) + { + case WM_CONTEXTMENU: + PUDeletePopUp(hWnd); + break; + + case WM_COMMAND: + switch ((int)PUGetPluginData(hWnd)) + { + case 0: + OpenAuthUrl("http://www.miranda-vi.org/"); + break; + + case 1: + OpenAuthUrl("http://%s.miranda-vi.org/global"); + break; + + case 3: + TCHAR path[MAX_PATH]; + crs_sntprintf(path, MAX_PATH, TEXT("%s\\VersionInfo.txt"), VersionInfoFolder); + ShellExecute(NULL, TEXT("open"), path, NULL, NULL, SW_SHOW); + break; + + } + PUDeletePopUp(hWnd); + break; + + case UM_FREEPLUGINDATA: + ReleaseIconEx("versionInfo"); + break; + } + + return DefWindowProc(hWnd, msg, wParam, lParam); +} + +void ShowMessage(int type, const TCHAR* format, ...) +{ + POPUPDATAT pi = {0}; + + va_list va; + va_start(va, format); + int len = _vsntprintf(pi.lptzText, SIZEOF(pi.lptzText)-1, format, va); + pi.lptzText[len] = 0; + va_end(va); + + if (ServiceExists(MS_POPUP_ADDPOPUPT)) + { + _tcscpy(pi.lptzContactName, TEXT(PluginName)); + pi.lchIcon = LoadIconEx("versionInfo"); + pi.PluginWindowProc = DlgProcPopup; + pi.PluginData = (void*)type; + + PUAddPopUpT(&pi); + } + else + MessageBox(NULL, pi.lptzText, TEXT(PluginName), MB_OK | MB_ICONINFORMATION); +} diff --git a/plugins/CrashDumper/upload.cpp b/plugins/CrashDumper/upload.cpp new file mode 100644 index 0000000000..498b5cb2f6 --- /dev/null +++ b/plugins/CrashDumper/upload.cpp @@ -0,0 +1,292 @@ +/* +Miranda Crash Dumper Plugin +Copyright (C) 2008 - 2012 Boris Krasnovskiy All Rights Reserved + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation version 2 +of the License. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#include "utils.h" +#include + +HANDLE hNetlibUser; + +static void arrayToHex(BYTE* data, size_t datasz, char* res) +{ + char* resptr = res; + for (unsigned i=0; i> 4); + *resptr++ = (char)((ch0 <= 9) ? ('0' + ch0) : (('a' - 10) + ch0)); + + const char ch1 = (char)(ch & 0xF); + *resptr++ = (char)((ch1 <= 9) ? ('0' + ch1) : (('a' - 10) + ch1)); + } + *resptr = '\0'; +} + +void GetLoginStr(char* user, size_t szuser, char* pass) +{ + DBVARIANT dbv; + + if (DBGetContactSettingString(NULL, PluginName, "Username", &dbv) == 0) + { + mir_snprintf(user, szuser, "%s", dbv.pszVal); + DBFreeVariant(&dbv); + } + else + user[0] = 0; + + if (DBGetContactSettingString(NULL, PluginName, "Password", &dbv) == 0) + { + CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal)+1, (LPARAM)dbv.pszVal); + + mir_md5_byte_t hash[16]; + mir_md5_state_t context; + + mir_md5_init(&context); + mir_md5_append(&context, (BYTE*)dbv.pszVal, (int)strlen(dbv.pszVal)); + mir_md5_finish(&context, hash); + + arrayToHex(hash, sizeof(hash), pass); + + DBFreeVariant(&dbv); + } + else + pass[0] = 0; +} + +void OpenAuthUrl(const char* url) +{ + char user[64], pass[40]; + GetLoginStr(user, sizeof(user), pass); + + if (user[0] && pass[0]) + { + char str[256]; + + mir_snprintf(str, sizeof(str), url, user); + char* eurl = (char*)CallService(MS_NETLIB_URLENCODE, 0, (LPARAM)str); + + mir_snprintf(str, sizeof(str), "http://www.miranda-vi.org/cdlogin?name=%s&pass=%s&redir=%s", user, pass, eurl); + CallService(MS_UTILS_OPENURL, 1, (LPARAM)str); + HeapFree(GetProcessHeap(), 0, eurl); + } + else + CallService(MS_UTILS_OPENURL, 1, (LPARAM)"http://www.miranda-vi.org/"); +} + +void CreateAuthString(char* auth) +{ + char user[64], pass[40]; + GetLoginStr(user, sizeof(user), pass); + + char str[110]; + int len = mir_snprintf(str, sizeof(str), "%s:%s", user, pass); + + strcpy(auth, "Basic "); + NETLIBBASE64 nlb = { auth+6, 250, (PBYTE)str, len }; + CallService(MS_NETLIB_BASE64ENCODE, 0, LPARAM(&nlb)); +} + + +bool InternetDownloadFile(const char *szUrl, VerTrnsfr* szReq) +{ + int result = 0xBADBAD; + char* szRedirUrl = NULL; + NETLIBHTTPREQUEST nlhr = {0}; + + // initialize the netlib request + nlhr.cbSize = sizeof(nlhr); + nlhr.requestType = REQUEST_POST; + nlhr.flags = NLHRF_HTTP11 | NLHRF_NODUMP; + nlhr.szUrl = (char*)szUrl; + + nlhr.headersCount = 6; + nlhr.headers=(NETLIBHTTPHEADER*)mir_alloc(sizeof(NETLIBHTTPHEADER)*nlhr.headersCount); + nlhr.headers[0].szName = "Connection"; + nlhr.headers[0].szValue = "close"; + nlhr.headers[1].szName = "Cache-Control"; + nlhr.headers[1].szValue = "no-cache"; + nlhr.headers[2].szName = "Pragma"; + nlhr.headers[2].szValue = "no-cache"; + nlhr.headers[3].szName = "Content-Type"; + nlhr.headers[3].szValue = "text/plain; charset=utf-8"; + nlhr.headers[4].szName = "AutoUpload"; + nlhr.headers[4].szValue = (char*)(szReq->autot ? "1" : "0"); + nlhr.headers[5].szName = "Authorization"; + + char auth[256]; + CreateAuthString(auth); + nlhr.headers[5].szValue = auth; + + nlhr.pData = szReq->buf; + nlhr.dataLength = (int)strlen(szReq->buf); + + while (result == 0xBADBAD) + { + // download the page + NETLIBHTTPREQUEST *nlhrReply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, + (WPARAM)hNetlibUser,(LPARAM)&nlhr); + + if (nlhrReply) + { + int i; + + // if the recieved code is 200 OK + switch(nlhrReply->resultCode) + { + case 200: + if (DBGetContactSettingByte(NULL, PluginName, "UploadChanged", 0)) + ProcessVIHash(true); + + for (i=nlhrReply->headersCount; i--; ) + { + if (_stricmp(nlhrReply->headers[i].szName, "OldPlugins") == 0) + { + i = atoi(nlhrReply->headers[i].szValue); + break; + } + } + + ShowMessage(1, TranslateT("VersionInfo upload successful,\n %d old plugins"), i); + result = 0; + break; + + case 401: + ShowMessage(0, TranslateT("Cannot upload VersionInfo. Incorrect username or password")); + result = 1; + break; + + case 510: + ShowMessage(0, TranslateT("Cannot upload VersionInfo. User is banned")); + result = 1; + break; + + case 511: + ShowMessage(0, TranslateT("Cannot upload VersionInfo. Daily upload limit exceeded")); + result = 1; + break; + + case 301: + case 302: + case 307: + // get the url for the new location and save it to szInfo + // look for the reply header "Location" + for (i=0; iheadersCount; i++) + { + if (!strcmp(nlhrReply->headers[i].szName, "Location")) + { + size_t rlen = 0; + if (nlhrReply->headers[i].szValue[0] == '/') + { + const char* szPath; + const char* szPref = strstr(szUrl, "://"); + szPref = szPref ? szPref + 3 : szUrl; + szPath = strchr(szPref, '/'); + rlen = szPath != NULL ? szPath - szUrl : strlen(szUrl); + } + + szRedirUrl = (char*)mir_realloc(szRedirUrl, + rlen + strlen(nlhrReply->headers[i].szValue)*3 + 1); + + strncpy(szRedirUrl, szUrl, rlen); + strcpy(szRedirUrl+rlen, nlhrReply->headers[i].szValue); + + nlhr.szUrl = szRedirUrl; + break; + } + } + break; + + default: + result = 1; + ShowMessage(0, TranslateT("Cannot upload VersionInfo. Unknown error")); + } + } + else + { + result = 1; + ShowMessage(0, TranslateT("Cannot upload VersionInfo. Host unreachable.")); + } + + CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,(LPARAM)nlhrReply); + } + + mir_free(szRedirUrl); + mir_free(nlhr.headers); + + return result == 0; +} + +void __cdecl VersionInfoUploadThread(void* arg) +{ + VerTrnsfr* trn = (VerTrnsfr*)arg; + InternetDownloadFile("http://www.miranda-vi.org/uploadpost", trn); + mir_free(trn->buf); + mir_free(trn); +} + + +void UploadInit(void) +{ + NETLIBUSER nlu = {0}; + nlu.cbSize = sizeof(nlu); + nlu.flags = NUF_OUTGOING | NUF_HTTPCONNS | NUF_NOHTTPSOPTION | NUF_TCHAR; + nlu.szSettingsModule = (char*)PluginName; + nlu.ptszDescriptiveName = TranslateT("Crash Dumper HTTP connections"); + hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu); +} + +void UploadClose(void) +{ + Netlib_CloseHandle(hNetlibUser); +} + +bool ProcessVIHash(bool store) +{ + bkstring buffer; + buffer.reserve(0x1800); + PrintVersionInfo(buffer, 0); + + mir_md5_byte_t hash[16]; + mir_md5_state_t context; + + mir_md5_init(&context); + mir_md5_append(&context, (PBYTE)buffer.c_str(), (int)buffer.sizebytes()); + mir_md5_finish(&context, hash); + + char hashstr[40]; + arrayToHex(hash, sizeof(hash), hashstr); + + bool result; + if (store) + { + DBWriteContactSettingString(NULL, PluginName, "VIHash", hashstr); + result = true; + } + else + { + DBVARIANT dbv; + if (DBGetContactSettingString(NULL, PluginName, "VIHash", &dbv) == 0) + { + result = strcmp(hashstr, dbv.pszVal) == 0; + DBFreeVariant(&dbv); + } + else + result = false; + } + return result; +} diff --git a/plugins/CrashDumper/utils.cpp b/plugins/CrashDumper/utils.cpp new file mode 100644 index 0000000000..d4dced7d70 --- /dev/null +++ b/plugins/CrashDumper/utils.cpp @@ -0,0 +1,836 @@ +/* +Miranda Crash Dumper Plugin +Copyright (C) 2008 - 2012 Boris Krasnovskiy All Rights Reserved + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation version 2 +of the License. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#include "utils.h" +#include + +static HMODULE hKernel = GetModuleHandle(TEXT("kernel32.dll")); + +tGetNativeSystemInfo pGetNativeSystemInfo = (tGetNativeSystemInfo)GetProcAddress(hKernel, "GetNativeSystemInfo"); +tGetProductInfo pGetProductInfo = (tGetProductInfo) GetProcAddress(hKernel, "GetProductInfo"); +tGlobalMemoryStatusEx pGlobalMemoryStatusEx = (tGlobalMemoryStatusEx) GetProcAddress(hKernel, "GlobalMemoryStatusEx"); +tGetUserDefaultUILanguage pGetUserDefaultUILanguage = (tGetUserDefaultUILanguage) GetProcAddress(hKernel, "GetUserDefaultUILanguage"); +tGetSystemDefaultUILanguage pGetSystemDefaultUILanguage = (tGetSystemDefaultUILanguage) GetProcAddress(hKernel, "GetSystemDefaultUILanguage"); +tIsWow64Process pIsWow64Process = (tIsWow64Process) GetProcAddress(hKernel, "IsWow64Process"); +tIsProcessorFeaturePresent pIsProcessorFeaturePresent = (tIsProcessorFeaturePresent) GetProcAddress(hKernel, "IsProcessorFeaturePresent"); + + +tGetDiskFreeSpaceEx pGetDiskFreeSpaceEx = (tGetDiskFreeSpaceEx) GetProcAddress(hKernel, "GetDiskFreeSpaceExW"); + + + +void CheckForOtherCrashReportingPlugins(void) +{ + HMODULE hModule = GetModuleHandle(TEXT("attache.dll")); + if (hModule == NULL) + hModule = GetModuleHandle(TEXT("crashrpt.dll")); + if (hModule == NULL) + hModule = GetModuleHandle(TEXT("crashdmp.dll")); + + if (hModule == NULL) return; + + MessageBox(NULL, TranslateT("More then one crash reporting plugin installed. This will result in inability of creating crash reports"), + TEXT("Miranda Crash Dumper"), MB_OK | MB_ICONERROR | MB_TASKMODAL | MB_TOPMOST); +} + +void GetOSDisplayString(bkstring& buffer) +{ + OSVERSIONINFOEX osvi = {0}; + SYSTEM_INFO si = {0}; + BOOL bOsVersionInfoEx; + DWORD dwType = 0; + + osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); + + bOsVersionInfoEx = GetVersionEx((OSVERSIONINFO*)&osvi); + if (!bOsVersionInfoEx) + { + osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + if (!GetVersionEx((OSVERSIONINFO*)&osvi)) + return; + } + + // Call GetNativeSystemInfo if supported or GetSystemInfo otherwise. + pGetNativeSystemInfo = (tGetNativeSystemInfo)GetProcAddress(hKernel, "GetNativeSystemInfo"); + if (NULL != pGetNativeSystemInfo) pGetNativeSystemInfo(&si); + else GetSystemInfo(&si); + + if (VER_PLATFORM_WIN32_NT == osvi.dwPlatformId && osvi.dwMajorVersion > 4) + { + buffer.append(TEXT("Operating System: Microsoft ")); + + // Test for the specific product. + if (osvi.dwMajorVersion == 6) + { + switch (osvi.dwMinorVersion) + { + case 0: + if (osvi.wProductType == VER_NT_WORKSTATION) + buffer.append(TEXT("Windows Vista ")); + else + buffer.append(TEXT("Windows Server 2008 ")); + break; + + case 1: + if (osvi.wProductType == VER_NT_WORKSTATION) + buffer.append(TEXT("Windows 7 ")); + else + buffer.append(TEXT("Windows Server 2008 R2 ")); + break; + + default: + if (osvi.wProductType == VER_NT_WORKSTATION) + buffer.append(TEXT("Windows 8 ")); + else + buffer.append(TEXT("Windows Server 2012 ")); + break; + } + + pGetProductInfo = (tGetProductInfo) GetProcAddress(hKernel, "GetProductInfo"); + if (pGetProductInfo != NULL) pGetProductInfo(6, 0, 0, 0, &dwType); + + switch(dwType) + { + case PRODUCT_ULTIMATE: + buffer.append(TEXT("Ultimate Edition")); + break; + case PRODUCT_HOME_PREMIUM: + buffer.append(TEXT("Home Premium Edition")); + break; + case PRODUCT_HOME_BASIC: + buffer.append(TEXT("Home Basic Edition")); + break; + case PRODUCT_ENTERPRISE: + buffer.append(TEXT("Enterprise Edition")); + break; + case PRODUCT_BUSINESS: + buffer.append(TEXT("Business Edition")); + break; + case PRODUCT_STARTER: + buffer.append(TEXT("Starter Edition")); + break; + case PRODUCT_CLUSTER_SERVER: + buffer.append(TEXT("Cluster Server Edition")); + break; + case PRODUCT_DATACENTER_SERVER: + buffer.append(TEXT("Datacenter Edition")); + break; + case PRODUCT_DATACENTER_SERVER_CORE: + buffer.append(TEXT("Datacenter Edition (core installation)")); + break; + case PRODUCT_ENTERPRISE_SERVER: + buffer.append(TEXT("Enterprise Edition")); + break; + case PRODUCT_ENTERPRISE_SERVER_CORE: + buffer.append(TEXT("Enterprise Edition (core installation)")); + break; + case PRODUCT_ENTERPRISE_SERVER_IA64: + buffer.append(TEXT("Enterprise Edition for Itanium-based Systems")); + break; + case PRODUCT_SMALLBUSINESS_SERVER: + buffer.append(TEXT("Small Business Server")); + break; + case PRODUCT_SMALLBUSINESS_SERVER_PREMIUM: + buffer.append(TEXT("Small Business Server Premium Edition")); + break; + case PRODUCT_STANDARD_SERVER: + buffer.append(TEXT("Standard Edition")); + break; + case PRODUCT_STANDARD_SERVER_CORE: + buffer.append(TEXT("Standard Edition (core installation)")); + break; + case PRODUCT_WEB_SERVER: + buffer.append(TEXT("Web Server Edition")); + break; + } + + if (si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64) + buffer.append(TEXT(", 64-bit")); + else if (si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_INTEL) + buffer.append(TEXT(", 32-bit")); + } + + if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2) + { + if (GetSystemMetrics(SM_SERVERR2)) + buffer.append(TEXT("Windows Server 2003 R2, ")); + else if (osvi.wSuiteMask==VER_SUITE_STORAGE_SERVER) + buffer.append(TEXT("Windows Storage Server 2003")); + else if (osvi.wProductType == VER_NT_WORKSTATION && + si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) + buffer.append(TEXT("Windows XP Professional x64 Edition")); + else buffer.append(TEXT("Windows Server 2003, ")); + + // Test for the server type. + if (osvi.wProductType != VER_NT_WORKSTATION) + { + if (si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_IA64) + { + if(osvi.wSuiteMask & VER_SUITE_DATACENTER) + buffer.append(TEXT("Datacenter Edition for Itanium-based Systems")); + else if(osvi.wSuiteMask & VER_SUITE_ENTERPRISE) + buffer.append(TEXT("Enterprise Edition for Itanium-based Systems")); + } + + else if (si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64) + { + if(osvi.wSuiteMask & VER_SUITE_DATACENTER) + buffer.append(TEXT("Datacenter x64 Edition")); + else if(osvi.wSuiteMask & VER_SUITE_ENTERPRISE) + buffer.append(TEXT("Enterprise x64 Edition")); + else buffer.append(TEXT("Standard x64 Edition")); + } + + else + { + if (osvi.wSuiteMask & VER_SUITE_COMPUTE_SERVER) + buffer.append(TEXT("Compute Cluster Edition")); + else if(osvi.wSuiteMask & VER_SUITE_DATACENTER) + buffer.append(TEXT("Datacenter Edition")); + else if(osvi.wSuiteMask & VER_SUITE_ENTERPRISE) + buffer.append(TEXT("Enterprise Edition")); + else if (osvi.wSuiteMask & VER_SUITE_BLADE) + buffer.append(TEXT("Web Edition")); + else buffer.append(TEXT("Standard Edition")); + } + } + } + + if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1) + { + buffer.append(TEXT("Windows XP ")); + if (osvi.wSuiteMask & VER_SUITE_PERSONAL) + buffer.append(TEXT("Home Edition")); + else + buffer.append(TEXT("Professional")); + } + + if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0) + { + buffer.append(TEXT("Windows 2000 ")); + + if (osvi.wProductType == VER_NT_WORKSTATION) + { + buffer.append(TEXT("Professional")); + } + else + { + if(osvi.wSuiteMask & VER_SUITE_DATACENTER) + buffer.append(TEXT("Datacenter Server")); + else if(osvi.wSuiteMask & VER_SUITE_ENTERPRISE) + buffer.append(TEXT("Advanced Server")); + else buffer.append(TEXT("Server")); + } + } + if (_tcslen(osvi.szCSDVersion) > 0) + { + buffer.append(TEXT(" ")); + buffer.append(osvi.szCSDVersion); + } + + buffer.appendfmt(TEXT(" (build %d)"), osvi.dwBuildNumber); + } + else + { + if (VER_PLATFORM_WIN32_NT == osvi.dwPlatformId) + { + buffer.append(TEXT("Microsoft Windows NT ")); + if (osvi.wProductType == VER_NT_WORKSTATION) + buffer.append(TEXT("Workstation 4.0 ")); + else if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE) + buffer.append(TEXT("Server 4.0, Enterprise Edition ")); + else + buffer.append(TEXT("Server 4.0 ")); + } + + if (osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS && osvi.dwMajorVersion == 4) + { + if (osvi.dwMinorVersion == 0) + { + buffer.append(TEXT("Microsoft Windows 95 ")); + if (osvi.szCSDVersion[1]==TEXT('C') || osvi.szCSDVersion[1]==TEXT('B')) + buffer.append(TEXT("OSR2 ")); + } + + if (osvi.dwMinorVersion == 10) + { + buffer.append(TEXT("Microsoft Windows 98 ")); + if (osvi.szCSDVersion[1]==TEXT('A') || osvi.szCSDVersion[1]==TEXT('B')) + buffer.append(TEXT("SE ")); + } + + if (osvi.dwMinorVersion == 90) + { + buffer.append(TEXT("Microsoft Windows Millennium Edition")); + } + buffer.appendfmt(TEXT("(build %d)"), LOWORD(osvi.dwBuildNumber)); + } + else if (osvi.dwPlatformId == VER_PLATFORM_WIN32s) + { + buffer.append(TEXT("Microsoft Win32s")); + } + } +} + +int GetTZOffset(void) +{ + TIME_ZONE_INFORMATION tzInfo = {0}; + DWORD type = GetTimeZoneInformation(&tzInfo); + + int offset = 0; + switch (type) + { + case TIME_ZONE_ID_DAYLIGHT: + offset = -(tzInfo.Bias + tzInfo.DaylightBias); + break; + + case TIME_ZONE_ID_STANDARD: + offset = -(tzInfo.Bias + tzInfo.StandardBias); + break; + + case TIME_ZONE_ID_UNKNOWN: + offset = -tzInfo.Bias; + break; + } + return offset; +} + +void GetISO8061Time(SYSTEMTIME* stLocal, LPTSTR lpszString, DWORD dwSize) +{ + SYSTEMTIME loctime; + if (stLocal == NULL) + { + stLocal = &loctime; + GetLocalTime(stLocal); + } + + if (clsdates) + { + GetDateFormat(LOCALE_INVARIANT, 0, stLocal, TEXT("d MMM yyyy"), lpszString, dwSize); + int dlen = (int)_tcslen(lpszString); + GetTimeFormat(LOCALE_INVARIANT, 0, stLocal, TEXT(" H:mm:ss"), lpszString+dlen, dwSize-dlen); + } + else + { + int offset = GetTZOffset(); + + // Build a string showing the date and time. + crs_sntprintf(lpszString, dwSize, TEXT("%d-%02d-%02d %02d:%02d:%02d%+03d%02d"), + stLocal->wYear, stLocal->wMonth, stLocal->wDay, + stLocal->wHour, stLocal->wMinute, stLocal->wSecond, + offset / 60, offset % 60); + } +} + +void GetLastWriteTime(FILETIME* ftime, LPTSTR lpszString, DWORD dwSize) +{ + FILETIME ftLocal; + SYSTEMTIME stLocal; + + // Convert the last-write time to local time. + FileTimeToLocalFileTime(ftime, &ftLocal); + FileTimeToSystemTime(&ftLocal, &stLocal); + + GetISO8061Time(&stLocal, lpszString, dwSize); +} + +void GetLastWriteTime(LPCTSTR fileName, LPTSTR lpszString, DWORD dwSize) +{ + WIN32_FIND_DATA FindFileData; + + HANDLE hFind = FindFirstFile(fileName, &FindFileData); + if (hFind == INVALID_HANDLE_VALUE) return; + FindClose(hFind); + + GetLastWriteTime(&FindFileData.ftLastWriteTime, lpszString, dwSize); +} + +typedef PLUGININFOEX * (__cdecl * Miranda_Plugin_Info) (DWORD mirandaVersion); + +PLUGININFOEX* GetMirInfo(HMODULE hModule) +{ + Miranda_Plugin_Info bpi = (Miranda_Plugin_Info)GetProcAddress(hModule, "MirandaPluginInfoEx"); + if (bpi == NULL) + return NULL; + + return bpi(mirandaVersion); +} + + +void GetInternetExplorerVersion(bkstring& buffer) +{ + HKEY hKey; + DWORD size; + + TCHAR ieVersion[1024] = {0}; + TCHAR ieBuild[512] = {0}; + TCHAR iVer[64] = {0}; + + if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Microsoft\\Internet Explorer"), 0, + KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) + { + size = sizeof(ieBuild)/sizeof(ieBuild[0]); + if (RegQueryValueEx(hKey, TEXT("Build"), NULL, NULL, (LPBYTE) ieBuild, &size) != ERROR_SUCCESS) + ieBuild[0] = 0; + + size = sizeof(ieVersion)/sizeof(ieVersion[0]); + if (RegQueryValueEx(hKey, TEXT("Version"), NULL, NULL, (LPBYTE) ieVersion, &size) != ERROR_SUCCESS) + ieVersion[0] = 0; + + size = sizeof(iVer)/sizeof(iVer[0]); + if (RegQueryValueEx(hKey, TEXT("IVer"), NULL, NULL, (LPBYTE) iVer, &size) != ERROR_SUCCESS) + iVer[0] = 0; + + RegCloseKey(hKey); + } + + buffer.append(TEXT("Internet Explorer: ")); + if (ieVersion[0] == 0) + { + if (iVer[0] == 0) + buffer.append(TEXT("")); + else if (_tcscmp(iVer, TEXT("100")) == 0) + buffer.append(TEXT("1.0")); + else if (_tcscmp(iVer, TEXT("101")) == 0) + buffer.append(TEXT("NT")); + else if (_tcscmp(iVer, TEXT("102")) == 0) + buffer.append(TEXT("2.0")); + else if (_tcscmp(iVer, TEXT("103")) == 0) + buffer.append(TEXT("3.0")); + } + else + { + buffer.append(ieVersion); + } + if (ieBuild[0] != 0) + { + buffer.appendfmt(TEXT(" (build %s)"), ieBuild); + } +} + + +void TrimMultiSpaces(TCHAR* str) +{ + TCHAR *src = str, *dest = str; + bool trimst = false; + + for (;;) + { + if (*src == TEXT(' ')) + { + if (!trimst) + { + trimst = true; + *dest++ = *src; + } + } + else + { + trimst = false; + *dest++ = *src; + } + if (*src++ == 0) break; + } +} + +void GetProcessorString(bkstring& buffer) +{ + HKEY hKey; + DWORD size; + + TCHAR cpuIdent[512] = {0}; + TCHAR cpuName[512] = {0}; + + if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("Hardware\\Description\\System\\CentralProcessor\\0"), 0, + KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) + { + size = sizeof(cpuName)/sizeof(cpuName[0]); + if (RegQueryValueEx(hKey, TEXT("ProcessorNameString"), NULL, NULL, (LPBYTE) cpuName, &size) != ERROR_SUCCESS) + _tcscpy(cpuName, TEXT("Unknown")); + + size = sizeof(cpuIdent)/sizeof(cpuIdent[0]); + if (RegQueryValueEx(hKey, TEXT("Identifier"), NULL, NULL, (LPBYTE) cpuIdent, &size) != ERROR_SUCCESS) + if (RegQueryValueEx(hKey, TEXT("VendorIdentifier"), NULL, NULL, (LPBYTE) cpuIdent, &size) != ERROR_SUCCESS) + _tcscpy(cpuIdent, TEXT("Unknown")); + + RegCloseKey(hKey); + } + TrimMultiSpaces(cpuName); + buffer.appendfmt(TEXT("CPU: %s [%s]"), cpuName, cpuIdent); + + if (pIsProcessorFeaturePresent && pIsProcessorFeaturePresent(PF_NX_ENABLED)) + buffer.append(TEXT(" [DEP Enabled]")); + + SYSTEM_INFO si = {0}; + GetSystemInfo(&si); + + if (si.dwNumberOfProcessors > 1) + buffer.appendfmt(TEXT(" [%u CPUs]"), si.dwNumberOfProcessors); +} + +void GetFreeMemoryString(bkstring& buffer) +{ + unsigned ram; + if (pGlobalMemoryStatusEx) + { + MEMORYSTATUSEX ms = {0}; + ms.dwLength = sizeof(ms); + pGlobalMemoryStatusEx(&ms); + ram = (unsigned int) ((ms.ullTotalPhys / (1024 * 1024)) + 1); + } + else + { + MEMORYSTATUS ms = {0}; + ZeroMemory(&ms, sizeof(ms)); + ms.dwLength = sizeof(ms); + GlobalMemoryStatus(&ms); + ram = (unsigned int)(ms.dwTotalPhys/(1024*1024))+1; + } + buffer.appendfmt(TEXT("Installed RAM: %u MBytes"), ram); +} + +void GetFreeDiskString(LPCTSTR dirname, bkstring& buffer) +{ + ULARGE_INTEGER tnb, tfb, fs = {0}; + if (pGetDiskFreeSpaceEx) + pGetDiskFreeSpaceEx(dirname, &fs, &tnb, &tfb); + else + { + DWORD SectorsPerCluster, BytesPerSector; + DWORD NumberOfFreeClusters, TotalNumberOfClusters; + + GetDiskFreeSpace(dirname, &SectorsPerCluster, &BytesPerSector, + &NumberOfFreeClusters, &TotalNumberOfClusters); + + fs.QuadPart = BytesPerSector * SectorsPerCluster; + fs.QuadPart *= NumberOfFreeClusters; + } + fs.QuadPart /= (1024*1024); + + buffer.appendfmt(TEXT("Free disk space on Miranda partition: %u MBytes"), fs.LowPart); +} + +void ReadableExceptionInfo(PEXCEPTION_RECORD excrec, bkstring& buffer) +{ + buffer.append(TEXT("Exception: ")); + + switch (excrec->ExceptionCode) + { + case EXCEPTION_BREAKPOINT: + buffer.append(TEXT("User Defined Breakpoint")); + break; + + case EXCEPTION_ACCESS_VIOLATION: + buffer.append(TEXT("Access Violation")); + break; + + case EXCEPTION_ARRAY_BOUNDS_EXCEEDED: + buffer.append(TEXT("Array Bounds Exceeded")); + break; + + case EXCEPTION_DATATYPE_MISALIGNMENT: + buffer.append(TEXT("Datatype Misalignment")); + break; + + case EXCEPTION_FLT_DENORMAL_OPERAND: + buffer.append(TEXT("Floating Point denormlized operand")); + break; + + case EXCEPTION_FLT_DIVIDE_BY_ZERO: + buffer.append(TEXT("Floating Point divide by 0")); + break; + + case EXCEPTION_FLT_INEXACT_RESULT: + buffer.append(TEXT("Floating Point inexact result")); + break; + + case EXCEPTION_FLT_INVALID_OPERATION: + buffer.append(TEXT("Floating Point invalid operation")); + break; + + case EXCEPTION_FLT_OVERFLOW: + buffer.append(TEXT("Floating Point overflow")); + break; + + case EXCEPTION_FLT_STACK_CHECK: + buffer.append(TEXT("Floating Point stack overflow/underflow")); + break; + + case EXCEPTION_FLT_UNDERFLOW: + buffer.append(TEXT("Floating Point underflow")); + break; + + case EXCEPTION_ILLEGAL_INSTRUCTION: + buffer.append(TEXT("Invalid instruction executed")); + break; + + case EXCEPTION_IN_PAGE_ERROR: + buffer.append(TEXT("Access to the not present page")); + break; + + case EXCEPTION_INT_DIVIDE_BY_ZERO: + buffer.append(TEXT("Integer divide by zero")); + break; + + case EXCEPTION_INT_OVERFLOW: + buffer.append(TEXT("Integer overflow")); + break; + + case EXCEPTION_PRIV_INSTRUCTION: + buffer.append(TEXT("Priveleged instruction executed")); + break; + + case EXCEPTION_STACK_OVERFLOW: + buffer.append(TEXT("Stack overflow")); + break; + + case 0xe06d7363: + buffer.append(TEXT("Unhandled C++ software exception")); + break; + + default: + buffer.appendfmt(TEXT("%x"), excrec->ExceptionCode); + break; + } + + buffer.appendfmt(TEXT(" at address %p."), excrec->ExceptionAddress); + + if (excrec->ExceptionCode == EXCEPTION_ACCESS_VIOLATION || + excrec->ExceptionCode == EXCEPTION_IN_PAGE_ERROR) + { + switch(excrec->ExceptionInformation[0]) + { + case 0: + buffer.appendfmt(TEXT(" Reading from address %p."), (LPVOID)excrec->ExceptionInformation[1]); + break; + + case 1: + buffer.appendfmt(TEXT(" Writing to address %p."), (LPVOID)excrec->ExceptionInformation[1]); + break; + + case 8: + buffer.appendfmt(TEXT(" DEP at address %p."), (LPVOID)excrec->ExceptionInformation[1]); + break; + } + } +} + +void GetAdminString(bkstring& buffer) +{ + BOOL b; + __try + { + SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY; + PSID AdministratorsGroup; + + b = AllocateAndInitializeSid(&NtAuthority, 2, SECURITY_BUILTIN_DOMAIN_RID, + DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &AdministratorsGroup); + if (b) + { + if (!CheckTokenMembership(NULL, AdministratorsGroup, &b)) + b = FALSE; + FreeSid(AdministratorsGroup); + } + else + b = GetLastError() == ERROR_CALL_NOT_IMPLEMENTED; + } + __except(EXCEPTION_EXECUTE_HANDLER) + { + b = TRUE; + } + + buffer.appendfmt(TEXT("Administrator privileges: %s"), b ? TEXT("Yes") : TEXT ("No")); +} + +void GetLanguageString(bkstring& buffer) +{ + TCHAR name1[256], name2[256], name3[256], name4[256]; + + GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SENGLANGUAGE, name1, 256); + GetLocaleInfo(LOCALE_SYSTEM_DEFAULT, LOCALE_SENGLANGUAGE, name2, 256); + + if (pGetUserDefaultUILanguage && pGetSystemDefaultUILanguage) + { + GetLocaleInfo(MAKELCID(pGetUserDefaultUILanguage(), SORT_DEFAULT), LOCALE_SENGLANGUAGE, name3, 256); + GetLocaleInfo(MAKELCID(pGetSystemDefaultUILanguage(), SORT_DEFAULT), LOCALE_SENGLANGUAGE, name4, 256); + } + else + { + _tcscpy(name3, name1); + _tcscpy(name4, name2); + } + + buffer.appendfmt(TEXT("OS Languages: (UI | Locale (User/System)) : %s/%s | %s/%s"), name3, name4, name1, name2); +} + +void GetLanguagePackString(bkstring& buffer) +{ + buffer.append(TEXT("Language pack: ")); + if (packlcid == LOCALE_USER_DEFAULT) + buffer.append(TEXT("No language pack installed")); + else + { + TCHAR path[MAX_PATH] = TEXT("Locale id invalid"); + GetLocaleInfo(packlcid, LOCALE_SENGLANGUAGE, path, MAX_PATH); + buffer.append(path); + + GetLocaleInfo(packlcid, LOCALE_SISO3166CTRYNAME, path, MAX_PATH); + buffer.appendfmt(TEXT(" (%s) [%04x]"), path, packlcid); + + GetModuleFileName(NULL, path, MAX_PATH); + + LPTSTR fname = _tcsrchr(path, TEXT('\\')); + if (fname == NULL) fname = path; + crs_sntprintf(fname, MAX_PATH-(fname-path), TEXT("\\langpack_*.txt")); + + WIN32_FIND_DATA FindFileData; + HANDLE hFind = FindFirstFile(path, &FindFileData); + if (hFind == INVALID_HANDLE_VALUE) return; + FindClose(hFind); + + crs_sntprintf(fname, MAX_PATH-(fname-path), TEXT("\\%s"), FindFileData.cFileName); + HANDLE hDumpFile = CreateFile(path, GENERIC_READ, FILE_SHARE_READ, NULL, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + + if (hDumpFile != INVALID_HANDLE_VALUE) + { + char buf[8192]; + + DWORD bytes = 0; + ReadFile(hDumpFile, buf, 8190, &bytes, NULL); + buf[bytes] = 0; + + char *id = strstr(buf, "FLID:"); + if (id != NULL) + { + char *endid = strchr(id, '\r'); + if (endid != NULL) *endid = 0; + + endid = strchr(id, '\n'); + if (endid != NULL) *endid = 0; + + TCHAR mirtime[30]; + GetLastWriteTime(path, mirtime, 30); + + TCHAR* tid; + crsi_a2t(tid, id+5); + buffer.appendfmt(TEXT(", %s, modified: %s"), tid, mirtime); + } + CloseHandle(hDumpFile); + } + } +} + +void GetWow64String(bkstring& buffer) +{ + BOOL wow64 = 0; + if (pIsWow64Process) + { + if (!pIsWow64Process(GetCurrentProcess(), &wow64)) + { + wow64 = 0; + } + } + if (wow64) buffer.append(TEXT(" [running inside WOW64]")); +} + + +bool CreateDirectoryTree(LPTSTR szDir) +{ + DWORD dwAttr = GetFileAttributes(szDir); + if (dwAttr != INVALID_FILE_ATTRIBUTES && (dwAttr & FILE_ATTRIBUTE_DIRECTORY)) + return true; + + TCHAR* pszSlash = _tcsrchr(szDir, TEXT('\\')); + if (pszSlash == NULL) + return false; + + *pszSlash = 0; + bool res = CreateDirectoryTree(szDir); + *pszSlash = TEXT('\\'); + + if (res) res = CreateDirectory(szDir, NULL) != 0; + + return res; +} + +int crs_sntprintf(TCHAR *buffer, size_t count, const TCHAR* fmt, ...) +{ + va_list va; + va_start(va, fmt); + + int len = _vsntprintf(buffer, count-1, fmt, va); + buffer[len] = 0; + + va_end(va); + return len; +} + +void GetVersionInfo(HMODULE hLib, bkstring& buffer) +{ + HRSRC hVersion = FindResource(hLib, MAKEINTRESOURCE(VS_VERSION_INFO), RT_VERSION); + if (hVersion != NULL) + { + HGLOBAL hGlobal = LoadResource(hLib, hVersion); + if (hGlobal != NULL) + { + LPVOID versionInfo = LockResource(hGlobal); + if (versionInfo != NULL) + { + int vl = *(unsigned short*)versionInfo; + unsigned *res = (unsigned*)versionInfo; + while (*res != 0xfeef04bd && ((char*)res - (char*)versionInfo) < vl) ++res; + + if (((char*)res - (char*)versionInfo) < vl) + { + VS_FIXEDFILEINFO *vsInfo = (VS_FIXEDFILEINFO*)res; + buffer.appendfmt(TEXT(" v.%u.%u.%u.%u"), + HIWORD(vsInfo->dwFileVersionMS), LOWORD(vsInfo->dwFileVersionMS), + HIWORD(vsInfo->dwFileVersionLS), LOWORD(vsInfo->dwFileVersionLS)); + } + } + FreeResource(hGlobal); + } + } +} + +void StoreStringToClip(bkstring& buffer) +{ + HANDLE hData = GlobalAlloc(GMEM_MOVEABLE, buffer.sizebytes() + sizeof(TCHAR)); + LPSTR buf = (LPSTR)GlobalLock(hData); + + memcpy(buf, buffer.c_str(), buffer.sizebytes() + sizeof(TCHAR)); + + GlobalUnlock(hData); + + OpenClipboard(NULL); + EmptyClipboard(); + + + SetClipboardData(CF_UNICODETEXT, hData); + +} + +bool IsPluginEnabled(TCHAR* filename) +{ + char* fname; + crsi_t2a(fname, filename); + char* ext = strstr(_strlwr(fname), ".dll"); + bool res = ext && ext[4] == '\0' && DBGetContactSettingByte(NULL, "PluginDisable", fname, 0) == 0; + return res; +} diff --git a/plugins/CrashDumper/utils.h b/plugins/CrashDumper/utils.h new file mode 100644 index 0000000000..9089f57571 --- /dev/null +++ b/plugins/CrashDumper/utils.h @@ -0,0 +1,177 @@ +/* +Miranda Crash Dumper Plugin +Copyright (C) 2008 - 2012 Boris Krasnovskiy All Rights Reserved + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation version 2 +of the License. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#define _CRT_SECURE_NO_WARNINGS +#define MIRANDA_VER 0x0A00 + +#include +#include "sdkstuff.h" + +#ifdef _MSC_VER +#include +#endif + +#include + +#include "resource.h" + +#include + +#ifdef _MSC_VER + +#pragma warning( push ) +#pragma warning( disable : 4201 4100 ) +#include +#pragma warning( pop ) + +#else + +#include + +#endif + +#ifdef __GNUC__ +#endif + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "bkstring.h" + +#define MS_PROTO_ENUMPROTOS "Proto/EnumProtos" + +int crs_sntprintf(TCHAR *buffer, size_t count, const TCHAR* fmt, ...); + +#define crsi_u2a(dst, src) \ +{ \ + int cbLen = WideCharToMultiByte(CP_ACP, 0, src, -1, NULL, 0, NULL, NULL); \ + dst = (char*)alloca(cbLen+1); \ + WideCharToMultiByte(CP_ACP, 0, src, -1, dst, cbLen, NULL, NULL); \ +} + +#define crsi_a2u(dst, src, alloc) \ +{ \ + int cbLen = MultiByteToWideChar(CP_ACP, 0, src, -1, NULL, 0); \ + dst = (wchar_t*)alloc(sizeof(wchar_t) * (cbLen+1)); \ + MultiByteToWideChar(CP_ACP, 0, src, -1, dst, cbLen); \ +} + + + +#define crsi_t2a(d,s) crsi_u2a(d,s) +#define crsi_a2t(d,s) crsi_a2u(d,s,alloca) +#define crs_a2t(d,s) crsi_a2u(d,s,mir_alloc) + + + +#define SIZEOF(X) (sizeof(X)/sizeof(X[0])) + +#define MS_CRASHDUMPER_STORETOFILE "CrashDmp/StoreVerInfoToFile" +#define MS_CRASHDUMPER_STORETOCLIP "CrashDmp/StoreVerInfoToClip" +#define MS_CRASHDUMPER_GETINFO "Versioninfo/GetInfo" +#define MS_CRASHDUMPER_VIEWINFO "CrashDmp/ViewInfo" +#define MS_CRASHDUMPER_UPLOAD "CrashDmp/UploadInfo" +#define MS_CRASHDUMPER_URL "CrashDmp/StartUrl" + +#define PluginName "Crash Dumper" + +#define VI_FLAG_FORMAT 1 +#define VI_FLAG_PRNVAR 2 +#define VI_FLAG_PRNDLL 4 +#define VI_FLAG_WEATHER 8 + +struct VerTrnsfr +{ + char* buf; + bool autot; +}; + +extern HMODULE hInst; +extern DWORD mirandaVersion; +extern LCID packlcid; +extern bool servicemode; +extern bool clsdates; +extern bool dtsubfldr; + +extern TCHAR CrashLogFolder[MAX_PATH]; +extern TCHAR VersionInfoFolder[MAX_PATH]; + +void WriteBBFile(bkstring& buffer, bool hdr); +void WriteUtfFile(HANDLE hDumpFile, char* bufu); +void UnloadDbgHlp(void); + +LONG WINAPI myfilter(PEXCEPTION_POINTERS exc_ptr); +LONG WINAPI myfilterv(PEXCEPTION_POINTERS exc_ptr); +DWORD MirandaThreadFilter(DWORD code, EXCEPTION_POINTERS* info); + +void GetOSDisplayString(bkstring& buffer); +void GetInternetExplorerVersion(bkstring& buffer); +void GetProcessorString(bkstring& buffer); +void GetFreeMemoryString(bkstring& buffer); +void GetFreeDiskString(LPCTSTR dirname, bkstring& buffer); +void GetAdminString(bkstring& buffer); +void GetLanguageString(bkstring& buffer); +void GetLanguagePackString(bkstring& buffer); +void GetWow64String(bkstring& buffer); +void GetVersionInfo(HMODULE hLib, bkstring& buffer); + +void GetISO8061Time(SYSTEMTIME* stLocal, LPTSTR lpszString, DWORD dwSize); + +void ReadableExceptionInfo(PEXCEPTION_RECORD excrec, bkstring& buffer); + +void GetLastWriteTime(LPCTSTR fileName, LPTSTR lpszString, DWORD dwSize); +void GetLastWriteTime(FILETIME* ftime, LPTSTR lpszString, DWORD dwSize); +bool CreateDirectoryTree(LPTSTR szDir); +void StoreStringToClip(bkstring& buffer); +void ShowMessage(int type, const TCHAR* format, ...); +bool IsPluginEnabled(TCHAR* filename); + +PLUGININFOEX* GetMirInfo(HMODULE hModule); +const PLUGININFOEX* GetPluginInfoEx(void); + +void CreateMiniDump (HANDLE hDumpFile, PEXCEPTION_POINTERS exc_ptr); +void CreateCrashReport(HANDLE hDumpFile, PEXCEPTION_POINTERS exc_ptr, const TCHAR* msg); +void PrintVersionInfo(bkstring& buffer, unsigned flags = VI_FLAG_PRNVAR); +bool ProcessVIHash(bool store); + +void InitExceptionHandler(void); +void DestroyExceptionHandler(void); +void SetExceptionHandler(void); +void RemoveExceptionHandler(void); +void CheckForOtherCrashReportingPlugins(void); + +INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); +INT_PTR CALLBACK DlgProcView(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); +void DestroyAllWindows(void); + +void UploadInit(void); +void UploadClose(void); +void OpenAuthUrl(const char* url); +void __cdecl VersionInfoUploadThread(void* arg); + +void InitIcons(void); +HICON LoadIconEx(const char* name, bool big = false); +HANDLE GetIconHandle(const char* name); +void ReleaseIconEx(const char* name); +void ReleaseIconEx(HICON hIcon); diff --git a/plugins/CrashDumper/vc6/dbghelp.h b/plugins/CrashDumper/vc6/dbghelp.h new file mode 100644 index 0000000000..d8a713060b --- /dev/null +++ b/plugins/CrashDumper/vc6/dbghelp.h @@ -0,0 +1,4532 @@ +/*++ BUILD Version: 0000 Increment this if a change has global effects + +Copyright (c) Microsoft Corporation. All rights reserved. + +Module Name: + + dbghelp.h + +Abstract: + + This module defines the prototypes and constants required for the image + help routines. + + Contains debugging support routines that are redistributable. + +Revision History: + +--*/ + +#ifndef _DBGHELP_ +#define _DBGHELP_ + +#if _MSC_VER > 1020 +#pragma once +#endif + + +// As a general principal always call the 64 bit version +// of every API, if a choice exists. The 64 bit version +// works great on 32 bit platforms, and is forward +// compatible to 64 bit platforms. + +#ifdef _WIN64 +#ifndef _IMAGEHLP64 +#define _IMAGEHLP64 +#endif +#endif + +// For those without specstrings.h +// Since there are different versions of this header, I need to +// individually test each item and define it if it is not around. + +#ifndef __in + #define __in +#endif +#ifndef __out + #define __out +#endif +#ifndef __inout + #define __inout +#endif +#ifndef __in_opt + #define __in_opt +#endif +#ifndef __out_opt + #define __out_opt +#endif +#ifndef __inout_opt + #define __inout_opt +#endif +#ifndef __in_ecount + #define __in_ecount(x) +#endif +#ifndef __out_ecount + #define __out_ecount(x) +#endif +#ifndef __inout_ecount + #define __inout_ecount(x) +#endif +#ifndef __in_bcount + #define __in_bcount(x) +#endif +#ifndef __out_bcount + #define __out_bcount(x) +#endif +#ifndef __inout_bcount + #define __inout_bcount(x) +#endif +#ifndef __out_xcount + #define __out_xcount(x) +#endif +#ifndef __deref_opt_out + #define __deref_opt_out +#endif +#ifndef __deref_out + #define __deref_out +#endif +#ifndef __out_ecount_opt + #define __out_ecount_opt(x) +#endif + + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _IMAGEHLP_SOURCE_ + #define IMAGEAPI __stdcall + #define DBHLP_DEPRECIATED +#else + #define IMAGEAPI DECLSPEC_IMPORT __stdcall + #if (_MSC_VER >= 1300) && !defined(MIDL_PASS) + #define DBHLP_DEPRECIATED __declspec(deprecated) + #else + #define DBHLP_DEPRECIATED + #endif +#endif + +#define DBHLPAPI IMAGEAPI + +#define IMAGE_SEPARATION (64*1024) + +// Observant readers may notice that 2 new fields, +// 'fReadOnly' and 'Version' have been added to +// the LOADED_IMAGE structure after 'fDOSImage'. +// This does not change the size of the structure +// from previous headers. That is because while +// 'fDOSImage' is a byte, it is padded by the +// compiler to 4 bytes. So the 2 new fields are +// slipped into the extra space. + +typedef struct _LOADED_IMAGE { + PSTR ModuleName; + HANDLE hFile; + PUCHAR MappedAddress; +#ifdef _IMAGEHLP64 + PIMAGE_NT_HEADERS64 FileHeader; +#else + PIMAGE_NT_HEADERS32 FileHeader; +#endif + PIMAGE_SECTION_HEADER LastRvaSection; + ULONG NumberOfSections; + PIMAGE_SECTION_HEADER Sections; + ULONG Characteristics; + BOOLEAN fSystemImage; + BOOLEAN fDOSImage; + BOOLEAN fReadOnly; + UCHAR Version; + LIST_ENTRY Links; + ULONG SizeOfImage; +} LOADED_IMAGE, *PLOADED_IMAGE; + +#define MAX_SYM_NAME 2000 + + +// Error codes set by dbghelp functions. Call GetLastError +// to see them. +// Dbghelp also sets error codes found in winerror.h + +#define ERROR_IMAGE_NOT_STRIPPED 0x8800 // the image is not stripped. No dbg file available. +#define ERROR_NO_DBG_POINTER 0x8801 // image is stripped but there is no pointer to a dbg file +#define ERROR_NO_PDB_POINTER 0x8802 // image does not point to a pdb file + +typedef BOOL +(CALLBACK *PFIND_DEBUG_FILE_CALLBACK)( + __in HANDLE FileHandle, + __in PCSTR FileName, + __in PVOID CallerData + ); + +HANDLE +IMAGEAPI +SymFindDebugInfoFile( + __in HANDLE hProcess, + __in PCSTR FileName, + __out_ecount(MAX_PATH + 1) PSTR DebugFilePath, + __in_opt PFIND_DEBUG_FILE_CALLBACK Callback, + __in_opt PVOID CallerData + ); + +typedef BOOL +(CALLBACK *PFIND_DEBUG_FILE_CALLBACKW)( + __in HANDLE FileHandle, + __in PCWSTR FileName, + __in PVOID CallerData + ); + +HANDLE +IMAGEAPI +SymFindDebugInfoFileW( + __in HANDLE hProcess, + __in PCWSTR FileName, + __out_ecount(MAX_PATH + 1) PWSTR DebugFilePath, + __in_opt PFIND_DEBUG_FILE_CALLBACKW Callback, + __in_opt PVOID CallerData + ); + +HANDLE +IMAGEAPI +FindDebugInfoFile ( + __in PCSTR FileName, + __in PCSTR SymbolPath, + __out_ecount(MAX_PATH + 1) PSTR DebugFilePath + ); + +HANDLE +IMAGEAPI +FindDebugInfoFileEx ( + __in PCSTR FileName, + __in PCSTR SymbolPath, + __out_ecount(MAX_PATH + 1) PSTR DebugFilePath, + __in_opt PFIND_DEBUG_FILE_CALLBACK Callback, + __in_opt PVOID CallerData + ); + +HANDLE +IMAGEAPI +FindDebugInfoFileExW ( + __in PCWSTR FileName, + __in PCWSTR SymbolPath, + __out_ecount(MAX_PATH + 1) PWSTR DebugFilePath, + __in_opt PFIND_DEBUG_FILE_CALLBACKW Callback, + __in_opt PVOID CallerData + ); + +typedef BOOL +(CALLBACK *PFINDFILEINPATHCALLBACK)( + PCSTR filename, + PVOID context + ); + +BOOL +IMAGEAPI +SymFindFileInPath( + __in HANDLE hprocess, + __in_opt PCSTR SearchPath, + __in PCSTR FileName, + __in_opt PVOID id, + __in DWORD two, + __in DWORD three, + __in DWORD flags, + __out_ecount(MAX_PATH + 1) PSTR FoundFile, + __in_opt PFINDFILEINPATHCALLBACK callback, + __in_opt PVOID context + ); + +typedef BOOL +(CALLBACK *PFINDFILEINPATHCALLBACKW)( + __in PCWSTR filename, + __in PVOID context + ); + +BOOL +IMAGEAPI +SymFindFileInPathW( + __in HANDLE hprocess, + __in_opt PCWSTR SearchPath, + __in PCWSTR FileName, + __in_opt PVOID id, + __in DWORD two, + __in DWORD three, + __in DWORD flags, + __out_ecount(MAX_PATH + 1) PWSTR FoundFile, + __in_opt PFINDFILEINPATHCALLBACKW callback, + __in_opt PVOID context + ); + +typedef BOOL +(CALLBACK *PFIND_EXE_FILE_CALLBACK)( + __in HANDLE FileHandle, + __in PCSTR FileName, + __in_opt PVOID CallerData + ); + +HANDLE +IMAGEAPI +SymFindExecutableImage( + __in HANDLE hProcess, + __in PCSTR FileName, + __out_ecount(MAX_PATH + 1) PSTR ImageFilePath, + __in PFIND_EXE_FILE_CALLBACK Callback, + __in PVOID CallerData + ); + +typedef BOOL +(CALLBACK *PFIND_EXE_FILE_CALLBACKW)( + __in HANDLE FileHandle, + __in PCWSTR FileName, + __in_opt PVOID CallerData + ); + +HANDLE +IMAGEAPI +SymFindExecutableImageW( + __in HANDLE hProcess, + __in PCWSTR FileName, + __out_ecount(MAX_PATH + 1) PWSTR ImageFilePath, + __in PFIND_EXE_FILE_CALLBACKW Callback, + __in PVOID CallerData + ); + +HANDLE +IMAGEAPI +FindExecutableImage( + __in PCSTR FileName, + __in PCSTR SymbolPath, + __out_ecount(MAX_PATH + 1) PSTR ImageFilePath + ); + +HANDLE +IMAGEAPI +FindExecutableImageEx( + __in PCSTR FileName, + __in PCSTR SymbolPath, + __out_ecount(MAX_PATH + 1) PSTR ImageFilePath, + __in_opt PFIND_EXE_FILE_CALLBACK Callback, + __in_opt PVOID CallerData + ); + +HANDLE +IMAGEAPI +FindExecutableImageExW( + __in PCWSTR FileName, + __in PCWSTR SymbolPath, + __out_ecount(MAX_PATH + 1) PWSTR ImageFilePath, + __in_opt PFIND_EXE_FILE_CALLBACKW Callback, + __in PVOID CallerData + ); + +PIMAGE_NT_HEADERS +IMAGEAPI +ImageNtHeader ( + __in PVOID Base + ); + +PVOID +IMAGEAPI +ImageDirectoryEntryToDataEx ( + __in PVOID Base, + __in BOOLEAN MappedAsImage, + __in USHORT DirectoryEntry, + __out PULONG Size, + __out_opt PIMAGE_SECTION_HEADER *FoundHeader + ); + +PVOID +IMAGEAPI +ImageDirectoryEntryToData ( + __in PVOID Base, + __in BOOLEAN MappedAsImage, + __in USHORT DirectoryEntry, + __out PULONG Size + ); + +PIMAGE_SECTION_HEADER +IMAGEAPI +ImageRvaToSection( + __in PIMAGE_NT_HEADERS NtHeaders, + __in PVOID Base, + __in ULONG Rva + ); + +PVOID +IMAGEAPI +ImageRvaToVa( + __in PIMAGE_NT_HEADERS NtHeaders, + __in PVOID Base, + __in ULONG Rva, + __in_opt OUT PIMAGE_SECTION_HEADER *LastRvaSection + ); + +#ifndef _WIN64 +// This api won't be ported to Win64 - Fix your code. + +typedef struct _IMAGE_DEBUG_INFORMATION { + LIST_ENTRY List; + DWORD ReservedSize; + PVOID ReservedMappedBase; + USHORT ReservedMachine; + USHORT ReservedCharacteristics; + DWORD ReservedCheckSum; + DWORD ImageBase; + DWORD SizeOfImage; + + DWORD ReservedNumberOfSections; + PIMAGE_SECTION_HEADER ReservedSections; + + DWORD ReservedExportedNamesSize; + PSTR ReservedExportedNames; + + DWORD ReservedNumberOfFunctionTableEntries; + PIMAGE_FUNCTION_ENTRY ReservedFunctionTableEntries; + DWORD ReservedLowestFunctionStartingAddress; + DWORD ReservedHighestFunctionEndingAddress; + + DWORD ReservedNumberOfFpoTableEntries; + PFPO_DATA ReservedFpoTableEntries; + + DWORD SizeOfCoffSymbols; + PIMAGE_COFF_SYMBOLS_HEADER CoffSymbols; + + DWORD ReservedSizeOfCodeViewSymbols; + PVOID ReservedCodeViewSymbols; + + PSTR ImageFilePath; + PSTR ImageFileName; + PSTR ReservedDebugFilePath; + + DWORD ReservedTimeDateStamp; + + BOOL ReservedRomImage; + PIMAGE_DEBUG_DIRECTORY ReservedDebugDirectory; + DWORD ReservedNumberOfDebugDirectories; + + DWORD ReservedOriginalFunctionTableBaseAddress; + + DWORD Reserved[ 2 ]; + +} IMAGE_DEBUG_INFORMATION, *PIMAGE_DEBUG_INFORMATION; + + +PIMAGE_DEBUG_INFORMATION +IMAGEAPI +MapDebugInformation( + __in_opt HANDLE FileHandle, + __in PCSTR FileName, + __in_opt PCSTR SymbolPath, + __in ULONG ImageBase + ); + +BOOL +IMAGEAPI +UnmapDebugInformation( + __out_xcount(unknown) PIMAGE_DEBUG_INFORMATION DebugInfo + ); + +#endif + +BOOL +IMAGEAPI +SearchTreeForFile( + __in PCSTR RootPath, + __in PCSTR InputPathName, + __out_ecount(MAX_PATH + 1) PSTR OutputPathBuffer + ); + +BOOL +IMAGEAPI +SearchTreeForFileW( + __in PCWSTR RootPath, + __in PCWSTR InputPathName, + __out_ecount(MAX_PATH + 1) PWSTR OutputPathBuffer + ); + +typedef BOOL +(CALLBACK *PENUMDIRTREE_CALLBACK)( + __in PCSTR FilePath, + __in_opt PVOID CallerData + ); + +BOOL +IMAGEAPI +EnumDirTree( + __in_opt HANDLE hProcess, + __in PCSTR RootPath, + __in PCSTR InputPathName, + __out_ecount_opt(MAX_PATH + 1) PSTR OutputPathBuffer, + __in_opt PENUMDIRTREE_CALLBACK cb, + __in_opt PVOID data + ); + +typedef BOOL +(CALLBACK *PENUMDIRTREE_CALLBACKW)( + __in PCWSTR FilePath, + __in_opt PVOID CallerData + ); + +BOOL +IMAGEAPI +EnumDirTreeW( + __in_opt HANDLE hProcess, + __in PCWSTR RootPath, + __in PCWSTR InputPathName, + __out_ecount_opt(MAX_PATH + 1) PWSTR OutputPathBuffer, + __in_opt PENUMDIRTREE_CALLBACKW cb, + __in_opt PVOID data + ); + +BOOL +IMAGEAPI +MakeSureDirectoryPathExists( + __in PCSTR DirPath + ); + +// +// UnDecorateSymbolName Flags +// + +#define UNDNAME_COMPLETE (0x0000) // Enable full undecoration +#define UNDNAME_NO_LEADING_UNDERSCORES (0x0001) // Remove leading underscores from MS extended keywords +#define UNDNAME_NO_MS_KEYWORDS (0x0002) // Disable expansion of MS extended keywords +#define UNDNAME_NO_FUNCTION_RETURNS (0x0004) // Disable expansion of return type for primary declaration +#define UNDNAME_NO_ALLOCATION_MODEL (0x0008) // Disable expansion of the declaration model +#define UNDNAME_NO_ALLOCATION_LANGUAGE (0x0010) // Disable expansion of the declaration language specifier +#define UNDNAME_NO_MS_THISTYPE (0x0020) // NYI Disable expansion of MS keywords on the 'this' type for primary declaration +#define UNDNAME_NO_CV_THISTYPE (0x0040) // NYI Disable expansion of CV modifiers on the 'this' type for primary declaration +#define UNDNAME_NO_THISTYPE (0x0060) // Disable all modifiers on the 'this' type +#define UNDNAME_NO_ACCESS_SPECIFIERS (0x0080) // Disable expansion of access specifiers for members +#define UNDNAME_NO_THROW_SIGNATURES (0x0100) // Disable expansion of 'throw-signatures' for functions and pointers to functions +#define UNDNAME_NO_MEMBER_TYPE (0x0200) // Disable expansion of 'static' or 'virtual'ness of members +#define UNDNAME_NO_RETURN_UDT_MODEL (0x0400) // Disable expansion of MS model for UDT returns +#define UNDNAME_32_BIT_DECODE (0x0800) // Undecorate 32-bit decorated names +#define UNDNAME_NAME_ONLY (0x1000) // Crack only the name for primary declaration; + // return just [scope::]name. Does expand template params +#define UNDNAME_NO_ARGUMENTS (0x2000) // Don't undecorate arguments to function +#define UNDNAME_NO_SPECIAL_SYMS (0x4000) // Don't undecorate special names (v-table, vcall, vector xxx, metatype, etc) + +DWORD +IMAGEAPI +WINAPI +UnDecorateSymbolName( + __in PCSTR name, + __out_ecount(maxStringLength) PSTR outputString, + __in DWORD maxStringLength, + __in DWORD flags + ); + +DWORD +IMAGEAPI +WINAPI +UnDecorateSymbolNameW( + __in PCWSTR name, + __out_ecount(maxStringLength) PWSTR outputString, + __in DWORD maxStringLength, + __in DWORD flags + ); + +// +// these values are used for synthesized file types +// that can be passed in as image headers instead of +// the standard ones from ntimage.h +// + +#define DBHHEADER_DEBUGDIRS 0x1 +#define DBHHEADER_CVMISC 0x2 + +typedef struct _MODLOAD_DATA { + DWORD ssize; // size of this struct + DWORD ssig; // signature identifying the passed data + PVOID data; // pointer to passed data + DWORD size; // size of passed data + DWORD flags; // options +} MODLOAD_DATA, *PMODLOAD_DATA; + +typedef struct _MODLOAD_CVMISC { + DWORD oCV; // ofset to the codeview record + size_t cCV; // size of the codeview record + DWORD oMisc; // offset to the misc record + size_t cMisc; // size of the misc record + DWORD dtImage; // datetime stamp of the image + DWORD cImage; // size of the image +} MODLOAD_CVMISC, *PMODLOAD_CVMISC; + +// +// StackWalking API +// + +typedef enum { + AddrMode1616, + AddrMode1632, + AddrModeReal, + AddrModeFlat +} ADDRESS_MODE; + +typedef struct _tagADDRESS64 { + DWORD64 Offset; + WORD Segment; + ADDRESS_MODE Mode; +} ADDRESS64, *LPADDRESS64; + +#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) +#define ADDRESS ADDRESS64 +#define LPADDRESS LPADDRESS64 +#else +typedef struct _tagADDRESS { + DWORD Offset; + WORD Segment; + ADDRESS_MODE Mode; +} ADDRESS, *LPADDRESS; + +__inline +void +Address32To64( + __in LPADDRESS a32, + __out LPADDRESS64 a64 + ) +{ + a64->Offset = (ULONG64)(LONG64)(LONG)a32->Offset; + a64->Segment = a32->Segment; + a64->Mode = a32->Mode; +} + +__inline +void +Address64To32( + __in LPADDRESS64 a64, + __out LPADDRESS a32 + ) +{ + a32->Offset = (ULONG)a64->Offset; + a32->Segment = a64->Segment; + a32->Mode = a64->Mode; +} +#endif + +// +// This structure is included in the STACKFRAME structure, +// and is used to trace through usermode callbacks in a thread's +// kernel stack. The values must be copied by the kernel debugger +// from the DBGKD_GET_VERSION and WAIT_STATE_CHANGE packets. +// + +// +// New KDHELP structure for 64 bit system support. +// This structure is preferred in new code. +// +typedef struct _KDHELP64 { + + // + // address of kernel thread object, as provided in the + // WAIT_STATE_CHANGE packet. + // + DWORD64 Thread; + + // + // offset in thread object to pointer to the current callback frame + // in kernel stack. + // + DWORD ThCallbackStack; + + // + // offset in thread object to pointer to the current callback backing + // store frame in kernel stack. + // + DWORD ThCallbackBStore; + + // + // offsets to values in frame: + // + // address of next callback frame + DWORD NextCallback; + + // address of saved frame pointer (if applicable) + DWORD FramePointer; + + + // + // Address of the kernel function that calls out to user mode + // + DWORD64 KiCallUserMode; + + // + // Address of the user mode dispatcher function + // + DWORD64 KeUserCallbackDispatcher; + + // + // Lowest kernel mode address + // + DWORD64 SystemRangeStart; + + // + // Address of the user mode exception dispatcher function. + // Added in API version 10. + // + DWORD64 KiUserExceptionDispatcher; + + // + // Stack bounds, added in API version 11. + // + DWORD64 StackBase; + DWORD64 StackLimit; + + DWORD64 Reserved[5]; + +} KDHELP64, *PKDHELP64; + +#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) +#define KDHELP KDHELP64 +#define PKDHELP PKDHELP64 +#else +typedef struct _KDHELP { + + // + // address of kernel thread object, as provided in the + // WAIT_STATE_CHANGE packet. + // + DWORD Thread; + + // + // offset in thread object to pointer to the current callback frame + // in kernel stack. + // + DWORD ThCallbackStack; + + // + // offsets to values in frame: + // + // address of next callback frame + DWORD NextCallback; + + // address of saved frame pointer (if applicable) + DWORD FramePointer; + + // + // Address of the kernel function that calls out to user mode + // + DWORD KiCallUserMode; + + // + // Address of the user mode dispatcher function + // + DWORD KeUserCallbackDispatcher; + + // + // Lowest kernel mode address + // + DWORD SystemRangeStart; + + // + // offset in thread object to pointer to the current callback backing + // store frame in kernel stack. + // + DWORD ThCallbackBStore; + + // + // Address of the user mode exception dispatcher function. + // Added in API version 10. + // + DWORD KiUserExceptionDispatcher; + + // + // Stack bounds, added in API version 11. + // + DWORD StackBase; + DWORD StackLimit; + + DWORD Reserved[5]; + +} KDHELP, *PKDHELP; + +__inline +void +KdHelp32To64( + __in PKDHELP p32, + __out PKDHELP64 p64 + ) +{ + p64->Thread = p32->Thread; + p64->ThCallbackStack = p32->ThCallbackStack; + p64->NextCallback = p32->NextCallback; + p64->FramePointer = p32->FramePointer; + p64->KiCallUserMode = p32->KiCallUserMode; + p64->KeUserCallbackDispatcher = p32->KeUserCallbackDispatcher; + p64->SystemRangeStart = p32->SystemRangeStart; + p64->KiUserExceptionDispatcher = p32->KiUserExceptionDispatcher; + p64->StackBase = p32->StackBase; + p64->StackLimit = p32->StackLimit; +} +#endif + +typedef struct _tagSTACKFRAME64 { + ADDRESS64 AddrPC; // program counter + ADDRESS64 AddrReturn; // return address + ADDRESS64 AddrFrame; // frame pointer + ADDRESS64 AddrStack; // stack pointer + ADDRESS64 AddrBStore; // backing store pointer + PVOID FuncTableEntry; // pointer to pdata/fpo or NULL + DWORD64 Params[4]; // possible arguments to the function + BOOL Far; // WOW far call + BOOL Virtual; // is this a virtual frame? + DWORD64 Reserved[3]; + KDHELP64 KdHelp; +} STACKFRAME64, *LPSTACKFRAME64; + +#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) +#define STACKFRAME STACKFRAME64 +#define LPSTACKFRAME LPSTACKFRAME64 +#else +typedef struct _tagSTACKFRAME { + ADDRESS AddrPC; // program counter + ADDRESS AddrReturn; // return address + ADDRESS AddrFrame; // frame pointer + ADDRESS AddrStack; // stack pointer + PVOID FuncTableEntry; // pointer to pdata/fpo or NULL + DWORD Params[4]; // possible arguments to the function + BOOL Far; // WOW far call + BOOL Virtual; // is this a virtual frame? + DWORD Reserved[3]; + KDHELP KdHelp; + ADDRESS AddrBStore; // backing store pointer +} STACKFRAME, *LPSTACKFRAME; +#endif + + +typedef +BOOL +(__stdcall *PREAD_PROCESS_MEMORY_ROUTINE64)( + __in HANDLE hProcess, + __in DWORD64 qwBaseAddress, + __out_bcount(nSize) PVOID lpBuffer, + __in DWORD nSize, + __out LPDWORD lpNumberOfBytesRead + ); + +typedef +PVOID +(__stdcall *PFUNCTION_TABLE_ACCESS_ROUTINE64)( + __in HANDLE ahProcess, + __in DWORD64 AddrBase + ); + +typedef +DWORD64 +(__stdcall *PGET_MODULE_BASE_ROUTINE64)( + __in HANDLE hProcess, + __in DWORD64 Address + ); + +typedef +DWORD64 +(__stdcall *PTRANSLATE_ADDRESS_ROUTINE64)( + __in HANDLE hProcess, + __in HANDLE hThread, + __in LPADDRESS64 lpaddr + ); + +BOOL +IMAGEAPI +StackWalk64( + __in DWORD MachineType, + __in HANDLE hProcess, + __in HANDLE hThread, + __inout LPSTACKFRAME64 StackFrame, + __inout PVOID ContextRecord, + __in_opt PREAD_PROCESS_MEMORY_ROUTINE64 ReadMemoryRoutine, + __in_opt PFUNCTION_TABLE_ACCESS_ROUTINE64 FunctionTableAccessRoutine, + __in_opt PGET_MODULE_BASE_ROUTINE64 GetModuleBaseRoutine, + __in_opt PTRANSLATE_ADDRESS_ROUTINE64 TranslateAddress + ); + +#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) + +#define PREAD_PROCESS_MEMORY_ROUTINE PREAD_PROCESS_MEMORY_ROUTINE64 +#define PFUNCTION_TABLE_ACCESS_ROUTINE PFUNCTION_TABLE_ACCESS_ROUTINE64 +#define PGET_MODULE_BASE_ROUTINE PGET_MODULE_BASE_ROUTINE64 +#define PTRANSLATE_ADDRESS_ROUTINE PTRANSLATE_ADDRESS_ROUTINE64 + +#define StackWalk StackWalk64 + +#else + +typedef +BOOL +(__stdcall *PREAD_PROCESS_MEMORY_ROUTINE)( + __in HANDLE hProcess, + __in DWORD lpBaseAddress, + __out_bcount(nSize) PVOID lpBuffer, + __in DWORD nSize, + __out PDWORD lpNumberOfBytesRead + ); + +typedef +PVOID +(__stdcall *PFUNCTION_TABLE_ACCESS_ROUTINE)( + __in HANDLE hProcess, + __in DWORD AddrBase + ); + +typedef +DWORD +(__stdcall *PGET_MODULE_BASE_ROUTINE)( + __in HANDLE hProcess, + __in DWORD Address + ); + +typedef +DWORD +(__stdcall *PTRANSLATE_ADDRESS_ROUTINE)( + __in HANDLE hProcess, + __in HANDLE hThread, + __out LPADDRESS lpaddr + ); + +BOOL +IMAGEAPI +StackWalk( + DWORD MachineType, + __in HANDLE hProcess, + __in HANDLE hThread, + __inout LPSTACKFRAME StackFrame, + __inout PVOID ContextRecord, + __in_opt PREAD_PROCESS_MEMORY_ROUTINE ReadMemoryRoutine, + __in_opt PFUNCTION_TABLE_ACCESS_ROUTINE FunctionTableAccessRoutine, + __in_opt PGET_MODULE_BASE_ROUTINE GetModuleBaseRoutine, + __in_opt PTRANSLATE_ADDRESS_ROUTINE TranslateAddress + ); + +#endif + + +#define API_VERSION_NUMBER 11 + +typedef struct API_VERSION { + USHORT MajorVersion; + USHORT MinorVersion; + USHORT Revision; + USHORT Reserved; +} API_VERSION, *LPAPI_VERSION; + +LPAPI_VERSION +IMAGEAPI +ImagehlpApiVersion( + VOID + ); + +LPAPI_VERSION +IMAGEAPI +ImagehlpApiVersionEx( + __in LPAPI_VERSION AppVersion + ); + +DWORD +IMAGEAPI +GetTimestampForLoadedLibrary( + __in HMODULE Module + ); + +// +// typedefs for function pointers +// +typedef BOOL +(CALLBACK *PSYM_ENUMMODULES_CALLBACK64)( + __in PCSTR ModuleName, + __in DWORD64 BaseOfDll, + __in_opt PVOID UserContext + ); + +typedef BOOL +(CALLBACK *PSYM_ENUMMODULES_CALLBACKW64)( + __in PCWSTR ModuleName, + __in DWORD64 BaseOfDll, + __in_opt PVOID UserContext + ); + +typedef BOOL +(CALLBACK *PENUMLOADED_MODULES_CALLBACK64)( + __in PCSTR ModuleName, + __in DWORD64 ModuleBase, + __in ULONG ModuleSize, + __in_opt PVOID UserContext + ); + +typedef BOOL +(CALLBACK *PENUMLOADED_MODULES_CALLBACKW64)( + __in PCWSTR ModuleName, + __in DWORD64 ModuleBase, + __in ULONG ModuleSize, + __in_opt PVOID UserContext + ); + +typedef BOOL +(CALLBACK *PSYM_ENUMSYMBOLS_CALLBACK64)( + __in PCSTR SymbolName, + __in DWORD64 SymbolAddress, + __in ULONG SymbolSize, + __in_opt PVOID UserContext + ); + +typedef BOOL +(CALLBACK *PSYM_ENUMSYMBOLS_CALLBACK64W)( + __in PCWSTR SymbolName, + __in DWORD64 SymbolAddress, + __in ULONG SymbolSize, + __in_opt PVOID UserContext + ); + +typedef BOOL +(CALLBACK *PSYMBOL_REGISTERED_CALLBACK64)( + __in HANDLE hProcess, + __in ULONG ActionCode, + __in_opt ULONG64 CallbackData, + __in_opt ULONG64 UserContext + ); + +typedef +PVOID +(CALLBACK *PSYMBOL_FUNCENTRY_CALLBACK)( + __in HANDLE hProcess, + __in DWORD AddrBase, + __in_opt PVOID UserContext + ); + +typedef +PVOID +(CALLBACK *PSYMBOL_FUNCENTRY_CALLBACK64)( + __in HANDLE hProcess, + __in ULONG64 AddrBase, + __in ULONG64 UserContext + ); + +#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) + +#define PSYM_ENUMMODULES_CALLBACK PSYM_ENUMMODULES_CALLBACK64 +#define PSYM_ENUMSYMBOLS_CALLBACK PSYM_ENUMSYMBOLS_CALLBACK64 +#define PSYM_ENUMSYMBOLS_CALLBACKW PSYM_ENUMSYMBOLS_CALLBACK64W +#define PENUMLOADED_MODULES_CALLBACK PENUMLOADED_MODULES_CALLBACK64 +#define PSYMBOL_REGISTERED_CALLBACK PSYMBOL_REGISTERED_CALLBACK64 +#define PSYMBOL_FUNCENTRY_CALLBACK PSYMBOL_FUNCENTRY_CALLBACK64 + +#else + +typedef BOOL +(CALLBACK *PSYM_ENUMMODULES_CALLBACK)( + __in PCSTR ModuleName, + __in ULONG BaseOfDll, + __in_opt PVOID UserContext + ); + +typedef BOOL +(CALLBACK *PSYM_ENUMSYMBOLS_CALLBACK)( + __in PCSTR SymbolName, + __in ULONG SymbolAddress, + __in ULONG SymbolSize, + __in_opt PVOID UserContext + ); + +typedef BOOL +(CALLBACK *PSYM_ENUMSYMBOLS_CALLBACKW)( + __in PCWSTR SymbolName, + __in ULONG SymbolAddress, + __in ULONG SymbolSize, + __in_opt PVOID UserContext + ); + +typedef BOOL +(CALLBACK *PENUMLOADED_MODULES_CALLBACK)( + __in PCSTR ModuleName, + __in ULONG ModuleBase, + __in ULONG ModuleSize, + __in_opt PVOID UserContext + ); + +typedef BOOL +(CALLBACK *PSYMBOL_REGISTERED_CALLBACK)( + __in HANDLE hProcess, + __in ULONG ActionCode, + __in_opt PVOID CallbackData, + __in_opt PVOID UserContext + ); + +#endif + + +// values found in SYMBOL_INFO.Tag +// +// This was taken from cvconst.h and should +// not override any values found there. +// +// #define _NO_CVCONST_H_ if you don't +// have access to that file... + +#ifdef _NO_CVCONST_H + +// DIA enums + +enum SymTagEnum +{ + SymTagNull, + SymTagExe, + SymTagCompiland, + SymTagCompilandDetails, + SymTagCompilandEnv, + SymTagFunction, + SymTagBlock, + SymTagData, + SymTagAnnotation, + SymTagLabel, + SymTagPublicSymbol, + SymTagUDT, + SymTagEnum, + SymTagFunctionType, + SymTagPointerType, + SymTagArrayType, + SymTagBaseType, + SymTagTypedef, + SymTagBaseClass, + SymTagFriend, + SymTagFunctionArgType, + SymTagFuncDebugStart, + SymTagFuncDebugEnd, + SymTagUsingNamespace, + SymTagVTableShape, + SymTagVTable, + SymTagCustom, + SymTagThunk, + SymTagCustomType, + SymTagManagedType, + SymTagDimension, + SymTagMax +}; + +#endif + +// +// flags found in SYMBOL_INFO.Flags +// + +#define SYMFLAG_VALUEPRESENT 0x00000001 +#define SYMFLAG_REGISTER 0x00000008 +#define SYMFLAG_REGREL 0x00000010 +#define SYMFLAG_FRAMEREL 0x00000020 +#define SYMFLAG_PARAMETER 0x00000040 +#define SYMFLAG_LOCAL 0x00000080 +#define SYMFLAG_CONSTANT 0x00000100 +#define SYMFLAG_EXPORT 0x00000200 +#define SYMFLAG_FORWARDER 0x00000400 +#define SYMFLAG_FUNCTION 0x00000800 +#define SYMFLAG_VIRTUAL 0x00001000 +#define SYMFLAG_THUNK 0x00002000 +#define SYMFLAG_TLSREL 0x00004000 +#define SYMFLAG_SLOT 0x00008000 +#define SYMFLAG_ILREL 0x00010000 +#define SYMFLAG_METADATA 0x00020000 +#define SYMFLAG_CLR_TOKEN 0x00040000 + +// this resets SymNext/Prev to the beginning +// of the module passed in the address field + +#define SYMFLAG_RESET 0x80000000 + +// +// symbol type enumeration +// +typedef enum { + SymNone = 0, + SymCoff, + SymCv, + SymPdb, + SymExport, + SymDeferred, + SymSym, // .sym file + SymDia, + SymVirtual, + NumSymTypes +} SYM_TYPE; + +// +// symbol data structure +// + +typedef struct _IMAGEHLP_SYMBOL64 { + DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_SYMBOL64) + DWORD64 Address; // virtual address including dll base address + DWORD Size; // estimated size of symbol, can be zero + DWORD Flags; // info about the symbols, see the SYMF defines + DWORD MaxNameLength; // maximum size of symbol name in 'Name' + CHAR Name[1]; // symbol name (null terminated string) +} IMAGEHLP_SYMBOL64, *PIMAGEHLP_SYMBOL64; + +typedef struct _IMAGEHLP_SYMBOL64_PACKAGE { + IMAGEHLP_SYMBOL64 sym; + CHAR name[MAX_SYM_NAME + 1]; +} IMAGEHLP_SYMBOL64_PACKAGE, *PIMAGEHLP_SYMBOL64_PACKAGE; + +typedef struct _IMAGEHLP_SYMBOLW64 { + DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_SYMBOLW64) + DWORD64 Address; // virtual address including dll base address + DWORD Size; // estimated size of symbol, can be zero + DWORD Flags; // info about the symbols, see the SYMF defines + DWORD MaxNameLength; // maximum size of symbol name in 'Name' + WCHAR Name[1]; // symbol name (null terminated string) +} IMAGEHLP_SYMBOLW64, *PIMAGEHLP_SYMBOLW64; + +typedef struct _IMAGEHLP_SYMBOLW64_PACKAGE { + IMAGEHLP_SYMBOLW64 sym; + WCHAR name[MAX_SYM_NAME + 1]; +} IMAGEHLP_SYMBOLW64_PACKAGE, *PIMAGEHLP_SYMBOLW64_PACKAGE; + +#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) + + #define IMAGEHLP_SYMBOL IMAGEHLP_SYMBOL64 + #define PIMAGEHLP_SYMBOL PIMAGEHLP_SYMBOL64 + #define IMAGEHLP_SYMBOL_PACKAGE IMAGEHLP_SYMBOL64_PACKAGE + #define PIMAGEHLP_SYMBOL_PACKAGE PIMAGEHLP_SYMBOL64_PACKAGE + #define IMAGEHLP_SYMBOLW IMAGEHLP_SYMBOLW64 + #define PIMAGEHLP_SYMBOLW PIMAGEHLP_SYMBOLW64 + #define IMAGEHLP_SYMBOLW_PACKAGE IMAGEHLP_SYMBOLW64_PACKAGE + #define PIMAGEHLP_SYMBOLW_PACKAGE PIMAGEHLP_SYMBOLW64_PACKAGE + +#else + + typedef struct _IMAGEHLP_SYMBOL { + DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_SYMBOL) + DWORD Address; // virtual address including dll base address + DWORD Size; // estimated size of symbol, can be zero + DWORD Flags; // info about the symbols, see the SYMF defines + DWORD MaxNameLength; // maximum size of symbol name in 'Name' + CHAR Name[1]; // symbol name (null terminated string) + } IMAGEHLP_SYMBOL, *PIMAGEHLP_SYMBOL; + + typedef struct _IMAGEHLP_SYMBOL_PACKAGE { + IMAGEHLP_SYMBOL sym; + CHAR name[MAX_SYM_NAME + 1]; + } IMAGEHLP_SYMBOL_PACKAGE, *PIMAGEHLP_SYMBOL_PACKAGE; + + typedef struct _IMAGEHLP_SYMBOLW { + DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_SYMBOLW) + DWORD Address; // virtual address including dll base address + DWORD Size; // estimated size of symbol, can be zero + DWORD Flags; // info about the symbols, see the SYMF defines + DWORD MaxNameLength; // maximum size of symbol name in 'Name' + WCHAR Name[1]; // symbol name (null terminated string) + } IMAGEHLP_SYMBOLW, *PIMAGEHLP_SYMBOLW; + + typedef struct _IMAGEHLP_SYMBOLW_PACKAGE { + IMAGEHLP_SYMBOLW sym; + WCHAR name[MAX_SYM_NAME + 1]; + } IMAGEHLP_SYMBOLW_PACKAGE, *PIMAGEHLP_SYMBOLW_PACKAGE; + +#endif + +// +// module data structure +// + +typedef struct _IMAGEHLP_MODULE64 { + DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_MODULE64) + DWORD64 BaseOfImage; // base load address of module + DWORD ImageSize; // virtual size of the loaded module + DWORD TimeDateStamp; // date/time stamp from pe header + DWORD CheckSum; // checksum from the pe header + DWORD NumSyms; // number of symbols in the symbol table + SYM_TYPE SymType; // type of symbols loaded + CHAR ModuleName[32]; // module name + CHAR ImageName[256]; // image name + CHAR LoadedImageName[256]; // symbol file name + // new elements: 07-Jun-2002 + CHAR LoadedPdbName[256]; // pdb file name + DWORD CVSig; // Signature of the CV record in the debug directories + CHAR CVData[MAX_PATH * 3]; // Contents of the CV record + DWORD PdbSig; // Signature of PDB + GUID PdbSig70; // Signature of PDB (VC 7 and up) + DWORD PdbAge; // DBI age of pdb + BOOL PdbUnmatched; // loaded an unmatched pdb + BOOL DbgUnmatched; // loaded an unmatched dbg + BOOL LineNumbers; // we have line number information + BOOL GlobalSymbols; // we have internal symbol information + BOOL TypeInfo; // we have type information + // new elements: 17-Dec-2003 + BOOL SourceIndexed; // pdb supports source server + BOOL Publics; // contains public symbols +} IMAGEHLP_MODULE64, *PIMAGEHLP_MODULE64; + +typedef struct _IMAGEHLP_MODULEW64 { + DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_MODULE64) + DWORD64 BaseOfImage; // base load address of module + DWORD ImageSize; // virtual size of the loaded module + DWORD TimeDateStamp; // date/time stamp from pe header + DWORD CheckSum; // checksum from the pe header + DWORD NumSyms; // number of symbols in the symbol table + SYM_TYPE SymType; // type of symbols loaded + WCHAR ModuleName[32]; // module name + WCHAR ImageName[256]; // image name + // new elements: 07-Jun-2002 + WCHAR LoadedImageName[256]; // symbol file name + WCHAR LoadedPdbName[256]; // pdb file name + DWORD CVSig; // Signature of the CV record in the debug directories + WCHAR CVData[MAX_PATH * 3]; // Contents of the CV record + DWORD PdbSig; // Signature of PDB + GUID PdbSig70; // Signature of PDB (VC 7 and up) + DWORD PdbAge; // DBI age of pdb + BOOL PdbUnmatched; // loaded an unmatched pdb + BOOL DbgUnmatched; // loaded an unmatched dbg + BOOL LineNumbers; // we have line number information + BOOL GlobalSymbols; // we have internal symbol information + BOOL TypeInfo; // we have type information + // new elements: 17-Dec-2003 + BOOL SourceIndexed; // pdb supports source server + BOOL Publics; // contains public symbols +} IMAGEHLP_MODULEW64, *PIMAGEHLP_MODULEW64; + +#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) +#define IMAGEHLP_MODULE IMAGEHLP_MODULE64 +#define PIMAGEHLP_MODULE PIMAGEHLP_MODULE64 +#define IMAGEHLP_MODULEW IMAGEHLP_MODULEW64 +#define PIMAGEHLP_MODULEW PIMAGEHLP_MODULEW64 +#else +typedef struct _IMAGEHLP_MODULE { + DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_MODULE) + DWORD BaseOfImage; // base load address of module + DWORD ImageSize; // virtual size of the loaded module + DWORD TimeDateStamp; // date/time stamp from pe header + DWORD CheckSum; // checksum from the pe header + DWORD NumSyms; // number of symbols in the symbol table + SYM_TYPE SymType; // type of symbols loaded + CHAR ModuleName[32]; // module name + CHAR ImageName[256]; // image name + CHAR LoadedImageName[256]; // symbol file name +} IMAGEHLP_MODULE, *PIMAGEHLP_MODULE; + +typedef struct _IMAGEHLP_MODULEW { + DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_MODULE) + DWORD BaseOfImage; // base load address of module + DWORD ImageSize; // virtual size of the loaded module + DWORD TimeDateStamp; // date/time stamp from pe header + DWORD CheckSum; // checksum from the pe header + DWORD NumSyms; // number of symbols in the symbol table + SYM_TYPE SymType; // type of symbols loaded + WCHAR ModuleName[32]; // module name + WCHAR ImageName[256]; // image name + WCHAR LoadedImageName[256]; // symbol file name +} IMAGEHLP_MODULEW, *PIMAGEHLP_MODULEW; +#endif + +// +// source file line data structure +// + +typedef struct _IMAGEHLP_LINE64 { + DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_LINE64) + PVOID Key; // internal + DWORD LineNumber; // line number in file + PCHAR FileName; // full filename + DWORD64 Address; // first instruction of line +} IMAGEHLP_LINE64, *PIMAGEHLP_LINE64; + +typedef struct _IMAGEHLP_LINEW64 { + DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_LINE64) + PVOID Key; // internal + DWORD LineNumber; // line number in file + PWSTR FileName; // full filename + DWORD64 Address; // first instruction of line +} IMAGEHLP_LINEW64, *PIMAGEHLP_LINEW64; + +#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) +#define IMAGEHLP_LINE IMAGEHLP_LINE64 +#define PIMAGEHLP_LINE PIMAGEHLP_LINE64 +#else +typedef struct _IMAGEHLP_LINE { + DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_LINE) + PVOID Key; // internal + DWORD LineNumber; // line number in file + PCHAR FileName; // full filename + DWORD Address; // first instruction of line +} IMAGEHLP_LINE, *PIMAGEHLP_LINE; + +typedef struct _IMAGEHLP_LINEW { + DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_LINE64) + PVOID Key; // internal + DWORD LineNumber; // line number in file + PCHAR FileName; // full filename + DWORD64 Address; // first instruction of line +} IMAGEHLP_LINEW, *PIMAGEHLP_LINEW; +#endif + +// +// source file structure +// + +typedef struct _SOURCEFILE { + DWORD64 ModBase; // base address of loaded module + PCHAR FileName; // full filename of source +} SOURCEFILE, *PSOURCEFILE; + +typedef struct _SOURCEFILEW { + DWORD64 ModBase; // base address of loaded module + PWSTR FileName; // full filename of source +} SOURCEFILEW, *PSOURCEFILEW; + +// +// data structures used for registered symbol callbacks +// + +#define CBA_DEFERRED_SYMBOL_LOAD_START 0x00000001 +#define CBA_DEFERRED_SYMBOL_LOAD_COMPLETE 0x00000002 +#define CBA_DEFERRED_SYMBOL_LOAD_FAILURE 0x00000003 +#define CBA_SYMBOLS_UNLOADED 0x00000004 +#define CBA_DUPLICATE_SYMBOL 0x00000005 +#define CBA_READ_MEMORY 0x00000006 +#define CBA_DEFERRED_SYMBOL_LOAD_CANCEL 0x00000007 +#define CBA_SET_OPTIONS 0x00000008 +#define CBA_EVENT 0x00000010 +#define CBA_DEFERRED_SYMBOL_LOAD_PARTIAL 0x00000020 +#define CBA_DEBUG_INFO 0x10000000 +#define CBA_SRCSRV_INFO 0x20000000 +#define CBA_SRCSRV_EVENT 0x40000000 + +typedef struct _IMAGEHLP_CBA_READ_MEMORY { + DWORD64 addr; // address to read from + PVOID buf; // buffer to read to + DWORD bytes; // amount of bytes to read + DWORD *bytesread; // pointer to store amount of bytes read +} IMAGEHLP_CBA_READ_MEMORY, *PIMAGEHLP_CBA_READ_MEMORY; + +enum { + sevInfo = 0, + sevProblem, + sevAttn, + sevFatal, + sevMax // unused +}; + +#define EVENT_SRCSPEW_START 100 +#define EVENT_SRCSPEW 100 +#define EVENT_SRCSPEW_END 199 + +typedef struct _IMAGEHLP_CBA_EVENT { + DWORD severity; // values from sevInfo to sevFatal + DWORD code; // numerical code IDs the error + PCHAR desc; // may contain a text description of the error + PVOID object; // value dependant upon the error code +} IMAGEHLP_CBA_EVENT, *PIMAGEHLP_CBA_EVENT; + +typedef struct _IMAGEHLP_CBA_EVENTW { + DWORD severity; // values from sevInfo to sevFatal + DWORD code; // numerical code IDs the error + PCWSTR desc; // may contain a text description of the error + PVOID object; // value dependant upon the error code +} IMAGEHLP_CBA_EVENTW, *PIMAGEHLP_CBA_EVENTW; + +typedef struct _IMAGEHLP_DEFERRED_SYMBOL_LOAD64 { + DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_DEFERRED_SYMBOL_LOAD64) + DWORD64 BaseOfImage; // base load address of module + DWORD CheckSum; // checksum from the pe header + DWORD TimeDateStamp; // date/time stamp from pe header + CHAR FileName[MAX_PATH]; // symbols file or image name + BOOLEAN Reparse; // load failure reparse + HANDLE hFile; // file handle, if passed + DWORD Flags; // +} IMAGEHLP_DEFERRED_SYMBOL_LOAD64, *PIMAGEHLP_DEFERRED_SYMBOL_LOAD64; + +typedef struct _IMAGEHLP_DEFERRED_SYMBOL_LOADW64 { + DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_DEFERRED_SYMBOL_LOADW64) + DWORD64 BaseOfImage; // base load address of module + DWORD CheckSum; // checksum from the pe header + DWORD TimeDateStamp; // date/time stamp from pe header + WCHAR FileName[MAX_PATH + 1]; // symbols file or image name + BOOLEAN Reparse; // load failure reparse + HANDLE hFile; // file handle, if passed + DWORD Flags; // +} IMAGEHLP_DEFERRED_SYMBOL_LOADW64, *PIMAGEHLP_DEFERRED_SYMBOL_LOADW64; + +#define DSLFLAG_MISMATCHED_PDB 0x1 +#define DSLFLAG_MISMATCHED_DBG 0x2 + +#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) +#define IMAGEHLP_DEFERRED_SYMBOL_LOAD IMAGEHLP_DEFERRED_SYMBOL_LOAD64 +#define PIMAGEHLP_DEFERRED_SYMBOL_LOAD PIMAGEHLP_DEFERRED_SYMBOL_LOAD64 +#else +typedef struct _IMAGEHLP_DEFERRED_SYMBOL_LOAD { + DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_DEFERRED_SYMBOL_LOAD) + DWORD BaseOfImage; // base load address of module + DWORD CheckSum; // checksum from the pe header + DWORD TimeDateStamp; // date/time stamp from pe header + CHAR FileName[MAX_PATH]; // symbols file or image name + BOOLEAN Reparse; // load failure reparse + HANDLE hFile; // file handle, if passed +} IMAGEHLP_DEFERRED_SYMBOL_LOAD, *PIMAGEHLP_DEFERRED_SYMBOL_LOAD; +#endif + +typedef struct _IMAGEHLP_DUPLICATE_SYMBOL64 { + DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_DUPLICATE_SYMBOL64) + DWORD NumberOfDups; // number of duplicates in the Symbol array + PIMAGEHLP_SYMBOL64 Symbol; // array of duplicate symbols + DWORD SelectedSymbol; // symbol selected (-1 to start) +} IMAGEHLP_DUPLICATE_SYMBOL64, *PIMAGEHLP_DUPLICATE_SYMBOL64; + +#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) +#define IMAGEHLP_DUPLICATE_SYMBOL IMAGEHLP_DUPLICATE_SYMBOL64 +#define PIMAGEHLP_DUPLICATE_SYMBOL PIMAGEHLP_DUPLICATE_SYMBOL64 +#else +typedef struct _IMAGEHLP_DUPLICATE_SYMBOL { + DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_DUPLICATE_SYMBOL) + DWORD NumberOfDups; // number of duplicates in the Symbol array + PIMAGEHLP_SYMBOL Symbol; // array of duplicate symbols + DWORD SelectedSymbol; // symbol selected (-1 to start) +} IMAGEHLP_DUPLICATE_SYMBOL, *PIMAGEHLP_DUPLICATE_SYMBOL; +#endif + +// If dbghelp ever needs to display graphical UI, it will use this as the parent window. + +BOOL +IMAGEAPI +SymSetParentWindow( + __in HWND hwnd + ); + +PCHAR +IMAGEAPI +SymSetHomeDirectory( + __in_opt HANDLE hProcess, + __in_opt PCSTR dir + ); + +PWSTR +IMAGEAPI +SymSetHomeDirectoryW( + __in_opt HANDLE hProcess, + __in_opt PCWSTR dir + ); + +PCHAR +IMAGEAPI +SymGetHomeDirectory( + __in DWORD type, + __out_ecount(size) PSTR dir, + __in size_t size + ); + +PWSTR +IMAGEAPI +SymGetHomeDirectoryW( + __in DWORD type, + __out_ecount(size) PWSTR dir, + __in size_t size + ); + +enum { + hdBase = 0, // root directory for dbghelp + hdSym, // where symbols are stored + hdSrc, // where source is stored + hdMax // end marker +}; + +typedef struct _OMAP { + ULONG rva; + ULONG rvaTo; +} OMAP, *POMAP; + +BOOL +IMAGEAPI +SymGetOmaps( + __in HANDLE hProcess, + __in DWORD64 BaseOfDll, + __out POMAP *OmapTo, + __out PDWORD64 cOmapTo, + __out POMAP *OmapFrom, + __out PDWORD64 cOmapFrom + ); + +// +// options that are set/returned by SymSetOptions() & SymGetOptions() +// these are used as a mask +// +#define SYMOPT_CASE_INSENSITIVE 0x00000001 +#define SYMOPT_UNDNAME 0x00000002 +#define SYMOPT_DEFERRED_LOADS 0x00000004 +#define SYMOPT_NO_CPP 0x00000008 +#define SYMOPT_LOAD_LINES 0x00000010 +#define SYMOPT_OMAP_FIND_NEAREST 0x00000020 +#define SYMOPT_LOAD_ANYTHING 0x00000040 +#define SYMOPT_IGNORE_CVREC 0x00000080 +#define SYMOPT_NO_UNQUALIFIED_LOADS 0x00000100 +#define SYMOPT_FAIL_CRITICAL_ERRORS 0x00000200 +#define SYMOPT_EXACT_SYMBOLS 0x00000400 +#define SYMOPT_ALLOW_ABSOLUTE_SYMBOLS 0x00000800 +#define SYMOPT_IGNORE_NT_SYMPATH 0x00001000 +#define SYMOPT_INCLUDE_32BIT_MODULES 0x00002000 +#define SYMOPT_PUBLICS_ONLY 0x00004000 +#define SYMOPT_NO_PUBLICS 0x00008000 +#define SYMOPT_AUTO_PUBLICS 0x00010000 +#define SYMOPT_NO_IMAGE_SEARCH 0x00020000 +#define SYMOPT_SECURE 0x00040000 +#define SYMOPT_NO_PROMPTS 0x00080000 +#define SYMOPT_OVERWRITE 0x00100000 +#define SYMOPT_IGNORE_IMAGEDIR 0x00200000 +#define SYMOPT_FLAT_DIRECTORY 0x00400000 +#define SYMOPT_FAVOR_COMPRESSED 0x00800000 +#define SYMOPT_ALLOW_ZERO_ADDRESS 0x01000000 +#define SYMOPT_DISABLE_SYMSRV_AUTODETECT 0x02000000 + +#define SYMOPT_DEBUG 0x80000000 + +DWORD +IMAGEAPI +SymSetOptions( + __in DWORD SymOptions + ); + +DWORD +IMAGEAPI +SymGetOptions( + VOID + ); + +BOOL +IMAGEAPI +SymCleanup( + __in HANDLE hProcess + ); + +BOOL +IMAGEAPI +SymMatchString( + __in PCSTR string, + __in PCSTR expression, + __in BOOL fCase + ); + +BOOL +IMAGEAPI +SymMatchStringA( + __in PCSTR string, + __in PCSTR expression, + __in BOOL fCase + ); + +BOOL +IMAGEAPI +SymMatchStringW( + __in PCWSTR string, + __in PCWSTR expression, + __in BOOL fCase + ); + +typedef BOOL +(CALLBACK *PSYM_ENUMSOURCEFILES_CALLBACK)( + __in PSOURCEFILE pSourceFile, + __in_opt PVOID UserContext + ); + +// for backwards compatibility - don't use this +#define PSYM_ENUMSOURCFILES_CALLBACK PSYM_ENUMSOURCEFILES_CALLBACK + +BOOL +IMAGEAPI +SymEnumSourceFiles( + __in HANDLE hProcess, + __in ULONG64 ModBase, + __in_opt PCSTR Mask, + __in PSYM_ENUMSOURCEFILES_CALLBACK cbSrcFiles, + __in_opt PVOID UserContext + ); + +typedef BOOL +(CALLBACK *PSYM_ENUMSOURCEFILES_CALLBACKW)( + __in PSOURCEFILEW pSourceFile, + __in_opt PVOID UserContext + ); + +BOOL +IMAGEAPI +SymEnumSourceFilesW( + __in HANDLE hProcess, + __in ULONG64 ModBase, + __in_opt PCWSTR Mask, + __in PSYM_ENUMSOURCEFILES_CALLBACKW cbSrcFiles, + __in_opt PVOID UserContext + ); + +BOOL +IMAGEAPI +SymEnumerateModules64( + __in HANDLE hProcess, + __in PSYM_ENUMMODULES_CALLBACK64 EnumModulesCallback, + __in_opt PVOID UserContext + ); + +BOOL +IMAGEAPI +SymEnumerateModulesW64( + __in HANDLE hProcess, + __in PSYM_ENUMMODULES_CALLBACKW64 EnumModulesCallback, + __in_opt PVOID UserContext + ); + +#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) +#define SymEnumerateModules SymEnumerateModules64 +#else +BOOL +IMAGEAPI +SymEnumerateModules( + __in HANDLE hProcess, + __in PSYM_ENUMMODULES_CALLBACK EnumModulesCallback, + __in_opt PVOID UserContext + ); +#endif + +BOOL +IMAGEAPI +EnumerateLoadedModulesEx( + __in HANDLE hProcess, + __in PENUMLOADED_MODULES_CALLBACK64 EnumLoadedModulesCallback, + __in_opt PVOID UserContext + ); + +BOOL +IMAGEAPI +EnumerateLoadedModulesExW( + __in HANDLE hProcess, + __in PENUMLOADED_MODULES_CALLBACKW64 EnumLoadedModulesCallback, + __in_opt PVOID UserContext + ); + +BOOL +IMAGEAPI +EnumerateLoadedModules64( + __in HANDLE hProcess, + __in PENUMLOADED_MODULES_CALLBACK64 EnumLoadedModulesCallback, + __in_opt PVOID UserContext + ); + +BOOL +IMAGEAPI +EnumerateLoadedModulesW64( + __in HANDLE hProcess, + __in PENUMLOADED_MODULES_CALLBACKW64 EnumLoadedModulesCallback, + __in_opt PVOID UserContext + ); + +#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) +#define EnumerateLoadedModules EnumerateLoadedModules64 +#else +BOOL +IMAGEAPI +EnumerateLoadedModules( + __in HANDLE hProcess, + __in PENUMLOADED_MODULES_CALLBACK EnumLoadedModulesCallback, + __in_opt PVOID UserContext + ); +#endif + +PVOID +IMAGEAPI +SymFunctionTableAccess64( + __in HANDLE hProcess, + __in DWORD64 AddrBase + ); + +#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) +#define SymFunctionTableAccess SymFunctionTableAccess64 +#else +PVOID +IMAGEAPI +SymFunctionTableAccess( + __in HANDLE hProcess, + __in DWORD AddrBase + ); +#endif + +BOOL +IMAGEAPI +SymGetUnwindInfo( + __in HANDLE hProcess, + __in DWORD64 Address, + __out_bcount_opt(*Size) PVOID Buffer, + __inout PULONG Size + ); + +BOOL +IMAGEAPI +SymGetModuleInfo64( + __in HANDLE hProcess, + __in DWORD64 qwAddr, + __out PIMAGEHLP_MODULE64 ModuleInfo + ); + +BOOL +IMAGEAPI +SymGetModuleInfoW64( + __in HANDLE hProcess, + __in DWORD64 qwAddr, + __out PIMAGEHLP_MODULEW64 ModuleInfo + ); + +#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) +#define SymGetModuleInfo SymGetModuleInfo64 +#define SymGetModuleInfoW SymGetModuleInfoW64 +#else +BOOL +IMAGEAPI +SymGetModuleInfo( + __in HANDLE hProcess, + __in DWORD dwAddr, + __out PIMAGEHLP_MODULE ModuleInfo + ); + +BOOL +IMAGEAPI +SymGetModuleInfoW( + __in HANDLE hProcess, + __in DWORD dwAddr, + __out PIMAGEHLP_MODULEW ModuleInfo + ); +#endif + +DWORD64 +IMAGEAPI +SymGetModuleBase64( + __in HANDLE hProcess, + __in DWORD64 qwAddr + ); + +#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) +#define SymGetModuleBase SymGetModuleBase64 +#else +DWORD +IMAGEAPI +SymGetModuleBase( + __in HANDLE hProcess, + __in DWORD dwAddr + ); +#endif + +typedef struct _SRCCODEINFO { + DWORD SizeOfStruct; // set to sizeof(SRCCODEINFO) + PVOID Key; // not used + DWORD64 ModBase; // base address of module this applies to + CHAR Obj[MAX_PATH + 1]; // the object file within the module + CHAR FileName[MAX_PATH + 1]; // full filename + DWORD LineNumber; // line number in file + DWORD64 Address; // first instruction of line +} SRCCODEINFO, *PSRCCODEINFO; + +typedef struct _SRCCODEINFOW { + DWORD SizeOfStruct; // set to sizeof(SRCCODEINFO) + PVOID Key; // not used + DWORD64 ModBase; // base address of module this applies to + WCHAR Obj[MAX_PATH + 1]; // the object file within the module + WCHAR FileName[MAX_PATH + 1]; // full filename + DWORD LineNumber; // line number in file + DWORD64 Address; // first instruction of line +} SRCCODEINFOW, *PSRCCODEINFOW; + +typedef BOOL +(CALLBACK *PSYM_ENUMLINES_CALLBACK)( + __in PSRCCODEINFO LineInfo, + __in_opt PVOID UserContext + ); + +BOOL +IMAGEAPI +SymEnumLines( + __in HANDLE hProcess, + __in ULONG64 Base, + __in_opt PCSTR Obj, + __in_opt PCSTR File, + __in PSYM_ENUMLINES_CALLBACK EnumLinesCallback, + __in_opt PVOID UserContext + ); + +typedef BOOL +(CALLBACK *PSYM_ENUMLINES_CALLBACKW)( + __in PSRCCODEINFOW LineInfo, + __in_opt PVOID UserContext + ); + +BOOL +IMAGEAPI +SymEnumLinesW( + __in HANDLE hProcess, + __in ULONG64 Base, + __in_opt PCWSTR Obj, + __in_opt PCWSTR File, + __in PSYM_ENUMLINES_CALLBACKW EnumLinesCallback, + __in_opt PVOID UserContext + ); + +BOOL +IMAGEAPI +SymGetLineFromAddr64( + __in HANDLE hProcess, + __in DWORD64 qwAddr, + __out PDWORD pdwDisplacement, + __out PIMAGEHLP_LINE64 Line64 + ); + +BOOL +IMAGEAPI +SymGetLineFromAddrW64( + __in HANDLE hProcess, + __in DWORD64 dwAddr, + __out PDWORD pdwDisplacement, + __out PIMAGEHLP_LINEW64 Line + ); + +BOOL +IMAGEAPI +SymEnumSourceLines( + __in HANDLE hProcess, + __in ULONG64 Base, + __in_opt PCSTR Obj, + __in_opt PCSTR File, + __in_opt DWORD Line, + __in DWORD Flags, + __in PSYM_ENUMLINES_CALLBACK EnumLinesCallback, + __in_opt PVOID UserContext + ); + +BOOL +IMAGEAPI +SymEnumSourceLinesW( + __in HANDLE hProcess, + __in ULONG64 Base, + __in_opt PCWSTR Obj, + __in_opt PCWSTR File, + __in_opt DWORD Line, + __in DWORD Flags, + __in PSYM_ENUMLINES_CALLBACKW EnumLinesCallback, + __in_opt PVOID UserContext + ); + +// flags for SymEnumSourceLines + +#define ESLFLAG_FULLPATH 0x1 +#define ESLFLAG_NEAREST 0x2 +#define ESLFLAG_PREV 0x4 +#define ESLFLAG_NEXT 0x8 + +#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) +#define SymGetLineFromAddr SymGetLineFromAddr64 +#define SymGetLineFromAddrW SymGetLineFromAddrW64 +#else +BOOL +IMAGEAPI +SymGetLineFromAddr( + __in HANDLE hProcess, + __in DWORD dwAddr, + __out PDWORD pdwDisplacement, + __out PIMAGEHLP_LINE Line + ); + +BOOL +IMAGEAPI +SymGetLineFromAddrW( + __in HANDLE hProcess, + __in DWORD dwAddr, + __out PDWORD pdwDisplacement, + __out PIMAGEHLP_LINEW Line + ); +#endif + +BOOL +IMAGEAPI +SymGetLineFromName64( + __in HANDLE hProcess, + __in_opt PCSTR ModuleName, + __in_opt PCSTR FileName, + __in DWORD dwLineNumber, + __out PLONG plDisplacement, + __inout PIMAGEHLP_LINE64 Line + ); + +BOOL +IMAGEAPI +SymGetLineFromNameW64( + __in HANDLE hProcess, + __in_opt PCWSTR ModuleName, + __in_opt PCWSTR FileName, + __in DWORD dwLineNumber, + __out PLONG plDisplacement, + __inout PIMAGEHLP_LINEW64 Line + ); + +#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) +#define SymGetLineFromName SymGetLineFromName64 +#else +BOOL +IMAGEAPI +SymGetLineFromName( + __in HANDLE hProcess, + __in_opt PCSTR ModuleName, + __in_opt PCSTR FileName, + __in DWORD dwLineNumber, + __out PLONG plDisplacement, + __inout PIMAGEHLP_LINE Line + ); +#endif + +BOOL +IMAGEAPI +SymGetLineNext64( + __in HANDLE hProcess, + __inout PIMAGEHLP_LINE64 Line + ); + +BOOL +IMAGEAPI +SymGetLineNextW64( + __in HANDLE hProcess, + __inout PIMAGEHLP_LINEW64 Line + ); + +#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) +#define SymGetLineNext SymGetLineNext64 +#else +BOOL +IMAGEAPI +SymGetLineNext( + __in HANDLE hProcess, + __inout PIMAGEHLP_LINE Line + ); + +BOOL +IMAGEAPI +SymGetLineNextW( + __in HANDLE hProcess, + __inout PIMAGEHLP_LINEW Line + ); +#endif + +BOOL +IMAGEAPI +SymGetLinePrev64( + __in HANDLE hProcess, + __inout PIMAGEHLP_LINE64 Line + ); + +BOOL +IMAGEAPI +SymGetLinePrevW64( + __in HANDLE hProcess, + __inout PIMAGEHLP_LINEW64 Line + ); + +#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) +#define SymGetLinePrev SymGetLinePrev64 +#else +BOOL +IMAGEAPI +SymGetLinePrev( + __in HANDLE hProcess, + __inout PIMAGEHLP_LINE Line + ); + +BOOL +IMAGEAPI +SymGetLinePrevW( + __in HANDLE hProcess, + __inout PIMAGEHLP_LINEW Line + ); +#endif + +ULONG +IMAGEAPI +SymGetFileLineOffsets64( + __in HANDLE hProcess, + __in_opt PCSTR ModuleName, + __in PCSTR FileName, + __out_ecount(BufferLines) PDWORD64 Buffer, + __in ULONG BufferLines + ); + +BOOL +IMAGEAPI +SymMatchFileName( + __in PCSTR FileName, + __in PCSTR Match, + __deref_opt_out PSTR *FileNameStop, + __deref_opt_out PSTR *MatchStop + ); + +BOOL +IMAGEAPI +SymMatchFileNameW( + __in PCWSTR FileName, + __in PCWSTR Match, + __deref_opt_out PWSTR *FileNameStop, + __deref_opt_out PWSTR *MatchStop + ); + +BOOL +IMAGEAPI +SymGetSourceFile( + __in HANDLE hProcess, + __in ULONG64 Base, + __in_opt PCSTR Params, + __in PCSTR FileSpec, + __out_ecount(Size) PSTR FilePath, + __in DWORD Size + ); + +BOOL +IMAGEAPI +SymGetSourceFileW( + __in HANDLE hProcess, + __in ULONG64 Base, + __in_opt PCWSTR Params, + __in PCWSTR FileSpec, + __out_ecount(Size) PWSTR FilePath, + __in DWORD Size + ); + +BOOL +IMAGEAPI +SymGetSourceFileToken( + __in HANDLE hProcess, + __in ULONG64 Base, + __in PCSTR FileSpec, + __deref_out PVOID *Token, + __out DWORD *Size + ); + +BOOL +IMAGEAPI +SymGetSourceFileTokenW( + __in HANDLE hProcess, + __in ULONG64 Base, + __in PCWSTR FileSpec, + __deref_out PVOID *Token, + __out DWORD *Size + ); + +BOOL +IMAGEAPI +SymGetSourceFileFromToken( + __in HANDLE hProcess, + __in PVOID Token, + __in_opt PCSTR Params, + __out_ecount(Size) PSTR FilePath, + __in DWORD Size + ); + +BOOL +IMAGEAPI +SymGetSourceFileFromTokenW( + __in HANDLE hProcess, + __in PVOID Token, + __in_opt PCWSTR Params, + __out_ecount(Size) PWSTR FilePath, + __in DWORD Size + ); + +BOOL +IMAGEAPI +SymGetSourceVarFromToken( + __in HANDLE hProcess, + __in PVOID Token, + __in_opt PCSTR Params, + __in PCSTR VarName, + __out_ecount(Size) PSTR Value, + __in DWORD Size + ); + +BOOL +IMAGEAPI +SymGetSourceVarFromTokenW( + __in HANDLE hProcess, + __in PVOID Token, + __in_opt PCWSTR Params, + __in PCWSTR VarName, + __out_ecount(Size) PWSTR Value, + __in DWORD Size + ); + +typedef BOOL (CALLBACK *PENUMSOURCEFILETOKENSCALLBACK)(__in PVOID token, __in size_t size); + +BOOL +IMAGEAPI +SymEnumSourceFileTokens( + __in HANDLE hProcess, + __in ULONG64 Base, + __in PENUMSOURCEFILETOKENSCALLBACK Callback + ); + +BOOL +IMAGEAPI +SymInitialize( + __in HANDLE hProcess, + __in_opt PCSTR UserSearchPath, + __in BOOL fInvadeProcess + ); + +BOOL +IMAGEAPI +SymInitializeW( + __in HANDLE hProcess, + __in_opt PCWSTR UserSearchPath, + __in BOOL fInvadeProcess + ); + +BOOL +IMAGEAPI +SymGetSearchPath( + __in HANDLE hProcess, + __out_ecount(SearchPathLength) PSTR SearchPath, + __in DWORD SearchPathLength + ); + +BOOL +IMAGEAPI +SymGetSearchPathW( + __in HANDLE hProcess, + __out_ecount(SearchPathLength) PWSTR SearchPath, + __in DWORD SearchPathLength + ); + +BOOL +IMAGEAPI +SymSetSearchPath( + __in HANDLE hProcess, + __in_opt PCSTR SearchPath + ); + +BOOL +IMAGEAPI +SymSetSearchPathW( + __in HANDLE hProcess, + __in_opt PCWSTR SearchPath + ); + +#define SLMFLAG_VIRTUAL 0x1 +#define SLMFLAG_ALT_INDEX 0x2 +#define SLMFLAG_NO_SYMBOLS 0x4 + +DWORD64 +IMAGEAPI +SymLoadModuleEx( + __in HANDLE hProcess, + __in_opt HANDLE hFile, + __in_opt PCSTR ImageName, + __in_opt PCSTR ModuleName, + __in DWORD64 BaseOfDll, + __in DWORD DllSize, + __in_opt PMODLOAD_DATA Data, + __in_opt DWORD Flags + ); + +DWORD64 +IMAGEAPI +SymLoadModuleExW( + __in HANDLE hProcess, + __in_opt HANDLE hFile, + __in_opt PCWSTR ImageName, + __in_opt PCWSTR ModuleName, + __in DWORD64 BaseOfDll, + __in DWORD DllSize, + __in_opt PMODLOAD_DATA Data, + __in_opt DWORD Flags + ); + +BOOL +IMAGEAPI +SymUnloadModule64( + __in HANDLE hProcess, + __in DWORD64 BaseOfDll + ); + +#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) +#define SymUnloadModule SymUnloadModule64 +#else +BOOL +IMAGEAPI +SymUnloadModule( + __in HANDLE hProcess, + __in DWORD BaseOfDll + ); +#endif + +BOOL +IMAGEAPI +SymUnDName64( + __in PIMAGEHLP_SYMBOL64 sym, // Symbol to undecorate + __out_ecount(UnDecNameLength) PSTR UnDecName, // Buffer to store undecorated name in + __in DWORD UnDecNameLength // Size of the buffer + ); + +#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) +#define SymUnDName SymUnDName64 +#else +BOOL +IMAGEAPI +SymUnDName( + __in PIMAGEHLP_SYMBOL sym, // Symbol to undecorate + __out_ecount(UnDecNameLength) PSTR UnDecName, // Buffer to store undecorated name in + __in DWORD UnDecNameLength // Size of the buffer + ); +#endif + +BOOL +IMAGEAPI +SymRegisterCallback64( + __in HANDLE hProcess, + __in PSYMBOL_REGISTERED_CALLBACK64 CallbackFunction, + __in ULONG64 UserContext + ); + +BOOL +IMAGEAPI +SymRegisterCallbackW64( + __in HANDLE hProcess, + __in PSYMBOL_REGISTERED_CALLBACK64 CallbackFunction, + __in ULONG64 UserContext + ); + +BOOL +IMAGEAPI +SymRegisterFunctionEntryCallback64( + __in HANDLE hProcess, + __in PSYMBOL_FUNCENTRY_CALLBACK64 CallbackFunction, + __in ULONG64 UserContext + ); + +#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) +#define SymRegisterCallback SymRegisterCallback64 +#define SymRegisterFunctionEntryCallback SymRegisterFunctionEntryCallback64 +#else +BOOL +IMAGEAPI +SymRegisterCallback( + __in HANDLE hProcess, + __in PSYMBOL_REGISTERED_CALLBACK CallbackFunction, + __in_opt PVOID UserContext + ); + +BOOL +IMAGEAPI +SymRegisterFunctionEntryCallback( + __in HANDLE hProcess, + __in PSYMBOL_FUNCENTRY_CALLBACK CallbackFunction, + __in_opt PVOID UserContext + ); +#endif + + +typedef struct _IMAGEHLP_SYMBOL_SRC { + DWORD sizeofstruct; + DWORD type; + char file[MAX_PATH]; +} IMAGEHLP_SYMBOL_SRC, *PIMAGEHLP_SYMBOL_SRC; + +typedef struct _MODULE_TYPE_INFO { // AKA TYPTYP + USHORT dataLength; + USHORT leaf; + BYTE data[1]; +} MODULE_TYPE_INFO, *PMODULE_TYPE_INFO; + +typedef struct _SYMBOL_INFO { + ULONG SizeOfStruct; + ULONG TypeIndex; // Type Index of symbol + ULONG64 Reserved[2]; + ULONG Index; + ULONG Size; + ULONG64 ModBase; // Base Address of module comtaining this symbol + ULONG Flags; + ULONG64 Value; // Value of symbol, ValuePresent should be 1 + ULONG64 Address; // Address of symbol including base address of module + ULONG Register; // register holding value or pointer to value + ULONG Scope; // scope of the symbol + ULONG Tag; // pdb classification + ULONG NameLen; // Actual length of name + ULONG MaxNameLen; + CHAR Name[1]; // Name of symbol +} SYMBOL_INFO, *PSYMBOL_INFO; + +typedef struct _SYMBOL_INFO_PACKAGE { + SYMBOL_INFO si; + CHAR name[MAX_SYM_NAME + 1]; +} SYMBOL_INFO_PACKAGE, *PSYMBOL_INFO_PACKAGE; + +typedef struct _SYMBOL_INFOW { + ULONG SizeOfStruct; + ULONG TypeIndex; // Type Index of symbol + ULONG64 Reserved[2]; + ULONG Index; + ULONG Size; + ULONG64 ModBase; // Base Address of module comtaining this symbol + ULONG Flags; + ULONG64 Value; // Value of symbol, ValuePresent should be 1 + ULONG64 Address; // Address of symbol including base address of module + ULONG Register; // register holding value or pointer to value + ULONG Scope; // scope of the symbol + ULONG Tag; // pdb classification + ULONG NameLen; // Actual length of name + ULONG MaxNameLen; + WCHAR Name[1]; // Name of symbol +} SYMBOL_INFOW, *PSYMBOL_INFOW; + +typedef struct _SYMBOL_INFO_PACKAGEW { + SYMBOL_INFOW si; + WCHAR name[MAX_SYM_NAME + 1]; +} SYMBOL_INFO_PACKAGEW, *PSYMBOL_INFO_PACKAGEW; + +typedef struct _IMAGEHLP_STACK_FRAME +{ + ULONG64 InstructionOffset; + ULONG64 ReturnOffset; + ULONG64 FrameOffset; + ULONG64 StackOffset; + ULONG64 BackingStoreOffset; + ULONG64 FuncTableEntry; + ULONG64 Params[4]; + ULONG64 Reserved[5]; + BOOL Virtual; + ULONG Reserved2; +} IMAGEHLP_STACK_FRAME, *PIMAGEHLP_STACK_FRAME; + +typedef VOID IMAGEHLP_CONTEXT, *PIMAGEHLP_CONTEXT; + + +BOOL +IMAGEAPI +SymSetContext( + __in HANDLE hProcess, + __in PIMAGEHLP_STACK_FRAME StackFrame, + __in_opt PIMAGEHLP_CONTEXT Context + ); + +BOOL +IMAGEAPI +SymSetScopeFromAddr( + __in HANDLE hProcess, + __in ULONG64 Address + ); + +BOOL +IMAGEAPI +SymSetScopeFromIndex( + __in HANDLE hProcess, + __in ULONG64 BaseOfDll, + __in DWORD Index + ); + +typedef BOOL +(CALLBACK *PSYM_ENUMPROCESSES_CALLBACK)( + __in HANDLE hProcess, + __in PVOID UserContext + ); + +BOOL +IMAGEAPI +SymEnumProcesses( + __in PSYM_ENUMPROCESSES_CALLBACK EnumProcessesCallback, + __in PVOID UserContext + ); + +BOOL +IMAGEAPI +SymFromAddr( + __in HANDLE hProcess, + __in DWORD64 Address, + __out_opt PDWORD64 Displacement, + __inout PSYMBOL_INFO Symbol + ); + +BOOL +IMAGEAPI +SymFromAddrW( + __in HANDLE hProcess, + __in DWORD64 Address, + __out_opt PDWORD64 Displacement, + __inout PSYMBOL_INFOW Symbol + ); + +BOOL +IMAGEAPI +SymFromToken( + __in HANDLE hProcess, + __in DWORD64 Base, + __in DWORD Token, + __inout PSYMBOL_INFO Symbol + ); + +BOOL +IMAGEAPI +SymFromTokenW( + __in HANDLE hProcess, + __in DWORD64 Base, + __in DWORD Token, + __inout PSYMBOL_INFOW Symbol + ); + +BOOL +IMAGEAPI +SymNext( + __in HANDLE hProcess, + __inout PSYMBOL_INFO si + ); + +BOOL +IMAGEAPI +SymNextW( + __in HANDLE hProcess, + __inout PSYMBOL_INFOW siw + ); + +BOOL +IMAGEAPI +SymPrev( + __in HANDLE hProcess, + __inout PSYMBOL_INFO si + ); + +BOOL +IMAGEAPI +SymPrevW( + __in HANDLE hProcess, + __inout PSYMBOL_INFOW siw + ); + +// While SymFromName will provide a symbol from a name, +// SymEnumSymbols can provide the same matching information +// for ALL symbols with a matching name, even regular +// expressions. That way you can search across modules +// and differentiate between identically named symbols. + +BOOL +IMAGEAPI +SymFromName( + __in HANDLE hProcess, + __in PCSTR Name, + __inout PSYMBOL_INFO Symbol + ); + +BOOL +IMAGEAPI +SymFromNameW( + __in HANDLE hProcess, + __in PCWSTR Name, + __inout PSYMBOL_INFOW Symbol + ); + +typedef BOOL +(CALLBACK *PSYM_ENUMERATESYMBOLS_CALLBACK)( + __in PSYMBOL_INFO pSymInfo, + __in ULONG SymbolSize, + __in_opt PVOID UserContext + ); + +BOOL +IMAGEAPI +SymEnumSymbols( + __in HANDLE hProcess, + __in ULONG64 BaseOfDll, + __in_opt PCSTR Mask, + __in PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback, + __in_opt PVOID UserContext + ); + +typedef BOOL +(CALLBACK *PSYM_ENUMERATESYMBOLS_CALLBACKW)( + __in PSYMBOL_INFOW pSymInfo, + __in ULONG SymbolSize, + __in_opt PVOID UserContext + ); + +BOOL +IMAGEAPI +SymEnumSymbolsW( + __in HANDLE hProcess, + __in ULONG64 BaseOfDll, + __in_opt PCWSTR Mask, + __in PSYM_ENUMERATESYMBOLS_CALLBACKW EnumSymbolsCallback, + __in_opt PVOID UserContext + ); + +BOOL +IMAGEAPI +SymEnumSymbolsForAddr( + __in HANDLE hProcess, + __in DWORD64 Address, + __in PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback, + __in_opt PVOID UserContext + ); + +BOOL +IMAGEAPI +SymEnumSymbolsForAddrW( + __in HANDLE hProcess, + __in DWORD64 Address, + __in PSYM_ENUMERATESYMBOLS_CALLBACKW EnumSymbolsCallback, + __in_opt PVOID UserContext + ); + +#define SYMSEARCH_MASKOBJS 0x01 // used internally to implement other APIs +#define SYMSEARCH_RECURSE 0X02 // recurse scopes +#define SYMSEARCH_GLOBALSONLY 0X04 // search only for global symbols +#define SYMSEARCH_ALLITEMS 0X08 // search for everything in the pdb, not just normal scoped symbols + +BOOL +IMAGEAPI +SymSearch( + __in HANDLE hProcess, + __in ULONG64 BaseOfDll, + __in_opt DWORD Index, + __in_opt DWORD SymTag, + __in_opt PCSTR Mask, + __in_opt DWORD64 Address, + __in PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback, + __in_opt PVOID UserContext, + __in DWORD Options + ); + +BOOL +IMAGEAPI +SymSearchW( + __in HANDLE hProcess, + __in ULONG64 BaseOfDll, + __in_opt DWORD Index, + __in_opt DWORD SymTag, + __in_opt PCWSTR Mask, + __in_opt DWORD64 Address, + __in PSYM_ENUMERATESYMBOLS_CALLBACKW EnumSymbolsCallback, + __in_opt PVOID UserContext, + __in DWORD Options + ); + +BOOL +IMAGEAPI +SymGetScope( + __in HANDLE hProcess, + __in ULONG64 BaseOfDll, + __in DWORD Index, + __inout PSYMBOL_INFO Symbol + ); + +BOOL +IMAGEAPI +SymGetScopeW( + __in HANDLE hProcess, + __in ULONG64 BaseOfDll, + __in DWORD Index, + __inout PSYMBOL_INFOW Symbol + ); + +BOOL +IMAGEAPI +SymFromIndex( + __in HANDLE hProcess, + __in ULONG64 BaseOfDll, + __in DWORD Index, + __inout PSYMBOL_INFO Symbol + ); + +BOOL +IMAGEAPI +SymFromIndexW( + __in HANDLE hProcess, + __in ULONG64 BaseOfDll, + __in DWORD Index, + __inout PSYMBOL_INFOW Symbol + ); + +typedef enum _IMAGEHLP_SYMBOL_TYPE_INFO { + TI_GET_SYMTAG, + TI_GET_SYMNAME, + TI_GET_LENGTH, + TI_GET_TYPE, + TI_GET_TYPEID, + TI_GET_BASETYPE, + TI_GET_ARRAYINDEXTYPEID, + TI_FINDCHILDREN, + TI_GET_DATAKIND, + TI_GET_ADDRESSOFFSET, + TI_GET_OFFSET, + TI_GET_VALUE, + TI_GET_COUNT, + TI_GET_CHILDRENCOUNT, + TI_GET_BITPOSITION, + TI_GET_VIRTUALBASECLASS, + TI_GET_VIRTUALTABLESHAPEID, + TI_GET_VIRTUALBASEPOINTEROFFSET, + TI_GET_CLASSPARENTID, + TI_GET_NESTED, + TI_GET_SYMINDEX, + TI_GET_LEXICALPARENT, + TI_GET_ADDRESS, + TI_GET_THISADJUST, + TI_GET_UDTKIND, + TI_IS_EQUIV_TO, + TI_GET_CALLING_CONVENTION, + TI_IS_CLOSE_EQUIV_TO, + TI_GTIEX_REQS_VALID, + TI_GET_VIRTUALBASEOFFSET, + TI_GET_VIRTUALBASEDISPINDEX, + TI_GET_IS_REFERENCE, + TI_GET_INDIRECTVIRTUALBASECLASS, + IMAGEHLP_SYMBOL_TYPE_INFO_MAX, +} IMAGEHLP_SYMBOL_TYPE_INFO; + +typedef struct _TI_FINDCHILDREN_PARAMS { + ULONG Count; + ULONG Start; + ULONG ChildId[1]; +} TI_FINDCHILDREN_PARAMS; + +BOOL +IMAGEAPI +SymGetTypeInfo( + __in HANDLE hProcess, + __in DWORD64 ModBase, + __in ULONG TypeId, + __in IMAGEHLP_SYMBOL_TYPE_INFO GetType, + __out PVOID pInfo + ); + +#define IMAGEHLP_GET_TYPE_INFO_UNCACHED 0x00000001 +#define IMAGEHLP_GET_TYPE_INFO_CHILDREN 0x00000002 + +typedef struct _IMAGEHLP_GET_TYPE_INFO_PARAMS { + IN ULONG SizeOfStruct; + IN ULONG Flags; + IN ULONG NumIds; + IN PULONG TypeIds; + IN ULONG64 TagFilter; + IN ULONG NumReqs; + IN IMAGEHLP_SYMBOL_TYPE_INFO* ReqKinds; + IN PULONG_PTR ReqOffsets; + IN PULONG ReqSizes; + IN ULONG_PTR ReqStride; + IN ULONG_PTR BufferSize; + OUT PVOID Buffer; + OUT ULONG EntriesMatched; + OUT ULONG EntriesFilled; + OUT ULONG64 TagsFound; + OUT ULONG64 AllReqsValid; + IN ULONG NumReqsValid; + OUT PULONG64 ReqsValid OPTIONAL; +} IMAGEHLP_GET_TYPE_INFO_PARAMS, *PIMAGEHLP_GET_TYPE_INFO_PARAMS; + +BOOL +IMAGEAPI +SymGetTypeInfoEx( + __in HANDLE hProcess, + __in DWORD64 ModBase, + __inout PIMAGEHLP_GET_TYPE_INFO_PARAMS Params + ); + +BOOL +IMAGEAPI +SymEnumTypes( + __in HANDLE hProcess, + __in ULONG64 BaseOfDll, + __in PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback, + __in_opt PVOID UserContext + ); + +BOOL +IMAGEAPI +SymEnumTypesW( + __in HANDLE hProcess, + __in ULONG64 BaseOfDll, + __in PSYM_ENUMERATESYMBOLS_CALLBACKW EnumSymbolsCallback, + __in_opt PVOID UserContext + ); + +BOOL +IMAGEAPI +SymEnumTypesByName( + __in HANDLE hProcess, + __in ULONG64 BaseOfDll, + __in_opt PCSTR mask, + __in PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback, + __in_opt PVOID UserContext + ); + +BOOL +IMAGEAPI +SymEnumTypesByNameW( + __in HANDLE hProcess, + __in ULONG64 BaseOfDll, + __in_opt PCWSTR mask, + __in PSYM_ENUMERATESYMBOLS_CALLBACKW EnumSymbolsCallback, + __in_opt PVOID UserContext + ); + +BOOL +IMAGEAPI +SymGetTypeFromName( + __in HANDLE hProcess, + __in ULONG64 BaseOfDll, + __in PCSTR Name, + __inout PSYMBOL_INFO Symbol + ); + +BOOL +IMAGEAPI +SymGetTypeFromNameW( + __in HANDLE hProcess, + __in ULONG64 BaseOfDll, + __in PCWSTR Name, + __inout PSYMBOL_INFOW Symbol + ); + +BOOL +IMAGEAPI +SymAddSymbol( + __in HANDLE hProcess, + __in ULONG64 BaseOfDll, + __in PCSTR Name, + __in DWORD64 Address, + __in DWORD Size, + __in DWORD Flags + ); + +BOOL +IMAGEAPI +SymAddSymbolW( + __in HANDLE hProcess, + __in ULONG64 BaseOfDll, + __in PCWSTR Name, + __in DWORD64 Address, + __in DWORD Size, + __in DWORD Flags + ); + +BOOL +IMAGEAPI +SymDeleteSymbol( + __in HANDLE hProcess, + __in ULONG64 BaseOfDll, + __in_opt PCSTR Name, + __in DWORD64 Address, + __in DWORD Flags + ); + +BOOL +IMAGEAPI +SymDeleteSymbolW( + __in HANDLE hProcess, + __in ULONG64 BaseOfDll, + __in_opt PCWSTR Name, + __in DWORD64 Address, + __in DWORD Flags + ); + +BOOL +IMAGEAPI +SymRefreshModuleList( + __in HANDLE hProcess + ); + +BOOL +IMAGEAPI +SymAddSourceStream( + __in HANDLE hProcess, + __in ULONG64 Base, + __in_opt PCSTR StreamFile, + __in_bcount_opt(Size) PBYTE Buffer, + __in size_t Size + ); + +typedef BOOL (WINAPI *SYMADDSOURCESTREAM)(HANDLE, ULONG64, PCSTR, PBYTE, size_t); + +BOOL +IMAGEAPI +SymAddSourceStreamA( + __in HANDLE hProcess, + __in ULONG64 Base, + __in_opt PCSTR StreamFile, + __in_bcount_opt(Size) PBYTE Buffer, + __in size_t Size + ); + +typedef BOOL (WINAPI *SYMADDSOURCESTREAMA)(HANDLE, ULONG64, PCSTR, PBYTE, size_t); + +BOOL +IMAGEAPI +SymAddSourceStreamW( + __in HANDLE hProcess, + __in ULONG64 Base, + __in_opt PCWSTR FileSpec, + __in_bcount_opt(Size) PBYTE Buffer, + __in size_t Size + ); + +BOOL +IMAGEAPI +SymSrvIsStoreW( + __in_opt HANDLE hProcess, + __in PCWSTR path + ); + +BOOL +IMAGEAPI +SymSrvIsStore( + __in_opt HANDLE hProcess, + __in PCSTR path + ); + +PCSTR +IMAGEAPI +SymSrvDeltaName( + __in HANDLE hProcess, + __in_opt PCSTR SymPath, + __in PCSTR Type, + __in PCSTR File1, + __in PCSTR File2 + ); + +PCWSTR +IMAGEAPI +SymSrvDeltaNameW( + __in HANDLE hProcess, + __in_opt PCWSTR SymPath, + __in PCWSTR Type, + __in PCWSTR File1, + __in PCWSTR File2 + ); + +PCSTR +IMAGEAPI +SymSrvGetSupplement( + __in HANDLE hProcess, + __in_opt PCSTR SymPath, + __in PCSTR Node, + __in PCSTR File + ); + +PCWSTR +IMAGEAPI +SymSrvGetSupplementW( + __in HANDLE hProcess, + __in_opt PCWSTR SymPath, + __in PCWSTR Node, + __in PCWSTR File + ); + +BOOL +IMAGEAPI +SymSrvGetFileIndexes( + __in PCSTR File, + __out GUID *Id, + __out PDWORD Val1, + __out_opt PDWORD Val2, + __in DWORD Flags + ); + +BOOL +IMAGEAPI +SymSrvGetFileIndexesW( + __in PCWSTR File, + __out GUID *Id, + __out PDWORD Val1, + __out_opt PDWORD Val2, + __in DWORD Flags + ); + +BOOL +IMAGEAPI +SymSrvGetFileIndexStringW( + __in HANDLE hProcess, + __in_opt PCWSTR SrvPath, + __in PCWSTR File, + __out_ecount(Size) PWSTR Index, + __in size_t Size, + __in DWORD Flags + ); + +BOOL +IMAGEAPI +SymSrvGetFileIndexString( + __in HANDLE hProcess, + __in_opt PCSTR SrvPath, + __in PCSTR File, + __out_ecount(Size) PSTR Index, + __in size_t Size, + __in DWORD Flags + ); + +typedef struct { + DWORD sizeofstruct; + char file[MAX_PATH +1]; + BOOL stripped; + DWORD timestamp; + DWORD size; + char dbgfile[MAX_PATH +1]; + char pdbfile[MAX_PATH + 1]; + GUID guid; + DWORD sig; + DWORD age; +} SYMSRV_INDEX_INFO, *PSYMSRV_INDEX_INFO; + +typedef struct { + DWORD sizeofstruct; + WCHAR file[MAX_PATH +1]; + BOOL stripped; + DWORD timestamp; + DWORD size; + WCHAR dbgfile[MAX_PATH +1]; + WCHAR pdbfile[MAX_PATH + 1]; + GUID guid; + DWORD sig; + DWORD age; +} SYMSRV_INDEX_INFOW, *PSYMSRV_INDEX_INFOW; + +BOOL +IMAGEAPI +SymSrvGetFileIndexInfo( + __in PCSTR File, + __out PSYMSRV_INDEX_INFO Info, + __in DWORD Flags + ); + +BOOL +IMAGEAPI +SymSrvGetFileIndexInfoW( + __in PCWSTR File, + __out PSYMSRV_INDEX_INFOW Info, + __in DWORD Flags + ); + +PCSTR +IMAGEAPI +SymSrvStoreSupplement( + __in HANDLE hProcess, + __in_opt PCSTR SrvPath, + __in PCSTR Node, + __in PCSTR File, + __in DWORD Flags + ); + +PCWSTR +IMAGEAPI +SymSrvStoreSupplementW( + __in HANDLE hProcess, + __in_opt PCWSTR SymPath, + __in PCWSTR Node, + __in PCWSTR File, + __in DWORD Flags + ); + +PCSTR +IMAGEAPI +SymSrvStoreFile( + __in HANDLE hProcess, + __in_opt PCSTR SrvPath, + __in PCSTR File, + __in DWORD Flags + ); + +PCWSTR +IMAGEAPI +SymSrvStoreFileW( + __in HANDLE hProcess, + __in_opt PCWSTR SrvPath, + __in PCWSTR File, + __in DWORD Flags + ); + +// used by SymGetSymbolFile's "Type" parameter + +enum { + sfImage = 0, + sfDbg, + sfPdb, + sfMpd, + sfMax +}; + +BOOL +IMAGEAPI +SymGetSymbolFile( + __in_opt HANDLE hProcess, + __in_opt PCSTR SymPath, + __in PCSTR ImageFile, + __in DWORD Type, + __out_ecount(cSymbolFile) PSTR SymbolFile, + __in size_t cSymbolFile, + __out_ecount(cDbgFile) PSTR DbgFile, + __in size_t cDbgFile + ); + +BOOL +IMAGEAPI +SymGetSymbolFileW( + __in_opt HANDLE hProcess, + __in_opt PCWSTR SymPath, + __in PCWSTR ImageFile, + __in DWORD Type, + __out_ecount(cSymbolFile) PWSTR SymbolFile, + __in size_t cSymbolFile, + __out_ecount(cDbgFile) PWSTR DbgFile, + __in size_t cDbgFile + ); + +// +// Full user-mode dump creation. +// + +typedef BOOL (WINAPI *PDBGHELP_CREATE_USER_DUMP_CALLBACK)( + __in DWORD DataType, + __in PVOID* Data, + __out LPDWORD DataLength, + __in_opt PVOID UserData + ); + +BOOL +WINAPI +DbgHelpCreateUserDump( + __in_opt LPCSTR FileName, + __in PDBGHELP_CREATE_USER_DUMP_CALLBACK Callback, + __in_opt PVOID UserData + ); + +BOOL +WINAPI +DbgHelpCreateUserDumpW( + __in_opt LPCWSTR FileName, + __in PDBGHELP_CREATE_USER_DUMP_CALLBACK Callback, + __in_opt PVOID UserData + ); + +// ----------------------------------------------------------------- +// The following 4 legacy APIs are fully supported, but newer +// ones are recommended. SymFromName and SymFromAddr provide +// much more detailed info on the returned symbol. + +BOOL +IMAGEAPI +SymGetSymFromAddr64( + __in HANDLE hProcess, + __in DWORD64 qwAddr, + __out_opt PDWORD64 pdwDisplacement, + __inout PIMAGEHLP_SYMBOL64 Symbol + ); + + +#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) +#define SymGetSymFromAddr SymGetSymFromAddr64 +#else +BOOL +IMAGEAPI +SymGetSymFromAddr( + __in HANDLE hProcess, + __in DWORD dwAddr, + __out_opt PDWORD pdwDisplacement, + __inout PIMAGEHLP_SYMBOL Symbol + ); +#endif + +// While following two APIs will provide a symbol from a name, +// SymEnumSymbols can provide the same matching information +// for ALL symbols with a matching name, even regular +// expressions. That way you can search across modules +// and differentiate between identically named symbols. + +BOOL +IMAGEAPI +SymGetSymFromName64( + __in HANDLE hProcess, + __in PCSTR Name, + __inout PIMAGEHLP_SYMBOL64 Symbol + ); + +#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) +#define SymGetSymFromName SymGetSymFromName64 +#else +BOOL +IMAGEAPI +SymGetSymFromName( + __in HANDLE hProcess, + __in PCSTR Name, + __inout PIMAGEHLP_SYMBOL Symbol + ); +#endif + + +// Symbol server exports + +typedef BOOL (WINAPI *PSYMBOLSERVERPROC)(PCSTR, PCSTR, PVOID, DWORD, DWORD, PSTR); +typedef BOOL (WINAPI *PSYMBOLSERVERPROCA)(PCSTR, PCSTR, PVOID, DWORD, DWORD, PSTR); +typedef BOOL (WINAPI *PSYMBOLSERVERPROCW)(PCWSTR, PCWSTR, PVOID, DWORD, DWORD, PWSTR); +typedef BOOL (WINAPI *PSYMBOLSERVERBYINDEXPROC)(PCSTR, PCSTR, PCSTR, PSTR); +typedef BOOL (WINAPI *PSYMBOLSERVERBYINDEXPROCA)(PCSTR, PCSTR, PCSTR, PSTR); +typedef BOOL (WINAPI *PSYMBOLSERVERBYINDEXPROCW)(PCWSTR, PCWSTR, PCWSTR, PWSTR); +typedef BOOL (WINAPI *PSYMBOLSERVEROPENPROC)(VOID); +typedef BOOL (WINAPI *PSYMBOLSERVERCLOSEPROC)(VOID); +typedef BOOL (WINAPI *PSYMBOLSERVERSETOPTIONSPROC)(UINT_PTR, ULONG64); +typedef BOOL (WINAPI *PSYMBOLSERVERSETOPTIONSWPROC)(UINT_PTR, ULONG64); +typedef BOOL (CALLBACK WINAPI *PSYMBOLSERVERCALLBACKPROC)(UINT_PTR action, ULONG64 data, ULONG64 context); +typedef UINT_PTR (WINAPI *PSYMBOLSERVERGETOPTIONSPROC)(); +typedef BOOL (WINAPI *PSYMBOLSERVERPINGPROC)(PCSTR); +typedef BOOL (WINAPI *PSYMBOLSERVERPINGPROCA)(PCSTR); +typedef BOOL (WINAPI *PSYMBOLSERVERPINGPROCW)(PCWSTR); +typedef BOOL (WINAPI *PSYMBOLSERVERGETVERSION)(LPAPI_VERSION); +typedef BOOL (WINAPI *PSYMBOLSERVERDELTANAME)(PCSTR, PVOID, DWORD, DWORD, PVOID, DWORD, DWORD, PSTR, size_t); +typedef BOOL (WINAPI *PSYMBOLSERVERDELTANAMEW)(PCWSTR, PVOID, DWORD, DWORD, PVOID, DWORD, DWORD, PWSTR, size_t); +typedef BOOL (WINAPI *PSYMBOLSERVERGETSUPPLEMENT)(PCSTR, PCSTR, PCSTR, PSTR, size_t); +typedef BOOL (WINAPI *PSYMBOLSERVERGETSUPPLEMENTW)(PCWSTR, PCWSTR, PCWSTR, PWSTR, size_t); +typedef BOOL (WINAPI *PSYMBOLSERVERSTORESUPPLEMENT)(PCSTR, PCSTR, PCSTR, PSTR, size_t, DWORD); +typedef BOOL (WINAPI *PSYMBOLSERVERSTORESUPPLEMENTW)(PCWSTR, PCWSTR, PCWSTR, PWSTR, size_t, DWORD); +typedef BOOL (WINAPI *PSYMBOLSERVERGETINDEXSTRING)(PVOID, DWORD, DWORD, PSTR, size_t); +typedef BOOL (WINAPI *PSYMBOLSERVERGETINDEXSTRINGW)(PVOID, DWORD, DWORD, PWSTR, size_t); +typedef BOOL (WINAPI *PSYMBOLSERVERSTOREFILE)(PCSTR, PCSTR, PVOID, DWORD, DWORD, PSTR, size_t, DWORD); +typedef BOOL (WINAPI *PSYMBOLSERVERSTOREFILEW)(PCWSTR, PCWSTR, PVOID, DWORD, DWORD, PWSTR, size_t, DWORD); +typedef BOOL (WINAPI *PSYMBOLSERVERISSTORE)(PCSTR); +typedef BOOL (WINAPI *PSYMBOLSERVERISSTOREW)(PCWSTR); +typedef DWORD (WINAPI *PSYMBOLSERVERVERSION)(); +typedef BOOL (CALLBACK WINAPI *PSYMBOLSERVERMESSAGEPROC)(UINT_PTR action, ULONG64 data, ULONG64 context); + +#define SYMSRV_VERSION 2 + +#define SSRVOPT_CALLBACK 0x00000001 +#define SSRVOPT_DWORD 0x00000002 +#define SSRVOPT_DWORDPTR 0x00000004 +#define SSRVOPT_GUIDPTR 0x00000008 +#define SSRVOPT_OLDGUIDPTR 0x00000010 +#define SSRVOPT_UNATTENDED 0x00000020 +#define SSRVOPT_NOCOPY 0x00000040 +#define SSRVOPT_GETPATH 0x00000040 +#define SSRVOPT_PARENTWIN 0x00000080 +#define SSRVOPT_PARAMTYPE 0x00000100 +#define SSRVOPT_SECURE 0x00000200 +#define SSRVOPT_TRACE 0x00000400 +#define SSRVOPT_SETCONTEXT 0x00000800 +#define SSRVOPT_PROXY 0x00001000 +#define SSRVOPT_DOWNSTREAM_STORE 0x00002000 +#define SSRVOPT_OVERWRITE 0x00004000 +#define SSRVOPT_RESETTOU 0x00008000 +#define SSRVOPT_CALLBACKW 0x00010000 +#define SSRVOPT_FLAT_DEFAULT_STORE 0x00020000 +#define SSRVOPT_PROXYW 0x00040000 +#define SSRVOPT_MESSAGE 0x00080000 +#define SSRVOPT_SERVICE 0x00100000 // deprecated +#define SSRVOPT_FAVOR_COMPRESSED 0x00200000 +#define SSRVOPT_STRING 0x00400000 +#define SSRVOPT_WINHTTP 0x00800000 +#define SSRVOPT_WININET 0x01000000 + +#define SSRVOPT_MAX 0x0100000 + +#define SSRVOPT_RESET ((ULONG_PTR)-1) + + +#define NUM_SSRVOPTS 30 + +#define SSRVACTION_TRACE 1 +#define SSRVACTION_QUERYCANCEL 2 +#define SSRVACTION_EVENT 3 +#define SSRVACTION_EVENTW 4 +#define SSRVACTION_SIZE 5 + +#define SYMSTOREOPT_COMPRESS 0x01 +#define SYMSTOREOPT_OVERWRITE 0x02 +#define SYMSTOREOPT_RETURNINDEX 0x04 +#define SYMSTOREOPT_POINTER 0x08 +#define SYMSTOREOPT_ALT_INDEX 0x10 +#define SYMSTOREOPT_UNICODE 0x20 +#define SYMSTOREOPT_PASS_IF_EXISTS 0x40 + +#ifdef DBGHELP_TRANSLATE_TCHAR + #define SymInitialize SymInitializeW + #define SymAddSymbol SymAddSymbolW + #define SymDeleteSymbol SymDeleteSymbolW + #define SearchTreeForFile SearchTreeForFileW + #define UnDecorateSymbolName UnDecorateSymbolNameW + #define SymGetLineFromName64 SymGetLineFromNameW64 + #define SymGetLineFromAddr64 SymGetLineFromAddrW64 + #define SymGetLineNext64 SymGetLineNextW64 + #define SymGetLinePrev64 SymGetLinePrevW64 + #define SymFromName SymFromNameW + #define SymFindExecutableImage SymFindExecutableImageW + #define FindExecutableImageEx FindExecutableImageExW + #define SymSearch SymSearchW + #define SymEnumLines SymEnumLinesW + #define SymEnumSourceLines SymEnumSourceLinesW + #define SymGetTypeFromName SymGetTypeFromNameW + #define SymEnumSymbolsForAddr SymEnumSymbolsForAddrW + #define SymFromAddr SymFromAddrW + #define SymMatchString SymMatchStringW + #define SymEnumSourceFiles SymEnumSourceFilesW + #define SymEnumSymbols SymEnumSymbolsW + #define SymLoadModuleEx SymLoadModuleExW + #define SymSetSearchPath SymSetSearchPathW + #define SymGetSearchPath SymGetSearchPathW + #define EnumDirTree EnumDirTreeW + #define SymFromToken SymFromTokenW + #define SymFromIndex SymFromIndexW + #define SymGetScope SymGetScopeW + #define SymNext SymNextW + #define SymPrev SymPrevW + #define SymEnumTypes SymEnumTypesW + #define SymEnumTypesByName SymEnumTypesByNameW + #define SymRegisterCallback64 SymRegisterCallbackW64 + #define SymFindDebugInfoFile SymFindDebugInfoFileW + #define FindDebugInfoFileEx FindDebugInfoFileExW + #define SymFindFileInPath SymFindFileInPathW + #define SymEnumerateModules64 SymEnumerateModulesW64 + #define SymSetHomeDirectory SymSetHomeDirectoryW + #define SymGetHomeDirectory SymGetHomeDirectoryW + #define SymGetSourceFile SymGetSourceFileW + #define SymGetSourceFileToken SymGetSourceFileTokenW + #define SymGetSourceFileFromToken SymGetSourceFileFromTokenW + #define SymGetSourceVarFromToken SymGetSourceVarFromTokenW + #define SymGetSourceFileToken SymGetSourceFileTokenW + #define SymGetFileLineOffsets64 SymGetFileLineOffsetsW64 + #define SymFindFileInPath SymFindFileInPathW + #define SymMatchFileName SymMatchFileNameW + #define SymGetSourceFileFromToken SymGetSourceFileFromTokenW + #define SymGetSourceVarFromToken SymGetSourceVarFromTokenW + #define SymGetModuleInfo64 SymGetModuleInfoW64 + #define SymSrvIsStore SymSrvIsStoreW + #define SymSrvDeltaName SymSrvDeltaNameW + #define SymSrvGetSupplement SymSrvGetSupplementW + #define SymSrvStoreSupplement SymSrvStoreSupplementW + #define SymSrvGetFileIndexes SymSrvGetFileIndexes + #define SymSrvGetFileIndexString SymSrvGetFileIndexStringW + #define SymSrvStoreFile SymSrvStoreFileW + #define SymGetSymbolFile SymGetSymbolFileW + #define EnumerateLoadedModules64 EnumerateLoadedModulesW64 + #define EnumerateLoadedModulesEx EnumerateLoadedModulesExW + #define SymSrvGetFileIndexInfo SymSrvGetFileIndexInfoW + + #define IMAGEHLP_LINE64 IMAGEHLP_LINEW64 + #define PIMAGEHLP_LINE64 PIMAGEHLP_LINEW64 + #define SYMBOL_INFO SYMBOL_INFOW + #define PSYMBOL_INFO PSYMBOL_INFOW + #define SYMBOL_INFO_PACKAGE SYMBOL_INFO_PACKAGEW + #define PSYMBOL_INFO_PACKAGE PSYMBOL_INFO_PACKAGEW + #define FIND_EXE_FILE_CALLBACK FIND_EXE_FILE_CALLBACKW + #define PFIND_EXE_FILE_CALLBACK PFIND_EXE_FILE_CALLBACKW + #define SYM_ENUMERATESYMBOLS_CALLBACK SYM_ENUMERATESYMBOLS_CALLBACKW + #define PSYM_ENUMERATESYMBOLS_CALLBACK PSYM_ENUMERATESYMBOLS_CALLBACKW + #define SRCCODEINFO SRCCODEINFOW + #define PSRCCODEINFO PSRCCODEINFOW + #define SOURCEFILE SOURCEFILEW + #define PSOURCEFILE PSOURCEFILEW + #define SYM_ENUMSOURECFILES_CALLBACK SYM_ENUMSOURCEFILES_CALLBACKW + #define PSYM_ENUMSOURCEFILES_CALLBACK PSYM_ENUMSOURECFILES_CALLBACKW + #define IMAGEHLP_CBA_EVENT IMAGEHLP_CBA_EVENTW + #define PIMAGEHLP_CBA_EVENT PIMAGEHLP_CBA_EVENTW + #define PENUMDIRTREE_CALLBACK PENUMDIRTREE_CALLBACKW + #define IMAGEHLP_DEFERRED_SYMBOL_LOAD64 IMAGEHLP_DEFERRED_SYMBOL_LOADW64 + #define PIMAGEHLP_DEFERRED_SYMBOL_LOAD64 PIMAGEHLP_DEFERRED_SYMBOL_LOADW64 + #define PFIND_DEBUG_FILE_CALLBACK PFIND_DEBUG_FILE_CALLBACKW + #define PFINDFILEINPATHCALLBACK PFINDFILEINPATHCALLBACKW + #define IMAGEHLP_MODULE64 IMAGEHLP_MODULEW64 + #define PIMAGEHLP_MODULE64 PIMAGEHLP_MODULEW64 + #define SYMSRV_INDEX_INFO SYMSRV_INDEX_INFOW + #define PSYMSRV_INDEX_INFO PSYMSRV_INDEX_INFOW + + #define PSYMBOLSERVERPROC PSYMBOLSERVERPROCW + #define PSYMBOLSERVERPINGPROC PSYMBOLSERVERPINGPROCW +#endif + +// ----------------------------------------------------------------- +// The following APIs exist only for backwards compatibility +// with a pre-release version documented in an MSDN release. + +// You should use SymFindFileInPath if you want to maintain +// future compatibility. + +DBHLP_DEPRECIATED +BOOL +IMAGEAPI +FindFileInPath( + __in HANDLE hprocess, + __in PCSTR SearchPath, + __in PCSTR FileName, + __in PVOID id, + __in DWORD two, + __in DWORD three, + __in DWORD flags, + __out_ecount(MAX_PATH + 1) PSTR FilePath + ); + +// You should use SymFindFileInPath if you want to maintain +// future compatibility. + +DBHLP_DEPRECIATED +BOOL +IMAGEAPI +FindFileInSearchPath( + __in HANDLE hprocess, + __in PCSTR SearchPath, + __in PCSTR FileName, + __in DWORD one, + __in DWORD two, + __in DWORD three, + __out_ecount(MAX_PATH + 1) PSTR FilePath + ); + +DBHLP_DEPRECIATED +BOOL +IMAGEAPI +SymEnumSym( + __in HANDLE hProcess, + __in ULONG64 BaseOfDll, + __in PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback, + __in_opt PVOID UserContext + ); + +DBHLP_DEPRECIATED +BOOL +IMAGEAPI +SymEnumerateSymbols64( + __in HANDLE hProcess, + __in ULONG64 BaseOfDll, + __in PSYM_ENUMSYMBOLS_CALLBACK64 EnumSymbolsCallback, + __in_opt PVOID UserContext + ); + +DBHLP_DEPRECIATED +BOOL +IMAGEAPI +SymEnumerateSymbolsW64( + __in HANDLE hProcess, + __in ULONG64 BaseOfDll, + __in PSYM_ENUMSYMBOLS_CALLBACK64W EnumSymbolsCallback, + __in_opt PVOID UserContext + ); + + +#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) +#define SymEnumerateSymbols SymEnumerateSymbols64 +#define SymEnumerateSymbolsW SymEnumerateSymbolsW64 +#else +DBHLP_DEPRECIATED +BOOL +IMAGEAPI +SymEnumerateSymbols( + __in HANDLE hProcess, + __in ULONG BaseOfDll, + __in PSYM_ENUMSYMBOLS_CALLBACK EnumSymbolsCallback, + __in_opt PVOID UserContext + ); + +DBHLP_DEPRECIATED +BOOL +IMAGEAPI +SymEnumerateSymbolsW( + __in HANDLE hProcess, + __in ULONG BaseOfDll, + __in PSYM_ENUMSYMBOLS_CALLBACKW EnumSymbolsCallback, + __in_opt PVOID UserContext + ); +#endif + +// use SymLoadModuleEx + +DWORD64 +IMAGEAPI +SymLoadModule64( + __in HANDLE hProcess, + __in_opt HANDLE hFile, + __in_opt PCSTR ImageName, + __in_opt PCSTR ModuleName, + __in DWORD64 BaseOfDll, + __in DWORD SizeOfDll + ); + +#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) +#define SymLoadModule SymLoadModule64 +#else +DWORD +IMAGEAPI +SymLoadModule( + __in HANDLE hProcess, + __in_opt HANDLE hFile, + __in_opt PCSTR ImageName, + __in_opt PCSTR ModuleName, + __in DWORD BaseOfDll, + __in DWORD SizeOfDll + ); +#endif + +BOOL +IMAGEAPI +SymGetSymNext64( + __in HANDLE hProcess, + __inout PIMAGEHLP_SYMBOL64 Symbol + ); + +BOOL +IMAGEAPI +SymGetSymNextW64( + __in HANDLE hProcess, + __inout PIMAGEHLP_SYMBOLW64 Symbol + ); + +#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) +#define SymGetSymNext SymGetSymNext64 +#define SymGetSymNextW SymGetSymNextW64 +#else +BOOL +IMAGEAPI +SymGetSymNext( + __in HANDLE hProcess, + __inout PIMAGEHLP_SYMBOL Symbol + ); + +BOOL +IMAGEAPI +SymGetSymNextW( + __in HANDLE hProcess, + __inout PIMAGEHLP_SYMBOLW Symbol + ); +#endif + +BOOL +IMAGEAPI +SymGetSymPrev64( + __in HANDLE hProcess, + __inout PIMAGEHLP_SYMBOL64 Symbol + ); + +BOOL +IMAGEAPI +SymGetSymPrevW64( + __in HANDLE hProcess, + __inout PIMAGEHLP_SYMBOLW64 Symbol + ); + +#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) +#define SymGetSymPrev SymGetSymPrev64 +#define SymGetSymPrevW SymGetSymPrevW64 +#else +BOOL +IMAGEAPI +SymGetSymPrev( + __in HANDLE hProcess, + __inout PIMAGEHLP_SYMBOL Symbol + ); + +BOOL +IMAGEAPI +SymGetSymPrevW( + __in HANDLE hProcess, + __inout PIMAGEHLP_SYMBOLW Symbol + ); +#endif + + +// These values should not be used. +// They have been replaced by SYMFLAG_ values. + +#define SYMF_OMAP_GENERATED 0x00000001 +#define SYMF_OMAP_MODIFIED 0x00000002 +#define SYMF_REGISTER 0x00000008 +#define SYMF_REGREL 0x00000010 +#define SYMF_FRAMEREL 0x00000020 +#define SYMF_PARAMETER 0x00000040 +#define SYMF_LOCAL 0x00000080 +#define SYMF_CONSTANT 0x00000100 +#define SYMF_EXPORT 0x00000200 +#define SYMF_FORWARDER 0x00000400 +#define SYMF_FUNCTION 0x00000800 +#define SYMF_VIRTUAL 0x00001000 +#define SYMF_THUNK 0x00002000 +#define SYMF_TLSREL 0x00004000 + +// These values should also not be used. +// They have been replaced by SYMFLAG_ values. + +#define IMAGEHLP_SYMBOL_INFO_VALUEPRESENT 1 +#define IMAGEHLP_SYMBOL_INFO_REGISTER SYMF_REGISTER // 0x0008 +#define IMAGEHLP_SYMBOL_INFO_REGRELATIVE SYMF_REGREL // 0x0010 +#define IMAGEHLP_SYMBOL_INFO_FRAMERELATIVE SYMF_FRAMEREL // 0x0020 +#define IMAGEHLP_SYMBOL_INFO_PARAMETER SYMF_PARAMETER // 0x0040 +#define IMAGEHLP_SYMBOL_INFO_LOCAL SYMF_LOCAL // 0x0080 +#define IMAGEHLP_SYMBOL_INFO_CONSTANT SYMF_CONSTANT // 0x0100 +#define IMAGEHLP_SYMBOL_FUNCTION SYMF_FUNCTION // 0x0800 +#define IMAGEHLP_SYMBOL_VIRTUAL SYMF_VIRTUAL // 0x1000 +#define IMAGEHLP_SYMBOL_THUNK SYMF_THUNK // 0x2000 +#define IMAGEHLP_SYMBOL_INFO_TLSRELATIVE SYMF_TLSREL // 0x4000 + + +#include + +#if defined(_MSC_VER) +#if _MSC_VER >= 800 +#if _MSC_VER >= 1200 +#pragma warning(push) +#endif +#pragma warning(disable:4200) /* Zero length array */ +#pragma warning(disable:4201) /* Nameless struct/union */ +#endif +#endif + +#define MINIDUMP_SIGNATURE ('PMDM') +#define MINIDUMP_VERSION (42899) +typedef DWORD RVA; +typedef ULONG64 RVA64; + +typedef struct _MINIDUMP_LOCATION_DESCRIPTOR { + ULONG32 DataSize; + RVA Rva; +} MINIDUMP_LOCATION_DESCRIPTOR; + +typedef struct _MINIDUMP_LOCATION_DESCRIPTOR64 { + ULONG64 DataSize; + RVA64 Rva; +} MINIDUMP_LOCATION_DESCRIPTOR64; + + +typedef struct _MINIDUMP_MEMORY_DESCRIPTOR { + ULONG64 StartOfMemoryRange; + MINIDUMP_LOCATION_DESCRIPTOR Memory; +} MINIDUMP_MEMORY_DESCRIPTOR, *PMINIDUMP_MEMORY_DESCRIPTOR; + +// DESCRIPTOR64 is used for full-memory minidumps where +// all of the raw memory is laid out sequentially at the +// end of the dump. There is no need for individual RVAs +// as the RVA is the base RVA plus the sum of the preceeding +// data blocks. +typedef struct _MINIDUMP_MEMORY_DESCRIPTOR64 { + ULONG64 StartOfMemoryRange; + ULONG64 DataSize; +} MINIDUMP_MEMORY_DESCRIPTOR64, *PMINIDUMP_MEMORY_DESCRIPTOR64; + + +typedef struct _MINIDUMP_HEADER { + ULONG32 Signature; + ULONG32 Version; + ULONG32 NumberOfStreams; + RVA StreamDirectoryRva; + ULONG32 CheckSum; + union { + ULONG32 Reserved; + ULONG32 TimeDateStamp; + }; + ULONG64 Flags; +} MINIDUMP_HEADER, *PMINIDUMP_HEADER; + +// +// The MINIDUMP_HEADER field StreamDirectoryRva points to +// an array of MINIDUMP_DIRECTORY structures. +// + +typedef struct _MINIDUMP_DIRECTORY { + ULONG32 StreamType; + MINIDUMP_LOCATION_DESCRIPTOR Location; +} MINIDUMP_DIRECTORY, *PMINIDUMP_DIRECTORY; + + +typedef struct _MINIDUMP_STRING { + ULONG32 Length; // Length in bytes of the string + WCHAR Buffer [0]; // Variable size buffer +} MINIDUMP_STRING, *PMINIDUMP_STRING; + + + +// +// The MINIDUMP_DIRECTORY field StreamType may be one of the following types. +// Types will be added in the future, so if a program reading the minidump +// header encounters a stream type it does not understand it should ignore +// the data altogether. Any tag above LastReservedStream will not be used by +// the system and is reserved for program-specific information. +// + +typedef enum _MINIDUMP_STREAM_TYPE { + + UnusedStream = 0, + ReservedStream0 = 1, + ReservedStream1 = 2, + ThreadListStream = 3, + ModuleListStream = 4, + MemoryListStream = 5, + ExceptionStream = 6, + SystemInfoStream = 7, + ThreadExListStream = 8, + Memory64ListStream = 9, + CommentStreamA = 10, + CommentStreamW = 11, + HandleDataStream = 12, + FunctionTableStream = 13, + UnloadedModuleListStream = 14, + MiscInfoStream = 15, + MemoryInfoListStream = 16, + ThreadInfoListStream = 17, + HandleOperationListStream = 18, + + ceStreamNull = 0x8000, + ceStreamSystemInfo = 0x8001, + ceStreamException = 0x8002, + ceStreamModuleList = 0x8003, + ceStreamProcessList = 0x8004, + ceStreamThreadList = 0x8005, + ceStreamThreadContextList = 0x8006, + ceStreamThreadCallStackList = 0x8007, + ceStreamMemoryVirtualList = 0x8008, + ceStreamMemoryPhysicalList = 0x8009, + ceStreamBucketParameters = 0x800A, + + LastReservedStream = 0xffff + +} MINIDUMP_STREAM_TYPE; + + +// +// The minidump system information contains processor and +// Operating System specific information. +// + +// +// CPU information is obtained from one of two places. +// +// 1) On x86 computers, CPU_INFORMATION is obtained from the CPUID +// instruction. You must use the X86 portion of the union for X86 +// computers. +// +// 2) On non-x86 architectures, CPU_INFORMATION is obtained by calling +// IsProcessorFeatureSupported(). +// + +typedef union _CPU_INFORMATION { + + // + // X86 platforms use CPUID function to obtain processor information. + // + + struct { + + // + // CPUID Subfunction 0, register EAX (VendorId [0]), + // EBX (VendorId [1]) and ECX (VendorId [2]). + // + + ULONG32 VendorId [ 3 ]; + + // + // CPUID Subfunction 1, register EAX + // + + ULONG32 VersionInformation; + + // + // CPUID Subfunction 1, register EDX + // + + ULONG32 FeatureInformation; + + + // + // CPUID, Subfunction 80000001, register EBX. This will only + // be obtained if the vendor id is "AuthenticAMD". + // + + ULONG32 AMDExtendedCpuFeatures; + + } X86CpuInfo; + + // + // Non-x86 platforms use processor feature flags. + // + + struct { + + ULONG64 ProcessorFeatures [ 2 ]; + + } OtherCpuInfo; + +} CPU_INFORMATION, *PCPU_INFORMATION; + +typedef struct _MINIDUMP_SYSTEM_INFO { + + // + // ProcessorArchitecture, ProcessorLevel and ProcessorRevision are all + // taken from the SYSTEM_INFO structure obtained by GetSystemInfo( ). + // + + USHORT ProcessorArchitecture; + USHORT ProcessorLevel; + USHORT ProcessorRevision; + + union { + USHORT Reserved0; + struct { + UCHAR NumberOfProcessors; + UCHAR ProductType; + }; + }; + + // + // MajorVersion, MinorVersion, BuildNumber, PlatformId and + // CSDVersion are all taken from the OSVERSIONINFO structure + // returned by GetVersionEx( ). + // + + ULONG32 MajorVersion; + ULONG32 MinorVersion; + ULONG32 BuildNumber; + ULONG32 PlatformId; + + // + // RVA to a CSDVersion string in the string table. + // + + RVA CSDVersionRva; + + union { + ULONG32 Reserved1; + struct { + USHORT SuiteMask; + USHORT Reserved2; + }; + }; + + CPU_INFORMATION Cpu; + +} MINIDUMP_SYSTEM_INFO, *PMINIDUMP_SYSTEM_INFO; + + +// +// The minidump thread contains standard thread +// information plus an RVA to the memory for this +// thread and an RVA to the CONTEXT structure for +// this thread. +// + + +// +// ThreadId must be 4 bytes on all architectures. +// + +C_ASSERT (sizeof ( ((PPROCESS_INFORMATION)0)->dwThreadId ) == 4); + +typedef struct _MINIDUMP_THREAD { + ULONG32 ThreadId; + ULONG32 SuspendCount; + ULONG32 PriorityClass; + ULONG32 Priority; + ULONG64 Teb; + MINIDUMP_MEMORY_DESCRIPTOR Stack; + MINIDUMP_LOCATION_DESCRIPTOR ThreadContext; +} MINIDUMP_THREAD, *PMINIDUMP_THREAD; + +// +// The thread list is a container of threads. +// + +typedef struct _MINIDUMP_THREAD_LIST { + ULONG32 NumberOfThreads; + MINIDUMP_THREAD Threads [0]; +} MINIDUMP_THREAD_LIST, *PMINIDUMP_THREAD_LIST; + + +typedef struct _MINIDUMP_THREAD_EX { + ULONG32 ThreadId; + ULONG32 SuspendCount; + ULONG32 PriorityClass; + ULONG32 Priority; + ULONG64 Teb; + MINIDUMP_MEMORY_DESCRIPTOR Stack; + MINIDUMP_LOCATION_DESCRIPTOR ThreadContext; + MINIDUMP_MEMORY_DESCRIPTOR BackingStore; +} MINIDUMP_THREAD_EX, *PMINIDUMP_THREAD_EX; + +// +// The thread list is a container of threads. +// + +typedef struct _MINIDUMP_THREAD_EX_LIST { + ULONG32 NumberOfThreads; + MINIDUMP_THREAD_EX Threads [0]; +} MINIDUMP_THREAD_EX_LIST, *PMINIDUMP_THREAD_EX_LIST; + + +// +// The MINIDUMP_EXCEPTION is the same as EXCEPTION on Win64. +// + +typedef struct _MINIDUMP_EXCEPTION { + ULONG32 ExceptionCode; + ULONG32 ExceptionFlags; + ULONG64 ExceptionRecord; + ULONG64 ExceptionAddress; + ULONG32 NumberParameters; + ULONG32 __unusedAlignment; + ULONG64 ExceptionInformation [ EXCEPTION_MAXIMUM_PARAMETERS ]; +} MINIDUMP_EXCEPTION, *PMINIDUMP_EXCEPTION; + + +// +// The exception information stream contains the id of the thread that caused +// the exception (ThreadId), the exception record for the exception +// (ExceptionRecord) and an RVA to the thread context where the exception +// occured. +// + +typedef struct MINIDUMP_EXCEPTION_STREAM { + ULONG32 ThreadId; + ULONG32 __alignment; + MINIDUMP_EXCEPTION ExceptionRecord; + MINIDUMP_LOCATION_DESCRIPTOR ThreadContext; +} MINIDUMP_EXCEPTION_STREAM, *PMINIDUMP_EXCEPTION_STREAM; + + +// +// The MINIDUMP_MODULE contains information about a +// a specific module. It includes the CheckSum and +// the TimeDateStamp for the module so the module +// can be reloaded during the analysis phase. +// + +typedef struct _MINIDUMP_MODULE { + ULONG64 BaseOfImage; + ULONG32 SizeOfImage; + ULONG32 CheckSum; + ULONG32 TimeDateStamp; + RVA ModuleNameRva; + VS_FIXEDFILEINFO VersionInfo; + MINIDUMP_LOCATION_DESCRIPTOR CvRecord; + MINIDUMP_LOCATION_DESCRIPTOR MiscRecord; + ULONG64 Reserved0; // Reserved for future use. + ULONG64 Reserved1; // Reserved for future use. +} MINIDUMP_MODULE, *PMINIDUMP_MODULE; + + +// +// The minidump module list is a container for modules. +// + +typedef struct _MINIDUMP_MODULE_LIST { + ULONG32 NumberOfModules; + MINIDUMP_MODULE Modules [ 0 ]; +} MINIDUMP_MODULE_LIST, *PMINIDUMP_MODULE_LIST; + + +// +// Memory Ranges +// + +typedef struct _MINIDUMP_MEMORY_LIST { + ULONG32 NumberOfMemoryRanges; + MINIDUMP_MEMORY_DESCRIPTOR MemoryRanges [0]; +} MINIDUMP_MEMORY_LIST, *PMINIDUMP_MEMORY_LIST; + +typedef struct _MINIDUMP_MEMORY64_LIST { + ULONG64 NumberOfMemoryRanges; + RVA64 BaseRva; + MINIDUMP_MEMORY_DESCRIPTOR64 MemoryRanges [0]; +} MINIDUMP_MEMORY64_LIST, *PMINIDUMP_MEMORY64_LIST; + + +// +// Support for user supplied exception information. +// + +typedef struct _MINIDUMP_EXCEPTION_INFORMATION { + DWORD ThreadId; + PEXCEPTION_POINTERS ExceptionPointers; + BOOL ClientPointers; +} MINIDUMP_EXCEPTION_INFORMATION, *PMINIDUMP_EXCEPTION_INFORMATION; + +typedef struct _MINIDUMP_EXCEPTION_INFORMATION64 { + DWORD ThreadId; + ULONG64 ExceptionRecord; + ULONG64 ContextRecord; + BOOL ClientPointers; +} MINIDUMP_EXCEPTION_INFORMATION64, *PMINIDUMP_EXCEPTION_INFORMATION64; + + +// +// Support for capturing system handle state at the time of the dump. +// + +// Per-handle object information varies according to +// the OS, the OS version, the processor type and +// so on. The minidump gives a minidump identifier +// to each possible data format for identification +// purposes but does not control nor describe the actual data. +typedef enum _MINIDUMP_HANDLE_OBJECT_INFORMATION_TYPE { + MiniHandleObjectInformationNone, + MiniThreadInformation1, + MiniMutantInformation1, + MiniMutantInformation2, + MiniProcessInformation1, + MiniProcessInformation2, + MiniHandleObjectInformationTypeMax +} MINIDUMP_HANDLE_OBJECT_INFORMATION_TYPE; + +typedef struct _MINIDUMP_HANDLE_OBJECT_INFORMATION { + RVA NextInfoRva; + ULONG32 InfoType; + ULONG32 SizeOfInfo; + // Raw information follows. +} MINIDUMP_HANDLE_OBJECT_INFORMATION; + +typedef struct _MINIDUMP_HANDLE_DESCRIPTOR { + ULONG64 Handle; + RVA TypeNameRva; + RVA ObjectNameRva; + ULONG32 Attributes; + ULONG32 GrantedAccess; + ULONG32 HandleCount; + ULONG32 PointerCount; +} MINIDUMP_HANDLE_DESCRIPTOR, *PMINIDUMP_HANDLE_DESCRIPTOR; + +typedef struct _MINIDUMP_HANDLE_DESCRIPTOR_2 { + ULONG64 Handle; + RVA TypeNameRva; + RVA ObjectNameRva; + ULONG32 Attributes; + ULONG32 GrantedAccess; + ULONG32 HandleCount; + ULONG32 PointerCount; + RVA ObjectInfoRva; + ULONG32 Reserved0; +} MINIDUMP_HANDLE_DESCRIPTOR_2, *PMINIDUMP_HANDLE_DESCRIPTOR_2; + +// The latest MINIDUMP_HANDLE_DESCRIPTOR definition. +typedef MINIDUMP_HANDLE_DESCRIPTOR_2 MINIDUMP_HANDLE_DESCRIPTOR_N; +typedef MINIDUMP_HANDLE_DESCRIPTOR_N *PMINIDUMP_HANDLE_DESCRIPTOR_N; + +typedef struct _MINIDUMP_HANDLE_DATA_STREAM { + ULONG32 SizeOfHeader; + ULONG32 SizeOfDescriptor; + ULONG32 NumberOfDescriptors; + ULONG32 Reserved; +} MINIDUMP_HANDLE_DATA_STREAM, *PMINIDUMP_HANDLE_DATA_STREAM; + +// Some operating systems can track the last operations +// performed on a handle. For example, Application Verifier +// can enable this for some versions of Windows. The +// handle operation list collects handle operations +// known for the dump target. +// Each entry is an AVRF_HANDLE_OPERATION. +typedef struct _MINIDUMP_HANDLE_OPERATION_LIST { + ULONG32 SizeOfHeader; + ULONG32 SizeOfEntry; + ULONG32 NumberOfEntries; + ULONG32 Reserved; +} MINIDUMP_HANDLE_OPERATION_LIST, *PMINIDUMP_HANDLE_OPERATION_LIST; + + +// +// Support for capturing dynamic function table state at the time of the dump. +// + +typedef struct _MINIDUMP_FUNCTION_TABLE_DESCRIPTOR { + ULONG64 MinimumAddress; + ULONG64 MaximumAddress; + ULONG64 BaseAddress; + ULONG32 EntryCount; + ULONG32 SizeOfAlignPad; +} MINIDUMP_FUNCTION_TABLE_DESCRIPTOR, *PMINIDUMP_FUNCTION_TABLE_DESCRIPTOR; + +typedef struct _MINIDUMP_FUNCTION_TABLE_STREAM { + ULONG32 SizeOfHeader; + ULONG32 SizeOfDescriptor; + ULONG32 SizeOfNativeDescriptor; + ULONG32 SizeOfFunctionEntry; + ULONG32 NumberOfDescriptors; + ULONG32 SizeOfAlignPad; +} MINIDUMP_FUNCTION_TABLE_STREAM, *PMINIDUMP_FUNCTION_TABLE_STREAM; + + +// +// The MINIDUMP_UNLOADED_MODULE contains information about a +// a specific module that was previously loaded but no +// longer is. This can help with diagnosing problems where +// callers attempt to call code that is no longer loaded. +// + +typedef struct _MINIDUMP_UNLOADED_MODULE { + ULONG64 BaseOfImage; + ULONG32 SizeOfImage; + ULONG32 CheckSum; + ULONG32 TimeDateStamp; + RVA ModuleNameRva; +} MINIDUMP_UNLOADED_MODULE, *PMINIDUMP_UNLOADED_MODULE; + + +// +// The minidump unloaded module list is a container for unloaded modules. +// + +typedef struct _MINIDUMP_UNLOADED_MODULE_LIST { + ULONG32 SizeOfHeader; + ULONG32 SizeOfEntry; + ULONG32 NumberOfEntries; +} MINIDUMP_UNLOADED_MODULE_LIST, *PMINIDUMP_UNLOADED_MODULE_LIST; + + +// +// The miscellaneous information stream contains a variety +// of small pieces of information. A member is valid if +// it's within the available size and its corresponding +// bit is set. +// + +#define MINIDUMP_MISC1_PROCESS_ID 0x00000001 +#define MINIDUMP_MISC1_PROCESS_TIMES 0x00000002 +#define MINIDUMP_MISC1_PROCESSOR_POWER_INFO 0x00000004 + +typedef struct _MINIDUMP_MISC_INFO { + ULONG32 SizeOfInfo; + ULONG32 Flags1; + ULONG32 ProcessId; + ULONG32 ProcessCreateTime; + ULONG32 ProcessUserTime; + ULONG32 ProcessKernelTime; +} MINIDUMP_MISC_INFO, *PMINIDUMP_MISC_INFO; + +typedef struct _MINIDUMP_MISC_INFO_2 { + ULONG32 SizeOfInfo; + ULONG32 Flags1; + ULONG32 ProcessId; + ULONG32 ProcessCreateTime; + ULONG32 ProcessUserTime; + ULONG32 ProcessKernelTime; + ULONG32 ProcessorMaxMhz; + ULONG32 ProcessorCurrentMhz; + ULONG32 ProcessorMhzLimit; + ULONG32 ProcessorMaxIdleState; + ULONG32 ProcessorCurrentIdleState; +} MINIDUMP_MISC_INFO_2, *PMINIDUMP_MISC_INFO_2; + +// The latest MINIDUMP_MISC_INFO definition. +typedef MINIDUMP_MISC_INFO_2 MINIDUMP_MISC_INFO_N; +typedef MINIDUMP_MISC_INFO_N* PMINIDUMP_MISC_INFO_N; + + +// +// The memory information stream contains memory region +// description information. This stream corresponds to +// what VirtualQuery would return for the process the +// dump was created for. +// + +typedef struct _MINIDUMP_MEMORY_INFO { + ULONG64 BaseAddress; + ULONG64 AllocationBase; + ULONG32 AllocationProtect; + ULONG32 __alignment1; + ULONG64 RegionSize; + ULONG32 State; + ULONG32 Protect; + ULONG32 Type; + ULONG32 __alignment2; +} MINIDUMP_MEMORY_INFO, *PMINIDUMP_MEMORY_INFO; + +typedef struct _MINIDUMP_MEMORY_INFO_LIST { + ULONG SizeOfHeader; + ULONG SizeOfEntry; + ULONG64 NumberOfEntries; +} MINIDUMP_MEMORY_INFO_LIST, *PMINIDUMP_MEMORY_INFO_LIST; + + +// +// The memory information stream contains memory region +// description information. This stream corresponds to +// what VirtualQuery would return for the process the +// dump was created for. +// + +// Thread dump writer status flags. +#define MINIDUMP_THREAD_INFO_ERROR_THREAD 0x00000001 +#define MINIDUMP_THREAD_INFO_WRITING_THREAD 0x00000002 +#define MINIDUMP_THREAD_INFO_EXITED_THREAD 0x00000004 +#define MINIDUMP_THREAD_INFO_INVALID_INFO 0x00000008 +#define MINIDUMP_THREAD_INFO_INVALID_CONTEXT 0x00000010 +#define MINIDUMP_THREAD_INFO_INVALID_TEB 0x00000020 + +typedef struct _MINIDUMP_THREAD_INFO { + ULONG32 ThreadId; + ULONG32 DumpFlags; + ULONG32 DumpError; + ULONG32 ExitStatus; + ULONG64 CreateTime; + ULONG64 ExitTime; + ULONG64 KernelTime; + ULONG64 UserTime; + ULONG64 StartAddress; + ULONG64 Affinity; +} MINIDUMP_THREAD_INFO, *PMINIDUMP_THREAD_INFO; + +typedef struct _MINIDUMP_THREAD_INFO_LIST { + ULONG SizeOfHeader; + ULONG SizeOfEntry; + ULONG NumberOfEntries; +} MINIDUMP_THREAD_INFO_LIST, *PMINIDUMP_THREAD_INFO_LIST; + + +// +// Support for arbitrary user-defined information. +// + +typedef struct _MINIDUMP_USER_RECORD { + ULONG32 Type; + MINIDUMP_LOCATION_DESCRIPTOR Memory; +} MINIDUMP_USER_RECORD, *PMINIDUMP_USER_RECORD; + + +typedef struct _MINIDUMP_USER_STREAM { + ULONG32 Type; + ULONG BufferSize; + PVOID Buffer; + +} MINIDUMP_USER_STREAM, *PMINIDUMP_USER_STREAM; + + +typedef struct _MINIDUMP_USER_STREAM_INFORMATION { + ULONG UserStreamCount; + PMINIDUMP_USER_STREAM UserStreamArray; +} MINIDUMP_USER_STREAM_INFORMATION, *PMINIDUMP_USER_STREAM_INFORMATION; + +// +// Callback support. +// + +typedef enum _MINIDUMP_CALLBACK_TYPE { + ModuleCallback, + ThreadCallback, + ThreadExCallback, + IncludeThreadCallback, + IncludeModuleCallback, + MemoryCallback, + CancelCallback, + WriteKernelMinidumpCallback, + KernelMinidumpStatusCallback, + RemoveMemoryCallback, + IncludeVmRegionCallback, + IoStartCallback, + IoWriteAllCallback, + IoFinishCallback, + ReadMemoryFailureCallback, + SecondaryFlagsCallback, +} MINIDUMP_CALLBACK_TYPE; + + +typedef struct _MINIDUMP_THREAD_CALLBACK { + ULONG ThreadId; + HANDLE ThreadHandle; + CONTEXT Context; + ULONG SizeOfContext; + ULONG64 StackBase; + ULONG64 StackEnd; +} MINIDUMP_THREAD_CALLBACK, *PMINIDUMP_THREAD_CALLBACK; + + +typedef struct _MINIDUMP_THREAD_EX_CALLBACK { + ULONG ThreadId; + HANDLE ThreadHandle; + CONTEXT Context; + ULONG SizeOfContext; + ULONG64 StackBase; + ULONG64 StackEnd; + ULONG64 BackingStoreBase; + ULONG64 BackingStoreEnd; +} MINIDUMP_THREAD_EX_CALLBACK, *PMINIDUMP_THREAD_EX_CALLBACK; + + +typedef struct _MINIDUMP_INCLUDE_THREAD_CALLBACK { + ULONG ThreadId; +} MINIDUMP_INCLUDE_THREAD_CALLBACK, *PMINIDUMP_INCLUDE_THREAD_CALLBACK; + + +typedef enum _THREAD_WRITE_FLAGS { + ThreadWriteThread = 0x0001, + ThreadWriteStack = 0x0002, + ThreadWriteContext = 0x0004, + ThreadWriteBackingStore = 0x0008, + ThreadWriteInstructionWindow = 0x0010, + ThreadWriteThreadData = 0x0020, + ThreadWriteThreadInfo = 0x0040, +} THREAD_WRITE_FLAGS; + +typedef struct _MINIDUMP_MODULE_CALLBACK { + PWCHAR FullPath; + ULONG64 BaseOfImage; + ULONG SizeOfImage; + ULONG CheckSum; + ULONG TimeDateStamp; + VS_FIXEDFILEINFO VersionInfo; + PVOID CvRecord; + ULONG SizeOfCvRecord; + PVOID MiscRecord; + ULONG SizeOfMiscRecord; +} MINIDUMP_MODULE_CALLBACK, *PMINIDUMP_MODULE_CALLBACK; + + +typedef struct _MINIDUMP_INCLUDE_MODULE_CALLBACK { + ULONG64 BaseOfImage; +} MINIDUMP_INCLUDE_MODULE_CALLBACK, *PMINIDUMP_INCLUDE_MODULE_CALLBACK; + + +typedef enum _MODULE_WRITE_FLAGS { + ModuleWriteModule = 0x0001, + ModuleWriteDataSeg = 0x0002, + ModuleWriteMiscRecord = 0x0004, + ModuleWriteCvRecord = 0x0008, + ModuleReferencedByMemory = 0x0010, + ModuleWriteTlsData = 0x0020, + ModuleWriteCodeSegs = 0x0040, +} MODULE_WRITE_FLAGS; + + +typedef struct _MINIDUMP_IO_CALLBACK { + HANDLE Handle; + ULONG64 Offset; + PVOID Buffer; + ULONG BufferBytes; +} MINIDUMP_IO_CALLBACK, *PMINIDUMP_IO_CALLBACK; + + +typedef struct _MINIDUMP_READ_MEMORY_FAILURE_CALLBACK +{ + ULONG64 Offset; + ULONG Bytes; + HRESULT FailureStatus; +} MINIDUMP_READ_MEMORY_FAILURE_CALLBACK, + *PMINIDUMP_READ_MEMORY_FAILURE_CALLBACK; + + +typedef struct _MINIDUMP_CALLBACK_INPUT { + ULONG ProcessId; + HANDLE ProcessHandle; + ULONG CallbackType; + union { + HRESULT Status; + MINIDUMP_THREAD_CALLBACK Thread; + MINIDUMP_THREAD_EX_CALLBACK ThreadEx; + MINIDUMP_MODULE_CALLBACK Module; + MINIDUMP_INCLUDE_THREAD_CALLBACK IncludeThread; + MINIDUMP_INCLUDE_MODULE_CALLBACK IncludeModule; + MINIDUMP_IO_CALLBACK Io; + MINIDUMP_READ_MEMORY_FAILURE_CALLBACK ReadMemoryFailure; + ULONG SecondaryFlags; + }; +} MINIDUMP_CALLBACK_INPUT, *PMINIDUMP_CALLBACK_INPUT; + +typedef struct _MINIDUMP_CALLBACK_OUTPUT { + union { + ULONG ModuleWriteFlags; + ULONG ThreadWriteFlags; + ULONG SecondaryFlags; + struct { + ULONG64 MemoryBase; + ULONG MemorySize; + }; + struct { + BOOL CheckCancel; + BOOL Cancel; + }; + HANDLE Handle; + struct { + MINIDUMP_MEMORY_INFO VmRegion; + BOOL Continue; + }; + HRESULT Status; + }; +} MINIDUMP_CALLBACK_OUTPUT, *PMINIDUMP_CALLBACK_OUTPUT; + + +// +// A normal minidump contains just the information +// necessary to capture stack traces for all of the +// existing threads in a process. +// +// A minidump with data segments includes all of the data +// sections from loaded modules in order to capture +// global variable contents. This can make the dump much +// larger if many modules have global data. +// +// A minidump with full memory includes all of the accessible +// memory in the process and can be very large. A minidump +// with full memory always has the raw memory data at the end +// of the dump so that the initial structures in the dump can +// be mapped directly without having to include the raw +// memory information. +// +// Stack and backing store memory can be filtered to remove +// data unnecessary for stack walking. This can improve +// compression of stacks and also deletes data that may +// be private and should not be stored in a dump. +// Memory can also be scanned to see what modules are +// referenced by stack and backing store memory to allow +// omission of other modules to reduce dump size. +// In either of these modes the ModuleReferencedByMemory flag +// is set for all modules referenced before the base +// module callbacks occur. +// +// On some operating systems a list of modules that were +// recently unloaded is kept in addition to the currently +// loaded module list. This information can be saved in +// the dump if desired. +// +// Stack and backing store memory can be scanned for referenced +// pages in order to pick up data referenced by locals or other +// stack memory. This can increase the size of a dump significantly. +// +// Module paths may contain undesired information such as user names +// or other important directory names so they can be stripped. This +// option reduces the ability to locate the proper image later +// and should only be used in certain situations. +// +// Complete operating system per-process and per-thread information can +// be gathered and stored in the dump. +// +// The virtual address space can be scanned for various types +// of memory to be included in the dump. +// +// Code which is concerned with potentially private information +// getting into the minidump can set a flag that automatically +// modifies all existing and future flags to avoid placing +// unnecessary data in the dump. Basic data, such as stack +// information, will still be included but optional data, such +// as indirect memory, will not. +// +// When doing a full memory dump it's possible to store all +// of the enumerated memory region descriptive information +// in a memory information stream. +// +// Additional thread information beyond the basic thread +// structure can be collected if desired. +// +// A minidump with code segments includes all of the code +// and code-related sections from loaded modules in order +// to capture executable content. +// +// MiniDumpWithoutAuxiliaryState turns off any secondary, +// auxiliary-supported memory gathering. +// +// MiniDumpWithFullAuxiliaryState asks any present auxiliary +// data providers to include all of their state in the dump. +// The exact set of what is provided depends on the auxiliary. +// This can be quite large. +// + +typedef enum _MINIDUMP_TYPE { + MiniDumpNormal = 0x00000000, + MiniDumpWithDataSegs = 0x00000001, + MiniDumpWithFullMemory = 0x00000002, + MiniDumpWithHandleData = 0x00000004, + MiniDumpFilterMemory = 0x00000008, + MiniDumpScanMemory = 0x00000010, + MiniDumpWithUnloadedModules = 0x00000020, + MiniDumpWithIndirectlyReferencedMemory = 0x00000040, + MiniDumpFilterModulePaths = 0x00000080, + MiniDumpWithProcessThreadData = 0x00000100, + MiniDumpWithPrivateReadWriteMemory = 0x00000200, + MiniDumpWithoutOptionalData = 0x00000400, + MiniDumpWithFullMemoryInfo = 0x00000800, + MiniDumpWithThreadInfo = 0x00001000, + MiniDumpWithCodeSegs = 0x00002000, + MiniDumpWithoutAuxiliaryState = 0x00004000, + MiniDumpWithFullAuxiliaryState = 0x00008000, + + MiniDumpValidTypeFlags = 0x0000ffff, +} MINIDUMP_TYPE; + +// +// In addition to the primary flags provided to +// MiniDumpWriteDump there are additional, less +// frequently used options queried via the secondary +// flags callback. +// +// MiniSecondaryWithoutPowerInfo suppresses the minidump +// query that retrieves processor power information for +// MINIDUMP_MISC_INFO. +// + +typedef enum _MINIDUMP_SECONDARY_FLAGS { + MiniSecondaryWithoutPowerInfo = 0x00000001, + + MiniSecondaryValidFlags = 0x00000001, +} MINIDUMP_SECONDARY_FLAGS; + + +// +// The minidump callback should modify the FieldsToWrite parameter to reflect +// what portions of the specified thread or module should be written to the +// file. +// + +typedef +BOOL +(WINAPI * MINIDUMP_CALLBACK_ROUTINE) ( + IN PVOID CallbackParam, + IN CONST PMINIDUMP_CALLBACK_INPUT CallbackInput, + IN OUT PMINIDUMP_CALLBACK_OUTPUT CallbackOutput + ); + +typedef struct _MINIDUMP_CALLBACK_INFORMATION { + MINIDUMP_CALLBACK_ROUTINE CallbackRoutine; + PVOID CallbackParam; +} MINIDUMP_CALLBACK_INFORMATION, *PMINIDUMP_CALLBACK_INFORMATION; + + + +//++ +// +// PVOID +// RVA_TO_ADDR( +// PVOID Mapping, +// ULONG Rva +// ) +// +// Routine Description: +// +// Map an RVA that is contained within a mapped file to it's associated +// flat address. +// +// Arguments: +// +// Mapping - Base address of mapped file containing the RVA. +// +// Rva - An Rva to fixup. +// +// Return Values: +// +// A pointer to the desired data. +// +//-- + +#define RVA_TO_ADDR(Mapping,Rva) ((PVOID)(((ULONG_PTR) (Mapping)) + (Rva))) + +BOOL +WINAPI +MiniDumpWriteDump( + IN HANDLE hProcess, + IN DWORD ProcessId, + IN HANDLE hFile, + IN MINIDUMP_TYPE DumpType, + IN CONST PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam, OPTIONAL + IN CONST PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam, OPTIONAL + IN CONST PMINIDUMP_CALLBACK_INFORMATION CallbackParam OPTIONAL + ); + +BOOL +WINAPI +MiniDumpReadDumpStream( + IN PVOID BaseOfDump, + IN ULONG StreamNumber, + OUT PMINIDUMP_DIRECTORY * Dir, OPTIONAL + OUT PVOID * StreamPointer, OPTIONAL + OUT ULONG * StreamSize OPTIONAL + ); + +#if defined(_MSC_VER) +#if _MSC_VER >= 800 +#if _MSC_VER >= 1200 +#pragma warning(pop) +#else +#pragma warning(default:4200) /* Zero length array */ +#pragma warning(default:4201) /* Nameless struct/union */ +#endif +#endif +#endif + +#include + +#ifdef __cplusplus +} +#endif + + +#endif // _DBGHELP_ diff --git a/plugins/CrashDumper/vc6/dbghelp.lib b/plugins/CrashDumper/vc6/dbghelp.lib new file mode 100644 index 0000000000..5d50c3f74d Binary files /dev/null and b/plugins/CrashDumper/vc6/dbghelp.lib differ diff --git a/plugins/CrashDumper/version.h b/plugins/CrashDumper/version.h new file mode 100644 index 0000000000..776e30e404 --- /dev/null +++ b/plugins/CrashDumper/version.h @@ -0,0 +1,3 @@ +#define __FILEVERSION_STRING 0,0,4,21 +#define __VERSION_STRING "0.0.4.21" +#define __VERSION_DWORD PLUGIN_MAKE_VERSION(0, 0, 4, 21) diff --git a/plugins/DbeditorPP/Res/Contacts.ico b/plugins/DbeditorPP/Res/Contacts.ico new file mode 100644 index 0000000000..f3de15b54b Binary files /dev/null and b/plugins/DbeditorPP/Res/Contacts.ico differ diff --git a/plugins/DbeditorPP/Res/Icon_1.ico b/plugins/DbeditorPP/Res/Icon_1.ico new file mode 100644 index 0000000000..a99fe06619 Binary files /dev/null and b/plugins/DbeditorPP/Res/Icon_1.ico differ diff --git a/plugins/DbeditorPP/Res/Icon_14.ico b/plugins/DbeditorPP/Res/Icon_14.ico new file mode 100644 index 0000000000..d14e4a1f96 Binary files /dev/null and b/plugins/DbeditorPP/Res/Icon_14.ico differ diff --git a/plugins/DbeditorPP/Res/Icon_15.ico b/plugins/DbeditorPP/Res/Icon_15.ico new file mode 100644 index 0000000000..343fd1aaf0 Binary files /dev/null and b/plugins/DbeditorPP/Res/Icon_15.ico differ diff --git a/plugins/DbeditorPP/Res/Icon_16.ico b/plugins/DbeditorPP/Res/Icon_16.ico new file mode 100644 index 0000000000..6cd2cd8e58 Binary files /dev/null and b/plugins/DbeditorPP/Res/Icon_16.ico differ diff --git a/plugins/DbeditorPP/Res/Icon_17.ico b/plugins/DbeditorPP/Res/Icon_17.ico new file mode 100644 index 0000000000..e11509e6cb Binary files /dev/null and b/plugins/DbeditorPP/Res/Icon_17.ico differ diff --git a/plugins/DbeditorPP/Res/Icon_18.ico b/plugins/DbeditorPP/Res/Icon_18.ico new file mode 100644 index 0000000000..e25d704f71 Binary files /dev/null and b/plugins/DbeditorPP/Res/Icon_18.ico differ diff --git a/plugins/DbeditorPP/Res/Icon_4.ico b/plugins/DbeditorPP/Res/Icon_4.ico new file mode 100644 index 0000000000..cac9a01f7e Binary files /dev/null and b/plugins/DbeditorPP/Res/Icon_4.ico differ diff --git a/plugins/DbeditorPP/Res/Red.ico b/plugins/DbeditorPP/Res/Red.ico new file mode 100644 index 0000000000..f6431fc7c1 Binary files /dev/null and b/plugins/DbeditorPP/Res/Red.ico differ diff --git a/plugins/DbeditorPP/Res/Red_open.ico b/plugins/DbeditorPP/Res/Red_open.ico new file mode 100644 index 0000000000..1aa476a9d6 Binary files /dev/null and b/plugins/DbeditorPP/Res/Red_open.ico differ diff --git a/plugins/DbeditorPP/Res/UserMenu.ico b/plugins/DbeditorPP/Res/UserMenu.ico new file mode 100644 index 0000000000..acc2af901c Binary files /dev/null and b/plugins/DbeditorPP/Res/UserMenu.ico differ diff --git a/plugins/DbeditorPP/Res/Yellow.ico b/plugins/DbeditorPP/Res/Yellow.ico new file mode 100644 index 0000000000..378bdb3909 Binary files /dev/null and b/plugins/DbeditorPP/Res/Yellow.ico differ diff --git a/plugins/DbeditorPP/Res/Yellow_open.ico b/plugins/DbeditorPP/Res/Yellow_open.ico new file mode 100644 index 0000000000..df3ae478c2 Binary files /dev/null and b/plugins/DbeditorPP/Res/Yellow_open.ico differ diff --git a/plugins/DbeditorPP/Res/dbepp.ico b/plugins/DbeditorPP/Res/dbepp.ico new file mode 100644 index 0000000000..817dba66f4 Binary files /dev/null and b/plugins/DbeditorPP/Res/dbepp.ico differ diff --git a/plugins/DbeditorPP/Res/handle.ico b/plugins/DbeditorPP/Res/handle.ico new file mode 100644 index 0000000000..5a4448f8a7 Binary files /dev/null and b/plugins/DbeditorPP/Res/handle.ico differ diff --git a/plugins/DbeditorPP/Res/handle1.ico b/plugins/DbeditorPP/Res/handle1.ico new file mode 100644 index 0000000000..705cbd3028 Binary files /dev/null and b/plugins/DbeditorPP/Res/handle1.ico differ diff --git a/plugins/DbeditorPP/Res/ico_RegEdit.ico b/plugins/DbeditorPP/Res/ico_RegEdit.ico new file mode 100644 index 0000000000..6d1287ddd2 Binary files /dev/null and b/plugins/DbeditorPP/Res/ico_RegEdit.ico differ diff --git a/plugins/DbeditorPP/Res/offline2.ico b/plugins/DbeditorPP/Res/offline2.ico new file mode 100644 index 0000000000..e31abd9905 Binary files /dev/null and b/plugins/DbeditorPP/Res/offline2.ico differ diff --git a/plugins/DbeditorPP/Res/online2.ico b/plugins/DbeditorPP/Res/online2.ico new file mode 100644 index 0000000000..c30bcee643 Binary files /dev/null and b/plugins/DbeditorPP/Res/online2.ico differ diff --git a/plugins/DbeditorPP/Res/unicode.ico b/plugins/DbeditorPP/Res/unicode.ico new file mode 100644 index 0000000000..c65c3f0875 Binary files /dev/null and b/plugins/DbeditorPP/Res/unicode.ico differ diff --git a/plugins/DbeditorPP/Version.h b/plugins/DbeditorPP/Version.h new file mode 100644 index 0000000000..565dddb582 --- /dev/null +++ b/plugins/DbeditorPP/Version.h @@ -0,0 +1,20 @@ +#define __MAJOR_VERSION 3 +#define __MINOR_VERSION 2 +#define __RELEASE_NUM 0 +#define __BUILD_NUM 0 + +#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM +#define __FILEVERSION_DOTS __MAJOR_VERSION.__MINOR_VERSION.__RELEASE_NUM.__BUILD_NUM + +#define __STRINGIFY_IMPL(x) #x +#define __STRINGIFY(x) __STRINGIFY_IMPL(x) +#define __VERSION_STRING __STRINGIFY(__FILEVERSION_DOTS) + +#define __PLUGIN_NAME "Database Editor++" +#define __INTERNAL_NAME "DBEditor" +#define __FILENAME "Svc_dbepp.dll" +#define __DESCRIPTION "Advanced Database Editor." +#define __AUTHOR "Bio, Jonathan Gordon" +#define __AUTHOREMAIL "bio@msx.ru, jdgordy@gmail.com" +#define __AUTHORWEB "http://addons.miranda-im.org/details.php?action=viewfile&id=2957" +#define __COPYRIGHT "© 2003-2011 Bio, Jonathan Gordon" diff --git a/plugins/DbeditorPP/Version.rc b/plugins/DbeditorPP/Version.rc new file mode 100644 index 0000000000..d1da5e8d6a --- /dev/null +++ b/plugins/DbeditorPP/Version.rc @@ -0,0 +1,42 @@ +// Microsoft Visual C++ generated resource script. +// +#ifdef APSTUDIO_INVOKED +#error this file is not editable by Microsoft Visual C++ +#endif //APSTUDIO_INVOKED + +#include "afxres.h" +#include "version.h" + +#ifdef _WIN32 +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL +#endif //_WIN32 + +VS_VERSION_INFO VERSIONINFO + FILEVERSION __FILEVERSION_STRING + PRODUCTVERSION __FILEVERSION_STRING + FILEFLAGSMASK 0x17L +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x0L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "000004b0" + BEGIN + VALUE "FileDescription", __DESCRIPTION + VALUE "InternalName", __PLUGIN_NAME + VALUE "LegalCopyright", __COPYRIGHT + VALUE "OriginalFilename", __FILENAME + VALUE "ProductName", __PLUGIN_NAME + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0, 1200 + END +END diff --git a/plugins/DbeditorPP/addeditsettingsdlg.cpp b/plugins/DbeditorPP/addeditsettingsdlg.cpp new file mode 100644 index 0000000000..6c21fe498c --- /dev/null +++ b/plugins/DbeditorPP/addeditsettingsdlg.cpp @@ -0,0 +1,458 @@ +#include "headers.h" + + +static BOOL Convert(HANDLE hContact, char* module, char* setting, int value, int toType) // 0 = byte, 1 = word, 2 = dword, 3 = string +{ + int Result = 1; + char temp[64]; + + switch (toType) + { + case 0: + if (value > 0xFF) + Result = 0; + else + DBWriteContactSettingByte(hContact, module, setting, (BYTE)value); + break; + case 1: + if (value > 0xFFFF) + Result = 0; + else + DBWriteContactSettingWord(hContact, module, setting, (WORD)value); + break; + case 2: + DBWriteContactSettingDword(hContact, module, setting, (DWORD)value); + break; + case 3: + DBDeleteContactSetting(hContact, module, setting); + DBWriteContactSettingString(hContact, module, setting, itoa(value,temp,10)); + break; + } + return Result; +} + + +BOOL convertSetting(HANDLE hContact, char* module, char* setting, int toType) // 0 = byte, 1 = word, 2 = dword, 3 = string, 4 = unicode +{ + DBVARIANT dbv = {0}; + BOOL Result = 0; + + if (!GetSetting(hContact, module, setting, &dbv)) + { + switch (dbv.type) + { + case DBVT_BYTE: + Result = Convert(hContact, module, setting, dbv.bVal, toType); + break; + + case DBVT_WORD: + Result = Convert(hContact, module, setting, dbv.wVal, toType); + break; + + case DBVT_DWORD: + Result = Convert(hContact, module, setting, dbv.dVal, toType); + break; + + case DBVT_ASCIIZ: + if (toType == 4) // convert to UNICODE + { + int len = (int)strlen(dbv.pszVal) + 1; + WCHAR *wc = (WCHAR*)_alloca(len*sizeof(WCHAR)); + MultiByteToWideChar(CP_ACP, 0, dbv.pszVal, -1, wc, len); + Result = !DBWriteContactSettingWString(hContact, module, setting, wc); + } + else + if (strlen(dbv.pszVal) < 11 && toType != 3) + { + int val = atoi(dbv.pszVal); + if (val == 0 && dbv.pszVal[0] != '0') + break; + + Result = Convert(hContact, module, setting, val, toType); + } + break; + case DBVT_UTF8: + if (toType == 3 && UOS) // convert to ANSI + { + int len = (int)strlen(dbv.pszVal) + 1; + char *sz = (char*)_alloca(len*3); + WCHAR *wc = (WCHAR*)_alloca(len*sizeof(WCHAR)); + MultiByteToWideChar(CP_UTF8, 0, dbv.pszVal, -1, wc, len); + WideCharToMultiByte(CP_ACP, 0, wc, -1, sz, len, NULL, NULL); + Result = !DBWriteContactSettingString(hContact, module, setting, sz); + } + break; + } + + if (!Result) + msg(Translate("Cannot Convert!"), modFullname); + + DBFreeVariant(&dbv); + } + + return Result; +} + + +int saveAsType(HWND hwnd) +{ + if(IsDlgButtonChecked(hwnd, CHK_BYTE)) + return 0; + else if(IsDlgButtonChecked(hwnd, CHK_WORD)) + return 1; + else if(IsDlgButtonChecked(hwnd, CHK_DWORD)) + return 2; + else if(IsDlgButtonChecked(hwnd, CHK_STRING)) + return 3; + return 3; +} + + +INT_PTR CALLBACK EditSettingDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch(msg) + { + case WM_INITDIALOG: + { + char tmp[32]; + SetWindowLongPtr(hwnd,GWLP_USERDATA,(LPARAM)lParam); + switch (((struct DBsetting*)lParam)->dbv.type) + { + case DBVT_BYTE: + ShowWindow(GetDlgItem(hwnd, IDC_STRING),SW_HIDE); + if (!((struct DBsetting*)lParam)->setting[0]) + { + SetWindowText(hwnd, Translate("New BYTE value")); + } + else + { + SetWindowText(hwnd, Translate("Edit BYTE value")); + SetDlgItemText(hwnd, IDC_SETTINGNAME, ((struct DBsetting*)lParam)->setting); + SetDlgItemText(hwnd, IDC_SETTINGVALUE, itoa(((struct DBsetting*)lParam)->dbv.bVal, tmp, 10)); + } + CheckRadioButton(hwnd, CHK_HEX, CHK_DECIMAL, CHK_DECIMAL); + CheckRadioButton(hwnd, CHK_BYTE, CHK_STRING, CHK_BYTE); + break; + case DBVT_WORD: + ShowWindow(GetDlgItem(hwnd, IDC_STRING),SW_HIDE); + if (!((struct DBsetting*)lParam)->setting[0]) + { + SetWindowText(hwnd, Translate("New WORD value")); + } + else + { + SetWindowText(hwnd, Translate("Edit WORD value")); + SetDlgItemText(hwnd, IDC_SETTINGNAME, ((struct DBsetting*)lParam)->setting); + SetDlgItemText(hwnd, IDC_SETTINGVALUE, itoa(((struct DBsetting*)lParam)->dbv.wVal, tmp, 10)); + } + CheckRadioButton(hwnd, CHK_HEX, CHK_DECIMAL, CHK_DECIMAL); + CheckRadioButton(hwnd, CHK_BYTE, CHK_STRING, CHK_WORD); + break; + case DBVT_DWORD: + ShowWindow(GetDlgItem(hwnd, IDC_STRING),SW_HIDE); + if (!((struct DBsetting*)lParam)->setting[0]) + { + SetWindowText(hwnd, Translate("New DWORD value")); + } + else + { + char text[32]; + SetWindowText(hwnd, Translate("Edit DWORD value")); + SetDlgItemText(hwnd, IDC_SETTINGNAME, ((struct DBsetting*)lParam)->setting); + mir_snprintf(text, SIZEOF(text), "%X", ((struct DBsetting*)lParam)->dbv.dVal); + SetDlgItemText(hwnd, IDC_SETTINGVALUE, text); + } + CheckRadioButton(hwnd, CHK_HEX, CHK_DECIMAL, CHK_HEX); + CheckRadioButton(hwnd, CHK_BYTE, CHK_STRING, CHK_DWORD); + break; + case DBVT_ASCIIZ: + ShowWindow(GetDlgItem(hwnd, IDC_STRING),SW_SHOW); + ShowWindow(GetDlgItem(hwnd, IDC_SETTINGVALUE),SW_HIDE); + ShowWindow(GetDlgItem(hwnd, CHK_HEX),SW_HIDE); + ShowWindow(GetDlgItem(hwnd, CHK_DECIMAL),SW_HIDE); + ShowWindow(GetDlgItem(hwnd, GRP_BASE),SW_HIDE); + ShowWindow(GetDlgItem(hwnd, GRP_TYPE),SW_HIDE); + ShowWindow(GetDlgItem(hwnd, CHK_BYTE),SW_HIDE); + ShowWindow(GetDlgItem(hwnd, CHK_WORD),SW_HIDE); + ShowWindow(GetDlgItem(hwnd, CHK_DWORD),SW_HIDE); + ShowWindow(GetDlgItem(hwnd, CHK_STRING),SW_HIDE); + if (!((struct DBsetting*)lParam)->setting[0]) + { + SetWindowText(hwnd, Translate("New STRING value")); + } + else + { + SetWindowText(hwnd, Translate("Edit STRING value")); + SetDlgItemText(hwnd, IDC_SETTINGNAME, ((struct DBsetting*)lParam)->setting); + SetDlgItemText(hwnd, IDC_STRING, ((struct DBsetting*)lParam)->dbv.pszVal); + } + break; + case DBVT_UTF8: + ShowWindow(GetDlgItem(hwnd, IDC_STRING),SW_SHOW); + ShowWindow(GetDlgItem(hwnd, IDC_SETTINGVALUE),SW_HIDE); + ShowWindow(GetDlgItem(hwnd, CHK_HEX),SW_HIDE); + ShowWindow(GetDlgItem(hwnd, CHK_DECIMAL),SW_HIDE); + ShowWindow(GetDlgItem(hwnd, GRP_BASE),SW_HIDE); + ShowWindow(GetDlgItem(hwnd, GRP_TYPE),SW_HIDE); + ShowWindow(GetDlgItem(hwnd, CHK_BYTE),SW_HIDE); + ShowWindow(GetDlgItem(hwnd, CHK_WORD),SW_HIDE); + ShowWindow(GetDlgItem(hwnd, CHK_DWORD),SW_HIDE); + ShowWindow(GetDlgItem(hwnd, CHK_STRING),SW_HIDE); + if (!((struct DBsetting*)lParam)->setting[0]) + { + SetWindowText(hwnd, Translate("New UNICODE value")); + } + else + { + char *tmp = (((struct DBsetting*)lParam)->dbv.pszVal); + if (UOS) + { + int length = (int)strlen(tmp) + 1; + WCHAR *wc = (WCHAR*)_alloca(length*sizeof(WCHAR)); + MultiByteToWideChar(CP_UTF8, 0, tmp, -1, wc, length); + SendMessageW(GetDlgItem(hwnd, IDC_STRING), WM_SETTEXT, 0, (LPARAM)wc); + } + else { + // convert from UTF8 + SetDlgItemText(hwnd, IDC_STRING, tmp); + } + SetWindowText(hwnd, Translate("Edit UNICODE value")); + SetDlgItemText(hwnd, IDC_SETTINGNAME, ((struct DBsetting*)lParam)->setting); + } + break; + case DBVT_BLOB: + { + ShowWindow(GetDlgItem(hwnd, IDC_STRING),SW_HIDE); + ShowWindow(GetDlgItem(hwnd, IDC_SETTINGVALUE),SW_HIDE); + ShowWindow(GetDlgItem(hwnd, IDC_BLOB),SW_SHOW); + + if (!((struct DBsetting*)lParam)->setting[0]) + { + SetWindowText(hwnd, Translate("New BLOB value")); + } + else + { + int j; + char tmp[16]; + int len = ((struct DBsetting*)lParam)->dbv.cpbVal; + char *data = (char*)_alloca(3*(len+1)+10); + BYTE *p = ((struct DBsetting*)lParam)->dbv.pbVal; + + if (!data) return TRUE; + data[0] = '\0'; + + for(j=0; jsetting); + SetDlgItemText(hwnd, IDC_BLOB, data); + } + ShowWindow(GetDlgItem(hwnd, CHK_HEX),SW_HIDE); + ShowWindow(GetDlgItem(hwnd, CHK_DECIMAL),SW_HIDE); + ShowWindow(GetDlgItem(hwnd, GRP_BASE),SW_HIDE); + ShowWindow(GetDlgItem(hwnd, GRP_TYPE),SW_HIDE); + ShowWindow(GetDlgItem(hwnd, CHK_BYTE),SW_HIDE); + ShowWindow(GetDlgItem(hwnd, CHK_WORD),SW_HIDE); + ShowWindow(GetDlgItem(hwnd, CHK_DWORD),SW_HIDE); + ShowWindow(GetDlgItem(hwnd, CHK_STRING),SW_HIDE); + } + break; + default: return TRUE; + } + TranslateDialogDefault(hwnd); + } + return TRUE; + case WM_COMMAND: + switch(LOWORD(wParam)) + { + case CHK_BYTE: + case CHK_WORD: + case CHK_DWORD: + EnableWindow(GetDlgItem(hwnd, CHK_HEX),1); + EnableWindow(GetDlgItem(hwnd, CHK_DECIMAL),1); + CheckRadioButton(hwnd, CHK_BYTE, CHK_STRING, LOWORD(wParam)); + break; + case CHK_STRING: + EnableWindow(GetDlgItem(hwnd, CHK_HEX),0); + EnableWindow(GetDlgItem(hwnd, CHK_DECIMAL),0); + CheckRadioButton(hwnd, CHK_BYTE, CHK_STRING, LOWORD(wParam)); + break; + + case CHK_HEX: + case CHK_DECIMAL: + CheckRadioButton(hwnd,CHK_HEX, CHK_DECIMAL, LOWORD(wParam)); + { + char *setting, temp[32]; + int settingLength, tmp; + settingLength = GetWindowTextLength(GetDlgItem(hwnd, IDC_SETTINGVALUE)); + if (settingLength) + { + setting = (char*)_alloca(settingLength + 1); + if (setting) + { + // havta convert it with sprintf() + GetWindowText(GetDlgItem(hwnd, IDC_SETTINGVALUE), setting, settingLength+1); + if (LOWORD(wParam) == CHK_DECIMAL && IsDlgButtonChecked(hwnd, CHK_DECIMAL)) + { + sscanf(setting, "%X", &tmp); + mir_snprintf(temp, SIZEOF(temp), "%ld", tmp); + } + else + { + sscanf(setting, "%d", &tmp); + mir_snprintf(temp, SIZEOF(temp), "%X", tmp); + } + SetWindowText(GetDlgItem(hwnd, IDC_SETTINGVALUE), temp); + } + } + } + break; + case IDOK: + { + struct DBsetting *dbsetting = (struct DBsetting*)GetWindowLongPtr(hwnd,GWLP_USERDATA); + char *setting, *value; + int settingLength, valueLength, valueID = IDC_SETTINGVALUE; + settingLength = GetWindowTextLength(GetDlgItem(hwnd, IDC_SETTINGNAME)); + + if (IsWindowVisible(GetDlgItem(hwnd,IDC_STRING))) + valueID = IDC_STRING; + else + if (IsWindowVisible(GetDlgItem(hwnd,IDC_SETTINGVALUE))) + valueID = IDC_SETTINGVALUE; + else + if (IsWindowVisible(GetDlgItem(hwnd,IDC_BLOB))) + valueID = IDC_BLOB; + else + break; + + valueLength = GetWindowTextLength(GetDlgItem(hwnd, valueID)); + + if (dbsetting->dbv.type == DBVT_UTF8 && UOS) + valueLength *= sizeof(WCHAR); + + if (settingLength) + { + int settingValue; + setting = (char*)_alloca(settingLength + 1); + + if (valueLength) + value = (char*)_alloca(valueLength + 2); + else + value = (char*)_alloca(2); + + if (!setting || !value) + { + msg(Translate("Couldnt allocate enough memory!"), modFullname); + DestroyWindow(hwnd); + break; + } + + GetWindowText(GetDlgItem(hwnd, IDC_SETTINGNAME), setting, settingLength+1); + + if (valueLength) + { + if (dbsetting->dbv.type == DBVT_UTF8 && UOS) + SendMessageW(GetDlgItem(hwnd, valueID), WM_GETTEXT, valueLength+2, (LPARAM)value); + else + GetWindowText(GetDlgItem(hwnd, valueID), value, valueLength+1); + } + else + if (IsWindowVisible(GetDlgItem(hwnd,IDC_STRING)) || (saveAsType(hwnd)==3)) + memcpy(value,"\0\0",2); + else + strcpy(value,"0"); + + // delete the old setting + if (mir_strcmp(setting, dbsetting->setting) && dbsetting->setting && (dbsetting->setting)[0] != 0) + DBDeleteContactSetting(dbsetting->hContact, dbsetting->module, dbsetting->setting); + + // delete the setting if we are saving as a different type + switch (dbsetting->dbv.type) + { + case DBVT_BYTE: + if (saveAsType(hwnd) != 0) DBDeleteContactSetting(dbsetting->hContact, dbsetting->module, setting); + break; + case DBVT_WORD: + if (saveAsType(hwnd) != 1) DBDeleteContactSetting(dbsetting->hContact, dbsetting->module, setting); + break; + case DBVT_DWORD: + if (saveAsType(hwnd) != 2) DBDeleteContactSetting(dbsetting->hContact, dbsetting->module, setting); + break; + //case DBVT_ASCIIZ: + //DBWriteContactSettingString(dbsetting->hContact, dbsetting->module, setting, value); + //break; + } + // write the setting + switch (saveAsType(hwnd)) + { + case 0: + if (IsDlgButtonChecked(hwnd, CHK_HEX)) sscanf(value, "%x", &settingValue); + else sscanf(value, "%d", &settingValue); + DBWriteContactSettingByte(dbsetting->hContact, dbsetting->module, setting, (BYTE)settingValue); + break; + case 1: + if (IsDlgButtonChecked(hwnd, CHK_HEX)) sscanf(value, "%x", &settingValue); + else sscanf(value, "%d", &settingValue); + DBWriteContactSettingWord(dbsetting->hContact, dbsetting->module, setting, (WORD)settingValue); + break; + case 2: + if (IsDlgButtonChecked(hwnd, CHK_HEX)) sscanf(value, "%x", &settingValue); + else sscanf(value, "%d", &settingValue); + DBWriteContactSettingDword(dbsetting->hContact, dbsetting->module, setting, (DWORD)settingValue); + break; + case 3: + if (dbsetting->dbv.type == DBVT_UTF8) + { + if (UOS) + DBWriteContactSettingWString(dbsetting->hContact, dbsetting->module, setting, (WCHAR*)value); + else + DBWriteContactSettingStringUtf(dbsetting->hContact, dbsetting->module, setting, value); + } + else + if (dbsetting->dbv.type == DBVT_BLOB) + WriteBlobFromString(dbsetting->hContact,dbsetting->module,setting,value,valueLength); + else + if (dbsetting->dbv.type == DBVT_ASCIIZ) + DBWriteContactSettingString(dbsetting->hContact, dbsetting->module, setting, value); + break; + } + + } + } // fall through + case IDCANCEL: + { + struct DBsetting *dbsetting = (struct DBsetting*)GetWindowLongPtr(hwnd,GWLP_USERDATA); + mir_free(dbsetting->module); + mir_free(dbsetting->setting); + mir_free(dbsetting); + DestroyWindow(hwnd); + } + break; + } + break; + } + return 0; +} + +void editSetting(HANDLE hContact, char* module, char* setting) +{ + DBVARIANT dbv = {0}; // freed in the dialog + if (!GetSetting(hContact,module, setting, &dbv)) + { + struct DBsetting *dbsetting = (struct DBsetting *)mir_alloc(sizeof(struct DBsetting)); // gets free()ed in the window proc + + dbsetting->dbv = dbv; // freed in the dialog + dbsetting->hContact = hContact; + dbsetting->module = mir_tstrdup(module); + dbsetting->setting = mir_tstrdup(setting); + + if (dbv.type == DBVT_UTF8 && UOS) + CreateDialogParamW(hInst, MAKEINTRESOURCEW(IDD_EDIT_SETTING), hwnd2mainWindow, EditSettingDlgProc, (LPARAM)dbsetting); + else + CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_EDIT_SETTING), hwnd2mainWindow, EditSettingDlgProc, (LPARAM)dbsetting); + } +} \ No newline at end of file diff --git a/plugins/DbeditorPP/copymodule.cpp b/plugins/DbeditorPP/copymodule.cpp new file mode 100644 index 0000000000..25489a7f52 --- /dev/null +++ b/plugins/DbeditorPP/copymodule.cpp @@ -0,0 +1,197 @@ +#include "headers.h" + +void copyModule(char* module, HANDLE hContactFrom, HANDLE hContactTo) +{ + ModuleSettingLL msll; + struct ModSetLinkLinkItem *setting; + + EnumSettings(hContactFrom,module, &msll); + + setting = msll.first; + while(setting) + { + DBVARIANT dbv; + if (!GetSetting(hContactFrom, module, setting->name, &dbv)) + { + switch (dbv.type) + { + case DBVT_BYTE: + DBWriteContactSettingByte(hContactTo, module, setting->name, dbv.bVal); + break; + case DBVT_WORD: + DBWriteContactSettingWord(hContactTo, module, setting->name, dbv.wVal); + break; + case DBVT_DWORD: + DBWriteContactSettingDword(hContactTo, module, setting->name, dbv.dVal); + break; + case DBVT_ASCIIZ: + DBWriteContactSettingString(hContactTo, module, setting->name, dbv.pszVal); + break; + case DBVT_UTF8: + DBWriteContactSettingStringUtf(hContactTo, module, setting->name, dbv.pszVal); + break; + case DBVT_BLOB: + DBWriteContactSettingBlob(hContactTo, module, setting->name, dbv.pbVal, dbv.cpbVal); + break; + } + } + DBFreeVariant(&dbv); + setting = (struct ModSetLinkLinkItem *)setting->next; + } + FreeModuleSettingLL(&msll); +} + +INT_PTR CALLBACK copyModDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + ModuleAndContact *mac = (ModuleAndContact *)GetWindowLongPtr(hwnd,GWLP_USERDATA); + if (msg == WM_INITDIALOG) + { + int index, loaded; + char szProto[256]; + HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + + while (hContact) + { + if (GetValue(hContact,"Protocol","p",szProto,SIZEOF(szProto))) + loaded = IsProtocolLoaded(szProto); + else + loaded = 0; + + // filter + if ((loaded && Mode == MODE_UNLOADED) || (!loaded && Mode == MODE_LOADED)) + { + hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); + continue; + } + + // contacts name + if (UOS) + { + DBVARIANT dbv ={0}; + WCHAR nick[256]; + WCHAR protoW[256]; // unicode proto + + if (szProto[0]) + a2u(szProto, protoW, SIZEOF(protoW)); + else + protoW[0] = 0; + + if (!szProto[0] || !loaded) + { + if (protoW) + { + if (Order) + mir_snwprintf(nick, SIZEOF(nick), L"(%s) %s %s", protoW, GetContactName(hContact, szProto, 1), L"(UNLOADED)"); + else + mir_snwprintf(nick, SIZEOF(nick), L"%s (%s) %s", GetContactName(hContact, szProto, 1), protoW, L"(UNLOADED)"); + } + else + wcscpy(nick, nick_unknownW); + } + else + { + if (Order) + mir_snwprintf(nick, SIZEOF(nick), L"(%s) %s", protoW, GetContactName(hContact, szProto, 1)); + else + mir_snwprintf(nick, SIZEOF(nick), L"%s (%s)", GetContactName(hContact, szProto, 1), protoW); + } + + index = SendMessageW(GetDlgItem(hwnd, IDC_CONTACTS), CB_ADDSTRING, 0, (LPARAM)nick); + SendMessageW(GetDlgItem(hwnd, IDC_CONTACTS), CB_SETITEMDATA, index, (LPARAM)hContact); + } + else + { + char nick[256]; + + if (!szProto[0] || !loaded) + { + if (szProto[0]) + { + if (Order) + mir_snprintf(nick, SIZEOF(nick), "(%s) %s %s", szProto, (char*)GetContactName(hContact, szProto, 0), "(UNLOADED)"); + else + mir_snprintf(nick, SIZEOF(nick), "%s (%s) %s", (char*)GetContactName(hContact, szProto, 0), szProto, "(UNLOADED)"); + } + else + strcpy(nick, nick_unknown); + } + else + { + if (Order) + mir_snprintf(nick, SIZEOF(nick), "(%s) %s", szProto, (char*)GetContactName(hContact, szProto, 0)); + else + mir_snprintf(nick, SIZEOF(nick), "%s (%s)", (char*)GetContactName(hContact, szProto, 0), szProto); + } + + index = SendMessage(GetDlgItem(hwnd, IDC_CONTACTS), CB_ADDSTRING, 0, (LPARAM)nick); + SendMessage(GetDlgItem(hwnd, IDC_CONTACTS), CB_SETITEMDATA, index, (LPARAM)hContact); + } + + hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)(HANDLE)hContact, 0); + } + + index = (int)SendMessage(GetDlgItem(hwnd, IDC_CONTACTS), CB_INSERTSTRING, 0, (LPARAM)(char*)Translate("Settings")); + SendMessage(GetDlgItem(hwnd, IDC_CONTACTS), CB_SETITEMDATA, index, (LPARAM)0); + SendMessage(GetDlgItem(hwnd, IDC_CONTACTS), CB_SETCURSEL, index, 0); + + SetWindowLongPtr(hwnd,GWLP_USERDATA,lParam); + TranslateDialogDefault(hwnd); + } + else + if (msg == WM_COMMAND) + { + switch(LOWORD(wParam)) + { + case CHK_COPY2ALL: + EnableWindow(GetDlgItem(hwnd, IDC_CONTACTS),!IsDlgButtonChecked(hwnd,CHK_COPY2ALL)); + break; + case IDOK: + { + HANDLE hContact; + + if (!IsDlgButtonChecked(hwnd,CHK_COPY2ALL)) + { + hContact = (HANDLE)SendMessage(GetDlgItem(hwnd, IDC_CONTACTS), CB_GETITEMDATA, SendMessage(GetDlgItem(hwnd, IDC_CONTACTS), CB_GETCURSEL, 0, 0), 0); + copyModule(mac->module, mac->hContact, hContact); + } + else + { + SetCursor(LoadCursor(NULL,IDC_WAIT)); + hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + + while (hContact) + { + copyModule(mac->module, mac->hContact, hContact); + hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)(HANDLE)hContact, 0); + } + + SetCursor(LoadCursor(NULL,IDC_ARROW)); + } + mir_free(mac); + refreshTree(1); + DestroyWindow(hwnd); + } + break; + case IDCANCEL: + { + mir_free(mac); + DestroyWindow(hwnd); + } + break; + } + } + return 0; +} + +void copyModuleMenuItem(char* module, HANDLE hContact) +{ + HWND hwnd; + ModuleAndContact *mac = (ModuleAndContact *)mir_calloc(sizeof(ModuleAndContact)); + mac->hContact = hContact; + strncpy(mac->module, module, 255); + + if (UOS) + hwnd = CreateDialogParamW(hInst, MAKEINTRESOURCEW(IDD_COPY_MOD), 0, copyModDlgProc, (LPARAM)mac); + else + hwnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_COPY_MOD), 0, copyModDlgProc, (LPARAM)mac); +} \ No newline at end of file diff --git a/plugins/DbeditorPP/dbeditorpp_10.vcxproj b/plugins/DbeditorPP/dbeditorpp_10.vcxproj new file mode 100644 index 0000000000..776ea53f7e --- /dev/null +++ b/plugins/DbeditorPP/dbeditorpp_10.vcxproj @@ -0,0 +1,231 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + Svc_dbepp + {9C6040B8-1173-40FA-A3DB-DE044CCD8250} + + + + DynamicLibrary + MultiByte + true + + + DynamicLibrary + MultiByte + true + + + DynamicLibrary + MultiByte + + + DynamicLibrary + MultiByte + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(SolutionDir)$(Configuration)\Plugins\ + $(SolutionDir)$(Configuration)64\Plugins\ + $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)\Plugins\ + $(SolutionDir)$(Configuration)64\Plugins\ + $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ + true + + + + Disabled + ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;DBEDITORPP_EXPORTS;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebugDLL + Use + headers.h + Level3 + EditAndContinue + 4996;%(DisableSpecificWarnings) + + + _DEBUG;%(PreprocessorDefinitions) + ..\..\include\msapi + + + true + false + $(IntDir)$(TargetName).lib + Windows + shlwapi.lib;comctl32.lib;%(AdditionalDependencies) + $(SolutionDir)\lib + + + + + Disabled + ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + WIN64;_DEBUG;_WINDOWS;_USRDLL;DBEDITORPP_EXPORTS;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebugDLL + Use + headers.h + Level3 + 4996;%(DisableSpecificWarnings) + + + _DEBUG;%(PreprocessorDefinitions) + ..\..\include\msapi + + + shlwapi.lib;comctl32.lib;%(AdditionalDependencies) + true + false + $(IntDir)$(TargetName).lib + Windows + $(SolutionDir)\lib + + + + + Full + OnlyExplicitInline + Size + ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;DBEDITORPP_EXPORTS;%(PreprocessorDefinitions) + true + true + Use + headers.h + Level3 + 4996;%(DisableSpecificWarnings) + + + NDEBUG;%(PreprocessorDefinitions) + ..\..\include\msapi + + + shlwapi.lib;comctl32.lib;%(AdditionalDependencies) + true + true + true + false + $(IntDir)$(TargetName).lib + Windows + $(SolutionDir)\lib + + + + + Full + OnlyExplicitInline + Size + ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + WIN64;NDEBUG;_WINDOWS;_USRDLL;DBEDITORPP_EXPORTS;%(PreprocessorDefinitions) + true + true + Use + headers.h + Level3 + 4996;%(DisableSpecificWarnings) + + + NDEBUG;%(PreprocessorDefinitions) + ..\..\include\msapi + + + shlwapi.lib;comctl32.lib;%(AdditionalDependencies) + true + true + true + false + $(IntDir)$(TargetName).lib + Windows + $(SolutionDir)\lib + + + + + + + + Create + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/plugins/DbeditorPP/dbeditorpp_10.vcxproj.filters b/plugins/DbeditorPP/dbeditorpp_10.vcxproj.filters new file mode 100644 index 0000000000..f0f8d79957 --- /dev/null +++ b/plugins/DbeditorPP/dbeditorpp_10.vcxproj.filters @@ -0,0 +1,142 @@ + + + + + {bc4414ca-bfab-4385-a016-6239272b67ab} + cpp;c;cxx;rc;def;r;odl;idl;hpj;bat + + + {8ba4deb9-307a-4c99-9c87-2243a0ef802e} + + + {b1b3b1b6-9fe0-435d-b8ab-1715cc5e7430} + + + {adcc58df-dacb-48fe-a36b-59f8221cb71e} + h;hpp;hxx;hm;inl + + + {fb09bf3d-d973-466d-b87b-0b785885753b} + ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files\ModSetting Enuming + + + Source Files\dialogs + + + Source Files\dialogs + + + Source Files\dialogs + + + Source Files\dialogs + + + Source Files\dialogs + + + Source Files\dialogs + + + Source Files\dialogs + + + Source Files\dialogs + + + Source Files\dialogs + + + + + Source Files\ModSetting Enuming + + + Header Files + + + Header Files + + + Header Files + + + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + + + Resource Files + + + \ No newline at end of file diff --git a/plugins/DbeditorPP/dbeditorpp_readme.txt b/plugins/DbeditorPP/dbeditorpp_readme.txt new file mode 100644 index 0000000000..774560721d --- /dev/null +++ b/plugins/DbeditorPP/dbeditorpp_readme.txt @@ -0,0 +1,143 @@ +Database Editor ++ +------------------- + +Database Editor ++ allows you to easily modify your database settings (which is a good and bad thing..). Be carefull editing values that you dont know what they are used for... you couldnt couse Miranda IM to not work if you change the wrong setting... +YOU HAVE BEEN WARNED... + +A summary of what DBE++ can do.. (each will be explained below) +- Edit every database setting (not history) +- export / import your entire (or partial) database to/from a txt file +- Remove an entire module from the database +- Find and replace a value in string variables.. +- Find text (numbers or letters) in any module, setting name or value +- Keep a list of variables you need to watch (usefull for developers) +- display modules which are not currently being used (if the plugin that uses that module isnt loaded) +- clone a contact +- copy a module to a contact +- rename module and settings +- change a variable type +- show popups when a certain setting changes +- show encrypted strings decrypted (as well as encrypt/decrypt any string variable) +and more.... + +Editing Variables +----------------- +The easiest way to edit or rename a setting is to dowuble click the setting's icon, a new window will popup and you can edit it there... +well, i lie.. the easiest way to edit/rename the settings is a bit more complicated :) +if you click twice the setting name a edit window should popup where you can rename the setting... pressing escape will cancel it, everything else will accpet your changes without confirmation. +Same goes for the setting value (2nd column) except you can do nifty stuff here which needs to be explained... +just typing a number will keep the vairable type the same and change the value to your new number (it does not check if your new number is larger that the type's largest possible number). +Typeing anything other than numbers will convert the variable to a string with your new data as the value. +Typeing a number into a string variable will keep the variable as a string. + +You can force a variable to a type by prepending the value with a letter. +'b' or 'B' to force a BYTE variable. +'w' or 'W' to force a WORD variable. +'d' or 'D' to force a DWORD variable. +If your new data starts with a ' or " the setting will be converted to a string, so if you actually want to start the value with a ' you need to put 2 ' marks at the start!.. +unless a number starts with 0x or 0X the number is assumed to be decimal, with a 0x/0X it is hexidecimal. + +Exporting / Importing +--------------------- +To export the entire database go Actions > Export / Import > Export entire database (in the DBE++ window), you can choose any file extension you want, it just saves as a plaintext file, so .txt is logical :) +To export only a certain module or contact right click it and go export.. + +Importing is a bit more complex... +there are two ways to import settings, either useing the import window, or just importing an entire file. +Using the import window lets you choose exactly which modules/settings to import into the selected contact. +Importing an entire file will start importing all the settings into the selected contact (the Settings contact if you do it from the actions menu item). + +Every time a line starting with "CONTACT:" is read a new contact is created and the following modules/settings get imported into that contact... there is one exception tho. if the line is "CONTACT: Settings" then the following modules/settings get imported into the Settings contact ( a new contact is not created..) + +Remove an entire module from the database +---------------------------------------------- +To remove a module from the database use the actions > Delete module menu item. If you have alot of modules this window can take a few seconds to finish setting up. when it finishes loading all the modules just choose the one u want to delete and press ok. there is no confirmation here so be careful... Also its a good idea to run dbtool after doing this as you may have lots of wasted space in the DB... + +Find and replace a value in string variables.. +---------------------------------------------- +Actions > find > find and replace... +This searches every string value in the DB and will replace the find text with the new text.. it does not replace text in value names, and there is no confirmation... + +Find text (numbers or letters) in any module, setting name or value +---------------------------------------------------------- +Actions > find > find +This window lets you search the entire database for any text (numbers included..) in module names, setting names and setting values... +Double clicking any of the found items will cause the main DBE++ window to select that item... + +Keep a list of variables you need to watch (AKA watch list) +------------------------------------------- +if there is a variable you want to keep an eye on (testing something?) then right click the setting in the list and go "watch". (you can also watch entire modules by right clicking them). To then see the watch list use the watches > view all menu item. A new window will apear with all the watched settings. double clicking any of them will find the item in the main window. If you have chosen to be notified with popups then any watched setting that changes will create a popup (even if the DBE++ and watch list windows are not open) +Currently there is no way to save the list after a restart... + +display modules which are not currently being used (AKA known modules list) +--------------------------------------------------------------------------- +If a module has the yellow folder icon it means that the module is currently being used, e.g the DBEditorpp module will always be yellow because its being used by this plugin... but the Chat module will only be yellow if you have the chat plugin enabled and installed... If you dont care whether a module is being used or not then u can turn this feature off in the options... +Unfortuantly, the only way to know which modules are being used is by other plugins letting DBE++ know... so untill more plugins get updated to use this feature you can add module names to the edit box in options > plugins > Database Editor++ (changeing this requires a restart to take effect), OR you can use an mbot script to add modules "on the fly" (read below) +Plugin developers please read below how to add your modules... + +Renameing modules +----------------- +Select the module you want to rename and press f2 or click the name again and you can type a new name, pressing esc will cancel the change, anything else will accept the change with no confirmation. + +Other Stuff +---------- +Everything else should be self-explanatory or easily done by context menu items.... + + +ADDING YOUR MODULES TO THE KNOWN MODULES LIST +------------------------------------------------ +If your plugin only uses ONE module then you can use the "DBEditorpp/RegisterSingleModule" Service function like this: +CallService("DBEditorpp/RegisterSingleModule",(WPARAM)"modName",0); +If you have more than one module then use the "DBEditorpp/RegisterModule" with the WPARAM char** and LPARAM int being the number of modules to register.. +e.g +{ + char *mods[4] = {"module1","Module2","Module3"}; + CallService("DBEditorpp/RegisterModule",(WPARAM)mods,(LPARAM)3); +} +REMEMBER TO DO THIS IN OR AFTER ME_SYSTEM_MODULESLOADED HAS BEEN TRIGGERED.... + +DOING IT WITH MSP (formerly mBot).. +If you want to add modules "on-the-fly" you can add them with an mbot script like this: + +then refresh the module tree and the module will be known.. + +Translation +----------- +ive added a translation.txt file in the archive... apart from the text in the windows i tihnk it has everything... + +Changelog +--------- +3.1 +- added icon manager support coz you people are annoying... btw huge thanx to Angeli-ka for the icons +- fixed a bug in the find and replace code... +- added a fix to disallow inline setting editing on win98 and winME to stop crashes +- big thanx to Std for pointing out (and fixing) some stupid bugs in the export/import code +- menu should be translatable now +- added a bit more room in the options dialog for tranlsators +- added in bio's code changes which seems to have fixed the popup module crash problem... (hopefully) (THANX BIO) +- the old "KnownModules" module is now used again... any modules in that are added +- still trying to work out how to not save the window size if it was maximised... +- added a "add module to known list" menu item +- modules added in the options page can now have a space in their name (put a \ before the space for it to work) +- fixed the options page a bit +- now asks to overwrite files when you export... +- no more contact proto icons in the contact list +- fixed various translation problems + +3.0 +- 99% recode and now it all works nicely :) + +1.0->2.0 +- old stuff.... not relevant anymore + +------------------------------ + +(c) 2005 Jonathan Gordon (jdgordy@gmail.com) + +contact me on ICQ, MSN, Email or Telepathy... just make sure you tell me who you are or youll get blocked :) +ICQ: 98791178 +MSN: jonnog@hotmail.com +Jabber: jdgordy@jabber.zim.net.au + diff --git a/plugins/DbeditorPP/dbeditorpp_translation.txt b/plugins/DbeditorPP/dbeditorpp_translation.txt new file mode 100644 index 0000000000..6d90341b35 --- /dev/null +++ b/plugins/DbeditorPP/dbeditorpp_translation.txt @@ -0,0 +1,38 @@ +Database Editor++ +Error Loading Module List +Couldnt create the image list... +Error Loading Setting List +Settings +(UNLOADED) +(UNKNOWN) +Contacts + +Are you sure you want to delete module \"%s\"? +Confirm Module Deletion + +Name +Data +Type +Size +BLOB +BYTE +WORD +DWORD +STRING + +Delete module from Database +Delete module from Database... Loading +Enter a string to search the DB for + +Found Module \"%s\" in contact \"%s\" ; <- module, contact name +Found Setting \"%s\" in module \"%s\" in contact \"%s\" ; <- setting, module, contact name +Found in Setting \"%s\" in module \"%s\" in contact \"%s\" ; <-setting,module, contact name +Finished. %d items found + + +Closed Known Module +Open Known Module +Closed Unknown Module +Open Unknown Module +Contacts Group +Unknown Contact \ No newline at end of file diff --git a/plugins/DbeditorPP/deletemodule.cpp b/plugins/DbeditorPP/deletemodule.cpp new file mode 100644 index 0000000000..a0eddf73a1 --- /dev/null +++ b/plugins/DbeditorPP/deletemodule.cpp @@ -0,0 +1,148 @@ +#include "headers.h" + +static int working; +static HWND hwnd2Delete = NULL; + +int deleteModule(char* module, HANDLE hContact, int fromMenu) +{ + char msg[1024]; + ModuleSettingLL settinglist; + struct ModSetLinkLinkItem *setting; + + if (!module) return 0; + + if (!fromMenu) + { + mir_snprintf(msg, SIZEOF(msg), Translate("Are you sure you want to delete module \"%s\"?"), module); + if (DBGetContactSettingByte(NULL,modname, "WarnOnDelete",1)) + { + if (MessageBox(0,msg, Translate("Confirm Module Deletion"), MB_YESNO|MB_ICONEXCLAMATION) == IDNO) + return 0; + } + } + + if (!EnumSettings(hContact,module,&settinglist)) return 0; + + setting = settinglist.first; + while (setting) + { + DBDeleteContactSetting(hContact, module, setting->name); + setting = (struct ModSetLinkLinkItem *)setting->next; + } + FreeModuleSettingLL(&settinglist); + return 1; +} + +void __cdecl PopulateModuleDropListThreadFunc(LPVOID di) +{ + HWND hwnd = (HWND)di; + ModuleSettingLL msll; + struct ModSetLinkLinkItem *module; + HANDLE hContact; + int moduleEmpty; + if (!EnumModules(&msll)) DestroyWindow(hwnd); + module = msll.first; + while (module && working) + { + moduleEmpty = 1; + // check the null + if (!IsModuleEmpty(NULL,module->name)) + { + SendDlgItemMessage(hwnd,IDC_CONTACTS,CB_ADDSTRING,0,(LPARAM)module->name); + moduleEmpty = 0; + module = (struct ModSetLinkLinkItem *)module->next; + continue; + } + for (hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);moduleEmpty && hContact;hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0)) + { + if (!IsModuleEmpty(hContact,module->name)) + { + SendDlgItemMessage(hwnd,IDC_CONTACTS,CB_ADDSTRING,0,(LPARAM)module->name); + moduleEmpty = 0; + break; + } + } + + module = (struct ModSetLinkLinkItem *)module->next; + SendDlgItemMessage(hwnd,IDC_CONTACTS,CB_SETCURSEL,0,0); + } + SendDlgItemMessage(hwnd,IDC_CONTACTS,CB_SETCURSEL,0,0); + FreeModuleSettingLL(&msll); + SetWindowText(hwnd,Translate("Delete module from Database")); + EnableWindow(GetDlgItem(hwnd,IDC_CONTACTS),1); + EnableWindow(GetDlgItem(hwnd,IDOK),1); + EnableWindow(GetDlgItem(hwnd,IDCANCEL),1); + + if (!working) + PostMessage(hwnd, WM_COMMAND, (WPARAM)IDCANCEL, 0); + else + working = 2; +} + +INT_PTR CALLBACK DeleteModuleDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch(msg) + { + case WM_INITDIALOG: + { + SetWindowText(hwnd,Translate("Delete module from Database... Loading")); + EnableWindow(GetDlgItem(hwnd,IDC_CONTACTS),0); + EnableWindow(GetDlgItem(hwnd,IDOK),0); + SetDlgItemText(hwnd,IDC_INFOTEXT,"Delete module from Database"); + SetDlgItemText(hwnd,CHK_COPY2ALL,"Delete module from all contacts (Includes Setting)"); + EnableWindow(GetDlgItem(hwnd,CHK_COPY2ALL),0); + CheckDlgButton(hwnd,CHK_COPY2ALL,1); + TranslateDialogDefault(hwnd); + working = 1; + forkthread(PopulateModuleDropListThreadFunc,0,hwnd); + } + return TRUE; + case WM_COMMAND: + switch(LOWORD(wParam)) + { + case IDOK: + { + char text[128]; + HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + GetDlgItemText(hwnd,IDC_CONTACTS,text,128); + SetCursor(LoadCursor(NULL,IDC_WAIT)); + while (hContact) + { + deleteModule(text,hContact,1); + hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); + } + // do the null + deleteModule(text,NULL,1); + SetCursor(LoadCursor(NULL,IDC_ARROW)); + refreshTree(1); + } + // fall through + case IDCANCEL: + { + if (working == 1) + { + working = 0; + EnableWindow(GetDlgItem(hwnd,IDCANCEL),0); + } + else + DestroyWindow(hwnd); + } + break; + } + break; + case WM_DESTROY: + hwnd2Delete = NULL; + break; + } + return 0; +} + + + +void deleteModuleGui() +{ + if (!hwnd2Delete) + hwnd2Delete = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_COPY_MOD), hwnd2mainWindow, DeleteModuleDlgProc, (LPARAM)0); + else + SetForegroundWindow(hwnd2Delete); +} \ No newline at end of file diff --git a/plugins/DbeditorPP/exportimport.cpp b/plugins/DbeditorPP/exportimport.cpp new file mode 100644 index 0000000000..ad9f508a21 --- /dev/null +++ b/plugins/DbeditorPP/exportimport.cpp @@ -0,0 +1,745 @@ +#include "headers.h" + +int Mode; +HWND hwnd2importWindow; + +int Openfile(char *outputFile, const char *module) +{ + OPENFILENAME ofn = {0}; + char filename[MAX_PATH] = ""; + char filter[MAX_PATH]; + mir_snprintf(filter, SIZEOF(filter), "%s%c*.ini%c%s%c*.*%c", Translate("INI Files"), 0, 0, Translate("All Files"), 0, 0); + char *title = Translate("Export to file"); + + if (module) + { + int n = 0; + mir_strncpy(filename, module, MAX_PATH); + + while(filename[n]) + { + switch(filename[n]) + { + case '*': + case ':': + case '/': + case '?': + case '|': + case '\\': + filename[n] = '_'; + break; + } + n++; + } + } + + ofn.lStructSize = sizeof(ofn); + ofn.lpstrFile = filename; + ofn.lpstrFilter = filter; + ofn.Flags = OFN_HIDEREADONLY | OFN_SHAREAWARE | OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT; + ofn.lpstrTitle = title; + ofn.nMaxFile = MAX_PATH; + ofn.lpstrDefExt = "ini"; + + if (!GetSaveFileName(&ofn)) + return 0; + lstrcpy(outputFile,filename); + return 1; +} + +char* StrReplace (char* Search, char* Replace, char* Resource) +{ + int i = 0; + int SearchLen = (int)_tcslen(Search); + char* Work = mir_tstrdup(Replace); + int ReplaceLen = (int)_tcslen(Work); + + char* Pointer = _tcsstr(Resource, Search); + + while (Pointer != NULL) + { + int PointerLen = (int)_tcslen(Pointer); + int ResourceLen = (int)_tcslen(Resource); + + char* NewText = (char*)mir_calloc((ResourceLen - SearchLen + ReplaceLen + 1)*sizeof(char)); + + _tcsncpy(NewText, Resource, ResourceLen - PointerLen); + _tcscat(NewText, Work); + _tcscat(NewText, Pointer + SearchLen); + + Resource = (char*)mir_realloc(Resource, (ResourceLen - SearchLen + ReplaceLen + 1)*sizeof(char)); + + for (i = 0; i < (ResourceLen - SearchLen + ReplaceLen); i++) + Resource[i] = NewText[i]; + Resource[i] = 0; + mir_free(NewText); + + Pointer = _tcsstr(Resource + (ResourceLen - PointerLen + ReplaceLen), Search); + } + mir_free(Work); + + return Resource; +} + +void exportModule(HANDLE hContact, char* module, FILE* file) +{ + char tmp[32]; + ModuleSettingLL settinglist; + struct ModSetLinkLinkItem *setting; + + EnumSettings(hContact,module,&settinglist); + + // print the module header.. + fprintf(file, "\n[%s]", module); + setting = settinglist.first; + while(setting) + { + DBVARIANT dbv; + if (!GetSetting(hContact, module, setting->name, &dbv)) + { + switch (dbv.type) + { + case DBVT_BYTE: + fprintf(file, "\n%s=b%s", setting->name, itoa(dbv.bVal,tmp,10)); + DBFreeVariant(&dbv); + break; + case DBVT_WORD: + fprintf(file, "\n%s=w%s", setting->name, itoa(dbv.wVal,tmp,10)); + DBFreeVariant(&dbv); + break; + case DBVT_DWORD: + fprintf(file, "\n%s=d%s", setting->name, itoa(dbv.dVal,tmp,10)); + DBFreeVariant(&dbv); + break; + case DBVT_ASCIIZ: + case DBVT_UTF8: + if (strchr(dbv.pszVal, '\r')) + { + char *end = StrReplace("\\", "\\\\", dbv.pszVal); + end = StrReplace("\r", "\\r", end); + end = StrReplace("\n", "\\n", end); + fprintf(file, "\n%s=g%s", setting->name, end); + break; + } + if (dbv.type == DBVT_UTF8) + fprintf(file, "\n%s=u%s", setting->name, dbv.pszVal); + else + fprintf(file, "\n%s=s%s", setting->name, dbv.pszVal); + DBFreeVariant(&dbv); + break; + case DBVT_BLOB: + { + int j; + char *data = NULL; + if (!(data = (char*)mir_alloc( 3*(dbv.cpbVal+1)*sizeof(char)))) + break; + data[0] = '\0'; + for (j=0; jname , data); + mir_free(data); + } + DBFreeVariant(&dbv); + break; + } + } + setting = (struct ModSetLinkLinkItem *)setting->next; + } + FreeModuleSettingLL(&settinglist); +} + + +char *NickFromHContact(HANDLE hContact) +{ + static char nick[512] = ""; + + if (hContact) + { + char szProto[256]; + int loaded = 0; + + if (GetValue(hContact,"Protocol","p",szProto,SIZEOF(szProto))) + loaded = IsProtocolLoaded(szProto); + + if (!szProto[0] || !loaded) + { + char name[256]; + + if (szProto[0]) + { + if (GetValue(hContact,szProto,"Nick",name,SIZEOF(name))) + mir_snprintf(nick, SIZEOF(nick),"%s (%s)", name, szProto); + else + mir_snprintf(nick, SIZEOF(nick),"(UNKNOWN) (%s)", szProto); + } + else + mir_snprintf(nick, SIZEOF(nick),"(UNKNOWN)"); + } + else + { + char *uid; + char szUID[256]; + + uid = (char*)CallProtoService(szProto,PS_GETCAPS,PFLAG_UNIQUEIDSETTING,0); + if ((int)uid!=CALLSERVICE_NOTFOUND && uid) + { + GetValue(hContact, szProto, uid, szUID, SIZEOF(szUID)); + mir_snprintf(nick, SIZEOF(nick), "%s *(%s)*<%s>*{%s}*", (char*)GetContactName(hContact,szProto,0), szProto, uid, szUID); + } + else + mir_snprintf(nick, SIZEOF(nick), "%s (%s)", (char*)GetContactName(hContact,szProto,0), szProto); + } + } + + return nick; +} + + +void exportDB(HANDLE hContact, char* module) // hContact == -1 export entire db. module == NULL export entire contact. +{ // hContact == -1, module == "" - all contacts + FILE* file = NULL; + char fileName[MAX_PATH]; + int nullcontactDone = 0; + ModuleSettingLL modlist; + struct ModSetLinkLinkItem *mod; + + // enum all the modules + if (!EnumModules(&modlist)) { msg(Translate("Error Loading Module List"),modFullname); return;} + + if (Openfile(fileName, ((int)hContact==-1)?NULL:module)) + { + if (!(file = fopen(fileName, "wt"))) { msg(Translate("Couldn't open file for writing"), modFullname); return; } + + SetCursor(LoadCursor(NULL,IDC_WAIT)); + + // exporting entire db + if (hContact == INVALID_HANDLE_VALUE) + { + hContact = NULL; + + if (module == NULL) + { + fprintf(file, "SETTINGS:\n"); + mod = modlist.first; + while(mod) + { + if (IsModuleEmpty(hContact, mod->name)) + { + mod = (struct ModSetLinkLinkItem *)mod->next; + continue; + } + exportModule(hContact, mod->name, file); + mod = (struct ModSetLinkLinkItem *)mod->next; + if (mod) + fprintf(file, "\n"); + } + } + else + { + if (module == "") module = NULL; // reset module for all contacts export + } + + hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + + while (hContact) + { + if (!hContact) continue; + + // filter + if (Mode != MODE_ALL) + { + char szProto[256]; + int loaded = 0; + + if (GetValue(hContact,"Protocol","p",szProto,SIZEOF(szProto))) + loaded = IsProtocolLoaded(szProto); + + if ((loaded && Mode == MODE_UNLOADED) || (!loaded && Mode == MODE_LOADED)) + { + hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); + continue; + } + } + + fprintf(file, "CONTACT: %s\n", NickFromHContact(hContact)); + + if (module == NULL) // export all modules + { + mod = modlist.first; + while(mod) + { + if (IsModuleEmpty(hContact, mod->name)) + { + mod = (struct ModSetLinkLinkItem *)mod->next; + continue; + } + exportModule(hContact, mod->name, file); + mod = (struct ModSetLinkLinkItem *)mod->next; + if (mod) + fprintf(file, "\n"); + } + } + else // export module + { + exportModule(hContact, module, file); + } + hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)(HANDLE)hContact, 0); + } + } + // exporting a contact + else + { + if (!module) // exporting every module + { + if (hContact) + fprintf(file, "CONTACT: %s\n", NickFromHContact(hContact)); + else + fprintf(file, "SETTINGS:\n"); + + mod = modlist.first; + while(mod) + { + if (IsModuleEmpty(hContact, mod->name)) + { + mod = (struct ModSetLinkLinkItem *)mod->next; + continue; + } + exportModule(hContact, mod->name, file); + mod = (struct ModSetLinkLinkItem *)mod->next; + if (mod) + fprintf(file, "\n"); + } + } + else + { + if (hContact) + fprintf(file, "FROM CONTACT: %s\n", NickFromHContact(hContact)); + else + fprintf(file, "SETTINGS:\n"); + + exportModule(hContact, module, file); + } + } + fclose(file); + + SetCursor(LoadCursor(NULL,IDC_ARROW)); + } + + FreeModuleSettingLL(&modlist); +} + + +HANDLE CheckNewContact(char *myProto, char *uid, char *myName) +{ + char szProto[256], szName[256]; + HANDLE resultHandle = INVALID_HANDLE_VALUE; + HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + + while (hContact) + { + //szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + if (DBGetContactSettingStringStatic(hContact, "Protocol", "p", szProto, 256)) + { + if (!mir_strcmp(szProto, myProto)) + { + if (GetValue(hContact, szProto, uid, szName, SIZEOF(szName)) && + !mir_strcmp(szName, myName)) + { + //char msg[1024]; + //_snprintf(msg, 1024, Translate("Do you want to overwrite it \"%s\"?"), szName); + //if (MessageBox(0,msg, Translate("Contact already exists"), MB_YESNO|MB_ICONEXCLAMATION) == IDYES) + resultHandle = hContact; + break; + } + } + } + + hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); + } + + return resultHandle; + +} + +HANDLE Clist_GroupExists(WCHAR *tszGroup) +{ + unsigned int i = 0; + WCHAR* _t = 0; + char str[10]; + INT_PTR result = 0; + DBVARIANT dbv = {0}; + int match; + + do { + _itoa(i, str, 10); + result = DBGetContactSettingTString(0, "CListGroups", str, &dbv); + if (!result) { + match = (!lstrcmpW(tszGroup, (LPCWSTR)&dbv.ptszVal[1]) && (lstrlenW(tszGroup) == lstrlenW((LPCWSTR)&dbv.ptszVal[1]))); + DBFreeVariant(&dbv); + if(match) + return((HANDLE)(i + 1)); + } + i++; + } + while(result == 0); + return(0); +} + +void importSettings(HANDLE hContact, char *importstring ) +{ + char module[256] = "", setting[256] = "", *end; + int i=0, value, type; + importstring = strtok(importstring, "\n"); + + SetCursor(LoadCursor(NULL,IDC_WAIT)); + + while (importstring != NULL) + { + i=0; + rtrim(importstring); + if (importstring[i] == '\0') + { + importstring = strtok(NULL, "\n"); + continue; + } + else if (!strncmp(&importstring[i],"SETTINGS:",strlen("SETTINGS:"))) + { + importstring = strtok(NULL, "\n"); + continue; + } + else if (!strncmp(&importstring[i],"CONTACT:", strlen("CONTACT:"))) + { + int len, add = 1; + hContact = INVALID_HANDLE_VALUE; + + i = i + (int)strlen("CONTACT:"); + len = (int)strlen(&importstring[i]); + + if (len > 10) + { + char uid[256]="",szUID[256]="",szProto[512]=""; + char *p1,*p2; + + p1 = strrchr(&importstring[i], '>*{'); + p2 = strrchr(&importstring[i], '}*'); + + if (p1 && p2 && p1+3 < p2 && p2-p1 < SIZEOF(szUID)) + { + strncpy(szUID, p1+1, p2-p1-2); + + p1 = strrchr(&importstring[i], ')*<'); + p2 = strrchr(&importstring[i], '>*{'); + + if (p1 && p2 && p1+3 < p2 && p2-p1 < SIZEOF(uid)) + { + strncpy(uid, p1+1, p2-p1-3); + + p1 = strrchr(&importstring[i], ' *('); + p2 = strrchr(&importstring[i], ')*<'); + + if (p1 && p2 && p1+3 < p2 && p2-p1 < SIZEOF(szProto)) + { + char *protouid; + strncpy(szProto, p1+1, p2-p1-3); + + protouid = (char*)CallProtoService(szProto,PS_GETCAPS,PFLAG_UNIQUEIDSETTING,0); + if ((int)protouid!=CALLSERVICE_NOTFOUND) + { + if (!mir_strcmp(protouid, uid)) + hContact = CheckNewContact(szProto, uid, szUID); + } + else + hContact = CheckNewContact(szProto, uid, szUID); + } + } + } + } + + if (hContact == INVALID_HANDLE_VALUE) + { + HANDLE temp = (HANDLE)CallService(MS_DB_CONTACT_ADD,0,0); + if (temp) + hContact = temp; + } + } + else if (importstring[i] == '[' && !strchr(&importstring[i+1],'='))// get the module + { + if (end = strpbrk(&importstring[i+1], "]")) { + if ((end+1) != '\0') *end = '\0'; + strcpy(module, &importstring[i+1]); + } + } + else if (importstring[i] == '-' && importstring[i+1] == '[' && + !strchr(&importstring[i+2],'='))// get the module + { + if (end = strpbrk(&importstring[i+2], "]")) { + if ((end+1) != '\0') *end = '\0'; + strcpy(module, &importstring[i+2]); + deleteModule(module, hContact, 1); + } + } + else if (strstr(&importstring[i], "=") && module[0]) // get the setting + { + if (end = strpbrk(&importstring[i+1], "=")) { + if ((end+1) != '\0') *end = '\0'; + strcpy(setting, &importstring[i]); + + // get the type + type = *(end+1); + if (lstrcmp(module, "CList") == 0 && lstrcmp(setting, "Group") == 0) + { + WCHAR* GroupName = mir_a2u(end+2); + if (!GroupName) + continue; + HANDLE GroupHandle = Clist_GroupExists(GroupName); + if(GroupHandle == 0) { + GroupHandle = (HANDLE)CallService(MS_CLIST_GROUPCREATE, 0, (LPARAM)GroupName); + + if(GroupHandle) { + CallService(MS_CLUI_GROUPADDED, (WPARAM)GroupHandle, 0); + CallService(MS_CLIST_GROUPSETEXPANDED, (WPARAM)GroupHandle, 1); + } + } + mir_free(GroupName); + } + switch (type) + { + case 'b': + case 'B': + if (sscanf((end+2), "%d", &value) == 1) + DBWriteContactSettingByte(hContact, module, setting, (BYTE)value); + break; + case 'w': + case 'W': + if (sscanf((end+2), "%d", &value) == 1) + DBWriteContactSettingWord(hContact, module, setting, (WORD)value); + break; + case 'd': + case 'D': + if (sscanf((end+2), "%d", &value) == 1) + DBWriteContactSettingDword(hContact, module, setting, (DWORD)value); + break; + case 's': + case 'S': + DBWriteContactSettingString(hContact,module, setting, (end+2)); + break; + case 'g': + case 'G': + { char *pstr; + for(pstr=end+2;*pstr;pstr++) { + if (*pstr=='\\') { + switch(pstr[1]) { + case 'n': *pstr='\n'; break; + case 't': *pstr='\t'; break; + case 'r': *pstr='\r'; break; + default: *pstr=pstr[1]; break; + } + MoveMemory(pstr+1,pstr+2,lstrlenA(pstr+2)+1); + } } } + case 'u': + case 'U': + DBWriteContactSettingStringUtf(hContact,module, setting, (end+2)); + break; + case 'l': + case 'L': + DBDeleteContactSetting(hContact, module, setting); + break; + case 'n': + case 'N': + WriteBlobFromString(hContact, module, setting, (end+2), (int)strlen((end+2))); + break; + } + } + } + importstring = strtok(NULL, "\n"); + } + SetCursor(LoadCursor(NULL,IDC_ARROW)); +} + +INT_PTR CALLBACK ImportDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch(msg) + { + case WM_INITDIALOG: + { + hwnd2importWindow = hwnd; + SetWindowLongPtr(hwnd,GWLP_USERDATA,lParam); + TranslateDialogDefault(hwnd); + SendDlgItemMessage(hwnd, IDC_TEXT, EM_LIMITTEXT, (WPARAM)sizeof(TCHAR)*0x7FFFFFFF, 0); + } + break; + + case WM_COMMAND: + { + switch(LOWORD(wParam)) + { + case IDC_CRLF: + { + int length = GetWindowTextLength(GetDlgItem(hwnd, IDC_TEXT)); + char *string = (char*)_alloca(length+3); + int Pos = 2; + + if (length) + { + int Range = SendDlgItemMessage(hwnd,IDC_TEXT,EM_GETSEL,0,0); + int Min = LOWORD(Range); + int Max = HIWORD(Range); + + + GetDlgItemText(hwnd, IDC_TEXT, string, length+1); + + if (Min == -1) + memcpy(string, crlf_string, SIZEOF(crlf_string)); + else + if (Max == -1 || Max >= length) + memcpy(&string[Min], crlf_string, SIZEOF(crlf_string)); + else + if (Max-Min > 2) + { + memcpy(&string[Min], crlf_string, SIZEOF(crlf_string)); + memmove(&string[Min+2], &string[Max], length - Max + 1); + } + else + { + memmove(&string[Min+2], &string[Max], length - Max + 1); + memcpy(&string[Min], crlf_string, SIZEOF(crlf_string)); + } + + if (Min) Pos += Min; + } + else + memcpy(string, crlf_string, SIZEOF(crlf_string)); + + SetDlgItemText(hwnd, IDC_TEXT, string); + SendDlgItemMessage(hwnd,IDC_TEXT,EM_SETSEL,Pos,Pos); + SetFocus(GetDlgItem(hwnd, IDC_TEXT)); + } + break; + + case IDOK: + { + HANDLE hContact = (HANDLE)GetWindowLongPtr(hwnd,GWLP_USERDATA); + int length = GetWindowTextLength(GetDlgItem(hwnd, IDC_TEXT)); + char *string; + if (length) + { + string = (char*)_alloca(length+1); + if (!string) {msg(Translate("Couldnt allocate enough memory!"), modFullname); DestroyWindow(hwnd); } + GetDlgItemText(hwnd, IDC_TEXT, string, length+1); + importSettings(hContact, string); + refreshTree(1); + } + } + break; + + case IDCANCEL: + DestroyWindow(hwnd); + hwnd2importWindow = 0; + break; + } + } + break; + } + return 0; +} + +void ImportSettingsMenuItem(HANDLE hContact) +{ + if (hwnd2importWindow) + DestroyWindow(hwnd2importWindow); + + CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_IMPORT), 0, ImportDlgProc, (LPARAM)hContact); +} + +int Openfile2Import(char *outputFiles) +{ + OPENFILENAME ofn = {0}; + char filter[MAX_PATH]; + mir_snprintf(filter, SIZEOF(filter), "%s%c*.ini%c%s%c*.*%c", Translate("INI Files"), 0, 0, Translate("All Files"), 0, 0); + char *title = Translate("Import from files"); + + ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; + ofn.lpstrFilter = filter; + ofn.hwndOwner = 0; + ofn.lpstrFile = outputFiles; + ofn.nMaxFile = MAX_PATH*10; + ofn.nMaxFileTitle = MAX_PATH; + ofn.Flags = OFN_HIDEREADONLY | OFN_SHAREAWARE | OFN_PATHMUSTEXIST | OFN_ALLOWMULTISELECT | OFN_EXPLORER; + ofn.lpstrTitle = title; + if (!GetOpenFileName(&ofn)) + return 0; + + return ofn.nFileOffset; +} + +BOOL Exists(LPCTSTR strName) +{ + return GetFileAttributes(strName) != INVALID_FILE_ATTRIBUTES; +} + +void ImportSettingsFromFileMenuItem(HANDLE hContact, char* FilePath) +{ + char szFileNames[MAX_PATH*10] = {0}; + char szPath[MAX_PATH] = ""; + char szFile[MAX_PATH]; + int index = 0; + HANDLE hFile, hMap; + PBYTE pFile = NULL; + DWORD offset = 0; + if (lstrcmp(FilePath, "") == 0) + offset = Openfile2Import(szFileNames); + else + { + if(Exists(FilePath)) + lstrcpy(szFileNames, FilePath); + else + lstrcpy(szFileNames, ""); + } + + if (!lstrcmp(szFileNames, "") == 0) + { + if ((DWORD)lstrlenA(szFileNames) < offset) + { + index += offset; + strncpy(szPath, szFileNames, offset); + strcat(szPath, "\\"); + } + + while(szFileNames[index]) + { + strcpy(szFile, szPath); + strcat(szFile, &szFileNames[index]); + index += (int)strlen(&szFileNames[index])+1; + + hFile = CreateFile(szFile, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); + if (hFile != INVALID_HANDLE_VALUE) + { + if (GetFileSize(hFile, NULL) > 0) + { + hMap = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL); + + if (hMap) { + pFile = (PBYTE)MapViewOfFile(hMap, FILE_MAP_COPY, 0, 0 ,0); + + if (pFile) { + importSettings(hContact, (char*)pFile); + UnmapViewOfFile(pFile); + } + CloseHandle(hMap); + } + + } + CloseHandle(hFile); + } + else + break; + + } + if (lstrcmp(FilePath, "") == 0) + refreshTree(1); + } +} diff --git a/plugins/DbeditorPP/findwindow.cpp b/plugins/DbeditorPP/findwindow.cpp new file mode 100644 index 0000000000..b9957cd246 --- /dev/null +++ b/plugins/DbeditorPP/findwindow.cpp @@ -0,0 +1,725 @@ +#include "headers.h" + +void __cdecl FindSettings(LPVOID di); + +static int working; +static int replace; + +#define FW_CASE 1 +#define FW_EXACT 2 +#define FW_MODNAME 4 +#define FW_SETNAME 8 +#define FW_SETVAL 16 + +#define FW_REPLACED 0x100 +#define FW_DELETED 0x200 + +#define RW_MODULE 1 +#define RW_SETNAME 2 +#define RW_SETVAL 4 +#define RW_FOUND 8 + +#define RW_FULL 0x100 +#define RW_CASE 0x200 + +typedef struct { + HWND hwnd; // hwnd 2 item list + char* text; // text to find + int options; // or'd about items + char* replace; // text to replace + int mode; // replace mode +} FindInfo; + + +int FindDialogResize(HWND hwnd,LPARAM lParam,UTILRESIZECONTROL *urc) +{ + switch(urc->wId) { + case IDC_LIST: + return RD_ANCHORX_WIDTH|RD_ANCHORY_HEIGHT; + case IDC_SBAR: + return RD_ANCHORX_WIDTH|RD_ANCHORY_BOTTOM; + default: + return RD_ANCHORX_LEFT|RD_ANCHORY_TOP; + } +} + + +void freeItems(HWND hwnd) +{ + int i; + ItemInfo *ii; + for (i=0;ihwnd = GetDlgItem(hwnd,IDC_LIST); + fi->options = (IsDlgButtonChecked(hwnd,IDC_CASESENSITIVE)?FW_CASE:0)| + (IsDlgButtonChecked(hwnd,IDC_EXACT)?FW_EXACT:0)| + (IsDlgButtonChecked(hwnd,IDC_MODNAME)?FW_MODNAME:0)| + (IsDlgButtonChecked(hwnd,IDC_SETTINGNAME)?FW_SETNAME:0)| + (IsDlgButtonChecked(hwnd,IDC_SETTINGVALUE)?FW_SETVAL:0); + + if (GetWindowLongPtr(GetDlgItem(hwnd,IDC_REPLACE),GWLP_USERDATA)) + { + if (IsDlgButtonChecked(hwnd,IDC_FOUND)) + fi->mode = RW_FOUND; + else + if (IsDlgButtonChecked(hwnd,IDC_MODNAME2)) + fi->mode = RW_MODULE; + else + if (IsDlgButtonChecked(hwnd,IDC_SETTINGNAME2)) + fi->mode = RW_SETNAME; + else + if (IsDlgButtonChecked(hwnd,IDC_SETTINGVALUE2)) + fi->mode = RW_SETVAL; + + if (IsDlgButtonChecked(hwnd,IDC_ENTIRELY)) + fi->mode |= RW_FULL; + + fi->replace = mir_tstrdup(replace); + + SetWindowText(GetDlgItem(hwnd,IDOK),Translate("Stop")); + EnableWindow(GetDlgItem(hwnd,IDC_SEARCH),0); + + if (IsDlgButtonChecked(hwnd,IDC_CASESENSITIVE)) + fi->mode |= RW_CASE; + } + else + { + SetWindowText(GetDlgItem(hwnd,IDC_SEARCH),Translate("Stop")); + EnableWindow(GetDlgItem(hwnd,IDOK),0); + } + + fi->text = mir_tstrdup(text); + + SendDlgItemMessage(hwnd,IDC_LIST,LB_RESETCONTENT,0,0); + SetWindowLongPtr(GetDlgItem(hwnd,IDC_SEARCH),GWLP_USERDATA,1); + + EnableWindow(GetDlgItem(hwnd,IDCANCEL),0); + forkthread(FindSettings,0,fi); + } + } + break; + case IDCANCEL: + DestroyWindow(hwnd); + break; + case IDC_LIST: + if (HIWORD(wParam) == LBN_DBLCLK) + { + int i = SendDlgItemMessage(hwnd,IDC_LIST,LB_GETCURSEL,0,0); + ItemInfo *ii =(ItemInfo*)SendDlgItemMessage(hwnd,IDC_LIST,LB_GETITEMDATA,i,0); + if (!ii) break; + SendMessage(GetParent(hwnd),WM_FINDITEM,(WPARAM)ii,0); + } + break; + } + break; + case WM_GETMINMAXINFO: + { + MINMAXINFO *mmi=(MINMAXINFO*)lParam; + mmi->ptMinTrackSize.x=520; + mmi->ptMinTrackSize.y=300; + return 0; + } + case WM_SIZE: + { + UTILRESIZEDIALOG urd; + ZeroMemory(&urd,sizeof(urd)); + urd.cbSize=sizeof(urd); + urd.hInstance=hInst; + urd.hwndDlg=hwnd; + urd.lpTemplate=MAKEINTRESOURCE(IDD_FIND); + urd.pfnResizer=FindDialogResize; + CallService(MS_UTILS_RESIZEDIALOG,0,(LPARAM)&urd); + } + break; + case WM_DESTROY: + freeItems(hwnd); + break; + } + return 0; +} + + +void ItemFound(HWND hwnd, HANDLE hContact,const char *module,const char *setting,const char* value,int type) +{ + ItemInfo *ii = (ItemInfo*)mir_calloc(sizeof(ItemInfo)); + int index; + char text[256] = ""; + int result = 0; + char szValue[256]; + char *name, *mode; + + if (!ii) return; + + if (type & FW_REPLACED) + mode = Translate("Replaced with"); + else + if (type & FW_DELETED) + mode = Translate("Deleted"); + else + mode = Translate("Found"); + + name = hContact?(char*)GetContactName(hContact,NULL,0):Translate("Settings"); + + switch (type & 0xFF) + { + case FW_MODULE: + ii->type = FW_MODULE; + mir_snprintf(text, SIZEOF(text), Translate("%s Module \"%s\" in contact \"%s\""), mode, module, name); + break; + case FW_SETTINGNAME: + mir_strncpy(ii->setting,setting,256); + ii->type = FW_SETTINGNAME; + if (GetValue(hContact,module,setting, szValue, SIZEOF(szValue))) + mir_snprintf(text, SIZEOF(text), Translate("%s Setting \"%s\" in module \"%s\" in contact \"%s\" - \"%s\""), mode, setting, module, name, szValue); + else + mir_snprintf(text, SIZEOF(text), Translate("%s Setting \"%s\" in module \"%s\" in contact \"%s\""), mode, setting, module, name); + break; + case FW_SETTINGVALUE: + mir_strncpy(ii->setting,setting,256); + ii->type = FW_SETTINGVALUE; + mir_snprintf(text, SIZEOF(text), Translate("%s \"%s\" in Setting \"%s\" in module \"%s\" in contact \"%s\""), mode, value, setting, module, name); + break; + } + + index = SendMessage(hwnd,LB_ADDSTRING,0,(LPARAM)text); + if (type & FW_DELETED) + { + SendMessage(hwnd,LB_SETITEMDATA,index,0); + mir_free(ii); + } + else + { + ii->hContact= hContact; + mir_strncpy(ii->module,module,256); + SendMessage(hwnd,LB_SETITEMDATA,index,(LPARAM)ii); + } +} + + +char *multiReplace(const char* value, const char *find, const char *replace, int cs) +{ + char *head, *temp, *string; + + int len = (int)strlen(find); + int replen = (int)strlen(replace); + + if (head = (char*)(cs?strstr(value, find):StrStrI(value, find))) // only should be 1 '=' sign there... + { + string = (char*)value; + temp = (char*)mir_alloc(1*sizeof(char)); + temp[0] = '\0'; + + while (head) + { + temp = (char*)mir_realloc(temp, strlen(temp) + strlen(string) + replen + 1); + if (!temp) mir_tstrdup(value); + + strncat(temp, string, (head - string)); + string = head + len; + strcat(temp, replace); + + head = (cs?strstr(string, find):StrStrI(string, find)); + } + strcat(temp, string); + + return temp; + } + + return mir_tstrdup(value); +} + + +int replaceValue(HWND hwnd, HANDLE hContact, const char *module, const char *setting, DBVARIANT *dbv, const char *find, const char *replace, int mode) +{ + + int count = 0; + + DWORD num = 0; + BOOL write = 0; + int isNumeric; + char *myreplace = NULL; + DBCONTACTWRITESETTING cws = {0}; + + if (!dbv->type || dbv->type == DBVT_BLOB) + return 0; + + if (!replace[0]) + isNumeric = 1; + else + isNumeric = sscanf(replace,"%d",&num); + + cws.szModule=module; + cws.szSetting=setting; + cws.value.type=dbv->type; + + switch(dbv->type) + { + case DBVT_UTF8: + case DBVT_ASCIIZ: + if (mode & RW_FULL) + cws.value.pszVal = (char*)replace; + else + { + myreplace = multiReplace(dbv->pszVal, find, replace, mode & RW_CASE); + cws.value.pszVal=myreplace; + } + break; + + case DBVT_BYTE: + if (isNumeric && num < 0x100) + cws.value.bVal = (BYTE)num; + else + return 0; + break; + + case DBVT_WORD: + if (isNumeric && num < 0x10000) + cws.value.wVal = (WORD)num; + else + return 0; + break; + + case DBVT_DWORD: + if (isNumeric) + cws.value.dVal = num; + else + return 0; + break; + + default: + return 0; + } + + if ((!cws.value.pszVal && !replace[0]) || (cws.value.pszVal && !cws.value.pszVal[0])) + { + ItemFound(hwnd,hContact,module,setting,NULL,FW_SETTINGNAME|FW_DELETED); + DBDeleteContactSetting(hContact,module,setting); + mir_free(myreplace); + return 1; + } + + if (!CallService(MS_DB_CONTACT_WRITESETTING,(WPARAM)hContact,(LPARAM)&cws)) + { + count++; + ItemFound(hwnd,hContact,module,setting,myreplace?myreplace:(char*)replace,FW_SETTINGVALUE|FW_REPLACED); + } + + mir_free(myreplace); + + return count; +} + + +int replaceSetting(HWND hwnd, HANDLE hContact, const char *module, const char *setting, DBVARIANT *dbv, const char *find, const char *replace, int mode) +{ + DBCONTACTWRITESETTING cws; + char *myreplace = NULL; + int count = 0; + DBVARIANT dbv2; + + if (!dbv->type) return 0; + + if (mode & RW_FULL) + cws.szSetting = (char*)replace; + else + { + myreplace = multiReplace(setting, find, replace, mode & RW_CASE); + cws.szSetting = myreplace; + } + + if (cws.szSetting[0]==0) + { + ItemFound(hwnd,hContact,module,setting,NULL,FW_SETTINGNAME|FW_DELETED); + DBDeleteContactSetting(hContact,module,setting); + mir_free(myreplace); + return 1; + } + + // check & write + if (GetSetting(hContact, module, myreplace, &dbv2)) + { + cws.szModule=module; + cws.value.type=dbv->type; + cws.value.pszVal=dbv->pszVal; + cws.value.bVal=dbv->bVal; + cws.value.wVal=dbv->wVal; + cws.value.dVal=dbv->dVal; + cws.value.pbVal = dbv->pbVal; + cws.value.cpbVal = dbv->cpbVal; + + if (!CallService(MS_DB_CONTACT_WRITESETTING,(WPARAM)hContact,(LPARAM)&cws)) + { + count++; + DBDeleteContactSetting(hContact,module,setting); + ItemFound(hwnd,hContact,module,cws.szSetting,NULL,FW_SETTINGNAME|FW_REPLACED); + } + } + else + DBFreeVariant(&dbv2); + + mir_free(myreplace); + + return count; +} + + +int replaceModule(HWND hwnd, HANDLE hContact, const char *module, const char *find, const char *replace, int mode) +{ + + ModuleSettingLL msll; + struct ModSetLinkLinkItem *setting; + char *myreplace = NULL; + char *newModule; + int count = 0; + + if (mode & RW_FULL) + newModule = (char*)replace; + else + { + myreplace = multiReplace(module, find, replace, mode & RW_CASE); + newModule = myreplace; + } + + if (newModule[0]==0) + { + ItemFound(hwnd,hContact,module,NULL,NULL,FW_MODULE|FW_DELETED); + deleteModule((char*)module, hContact, 1); + replaceTreeItem(GetDlgItem(hwnd2mainWindow,IDC_MODULES), hContact, module, NULL); + mir_free(myreplace); + return 1; + } + + if (!IsModuleEmpty(hContact, newModule)) + return 0; + + if (EnumSettings(hContact,(char*)module,&msll)) + { + setting = msll.first; + + while(setting) + { + DBVARIANT dbv; + + if (!GetSetting(hContact, module, setting->name, &dbv)) + { + switch (dbv.type) + { + case DBVT_BYTE: + DBWriteContactSettingByte(hContact, newModule, setting->name, dbv.bVal); + break; + case DBVT_WORD: + DBWriteContactSettingWord(hContact, newModule, setting->name, dbv.wVal); + break; + case DBVT_DWORD: + DBWriteContactSettingDword(hContact, newModule, setting->name, dbv.dVal); + break; + case DBVT_ASCIIZ: + DBWriteContactSettingString(hContact, newModule, setting->name, dbv.pszVal); + break; + case DBVT_UTF8: + DBWriteContactSettingStringUtf(hContact, newModule, setting->name, dbv.pszVal); + break; + case DBVT_BLOB: + DBWriteContactSettingBlob(hContact, newModule, setting->name, dbv.pbVal, dbv.cpbVal); + break; + } + + DBFreeVariant(&dbv); + DBDeleteContactSetting(hContact, module, setting->name); + } + + setting = (struct ModSetLinkLinkItem *)setting->next; + } + FreeModuleSettingLL(&msll); + + replaceTreeItem(GetDlgItem(hwnd2mainWindow,IDC_MODULES), hContact, module, newModule); + + ItemFound(hwnd,hContact,newModule,NULL,NULL,FW_MODULE|FW_REPLACED); + count++; + } + + mir_free(myreplace); + + return count; +} + + +char* stringToUpper(char* in, char* out, int maxlen) +{ + int i; + int len; + + if (maxlen>0) + len = maxlen - 1; + else + len = 0x10000; + + for (i=0;in[i] && i='a' && in[i]<='z')?toupper(in[i]):in[i]; + out[i] = '\0'; + + return out; +} + + +void __cdecl FindSettings(LPVOID di) +{ + char* text = ((FindInfo*)di)->text; + char* replace = ((FindInfo*)di)->replace; + int mode = ((FindInfo*)di)->mode; + HWND hwnd = ((FindInfo*)di)->hwnd; + HWND prnthwnd = GetParent(hwnd); + int options = ((FindInfo*)di)->options; + ModuleSettingLL ModuleList, SettingList; + struct ModSetLinkLinkItem *module, *setting; + HANDLE hContact; + DBVARIANT dbv = {0}; + int caseSensitive = options&FW_CASE; + int exactMatch = options&FW_EXACT; + int inModuleName = options&FW_MODNAME; + int inSettingName = options&FW_SETNAME; + int inSettingValue = options&FW_SETVAL; + int foundCount = 0; + int replaceCount = 0; + char szTmp[128]; + int settingValue, isNumber, NULLContactDone = 0; + + freeItems(hwnd); + if (!text) return; + + if (!EnumModules(&ModuleList)) { msg(Translate("Error Loading Module List"),modFullname); mir_free(di); return;} + + SendMessage(GetDlgItem(GetParent(hwnd),IDC_SBAR),SB_SETTEXT,0,(LPARAM)Translate("Searching...")); + + hContact = 0; + + isNumber = sscanf(text,"%d",&settingValue); + + while (GetWindowLongPtr(GetDlgItem(prnthwnd,IDC_SEARCH),GWLP_USERDATA)) + { + if (!hContact) + { + if (NULLContactDone) break; + else + { + NULLContactDone = 1; + hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + } + } + else hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); + + module = ModuleList.first; + while (module) + { + if (IsModuleEmpty(hContact, module->name)) + { + module = (struct ModSetLinkLinkItem *)module->next; + continue; + } + + if (!EnumSettings(hContact,module->name,&SettingList)) + { + msg(Translate("Error Loading Setting List"),modFullname); + mir_free(text); + mir_free(di); + FreeModuleSettingLL(&ModuleList); + return; + } + setting = SettingList.first; + + // check in settings value + while (setting) + { + if (inSettingValue) + { + dbv.type = 0; + // check the setting value + if (!GetSetting(hContact,module->name,setting->name,&dbv)) + { + switch (dbv.type) + { + case DBVT_UTF8: // no conversion atm + case DBVT_ASCIIZ: + if ((exactMatch && !(caseSensitive?strcmp(dbv.pszVal,text):strcmpi(dbv.pszVal,text))) || (!exactMatch && (caseSensitive?strstr(dbv.pszVal,text):StrStrI(dbv.pszVal,text)))) + { + if ((mode & RW_FOUND) || (mode & RW_SETVAL)) + replaceCount += replaceValue(hwnd, hContact, module->name, setting->name, &dbv, text, replace, mode); + else + ItemFound(hwnd,hContact,module->name,setting->name,dbv.pszVal,FW_SETTINGVALUE); + + foundCount++; + } + break; + + case DBVT_BYTE: + if (isNumber && settingValue == dbv.bVal) + { + if ((mode & RW_FOUND) || (mode & RW_SETVAL)) + replaceCount += replaceValue(hwnd, hContact, module->name, setting->name, &dbv, NULL, replace, mode); + else + ItemFound(hwnd,hContact,module->name,setting->name,text,FW_SETTINGVALUE); + foundCount++; + } + break; + + case DBVT_WORD: + if (isNumber && settingValue == dbv.wVal) + { + if ((mode & RW_FOUND) || (mode & RW_SETVAL)) + replaceCount += replaceValue(hwnd, hContact, module->name, setting->name, &dbv, NULL, replace, mode); + else + ItemFound(hwnd,hContact,module->name,setting->name,text,FW_SETTINGVALUE); + foundCount++; + } + break; + + case DBVT_DWORD: + if (isNumber && settingValue == (int)dbv.dVal) + { + if ((mode & RW_FOUND) || (mode & RW_SETVAL)) + replaceCount += replaceValue(hwnd, hContact, module->name, setting->name, &dbv, NULL, replace, mode); + else + ItemFound(hwnd,hContact,module->name,setting->name,text,FW_SETTINGVALUE); + foundCount++; + } + break; + + } + DBFreeVariant(&dbv); + } + } + + // check in setting name + if (inSettingName) + { + if ((exactMatch && !(caseSensitive?strcmp(setting->name,text):strcmpi(setting->name,text))) || (!exactMatch && (caseSensitive?StrStrI(setting->name,text):StrStrI(setting->name,text)))) + { + if ((mode & RW_FOUND) || (mode & RW_SETNAME)) + { + if (!GetSetting(hContact,module->name,setting->name,&dbv)) + { + replaceCount += replaceSetting(hwnd, hContact, module->name, setting->name, &dbv, text, replace, mode); + DBFreeVariant(&dbv); + } + } + else + ItemFound(hwnd,hContact,module->name,setting->name, NULL, FW_SETTINGNAME); + foundCount++; + } + } + + setting = (struct ModSetLinkLinkItem *)setting->next; + } + + // check in module name + if (inModuleName) + { + if ((exactMatch && !(caseSensitive?strcmp(module->name,text):strcmpi(module->name,text))) || (!exactMatch && (caseSensitive?strstr(module->name,text):StrStrI(module->name,text)))) + { + if ((mode & RW_FOUND) || (mode & RW_MODULE)) + replaceCount += replaceModule(hwnd, hContact, module->name, text, replace, mode); + else + ItemFound(hwnd,hContact,module->name,0, 0, FW_MODULE); + foundCount++; + } + } + + FreeModuleSettingLL(&SettingList); + module = (struct ModSetLinkLinkItem *)module->next; + } + } + + if (mode) + { + if (!replace[0]) + mir_snprintf(szTmp, SIZEOF(szTmp), Translate("Finished. %d items were found, %d items were deleted."), foundCount, replaceCount); + else + mir_snprintf(szTmp, SIZEOF(szTmp), Translate("Finished. %d items were found, %d items were replaced."), foundCount, replaceCount); + } + else + mir_snprintf(szTmp, SIZEOF(szTmp), Translate("Finished. %d items were found."), foundCount); + + SendMessage(GetDlgItem(prnthwnd,IDC_SBAR),SB_SETTEXT,0,(LPARAM)szTmp); + + SetWindowLongPtr(GetDlgItem(prnthwnd,IDC_SEARCH),GWLP_USERDATA,0); + + if (GetWindowLongPtr(GetDlgItem(prnthwnd,IDC_REPLACE),GWLP_USERDATA)) + { + SetWindowLongPtr(GetDlgItem(prnthwnd,IDC_REPLACE),GWLP_USERDATA, 0); + EnableWindow(GetDlgItem(prnthwnd,IDC_SEARCH),1); + SetWindowText(GetDlgItem(prnthwnd,IDOK),Translate("&Replace")); + } + else + { + SetWindowText(GetDlgItem(prnthwnd,IDC_SEARCH),Translate("&Search")); + EnableWindow(GetDlgItem(prnthwnd,IDOK),1); + } + + mir_free(replace); + mir_free(text); + mir_free(di); + FreeModuleSettingLL(&ModuleList); + + EnableWindow(GetDlgItem(prnthwnd,IDCANCEL),1); + +} diff --git a/plugins/DbeditorPP/headers.h b/plugins/DbeditorPP/headers.h new file mode 100644 index 0000000000..0815c16c10 --- /dev/null +++ b/plugins/DbeditorPP/headers.h @@ -0,0 +1,257 @@ +#ifndef _COMMONHEADERS_H +#define _COMMONHEADERS_H +//===================================================== +// Includes +//===================================================== + +#define _WIN32_WINNT 0x0501 +#define MIRANDA_VER 0x0A00 + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "m_toptoolbar.h" + +#include "resource.h" +#include "Version.h" +#include "modsettingenum.h" + +#define DEF_ICON 7 +#define crlf_string "\r\n\0" + +/////// icons support + +void addIcons(TCHAR* szModuleFileName); +HICON LoadSkinnedDBEIcon(int icon); +int AddIconToList(HIMAGELIST hil, HICON hIcon); +void AddProtoIconsToList(HIMAGELIST hil, int newshift); +int GetProtoIcon(char *szProto); +extern HANDLE hRestore; +extern HANDLE hUserMenu; +///////////////////// + +#ifndef NDEBUG + #define new new(_NORMAL_BLOCK, __FILE__, __LINE__) +#endif + +//======================================================= +// Definitions +//======================================================= +#define modname "DBEditorpp" +#define modFullname "Database Editor++" +#define msg(a,b) MessageBoxA(0,a,b,MB_OK) +#define nick_unknown "(UNKNOWN)" +#define nick_unknownW L"(UNKNOWN)" + + +#define WM_FINDITEM (WM_USER+1) // onyl for the main window, wparam is ItemIfno* lparam is 0 + +#define mir_strlen(ptr) ((ptr==NULL)?0:(int)strlen(ptr)) +#define mir_strncpy(dst, src, len) strncpy(dst, src, len)[len-1]=0; +#define mir_strcmp(ptr1, ptr2) ((ptr1 && ptr2)?strcmp(ptr1, ptr2):1) // (ptr1||ptr2) + +#define ListView_SetItemTextW(hwndLV, i, iSubItem_, pszText_) \ +{ LV_ITEMW _ms_lvi;\ + _ms_lvi.iSubItem = iSubItem_;\ + _ms_lvi.pszText = pszText_;\ + SendMessageW((hwndLV), LVM_SETITEMTEXTW, (WPARAM)(i), (LPARAM)(LV_ITEMW *)&_ms_lvi);\ +} + +#define ListView_InsertItemW(hwnd, pitem) \ + SendMessageW((hwnd), LVM_INSERTITEMW, 0, (LPARAM)(const LV_ITEMW *)(pitem)) + + +#define TreeView_InsertItemW(hwnd, lpis) \ + (HTREEITEM)SendMessageW((hwnd), TVM_INSERTITEMW, 0, (LPARAM)(LPTV_INSERTSTRUCTW)(lpis)) + +/*********************** + ModuleTreeInfoStruct + this gets dumped as the lparam for each module tree item +************************/ +// types +#define CONTACT_ROOT_ITEM 0 +#define CONTACT 1 +#define MODULE 0x2 +#define KNOWN_MODULE 2 +#define UNKNOWN_MODULE 3 +#define STUB 4 +#define EMPTY 8 + +typedef struct { + int type; // from above types + HANDLE hContact; +} ModuleTreeInfoStruct; + +typedef struct { + HANDLE hContact; + char* module; + HWND hwnd2Edit; + int selectedItem; // item that is currently selected + int clicks; // set to 0 when selection changes, 1 after another click.. cant edit till this is 1 +} SettingListInfo; + +#define WATCH_MODULE 1 +#define WATCH_SETTING 0 + +struct DBsetting { + DBVARIANT dbv; + HANDLE hContact; + char *module; + char *setting; + int WatchModule; // above defines +}; + +typedef struct { + char module[256]; + HANDLE hContact; +} ModuleAndContact; + +// find window +#define FW_MODULE 0 +#define FW_SETTINGNAME 1 +#define FW_SETTINGVALUE 2 + +typedef struct { + int type; // above types + HANDLE hContact; + char module[256]; + char setting[256]; +} ItemInfo; + +// watchwindow +struct WatchListArrayStruct{ + struct DBsetting *item; // gotta malloc this + int count; + int size; +}; +extern WatchListArrayStruct WatchListArray; + +//======================================================= +// Variables +//======================================================= +extern HINSTANCE hInst; +extern HWND hwnd2mainWindow, hwnd2watchedVarsWindow, hwnd2importWindow; +extern HIMAGELIST himl; +extern HIMAGELIST himl2; +extern int Mode; +extern int Hex; +extern int Order; +extern BOOL UDB, UOS; + +extern BOOL usePopUps; + +#define NAMEORDERCOUNT 8 + +#define MODE_UNLOADED 1 +#define MODE_LOADED 2 +#define MODE_ALL 3 + +#define HEX_BYTE 1 +#define HEX_WORD 2 +#define HEX_DWORD 4 + +//main.c +int DBGetContactSettingStringStatic(HANDLE hContact, char* szModule, char* szSetting, char* value, int maxLength); +int WriteBlobFromString(HANDLE hContact,const char *szModule,const char *szSetting, const char *Value, int len); +int GetSetting(HANDLE hContact, const char *szModule, const char *szSetting, DBVARIANT *dbv); +int GetValue(HANDLE hContact, const char* szModule, const char* szSetting, char* Value, int length); +int GetValueW(HANDLE hContact, const char* szModule, const char* szSetting, WCHAR* Value, int length); +char* u2a( wchar_t* src ); +wchar_t *a2u( char* src , wchar_t *buffer, int len ); +int mir_snwprintf(WCHAR *buffer, size_t count, const WCHAR* fmt, ...); +WCHAR *GetContactName(HANDLE hContact, const char *szProto, int unicode); +BOOL IsProtocolLoaded(char* pszProtocolName); + +// main_window.c +INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); + +// modules.c +int deleteModule(char* module, HANDLE hContact, int fromMenu); +void deleteModuleGui(); +void renameModule(char* oldName, char* newName, HANDLE hContact); +INT_PTR CALLBACK AddModDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); +int CloneContact(HANDLE hContact); + +// moduletree.c +void replaceTreeItem(HWND hwnd, HANDLE hContact, const char *module, const char *newModule); +void refreshTree(BOOL restore); +void __cdecl PopulateModuleTreeThreadFunc(LPVOID di); +void freeTree(HWND hwnd2Tree, HANDLE hContact); +int findItemInTree(HWND hwnd2Tree, HANDLE hContact, char* module); + +// settinglist.c +void setupSettingsList(HWND hwnd2List); +void saveListSettings(HWND hwnd2List); +void ClearListview(HWND hwnd2Settings); +void DeleteSettingsFromList(HWND hSettings, HANDLE hContact, char *module, char *setting); +void PopulateSettings(HWND hwnd2Settings, HANDLE hContact, char* module); +void SelectSetting(char* setting); + +// addeditsettingsdlg.c +INT_PTR CALLBACK EditSettingDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); +void editSetting(HANDLE hContact, char* module, char* setting); +BOOL convertSetting(HANDLE hContact, char* module, char* setting, int toType); // 0 = byte, 1 = word, 2 = dword, 3 = string + +// exportimport.c +void exportDB(HANDLE hContact, char* module); // hContact == -1 export entire db. module == NULL export entire contact +void ImportSettingsMenuItem(HANDLE hContact); +void ImportSettingsFromFileMenuItem(HANDLE hContact, char* FilePath); + +// find window.c +INT_PTR CALLBACK FindWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); + +// knownmodules.c +extern BYTE UseKnownModList; +INT_PTR RegisterModule(WPARAM wParam, LPARAM lParam); +INT_PTR RegisterSingleModule(WPARAM wParam, LPARAM lParam); +void FreeKnownModuleList(); +int IsModuleKnown(char* moduleName); +void doOldKnownModulesList(); + +// copymodule.c +void copyModuleMenuItem(char* module, HANDLE hContact); +void copyModule(char* module, HANDLE hContactFrom, HANDLE hContactTo); + +// options.c +int OptInit(WPARAM wParam,LPARAM lParam); + +// watchlist +int addSettingToWatchList(HANDLE hContact, char* module, char* setting); +void freeWatchListItem(int item); +void PopulateWatchedWindow(HWND hwnd); +void freeAllWatches(); +INT_PTR CALLBACK WatchDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); +void popupWatchedVar(HANDLE hContact,const char* module,const char* setting); + +#endif //_COMMONHEADERS_H \ No newline at end of file diff --git a/plugins/DbeditorPP/icons.cpp b/plugins/DbeditorPP/icons.cpp new file mode 100644 index 0000000000..6da3723bfe --- /dev/null +++ b/plugins/DbeditorPP/icons.cpp @@ -0,0 +1,143 @@ +#include "headers.h" + +HIMAGELIST himl; + +void addIcons(TCHAR* szModuleFileName) +{ + SKINICONDESC sid={0}; + char name[32]; + sid.cbSize = sizeof(sid); + sid.ptszSection = _T(modFullname); + sid.ptszDefaultFile = szModuleFileName; + sid.flags = SIDF_ALL_TCHAR; + + // closed known module + sid.ptszDescription = LPGENT("Closed Known Module"); + mir_snprintf(name, SIZEOF(name), "DBE++_%d", ICO_KNOWN); + sid.pszName = name; + sid.iDefaultIndex = -ICO_KNOWN; + Skin_AddIcon(&sid); + + // open known module + sid.ptszDescription = LPGENT("Open Known Module"); + mir_snprintf(name, SIZEOF(name), "DBE++_%d", ICO_KNOWNOPEN); + sid.pszName = name; + sid.iDefaultIndex = -ICO_KNOWNOPEN; + Skin_AddIcon(&sid); + + // closed unknown module + sid.ptszDescription = LPGENT("Closed Unknown Module"); + mir_snprintf(name, SIZEOF(name), "DBE++_%d", ICO_UNKNOWN); + sid.pszName = name; + sid.iDefaultIndex = -ICO_UNKNOWN; + Skin_AddIcon(&sid); + + // open unknown module + sid.ptszDescription = LPGENT("Open Unknown Module"); + mir_snprintf(name, SIZEOF(name), "DBE++_%d", ICO_UNKNOWNOPEN); + sid.pszName = name; + sid.iDefaultIndex = -ICO_UNKNOWNOPEN; + Skin_AddIcon(&sid); + + // settings contact + sid.ptszDescription = LPGENT("Settings"); + mir_snprintf(name, SIZEOF(name), "DBE++_%d", ICO_SETTINGS); + sid.pszName = name; + sid.iDefaultIndex = -ICO_SETTINGS; + Skin_AddIcon(&sid); + + // contact group + sid.ptszDescription = LPGENT("Contacts Group"); + mir_snprintf(name, SIZEOF(name), "DBE++_%d", ICO_CONTACTS); + sid.pszName = name; + sid.iDefaultIndex = -ICO_CONTACTS; + Skin_AddIcon(&sid); + + // unknwon contact + sid.ptszDescription = LPGENT("Unknown Contact"); + mir_snprintf(name, SIZEOF(name), "DBE++_%d", ICO_OFFLINE); + sid.pszName = name; + sid.iDefaultIndex = -ICO_OFFLINE; + Skin_AddIcon(&sid); + + // known contact + sid.ptszDescription = LPGENT("Known Contact"); + mir_snprintf(name, SIZEOF(name), "DBE++_%d", ICO_ONLINE); + sid.pszName = name; + sid.iDefaultIndex = -ICO_ONLINE; + Skin_AddIcon(&sid); +} + +HICON LoadSkinnedDBEIcon(int icon) +{ + char name[32]; + mir_snprintf(name, SIZEOF(name), "DBE++_%d", icon); + HICON hIcon = (HICON)CallService(MS_SKIN2_GETICON,0,(LPARAM)name); + return (hIcon) ? hIcon : LoadIcon(hInst, MAKEINTRESOURCE(icon)); +} + + +int AddIconToList(HIMAGELIST hil, HICON hIcon) +{ + if (!hIcon || !hil) + return 0; + + ImageList_AddIcon(hil, hIcon); + return 1; +} + +static PROTOCOLDESCRIPTOR **protocols = NULL; +static int protoCount = 0; +static int shift = 0; + +void AddProtoIconsToList(HIMAGELIST hil, int newshift) +{ + shift = newshift; + + CallService(MS_PROTO_ENUMPROTOCOLS,(WPARAM)&protoCount,(LPARAM)&protocols); + + for (int i = 0; i < protoCount; i++) { + if (protocols[i]->type != PROTOTYPE_PROTOCOL) + continue; + + HICON hIcon; + if (hIcon=LoadSkinnedProtoIcon(protocols[i]->szName, ID_STATUS_ONLINE)) + AddIconToList(hil, hIcon); + else + AddIconToList(himl, LoadSkinnedDBEIcon(ICO_ONLINE)); + } +} + +int GetProtoIcon(char *szProto) +{ + if ( !protoCount || !protocols || !szProto) + return DEF_ICON; + + int n = 0; + + for (int i = 0; i < protoCount; i++) { + if (protocols[i]->type != PROTOTYPE_PROTOCOL) + continue; + + if (!mir_strcmp(protocols[i]->szName, szProto)) + return n + shift; + + n++; + } + + return DEF_ICON; +} + +BOOL IsProtocolLoaded(char* pszProtocolName) +{ + if (protoCount) + for(int i = 0; i < protoCount; i++) { + if (protocols[i]->type != PROTOTYPE_PROTOCOL) + continue; + + if (!mir_strcmp(protocols[i]->szName, pszProtocolName)) + return TRUE; + } + + return FALSE; +} diff --git a/plugins/DbeditorPP/knownmodules.cpp b/plugins/DbeditorPP/knownmodules.cpp new file mode 100644 index 0000000000..13c4379f6b --- /dev/null +++ b/plugins/DbeditorPP/knownmodules.cpp @@ -0,0 +1,84 @@ +#include "headers.h" + +BYTE UseKnownModList; + +#define MAXMODS 1024 +char *KnownModules[MAXMODS]; +int KnownModulesCount = 0; + +INT_PTR RegisterModule(WPARAM wParam, LPARAM lParam) +{ + char **mods = (char**)wParam; + int count = lParam; + int i; + for (i=0;iname,&dbv) && dbv.type == DBVT_ASCIIZ) + { + temp = (char*)mir_alloc((strlen(dbv.pszVal)+5)*sizeof(char)); + if (!temp) break; + strcpy(temp,dbv.pszVal); + strcat(temp,",\0"); + var = strtok(temp,", "); + while (var) + { + if (KnownModulesCountnext; + } + FreeModuleSettingLL(&msll); + + UseKnownModList = DBGetContactSettingByte(NULL,modname,"UseKnownModList",0); +} diff --git a/plugins/DbeditorPP/main.cpp b/plugins/DbeditorPP/main.cpp new file mode 100644 index 0000000000..51c64d0ae7 --- /dev/null +++ b/plugins/DbeditorPP/main.cpp @@ -0,0 +1,669 @@ +#include "headers.h" + +// {A8A417EF-07AA-4f37-869F-7BFD74886534} +#define MIID_DBEDITOR {0xa8a417ef, 0x7aa, 0x4f37, { 0x86, 0x9f, 0x7b, 0xfd, 0x74, 0x88, 0x65, 0x34}} + + +HINSTANCE hInst = NULL; + +HANDLE hTTBButt = NULL; +BOOL bServiceMode = FALSE; +BOOL usePopUps; +HWND hwnd2watchedVarsWindow; +int UDB; +int hLangpack; +BYTE nameOrder[NAMEORDERCOUNT]; +HANDLE hUserMenu; +HANDLE hRestore; +WatchListArrayStruct WatchListArray; +HANDLE sMenuCommand, sRegisterModule, sRegisterSingleModule, sImport, sServicemodeLaunch; +HANDLE hModulesLoadedHook = NULL, hSettingsChangedHook=NULL, hOptInitHook=NULL, hPreShutdownHook=NULL, hTTBHook = NULL; + +//======================== +// MirandaPluginInfo +//======================== +PLUGININFOEX pluginInfoEx={ + sizeof(PLUGININFOEX), + __PLUGIN_NAME, + PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM), + __DESCRIPTION, + __AUTHOR, + __AUTHOREMAIL, + __COPYRIGHT, + __AUTHORWEB, + UNICODE_AWARE, + MIID_DBEDITOR +}; + +extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) +{ + return &pluginInfoEx; +} + +// we implement service mode interface +extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = {MIID_SERVICEMODE, MIID_LAST}; + +//======================== +// WINAPI DllMain +//======================== +BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved) +{ + hInst=hinstDLL; + return TRUE; +} + +void settingChanged(HWND hwnd2Settings, HANDLE hContact, char* module, char* setting); + +int DBSettingChanged(WPARAM wParam,LPARAM lParam) +{ + DBCONTACTWRITESETTING *cws=(DBCONTACTWRITESETTING*)lParam; + HANDLE hContact = (HANDLE)wParam; + char *setting; + int i; + SettingListInfo* info; + + if (hwnd2mainWindow) + { + HWND hwnd2Settings = GetDlgItem(hwnd2mainWindow, IDC_SETTINGS); + if (info = (SettingListInfo*)GetWindowLongPtr(hwnd2Settings,GWLP_USERDATA)) + { + if ((hContact == info->hContact) && !mir_strcmp(info->module, cws->szModule)) + { + setting = mir_strdup(cws->szSetting); + if (cws->value.type == DBVT_DELETED) + { + LVFINDINFO lvfi; + int index; + lvfi.flags = LVFI_STRING; + lvfi.psz = setting; + lvfi.vkDirection = VK_DOWN; + index = ListView_FindItem(hwnd2Settings,-1,&lvfi); + if (index > -1) + ListView_DeleteItem(hwnd2Settings, index); + mir_free(setting); + return 0; + } + settingChanged(hwnd2Settings, hContact, info->module, setting); + mir_free(setting); + } + } + } + // watch list + if (!hwnd2watchedVarsWindow && !usePopUps) return 0; + + for (i=0; iszModule, WatchListArray.item[i].module)) + { + if (!WatchListArray.item[i].setting || !mir_strcmp(cws->szSetting, WatchListArray.item[i].setting)) + { + if (usePopUps) + popupWatchedVar(hContact, cws->szModule, cws->szSetting); + if (hwnd2watchedVarsWindow) + PopulateWatchedWindow(GetDlgItem(hwnd2watchedVarsWindow, IDC_VARS)); + break; + } + } + } + } + return 0; +} + +INT_PTR DBEditorppMenuCommand(WPARAM wParam, LPARAM lParam) +{ + + if (!hwnd2mainWindow) // so only opens 1 at a time + { + hRestore = (HANDLE)wParam; + SetCursor(LoadCursor(NULL,IDC_WAIT)); + CreateDialog(hInst, MAKEINTRESOURCE(IDD_MAIN), 0, MainDlgProc); + } + else + { + ShowWindow(hwnd2mainWindow, SW_RESTORE); + SetForegroundWindow(hwnd2mainWindow); + if (!hRestore && wParam) { + hRestore = (HANDLE)wParam; + refreshTree(4); + } + } + + if (hTTBButt) + CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)hTTBButt, (LPARAM)(TTBST_RELEASED)); + + return 0; +} + +BOOL IsCP_UTF8(void) +{ + CPINFO CPInfo; + + return GetCPInfo(CP_UTF8, &CPInfo); +} + +static int OnTTBLoaded(WPARAM wParam,LPARAM lParam) +{ + TTBButton ttbb = {0}; + HICON ico = LoadIcon(hInst, MAKEINTRESOURCE(ICO_DBE_BUTT)); + UnhookEvent(hTTBHook); + + ttbb.cbSize = sizeof(ttbb); + ttbb.dwFlags = TTBBF_VISIBLE | TTBBF_SHOWTOOLTIP; + ttbb.pszService = "DBEditorpp/MenuCommand"; + ttbb.name = LPGEN("Database Editor++"); + ttbb.hIconUp = ico; + ttbb.pszTooltipUp = LPGEN("Show DataBase Editor"); + hTTBButt = TopToolbar_AddButton(&ttbb); + return 0; +} + +int ModulesLoaded(WPARAM wParam,LPARAM lParam) +{ + DBVARIANT dbv; + char *coreMods = ""; + char *mods; + char mod[64] = ""; + TCHAR szModuleFileName[MAX_PATH]; + int i=0, len; + if (!DBGetContactSetting(NULL,modname,"CoreModules",&dbv) && dbv.type == DBVT_ASCIIZ) + mods = dbv.pszVal; + else + { + DBWriteContactSettingString(NULL,modname,"CoreModules",coreMods); + mods = coreMods; + } + + len = (int)strlen(mods); + while (i < len) + { + if (mods[i] == '\\' && mods[i+1] == ' ') + { + strcat(mod," "); + i++; + } + else if (mods[i] == ' ' || mods[i] == ',' || mods[i] == '\r' || mods[i] == '\n'|| mods[i] == '\0') + { + if (mod[0]) + CallService("DBEditorpp/RegisterSingleModule",(WPARAM)mod,0); + mod[0] = '\0'; + } + else strncat(mod,&mods[i],1); + i++; + } + if (mod[0]) CallService("DBEditorpp/RegisterSingleModule",(WPARAM)mod,0); + + doOldKnownModulesList(); // add the old plugins which havnt been changed over yet.. + + // icons + if (GetModuleFileName(hInst, szModuleFileName, MAX_PATH)) + addIcons(szModuleFileName); + + DBFreeVariant(&dbv); + UnhookEvent(hModulesLoadedHook); + + usePopUps = DBGetContactSettingByte(NULL,modname,"UsePopUps",0); + + // Load the name order + for(i=0;i='0' && b<='9') || + (b>='A' && b<='F') || + (b>='a' && b<='f')) + { + if (sscanf(&szValue[j], "%02X", &tmp) == 1) + { + data[i++] = (BYTE)tmp; + j++; + } + } + j++; + } + + if (i) + return DBWriteContactSettingBlob(hContact,szModule,szSetting, data, (WORD)i); + + return 0; +} + + +int GetSetting(HANDLE hContact, const char *szModule, const char *szSetting, DBVARIANT *dbv) +{ + DBCONTACTGETSETTING cgs; + + cgs.szModule=szModule; + cgs.szSetting=szSetting; + cgs.pValue=dbv; + dbv->type = 0; + + if (UDB) + return CallService(MS_DB_CONTACT_GETSETTING_STR,(WPARAM)hContact,(LPARAM)&cgs); + else + { + int rr = CallService(MS_DB_CONTACT_GETSETTING,(WPARAM)hContact,(LPARAM)&cgs); + + if (dbv->type != DBVT_UTF8) + return rr; + else + return 1; + } +} + + +int GetValue(HANDLE hContact, const char* szModule, const char* szSetting, char* Value, int length) +{ + DBVARIANT dbv = {0}; + + if (Value && length >= 10 && !GetSetting(hContact, szModule, szSetting, &dbv)) + { + switch(dbv.type) { + case DBVT_UTF8: + if (UOS) + { + int len = (int)strlen(dbv.pszVal)+1; + char *sz = (char*)_alloca(len*3); + WCHAR *wc = (WCHAR*)_alloca(len*sizeof(WCHAR)); + MultiByteToWideChar(CP_UTF8, 0, dbv.pszVal, -1, wc, len); + WideCharToMultiByte(CP_ACP, 0, wc, -1, sz, len, NULL, NULL); + strncpy(Value, sz, length); + break; + }// else fall through + case DBVT_ASCIIZ: + strncpy(Value, dbv.pszVal, length); + break; + case DBVT_DWORD: + _itoa(dbv.dVal,Value,10); + break; + case DBVT_BYTE: + _itoa(dbv.bVal,Value,10); + break; + case DBVT_WORD: + _itoa(dbv.wVal,Value,10); + break; + } + + DBFreeVariant(&dbv); + + Value[length-1] = 0; + return 1; + } + + if (Value) + Value[0] = 0; + + return 0; +} + + +int GetValueW(HANDLE hContact, const char* szModule, const char* szSetting, WCHAR* Value, int length) +{ + DBVARIANT dbv ={0}; + + if (Value && length >= 10 && !GetSetting(hContact, szModule, szSetting, &dbv)) + { + switch(dbv.type) { + case DBVT_UTF8: + { + int len = (int)strlen(dbv.pszVal) + 1; + WCHAR *wc = (WCHAR*)_alloca(length*sizeof(WCHAR)); + MultiByteToWideChar(CP_UTF8, 0, dbv.pszVal, -1, wc, len); + wcsncpy((WCHAR*)Value, wc, length); + } + break; + case DBVT_ASCIIZ: + { + int len = (int)strlen(dbv.pszVal) + 1; + WCHAR *wc = (WCHAR*)_alloca(len*sizeof(WCHAR)); + MultiByteToWideChar(CP_ACP, 0, dbv.pszVal, -1, wc, len); + wcsncpy((WCHAR*)Value, wc, length); + } + break; + case DBVT_DWORD: + _itow(dbv.dVal,Value,10); + break; + case DBVT_BYTE: + _itow(dbv.bVal,Value,10); + break; + case DBVT_WORD: + _itow(dbv.wVal,Value,10); + break; + } + + DBFreeVariant(&dbv); + + Value[length-1] = 0; + return 1; + } + + if (Value) + Value[0] = 0; + + return 0; +} + + +char *u2a( wchar_t* src ) +{ + if (src) + { + int cbLen = WideCharToMultiByte( CP_ACP, 0, src, -1, NULL, 0, NULL, NULL ); + char* result = (char*)mir_calloc((cbLen+1)*sizeof(char)); + if ( result == NULL ) + return NULL; + + WideCharToMultiByte( CP_ACP, 0, src, -1, result, cbLen, NULL, NULL ); + result[ cbLen ] = 0; + return result; + } + else + return NULL; +} + + +wchar_t *a2u( char* src , wchar_t *buffer, int len ) +{ + wchar_t *result = buffer; + if ( result == NULL || len < 3) + return NULL; + + MultiByteToWideChar( CP_ACP, 0, src, -1, result, len - 1 ); + result[ len - 1 ] = 0; + + return result; +} + +int mir_snwprintf(WCHAR *buffer, size_t count, const WCHAR* fmt, ...) +{ + va_list va; + int len; + + va_start(va, fmt); + len = _vsnwprintf(buffer, count-1, fmt, va); + va_end(va); + + buffer[count-1] = 0; + + return len; +} + + +int GetDatabaseString(HANDLE hContact, const char *szModule, const char* szSetting, WCHAR *Value, int length, BOOL unicode) +{ + if (unicode) + return GetValueW(hContact, szModule, szSetting, Value, length); + else + return GetValue(hContact, szModule, szSetting, (char*)Value, length); +} + + +WCHAR *GetContactName(HANDLE hContact, const char *szProto, int unicode) +{ + + int i, r = 0; + static WCHAR res[512]; + char *proto = (char*)szProto; + char name[256]; + + if (hContact && !proto) + { + if (GetValue(hContact,"Protocol","p",name,SIZEOF(name))) + proto = name; + } + + if (proto) + { + + for(i=0;i 1) + r |= GetDatabaseString(hContact,proto,"LastName",&res[len],SIZEOF(res)-len,unicode); + + break; + } + } + + if (r) return res; + } + } + + if (unicode) + return nick_unknownW; + else + return (WCHAR*)nick_unknown; +} diff --git a/plugins/DbeditorPP/main_window.cpp b/plugins/DbeditorPP/main_window.cpp new file mode 100644 index 0000000000..d7fdb75256 --- /dev/null +++ b/plugins/DbeditorPP/main_window.cpp @@ -0,0 +1,673 @@ +#include "headers.h" + +HWND hwnd2mainWindow; +int Order; +HIMAGELIST himl2; +int Hex; + +#define GC_SPLITTERMOVED (WM_USER+101) + +extern BOOL bServiceMode; + +static WNDPROC SettingListSubClass, ModuleTreeSubClass, SplitterSubClass; + +void moduleListWM_NOTIFY(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam); +void SettingsListWM_NOTIFY(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam); + +int DialogResize(HWND hwnd,LPARAM lParam,UTILRESIZECONTROL *urc) +{ + switch(urc->wId) + { + case IDC_MODULES: + urc->rcItem.right = lParam-3; + urc->rcItem.top = 0; + urc->rcItem.left = 0; + urc->rcItem.bottom = urc->dlgNewSize.cy; + return RD_ANCHORX_CUSTOM|RD_ANCHORY_CUSTOM; + case IDC_SPLITTER: + urc->rcItem.top = 0; + urc->rcItem.bottom = urc->dlgNewSize.cy; + urc->rcItem.right = lParam; + urc->rcItem.left = lParam-3; + return RD_ANCHORX_CUSTOM|RD_ANCHORY_CUSTOM; + case IDC_SETTINGS: + urc->rcItem.top = 0; + urc->rcItem.bottom = urc->dlgNewSize.cy; + urc->rcItem.left = lParam; + urc->rcItem.right = urc->dlgNewSize.cx; + return RD_ANCHORX_CUSTOM|RD_ANCHORY_CUSTOM; + case IDC_VARS: + urc->rcItem.top = 0; + urc->rcItem.bottom = urc->dlgNewSize.cy; + urc->rcItem.left = 0; + urc->rcItem.right = urc->dlgNewSize.cx; + return RD_ANCHORY_CUSTOM|RD_ANCHORX_CUSTOM; + } + return RD_ANCHORX_LEFT|RD_ANCHORY_TOP; + +} + +static LRESULT CALLBACK SplitterSubclassProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam) +{ + switch(msg) { + case WM_NCHITTEST: + return HTCLIENT; + case WM_SETCURSOR: + { RECT rc; + GetClientRect(hwnd,&rc); + SetCursor(rc.right>rc.bottom?LoadCursor(NULL, IDC_SIZENS):LoadCursor(NULL, IDC_SIZEWE)); + return TRUE; + } + case WM_LBUTTONDOWN: + SetCapture(hwnd); + return 0; + case WM_MOUSEMOVE: + if(GetCapture()==hwnd) { + RECT rc; + GetClientRect(hwnd,&rc); + SendMessage(GetParent(hwnd),GC_SPLITTERMOVED,rc.right>rc.bottom?(short)HIWORD(GetMessagePos())+rc.bottom/2:(short)LOWORD(GetMessagePos())+rc.right/2,(LPARAM)hwnd); + } + return 0; + case WM_LBUTTONUP: + ReleaseCapture(); + return 0; + } + return CallWindowProc(SplitterSubClass,hwnd,msg,wParam,lParam); +} +LRESULT CALLBACK ModuleTreeSubclassProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam) +{ + switch(msg) { + case WM_RBUTTONDOWN: + { + TVHITTESTINFO hti; + hti.pt.x=(short)LOWORD(GetMessagePos()); + hti.pt.y=(short)HIWORD(GetMessagePos()); + ScreenToClient(hwnd,&hti.pt); + + if(TreeView_HitTest(hwnd,&hti)) + { + if(hti.flags&TVHT_ONITEM) + TreeView_SelectItem(hwnd, hti.hItem); + } + } + break; + case WM_CHAR: + if (GetKeyState(VK_CONTROL)&0x8000 && wParam == 6) + CreateDialog(hInst, MAKEINTRESOURCE(IDD_FIND), hwnd, FindWindowDlgProc); + break; + case WM_KEYUP: + { + if (wParam == VK_DELETE || + wParam == VK_F2 || + //wParam == VK_UP || + //wParam == VK_DOWN || + wParam == VK_F5 || + wParam == VK_F3) + + { + TVITEM tvi; + char module[256]; + tvi.mask=TVIF_HANDLE|TVIF_PARAM|TVIF_TEXT; + tvi.hItem=TreeView_GetSelection(hwnd); + tvi.pszText = module; + tvi.cchTextMax = 255; + if (TreeView_GetItem(hwnd,&tvi) && tvi.lParam) + { + ModuleTreeInfoStruct *mtis = (ModuleTreeInfoStruct*)tvi.lParam; + HANDLE hContact = mtis->hContact; + if (wParam == VK_DELETE) + { + if ((mtis->type) & MODULE) + { + if (deleteModule(module, hContact,0)) + { + mir_free(mtis); + TreeView_DeleteItem(hwnd,tvi.hItem); + } + } + else if ((mtis->type == CONTACT) && hContact) + { + if (DBGetContactSettingByte(NULL,"CList", "ConfirmDelete",1)) + { + char msg[1024]; + mir_snprintf(msg, SIZEOF(msg), Translate("Are you sure you want to delete contact \"%s\"?"), module); + if (MessageBox(0,msg, Translate("Confirm Contact Delete"), MB_YESNO|MB_ICONEXCLAMATION) == IDNO) + break; + } + CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact,0); + freeTree(hwnd,mtis->hContact); + TreeView_DeleteItem(hwnd,tvi.hItem); + } + } + else if (wParam == VK_F2 && (mtis->type == MODULE || mtis->type == UNKNOWN_MODULE)) + TreeView_EditLabel(hwnd,tvi.hItem); + else if (wParam == VK_F5) + { + refreshTree(1); + break; + } + + else if (wParam == VK_F3) + { + CreateDialog(hInst, MAKEINTRESOURCE(IDD_FIND), hwnd, FindWindowDlgProc); + break; + } + } + } + } + break; + default:break; + } + return CallWindowProc(ModuleTreeSubClass,hwnd,msg,wParam,lParam); +} +static LRESULT CALLBACK SettingListSubclassProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam) +{ + switch(msg) { + case WM_CHAR: + if (GetKeyState(VK_CONTROL)&0x8000 && wParam == 6) + CreateDialog(hInst, MAKEINTRESOURCE(IDD_FIND), hwnd, FindWindowDlgProc); + break; + case WM_KEYDOWN: + if (wParam == VK_DELETE || wParam == VK_F5 || (wParam == VK_F2 && ListView_GetSelectedCount(hwnd) == 1)) + { + char *module, setting[256]; + HANDLE hContact; + SettingListInfo* sli = (SettingListInfo*)GetWindowLongPtr(hwnd,GWLP_USERDATA); + if (!sli) break; + hContact = sli->hContact; + module = sli->module; + ListView_GetItemText(hwnd, ListView_GetSelectionMark(hwnd), 0, setting, 256); + + if (wParam == VK_F2) + editSetting(hContact,module, setting); + else if (wParam == VK_F5) + { + char *szModule = mir_tstrdup(module); // need to do this, otheriwse the setlist stays empty + PopulateSettings(hwnd,hContact,szModule); + mir_free(szModule); + } + else if (wParam == VK_DELETE) + DeleteSettingsFromList(hwnd, hContact, module, setting); + + return 0; + } + else if (wParam == VK_F3) + CreateDialog(hInst, MAKEINTRESOURCE(IDD_FIND), hwnd, FindWindowDlgProc); + break; + + default: break; + } + return CallWindowProc(SettingListSubClass,hwnd,msg,wParam,lParam); +} + +INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch(msg) + { + case WM_INITDIALOG: + { + int i; + HMENU hMenu = GetMenu(hwnd); + + hwnd2mainWindow = hwnd; + // do the icon + SendMessage(hwnd,WM_SETICON,ICON_BIG,(LPARAM)LoadIcon(hInst,MAKEINTRESOURCE(ICO_REGEDIT))); + if (UOS) + SetWindowText(hwnd, Translate("Database Editor++ (unicode mode)")); + else + SetWindowText(hwnd, Translate("Database Editor++ (ansi mode)")); + // setup the splitter + SetWindowLongPtr(GetDlgItem(hwnd,IDC_SPLITTER),GWLP_USERDATA,(LPARAM)DBGetContactSettingWord(NULL, modname, "Splitter", 300)); + SendMessage(hwnd, GC_SPLITTERMOVED, 0,0); + SplitterSubClass=(WNDPROC)SetWindowLongPtr(GetDlgItem(hwnd,IDC_SPLITTER),GWLP_WNDPROC,(LONG)SplitterSubclassProc); + // module tree + TreeView_SetUnicodeFormat(GetDlgItem(hwnd,IDC_MODULES), UOS); + ModuleTreeSubClass=(WNDPROC)SetWindowLongPtr(GetDlgItem(hwnd,IDC_MODULES),GWLP_WNDPROC,(LONG)ModuleTreeSubclassProc); + //setting list + setupSettingsList(GetDlgItem(hwnd,IDC_SETTINGS)); + SettingListSubClass=(WNDPROC)SetWindowLongPtr(GetDlgItem(hwnd,IDC_SETTINGS),GWLP_WNDPROC,(LONG)SettingListSubclassProc); + // traslation stuff + TranslateDialogDefault(hwnd); + TranslateMenu(hMenu); + + for (i=0;i<6;i++) + { + TranslateMenu(GetSubMenu(hMenu,i)); + } + + // move the dialog to the users position + MoveWindow(hwnd,DBGetContactSettingDword(NULL,modname,"x",0),DBGetContactSettingDword(NULL,modname,"y",0),DBGetContactSettingDword(NULL,modname,"width",500),DBGetContactSettingDword(NULL,modname,"height",250),0); + if (DBGetContactSettingByte(NULL,modname,"Maximised",0)) + { + WINDOWPLACEMENT wp; + wp.length = sizeof(WINDOWPLACEMENT); + wp.flags = WPF_RESTORETOMAXIMIZED; + wp.showCmd = SW_SHOWMAXIMIZED; + + SetWindowPlacement(hwnd,&wp); + } + SetCursor(LoadCursor(NULL,IDC_ARROW)); + + Mode = MODE_ALL; + CheckMenuItem(GetSubMenu(hMenu,5),MENU_FILTER_ALL,MF_BYCOMMAND|MF_CHECKED); + + Hex = DBGetContactSettingByte(NULL,modname,"HexMode",0); + CheckMenuItem(GetSubMenu(hMenu,5),MENU_BYTE_HEX,MF_BYCOMMAND|((Hex & HEX_BYTE)?MF_CHECKED:MF_UNCHECKED)); + CheckMenuItem(GetSubMenu(hMenu,5),MENU_WORD_HEX,MF_BYCOMMAND|((Hex & HEX_WORD)?MF_CHECKED:MF_UNCHECKED)); + CheckMenuItem(GetSubMenu(hMenu,5),MENU_DWORD_HEX,MF_BYCOMMAND|((Hex & HEX_DWORD)?MF_CHECKED:MF_UNCHECKED)); + + CheckMenuItem(GetSubMenu(GetMenu(hwnd),5),MENU_SAVE_POSITION,MF_BYCOMMAND|(DBGetContactSettingByte(NULL,modname,"RestoreOnOpen",1)?MF_CHECKED:MF_UNCHECKED)); + + Order = DBGetContactSettingByte(NULL,modname,"SortMode",1); + CheckMenuItem(GetSubMenu(GetMenu(hwnd),5),MENU_SORT_ORDER,MF_BYCOMMAND|(Order?MF_CHECKED:MF_UNCHECKED)); + + + + // image list + { + int numberOfIcons = 0; + himl = NULL; + + if (himl = ImageList_Create(16, 16, IsWinVerXPPlus() ? ILC_COLOR32 | ILC_MASK : ILC_COLOR8 | ILC_MASK, 10, 0)) + { + if (AddIconToList(himl, LoadSkinnedDBEIcon(ICO_SETTINGS))) + numberOfIcons++; + if (AddIconToList(himl, LoadSkinnedDBEIcon(ICO_KNOWN))) + numberOfIcons++; + if (AddIconToList(himl, LoadSkinnedDBEIcon(ICO_KNOWNOPEN))) + numberOfIcons++; + if (AddIconToList(himl, LoadSkinnedDBEIcon(ICO_CONTACTS))) + numberOfIcons++; + if (AddIconToList(himl, LoadSkinnedDBEIcon(ICO_OFFLINE))) + numberOfIcons++; + if (AddIconToList(himl, LoadSkinnedDBEIcon(ICO_UNKNOWN))) + numberOfIcons++; + if (AddIconToList(himl, LoadSkinnedDBEIcon(ICO_UNKNOWNOPEN))) + numberOfIcons++; + if (AddIconToList(himl, LoadSkinnedDBEIcon(ICO_ONLINE))) + numberOfIcons++; + + if (numberOfIcons < DEF_ICON + 1) + { + if (numberOfIcons) + ImageList_Destroy(himl); + himl = NULL; + } + + AddProtoIconsToList(himl, numberOfIcons); + + } + + himl2 = NULL; + numberOfIcons = 0; + + if (himl2 = ImageList_Create(16, 16, IsWinVerXPPlus() ? ILC_COLOR32 | ILC_MASK : ILC_COLOR8 | ILC_MASK, 5, 0)) + { + + if (AddIconToList(himl2, LoadIcon(hInst, MAKEINTRESOURCE(ICO_BINARY)))) + numberOfIcons++; + if (AddIconToList(himl2, LoadIcon(hInst, MAKEINTRESOURCE(ICO_BYTE)))) + numberOfIcons++; + if (AddIconToList(himl2, LoadIcon(hInst, MAKEINTRESOURCE(ICO_WORD)))) + numberOfIcons++; + if (AddIconToList(himl2, LoadIcon(hInst, MAKEINTRESOURCE(ICO_DWORD)))) + numberOfIcons++; + if (AddIconToList(himl2, LoadIcon(hInst, MAKEINTRESOURCE(ICO_STRING)))) + numberOfIcons++; + if (AddIconToList(himl2, LoadIcon(hInst, MAKEINTRESOURCE(ICO_UNICODE)))) + numberOfIcons++; + if (AddIconToList(himl2, LoadIcon(hInst, MAKEINTRESOURCE(ICO_HANDLE)))) + numberOfIcons++; + + if (numberOfIcons < 7) + { + if (numberOfIcons) + ImageList_Destroy(himl2); + himl2 = NULL; + } + } + } + + { + int restore; + + if (hRestore) + restore = 3; + else + if (DBGetContactSettingByte(NULL,modname,"RestoreOnOpen",1)) + restore = 2; + else + restore = 0; + + refreshTree(restore); + } + + } + return TRUE; + case GC_SPLITTERMOVED: + { + POINT pt; + RECT rc; + RECT rc2; + + int splitterPos = GetWindowLongPtr(GetDlgItem(hwnd,IDC_SPLITTER),GWLP_USERDATA); + + GetWindowRect(hwnd,&rc2); + + if ((HWND)lParam==GetDlgItem(hwnd,IDC_SPLITTER)) + { + GetClientRect(hwnd,&rc); + pt.x=wParam; pt.y=0; + ScreenToClient(hwnd,&pt); + + splitterPos=rc.left+pt.x+1; + if (splitterPos<65) splitterPos=65; + if (splitterPos > rc2.right-rc2.left-65) splitterPos=rc2.right-rc2.left-65; + SetWindowLongPtr(GetDlgItem(hwnd,IDC_SPLITTER),GWLP_USERDATA, splitterPos); + DBWriteContactSettingWord(NULL, modname, "Splitter",(WORD)splitterPos); + } + PostMessage(hwnd,WM_SIZE,0,0); + } + break; + case WM_GETMINMAXINFO: + { + MINMAXINFO *mmi=(MINMAXINFO*)lParam; + int splitterPos = GetWindowLongPtr(GetDlgItem(hwnd,IDC_SPLITTER),GWLP_USERDATA); + + if(splitterPos+40 > 200) + mmi->ptMinTrackSize.x=splitterPos+65; + else + mmi->ptMinTrackSize.x=200; + mmi->ptMinTrackSize.y=150; + return 0; + } + case WM_MOVE: + case WM_SIZE: + { + UTILRESIZEDIALOG urd; + + ZeroMemory(&urd,sizeof(urd)); + urd.cbSize=sizeof(urd); + urd.hInstance=hInst; + urd.hwndDlg=hwnd; + urd.lParam=(LPARAM)GetWindowLongPtr(GetDlgItem(hwnd,IDC_SPLITTER),GWLP_USERDATA); + urd.lpTemplate=MAKEINTRESOURCE(IDD_MAIN); + urd.pfnResizer=DialogResize; + CallService(MS_UTILS_RESIZEDIALOG,0,(LPARAM)&urd); + + if (msg == WM_SIZE && wParam == SIZE_MAXIMIZED || wParam == SIZE_MINIMIZED) + { + DBWriteContactSettingByte(NULL,modname,"Maximised",1); + } + else if (msg == WM_SIZE && wParam == SIZE_RESTORED) + { + DBWriteContactSettingByte(NULL,modname,"Maximised",0); + } + + } + break; + case WM_DESTROY: // free our shit! + + if (DBGetContactSettingByte(NULL,modname,"RestoreOnOpen",1)) + { + HTREEITEM item; + HWND hwnd2Tree = GetDlgItem(hwnd,IDC_MODULES); + char module[256] = {0}; + if (item = TreeView_GetSelection(hwnd2Tree)) + { + int type = MODULE; + TVITEM tvi = {0}; + HANDLE hContact = NULL; + tvi.mask=TVIF_HANDLE|TVIF_PARAM|TVIF_TEXT; + tvi.pszText = module; + tvi.cchTextMax = 255; + tvi.hItem=item; + + if (TreeView_GetItem(hwnd2Tree, &tvi)) + { + if (tvi.lParam) + { + ModuleTreeInfoStruct *mtis = (ModuleTreeInfoStruct *)tvi.lParam; + hContact = mtis->hContact; + type = mtis->type; + } + + DBWriteContactSettingDword(NULL,modname,"LastContact",(DWORD)hContact); + + if (type == CONTACT) + DBWriteContactSettingString(NULL,modname,"LastModule",""); + else + DBWriteContactSettingString(NULL,modname,"LastModule",module); + } + else + { + DBDeleteContactSetting(NULL,modname,"LastContact"); + DBDeleteContactSetting(NULL,modname,"LastModule"); + } + + // setting list + { + HWND hwnd2Settings = GetDlgItem(hwnd, IDC_SETTINGS); + int pos = ListView_GetSelectionMark(hwnd2Settings); + + if (pos != -1) + { + char text[256]; + + ListView_GetItemText(hwnd2Settings, pos, 0, text, SIZEOF(text)); + + DBWriteContactSettingString(NULL,modname,"LastSetting",text); + } + else + DBDeleteContactSetting(NULL,modname,"LastSetting"); + } + } + } + DBWriteContactSettingByte(NULL,modname,"HexMode",(byte)Hex); + DBWriteContactSettingByte(NULL,modname,"SortMode",(byte)Order); + saveListSettings(GetDlgItem(hwnd,IDC_SETTINGS)); + hwnd2mainWindow = 0; + ClearListview(GetDlgItem(hwnd,IDC_SETTINGS)); + freeTree(GetDlgItem(hwnd,IDC_MODULES),0); + if (himl) + ImageList_Destroy(himl); + if (himl2) + ImageList_Destroy(himl2); + SetWindowLongPtr(GetDlgItem(hwnd,IDC_SETTINGS),GWLP_WNDPROC,(LONG)SettingListSubClass); + SetWindowLongPtr(GetDlgItem(hwnd,IDC_MODULES),GWLP_WNDPROC,(LONG)ModuleTreeSubClass); + SetWindowLongPtr(GetDlgItem(hwnd,IDC_SPLITTER),GWLP_WNDPROC,(LONG)SplitterSubClass); + if (!DBGetContactSettingByte(NULL,modname,"Maximised",0)) + { + RECT rc; + GetWindowRect(hwnd,&rc); + DBWriteContactSettingDword(NULL,modname,"x",rc.left); + DBWriteContactSettingDword(NULL,modname,"y",rc.top); + DBWriteContactSettingDword(NULL,modname,"width",rc.right-rc.left); + DBWriteContactSettingDword(NULL,modname,"height",rc.bottom-rc.top); + } + if (hwnd2importWindow) { + DestroyWindow(hwnd2importWindow); + hwnd2importWindow = 0; + } + if ( bServiceMode ) { + PostQuitMessage(0); + } + + return 0; + case WM_COMMAND: + if (GetKeyState(VK_ESCAPE) & 0x8000) return TRUE; // this needs to be changed to c if htere is a label edit happening.. + switch(LOWORD(wParam)) + { + case MENU_REFRESH_MODS: + refreshTree(1); + break; + case MENU_REFRESH_SETS: + { + TVITEM tvi; + ModuleTreeInfoStruct *mtis; + char module[256]; + tvi.mask=TVIF_HANDLE|TVIF_PARAM|TVIF_TEXT; + tvi.hItem=TreeView_GetSelection(GetDlgItem(hwnd, IDC_MODULES)); + tvi.pszText = module; + tvi.cchTextMax = 255; + if (!TreeView_GetItem(GetDlgItem(hwnd, IDC_MODULES),&tvi)) break; + if (tvi.lParam) + { + mtis = (ModuleTreeInfoStruct *)tvi.lParam; + if (mtis->type == MODULE || mtis->type == UNKNOWN_MODULE) + PopulateSettings(GetDlgItem(hwnd, IDC_SETTINGS), mtis->hContact, module); + else ClearListview(GetDlgItem(hwnd, IDC_SETTINGS)); + } + else ClearListview(GetDlgItem(hwnd, IDC_SETTINGS)); + } + break; + ///////////////////////// // watches + case MENU_VIEW_WATCHES: + { + if (!hwnd2watchedVarsWindow) // so only opens 1 at a time + hwnd2watchedVarsWindow = CreateDialog(hInst, MAKEINTRESOURCE(IDD_WATCH_DIAG), 0, WatchDlgProc); + else SetForegroundWindow(hwnd2watchedVarsWindow); + } + break; + case MENU_REMALL_WATCHES: + freeAllWatches(); + break; + case MENU_EXPORTDB: // all db + exportDB(INVALID_HANDLE_VALUE,0); + break; + case MENU_EXPORTCONTACT: // all contacts + exportDB(INVALID_HANDLE_VALUE, ""); + break; + case MENU_EXPORTMODULE: // all settings + exportDB(NULL, 0); + break; + case MENU_IMPORTFROMFILE: + ImportSettingsFromFileMenuItem(NULL, ""); + break; + case MENU_IMPORTFROMTEXT: + ImportSettingsMenuItem(NULL); + break; + case MENU_EXIT: + case IDCANCEL: + DestroyWindow(hwnd); + break; + case MENU_DELETE: + deleteModuleGui(); + break; + case MENU_FINDANDREPLACE: + CreateDialog(hInst, MAKEINTRESOURCE(IDD_FIND), hwnd, FindWindowDlgProc); + break; + case MENU_FILTER_ALL: + if (Mode != MODE_ALL) + { + HMENU hMenu = GetMenu(hwnd); + CheckMenuItem(GetSubMenu(hMenu,5),MENU_FILTER_ALL,MF_BYCOMMAND|MF_CHECKED); + CheckMenuItem(GetSubMenu(hMenu,5),MENU_FILTER_LOADED,MF_BYCOMMAND|MF_UNCHECKED); + CheckMenuItem(GetSubMenu(hMenu,5),MENU_FILTER_UNLOADED,MF_BYCOMMAND|MF_UNCHECKED); + Mode = MODE_ALL; + refreshTree(1); + } + break; + case MENU_FILTER_LOADED: + if (Mode != MODE_LOADED) + { + HMENU hMenu = GetMenu(hwnd); + CheckMenuItem(GetSubMenu(hMenu,5),MENU_FILTER_ALL,MF_BYCOMMAND|MF_UNCHECKED); + CheckMenuItem(GetSubMenu(hMenu,5),MENU_FILTER_LOADED,MF_BYCOMMAND|MF_CHECKED); + CheckMenuItem(GetSubMenu(hMenu,5),MENU_FILTER_UNLOADED,MF_BYCOMMAND|MF_UNCHECKED); + Mode = MODE_LOADED; + refreshTree(1); + } + break; + case MENU_FILTER_UNLOADED: + if (Mode != MODE_UNLOADED) + { + HMENU hMenu = GetMenu(hwnd); + CheckMenuItem(GetSubMenu(hMenu,5),MENU_FILTER_ALL,MF_BYCOMMAND|MF_UNCHECKED); + CheckMenuItem(GetSubMenu(hMenu,5),MENU_FILTER_LOADED,MF_BYCOMMAND|MF_UNCHECKED); + CheckMenuItem(GetSubMenu(hMenu,5),MENU_FILTER_UNLOADED,MF_BYCOMMAND|MF_CHECKED); + Mode = MODE_UNLOADED; + refreshTree(1); + } + break; + case MENU_BYTE_HEX: + { + Hex ^= HEX_BYTE; + CheckMenuItem(GetSubMenu(GetMenu(hwnd),5),MENU_BYTE_HEX,MF_BYCOMMAND|((Hex & HEX_BYTE)?MF_CHECKED:MF_UNCHECKED)); + } + break; + case MENU_WORD_HEX: + { + Hex ^= HEX_WORD; + CheckMenuItem(GetSubMenu(GetMenu(hwnd),5),MENU_WORD_HEX,MF_BYCOMMAND|((Hex & HEX_WORD)?MF_CHECKED:MF_UNCHECKED)); + } + break; + case MENU_DWORD_HEX: + { + Hex ^= HEX_DWORD; + CheckMenuItem(GetSubMenu(GetMenu(hwnd),5),MENU_DWORD_HEX,MF_BYCOMMAND|((Hex & HEX_DWORD)?MF_CHECKED:MF_UNCHECKED)); + } + break; + case MENU_SAVE_POSITION: + { + BOOL save = !DBGetContactSettingByte(NULL,modname,"RestoreOnOpen",1); + CheckMenuItem(GetSubMenu(GetMenu(hwnd),5),MENU_SAVE_POSITION,MF_BYCOMMAND|(save?MF_CHECKED:MF_UNCHECKED)); + DBWriteContactSettingByte(NULL,modname,"RestoreOnOpen", (byte)save); + } + break; + case MENU_SORT_ORDER: + Order = !Order; + CheckMenuItem(GetSubMenu(GetMenu(hwnd),5),MENU_SORT_ORDER,MF_BYCOMMAND|(Order?MF_CHECKED:MF_UNCHECKED)); + refreshTree(1); + break; + case MENU_OPEN_OPTIONS: + OPENOPTIONSDIALOG odp = {0}; + odp.cbSize = sizeof(odp); + odp.pszGroup = "Services"; + odp.pszPage = modFullname; + odp.pszTab = 0; + CallService(MS_OPT_OPENOPTIONS,0,(LPARAM)&odp); + break; + } + return TRUE; // case WM_COMMAND + case WM_NOTIFY: + switch(LOWORD(wParam)) + { + case IDC_MODULES: + moduleListWM_NOTIFY(hwnd,msg,wParam,lParam); + break; + case IDC_SETTINGS: + SettingsListWM_NOTIFY(hwnd,msg,wParam,lParam); + break; + } + return TRUE; // case WM_NOTIFY + case WM_FINDITEM: + { + ItemInfo *ii = (ItemInfo*)wParam; + HWND hwnd2Settings = GetDlgItem(hwnd,IDC_SETTINGS); + int hItem = findItemInTree(GetDlgItem(hwnd,IDC_MODULES),ii->hContact,ii->module); + + if (hItem != -1) + { + TreeView_SelectItem(GetDlgItem(hwnd,IDC_MODULES), (HTREEITEM)hItem); + if (ii->type != FW_MODULE) + { + LVITEM lvItem; + LVFINDINFO lvfi; + + lvfi.flags = LVFI_STRING; + lvfi.psz = ii->setting; + lvfi.vkDirection = VK_DOWN; + + lvItem.mask = LVIF_TEXT|LVIF_IMAGE; + lvItem.iItem = ListView_FindItem(hwnd2Settings,-1,&lvfi); + lvItem.iSubItem = 0; + if (lvItem.iItem >= 0) + ListView_SetItemState(hwnd2Settings,lvItem.iItem, LVIS_SELECTED, LVIS_SELECTED); + } + } + } + break; + } // switch(msg) + return 0; +} diff --git a/plugins/DbeditorPP/modsettingenum.cpp b/plugins/DbeditorPP/modsettingenum.cpp new file mode 100644 index 0000000000..7eaecdd1a0 --- /dev/null +++ b/plugins/DbeditorPP/modsettingenum.cpp @@ -0,0 +1,88 @@ +#include "headers.h" + +void FreeModuleSettingLL(ModuleSettingLL* msll) +{ + if (msll) + { + + struct ModSetLinkLinkItem *item = msll->first; + struct ModSetLinkLinkItem *temp; + + while (item) + { + mir_free(item->name); + temp = item; + item = (struct ModSetLinkLinkItem *)item->next; + mir_free(temp); + } + + msll->first = 0; + msll->last = 0; + } +} + +int enumModulesSettingsProc( const char *szName , DWORD ofsModuleName , LPARAM lParam) +{ + ModuleSettingLL *msll = (ModuleSettingLL *)lParam; + if (!msll->first) + { + msll->first = (struct ModSetLinkLinkItem *)mir_alloc(sizeof(struct ModSetLinkLinkItem)); + if (!msll->first) return 1; + msll->first->name = mir_tstrdup(szName); + msll->first->next = 0; + msll->last = msll->first; + } + else + { + struct ModSetLinkLinkItem *item = (struct ModSetLinkLinkItem *)mir_alloc(sizeof(struct ModSetLinkLinkItem)); + if (!item) return 1; + msll->last->next = (BYTE*)item; + msll->last = (struct ModSetLinkLinkItem *)item; + item->name = mir_tstrdup(szName); + item->next = 0; + } + return 0; +} + +int EnumModules(ModuleSettingLL *msll) // 1 = success, 0 = fail +{ + msll->first = 0; + msll->last = 0; + return !CallService(MS_DB_MODULES_ENUM, (WPARAM)msll,(WPARAM)enumModulesSettingsProc); +} + + +int enumSettingsProc(const char *szSetting,LPARAM lParam) +{ + return enumModulesSettingsProc(szSetting,0,lParam); +} + + +int EnumSettings(HANDLE hContact, char* module, ModuleSettingLL *msll) +{ + DBCONTACTENUMSETTINGS dbces; + // enum all setting the contact has for the module + dbces.pfnEnumProc = enumSettingsProc; + dbces.szModule = module; + dbces.lParam = (LPARAM)msll; + msll->first = 0; + msll->last = 0; + return !CallService(MS_DB_CONTACT_ENUMSETTINGS, (WPARAM)hContact,(LPARAM)&dbces); +} + +int CheckIfModuleIsEmptyProc(const char *szSetting,LPARAM lParam) +{ + return 1; +} + +int IsModuleEmpty(HANDLE hContact, char* szModule) +{ + DBCONTACTENUMSETTINGS dbces; + int retVal; + dbces.pfnEnumProc = CheckIfModuleIsEmptyProc; + dbces.szModule = szModule; + retVal = CallService(MS_DB_CONTACT_ENUMSETTINGS, (WPARAM)hContact,(LPARAM)&dbces); + if (retVal >= 0) + return 0; + else return 1; +} \ No newline at end of file diff --git a/plugins/DbeditorPP/modsettingenum.h b/plugins/DbeditorPP/modsettingenum.h new file mode 100644 index 0000000000..0ef32f8cc5 --- /dev/null +++ b/plugins/DbeditorPP/modsettingenum.h @@ -0,0 +1,17 @@ +struct ModSetLinkLinkItem { + char *name; + BYTE *next; //struct ModSetLinkLinkItem + int known; +}; + +typedef struct { + struct ModSetLinkLinkItem *first; + struct ModSetLinkLinkItem *last; +} ModuleSettingLL; + +int EnumModules(ModuleSettingLL *msll); +int EnumSettings(HANDLE hContact, char* module, ModuleSettingLL *msll); + +void FreeModuleSettingLL(ModuleSettingLL *msll); + +int IsModuleEmpty(HANDLE hContact, char* szModule); \ No newline at end of file diff --git a/plugins/DbeditorPP/modules.cpp b/plugins/DbeditorPP/modules.cpp new file mode 100644 index 0000000000..4053180038 --- /dev/null +++ b/plugins/DbeditorPP/modules.cpp @@ -0,0 +1,109 @@ +#include "headers.h" + + +void renameModule(char* oldName, char* newName, HANDLE hContact) +{ + DBVARIANT dbv; + ModuleSettingLL settinglist; + struct ModSetLinkLinkItem *setting; + + if (!EnumSettings(hContact,oldName,&settinglist)) { msg(Translate("Error Loading Setting List"),modFullname); return;} + + setting = settinglist.first; + while (setting) + { + if (!GetSetting(hContact,oldName,setting->name,&dbv)) + { + switch (dbv.type) + { + case DBVT_BYTE: + DBWriteContactSettingByte(hContact, newName, setting->name, dbv.bVal); + break; + case DBVT_WORD: + DBWriteContactSettingWord(hContact, newName, setting->name, dbv.wVal); + break; + case DBVT_DWORD: + DBWriteContactSettingDword(hContact, newName, setting->name, dbv.dVal); + break; + case DBVT_ASCIIZ: + DBWriteContactSettingString(hContact, newName, setting->name, dbv.pszVal); + break; + case DBVT_UTF8: + DBWriteContactSettingStringUtf(hContact, newName, setting->name, dbv.pszVal); + break; + case DBVT_BLOB: + DBWriteContactSettingBlob(hContact, newName, setting->name, dbv.pbVal, dbv.cpbVal); + break; + + } + DBDeleteContactSetting(hContact, oldName, setting->name); + } + DBFreeVariant(&dbv); + setting = (struct ModSetLinkLinkItem *)setting->next; + } + FreeModuleSettingLL(&settinglist); +} + +INT_PTR CALLBACK AddModDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + if (msg == WM_INITDIALOG) + { + SetWindowLongPtr(hwnd,GWLP_USERDATA,lParam); + TranslateDialogDefault(hwnd); + } + if (msg == WM_COMMAND) + { + switch(LOWORD(wParam)) + { + case IDOK: + { + if (GetWindowTextLength(GetDlgItem(hwnd, IDC_MODNAME))) + { + char modulename[256]; + GetDlgItemText(hwnd, IDC_MODNAME, modulename, 256); + if (IsDlgButtonChecked(hwnd,CHK_ADD2ALL)) + { + HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + // null contact + DBWriteContactSettingByte(NULL, modulename, "(Default)", 0); + while (hContact) + { + DBWriteContactSettingByte(hContact, modulename, "(Default)", 0); + hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)(HANDLE)hContact, 0); + } + } + else + { + DBWriteContactSettingByte((HANDLE)GetWindowLongPtr(hwnd,GWLP_USERDATA), modulename, "(Default)", 0); + } + refreshTree(1); + } + } + // fall through + case IDCANCEL: + DestroyWindow(hwnd); + break; + } + } + return 0; +} + +int CloneContact(HANDLE hContact) +{ + HANDLE newContact = (HANDLE)CallService(MS_DB_CONTACT_ADD,0,0); + + ModuleSettingLL modlist; + struct ModSetLinkLinkItem *mod; + if (!newContact) return 0; + // enum all the modules + if (!EnumModules(&modlist)) { msg(Translate("Error Loading Module List"),modFullname); return 0;} + + mod = modlist.first; + while (mod) + { + copyModule(mod->name,hContact,newContact); + mod = (struct ModSetLinkLinkItem *)mod->next; + } + FreeModuleSettingLL(&modlist); + return 1; +} \ No newline at end of file diff --git a/plugins/DbeditorPP/moduletree.cpp b/plugins/DbeditorPP/moduletree.cpp new file mode 100644 index 0000000000..b5554cabc5 --- /dev/null +++ b/plugins/DbeditorPP/moduletree.cpp @@ -0,0 +1,1132 @@ +#include "headers.h" + +static BOOL populating = 0; +int Select = 0; +static ModuleTreeInfoStruct contacts_mtis = {CONTACT_ROOT_ITEM, 0}; +static ModuleTreeInfoStruct settings_mtis = {CONTACT, 0}; + + +int doContacts(HWND hwnd2Tree,HTREEITEM contactsRoot,ModuleSettingLL *modlist, HANDLE hSelectedContact, char *SelectedModule, char *SelectedSetting) +{ + TVINSERTSTRUCT tvi; + char szProto[256]; + HANDLE hContact; + HTREEITEM contact; + ModuleTreeInfoStruct *lParam; + struct ModSetLinkLinkItem *module; + int count = CallService(MS_DB_CONTACT_GETCOUNT, 0, 0); + int itemscount = 0; + int loaded, i = 0, icon = 0; + HWND hwnd = GetParent(hwnd2Tree); + int hItem = -1; + +// char percent[96], title[64]; +// mir_snprintf(title, sizeof(title),Translate("Loading contacts...")); + SetWindowText(hwnd2mainWindow, Translate("Loading contacts...")); + + hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + + tvi.hInsertAfter = TVI_SORT; + tvi.item.cChildren = 1; + + while (hContact && hwnd2mainWindow) // break after null contact + { + + if (GetValue(hContact,"Protocol","p",szProto,SIZEOF(szProto))) + { + icon = GetProtoIcon(szProto); + loaded = (icon != DEF_ICON); + } + else + { + icon = DEF_ICON; + loaded = 0; + } + + i++; + + // filter + if ((loaded && Mode == MODE_UNLOADED) || (!loaded && Mode == MODE_LOADED)) + { + hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); + continue; + } + + // Caption +// mir_snprintf(percent,sizeof(percent),"%s %d%%",title,(int)(100*i/count)); +// SetWindowText(hwnd2mainWindow, percent); + + // add the contact + lParam = (ModuleTreeInfoStruct *)mir_calloc(sizeof(ModuleTreeInfoStruct)); + lParam->hContact = hContact; + lParam->type = CONTACT; + tvi.item.mask = TVIF_TEXT|TVIF_CHILDREN|TVIF_PARAM|TVIF_IMAGE|TVIF_SELECTEDIMAGE; + tvi.item.lParam = (LPARAM)lParam; + tvi.hParent = contactsRoot; + + if (hSelectedContact != hContact) + lParam->type |= EMPTY; + + // contacts name + if (UOS) + { + DBVARIANT dbv ={0}; + WCHAR nick[256]; + WCHAR protoW[256]; // unicode proto + + if (szProto[0]) + a2u(szProto, protoW, SIZEOF(protoW)); + else + protoW[0] = 0; + + if (!szProto[0] || !loaded) + { + tvi.item.iSelectedImage = (tvi.item.iImage = 4); + + if (protoW) + { + if (Order) + mir_snwprintf(nick, SIZEOF(nick), L"(%s) %s %s", protoW, GetContactName(hContact, szProto, 1), L"(UNLOADED)"); + else + mir_snwprintf(nick, SIZEOF(nick), L"%s (%s) %s", GetContactName(hContact, szProto, 1), protoW, L"(UNLOADED)"); + } + else + wcscpy(nick, nick_unknownW); + } + else + { + tvi.item.iSelectedImage = (tvi.item.iImage = icon); //GetProtoIcon(szProto, 7)); + if (Order) + mir_snwprintf(nick, SIZEOF(nick), L"(%s) %s", protoW, GetContactName(hContact, szProto, 1)); + else + mir_snwprintf(nick, SIZEOF(nick), L"%s (%s)", GetContactName(hContact, szProto, 1), protoW); + } + + tvi.item.pszText = (char*)nick; + contact = TreeView_InsertItemW(hwnd2Tree, &tvi); + } + else + { + char nick[256]; + + if (!szProto[0] || !loaded) + { + tvi.item.iSelectedImage = (tvi.item.iImage = 4); + + if (szProto[0]) + { + if (Order) + mir_snprintf(nick, SIZEOF(nick), "(%s) %s %s", szProto, (char*)GetContactName(hContact, szProto, 0), "(UNLOADED)"); + else + mir_snprintf(nick, SIZEOF(nick), "%s (%s) %s", (char*)GetContactName(hContact, szProto, 0), szProto, "(UNLOADED)"); + } + else + strcpy(nick, nick_unknown); + } + else + { + tvi.item.iSelectedImage = (tvi.item.iImage = icon); //GetProtoIcon(szProto, 7)); + if (Order) + mir_snprintf(nick, SIZEOF(nick), "(%s) %s", szProto, (char*)GetContactName(hContact, szProto, 0)); + else + mir_snprintf(nick, SIZEOF(nick), "%s (%s)", (char*)GetContactName(hContact, szProto, 0), szProto); + } + + tvi.item.pszText = nick; + contact = TreeView_InsertItem(hwnd2Tree, &tvi); + } + + itemscount++; + + if (hSelectedContact == hContact) + { + + module = modlist->first; + while(module && hwnd2mainWindow) + { + if (module->name[0] && !IsModuleEmpty(hContact,module->name)) + { + tvi.hParent = contact; + tvi.hInsertAfter = TVI_SORT; + tvi.item.mask = TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_PARAM; + tvi.item.pszText = module->name; + + lParam = (ModuleTreeInfoStruct *)mir_calloc(sizeof(ModuleTreeInfoStruct)); + lParam->hContact = hContact; + + if (!module->known) + { + tvi.item.iImage = 5; + tvi.item.iSelectedImage = 6; + lParam->type = UNKNOWN_MODULE; + } + else + { + tvi.item.iImage = 1; + tvi.item.iSelectedImage = 2; + lParam->type = KNOWN_MODULE; + } + + tvi.item.lParam = (LPARAM)lParam; + TreeView_InsertItem(hwnd2Tree, &tvi); + } + module = (struct ModSetLinkLinkItem *)module->next; + } + + hItem = findItemInTree(hwnd2Tree, hSelectedContact, SelectedModule); + + } + + hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); + } + + + if (hItem != -1) + { + TreeView_SelectItem(hwnd2Tree, (HTREEITEM)hItem); + TreeView_Expand(hwnd2Tree,hItem,TVE_EXPAND); + if (SelectedSetting[0]) SelectSetting(SelectedSetting); + } + +// if (UOS) +// SetWindowText(hwnd, Translate("Database Editor++ (unicode mode)")); +// else +// SetWindowText(hwnd, Translate("Database Editor++ (ansi mode)")); + + + return itemscount; +} + + + +void doItems(HWND hwnd2Tree,ModuleSettingLL *modlist, int count) +{ + TVINSERTSTRUCT tvi; + TVITEM item ={0}; + HANDLE hContact; + HTREEITEM contact; + ModuleTreeInfoStruct *lParam; + struct ModSetLinkLinkItem *module; + char percent[96], title[64]; + HWND hwnd = GetParent(hwnd2Tree); + int i = 0; + + mir_snprintf(title, SIZEOF(title), Translate("Loading modules...")); + + item.mask = TVIF_STATE|TVIF_PARAM; + + contact = TreeView_GetChild( hwnd2Tree, TVI_ROOT ); + contact = TreeView_GetNextSibling(hwnd2Tree, contact); + contact = TreeView_GetChild(hwnd2Tree, contact); + + while (contact && hwnd2mainWindow) + { + i++; + item.hItem = contact; + contact = TreeView_GetNextSibling(hwnd2Tree, contact); + + if (TreeView_GetItem( hwnd2Tree, &item ) && + item.lParam) // && item.state != TVE_EXPAND) + { + ModuleTreeInfoStruct *mtis = (ModuleTreeInfoStruct *)item.lParam; + hContact = mtis->hContact; + if (hContact == NULL || mtis->type != (CONTACT|EMPTY)) + continue; + else + mtis->type = CONTACT; + } + else continue; + + // Caption + mir_snprintf(percent, SIZEOF(percent), "%s %d%%", title, (int)(100*i/count)); + SetWindowText(hwnd, percent); + + module = modlist->first; + while(module && hwnd2mainWindow) + { + if (module->name[0] && !IsModuleEmpty(hContact,module->name)) + { + tvi.hParent = item.hItem; + tvi.hInsertAfter = TVI_SORT; + tvi.item.mask = TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_PARAM; + tvi.item.pszText = module->name; + + lParam = (ModuleTreeInfoStruct *)mir_calloc(sizeof(ModuleTreeInfoStruct)); + lParam->hContact = hContact; + + if (!module->known) + { + tvi.item.iImage = 5; + tvi.item.iSelectedImage = 6; + lParam->type = UNKNOWN_MODULE; + } + else + { + tvi.item.iImage = 1; + tvi.item.iSelectedImage = 2; + lParam->type = KNOWN_MODULE; + } + + tvi.item.lParam = (LPARAM)lParam; + TreeView_InsertItem(hwnd2Tree, &tvi); + } + module = (struct ModSetLinkLinkItem *)module->next; + } + + } + + if (UOS) + SetWindowText(hwnd, Translate("Database Editor++ (unicode mode)")); + else + SetWindowText(hwnd, Translate("Database Editor++ (ansi mode)")); + + +} + + +int findItemInTree(HWND hwnd2Tree, HANDLE hContact, char* module) +/* the following code to go through the whole tree is nicked from codeguru.. +http://www.codeguru.com/Cpp/controls/treeview/treetraversal/comments.php/c683/?thread=7680 */ +{ + TVITEM item; + char text[265]; + HTREEITEM lastItem; + if (!TreeView_GetCount(hwnd2Tree)) return 0; + + item.mask = TVIF_STATE|TVIF_PARAM|TVIF_TEXT; + item.hItem = TVI_ROOT; + item.pszText = text; + item.cchTextMax = 264; + do + { + do + { + lastItem = item.hItem; + if (lastItem != TVI_ROOT) + { +/* these next 2 lines are not from code guru..... */ + if (TreeView_GetItem( hwnd2Tree, &item) && item.lParam) + { + if ((hContact == ((ModuleTreeInfoStruct *)item.lParam)->hContact) && (!module[0] || !mir_strcmp(module,text))) + { + //TreeView_SelectItem(hwnd2Tree,item.hItem); + return (int)item.hItem; + } + } +/* back to coduguru's code*/ + } + } while ( (item.hItem = TreeView_GetChild( hwnd2Tree, lastItem ))); + while ( (! (item.hItem = TreeView_GetNextSibling( hwnd2Tree, lastItem ))) && (lastItem = item.hItem = TreeView_GetParent( hwnd2Tree, lastItem ))) {} + + } while ( item.hItem ); +/*****************************************************************************/ + + return -1; +} + +void freeTree(HWND hwnd2Tree, HANDLE hContact) +/* the following code to go through the whole tree is nicked from codeguru.. +http://www.codeguru.com/Cpp/controls/treeview/treetraversal/comments.php/c683/?thread=7680 */ +{ + TVITEM item; + HTREEITEM lastItem; + if (!TreeView_GetCount(hwnd2Tree)) return; + + item.mask = TVIF_STATE|TVIF_PARAM; + item.hItem = TVI_ROOT; + do + { + do + { + lastItem = item.hItem; + if (lastItem != TVI_ROOT) + { + TreeView_GetItem( hwnd2Tree, &item ); +/* these next 2 lines are not from code guru..... */ + if (item.lParam) + { + ModuleTreeInfoStruct *mtis = (ModuleTreeInfoStruct *)item.lParam; + + if (!hContact || (hContact == mtis->hContact)) + { + if (hContact != NULL) { + TreeView_DeleteItem(hwnd2Tree,item.hItem); + mir_free(mtis); + } else + mtis->type = STUB; + } + } +/* back to coduguru's code*/ + } + } while ( (item.hItem = TreeView_GetChild( hwnd2Tree, lastItem ))); + while ( (! (item.hItem = TreeView_GetNextSibling( hwnd2Tree, lastItem ))) && (lastItem = item.hItem = TreeView_GetParent( hwnd2Tree, lastItem ))) {} + + } while ( item.hItem ); +/*****************************************************************************/ +} + +BOOL findAndRemoveDuplicates(HWND hwnd2Tree, HANDLE hContact, char* module) +/* the following code to go through the whole tree is nicked from codeguru.. +http://www.codeguru.com/Cpp/controls/treeview/treetraversal/comments.php/c683/?thread=7680 */ +{ + TVITEM item; + HTREEITEM lastItem, prelastItem; + BOOL Result = 0; + char text[265]; + if (!TreeView_GetCount(hwnd2Tree)) return Result; + + item.mask = TVIF_STATE|TVIF_PARAM|TVIF_TEXT; + item.hItem = TVI_ROOT; + item.pszText = text; + item.cchTextMax = 264; + prelastItem = item.hItem; + + do + { + do + { + lastItem = item.hItem; + if (lastItem != TVI_ROOT) + { + TreeView_GetItem( hwnd2Tree, &item ); +/* these next lines are not from code guru..... */ + if (item.lParam) + { + ModuleTreeInfoStruct *mtis = (ModuleTreeInfoStruct *)item.lParam; + if (hContact == mtis->hContact && !mir_strcmp(text,module)) + { + mir_free(mtis); + TreeView_DeleteItem(hwnd2Tree,item.hItem); + lastItem = prelastItem; + Result = 1; + } + else + prelastItem = lastItem; + } +/* back to coduguru's code*/ + } + } while ( (item.hItem = TreeView_GetChild( hwnd2Tree, lastItem ))); + while ( (! (item.hItem = TreeView_GetNextSibling( hwnd2Tree, lastItem ))) && (lastItem = item.hItem = TreeView_GetParent( hwnd2Tree, lastItem ))) {} + + } while ( item.hItem ); +/*****************************************************************************/ + + return Result; +} + + +void replaceTreeItem(HWND hwnd, HANDLE hContact, const char *module, const char *newModule) +{ + int hItem = findItemInTree(hwnd, hContact, (char*)module); + HTREEITEM hParent; + + if (hItem == -1) return; + + hParent = TreeView_GetParent(hwnd,(HTREEITEM)hItem); + + { + TVITEM item; + item.mask = TVIF_PARAM; + item.hItem = (HTREEITEM)hItem; + + if (TreeView_GetItem(hwnd, &item)) + mir_free((ModuleTreeInfoStruct *)item.lParam); + TreeView_DeleteItem(hwnd,item.hItem); + } + + if (hParent && newModule) + { + TVINSERTSTRUCT tvi = {0}; + ModuleTreeInfoStruct *lParam; + + tvi.hParent = hParent; + tvi.hInsertAfter = TVI_SORT; + tvi.item.mask = TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_PARAM; + tvi.item.pszText = (char*)newModule; + + lParam = (ModuleTreeInfoStruct *)mir_calloc(sizeof(ModuleTreeInfoStruct)); + lParam->hContact = hContact; + lParam->type = IsModuleKnown((char*)newModule)?KNOWN_MODULE:UNKNOWN_MODULE; + if (lParam->type == UNKNOWN_MODULE) + { + tvi.item.iImage = 5; + tvi.item.iSelectedImage = 6; + } + else + { + tvi.item.iImage = 1; + tvi.item.iSelectedImage = 2; + } + + tvi.item.lParam = (LPARAM)lParam; + + TreeView_InsertItem(hwnd, &tvi); + } +} + +void refreshTree(int restore) +{ + UseKnownModList = DBGetContactSettingByte(NULL,modname,"UseKnownModList",0); + if (populating) return; + populating = 1; + forkthread(PopulateModuleTreeThreadFunc,0,(HWND)restore); +} + +void __cdecl PopulateModuleTreeThreadFunc(LPVOID di) +{ + TVINSERTSTRUCT tvi; + HWND hwnd2Tree = GetDlgItem(hwnd2mainWindow,IDC_MODULES); + char SelectedModule[256] = {0}; + char SelectedSetting[256] = {0}; + HANDLE hSelectedContact = hRestore; + HANDLE hContact; + HTREEITEM contact, contactsRoot; + int count; + + // item lParams + ModuleTreeInfoStruct *lParam; + + // module list + struct ModSetLinkLinkItem *module; + ModuleSettingLL modlist; + + hRestore = NULL; + + if (!hwnd2Tree) { msg(Translate("Module tree not found"),modFullname); return;} + + Select = 0; + + switch((int)di) { + case 1: // restore after rebuild + { + HTREEITEM item; + if (item = TreeView_GetSelection(hwnd2Tree)) + { + TVITEM tvi = {0}; + + tvi.mask=TVIF_HANDLE|TVIF_PARAM|TVIF_TEXT; + tvi.pszText = SelectedModule; + tvi.cchTextMax = 255; + tvi.hItem=item; + + TreeView_GetItem(hwnd2Tree, &tvi); + if (tvi.lParam) + { + ModuleTreeInfoStruct *mtis = (ModuleTreeInfoStruct *)tvi.lParam; + hSelectedContact = mtis->hContact; + if (mtis->type == CONTACT) SelectedModule[0] = 0; + Select = 1; + } + } + break; + } + case 2: // restore saved + if (GetValue(NULL,modname,"LastModule",SelectedModule,SIZEOF(SelectedModule))) + { + hSelectedContact = (HANDLE)DBGetContactSettingDword(NULL,modname,"LastContact",(DWORD)INVALID_HANDLE_VALUE); + if (hSelectedContact != INVALID_HANDLE_VALUE) + Select = 1; + GetValue(NULL,modname,"LastSetting",SelectedSetting,SIZEOF(SelectedSetting)); + } + break; + case 3: // restore from user menu + case 4: // jump from user menu + { + if (hSelectedContact && hSelectedContact != INVALID_HANDLE_VALUE) + { + Select = 1; + } + break; + } + } // switch + + if ((int)di != 4) // do not rebuild on just going to another setting + { + + if (!EnumModules(&modlist)) { msg(Translate("Error Loading Module List"),modFullname); return;} + + // remove all items (incase there are items there... + freeTree(hwnd2Tree,0); + TreeView_DeleteAllItems(hwnd2Tree); + TreeView_SelectItem(hwnd2Tree,0); + + //image list + TreeView_SetImageList(hwnd2Tree, himl, TVSIL_NORMAL); + + /// contact root item + contacts_mtis.type = CONTACT_ROOT_ITEM; + tvi.item.lParam = (LPARAM)&contacts_mtis; + tvi.hParent = NULL; + tvi.item.mask = TVIF_TEXT|TVIF_CHILDREN|TVIF_STATE|TVIF_PARAM|TVIF_IMAGE|TVIF_SELECTEDIMAGE; + tvi.item.state = TVIS_BOLD; + tvi.item.stateMask = TVIS_BOLD; + tvi.item.cChildren = 1; + tvi.hInsertAfter = TVI_FIRST; + + tvi.item.pszText = Translate("Contacts"); + tvi.item.iImage = 3; + tvi.item.iSelectedImage = 3; + contactsRoot = TreeView_InsertItem(hwnd2Tree, &tvi); + + // add the settings item + settings_mtis.type = STUB; + tvi.item.lParam = (LPARAM)&settings_mtis; + tvi.item.mask = TVIF_TEXT|TVIF_CHILDREN|TVIF_PARAM|TVIF_IMAGE|TVIF_SELECTEDIMAGE; + tvi.item.cChildren = 1; + tvi.hParent = NULL; + tvi.hInsertAfter = TVI_FIRST; + tvi.item.pszText = Translate("Settings"); + tvi.item.iSelectedImage = (tvi.item.iImage = 0); + contact = TreeView_InsertItem(hwnd2Tree, &tvi); + + // to fix bug with CHANGE NOTIFY on window activation + TreeView_SelectItem(hwnd2Tree, contact); + settings_mtis.type = CONTACT; + + hContact = 0; + module = modlist.first; + while (module) + { + // set the module status type for the icon + module->known = IsModuleKnown(module->name); + + if (!IsModuleEmpty(hContact,module->name)) + { + tvi.hParent = contact; + tvi.hInsertAfter = TVI_SORT; + tvi.item.mask = TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_PARAM; + tvi.item.pszText = module->name; + + lParam = (ModuleTreeInfoStruct *)mir_calloc(sizeof(ModuleTreeInfoStruct)); + lParam->hContact = hContact; + if (!module->known) + { + tvi.item.iImage = 5; + tvi.item.iSelectedImage = 6; + lParam->type = UNKNOWN_MODULE; + } + else + { + tvi.item.iImage = 1; + tvi.item.iSelectedImage = 2; + lParam->type = KNOWN_MODULE; + } + + tvi.item.lParam = (LPARAM)lParam; + + TreeView_InsertItem(hwnd2Tree, &tvi); + } + module = (struct ModSetLinkLinkItem *)module->next; + } + + if (DBGetContactSettingByte(NULL,modname,"ExpandSettingsOnOpen",0)) + TreeView_Expand(hwnd2Tree,contact,TVE_EXPAND); + + if (Select && hSelectedContact == NULL) + { + int hItem = findItemInTree(hwnd2Tree, hSelectedContact, SelectedModule); + if (hItem != -1) + { + TreeView_SelectItem(hwnd2Tree, (HTREEITEM)hItem); + TreeView_Expand(hwnd2Tree,hItem,TVE_EXPAND); + if (SelectedSetting[0]) SelectSetting(SelectedSetting); + } + Select = 0; + } + + count = doContacts(hwnd2Tree,contactsRoot,&modlist, Select?hSelectedContact:NULL, SelectedModule, SelectedSetting); + Select = 0; + doItems(hwnd2Tree,&modlist,count); + + FreeModuleSettingLL(&modlist); + } + + if (Select) + { + int hItem = findItemInTree(hwnd2Tree, hSelectedContact, SelectedModule); + if (hItem != -1) + { + TreeView_SelectItem(hwnd2Tree, (HTREEITEM)hItem); + TreeView_Expand(hwnd2Tree,hItem,TVE_EXPAND); + if (SelectedSetting[0]) SelectSetting(SelectedSetting); + } + } + + populating = 0; + +} + + +static WNDPROC ModuleTreeLabelEditSubClass; + +static LRESULT CALLBACK ModuleTreeLabelEditSubClassProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam) +{ + switch(msg) { + case WM_KEYUP: + switch (wParam) + { + case VK_RETURN: + TreeView_EndEditLabelNow(GetParent(hwnd),0); + return 0; + case VK_ESCAPE: + TreeView_EndEditLabelNow(GetParent(hwnd),1); + return 0; + } + break; + } + return CallWindowProc(ModuleTreeLabelEditSubClass,hwnd,msg,wParam,lParam); +} +void moduleListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam); + +void moduleListWM_NOTIFY(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)// hwnd here is to the main window, NOT the treview +{ + switch(((NMHDR*)lParam)->code) + { + case TVN_ITEMEXPANDINGA: + case TVN_ITEMEXPANDINGW: + if (populating && ((LPNMTREEVIEW)lParam)->action == TVE_EXPAND) + { + ModuleTreeInfoStruct *mtis = (ModuleTreeInfoStruct *)((LPNMTREEVIEW)lParam)->itemNew.lParam; + if (mtis && (mtis->type == (CONTACT | EMPTY))) + { + TVINSERTSTRUCT tvi; + HTREEITEM item = {0}; + ModuleTreeInfoStruct *_lParam; + HWND hwnd2Tree = GetDlgItem(hwnd2mainWindow,IDC_MODULES); + struct ModSetLinkLinkItem *module; + ModuleSettingLL modlist; + HANDLE hContact = mtis->hContact; + + mtis->type = CONTACT; + + if (!EnumModules(&modlist)) { msg(Translate("Error Loading Module List"),modFullname); break;} + + module = modlist.first; + while(module && hwnd2mainWindow) + { + if (module->name[0] && !IsModuleEmpty(hContact,module->name)) + { + tvi.hParent = ((LPNMTREEVIEW)lParam)->itemNew.hItem; + tvi.hInsertAfter = TVI_SORT; + tvi.item.mask = TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_PARAM; + tvi.item.pszText = module->name; + + _lParam = (ModuleTreeInfoStruct *)mir_calloc(sizeof(ModuleTreeInfoStruct)); + _lParam->hContact = hContact; + + if (IsModuleKnown(module->name)) + { + tvi.item.iImage = 5; + tvi.item.iSelectedImage = 6; + _lParam->type = KNOWN_MODULE; + } + else + { + tvi.item.iImage = 1; + tvi.item.iSelectedImage = 2; + _lParam->type = UNKNOWN_MODULE; + } + + tvi.item.lParam = (LPARAM)_lParam; + TreeView_InsertItem(hwnd2Tree, &tvi); + } + module = (struct ModSetLinkLinkItem *)module->next; + } + + FreeModuleSettingLL(&modlist); + } + + } + break; + + case TVN_SELCHANGEDA: + case TVN_SELCHANGEDW: + { + ModuleTreeInfoStruct *mtis; + LPNMTREEVIEW pnmtv = (LPNMTREEVIEW)lParam; + TVITEM tvi = {0}; + char text[264]; + HANDLE hContact; + HWND hwnd2Settings = GetDlgItem(hwnd, IDC_SETTINGS); + tvi.mask = TVIF_HANDLE|TVIF_PARAM|TVIF_TEXT; + tvi.hItem = pnmtv->itemNew.hItem; + tvi.pszText = text; + tvi.cchTextMax = 264; + TreeView_GetItem(pnmtv->hdr.hwndFrom,&tvi); + + if (tvi.lParam) + { + mtis = (ModuleTreeInfoStruct *)tvi.lParam; + hContact = mtis->hContact; + + if (mtis->type == STUB) break; + + if (populating) Select = 0; + + if (mtis->type == MODULE || mtis->type == UNKNOWN_MODULE) + { + SettingListInfo *info = (SettingListInfo*)GetWindowLongPtr(hwnd2Settings,GWLP_USERDATA); + BOOL refresh = 1; + + if (info) + { + if (info->hContact == hContact && + !mir_strcmp(info->module, text)) + refresh = 0; + } + + if (refresh) + PopulateSettings(hwnd2Settings, hContact, text); + } + else + if (((mtis->type & CONTACT) == CONTACT && hContact) || + (mtis->type == CONTACT_ROOT_ITEM && !hContact)) + { + char data[32], szProto[256]; + int index, loaded, multi = 0; + LVITEM lvi = {0}; + lvi.mask = LVIF_IMAGE|LVIF_TEXT|LVIF_PARAM; + lvi.iImage = 6; + + ClearListview(hwnd2Settings); + SetWindowLongPtr(hwnd2Settings,GWLP_USERDATA, (LONG)NULL); + if (himl2) ListView_SetImageList(hwnd2Settings, himl2, LVSIL_SMALL); + + if (mtis->type == CONTACT_ROOT_ITEM && !hContact) + { + multi = 1; + hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + } + + while(hContact && hwnd2mainWindow) + { + if (multi) + { + // filter + if (GetValue(hContact,"Protocol","p",szProto,SIZEOF(szProto))) + loaded = IsProtocolLoaded(szProto); + else + loaded = 0; + + if ((loaded && Mode == MODE_UNLOADED) || (!loaded && Mode == MODE_LOADED)) + { + hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); + continue; + } + } + + lvi.iItem = 0; + lvi.pszText = (char*)GetContactName(hContact,NULL,UOS); + + if (UOS) + index = ListView_InsertItemW(hwnd2Settings,&lvi); + else + index = ListView_InsertItem(hwnd2Settings,&lvi); + + mir_snprintf(data, SIZEOF(data), "0x%08X (%ld)", hContact, hContact); + + ListView_SetItemText(hwnd2Settings,index,1,data); + ListView_SetItemText(hwnd2Settings,index,2,Translate("HANDLE")); + ListView_SetItemText(hwnd2Settings,index,3,"0x0004 (4)"); + + if (!multi) break; + + hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); + } + + } + else + ClearListview(hwnd2Settings); + } + else + { + // clear any settings that may be there... + ClearListview(hwnd2Settings); + } + } + break; //TVN_SELCHANGED: + case NM_RCLICK: + if (((NMHDR*)lParam)->code == NM_RCLICK) + moduleListRightClick(hwnd,wParam,lParam); + break; + case TVN_BEGINLABELEDITA: // subclass it.. + case TVN_BEGINLABELEDITW: + { + LPNMTVDISPINFO ptvdi = (LPNMTVDISPINFO) lParam; + ModuleTreeInfoStruct *mtis = (ModuleTreeInfoStruct *)ptvdi->item.lParam; + HWND hwnd2Edit = TreeView_GetEditControl(GetDlgItem(hwnd, IDC_MODULES)); + if (!mtis->type || (mtis->type == CONTACT)) + { + SetWindowLongPtr(hwnd, DWLP_MSGRESULT, TRUE); + break; + } + ModuleTreeLabelEditSubClass = (WNDPROC)SetWindowLongPtr(hwnd2Edit, GWLP_WNDPROC, (LONG)ModuleTreeLabelEditSubClassProc); + SetWindowLongPtr(hwnd, DWLP_MSGRESULT, FALSE); + } + break; + case TVN_ENDLABELEDITA: + case TVN_ENDLABELEDITW: + { + LPNMTVDISPINFO ptvdi = (LPNMTVDISPINFO) lParam; + TVITEM tvi = {0}; + char text[264]; + char *newtext; + ModuleTreeInfoStruct *mtis; + tvi.mask=TVIF_HANDLE|TVIF_TEXT|TVIF_PARAM; + tvi.hItem=ptvdi->item.hItem; + tvi.pszText = text; + tvi.cchTextMax = 264; + TreeView_GetItem(((LPNMHDR)lParam)->hwndFrom,&tvi); + mtis = (ModuleTreeInfoStruct *)ptvdi->item.lParam; + + if (UOS) + newtext = u2a((WCHAR*)ptvdi->item.pszText); + else + newtext = mir_tstrdup(ptvdi->item.pszText); + + if (!newtext || // edit control failed + !mtis->type || // its a root item + mtis->type == CONTACT || // its a contact + *newtext == 0) // empty string + SetWindowLongPtr(hwnd, DWLP_MSGRESULT, FALSE); + else + { + if (mir_strcmp(tvi.pszText, newtext)) + { + renameModule(tvi.pszText, newtext, mtis->hContact); + + findAndRemoveDuplicates(((LPNMHDR)lParam)->hwndFrom,mtis->hContact,newtext); + + if (TreeView_GetItem(((LPNMHDR)lParam)->hwndFrom,&tvi)) + { + tvi.mask = TVIF_IMAGE|TVIF_SELECTEDIMAGE; + if (!IsModuleKnown(newtext)) + { + tvi.iImage = 5; + tvi.iSelectedImage = 6; + } + else + { + tvi.iImage = 1; + tvi.iSelectedImage = 2; + } + TreeView_SetItem(((LPNMHDR)lParam)->hwndFrom, &tvi); + + PopulateSettings(GetDlgItem(hwnd, IDC_SETTINGS), mtis->hContact, newtext); + } + } + SetWindowLongPtr(hwnd, DWLP_MSGRESULT, TRUE); + } + + mir_free(newtext); + } + break; + } +} + +void moduleListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam) // hwnd here is to the main window, NOT the treview +{ + TVHITTESTINFO hti; + hti.pt.x=(short)LOWORD(GetMessagePos()); + hti.pt.y=(short)HIWORD(GetMessagePos()); + ScreenToClient(((LPNMHDR)lParam)->hwndFrom,&hti.pt); + + if(TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom,&hti)) + { + if(hti.flags&TVHT_ONITEM) + { + TVITEM tvi = {0}; + HMENU hMenu,hSubMenu; + int menuNumber; + char module[256]; + tvi.mask=TVIF_HANDLE|TVIF_PARAM|TVIF_TEXT; + tvi.hItem=hti.hItem; + tvi.pszText = module; + tvi.cchTextMax = 255; + TreeView_GetItem(((LPNMHDR)lParam)->hwndFrom,&tvi); + if (tvi.lParam) + { + ModuleTreeInfoStruct *mtis = (ModuleTreeInfoStruct *)tvi.lParam; + HANDLE hContact = mtis->hContact; + GetCursorPos(&(hti.pt)); + hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_CONTEXTMENU)); + TranslateMenu(hMenu); + if (mtis->type == CONTACT && hContact) menuNumber = 2; + else if ((mtis->type == MODULE || mtis->type == UNKNOWN_MODULE) && !hContact) menuNumber = 1; + else if (mtis->type == CONTACT && !hContact) menuNumber = 3; + else if (mtis->type == CONTACT_ROOT_ITEM && !hContact) menuNumber = 4; + else if ((mtis->type == MODULE || mtis->type == UNKNOWN_MODULE) && hContact) menuNumber = 5; + else return; + hSubMenu = GetSubMenu(hMenu, menuNumber); + + TranslateMenu(hSubMenu); + switch (menuNumber) + { + case 1: // null module + case 5: // contact module + { + // check if we r already watching the module + int i; + int watching = 0; + // check if the setting is being watched and if it is then check the menu item + if (WatchListArray.item) + for (i=0; ihwndFrom,hti.hItem); + mir_free(mtis); + } + break; + case MENU_COPY_MOD: + copyModuleMenuItem(module, hContact); + break; +////////////////////////////////////////////////////////////////////// divider + case MENU_WATCH_ITEM: + if (!watching) + addSettingToWatchList(hContact,module,0); + else freeWatchListItem(i); + if (hwnd2watchedVarsWindow) + PopulateWatchedWindow(GetDlgItem(hwnd2watchedVarsWindow, IDC_VARS)); + break; + case MENU_EXPORTMODULE: + exportDB(hContact, module); + break; + case MENU_EXPORTDB: + exportDB(INVALID_HANDLE_VALUE, module); + break; + case MENU_ADDKNOWN: + { + DBVARIANT dbv; + char *moduletemp = (char*)_alloca(strlen(module)*3); + unsigned int i; + moduletemp[0] = '\0'; + for(i=0;ihwndFrom,hContact); + TreeView_DeleteItem(((LPNMHDR)lParam)->hwndFrom,tvi.hItem); + } + } + else + { + CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact,0); + freeTree(((LPNMHDR)lParam)->hwndFrom,hContact); + TreeView_DeleteItem(((LPNMHDR)lParam)->hwndFrom,tvi.hItem); + } + break; +////////////////////////////////////////////////////////////////////// divider + case MENU_EXPORTCONTACT: + exportDB(hContact, 0); + break; + case MENU_IMPORTFROMTEXT: + ImportSettingsMenuItem(hContact); + break; + case MENU_IMPORTFROMFILE: + ImportSettingsFromFileMenuItem(hContact, ""); + break; +////////////////////////////////////////////////////////////////////// divider + case MENU_ADD_MODULE: + { + HWND AddModhwnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ADD_MODULE), hwnd, AddModDlgProc, (LPARAM)hContact); + char msg[1024]; + mir_snprintf(msg, SIZEOF(msg), Translate("Add module to contact \"%s\""), module); + SetWindowText(AddModhwnd, module); + } + break; + } + break; + case 3: // NULL contact + switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, hti.pt.x, hti.pt.y, 0, hwnd, NULL)) + { + case MENU_ADD_MODULE: + { + HWND AddModhwnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ADD_MODULE), hwnd, AddModDlgProc, (LPARAM)hContact); + char msg[1024]; + mir_snprintf(msg, SIZEOF(msg), Translate("Add module to contact \"%s\""), module); + SetWindowText(AddModhwnd, module); + } + break; + case MENU_EXPORTCONTACT: + exportDB(NULL, 0); + break; + case MENU_IMPORTFROMTEXT: + ImportSettingsMenuItem(NULL); + break; + case MENU_IMPORTFROMFILE: + ImportSettingsFromFileMenuItem(NULL, ""); + break; + } + break; + case 4: // Contacts root + switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, hti.pt.x, hti.pt.y, 0, hwnd, NULL)) + { + case MENU_EXPORTCONTACT: + exportDB(INVALID_HANDLE_VALUE, ""); + break; + case MENU_IMPORTFROMTEXT: + ImportSettingsMenuItem(NULL); + break; + case MENU_IMPORTFROMFILE: + ImportSettingsFromFileMenuItem(NULL, ""); + break; + } + break; + } + DestroyMenu(hMenu); + } + } // if (tvi.lParam) + } // if(hti.flags&TVHT_ONITEM) +} \ No newline at end of file diff --git a/plugins/DbeditorPP/options.cpp b/plugins/DbeditorPP/options.cpp new file mode 100644 index 0000000000..0630fa353c --- /dev/null +++ b/plugins/DbeditorPP/options.cpp @@ -0,0 +1,94 @@ +#include "headers.h" + +INT_PTR CALLBACK DlgProcOpts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch(msg) + { + case WM_INITDIALOG: + { + DBVARIANT dbv; + CheckDlgButton(hwnd,IDC_EXPANDSETTINGS,DBGetContactSettingByte(NULL,modname,"ExpandSettingsOnOpen",0)); + CheckDlgButton(hwnd,IDC_RESTORESETTINGS,DBGetContactSettingByte(NULL,modname,"RestoreOnOpen",1)); + CheckDlgButton(hwnd,IDC_USEKNOWNMODS,DBGetContactSettingByte(NULL,modname,"UseKnownModList",0)); + CheckDlgButton(hwnd,IDC_WARNONDEL,DBGetContactSettingByte(NULL,modname,"WarnOnDelete",1)); + CheckDlgButton(hwnd,IDC_MENU,DBGetContactSettingByte(NULL,modname,"UserMenuItem",0)); + CheckDlgButton(hwnd,IDC_POPUPS,usePopUps); + if (!DBGetContactSetting(NULL,modname,"CoreModules",&dbv) && dbv.type == DBVT_ASCIIZ) + SetDlgItemText(hwnd,IDC_MODULES,dbv.pszVal); + DBFreeVariant(&dbv); + SetDlgItemInt(hwnd,IDC_POPUPTIMEOUT,DBGetContactSettingWord(NULL,modname,"PopupDelay",4),0); + SendDlgItemMessage(hwnd, IDC_COLOUR, CPM_SETCOLOUR, 0, (LPARAM)DBGetContactSettingDword(NULL,modname,"PopupColour",RGB(255,0,0))); + TranslateDialogDefault(hwnd); + } + return TRUE; + case WM_COMMAND: + switch(LOWORD(wParam)) + { + case IDC_RESTORESETTINGS: + case IDC_EXPANDSETTINGS: + case IDC_USEKNOWNMODS: + case IDC_MODULES: + case IDC_MENU: + case IDC_POPUPS: + case IDC_WARNONDEL: + case IDC_COLOUR: + case IDC_POPUPTIMEOUT: + SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0); + break; + } + break; + case WM_NOTIFY: + switch(((LPNMHDR)lParam)->idFrom) + { + case 0: + switch (((LPNMHDR)lParam)->code) + { + case PSN_APPLY: + { + CLISTMENUITEM mi = {0}; + char mods[4096]; + DBWriteContactSettingByte(NULL,modname,"ExpandSettingsOnOpen",(BYTE)IsDlgButtonChecked(hwnd,IDC_EXPANDSETTINGS)); + DBWriteContactSettingByte(NULL,modname,"RestoreOnOpen",(BYTE)IsDlgButtonChecked(hwnd,IDC_RESTORESETTINGS)); + DBWriteContactSettingByte(NULL,modname,"WarnOnDelete",(BYTE)IsDlgButtonChecked(hwnd,IDC_WARNONDEL)); + DBWriteContactSettingByte(NULL,modname,"UserMenuItem",(BYTE)IsDlgButtonChecked(hwnd,IDC_MENU)); + DBWriteContactSettingByte(NULL,modname,"UseKnownModList",(BYTE)IsDlgButtonChecked(hwnd,IDC_USEKNOWNMODS)); + usePopUps = IsDlgButtonChecked(hwnd,IDC_POPUPS); + DBWriteContactSettingByte(NULL,modname,"UsePopUps",(BYTE)usePopUps); + if (GetDlgItemText(hwnd,IDC_MODULES,mods,4096)) + DBWriteContactSettingString(NULL,modname,"CoreModules",mods); + DBWriteContactSettingWord(NULL,modname,"PopupDelay",(WORD)GetDlgItemInt(hwnd,IDC_POPUPTIMEOUT,NULL,0)); + DBWriteContactSettingDword(NULL,modname,"PopupColour",(DWORD)SendDlgItemMessage(hwnd, IDC_COLOUR, CPM_GETCOLOUR, 0, 0)); + + mi.cbSize = sizeof(mi); + + if (!IsDlgButtonChecked(hwnd,IDC_MENU)) + mi.flags = CMIM_FLAGS | CMIF_HIDDEN; + else + mi.flags = CMIM_FLAGS; + + CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM) hUserMenu, (LPARAM) & mi); + + } + return TRUE; + } + break; + } + break; + } + return FALSE; +} + +INT OptInit(WPARAM wParam,LPARAM lParam) +{ + OPTIONSDIALOGPAGE odp = { 0 }; + odp.cbSize = sizeof(odp); + odp.hInstance = hInst; + odp.pszTemplate = MAKEINTRESOURCE(IDD_OPTIONS); + odp.pszGroup = LPGEN("Services"); + odp.pszTitle = modFullname; + odp.pfnDlgProc = DlgProcOpts; + odp.flags = ODPF_BOLDGROUPS; + Options_AddPage(wParam, &odp); + + return 0; +} \ No newline at end of file diff --git a/plugins/DbeditorPP/resource.h b/plugins/DbeditorPP/resource.h new file mode 100644 index 0000000000..c32d146126 --- /dev/null +++ b/plugins/DbeditorPP/resource.h @@ -0,0 +1,157 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by resource.rc +// +#define ICO_REGEDIT 1 +#define ICO_UNICODE 2 +#define ICO_DBE_BUTT 3 +#define ICO_REGUSER 4 +#define ICO_STRING 5 +#define ICO_BINARY 6 +#define ICO_DWORD 7 +#define ICO_BYTE 8 +#define ICO_WORD 9 +#define ICO_HANDLE 10 +#define IDD_MAIN 101 +#define IDR_MAINMENU 103 +#define IDR_CONTEXTMENU 104 +#define ICO_CONTACTS 106 +#define ICO_OFFLINE 107 +#define IDD_ADD_MODULE 108 +#define IDD_EDIT_SETTING 109 +#define IDD_WATCH_DIAG 110 +#define IDR_WATCHWINDOWMENU 112 +#define ICO_UNLOADED 115 +#define IDD_COPY_MOD 116 +#define IDD_IMPORT 118 +#define IDD_CHANGE_ARRAYSIZE 120 +#define IDD_FIND 121 +#define IDD_OPTIONS 122 +#define ICO_KNOWN 124 +#define ICO_KNOWNOPEN 125 +#define ICO_UNKNOWNOPEN 126 +#define ICO_UNKNOWN 127 +#define ICO_SETTINGS 128 +#define ICO_ONLINE 129 +#define IDC_MODULES 1000 +#define IDC_SETTINGS 1001 +#define IDC_MENU 1002 +#define IDC_MODNAME 1004 +#define CHK_ADD2ALL 1005 +#define IDC_MODNAME2 1005 +#define IDC_SETTINGNAME 1006 +#define IDC_SPLITTER 1006 +#define IDC_STRING 1007 +#define IDC_SETTINGNAME2 1007 +#define GRP_BASE 1008 +#define CHK_HEX 1009 +#define CHK_DECIMAL 1010 +#define IDC_SETTINGVALUE 1011 +#define GRP_TYPE 1012 +#define IDC_SETTINGVALUE2 1012 +#define CHK_BYTE 1013 +#define IDC_SETTINGVALUE3 1013 +#define CHK_WORD 1014 +#define CHK_DWORD 1015 +#define CHK_STRING 1016 +#define IDC_VARS 1017 +#define IDC_ADDMODNAMESTATIC 1020 +#define IDC_CONTACTS 1021 +#define CHK_COPY2ALL 1022 +#define IDC_TEXT 1025 +#define IDC_FIND 1026 +#define IDC_REPLACE 1027 +#define IDC_CASE_SENSITIVE 1027 +#define IDC_REQUIRED 1028 +#define IDC_ARRAYSIZE 1030 +#define IDC_CURRENTSIZE 1032 +#define IDC_INFOTEXT 1033 +#define IDC_CRLF 1035 +#define IDC_CASESENSITIVE 1040 +#define IDC_LIST 1041 +#define IDC_SEARCH 1042 +#define IDC_EXACT 1043 +#define IDC_EXPANDSETTINGS 1044 +#define IDC_USEKNOWNMODS 1045 +#define IDC_WARNONDEL 1047 +#define IDC_POPUPS 1048 +#define IDC_POPUPTIMEOUT 1049 +#define IDC_COLOUR 1050 +#define IDC_RESTORESETTINGS 1051 +#define IDC_BLOB 1052 +#define IDC_FOUND 1056 +#define IDC_SBAR 1057 +#define IDC_ENTIRELY 1058 +#define MENU_REFRESH_MODS 40001 +#define MENU_REFRESH_SETS 40002 +#define MENU_EXIT 40003 +#define MENU_CHANGE2UNICODE 40004 +#define MENU_ADD_UNICODE 40005 +#define MENU_RENAME_SET 40006 +#define MENU_EDIT_SET 40007 +#define MENU_CHANGE2BYTE 40008 +#define MENU_CHANGE2WORD 40009 +#define MENU_CHANGE2DWORD 40010 +#define MENU_CHANGE2STRING 40011 +#define MENU_DELETE_SET 40012 +#define MENU_DELETE_MOD 40013 +#define MENU_CREATE_MOD 40014 +#define MENU_VIEW_WATCHES 40016 +#define MENU_REMALL_WATCHES 40017 +#define MENU_ADD_WATCH 40018 +#define MENU_WATCH_ITEM 40018 +#define MENU_WATCH_MOD 40019 +#define MENU_ADD_BLOB 40020 +#define MENU_CLONE_CONTACT 40021 +#define MENU_DELETE_CONTACT 40022 +#define MENU_ADD_MODULE 40023 +#define MENU_ADD_BYTE 40024 +#define MENU_ADD_WORD 40025 +#define MENU_ADD_DWORD 40026 +#define MENU_ADD_STRING 40027 +#define MENU_SAVE_WATCHES 40028 +#define MENU_RENAME_MOD 40030 +#define MENU_COPY_MOD 40032 +#define MENU_USE_MODLIST 40033 +#define MENU_USE_POPUPS 40034 +#define MENU_SORT_ORDER 40035 +#define MENU_EXPORTDB 40036 +#define MENU_EXPORTMODULE 40037 +#define MENU_EXPORTCONTACT 40038 +#define MENU_SAVE_POSITION 40039 +#define MENU_IMPORTSETTINGS 40040 +#define MENU_ADDCONTACT 40041 +#define MENU_WARNONDEL 40042 +#define MENU_LOAD_WATCHES 40043 +#define MENU_WORD_HEX 40044 +#define MENU_DECRYPT 40045 +#define MENU_ENCRYPT 40046 +#define MENU_VIEWDECRYPT 40047 +#define MENU_VIEWENCRYPT 40048 +#define MENU_LOGTODISK 40049 +#define MENU_FINDANDREPLACE 40050 +#define MENU_FINDMODSETTING 40051 +#define MENU_DWORD_HEX 40052 +#define MENU_IMPORTFROMFILE 40053 +#define MENU_IMPORTFROMTEXT 40054 +#define MENU_CHANGEARRAYSIZE 40055 +#define MENU_OPTIONS 40056 +#define MENU_DELETE 40057 +#define MENU_REFRESH 40058 +#define MENU_ADDKNOWN 40059 +#define MENU_FILTER_ALL 40060 +#define MENU_FILTER_LOADED 40061 +#define MENU_FILTER_UNLOADED 40062 +#define MENU_BYTE_HEX 40063 +#define MENU_OPEN_OPTIONS 40064 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 131 +#define _APS_NEXT_COMMAND_VALUE 40065 +#define _APS_NEXT_CONTROL_VALUE 1059 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/plugins/DbeditorPP/resource.rc b/plugins/DbeditorPP/resource.rc new file mode 100644 index 0000000000..26ac45f0eb --- /dev/null +++ b/plugins/DbeditorPP/resource.rc @@ -0,0 +1,516 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// Ŕíăëčéńęčé (ŃŘŔ) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_FIND DIALOGEX 0, 0, 340, 249 +STYLE DS_SETFONT | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME +CAPTION "Database Editor++ Search and Replace" +FONT 8, "MS Shell Dlg", 0, 0, 0x0 +BEGIN + EDITTEXT IDC_TEXT,40,13,216,12,ES_AUTOHSCROLL + CONTROL "Case Sensitive",IDC_CASESENSITIVE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,40,30,72,10 + CONTROL "Module Name",IDC_MODNAME,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,40,44,73,10 + CONTROL "Exact Match",IDC_EXACT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,115,30,64,10 + CONTROL "Setting Name",IDC_SETTINGNAME,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,115,44,72,10 + CONTROL "Setting Value",IDC_SETTINGVALUE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,194,44,69,10 + DEFPUSHBUTTON "&Search",IDC_SEARCH,277,5,60,14 + EDITTEXT IDC_REPLACE,40,72,216,12,ES_AUTOHSCROLL + CONTROL "Module Name",IDC_MODNAME2,"Button",BS_AUTORADIOBUTTON | NOT WS_VISIBLE | WS_DISABLED | WS_GROUP | WS_TABSTOP,40,90,73,10 + CONTROL "Setting Name",IDC_SETTINGNAME2,"Button",BS_AUTORADIOBUTTON | NOT WS_VISIBLE | WS_DISABLED | WS_TABSTOP,115,90,72,10 + CONTROL "Setting Value",IDC_SETTINGVALUE2,"Button",BS_AUTORADIOBUTTON | NOT WS_VISIBLE | WS_DISABLED | WS_TABSTOP,194,90,67,10 + CONTROL "Found field",IDC_FOUND,"Button",BS_AUTORADIOBUTTON | NOT WS_VISIBLE | WS_TABSTOP,267,90,65,10 + PUSHBUTTON "&Replace",IDOK,277,25,60,14 + PUSHBUTTON "&Cancel",IDCANCEL,277,45,60,14 + LISTBOX IDC_LIST,3,95,334,136,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP + GROUPBOX "Search For",IDC_STATIC,3,1,268,58 + LTEXT "Text:",IDC_STATIC,10,15,26,8 + LTEXT "In:",IDC_STATIC,10,30,23,8 + GROUPBOX "Replace With",IDC_STATIC,3,60,334,30 + LTEXT "Text:",IDC_STATIC,10,74,26,8 + LTEXT "In:",IDC_STATIC,10,90,23,8,NOT WS_VISIBLE + CONTROL "",IDC_SBAR,"msctls_statusbar32",WS_TABSTOP | 0x100,3,237,334,12 + CONTROL "Entirely",IDC_ENTIRELY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,262,74,67,10 +END + +IDD_OPTIONS DIALOGEX 0, 0, 314, 239 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE +FONT 8, "MS Shell Dlg", 0, 0, 0x0 +BEGIN + CONTROL "Restore last opened position",IDC_RESTORESETTINGS, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,13,283,10 + CONTROL "Automatically expand ""settings"" when Database Editor ++ starts",IDC_EXPANDSETTINGS, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,26,283,10 + CONTROL "Use known modules list",IDC_USEKNOWNMODS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,39,253,10 + CONTROL "Warn when deleting modules",IDC_WARNONDEL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,52,280,10 + CONTROL """Open user tree in DBE++"" menu item",IDC_MENU,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,65,280,10 + CONTROL "Use popups when watched settings change values",IDC_POPUPS, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,78,275,10 + EDITTEXT IDC_POPUPTIMEOUT,144,89,20,12,ES_NUMBER + CONTROL "",IDC_COLOUR,"ColourPicker",WS_TABSTOP,257,89,26,12 + EDITTEXT IDC_MODULES,12,140,288,46,ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN | WS_VSCROLL + GROUPBOX "Modules to ALWAYS mark as known (e.g core modules)",IDC_STATIC,7,105,300,96 + LTEXT "Put a space or comma between each module name",IDC_STATIC,12,116,286,8 + LTEXT "Changes to this list will take effect next time miranda starts",IDC_STATIC,12,189,284,8 + RTEXT "Popup timeout (0 for infinite)",IDC_STATIC,35,91,103,8 + RTEXT "Background Colour",IDC_STATIC,177,91,77,8 + LTEXT "If the module name has a space in it, put a \\ before the space. eg ""aaa\\ bbb""",IDC_STATIC,12,127,286,8 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_FIND, DIALOG + BEGIN + LEFTMARGIN, 3 + RIGHTMARGIN, 337 + VERTGUIDE, 10 + VERTGUIDE, 40 + VERTGUIDE, 115 + VERTGUIDE, 194 + VERTGUIDE, 277 + TOPMARGIN, 7 + HORZGUIDE, 18 + HORZGUIDE, 35 + HORZGUIDE, 48 + HORZGUIDE, 68 + HORZGUIDE, 95 + END + + IDD_OPTIONS, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 307 + VERTGUIDE, 12 + TOPMARGIN, 7 + BOTTOMMARGIN, 232 + HORZGUIDE, 68 + END +END +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +ICO_KNOWN ICON "res\\Yellow.ico" +ICO_KNOWNOPEN ICON "res\\Yellow_open.ico" +ICO_UNKNOWNOPEN ICON "res\\Red_open.ico" +ICO_UNKNOWN ICON "res\\Red.ico" +ICO_SETTINGS ICON "res\\Icon_4.ico" +ICO_ONLINE ICON "res\\online2.ico" +#endif // Ŕíăëčéńęčé (ŃŘŔ) resources +///////////////////////////////////////////////////////////////////////////// + + +///////////////////////////////////////////////////////////////////////////// +// Ŕíăëčéńęčé (Ŕâńňđŕëč˙) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENA) +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_AUS +#pragma code_page(1252) + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_ADD_MODULE DIALOGEX 0, 0, 186, 67 +STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Add a module to contact" +FONT 8, "MS Shell Dlg", 0, 0, 0x0 +BEGIN + EDITTEXT IDC_MODNAME,7,17,172,12,ES_AUTOHSCROLL + LTEXT "Add a module named",IDC_ADDMODNAMESTATIC,7,6,124,8 + CONTROL "Add to all contacts (Includes Settings)",CHK_COPY2ALL, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,35,172,10 + DEFPUSHBUTTON "OK",IDOK,29,49,50,14 + PUSHBUTTON "Cancel",IDCANCEL,107,49,50,14 +END + +IDD_EDIT_SETTING DIALOGEX 0, 0, 252, 121 +STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION +CAPTION "Edit Setting" +FONT 8, "MS Shell Dlg", 0, 0, 0x0 +BEGIN + EDITTEXT IDC_SETTINGNAME,7,18,238,14,ES_AUTOHSCROLL + EDITTEXT IDC_SETTINGVALUE,7,49,159,14,ES_AUTOHSCROLL + EDITTEXT IDC_STRING,49,37,196,61,ES_MULTILINE | ES_WANTRETURN | NOT WS_VISIBLE | WS_VSCROLL | WS_HSCROLL + EDITTEXT IDC_BLOB,49,37,196,61,ES_MULTILINE | NOT WS_VISIBLE | WS_VSCROLL + RADIOBUTTON "Byte",CHK_BYTE,13,81,30,10 + RADIOBUTTON "Word",CHK_WORD,50,81,33,10 + RADIOBUTTON "Dword",CHK_DWORD,90,81,37,10 + RADIOBUTTON "String",CHK_STRING,132,81,34,10 + DEFPUSHBUTTON "OK",IDOK,70,102,50,14 + PUSHBUTTON "Cancel",IDCANCEL,132,102,50,14 + RADIOBUTTON "Hexadecimal",CHK_HEX,182,49,57,10 + RADIOBUTTON "Decimal",CHK_DECIMAL,182,62,41,10 + LTEXT "Value Name:",IDC_STATIC,7,7,42,8 + LTEXT "Value Data:",IDC_STATIC,7,37,38,8 + GROUPBOX "Base",GRP_BASE,174,37,71,38 + GROUPBOX "Save Value as:",GRP_TYPE,7,67,160,29 +END + +IDD_WATCH_DIAG DIALOGEX 0, 0, 414, 190 +STYLE DS_SETFONT | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CLIPCHILDREN | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME +CAPTION "Watched Database Variables" +MENU IDR_WATCHWINDOWMENU +FONT 8, "MS Shell Dlg", 0, 0, 0x0 +BEGIN + CONTROL "List1",IDC_VARS,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_SORTDESCENDING | LVS_SHAREIMAGELISTS | LVS_AUTOARRANGE | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,0,0,414,190 +END + +IDD_COPY_MOD DIALOGEX 0, 0, 186, 67 +STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Copy module to contact" +FONT 8, "MS Shell Dlg", 0, 0, 0x0 +BEGIN + COMBOBOX IDC_CONTACTS,7,17,172,99,CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL | WS_TABSTOP + CONTROL "Copy to all contacts (Includes Settings)",CHK_COPY2ALL, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,35,172,10 + DEFPUSHBUTTON "OK",IDOK,29,49,50,14 + PUSHBUTTON "Cancel",IDCANCEL,107,49,50,14 + LTEXT "Contact to copy module and settings to",IDC_INFOTEXT,7,6,124,8 +END + +IDD_IMPORT DIALOGEX 0, 0, 268, 170 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Import Module/Settings" +FONT 8, "MS Shell Dlg", 0, 0, 0x0 +BEGIN + EDITTEXT IDC_TEXT,7,18,254,124,ES_MULTILINE | ES_WANTRETURN | WS_VSCROLL | WS_HSCROLL + DEFPUSHBUTTON "Import",IDOK,153,149,50,14 + PUSHBUTTON "Cancel",IDCANCEL,211,149,50,14 + PUSHBUTTON "Insert &CR/LF",IDC_CRLF,20,149,58,14 + LTEXT "Paste the Settings to import here.",IDC_STATIC,7,7,105,8 +END + +IDD_MAIN DIALOGEX 0, 0, 408, 225 +STYLE DS_ABSALIGN | DS_SETFONT | DS_FIXEDSYS | DS_CENTER | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CLIPCHILDREN | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME +CAPTION "DBEditor++" +MENU IDR_MAINMENU +FONT 8, "MS Shell Dlg", 0, 0, 0x0 +BEGIN + CONTROL "Tree1",IDC_MODULES,"SysTreeView32",TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT | TVS_EDITLABELS | TVS_DISABLEDRAGDROP | TVS_SHOWSELALWAYS | WS_BORDER | WS_HSCROLL | WS_TABSTOP,0,3,102,222 + CONTROL "List1",IDC_SETTINGS,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_SORTASCENDING | LVS_SHAREIMAGELISTS | WS_BORDER | WS_TABSTOP,103,3,305,222 + CONTROL "",IDC_SPLITTER,"Static",SS_ENHMETAFILE,102,3,1,222 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_ADD_MODULE, DIALOG + BEGIN + LEFTMARGIN, 7 + TOPMARGIN, 7 + BOTTOMMARGIN, 63 + END + + IDD_EDIT_SETTING, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 245 + VERTGUIDE, 166 + VERTGUIDE, 174 + VERTGUIDE, 182 + TOPMARGIN, 7 + BOTTOMMARGIN, 116 + HORZGUIDE, 37 + HORZGUIDE, 49 + HORZGUIDE, 67 + HORZGUIDE, 75 + HORZGUIDE, 81 + END + + IDD_COPY_MOD, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 179 + TOPMARGIN, 7 + BOTTOMMARGIN, 63 + END + + IDD_IMPORT, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 261 + TOPMARGIN, 7 + BOTTOMMARGIN, 163 + END + + IDD_MAIN, DIALOG + BEGIN + VERTGUIDE, 102 + VERTGUIDE, 103 + TOPMARGIN, 3 + END +END +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +ICO_REGEDIT ICON "res\\Icon_1.ico" +ICO_DBE_BUTT ICON "res\\dbepp.ico" +ICO_REGUSER ICON "res\\usermenu.ico" +ICO_STRING ICON "res\\Icon_14.ico" +ICO_CONTACTS ICON "res\\Contacts.ico" +ICO_BINARY ICON "res\\Icon_15.ico" +ICO_DWORD ICON "res\\Icon_16.ico" +ICO_BYTE ICON "res\\Icon_17.ico" +ICO_WORD ICON "res\\Icon_18.ico" +ICO_OFFLINE ICON "res\\offline2.ico" +ICO_UNICODE ICON "res\\unicode.ico" +ICO_HANDLE ICON "res\\handle.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Menu +// + +IDR_MAINMENU MENU +BEGIN + POPUP "&Main" + BEGIN + MENUITEM "&Refresh Modules", MENU_REFRESH_MODS + MENUITEM "Refresh &Settings", MENU_REFRESH_SETS + MENUITEM SEPARATOR + MENUITEM "E&xit", MENU_EXIT + END + POPUP "&Actions" + BEGIN + MENUITEM "&Search and Replace", MENU_FINDANDREPLACE + MENUITEM SEPARATOR + MENUITEM "&Delete Module", MENU_DELETE + END + POPUP "&Watches" + BEGIN + MENUITEM "&View all", MENU_VIEW_WATCHES + MENUITEM "&Delete all", MENU_REMALL_WATCHES + END + POPUP "&Export" + BEGIN + MENUITEM "Entire &Database", MENU_EXPORTDB + MENUITEM "All &Settings", MENU_EXPORTMODULE + MENUITEM "All &Contacts", MENU_EXPORTCONTACT + END + POPUP "&Import" + BEGIN + MENUITEM "From a &file", MENU_IMPORTFROMFILE + MENUITEM "From pasted &text", MENU_IMPORTFROMTEXT + END + POPUP "&Options" + BEGIN + MENUITEM "&Sort by protocol", MENU_SORT_ORDER + MENUITEM SEPARATOR + MENUITEM "Show &All", MENU_FILTER_ALL + MENUITEM "Show only &Loaded", MENU_FILTER_LOADED + MENUITEM "Show only &Unloaded", MENU_FILTER_UNLOADED + MENUITEM SEPARATOR + MENUITEM "Edit &Bytes in Hex", MENU_BYTE_HEX + MENUITEM "Edit &Words in Hex", MENU_WORD_HEX + MENUITEM "Edit &Dwords in Hex", MENU_DWORD_HEX + MENUITEM SEPARATOR + MENUITEM "&Restore position", MENU_SAVE_POSITION + MENUITEM "&Open Options", MENU_OPEN_OPTIONS + END +END + +IDR_CONTEXTMENU MENU +BEGIN + POPUP "Item context" + BEGIN + MENUITEM "&Edit / Rename", MENU_EDIT_SET + MENUITEM SEPARATOR + POPUP "NEW" + BEGIN + MENUITEM "&Byte", MENU_ADD_BYTE + MENUITEM "&Word", MENU_ADD_WORD + MENUITEM "&Dword", MENU_ADD_DWORD + MENUITEM "&String", MENU_ADD_STRING + MENUITEM "&Unicode", MENU_ADD_UNICODE + MENUITEM "BL&OB", MENU_ADD_BLOB + END + POPUP "&Convert to" + BEGIN + MENUITEM "&Byte", MENU_CHANGE2BYTE + MENUITEM "&Word", MENU_CHANGE2WORD + MENUITEM "&Dword", MENU_CHANGE2DWORD + MENUITEM "&String", MENU_CHANGE2STRING + MENUITEM "&Unicode", MENU_CHANGE2UNICODE + END + POPUP "Encyption" + BEGIN + MENUITEM "View Decrypted String", MENU_VIEWDECRYPT + MENUITEM "View Encrypted String", MENU_VIEWENCRYPT + MENUITEM "Decrypt String", MENU_DECRYPT + MENUITEM "Encrypt String", MENU_ENCRYPT + END + MENUITEM SEPARATOR + MENUITEM "&Watch", MENU_WATCH_ITEM + MENUITEM "&Delete", MENU_DELETE_SET + END + POPUP "Null Mod context" + BEGIN + MENUITEM "&Rename", MENU_RENAME_MOD + MENUITEM "Copy To Contact", MENU_COPY_MOD + MENUITEM SEPARATOR + MENUITEM "Export Module", MENU_EXPORTMODULE + MENUITEM "Add To Known Modules", MENU_ADDKNOWN + MENUITEM SEPARATOR + MENUITEM "&Watch", MENU_WATCH_ITEM + MENUITEM "&Delete", MENU_DELETE_MOD + END + POPUP "Contact menu" + BEGIN + MENUITEM "&Clone", MENU_CLONE_CONTACT + MENUITEM "&Delete", MENU_DELETE_CONTACT + MENUITEM SEPARATOR + MENUITEM "Export Contact", MENU_EXPORTCONTACT + POPUP "Import Settings" + BEGIN + MENUITEM "From a file", MENU_IMPORTFROMFILE + MENUITEM "From pasted text", MENU_IMPORTFROMTEXT + END + MENUITEM SEPARATOR + MENUITEM "&Add Module", MENU_ADD_MODULE + END + POPUP "NULL contact menu" + BEGIN + MENUITEM "&Add Module", MENU_ADD_MODULE + MENUITEM "Export Settings", MENU_EXPORTCONTACT + POPUP "Import Settings" + BEGIN + MENUITEM "From a file", MENU_IMPORTFROMFILE + MENUITEM "From pasted text", MENU_IMPORTFROMTEXT + END + END + POPUP "Contacts menu" + BEGIN + MENUITEM "Export Contacts", MENU_EXPORTCONTACT + POPUP "Import Contacts" + BEGIN + MENUITEM "From a file", MENU_IMPORTFROMFILE + MENUITEM "From pasted text", MENU_IMPORTFROMTEXT + END + END + POPUP "Contact Mod context" + BEGIN + MENUITEM "&Rename", MENU_RENAME_MOD + MENUITEM "Copy To Contact", MENU_COPY_MOD + MENUITEM SEPARATOR + MENUITEM "Export Module", MENU_EXPORTMODULE + MENUITEM "Export Module from all contacts", MENU_EXPORTDB + MENUITEM "Add To Known Modules", MENU_ADDKNOWN + MENUITEM SEPARATOR + MENUITEM "&Watch", MENU_WATCH_ITEM + MENUITEM "&Delete", MENU_DELETE_MOD + END + POPUP "new item" + BEGIN + POPUP "NEW" + BEGIN + MENUITEM "&Byte", MENU_ADD_BYTE + MENUITEM "&Word", MENU_ADD_WORD + MENUITEM "&Dword", MENU_ADD_DWORD + MENUITEM "&String", MENU_ADD_STRING + MENUITEM "&Unicode", MENU_ADD_UNICODE + MENUITEM "BL&OB", MENU_ADD_BLOB + END + END +END + +IDR_WATCHWINDOWMENU MENU +BEGIN + POPUP "Watch Window" + BEGIN + MENUITEM "Reload Watch List", MENU_REFRESH + MENUITEM "&Delete all", MENU_REMALL_WATCHES + MENUITEM SEPARATOR + MENUITEM "E&xit", MENU_EXIT + END +END + +#endif // Ŕíăëčéńęčé (Ŕâńňđŕëč˙) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/plugins/DbeditorPP/settinglist.cpp b/plugins/DbeditorPP/settinglist.cpp new file mode 100644 index 0000000000..5fff4fed21 --- /dev/null +++ b/plugins/DbeditorPP/settinglist.cpp @@ -0,0 +1,1261 @@ +#include "headers.h" + +int UOS; + +void setupSettingsList(HWND hwnd2List) +{ + LVCOLUMN sLC; + + ListView_SetUnicodeFormat(hwnd2List, UOS); + + sLC.fmt = LVCFMT_LEFT; + ListView_SetExtendedListViewStyle(hwnd2List, 32|LVS_EX_SUBITEMIMAGES); //LVS_EX_FULLROWSELECT + sLC.mask = LVCF_FMT | LVCF_TEXT | LVCF_SUBITEM | LVCF_WIDTH; + + sLC.pszText = Translate("Name"); + sLC.cx = DBGetContactSettingWord(NULL, modname, "Column0width", 145); + ListView_InsertColumn(hwnd2List,0,&sLC); + sLC.pszText = Translate("Data"); + sLC.cx = DBGetContactSettingWord(NULL, modname, "Column1width", 145); + ListView_InsertColumn(hwnd2List,1,&sLC); + sLC.pszText = Translate("Type"); + sLC.cx = DBGetContactSettingWord(NULL, modname, "Column2width", 60); + ListView_InsertColumn(hwnd2List,2,&sLC); + sLC.pszText = Translate("Size"); + sLC.cx = DBGetContactSettingWord(NULL, modname, "Column3width", 80); + ListView_InsertColumn(hwnd2List,3,&sLC); +} + + +void saveListSettings(HWND hwnd2List) +{ + int i; + LVCOLUMN sLC = {0}; + char tmp[33]; tmp[32] = 0; + + sLC.mask = LVCF_WIDTH; + + for (i=0; i <= 3; i++) + if (ListView_GetColumn(hwnd2List,i,&sLC)) + { + mir_snprintf(tmp, SIZEOF(tmp), "Column%dwidth", i); + DBWriteContactSettingWord(NULL, modname, tmp, (WORD)sLC.cx); + } + +} + + +void ClearListview(HWND hwnd2Settings) +{ + SettingListInfo *info = (SettingListInfo*)GetWindowLongPtr(hwnd2Settings,GWLP_USERDATA); + if (info && ListView_GetItemCount(hwnd2Settings)) + { + mir_free(info->module); + if (info->hwnd2Edit) + { + SendMessage(info->hwnd2Edit,WM_COMMAND,MAKEWPARAM(IDCANCEL,0),0); + info->hwnd2Edit = NULL; + } + mir_free(info); + SetWindowLongPtr(hwnd2Settings,GWLP_USERDATA, 0); + } + ListView_DeleteAllItems(hwnd2Settings); +} + +void DeleteSettingsFromList(HWND hSettings, HANDLE hContact, char *module, char *setting) +{ + int count = ListView_GetSelectedCount(hSettings); + + if (!count) return; + else + if (count == 1) + { + DBDeleteContactSetting(hContact,module,setting); + } + else + { + int items = ListView_GetItemCount(hSettings); + int i = 0; + char text[256]; + + while(i")); + ListView_SetItemText(hwnd2Settings,index,2,Translate("UNICODE")); + ListView_SetItemText(hwnd2Settings,index,3,Translate("")); + } + else + ListView_DeleteItem(hwnd2Settings,index); + + DBFreeVariant(&dbv); + mir_free(data); +} + +void PopulateSettings(HWND hwnd2Settings, HANDLE hContact, char* module) +{ + SettingListInfo* info = (SettingListInfo*)mir_calloc(sizeof(SettingListInfo)); + LVITEM lvItem; + + struct ModSetLinkLinkItem *setting; + ModuleSettingLL setlist; + if (!EnumSettings(hContact,module,&setlist)) { msg(Translate("Error Loading Setting List"),modFullname); mir_free(info); return;} + + // clear any settings that may be there... + ClearListview(hwnd2Settings); + + info->hContact = hContact; + info->module = mir_tstrdup(module); + SetWindowLongPtr(hwnd2Settings,GWLP_USERDATA, (LONG)info); + + // icons + if (himl2) ListView_SetImageList(hwnd2Settings, himl2, LVSIL_SMALL); + + lvItem.mask = LVIF_TEXT; + lvItem.iItem = 0; + lvItem.iSubItem = 0; + setting = setlist.first; + + while (setting) + { + lvItem.pszText = setting->name; + additem(hwnd2Settings,hContact,module, setting->name, ListView_InsertItem(hwnd2Settings,&lvItem)); + setting = (struct ModSetLinkLinkItem *)setting->next; + } + + FreeModuleSettingLL(&setlist); +} + + +void SelectSetting(char* setting) +{ + LVITEM lvItem; + LVFINDINFO lvfi; + HWND hwnd2Settings = GetDlgItem(hwnd2mainWindow,IDC_SETTINGS); + + lvfi.flags = LVFI_STRING; + lvfi.psz = setting; + lvfi.vkDirection = VK_DOWN; + + lvItem.mask = LVIF_TEXT; + lvItem.iItem = ListView_FindItem(hwnd2Settings,-1,&lvfi); + if (lvItem.iItem != -1) + { + lvItem.mask = LVIF_STATE; + lvItem.state = LVIS_SELECTED | LVIS_FOCUSED; + lvItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED; + ListView_SetItem(hwnd2Settings,&lvItem); + } +} + +void settingChanged(HWND hwnd2Settings, HANDLE hContact, char* module, char* setting) +{ + LVITEM lvItem; + LVFINDINFO lvfi; + + lvfi.flags = LVFI_STRING; + lvfi.psz = setting; + lvfi.vkDirection = VK_DOWN; + + lvItem.mask = LVIF_TEXT|LVIF_IMAGE; + lvItem.iItem = ListView_FindItem(hwnd2Settings,-1,&lvfi); + lvItem.iSubItem = 0; + + if (lvItem.iItem == -1) + { + lvItem.iItem = 0; + lvItem.pszText = setting; + lvItem.cchTextMax = mir_strlen(setting); + lvItem.iItem = ListView_InsertItem(hwnd2Settings,&lvItem); + } + additem(hwnd2Settings,hContact,module, setting,lvItem.iItem); +} + +static WNDPROC SettingLabelEditSubClass; + +typedef struct { + HANDLE hContact; + char module[256]; + char setting[256]; + int item; + int subitem; + HWND hwnd; + int unicode; +} EditLabelInfoStruct; + +void writeStandardTextfromLabel(EditLabelInfoStruct* info, char* value, WCHAR *wc, int type) +{ + if (type != DBVT_ASCIIZ && type != DBVT_UTF8) + DBDeleteContactSetting(info->hContact,info->module,info->setting); + if (type == DBVT_UTF8 && wc) + { + DBWriteContactSettingWString(info->hContact,info->module,info->setting,wc); + mir_free(wc); + } + else + DBWriteContactSettingString(info->hContact,info->module,info->setting,value); + +} + +static LRESULT CALLBACK SettingLabelEditSubClassProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam) +{ + EditLabelInfoStruct* info = (EditLabelInfoStruct*)GetWindowLongPtr(hwnd,GWLP_USERDATA); + switch(msg) { + case WM_KEYDOWN: + switch (wParam) + { + case VK_RETURN: + if (GetKeyState(VK_CONTROL)&0x8000) // ctrl is pressed + break; + SendMessage(hwnd,WM_COMMAND,MAKEWPARAM(IDOK,0),0); + return 0; + case VK_ESCAPE: + SendMessage(hwnd,WM_COMMAND,MAKEWPARAM(IDCANCEL,0),0); + return 0; + } + break; + case WM_USER: + SetWindowLongPtr(hwnd,GWLP_USERDATA,lParam); + SetFocus(hwnd); + SendMessage(hwnd, WM_SETFONT, SendMessage(GetParent(hwnd), WM_GETFONT, 0, 0), 1); + info = ((EditLabelInfoStruct*)lParam); + if (info->subitem) + SendMessage(hwnd, EM_LIMITTEXT, (WPARAM)65535, 0); + else + SendMessage(hwnd, EM_LIMITTEXT, (WPARAM)255, 0); + SendMessage(hwnd, EM_SETSEL,0,-1); + break; + case WM_PAINT: + break; + case WM_COMMAND: + switch (LOWORD(wParam)) + { + case IDOK: + { + int len = GetWindowTextLength(hwnd)+1; + char *value = (char*)_alloca(len); + WCHAR *wc = NULL; + DBVARIANT dbv = {0}; + + GetWindowText(hwnd,value,len); + + if (info->unicode) + wc = mir_a2u(value); + + if (len <= 1 || GetSetting(info->hContact,info->module,info->setting,&dbv)) + { + SendMessage(hwnd,WM_COMMAND,MAKEWPARAM(IDCANCEL,0),0); + return 0; + } + + switch (info->subitem) + { + case 0:// setting name + if (!mir_strcmp(info->setting,value) || mir_strlen(value)>255) + { + DBFreeVariant(&dbv); + SendMessage(hwnd,WM_COMMAND,MAKEWPARAM(IDCANCEL,0),0); + return 0; + } + switch (dbv.type) + { + case DBVT_UTF8: + DBWriteContactSettingStringUtf(info->hContact,info->module,value,dbv.pszVal); + break; + case DBVT_ASCIIZ: + DBWriteContactSettingString(info->hContact,info->module,value,dbv.pszVal); + break; + case DBVT_BYTE: + DBWriteContactSettingByte(info->hContact,info->module,value,dbv.bVal); + break; + case DBVT_WORD: + DBWriteContactSettingWord(info->hContact,info->module,value,dbv.wVal); + break; + case DBVT_DWORD: + DBWriteContactSettingDword(info->hContact,info->module,value,dbv.dVal); + break; + case DBVT_BLOB: + DBWriteContactSettingBlob(info->hContact,info->module,value,dbv.pbVal,dbv.cpbVal); + break; + } + DBDeleteContactSetting(info->hContact,info->module,info->setting); + { + LVFINDINFO lvfi; + int item; + + lvfi.flags = LVFI_STRING; + lvfi.psz = info->setting; + lvfi.vkDirection = VK_DOWN; + + item = ListView_FindItem(info->hwnd,-1,&lvfi); + ListView_DeleteItem(info->hwnd,item); + } + break; + case 1: // value + { + int val; + int i = 0; + + if (dbv.type == DBVT_BLOB) + { + WriteBlobFromString(info->hContact,info->module,info->setting,value,len); + break; + } + + switch (value[0]) + { + case 'b': + case 'B': + if (value[1] == '0' && (value[2] == 'x' || value[2] == 'X')) + sscanf(&value[3],"%x",&val); + else if (value[1] >= '0' && value[1] <= '9') + { + val = atoi(&value[1]); + if (dbv.type == DBVT_ASCIIZ || dbv.type == DBVT_UTF8) + DBDeleteContactSetting(info->hContact,info->module,info->setting); + + DBWriteContactSettingByte(info->hContact,info->module,info->setting,(BYTE)val); + } + else + writeStandardTextfromLabel(info, value, wc, dbv.type); + break; + case 'w': + case 'W': + if (value[1] == '0' && (value[2] == 'x' || value[2] == 'X')) + sscanf(&value[3],"%x",&val); + else if (value[1] >= '0' && value[1] <= '9') + { + val = atoi(&value[1]); + if (dbv.type == DBVT_ASCIIZ || dbv.type == DBVT_UTF8) + DBDeleteContactSetting(info->hContact,info->module,info->setting); + DBWriteContactSettingWord(info->hContact,info->module,info->setting,(WORD)val); + } + else + writeStandardTextfromLabel(info, value, wc, dbv.type); + break; + case 'd': + case 'D': + if (value[1] == '0' && (value[2] == 'x' || value[2] == 'X')) + sscanf(&value[3],"%x",&val); + else if (value[1] >= '0' && value[1] <= '9') + { + val = atoi(&value[1]); + if (dbv.type == DBVT_ASCIIZ || dbv.type == DBVT_UTF8) + DBDeleteContactSetting(info->hContact,info->module,info->setting); + DBWriteContactSettingDword(info->hContact,info->module,info->setting,val); + } + else + writeStandardTextfromLabel(info, value, wc, dbv.type); + break; + case '0': + i=1; + case 'x': + case 'X': + if (value[i] == 'x' || value[i] == 'X') + { + + sscanf(&value[i+1],"%x",&val); + switch (dbv.type) + { + case DBVT_UTF8: + case DBVT_ASCIIZ: + writeStandardTextfromLabel(info, value, wc, dbv.type); + break; + case DBVT_BYTE: + DBWriteContactSettingByte(info->hContact,info->module,info->setting,(BYTE)val); + break; + case DBVT_WORD: + DBWriteContactSettingWord(info->hContact,info->module,info->setting,(WORD)val); + break; + case DBVT_DWORD: + DBWriteContactSettingDword(info->hContact,info->module,info->setting,(DWORD)val); + break; + } + } + else + { + val = atoi(value); + switch (dbv.type) + { + case DBVT_ASCIIZ: + case DBVT_UTF8: + writeStandardTextfromLabel(info, value, wc, dbv.type); + break; + case DBVT_BYTE: + DBWriteContactSettingByte(info->hContact,info->module,info->setting,(BYTE)val); + break; + case DBVT_WORD: + DBWriteContactSettingWord(info->hContact,info->module,info->setting,(WORD)val); + break; + case DBVT_DWORD: + DBWriteContactSettingDword(info->hContact,info->module,info->setting,(DWORD)val); + break; + } + } + break; + case '\"': + case '\'': + { + int nlen = mir_strlen(value); + int sh = 0; + if (nlen > 3) + { + if (value[nlen-1] == value[0]) + { + value[nlen-1] = '\0'; + sh = 1; + } + } + writeStandardTextfromLabel(info, &value[sh], wc, dbv.type); + } + break; + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case '-': + val = atoi(value); + switch (dbv.type) + { + case DBVT_ASCIIZ: + case DBVT_UTF8: + writeStandardTextfromLabel(info, value, wc, dbv.type); + break; + case DBVT_BYTE: + DBWriteContactSettingByte(info->hContact,info->module,info->setting,(BYTE)val); + break; + case DBVT_WORD: + DBWriteContactSettingWord(info->hContact,info->module,info->setting,(WORD)val); + break; + case DBVT_DWORD: + DBWriteContactSettingDword(info->hContact,info->module,info->setting,(DWORD)val); + break; + } + break; + default: + writeStandardTextfromLabel(info, value, wc, dbv.type); + break; + } // switch (value[0]) + } + break; // case 1: + } + DBFreeVariant(&dbv); + } // fall through + case IDCANCEL: + { + SettingListInfo *sli = (SettingListInfo*)GetWindowLongPtr(info->hwnd,GWLP_USERDATA); + + if (sli && sli->hwnd2Edit==hwnd) + sli->hwnd2Edit = NULL; + + mir_free(info); + DestroyWindow(hwnd); + } + return 0; + } + break; // wm_command + case WM_GETDLGCODE: + return DLGC_WANTALLKEYS; + } + if (UOS) + return CallWindowProcW(SettingLabelEditSubClass,hwnd,msg,wParam,lParam); + else + return CallWindowProc(SettingLabelEditSubClass,hwnd,msg,wParam,lParam); +} + + +void EditLabel(HWND hwnd2List, int item, int subitem) +{ + RECT rc; + LVITEM lvi; + char setting[256], value[16] = {0}; + DBVARIANT dbv; + SettingListInfo* info = (SettingListInfo*)GetWindowLongPtr(hwnd2List,GWLP_USERDATA); + EditLabelInfoStruct *data = (EditLabelInfoStruct*)mir_calloc(sizeof(EditLabelInfoStruct)); + if (!data || !info) return; + if (info->hwnd2Edit) + { + SendMessage(info->hwnd2Edit,WM_COMMAND,MAKEWPARAM(IDCANCEL,0),0); // ignore the new value of the last edit + info->hwnd2Edit = NULL; + } + lvi.mask = LVIF_TEXT; + lvi.iItem = item; + lvi.iSubItem = 0; + lvi.pszText = setting; + lvi.cchTextMax = 256; + + if (!ListView_GetItem(hwnd2List, &lvi) || + !ListView_GetSubItemRect + (hwnd2List,item,subitem,LVIR_LABEL,&rc) || + GetSetting(info->hContact,info->module,setting,&dbv)) + { + mir_free(data); + return; + } + + data->hContact = info->hContact; + strcpy(data->module, info->module); + strcpy(data->setting, setting); + data->item = item; + data->subitem = subitem; + data->hwnd = hwnd2List; + + // fix size for long strings + + switch (dbv.type) + { + case DBVT_UTF8: + if (subitem && UOS) + { + int len = mir_strlen(dbv.pszVal)+1; + WCHAR *wc = (WCHAR*)_alloca(len*sizeof(WCHAR)); + MultiByteToWideChar(CP_UTF8, 0, dbv.pszVal, -1, wc, len); + data->unicode = 1; + info->hwnd2Edit = CreateWindowW(L"EDIT",wc,WS_BORDER|WS_VISIBLE|WS_CHILD|WS_VSCROLL|ES_MULTILINE|ES_AUTOHSCROLL, rc.left,rc.top,(int)((rc.right - rc.left)*1.5),(rc.bottom - rc.top)*3,hwnd2List, 0,hInst,0); + break; + } + // fall through + case DBVT_ASCIIZ: + if (subitem) { + // convert from UTF8 + info->hwnd2Edit = CreateWindow("EDIT",dbv.pszVal,WS_BORDER|WS_VISIBLE|WS_CHILD|WS_VSCROLL|ES_MULTILINE|ES_AUTOHSCROLL, rc.left,rc.top,(int)((rc.right - rc.left)*1.5),(rc.bottom - rc.top)*3,hwnd2List, 0,hInst,0); + } + else + info->hwnd2Edit = CreateWindow("EDIT",setting,WS_BORDER|WS_VISIBLE|WS_CHILD|ES_AUTOHSCROLL, rc.left,rc.top,(rc.right - rc.left),(rc.bottom - rc.top),hwnd2List, 0,hInst,0); + break; + case DBVT_BYTE: + if (Hex&HEX_BYTE) + mir_snprintf(value, SIZEOF(value), "0x%02X", dbv.bVal); + else + itoa(dbv.bVal,value,10); + info->hwnd2Edit = CreateWindow("EDIT",!subitem?setting:value,WS_BORDER|WS_VISIBLE|WS_CHILD|ES_AUTOHSCROLL, rc.left,rc.top,(rc.right - rc.left),(rc.bottom - rc.top),hwnd2List, 0,hInst,0); + break; + case DBVT_WORD: + if (Hex&HEX_WORD) + mir_snprintf(value, SIZEOF(value), "0x%04X", dbv.wVal); + else + itoa(dbv.wVal,value,10); + info->hwnd2Edit = CreateWindow("EDIT",!subitem?setting:value,WS_BORDER|WS_VISIBLE|WS_CHILD|ES_AUTOHSCROLL, rc.left,rc.top,(rc.right - rc.left),(rc.bottom - rc.top),hwnd2List, 0,hInst,0); + break; + case DBVT_DWORD: + if (Hex&HEX_DWORD) + mir_snprintf(value, SIZEOF(value), "0x%08X", dbv.dVal); + else + itoa(dbv.dVal,value,10); + info->hwnd2Edit = CreateWindow("EDIT",!subitem?setting:value,WS_BORDER|WS_VISIBLE|WS_CHILD|ES_AUTOHSCROLL, rc.left,rc.top,(rc.right - rc.left),(rc.bottom - rc.top),hwnd2List, 0,hInst,0); + break; + case DBVT_BLOB: + if (!subitem) + info->hwnd2Edit = CreateWindow("EDIT",setting,WS_BORDER|WS_VISIBLE|WS_CHILD|ES_AUTOHSCROLL, rc.left,rc.top,(rc.right - rc.left),(rc.bottom - rc.top),hwnd2List, 0,hInst,0); + else + { + int j; + char tmp[16]; + char *data = (char*)_alloca(3*(dbv.cpbVal+1)+10); + + if (!data) {msg(Translate("Couldnt allocate enough memory!"), modFullname); return;} + data[0] = '\0'; + + for(j=0; jhwnd2Edit = CreateWindow("EDIT",data,WS_BORDER|WS_VISIBLE|WS_CHILD|WS_VSCROLL|ES_MULTILINE, rc.left,rc.top,(int)((rc.right - rc.left)*1.5),(rc.bottom - rc.top)*3,hwnd2List,0,hInst,0); + } + break; + default: return; + } + + DBFreeVariant(&dbv); + + if (UOS) + SettingLabelEditSubClass=(WNDPROC)SetWindowLongPtrW(info->hwnd2Edit,GWLP_WNDPROC,(LONG)SettingLabelEditSubClassProc); + else + SettingLabelEditSubClass=(WNDPROC)SetWindowLongPtr(info->hwnd2Edit,GWLP_WNDPROC,(LONG)SettingLabelEditSubClassProc); + + SendMessage(info->hwnd2Edit,WM_USER,0,(LPARAM)data); +} + +static int test; +void SettingsListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam); +static int lastColumn = -1; + +struct SettingsSortParams{ + HWND hList; + int column; +}; + +INT_PTR CALLBACK SettingsCompare(LPARAM lParam1, LPARAM lParam2, LPARAM myParam) +{ + SettingsSortParams params = *(SettingsSortParams *) myParam; + const int maxSize = 1024; + TCHAR text1[maxSize]; + TCHAR text2[maxSize]; + ListView_GetItemText(params.hList, (int) lParam1, params.column, text1, maxSize); + ListView_GetItemText(params.hList, (int) lParam2, params.column, text2, maxSize); + + int res = _tcsicmp(text1, text2); + res = (params.column == lastColumn) ? -res : res; + return res; +} + +void SettingsListWM_NOTIFY(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam) +{ + switch(((NMHDR*)lParam)->code) + { + case NM_CLICK: + { + SettingListInfo* info = (SettingListInfo*)GetWindowLongPtr(GetDlgItem(hwnd,IDC_SETTINGS),GWLP_USERDATA); + + LVHITTESTINFO hti; + hti.pt=((NMLISTVIEW*)lParam)->ptAction; + if (DBGetContactSettingByte(NULL,modname,"DontAllowInLineEdit",0) || !IsWinVer2000Plus()) /* fix for TioDuke and win98 */ + break; + if (info && ListView_SubItemHitTest(GetDlgItem(hwnd,IDC_SETTINGS),&hti) >-1) + { + if (hti.iSubItem < 2 && hti.flags != LVHT_ONITEMICON) + { + if (info->selectedItem == hti.iItem) + EditLabel(GetDlgItem(hwnd,IDC_SETTINGS),hti.iItem,hti.iSubItem); + else if (info->hwnd2Edit) + { + SendMessage(info->hwnd2Edit,WM_COMMAND,MAKEWPARAM(IDOK,0),0); + info->hwnd2Edit = NULL; + info->selectedItem = hti.iItem; + } + else info->selectedItem = hti.iItem; + } + else + { + if (info->hwnd2Edit) + { + SendMessage(info->hwnd2Edit,WM_COMMAND,MAKEWPARAM(IDOK,0),0); + info->hwnd2Edit = NULL; + } + info->selectedItem = hti.iItem; + } + } + else if (info && info->hwnd2Edit) + { + SendMessage(info->hwnd2Edit,WM_COMMAND,MAKEWPARAM(IDOK,0),0); + info->hwnd2Edit = NULL; + info->selectedItem = 0; + } + break; + } + + case NM_DBLCLK: + { + SettingListInfo* info = (SettingListInfo*)GetWindowLongPtr(GetDlgItem(hwnd,IDC_SETTINGS),GWLP_USERDATA); + + LVHITTESTINFO hti; + + hti.pt=((NMLISTVIEW*)lParam)->ptAction; + if (info && ListView_SubItemHitTest(GetDlgItem(hwnd,IDC_SETTINGS),&hti) >-1) + { + if ((hti.iSubItem > 1 || hti.flags == LVHT_ONITEMICON) || (DBGetContactSettingByte(NULL,modname,"DontAllowInLineEdit",0) || !IsWinVer2000Plus()/* fix for TioDuke and win98 */ )) + { + char setting[256]; + SendMessage(info->hwnd2Edit,WM_COMMAND,MAKEWPARAM(IDOK,0),0); + info->hwnd2Edit = NULL; + ListView_GetItemText(GetDlgItem(hwnd, IDC_SETTINGS), hti.iItem, 0, setting, 256); + editSetting(info->hContact,info->module, setting); + } + else EditLabel(GetDlgItem(hwnd,IDC_SETTINGS),hti.iItem,hti.iSubItem); + } + break; + } + + case NM_RCLICK: + SettingsListRightClick(hwnd,wParam,lParam); + break; + + case LVN_COLUMNCLICK: + { + LPNMLISTVIEW lv = (LPNMLISTVIEW) lParam; + SettingsSortParams params = {0}; + params.hList = GetDlgItem(hwnd, IDC_SETTINGS); + params.column = lv->iSubItem; + ListView_SortItemsEx(params.hList, SettingsCompare, (LPARAM) ¶ms); + lastColumn = (params.column == lastColumn) ? -1 : params.column; + break; + } + + } // switch(((NMHDR*)lParam)->code) +} + +void SettingsListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam) // hwnd here is to the main window, NOT the listview +{ + HWND hSettings = GetDlgItem(hwnd,IDC_SETTINGS); + SettingListInfo* info = (SettingListInfo*)GetWindowLongPtr(hSettings,GWLP_USERDATA); + char setting[256], *module; + HANDLE hContact; + LVHITTESTINFO hti; + POINT pt; + HMENU hMenu, hSubMenu; + + if (!info) return; + module = info->module; + hContact = info->hContact; + + hti.pt=((NMLISTVIEW*)lParam)->ptAction; + if (ListView_SubItemHitTest(hSettings,&hti) == -1) + { + // nowhere.. new item menu + GetCursorPos(&pt); + hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_CONTEXTMENU)); + hSubMenu = GetSubMenu(hMenu, 6); + TranslateMenu(hSubMenu); + + if (!UDB) + RemoveMenu(hSubMenu, MENU_ADD_UNICODE, MF_BYCOMMAND); + + switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwnd, NULL)) + { + case MENU_ADD_BYTE: + { + struct DBsetting *dbsetting = (struct DBsetting *)mir_alloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc + DBVARIANT dbv = {0}; // freed in the dialog + dbv.type = DBVT_BYTE; + dbsetting->dbv = dbv; + dbsetting->hContact = hContact; + dbsetting->module = mir_tstrdup(module); + dbsetting->setting = mir_tstrdup(""); + CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); + } + break; + case MENU_ADD_WORD: + { + struct DBsetting *dbsetting = (struct DBsetting *)mir_alloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc + DBVARIANT dbv = {0}; // freed in the dialog + dbv.type = DBVT_WORD; + dbsetting->dbv = dbv; + dbsetting->hContact = hContact; + dbsetting->module = mir_tstrdup(module); + dbsetting->setting = mir_tstrdup(""); + CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); + } + break; + case MENU_ADD_DWORD: + { + struct DBsetting *dbsetting = (struct DBsetting *)mir_alloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc + DBVARIANT dbv = {0}; // freed in the dialog + dbv.type = DBVT_DWORD; + dbsetting->dbv = dbv; + dbsetting->hContact = hContact; + dbsetting->module = mir_tstrdup(module); + dbsetting->setting = mir_tstrdup(""); + CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); + } + break; + case MENU_ADD_STRING: + { + struct DBsetting *dbsetting = (struct DBsetting *)mir_alloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc + DBVARIANT dbv = {0}; // freed in the dialog + dbv.type = DBVT_ASCIIZ; + dbsetting->dbv = dbv; + dbsetting->hContact = hContact; + dbsetting->module = mir_tstrdup(module); + dbsetting->setting = mir_tstrdup(""); + CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); + } + break; + case MENU_ADD_UNICODE: + if (UDB) + { + struct DBsetting *dbsetting = (struct DBsetting *)mir_alloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc + DBVARIANT dbv = {0}; // freed in the dialog + dbv.type = DBVT_UTF8; + dbsetting->dbv = dbv; + dbsetting->hContact = hContact; + dbsetting->module = mir_tstrdup(module); + dbsetting->setting = mir_tstrdup(""); + if (UOS) + CreateDialogParamW(hInst,MAKEINTRESOURCEW(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); + else + CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); + } + break; + case MENU_ADD_BLOB: + { + struct DBsetting *dbsetting = (struct DBsetting *)mir_alloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc + DBVARIANT dbv = {0}; // freed in the dialog + dbv.type = DBVT_BLOB; + dbsetting->dbv = dbv; + dbsetting->hContact = hContact; + dbsetting->module = mir_tstrdup(module); + dbsetting->setting = mir_tstrdup(""); + CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); + } + break; + + } // switch + } + else // on item + { + char type[8]; + LVITEM lvi; + int i; + int watching = 0; + GetCursorPos(&pt); + hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_CONTEXTMENU)); + hSubMenu = GetSubMenu(hMenu, 0); + TranslateMenu(hSubMenu); + + lvi.mask = LVIF_IMAGE|LVIF_TEXT; + lvi.iItem = hti.iItem; + lvi.iSubItem = 0; + lvi.pszText = setting; + lvi.cchTextMax = 256; + + ListView_GetItem(hSettings,&lvi); + ListView_GetItemText(hSettings, hti.iItem, 2, type, 8); + + if (!UDB) + { + RemoveMenu(hSubMenu, MENU_ADD_UNICODE, MF_BYCOMMAND); + RemoveMenu(hSubMenu, MENU_CHANGE2UNICODE, MF_BYCOMMAND); + } + + switch(lvi.iImage) { + case 4: // STRING + RemoveMenu(hSubMenu, MENU_CHANGE2STRING, MF_BYCOMMAND); + break; + case 1: // BYTE + RemoveMenu(hSubMenu, 4, MF_BYPOSITION); + RemoveMenu(hSubMenu, MENU_CHANGE2BYTE, MF_BYCOMMAND); + RemoveMenu(hSubMenu, MENU_CHANGE2UNICODE, MF_BYCOMMAND); + break; + case 2: // WORD + RemoveMenu(hSubMenu, 4, MF_BYPOSITION); + RemoveMenu(hSubMenu, MENU_CHANGE2WORD, MF_BYCOMMAND); + RemoveMenu(hSubMenu, MENU_CHANGE2UNICODE, MF_BYCOMMAND); + break; + case 3: // DWORD + RemoveMenu(hSubMenu, 4, MF_BYPOSITION); + RemoveMenu(hSubMenu, MENU_CHANGE2DWORD, MF_BYCOMMAND); + RemoveMenu(hSubMenu, MENU_CHANGE2UNICODE, MF_BYCOMMAND); + break; + case 0: // BLOB + RemoveMenu(hSubMenu, 3, MF_BYPOSITION); + RemoveMenu(hSubMenu, 1, MF_BYPOSITION); + RemoveMenu(hSubMenu, 2, MF_BYPOSITION); + RemoveMenu(hSubMenu, MENU_EDIT_SET, MF_BYCOMMAND); + break; + case 5: // UTF8 + RemoveMenu(hSubMenu, 4, MF_BYPOSITION); + RemoveMenu(hSubMenu, MENU_CHANGE2DWORD, MF_BYCOMMAND); + RemoveMenu(hSubMenu, MENU_CHANGE2WORD, MF_BYCOMMAND); + RemoveMenu(hSubMenu, MENU_CHANGE2BYTE, MF_BYCOMMAND); + if (!UDB) + { + RemoveMenu(hSubMenu, 3, MF_BYPOSITION); + RemoveMenu(hSubMenu, 1, MF_BYPOSITION); + RemoveMenu(hSubMenu, 2, MF_BYPOSITION); + RemoveMenu(hSubMenu, MENU_EDIT_SET, MF_BYCOMMAND); + RemoveMenu(hSubMenu, MENU_WATCH_ITEM, MF_BYCOMMAND); + } + else + RemoveMenu(hSubMenu, MENU_CHANGE2UNICODE, MF_BYCOMMAND); + break; + } + + // watch list stuff + + if (ListView_GetSelectedCount(hSettings) >1) + { + RemoveMenu(hSubMenu, 3, MF_BYPOSITION); + RemoveMenu(hSubMenu, 1, MF_BYPOSITION); + RemoveMenu(hSubMenu, 3, MF_BYPOSITION); + RemoveMenu(hSubMenu, MENU_EDIT_SET, MF_BYCOMMAND); + } + + // check if the setting is being watched and if it is then check the menu item + for (i=0; ihContact,info->module, setting); + break; +///////////////////////// divider +//////////////////////// NEW item submenu + case MENU_ADD_BYTE: + { + struct DBsetting *dbsetting = (struct DBsetting *)mir_alloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc + DBVARIANT dbv = {0}; // freed in the dialog + dbv.type = DBVT_BYTE; + dbsetting->dbv = dbv; + dbsetting->hContact = hContact; + dbsetting->module = mir_tstrdup(module); + dbsetting->setting = mir_tstrdup(""); + CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); + } + break; + case MENU_ADD_WORD: + { + struct DBsetting *dbsetting = (struct DBsetting *)mir_alloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc + DBVARIANT dbv = {0}; // freed in the dialog + dbv.type = DBVT_WORD; + dbsetting->dbv = dbv; + dbsetting->hContact = hContact; + dbsetting->module = mir_tstrdup(module); + dbsetting->setting = mir_tstrdup(""); + CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); + } + break; + case MENU_ADD_DWORD: + { + struct DBsetting *dbsetting = (struct DBsetting *)mir_alloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc + DBVARIANT dbv = {0}; // freed in the dialog + dbv.type = DBVT_DWORD; + dbsetting->dbv = dbv; + dbsetting->hContact = hContact; + dbsetting->module = mir_tstrdup(module); + dbsetting->setting = mir_tstrdup(""); + CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); + } + break; + case MENU_ADD_STRING: + { + struct DBsetting *dbsetting = (struct DBsetting *)mir_alloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc + DBVARIANT dbv = {0}; // freed in the dialog + dbv.type = DBVT_ASCIIZ; + dbsetting->dbv = dbv; + dbsetting->hContact = hContact; + dbsetting->module = mir_tstrdup(module); + dbsetting->setting = mir_tstrdup(""); + CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); + } + break; + case MENU_ADD_UNICODE: + if (UDB) + { + struct DBsetting *dbsetting = (struct DBsetting *)mir_alloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc + DBVARIANT dbv = {0}; // freed in the dialog + dbv.type = DBVT_UTF8; + dbsetting->dbv = dbv; + dbsetting->hContact = hContact; + dbsetting->module = mir_tstrdup(module); + dbsetting->setting = mir_tstrdup(""); + if (UOS) + CreateDialogParamW(hInst,MAKEINTRESOURCEW(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); + else + CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); + } + break; + case MENU_ADD_BLOB: + { + struct DBsetting *dbsetting = (struct DBsetting *)mir_alloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc + DBVARIANT dbv = {0}; // freed in the dialog + dbv.type = DBVT_BLOB; + dbsetting->dbv = dbv; + dbsetting->hContact = hContact; + dbsetting->module = mir_tstrdup(module); + dbsetting->setting = mir_tstrdup(""); + CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); + } + break; +///////////////////////// convert to submenu + case MENU_CHANGE2BYTE: + if (convertSetting(hContact, module, setting, 0)) + { + lvi.iImage = 1; + ListView_SetItem(hSettings,&lvi); + } + break; + case MENU_CHANGE2WORD: + if (convertSetting(hContact, module, setting, 1)) + { + lvi.iImage = 2; + ListView_SetItem(hSettings,&lvi); + } + break; + case MENU_CHANGE2DWORD: + if (convertSetting(hContact, module, setting, 2)) + { + lvi.iImage = 3; + ListView_SetItem(hSettings,&lvi); + } + break; + case MENU_CHANGE2STRING: + if (convertSetting(hContact, module, setting, 3)) + { + lvi.iImage = 4; + ListView_SetItem(hSettings,&lvi); + } + break; + case MENU_CHANGE2UNICODE: + if (convertSetting(hContact, module, setting, 4)) + { + lvi.iImage = 5; + ListView_SetItem(hSettings,&lvi); + } + break; +///////////////////////// convert to submenu + case MENU_VIEWDECRYPT: + { + DBVARIANT dbv; + if (!DBGetContactSetting(hContact,module,setting,&dbv) && dbv.type==DBVT_ASCIIZ) + { + if (lstrcmpA(setting, "LoginPassword")) + { + char *text = mir_strdup(dbv.pszVal); + CallService(MS_DB_CRYPT_DECODESTRING, (WPARAM)lstrlenA(dbv.pszVal)+1, (LPARAM)text); + msg(text, Translate("Decoded string..")); + mir_free(text); + } + else + { + char *str = mir_strdup(dbv.pszVal); + char *str1 = str; + for (;*str1; ++str1) + { + const char c = *str1 ^ 0xc3; + if (c) *str1 = c; + } + if (UOS) + { + WCHAR *res = mir_utf8decodeW(str); + MessageBoxW(0, res, TranslateW(L"Decoded string.."),MB_OK); + mir_free(res); + } + else + { + mir_utf8decode(str, NULL); + MessageBoxA(0, str, Translate("Decoded string.."),MB_OK); + } + mir_free(str); + } + } + DBFreeVariant(&dbv); + } + break; + case MENU_VIEWENCRYPT: + { + DBVARIANT dbv; + char *text; + if (!DBGetContactSetting(hContact,module,setting,&dbv) && dbv.type==DBVT_ASCIIZ) + { + text = mir_tstrdup(dbv.pszVal); + CallService(MS_DB_CRYPT_ENCODESTRING, (WPARAM)strlen(dbv.pszVal)+1, (LPARAM)text); + msg(text, Translate("Encoded string..")); + mir_free(text); + } + DBFreeVariant(&dbv); + } + break; + case MENU_DECRYPT: + { + DBVARIANT dbv; + char *text; + if (!DBGetContactSetting(hContact,module,setting,&dbv) && dbv.type==DBVT_ASCIIZ) + { + text = mir_tstrdup(dbv.pszVal); + CallService(MS_DB_CRYPT_DECODESTRING, (WPARAM)strlen(dbv.pszVal)+1, (LPARAM)text); + DBWriteContactSettingString(hContact,module,setting,text); + mir_free(text); + } + DBFreeVariant(&dbv); + } + break; + case MENU_ENCRYPT: + { + DBVARIANT dbv; + char *text; + if (!DBGetContactSetting(hContact,module,setting,&dbv) && dbv.type==DBVT_ASCIIZ) + { + text = mir_tstrdup(dbv.pszVal); + CallService(MS_DB_CRYPT_ENCODESTRING, (WPARAM)strlen(dbv.pszVal)+1, (LPARAM)text); + DBWriteContactSettingString(hContact,module,setting,text); + mir_free(text); + } + DBFreeVariant(&dbv); + } + break; +///////////////////////// divider + case MENU_WATCH_ITEM: + + if (!watching) + { + addSettingToWatchList(hContact,module,setting); + } + else freeWatchListItem(i); + if (hwnd2watchedVarsWindow) + PopulateWatchedWindow(GetDlgItem(hwnd2watchedVarsWindow, IDC_VARS)); + break; + case MENU_DELETE_SET: + DeleteSettingsFromList(hSettings, hContact, module, setting); + break; + } + } +} \ No newline at end of file diff --git a/plugins/DbeditorPP/svc_dbepp-translation.txt b/plugins/DbeditorPP/svc_dbepp-translation.txt new file mode 100644 index 0000000000..dbdf205b20 --- /dev/null +++ b/plugins/DbeditorPP/svc_dbepp-translation.txt @@ -0,0 +1,219 @@ +; Common strings that belong to many files +;[&Replace] +;[&Search] +;[Are you sure you want to delete contact \"%s\"?] +;[Confirm Contact Delete] +;[Couldnt allocate enough memory!] +;[Data] +;[Database Editor++ (ansi mode)] +;[Database Editor++ (unicode mode)] +;[Error Loading Module List] +;[Error Loading Setting List] +;[Settings] +;[Type] + +; ../../plugins/Svc_dbepp/addeditsettingsdlg.cpp +;[Cannot Convert!] +;[Edit BLOB value] +;[Edit BYTE value] +;[Edit DWORD value] +;[Edit STRING value] +;[Edit UNICODE value] +;[Edit WORD value] +;[New BLOB value] +;[New BYTE value] +;[New DWORD value] +;[New STRING value] +;[New UNICODE value] +;[New WORD value] + +; ../../plugins/Svc_dbepp/deletemodule.cpp +;[Are you sure you want to delete module \"%s\"?] +;[Confirm Module Deletion] +;[Delete module from Database] +;[Delete module from Database... Loading] + +; ../../plugins/Svc_dbepp/exportimport.cpp +;[All Files] +;[Contact already exists] +;[Couldn't open file for writing] +;[Do you want to overwrite it \"%s\"?] +;[Export to file] +;[INI Files] +;[Import from files] + +; ../../plugins/Svc_dbepp/findwindow.cpp +;[%s Module \"%s\" in contact \"%s\"] +;[%s Setting \"%s\" in module \"%s\" in contact \"%s\"] +;[%s Setting \"%s\" in module \"%s\" in contact \"%s\" - \"%s\"] +;[%s \"%s\" in Setting \"%s\" in module \"%s\" in contact \"%s\"] +;[Deleted] +;[Enter a string to search the DB for] +;[Finished. %d items were found, %d items were deleted.] +;[Finished. %d items were found, %d items were replaced.] +;[Finished. %d items were found.] +;[Found] +;[Replaced with] +;[Searching...] +;[Stop] + +; ../../plugins/Svc_dbepp/icons.cpp +;[Closed Known Module] +;[Closed Unknown Module] +;[Contacts Group] +;[Known Contact] +;[Open Known Module] +;[Open Unknown Module] +;[Unknown Contact] + +; ../../plugins/Svc_dbepp/main.cpp +;[Database Editor++] +;[Open Database Editor] +;[Open user tree in DBE++] +;[Show DataBase Editor] + +; ../../plugins/Svc_dbepp/moduletree.cpp +;[Add module to contact \"%s\"] +;[Contacts] +;[HANDLE] +;[Loading contacts...] +;[Loading modules...] +;[Module tree not found] + +; ../../plugins/Svc_dbepp/options.cpp +;[Services] + +; ../../plugins/Svc_dbepp/resource.rc +;[&Actions] +;[&Add Module] +;[&Byte] +;[&Cancel] +;[&Clone] +;[&Convert to] +;[&Delete] +;[&Delete Module] +;[&Delete all] +;[&Dword] +;[&Edit / Rename] +;[&Export] +;[&Import] +;[&Main] +;[&Open Options] +;[&Options] +;[&Refresh Modules] +;[&Rename] +;[&Restore position] +;[&Search and Replace] +;[&Sort by protocol] +;[&String] +;[&Unicode] +;[&View all] +;[&Watch] +;[&Watches] +;[&Word] +;[Add To Known Modules] +;[Add a module named] +;[Add a module to contact] +;[Add to all contacts (Includes Settings)] +;[All &Contacts] +;[All &Settings] +;[Automatically expand \"settings\" when Database Editor ++ starts] +;[BL&OB] +;[Background Colour] +;[Base] +;[Cancel] +;[Case Sensitive] +;[Changes to this list will take effect next time miranda starts] +;[Contact Mod context] +;[Contact menu] +;[Contact to copy module and settings to] +;[Contacts menu] +;[Copy To Contact] +;[Copy module to contact] +;[Copy to all contacts (Includes Settings)] +;[DBEditor++] +;[Database Editor++ Search and Replace] +;[Decrypt String] +;[E&xit] +;[Edit &Bytes in Hex] +;[Edit &Dwords in Hex] +;[Edit &Words in Hex] +;[Edit Setting] +;[Encrypt String] +;[Encyption] +;[Entire &Database] +;[Entirely] +;[Exact Match] +;[Export Contact] +;[Export Contacts] +;[Export Module] +;[Export Module from all contacts] +;[Export Settings] +;[Found field] +;[From a &file] +;[From a file] +;[From pasted &text] +;[From pasted text] +;[If the module name has a space in it, put a \\ before the space. eg \"aaa\\ bbb\"] +;[Import] +;[Import Contacts] +;[Import Module/Settings] +;[Import Settings] +;[In:] +;[Insert &CR/LF] +;[Item context] +;[Module Name] +;[Modules to ALWAYS mark as known (e.g core modules)] +;[NEW] +;[NULL contact menu] +;[Null Mod context] +;[OK] +;[Paste the Settings to import here.] +;[Popup timeout (0 for infinite)] +;[Put a space or comma between each module name] +;[Refresh &Settings] +;[Reload Watch List] +;[Replace With] +;[Restore last opened position] +;[Save Value as:] +;[Search For] +;[Setting Name] +;[Setting Value] +;[Show &All] +;[Show only &Loaded] +;[Show only &Unloaded] +;[Text:] +;[Use known modules list] +;[Use popups when watched settings change values] +;[Value Data:] +;[Value Name:] +;[View Decrypted String] +;[View Encrypted String] +;[Warn when deleting modules] +;[Watch Window] +;[Watched Database Variables] +;[new item] + +; ../../plugins/Svc_dbepp/settinglist.cpp +;[] +;[] +;[BLOB] +;[BYTE] +;[DWORD] +;[Decoded string..] +;[Encoded string..] +;[Name] +;[STRING] +;[Size] +;[UNICODE] +;[WORD] + +; ../../plugins/Svc_dbepp/watchedvars.cpp +;[Contact] +;[Database Setting Changed: \nModule: \"%s\" , Setting: \"%s\"\nNew Value (UTF8): \"%s\"] +;[Database Setting Changed: \nModule: \"%s\" , Setting: \"%s\"\nNew Value: (BYTE) %d] +;[Database Setting Changed: \nModule: \"%s\" , Setting: \"%s\"\nNew Value: (DWORD) 0x%X] +;[Database Setting Changed: \nModule: \"%s\" , Setting: \"%s\"\nNew Value: (WORD) %d] +;[Database Setting Changed: \nModule: \"%s\" , Setting: \"%s\"\nNew Value: \"%s\"] +;[Module] +;[Setting] diff --git a/plugins/DbeditorPP/threads.cpp b/plugins/DbeditorPP/threads.cpp new file mode 100644 index 0000000000..7ac144adc4 --- /dev/null +++ b/plugins/DbeditorPP/threads.cpp @@ -0,0 +1,48 @@ +#include "headers.h" + +// thread stuff + +struct FORK_ARG { + HANDLE hEvent; + void (__cdecl *threadcode)(void*); + unsigned (__stdcall *threadcodeex)(void*); + void *arg; +}; + +void __cdecl forkthread_r(void *param) +{ + struct FORK_ARG *fa=(struct FORK_ARG*)param; + void (*callercode)(void*)=fa->threadcode; + void *arg=fa->arg; + + CallService(MS_SYSTEM_THREAD_PUSH,0,0); + + SetEvent(fa->hEvent); + + __try { + callercode(arg); + } __finally { + CallService(MS_SYSTEM_THREAD_POP,0,0); + } + + return; +} + +unsigned long forkthread ( void (__cdecl *threadcode)(void*),unsigned long stacksize,void *arg) +{ + unsigned long rc; + struct FORK_ARG fa; + + fa.hEvent=CreateEvent(NULL,FALSE,FALSE,NULL); + fa.threadcode=threadcode; + fa.arg=arg; + + rc=_beginthread(forkthread_r,stacksize,&fa); + + if ((unsigned long)-1L != rc) { + WaitForSingleObject(fa.hEvent,INFINITE); + } + CloseHandle(fa.hEvent); + + return rc; +} diff --git a/plugins/DbeditorPP/watchedvars.cpp b/plugins/DbeditorPP/watchedvars.cpp new file mode 100644 index 0000000000..b7d2cf6b73 --- /dev/null +++ b/plugins/DbeditorPP/watchedvars.cpp @@ -0,0 +1,358 @@ +#include "headers.h" + +int addSettingToWatchList(HANDLE hContact, char* module, char* setting) +{ + if (WatchListArray.count == WatchListArray.size) + { + WatchListArray.size += 32; + WatchListArray.item = (struct DBsetting*)mir_realloc(WatchListArray.item, sizeof(struct DBsetting)*WatchListArray.size); + } + if (!WatchListArray.item) return 0; + if (setting && DBGetContactSetting(hContact,module, setting, &(WatchListArray.item[WatchListArray.count].dbv))) return 0; + WatchListArray.item[WatchListArray.count].hContact = hContact; + WatchListArray.item[WatchListArray.count].module = mir_tstrdup(module); + if (setting) WatchListArray.item[WatchListArray.count].setting = mir_tstrdup(setting); + else WatchListArray.item[WatchListArray.count].setting = 0; + + WatchListArray.item[WatchListArray.count].WatchModule = setting?WATCH_SETTING:WATCH_MODULE; + WatchListArray.count++; + return 1; +} + +void freeWatchListItem(int item) +{ + if (WatchListArray.item[item].module) mir_free(WatchListArray.item[item].module); + WatchListArray.item[item].module = 0; + if (WatchListArray.item[item].setting) mir_free(WatchListArray.item[item].setting); + WatchListArray.item[item].setting = 0; + DBFreeVariant(&(WatchListArray.item[item].dbv)); + WatchListArray.item[item].hContact = 0; +} + + +void addwatchtolist(HWND hwnd2list, struct DBsetting *lParam) +{ + LVITEM lvItem; + int index; + char data[32], tmp[32]; + DBVARIANT *dbv = &(lParam->dbv); + HANDLE hContact = lParam->hContact; + char *module = lParam->module; + char *setting = lParam->setting; + if (!module) return; + lvItem.lParam = (LPARAM)lParam->hContact; + lvItem.mask = LVIF_TEXT|LVIF_PARAM; + lvItem.iItem = 0; + lvItem.iSubItem = 0; + + if (!setting || (int)(lParam->setting) == WATCH_MODULE) // add every item in the module and return + { + ModuleSettingLL settinglist; + struct DBsetting dummy; + struct ModSetLinkLinkItem *setting; + if (!EnumSettings(hContact,module,&settinglist)) return; + dummy.hContact = hContact; + dummy.module = mir_tstrdup(module); + setting = settinglist.first; + while (setting) + { + dummy.setting = setting->name; + addwatchtolist(hwnd2list, &dummy); + setting = (struct ModSetLinkLinkItem *)setting->next; + } + mir_free(dummy.module); + FreeModuleSettingLL(&settinglist); + return; + } + DBFreeVariant(&(lParam->dbv)); + if (GetSetting(hContact, module, setting, &(lParam->dbv))) return; + + if (!hContact) + lvItem.pszText = "NULL"; + else + lvItem.pszText = (char*)GetContactName(hContact,NULL,UOS); + + index = ListView_InsertItem(hwnd2list,&lvItem); + + if (UOS) + { + WCHAR* ptszText = mir_a2u(lvItem.pszText); + ListView_SetItemTextW(hwnd2list, index, 0, ptszText); + mir_free(ptszText); + } + + ListView_SetItemText(hwnd2list,index,1,module); + ListView_SetItemText(hwnd2list,index,2,setting); + + switch (dbv->type) + { + case DBVT_BLOB: + { + int j; + char *data = NULL; + if (!(data = (char*)mir_realloc(data, 3*(dbv->cpbVal+1)) )) + return; + data[0] = '\0'; + for (j=0; jcpbVal; j++) + { + char tmp[16]; + mir_snprintf(tmp, SIZEOF(tmp), "%02X ", (BYTE)dbv->pbVal[j]); + strcat(data, tmp); + } + ListView_SetItemText(hwnd2list,index,4,data); + ListView_SetItemText(hwnd2list,index,3,"BLOB"); + mir_free(data); + } + break; + case DBVT_BYTE: + mir_snprintf(data, 32, "0x%02X (%s)", dbv->bVal, itoa(dbv->bVal,tmp,10)); + ListView_SetItemText(hwnd2list,index,4,data); + ListView_SetItemText(hwnd2list,index,3,"BYTE"); + break; + case DBVT_WORD: + mir_snprintf(data, 32, "0x%04X (%s)", dbv->wVal, itoa(dbv->wVal,tmp,10)); + ListView_SetItemText(hwnd2list,index,4,data); + ListView_SetItemText(hwnd2list,index,3,"WORD"); + break; + case DBVT_DWORD: + mir_snprintf(data, 32, "0x%08X (%s)", dbv->dVal, itoa(dbv->dVal,tmp,10)); + ListView_SetItemText(hwnd2list,index,4,data); + ListView_SetItemText(hwnd2list,index,3,"DWORD"); + break; + case DBVT_ASCIIZ: + ListView_SetItemText(hwnd2list,index,4,dbv->pszVal); + ListView_SetItemText(hwnd2list,index,3,"STRING"); + break; + case DBVT_UTF8: + { + if (UOS) + { + int length = (int)strlen(dbv->pszVal) + 1; + WCHAR *wc = (WCHAR*)_alloca(length*sizeof(WCHAR)); + MultiByteToWideChar(CP_UTF8, 0, dbv->pszVal, -1, wc, length); + ListView_SetItemTextW(hwnd2list,index,4,wc); + } + else { + // convert from UTF8 + ListView_SetItemText(hwnd2list,index,4,dbv->pszVal); + } + ListView_SetItemText(hwnd2list,index,3,"UNICODE"); + } + break; + + } +} + +void PopulateWatchedWindow(HWND hwnd) +{ + int i; + ListView_DeleteAllItems(hwnd); + for (i=0;iwId) + { + case IDC_VARS: + urc->rcItem.top = 0; + urc->rcItem.bottom = urc->dlgNewSize.cy; + urc->rcItem.left = 0; + urc->rcItem.right = urc->dlgNewSize.cx; + return RD_ANCHORY_CUSTOM|RD_ANCHORX_CUSTOM; + } + return RD_ANCHORX_LEFT|RD_ANCHORY_TOP; +} + +INT_PTR CALLBACK WatchDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch(msg) + { + case WM_INITDIALOG: + { + // setup the list... + LVCOLUMN sLC; + + sLC.fmt = LVCFMT_LEFT; + ListView_SetExtendedListViewStyle(GetDlgItem(hwnd, IDC_VARS), 32|LVS_EX_SUBITEMIMAGES); //LVS_EX_FULLROWSELECT + sLC.mask = LVCF_FMT | LVCF_TEXT | LVCF_SUBITEM | LVCF_WIDTH; + + sLC.pszText = Translate("Contact"); sLC.cx = 80; + ListView_InsertColumn(GetDlgItem(hwnd, IDC_VARS),0,&sLC); + sLC.pszText = Translate("Module"); sLC.cx = 80; + ListView_InsertColumn(GetDlgItem(hwnd, IDC_VARS),1,&sLC); + sLC.pszText = Translate("Setting"); sLC.cx = 80; + ListView_InsertColumn(GetDlgItem(hwnd, IDC_VARS),2,&sLC); + sLC.pszText = Translate("Type"); sLC.cx = 60; + ListView_InsertColumn(GetDlgItem(hwnd, IDC_VARS),3,&sLC); + sLC.pszText = Translate("Data"); sLC.cx = 300; + ListView_InsertColumn(GetDlgItem(hwnd, IDC_VARS),4,&sLC); + + PopulateWatchedWindow(GetDlgItem(hwnd, IDC_VARS)); + + TranslateMenu(GetMenu(hwnd)); + TranslateMenu(GetSubMenu(GetMenu(hwnd),0)); + TranslateDialogDefault(hwnd); + // do the icon + SendMessage(hwnd,WM_SETICON,ICON_BIG,(LPARAM)LoadIcon(hInst,MAKEINTRESOURCE(ICO_REGEDIT))); + } + return TRUE; + // for the resize + case WM_GETMINMAXINFO: + { + MINMAXINFO *mmi=(MINMAXINFO*)lParam; + mmi->ptMinTrackSize.x=200; + mmi->ptMinTrackSize.y=90; + return 0; + } + case WM_SIZE: + { + UTILRESIZEDIALOG urd; + ZeroMemory(&urd,sizeof(urd)); + urd.cbSize=sizeof(urd); + urd.hInstance=hInst; + urd.hwndDlg=hwnd; + urd.lParam=(LPARAM)0; + urd.lpTemplate=MAKEINTRESOURCE(IDD_WATCH_DIAG); + urd.pfnResizer=WatchDialogResize; + CallService(MS_UTILS_RESIZEDIALOG,0,(LPARAM)&urd); + break; + + } + case WM_COMMAND: + switch(LOWORD(wParam)) + { + case MENU_REMALL_WATCHES: + freeAllWatches(); + ListView_DeleteAllItems(GetDlgItem(hwnd, IDC_VARS)); + break; + case MENU_EXIT: + case IDCANCEL: + hwnd2watchedVarsWindow = 0; + DestroyWindow(hwnd); + break; + case MENU_REFRESH: + PopulateWatchedWindow(GetDlgItem(hwnd, IDC_VARS)); + } + break; + + case WM_NOTIFY: + switch(LOWORD(wParam)) + { + case IDC_VARS: + switch(((NMHDR*)lParam)->code) + { + case NM_DBLCLK: + { + LVHITTESTINFO hti; + LVITEM lvi; + hti.pt=((NMLISTVIEW*)lParam)->ptAction; + if (ListView_SubItemHitTest(GetDlgItem(hwnd,IDC_VARS),&hti) >-1) + { + if (hti.flags&LVHT_ONITEM) + { + lvi.mask = LVIF_PARAM; + lvi.iItem = hti.iItem; + lvi.iSubItem = 0; + if (ListView_GetItem(GetDlgItem(hwnd,IDC_VARS),&lvi)) + { + ItemInfo ii; + ii.hContact = (HANDLE)lvi.lParam; + ListView_GetItemText(GetDlgItem(hwnd,IDC_VARS),hti.iItem,1,ii.module,128); + ListView_GetItemText(GetDlgItem(hwnd,IDC_VARS),hti.iItem,2,ii.setting,128); + ii.type = FW_SETTINGNAME; + SendMessage(hwnd2mainWindow,WM_FINDITEM,(WPARAM)&ii,0); + } + } + } + } + break; + } + break; + } + break; + } + return 0; +} + + +void popupWatchedVar(HANDLE hContact,const char* module,const char* setting) +{ + POPUPDATAEX ppd = {0}; + HICON hIcon = LoadIcon(hInst, MAKEINTRESOURCE(ICO_REGEDIT)); + char lpzContactName[MAX_CONTACTNAME]; + char lpzText[MAX_SECONDLINE]; + COLORREF colorBack = DBGetContactSettingDword(NULL,modname,"PopupColour",RGB(255,0,0)); + COLORREF colorText = RGB(0,0,0); + DBVARIANT dbv; + int timeout = DBGetContactSettingByte(NULL,modname,"PopupDelay",3); + + if (hContact) + { + // contacts nick + char szProto[256]; + if (GetValue(hContact,"Protocol","p",szProto,SIZEOF(szProto))) + mir_snprintf(lpzContactName, MAX_SECONDLINE, "%s (%s)", (char*)GetContactName(hContact, szProto, 0), szProto); + else + mir_snprintf(lpzContactName, MAX_SECONDLINE, nick_unknown); + } + else + { + strcpy(lpzContactName,Translate("Settings")); + } + // 2nd line + if (!GetSetting(hContact, module, setting, &dbv)) + { + switch (dbv.type) + { + case DBVT_BYTE: + mir_snprintf(lpzText, SIZEOF(lpzText), Translate("Database Setting Changed: \nModule: \"%s\" , Setting: \"%s\"\nNew Value: (BYTE) %d"), module, setting, dbv.bVal); + break; + case DBVT_WORD: + mir_snprintf(lpzText, SIZEOF(lpzText), Translate("Database Setting Changed: \nModule: \"%s\" , Setting: \"%s\"\nNew Value: (WORD) %d"), module, setting, dbv.wVal); + break; + case DBVT_DWORD: + mir_snprintf(lpzText, SIZEOF(lpzText), Translate("Database Setting Changed: \nModule: \"%s\" , Setting: \"%s\"\nNew Value: (DWORD) 0x%X"), module, setting, dbv.dVal); + break; + case DBVT_ASCIIZ: + mir_snprintf(lpzText, SIZEOF(lpzText), Translate("Database Setting Changed: \nModule: \"%s\" , Setting: \"%s\"\nNew Value: \"%s\""), module, setting, dbv.pszVal); + break; + case DBVT_UTF8: + mir_snprintf(lpzText, SIZEOF(lpzText), Translate("Database Setting Changed: \nModule: \"%s\" , Setting: \"%s\"\nNew Value (UTF8): \"%s\""), module, setting, dbv.pszVal); + break; + default: + return; + } + } + else return; + + DBFreeVariant(&dbv); + + ppd.lchContact = (HANDLE)hContact; + ppd.lchIcon = hIcon; + lstrcpyn(ppd.lpzContactName, lpzContactName,MAX_CONTACTNAME); + lstrcpyn(ppd.lpzText, lpzText,MAX_SECONDLINE); + ppd.colorBack = colorBack; + ppd.colorText = colorText; + ppd.PluginWindowProc = NULL; + ppd.PluginData = NULL; + ppd.iSeconds = timeout?timeout:-1; + + //Now that every field has been filled, we want to see the popup. + CallService(MS_POPUP_ADDPOPUPEX, (WPARAM)&ppd, 0); +} diff --git a/plugins/Svc_crshdmp/Vi show.ico b/plugins/Svc_crshdmp/Vi show.ico deleted file mode 100644 index 55556862f3..0000000000 Binary files a/plugins/Svc_crshdmp/Vi show.ico and /dev/null differ diff --git a/plugins/Svc_crshdmp/Vi to clipboard.ico b/plugins/Svc_crshdmp/Vi to clipboard.ico deleted file mode 100644 index 6f095b59b1..0000000000 Binary files a/plugins/Svc_crshdmp/Vi to clipboard.ico and /dev/null differ diff --git a/plugins/Svc_crshdmp/Vi to file.ico b/plugins/Svc_crshdmp/Vi to file.ico deleted file mode 100644 index abfc196437..0000000000 Binary files a/plugins/Svc_crshdmp/Vi to file.ico and /dev/null differ diff --git a/plugins/Svc_crshdmp/Vi upload.ico b/plugins/Svc_crshdmp/Vi upload.ico deleted file mode 100644 index 4c562b02b8..0000000000 Binary files a/plugins/Svc_crshdmp/Vi upload.ico and /dev/null differ diff --git a/plugins/Svc_crshdmp/Vi.ico b/plugins/Svc_crshdmp/Vi.ico deleted file mode 100644 index 371aeb345e..0000000000 Binary files a/plugins/Svc_crshdmp/Vi.ico and /dev/null differ diff --git a/plugins/Svc_crshdmp/bkstring.cpp b/plugins/Svc_crshdmp/bkstring.cpp deleted file mode 100644 index 418cb0bd83..0000000000 --- a/plugins/Svc_crshdmp/bkstring.cpp +++ /dev/null @@ -1,188 +0,0 @@ -/* -Miranda Crash Dumper Plugin -Copyright (C) 2008 - 2012 Boris Krasnovskiy All Rights Reserved - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation version 2 -of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ - -#include "bkstring.h" - -bkstring::~bkstring() { if (sizeAlloced) free(buf); } - - -void bkstring::reserve(size_type len) -{ - if (len >= sizeAlloced || sizeAlloced == 0) - { - if (sizeAlloced == 0) buf = NULL; - buf = (value_type*)realloc(buf, (len+1) * sizeof(value_type)); - if (sizeAlloced == 0) buf[0] = 0; - sizeAlloced = len+1; - } -} - -void bkstring::appendfmt(const value_type *fmt, ...) -{ - areserve(_tcslen(fmt)*2); - - va_list vararg; - va_start(vararg, fmt); - for (;;) - { - int len = _vsntprintf(buf + lenBuf, sizeAlloced - lenBuf - 1, fmt, vararg); - if (len < 0) - reserve(sizeAlloced + 256); - else - { - lenBuf += len; - buf[lenBuf] = 0; - break; - } - } - va_end(vararg); -} - -bkstring& bkstring::append(const value_type* _Ptr) -{ - size_type len = _tcslen(_Ptr); - areserve(len); - memcpy(buf+lenBuf, _Ptr, (len+1)*sizeof(value_type)); - lenBuf += len; - return *this; -} - -bkstring& bkstring::append(const value_type* _Ptr, size_type _Count) -{ - size_type len = min(_tcslen(_Ptr), _Count); - areserve(len); - memcpy(buf+lenBuf, _Ptr, len*sizeof(value_type)); - lenBuf += len; - buf[lenBuf] = 0; - return *this; -} - -bkstring& bkstring::append(const bkstring& _Str, size_type _Off, size_type _Count) -{ - size_type len = min(_Count, _Str.size() - _Off); - areserve(len); - memcpy(buf+lenBuf, _Str.c_str()+_Off, len*sizeof(value_type)); - lenBuf += len; - buf[lenBuf] = 0; - return *this; -} - -bkstring& bkstring::append(const bkstring& _Str) -{ - size_type len = _Str.size(); - areserve(len); - memcpy(buf+lenBuf, _Str.c_str(), len*sizeof(value_type)); - lenBuf += len; - buf[lenBuf] = 0; - return *this; -} - -bkstring& bkstring::append(size_type _Count, value_type _Ch) -{ - areserve(_Count); - for(size_type i=0; i<_Count; ++i) buf[lenBuf+i] = _Ch; - lenBuf += _Count; - buf[lenBuf] = 0; - return *this; -} - - -bkstring& bkstring::assign(const value_type* _Ptr, size_type _Count) -{ - reserve(_Count); - memcpy(buf, _Ptr, _Count*sizeof(value_type)); - buf[_Count] = 0; - lenBuf = _Count; - return *this; -} - -bkstring& bkstring::assign(const bkstring& _Str, size_type _Off, size_type _Count) -{ - size_type len = min(_Count, _Str.size() - _Off); - reserve(len); - memcpy(buf, _Str.c_str() + _Off, len*sizeof(value_type)); - lenBuf = len; - buf[len] = 0; - return *this; -} - -bkstring& bkstring::assign(size_type _Count, value_type _Ch) -{ - reserve(_Count); - for(size_type i=0; i<_Count; ++i) buf[i] = _Ch; - buf[_Count] = 0; - lenBuf = _Count; - return *this; -} - -bkstring::size_type bkstring::find(value_type _Ch, size_type _Off) const -{ - for (size_type i=_Off; i<=lenBuf; ++i) - if (buf[i] == _Ch) return i; - return (size_type)npos; -} - -bkstring::size_type bkstring::find(const value_type* _Ptr, size_type _Off) const -{ - if (_Off > lenBuf) return (size_type)npos; - - value_type* pstr = _tcsstr(buf+_Off, _Ptr); - return pstr ? pstr - buf : npos; -} - -bkstring::size_type bkstring::find_last_of(value_type _Ch, size_type _Off) const -{ - for (size_type i=(_Off == npos ? lenBuf : _Off); i--;) - if (buf[i] == _Ch) return i; - return (size_type)npos; -} - -bkstring& bkstring::insert(size_type _P0, const value_type* _Ptr, size_type _Count) -{ - size_type len = _tcslen(_Ptr); - if (_Count < len) len = _Count; - areserve(len); - value_type *p = buf + _P0; - memmove(p+len, p, (lenBuf-_P0+1)*sizeof(value_type)); - memcpy(p, _Ptr, _Count*sizeof(value_type)); - lenBuf += len; - return *this; -} - -bkstring& bkstring::insert(size_type _P0, size_type _Count, value_type _Ch) -{ - areserve(_Count); - value_type *p = buf + _P0; - memmove(p+_Count, p, (lenBuf-_P0+1)*sizeof(value_type)); - for(size_type i=0; i<_Count; ++i) p[i] = _Ch; - lenBuf += _Count; - return *this; -} - -bkstring& bkstring::erase(size_type _Pos, size_type _Count) -{ - if (_Pos < lenBuf) - { - const size_type len = min(lenBuf - _Pos, _Count); - value_type *p = buf + _Pos; - lenBuf -= len; - memmove(p, p+len, (lenBuf - _Pos)*sizeof(value_type)); - buf[lenBuf] = 0; - } - return *this; -} diff --git a/plugins/Svc_crshdmp/bkstring.h b/plugins/Svc_crshdmp/bkstring.h deleted file mode 100644 index a546bb8bc8..0000000000 --- a/plugins/Svc_crshdmp/bkstring.h +++ /dev/null @@ -1,276 +0,0 @@ -/* -Miranda Crash Dumper Plugin -Copyright (C) 2008 - 2012 Boris Krasnovskiy All Rights Reserved - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation version 2 -of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ - -#ifndef _BKSTRING_H_ -#define _BKSTRING_H_ - -#include -#include -#include -#include -#include - -#ifndef min -#define min(A, B) ((A) < (B) ? (A) : (B)) -#endif - -class bkstring -{ -public: - typedef size_t size_type; - typedef TCHAR value_type; - typedef value_type* iterator; - typedef const value_type* const_iterator; - -#if defined(_MSC_VER) && _MSC_VER > 1200 - static const size_type npos = size_type(-1); -#else - enum { npos = -1 }; -#endif - -private: - value_type* buf; - size_type sizeAlloced; - size_type lenBuf; - - void areserve(size_type len) { reserve(lenBuf + len); } - -public: - - explicit bkstring() : buf((TCHAR*)_T("")), sizeAlloced(0), lenBuf(0) - {} - - bkstring(const value_type* _Ptr, size_type _Count) : sizeAlloced(0), lenBuf(0) - { assign(_Ptr, _Count); } - - bkstring(const value_type* _Ptr) : sizeAlloced(0), lenBuf(0) - { assign(_Ptr); } - - bkstring(size_type _Count, value_type _Ch) : sizeAlloced(0), lenBuf(0) - { assign(_Count, _Ch); } - - bkstring(const bkstring& _Str) : sizeAlloced(0), lenBuf(0) - { assign(_Str); } - - bkstring(const bkstring& _Str, size_type _Off, size_type _Count) : sizeAlloced(0), lenBuf(0) - { assign(_Str, _Off, _Count); } - - ~bkstring(); - - size_type size(void) const { return lenBuf; } - const value_type* c_str(void) const { return buf; } - - void clear(void) { if (lenBuf) { lenBuf = 0; buf[0] = 0; } } - void insert(const value_type *txt); - void reserve(size_type len); - - bkstring& assign(const value_type* _Ptr) - { return assign(_Ptr, _tcslen(_Ptr)); } - - bkstring& assign(const bkstring& _Str) - { return assign(_Str, 0, (size_type)npos); } - - bkstring& assign(const value_type* _Ptr, size_type _Count); - bkstring& assign(const bkstring& _Str, size_type off, size_type _Count); - bkstring& assign(size_type _Count, value_type _Ch); - - bkstring& append(const value_type* _Ptr); - bkstring& append(const value_type* _Ptr, size_type _Count); - bkstring& append(const bkstring& _Str, size_type _Off, size_type _Count); - bkstring& append(const bkstring& _Str); - bkstring& append(size_type _Count, value_type _Ch); - - int compare(const bkstring& _Str) const - { return _tcscmp(buf, _Str.c_str()); } - - int compare(size_type _Pos1, size_type _Num1, const bkstring& _Str) const - { return _tcsncmp(&buf[_Pos1], _Str.c_str(), _Num1); } - - int compare(size_type _Pos1, size_type _Num1, const bkstring& _Str, size_type _Off, size_type _Count) const - { return _tcsncmp(&buf[_Pos1], _Str.c_str()+_Off, min(_Num1, _Count)); } - - int compare(const value_type* _Ptr) const - { return _tcscmp(buf, _Ptr); } - - int compare(size_type _Pos1, size_type _Num1, const value_type* _Ptr) const - { return _tcsncmp(&buf[_Pos1], _Ptr, _Num1); } - - int compare(size_type _Pos1, size_type _Num1, const value_type* _Ptr, size_type _Num2) const - { return _tcsncmp(&buf[_Pos1], _Ptr, min(_Num1, _Num2)); } - - int comparei(const bkstring& _Str) const - { return _tcsicmp(buf, _Str.c_str()); } - - int comparei(size_type _Pos1, size_type _Num1, const bkstring& _Str) const - { return _tcsnicmp(&buf[_Pos1], _Str.c_str(), _Num1); } - - int comparei(size_type _Pos1, size_type _Num1, const bkstring& _Str, size_type _Off, size_type _Count) const - { return _tcsnicmp(&buf[_Pos1], _Str.c_str()+_Off, min(_Num1, _Count)); } - - int comparei(const value_type* _Ptr) const - { return _tcsicmp(buf, _Ptr); } - - int comparei(size_type _Pos1, size_type _Num1, const value_type* _Ptr) const - { return _tcsnicmp(&buf[_Pos1], _Ptr, _Num1); } - - int comparei(size_type _Pos1, size_type _Num1, const value_type* _Ptr, size_type _Num2) const - { return _tcsnicmp(&buf[_Pos1], _Ptr, min(_Num1, _Num2)); } - - bool empty(void) const { return lenBuf == 0; }; - bkstring& erase(size_type _Pos = 0, size_type _Count = npos); - - size_type find(value_type _Ch, size_type _Off = 0) const; - size_type find(const value_type* _Ptr, size_type _Off = 0) const; - size_type find(bkstring& _Str, size_type _Off = 0) const - { return find(_Str.c_str(), _Off); } - - size_type find_last_of(value_type _Ch, size_type _Off = npos) const; - - bkstring& insert(size_type _P0, const value_type* _Ptr) - { return insert(_P0, _Ptr, _tcslen(_Ptr)); } - - bkstring& insert(size_type _P0, const bkstring& _Str) - { return insert(_P0, _Str.c_str(), _Str.size()); }; - - bkstring& insert(size_type _P0, const value_type* _Ptr, size_type _Count); - bkstring& insert(size_type _P0, size_type _Count, value_type _Ch); - - bkstring substr(size_type _Off = 0, size_type _Count = npos) const - { return bkstring(*this, _Off, _Count); } - - bkstring& operator = (const bkstring& _Str) - { return assign(_Str); } - - bkstring& operator =(const value_type* _Ptr) - { return assign(_Ptr); } - - bkstring& operator = (const value_type _Ch) - { return assign(1, _Ch); } - - bkstring& operator +=(const bkstring& _Str) - { return append(_Str); } - - bkstring& operator += (const value_type* _Ptr) - { return append(_Ptr); } - - bkstring& operator += (const value_type _Ch) - { return append(1, _Ch); } - - value_type& operator[] (int ind) const - { return buf[ind]; } - - friend bkstring operator+ (const bkstring& _Str1, const bkstring& _Str2) - { bkstring s(_Str1); return s.append(_Str2); } - - friend bkstring operator+ (const bkstring& _Str1, const value_type* _Ptr2) - { bkstring s(_Str1); return s.append(_Ptr2); } - - friend bkstring operator+(const value_type* _Ptr1, const bkstring& _Str2) - { bkstring s(_Ptr1); return s.append(_Str2); } - - friend bkstring operator+ (const bkstring& _Str1, const value_type _Ch) - { bkstring s(_Str1); return s.append(1, _Ch); } - - friend bool operator==(const bkstring& _Str1, const bkstring& _Str2) - { return _Str1.compare(_Str2) == 0; } - - friend bool operator==(const bkstring& _Str1, const value_type* _Ptr2) - { return _Str1.compare(_Ptr2) == 0; } - - friend bool operator==(const value_type* _Ptr1, const bkstring& _Str2) - { return _Str2.compare(_Ptr1) == 0; } - - friend bool operator!=(const bkstring& _Str1, const bkstring& _Str2) - { return _Str1.compare(_Str2) != 0; } - - friend bool operator!=(const bkstring& _Str1, const value_type* _Ptr2) - { return _Str1.compare(_Ptr2) != 0; } - - friend bool operator!=(const value_type* _Ptr1, const bkstring& _Str2) - { return _Str2.compare(_Ptr1) != 0; } - - friend bool operator<(const bkstring& _Str1, const bkstring& _Str2) - { return _Str1.compare(_Str2) < 0; } - - friend bool operator<(const bkstring& _Str1, const value_type* _Ptr2) - { return _Str1.compare(_Ptr2) < 0; } - - friend bool operator<(const value_type* _Ptr1, const bkstring& _Str2) - { return _Str2.compare(_Ptr1) > 0; } - - friend bool operator>(const bkstring& _Str1, const bkstring& _Str2) - { return _Str1.compare(_Str2) > 0; } - - friend bool operator>(const bkstring& _Str1, const value_type* _Ptr2) - { return _Str1.compare(_Ptr2) > 0; } - - friend bool operator>(const value_type* _Ptr1, const bkstring& _Str2) - { return _Str2.compare(_Ptr1) < 0; } - - friend bool operator<=(const bkstring& _Str1, const bkstring& _Str2) - { return _Str1.compare(_Str2) <= 0; } - - friend bool operator<=(const bkstring& _Str1, const value_type* _Ptr2) - { return _Str1.compare(_Ptr2) <= 0; } - - friend bool operator<=(const value_type* _Ptr1, const bkstring& _Str2) - { return _Str2.compare(_Ptr1) >= 0; } - - friend bool operator>=(const bkstring& _Str1, const bkstring& _Str2) - { return _Str1.compare(_Str2) >= 0; } - - friend bool operator>=(const bkstring& _Str1, const value_type* _Ptr2) - { return _Str1.compare(_Ptr2) >= 0; } - - friend bool operator>=(const value_type* _Ptr1, const bkstring& _Str2) - { return _Str2.compare(_Ptr1) <= 0; } - - friend bool operator==(const value_type _Ch1, const bkstring& _Str2) - { return (_Str2.size() == 1) && (_Str2[0] == _Ch1); } - - friend bool operator==(const bkstring& _Str1, const value_type _Ch2) - { return (_Str1.size() == 1) && (_Str1[0] == _Ch2); } - - friend bool operator!=(const value_type _Ch1, const bkstring& _Str2) - { return (_Str2.size() != 1) || (_Str2[0] != _Ch1); } - - friend bool operator!=(const bkstring& _Str1, const value_type _Ch2) - { return (_Str1.size() != 1) || (_Str1[0] != _Ch2); } - - iterator begin(void) - { return buf; } - - const_iterator begin(void) const - { return buf; } - - iterator end(void) - { return buf + lenBuf; } - - const_iterator end(void) const - { return buf + lenBuf; } - - // Custom extentions - - void appendfmt(const value_type *fmt, ...); - - size_type sizebytes(void) const { return lenBuf * sizeof(value_type); } -}; - -//const bkstring::size_type bkstring::npos = -1; - -#endif diff --git a/plugins/Svc_crshdmp/crshdmp.cpp b/plugins/Svc_crshdmp/crshdmp.cpp deleted file mode 100644 index 72ffac7f44..0000000000 --- a/plugins/Svc_crshdmp/crshdmp.cpp +++ /dev/null @@ -1,434 +0,0 @@ -/* -Miranda Crash Dumper Plugin -Copyright (C) 2008 - 2012 Boris Krasnovskiy All Rights Reserved - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation version 2 -of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ - -#include "utils.h" -#include -#include "m_folders.h" -#include "m_toptoolbar.h" -#include "version.h" - -int hLangpack; - -HINSTANCE hInst; -DWORD mirandaVersion; -LCID packlcid; -HANDLE hCrashLogFolder, hVerInfoFolder; -HMODULE hRichModule; - -TCHAR* vertxt; -TCHAR* profname; -TCHAR* profpath; - -TCHAR CrashLogFolder[MAX_PATH]; -TCHAR VersionInfoFolder[MAX_PATH]; - -bool servicemode; -bool clsdates; -bool dtsubfldr; - -static const PLUGININFOEX pluginInfoEx = -{ - sizeof(PLUGININFOEX), - "Crash Dumper", - __VERSION_DWORD, - "Crash Dumper for Miranda IM.", - "borkra", - "borkra@miranda-im.org", - "Copyright© 2008 - 2012 Boris Krasnovskiy All Rights Reserved", - "http://code.google.com/p/mirandaimplugins/downloads/list", - UNICODE_AWARE, - // {F62C1D7A-FFA4-4065-A251-4C9DD9101CC8} - { 0xf62c1d7a, 0xffa4, 0x4065, { 0xa2, 0x51, 0x4c, 0x9d, 0xd9, 0x10, 0x1c, 0xc8 } } -}; - -const PLUGININFOEX* GetPluginInfoEx(void) { return &pluginInfoEx; } - - -extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirVersion) -{ - ::mirandaVersion = mirVersion; - return (PLUGININFOEX*)&pluginInfoEx; -} - -#define MIID_CRASHDUMP { 0x36a31a50, 0xcb55, 0x46d0, { 0xab, 0x9c, 0x1e, 0xac, 0xfb, 0x24, 0x0, 0x2a } } - -// MirandaInterfaces - returns the protocol interface to the core -extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_SERVICEMODE, MIID_CRASHDUMP, MIID_LAST }; - -HANDLE hHooks[5]; -HANDLE hServices[6]; - - -INT_PTR StoreVersionInfoToFile(WPARAM, LPARAM lParam) -{ - CreateDirectoryTree(VersionInfoFolder); - - TCHAR path[MAX_PATH]; - crs_sntprintf(path, MAX_PATH, TEXT("%s\\VersionInfo.txt"), VersionInfoFolder); - - HANDLE hDumpFile = CreateFile(path, GENERIC_WRITE, 0, NULL, - CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); - - if (hDumpFile != INVALID_HANDLE_VALUE) - { - bkstring buffer; - - buffer.reserve(0x1800); - PrintVersionInfo(buffer, (unsigned int)lParam | VI_FLAG_PRNVAR); - - char* bufu = mir_utf8encodeT(buffer.c_str()); - WriteUtfFile(hDumpFile, bufu); - mir_free(bufu); - - CloseHandle(hDumpFile); - - ShowMessage(3, TranslateT("VersionInfo stored into file %s"), path); - } - else - ShowMessage(2, TranslateT("VersionInfo file %s is inaccessible"), path); - - return 0; -} - -INT_PTR StoreVersionInfoToClipboard(WPARAM, LPARAM lParam) -{ - bkstring buffer; - buffer.reserve(0x1800); - - WriteBBFile(buffer, true); - PrintVersionInfo(buffer, (unsigned int)lParam | VI_FLAG_PRNVAR | VI_FLAG_FORMAT); - WriteBBFile(buffer, false); - - StoreStringToClip(buffer); - - return 0; -} - -INT_PTR UploadVersionInfo(WPARAM, LPARAM lParam) -{ - bkstring buffer; - buffer.reserve(0x1800); - PrintVersionInfo(buffer); - - VerTrnsfr *trn = (VerTrnsfr*)mir_alloc(sizeof(VerTrnsfr)); - trn->buf = mir_utf8encodeT(buffer.c_str()); - trn->autot = lParam == 0xa1; - - mir_forkthread(VersionInfoUploadThread, trn); - - return 0; -} - - -INT_PTR ViewVersionInfo(WPARAM wParam, LPARAM) -{ - // unsigned *p = (unsigned*)0x15; - // *p = 324; - - if (hRichModule == NULL && GetModuleHandle(TEXT("Riched20.dll")) == NULL) - hRichModule = LoadLibrary(TEXT("Riched20.dll")); - - CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_VIEWVERSION), NULL, - DlgProcView, wParam ? (VI_FLAG_PRNVAR | VI_FLAG_PRNDLL) : VI_FLAG_PRNVAR); - - return 0; -} - -INT_PTR OpenUrl(WPARAM wParam, LPARAM) -{ - switch (wParam) - { - case 0: - ShellExecute(NULL, TEXT("explore"), CrashLogFolder, NULL, NULL, SW_SHOW); - break; - - case 1: - OpenAuthUrl("http://%s.miranda-vi.org"); - break; - } - return 0; -} - -INT_PTR ServiceModeLaunch(WPARAM, LPARAM) -{ - servicemode = true; - return 0; -} - - -static int FoldersPathChanged(WPARAM, LPARAM) -{ - FOLDERSGETDATA fgd = {0}; - fgd.cbSize = sizeof(FOLDERSGETDATA); - fgd.nMaxPathSize = MAX_PATH; - fgd.szPathT = CrashLogFolder; - CallService(MS_FOLDERS_GET_PATH, (WPARAM) hCrashLogFolder, (LPARAM) &fgd); - - fgd.szPathT = VersionInfoFolder; - CallService(MS_FOLDERS_GET_PATH, (WPARAM) hVerInfoFolder, (LPARAM) &fgd); - return 0; -} - -int OptionsInit(WPARAM wParam, LPARAM) -{ - OPTIONSDIALOGPAGE odp = { 0 }; - - odp.cbSize = sizeof(odp); - odp.position = -790000000; - odp.hInstance = hInst; - odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS); - odp.pszTitle = (char*)PluginName; - odp.pszGroup = LPGEN("Services"); - odp.flags = ODPF_BOLDGROUPS; - odp.pfnDlgProc = DlgProcOptions; - Options_AddPage(wParam, &odp); - - return 0; -} - -static int ToolbarModulesLoaded(WPARAM, LPARAM) -{ - TTBButton tbb = {0}; - tbb.cbSize = sizeof(TTBButton); - - tbb.pszService = MS_CRASHDUMPER_STORETOCLIP; - tbb.name = tbb.pszTooltipUp = LPGEN("Version Information To Clipboard"); - tbb.hIconHandleUp = GetIconHandle("storeToClip"); - tbb.dwFlags = TTBBF_VISIBLE; - TopToolbar_AddButton(&tbb); - - tbb.pszService = MS_CRASHDUMPER_STORETOFILE; - tbb.name = tbb.pszTooltipUp = LPGEN("Version Information To File"); - tbb.hIconHandleUp = GetIconHandle("storeToFile"); - tbb.dwFlags = 0; - TopToolbar_AddButton(&tbb); - - tbb.pszService = MS_CRASHDUMPER_VIEWINFO; - tbb.name = tbb.pszTooltipUp = LPGEN("Show Version Information"); - tbb.hIconHandleUp = GetIconHandle("showInfo"); - TopToolbar_AddButton(&tbb); - - tbb.pszService = MS_CRASHDUMPER_UPLOAD; - tbb.name = tbb.pszTooltipUp = LPGEN("Upload Version Information"); - tbb.hIconHandleUp = GetIconHandle("uploadInfo"); - TopToolbar_AddButton(&tbb); - return 0; -} - -static int ModulesLoaded(WPARAM, LPARAM) -{ - char temp[MAX_PATH]; - CallService(MS_SYSTEM_GETVERSIONTEXT, (WPARAM)SIZEOF(temp), (LPARAM)temp); - crs_a2t(vertxt, temp); - - profname = Utils_ReplaceVarsT(_T("%miranda_profilename%.dat")); - if (ServiceExists(MS_FOLDERS_REGISTER_PATH)) - { - profpath = _T("%miranda_userdata%"); - } - else - { - profpath = Utils_ReplaceVarsT(_T("%miranda_userdata%")); - } - - crs_sntprintf(CrashLogFolder, MAX_PATH, TEXT("%s\\CrashLog"), profpath); - crs_sntprintf(VersionInfoFolder, MAX_PATH, TEXT("%s"), profpath); - - SetExceptionHandler(); - - hCrashLogFolder = FoldersRegisterCustomPathT(PluginName, "Crash Reports", CrashLogFolder); - hVerInfoFolder = FoldersRegisterCustomPathT(PluginName, "Version Information", VersionInfoFolder); - - FoldersPathChanged(0, 0); - - - - hHooks[2] = HookEvent(ME_FOLDERS_PATH_CHANGED, FoldersPathChanged); - if (hHooks[3] == NULL) hHooks[3] = HookEvent(ME_TTB_MODULELOADED, ToolbarModulesLoaded); - - UploadInit(); - - CLISTMENUITEM mi = { 0 }; - - mi.cbSize = sizeof(mi); - - mi.popupPosition = 2000089999; - mi.position = 2000089999; - mi.flags = CMIF_ROOTPOPUP | CMIF_ICONFROMICOLIB | CMIF_TCHAR; - mi.icolibItem = GetIconHandle("versionInfo"); - mi.ptszName = LPGENT("Version Information"); - mi.pszPopupName = (char *)-1; - HANDLE hMenuRoot = Menu_AddMainMenuItem(&mi); - - mi.flags = CMIF_CHILDPOPUP | CMIF_ICONFROMICOLIB | CMIF_TCHAR; - mi.pszPopupName = (char *)hMenuRoot; - mi.popupPosition = 0; - - mi.position = 2000089995; - mi.ptszName = LPGENT("Copy to clipboard"); - mi.icolibItem = GetIconHandle("storeToClip"); - mi.pszService = MS_CRASHDUMPER_STORETOCLIP; - Menu_AddMainMenuItem(&mi); - - mi.position = 2000089996; - mi.ptszName = LPGENT("Store to file"); - mi.icolibItem = GetIconHandle("storeToFile"); - mi.pszService = MS_CRASHDUMPER_STORETOFILE; - Menu_AddMainMenuItem(&mi); - - mi.position = 2000089997; - mi.ptszName = LPGENT("Show"); - mi.icolibItem = GetIconHandle("showInfo"); - mi.pszService = MS_CRASHDUMPER_VIEWINFO; - Menu_AddMainMenuItem(&mi); - - mi.popupPosition = 1; - mi.position = 2000089998; - mi.ptszName = LPGENT("Show with DLLs"); - mi.icolibItem = GetIconHandle("showInfo"); - mi.pszService = MS_CRASHDUMPER_VIEWINFO; - Menu_AddMainMenuItem(&mi); - - mi.popupPosition = 0; - mi.position = 2000089999; - mi.ptszName = LPGENT("Upload"); - mi.icolibItem = GetIconHandle("uploadInfo"); - mi.pszService = MS_CRASHDUMPER_UPLOAD; - Menu_AddMainMenuItem(&mi); - - mi.position = 2000099990; - mi.ptszName = LPGENT("Open crash report directory"); - mi.icolibItem = LoadSkinnedIconHandle(SKINICON_EVENT_FILE); - mi.pszService = MS_CRASHDUMPER_URL; - Menu_AddMainMenuItem(&mi); - - mi.popupPosition = 1; - mi.position = 2000099991; - mi.ptszName = LPGENT("Open miranda-vi.org"); - mi.icolibItem = LoadSkinnedIconHandle(SKINICON_EVENT_URL); - mi.pszService = MS_CRASHDUMPER_URL; - Menu_AddMainMenuItem(&mi); - - HOTKEYDESC hk = {0}; - hk.cbSize = sizeof(hk); - hk.pszSection = PluginName; - - hk.pszDescription = LPGEN("Copy Version Info to clipboard"); - hk.pszName = "CopyVerInfo"; - hk.pszService = MS_CRASHDUMPER_STORETOCLIP; - Hotkey_Register(&hk); - - hk.pszDescription = LPGEN("Show Version Info"); - hk.pszName = "ShowVerInfo"; - hk.pszService = MS_CRASHDUMPER_VIEWINFO; - Hotkey_Register(&hk); - - if (servicemode) ViewVersionInfo(0, 0); - else - { - if (DBGetContactSettingByte(NULL, PluginName, "UploadChanged", 0) && !ProcessVIHash(false)) - UploadVersionInfo(0, 0xa1); - } - - CheckForOtherCrashReportingPlugins(); - return 0; -} - -static int PreShutdown(WPARAM, LPARAM) -{ - unsigned i; - - DestroyAllWindows(); - UploadClose(); - - for (i=0; i - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - Svc_crshdmp - {576EEEFD-E423-482B-879A-F0515D40B8E1} - - - - DynamicLibrary - Unicode - - - DynamicLibrary - Unicode - true - - - DynamicLibrary - Unicode - - - DynamicLibrary - Unicode - true - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.311 - $(SolutionDir)$(Configuration)\Plugins\ - $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ - $(SolutionDir)$(Configuration)64\Plugins\ - $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ - $(SolutionDir)$(Configuration)\Plugins\ - $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ - $(SolutionDir)$(Configuration)64\Plugins\ - $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ - true - - - - Full - Size - true - ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - false - false - false - Fast - Level3 - OnlyExplicitInline - - - dbghelp.lib;%(AdditionalDependencies) - dbghelp.dll;%(DelayLoadDLLs) - true - Windows - true - true - true - $(IntDir)$(TargetName).lib - false - $(SolutionDir)\lib - - - ..\..\include\msapi - NDEBUG;%(PreprocessorDefinitions) - - - - - Full - Size - true - ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - WIN64;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - false - false - false - Fast - Level3 - OnlyExplicitInline - - - dbghelp.lib;%(AdditionalDependencies) - dbghelp.dll;%(DelayLoadDLLs) - true - Windows - true - true - true - $(IntDir)$(TargetName).lib - false - $(SolutionDir)\lib - - - ..\..\include\msapi - NDEBUG;%(PreprocessorDefinitions) - - - - - Disabled - ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Fast - Level3 - EditAndContinue - - - dbghelp.lib;%(AdditionalDependencies) - dbghelp.dll;%(DelayLoadDLLs) - true - Windows - true - $(IntDir)$(TargetName).lib - false - $(SolutionDir)\lib - - - ..\..\include\msapi - _DEBUG;%(PreprocessorDefinitions) - - - - - Disabled - ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - WIN64;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - Fast - Level3 - - - dbghelp.lib;%(AdditionalDependencies) - dbghelp.dll;%(DelayLoadDLLs) - true - Windows - true - $(IntDir)$(TargetName).lib - false - $(SolutionDir)\lib - - - ..\..\include\msapi - _DEBUG;%(PreprocessorDefinitions) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/plugins/Svc_crshdmp/crshdmp_icons.cpp b/plugins/Svc_crshdmp/crshdmp_icons.cpp deleted file mode 100644 index 1f7106303f..0000000000 --- a/plugins/Svc_crshdmp/crshdmp_icons.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* -Miranda Crash Dumper Plugin -Copyright (C) 2008 - 2012 Boris Krasnovskiy All Rights Reserved - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation version 2 -of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ - -#include "utils.h" -#include - -struct _tag_iconList -{ - const char* szDescr; - const char* szName; - int defIconID; -} -static const iconList[] = -{ - { "Version Information", "versionInfo", IDI_VI }, - { "Copy To Clipboard", "storeToClip", IDI_VITOCLIP }, - { "Store to file", "storeToFile", IDI_VITOFILE }, - { "Show", "showInfo", IDI_VISHOW }, - { "Upload", "uploadInfo", IDI_VIUPLOAD }, -}; - -static HANDLE hIconLibItem[SIZEOF(iconList)]; - -void InitIcons(void) -{ - char szFile[MAX_PATH]; - char szSettingName[100]; - SKINICONDESC sid = {0}; - - sid.cbSize = sizeof(SKINICONDESC); - sid.pszDefaultFile = szFile; - sid.pszName = szSettingName; - sid.pszSection = (char*)PluginName; - - GetModuleFileNameA(hInst, szFile, MAX_PATH); - - for (unsigned i = 0; i < SIZEOF(iconList); i++) - { - mir_snprintf(szSettingName, sizeof(szSettingName), "%s_%s", PluginName, iconList[i].szName); - - sid.pszDescription = (char*)iconList[i].szDescr; - sid.iDefaultIndex = -iconList[i].defIconID; - hIconLibItem[i] = Skin_AddIcon(&sid); - } -} - -HICON LoadIconEx(const char* name, bool big) -{ - char szSettingName[100]; - mir_snprintf(szSettingName, sizeof(szSettingName), "%s_%s", PluginName, name); - return (HICON)CallService(MS_SKIN2_GETICON, big, (LPARAM)szSettingName); -} - -HANDLE GetIconHandle(const char* name) -{ - unsigned i; - for (i=0; i < SIZEOF(iconList); i++) - if (strcmp(iconList[i].szName, name) == 0) - return hIconLibItem[i]; - return NULL; -} - -void ReleaseIconEx(const char* name) -{ - char szSettingName[100]; - mir_snprintf(szSettingName, sizeof(szSettingName), "%s_%s", PluginName, name); - CallService(MS_SKIN2_RELEASEICON, 0, (LPARAM)szSettingName); -} - -void ReleaseIconEx(HICON hIcon) -{ - CallService(MS_SKIN2_RELEASEICON, (WPARAM)hIcon, 0); -} diff --git a/plugins/Svc_crshdmp/crshdmp_readme.txt b/plugins/Svc_crshdmp/crshdmp_readme.txt deleted file mode 100644 index f4e1ff92ac..0000000000 --- a/plugins/Svc_crshdmp/crshdmp_readme.txt +++ /dev/null @@ -1,379 +0,0 @@ -Crash Dumper plugin for Miranda IM -===================================================================== -Plugin creates usable Crash Report and Version Information for Miranda IM - -When Miranda crashes plugin ptrovides: -- text representation of crash report -- MiniDump representation of crash report - -On demand plugin provides Version Information report -On demand uploads VersionInfo report to www.miranda-vi.org - -VersionInfo report includes: - -- OS Version information -- Internet Explorer version information -- Miranda version information with build date -- Miranda profile used -- Loaded Miranda plugin list with versions -- Loaded language pack version -- Loaded weather ini files -- Created protocols accounts - -Files stored in {Miranda Profile}\CrashLog directory - -Text version of crash report includes: - -- Guess for plugin responsible for the crash (it printed in the report) -- Stack trace for exception (with function names, source file names - and line numbers, if possible) -- Version Information (see above) -- Loaded modules (dlls) list -- Plugin lists all information you need to submit crash report for Miranda -- Loaded weather ini files - -Plugin works with all current Operating Systems. - -It could be downloaded here: -ANSI: http://addons.miranda-im.org/details.php?action=viewfile&id=3695 -Unicode: http://addons.miranda-im.org/details.php?action=viewfile&id=3806 -x64: http://addons.miranda-im.org/details.php?action=viewfile&id=4114 -All: http://code.google.com/p/mirandaimplugins/downloads/list - -Win9x, WinNT users required to install dbghelp.dll v 5.0 or later. -dbghelp.dll v 5.0 is available here: -http://www.microsoft.com/downloads/details.aspx?FamilyID=cd1fc4b2-0885-47f4-af45-7fd5e14db6c0&DisplayLang=en - - -Author: Boris Krasnovskiy (borkra) - -Licensing terms could be found below. - -Change Log -========== - -0.0.4.20 --------- -Added Windows 8 detection - -0.0.4.19 --------- -Improved reporting for MS RTL failures -Fixes for translation - -0.0.4.18 --------- -Renamed Hotkeys, added Hotkey to open message window -Added support for 32x32 icons -Added proper display of Miranda 0.9 profile path - -0.0.4.17 --------- -Removed option to ignore crashes that do not cause Miranda to close -Improved protocol reporting -Fixed TopToolbar buttons no show -Added proper handling of Crash Dumper late exit in Miranda 0.9 - -0.0.4.16 --------- -Added icon pack reporting -Fixed toolbar button for storing to file - -0.0.4.14 --------- -Fixed options dialog -Changed bug reporting message to popup - -0.0.4.13 --------- -Changed option to notify only about crashes that stop Miranda -Fixed bug reporting menu - -0.0.4.12 --------- -Improved accounts reporting -Fixed error messages about inability to store crash report -Added option to disable crash reporting function -Added coping VI into clipboard on Report Bug menu item - -0.0.4.11 --------- -Allow creating crash report with dbghelp.dll v5.0 -(this adds support for creating crash reports on Windows 95 with extra dbghelp.dll -and on Windows 2000 with built-in dbghelp.dll) - -0.0.4.10 --------- -Fixed bbcodes for Weather ini -x64 portability -Windows 95 compatibility -Fixed crash in service mode - -0.0.4.9 --------- -Printing weather only if weather plugin present -Changed alternative date format -Fixed langpack display when non ANSI chars used in the description -Fixed crash in debug version -Fixed langpack display when locale id is bogus -Changed stored file format to UTF-8 -Added opening generated version info file on popup click - -0.0.4.8 --------- -Changed upload to miranda-vi.org to unicode -Added Windows 7 & Windows Server 2008 R2 detection -Added Weather ini files reporting -Changed Accounts reporting to list enabled and disabled accounts -Changed VI display font to Courier New - -0.0.4.7 --------- -Made message boxes the topmost window -Added Protocols and Accounts printout - -0.0.4.6 --------- -Attempt to reduce no-report conditions - -0.0.4.5 --------- -Added icons to menu items -Added storing crash report in clipboard only by request -Added base address display to VI with DLLs -Fixed buttons in VI view when show VI with DLL - -0.0.4.4 --------- -Added menu item to open crash log folder in explorer -Added menu item to open miranda-vi.org in web browser -Added automatic login into miranda-vi when open in web browser through Miranda -Added option to display date and time in "traditional" format for all reports - -0.0.4.3 --------- -Removed Trap all exceptions option - -0.0.4.2 --------- -Added caution note to Trap All Exceptions option -Restored compatibility of Crash Dumper Unicode with dbghelp.dll distributed with XP -Disabled on startup Trap All Exceptions option on pre Vista OSes - -0.0.4.1 --------- -Fixed crash in Trap all possible exceptions mode - -0.0.4.0 --------- -Fixed crash on VI upload -Modified unicode handling -Fixed memory leak -Added option to trap all possible exceptions -Added ability to provide crash reports for crashes in Miranda threads in 0.8 #19 and higher -Added Unicode version distribution - -0.0.3.4 --------- -Added storing version Information to file to top toolbar -Added storing crash report to clipboard -Attempt to resolve crashes with no report - -0.0.3.3 --------- -Fix for crash while generating crash report - -0.0.3.2 --------- -Added VersionInfo buttons to clist_modern toolbar -Fixed crash when dbghelp not installed or wrong version - -0.0.3.0 --------- -Added option to printout all loaded DLLs as VI -Added printout of dll version and date to dll list - -0.0.2.8 --------- -Fixed crash with Wine -Added MessageBox with location of Crash Report after every crash - -0.0.2.7 --------- -Fixed crash with debughlp.dll not available -Fixed unloadable dll diagnostics -Fixed Show VersionInfo under Win9x - -0.0.2.6 --------- -Fixed translation - -0.0.2.5 --------- -Improved diagnostics for unloadable dlls -Fixed unloading dbghelp when not needed -Fixed spelling - -0.0.2.4 --------- -Improved chances of getting crash report for some crashes - -0.0.2.3 --------- -Fixed unloadable plugin display -Improvements in notifications - -0.0.2.2 --------- -Added unloadable plugin display in VI -Fixed VI Show under Windows 9x - -0.0.2.1 --------- -Clarification in options text -Open global compare url on popup click after successful upload -Added outdated plugin indication after successful upload -Moved all db settings onto one group - -0.0.2.0 --------- -Fixed icolib support -Added new icons by Angeli-Ka -Added printout for profile creation date and size -Added VersionInfo uploading to www.miranda-vi.org -Removed interface to VIUploader plugin - -0.0.1.4 --------- -Fixed BBCode for uploaded VI - -0.0.1.3 --------- -Fixed BBCode formatting -Added BBCode to uploaded VI -Added country code to language pack info -Added possibility to add icons for menu items through icolib - -0.0.1.2 --------- -Fixed Folders support - -0.0.1.1 --------- -More robustness updates - -0.0.1.0 --------- -Fixed crashes during VersionInfo reporting -More lang pack info -Moved plugin causing crash reporting earlier - -0.0.0.13 --------- -More fixes to plugin sorting - -0.0.0.12 --------- -Made plugin sorting case insensitive - -0.0.0.11 --------- -Added WOW64 printout -Fixed VIUploader interface -Added explicit plugin sorting - -0.0.0.10 --------- -Changed printed timestamp -Merged profilename and path -Capturing only unhandled crashes - -0.0.0.9 -------- -Added protection against infinite exception loops -Fixed printing VersionInfo to file -Added context menu for VersionInfo window - -0.0.0.8 -------- -Fixed operation in service mode -Fixed inability to create crash report -Added ability to provide reports when multiple crash report plugins installed (only on XP or later) -Added notification when multiple crash reporting plugins installed -(as this causes conflict among plugins and inability to create crash reports) - -0.0.0.7 -------- -Changed all timestamps to ISO 8061:2004 format -Added keeping of window sizing & position -Changed preview window color -VersionInfo stored in profile directory by default -Added more formatting to VersionInfo -Added service mode support (dll name changed) - -0.0.0.6 -------- -Fixed storing VersionInfo to file -Added ui to show VersionInfo -Added service to retrieve VersionInfo - -0.0.0.5 -------- -Fixed crash reports with older dbghelp.dll -Added Folders plugin support -Added more VersionInfo reporting -Added VersionInfo storage (to file and clipboard) -Improved report formatting -Added ability to get VersionInfo by hotkey - -0.0.0.4 -------- -Added human readable exception code -Added complete description for access violation -Updated sources to compile with older PSDK -More VersionInfo related stuff - -0.0.0.3 -------- -Added reporting for Internet Explorer version -Added reporting for plugin Unicode capability -Added reporting for Miranda profile path and name -Added reporting for miranda.exe build date - -0.0.0.2 -------- -Reduced resource utilization -Allow Unicode compilation - -0.0.0.1 -------- -Initial release of the plugin - - -Miranda IM -========== -Miranda IM is an open source instant messenger framework that -support plugins for many different networks; ICQ, MSN, YAHOO -AIM to mention a few (but not all). Get it at: -http://www.miranda-im.org/ - - -Copyright and license -===================== - -Software: - -Copyright (C) 2008 - 2010 Boris Krasnovskiy All Rights Reserved - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; version 2 -of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . diff --git a/plugins/Svc_crshdmp/dumper.cpp b/plugins/Svc_crshdmp/dumper.cpp deleted file mode 100644 index bae091a023..0000000000 --- a/plugins/Svc_crshdmp/dumper.cpp +++ /dev/null @@ -1,745 +0,0 @@ -/* -Miranda Crash Dumper Plugin -Copyright (C) 2008 - 2012 Boris Krasnovskiy All Rights Reserved - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation version 2 -of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ - -#include "utils.h" - -extern TCHAR* vertxt; -extern TCHAR* profname; -extern TCHAR* profpath; - - -void CreateMiniDump(HANDLE hDumpFile, PEXCEPTION_POINTERS exc_ptr) -{ - MINIDUMP_EXCEPTION_INFORMATION exceptionInfo; - exceptionInfo.ThreadId = GetCurrentThreadId(); - exceptionInfo.ExceptionPointers = exc_ptr; - exceptionInfo.ClientPointers = false; - - MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), - hDumpFile, MiniDumpNormal, &exceptionInfo, NULL, NULL); -} - - -void WriteBBFile(bkstring& buffer, bool hdr) -{ - static const TCHAR header[] = TEXT("[quote][size=1]"); - static const TCHAR footer[] = TEXT("[/size][/quote]"); - - buffer.append(hdr ? header : footer); -} - - -void WriteUtfFile(HANDLE hDumpFile, char* bufu) -{ - DWORD bytes; - - static const unsigned char bytemark[] = { 0xEF, 0xBB, 0xBF }; - WriteFile(hDumpFile, bytemark, 3, &bytes, NULL); - WriteFile(hDumpFile, bufu, (DWORD)strlen(bufu), &bytes, NULL); -} - - -BOOL CALLBACK LoadedModules64(LPCSTR, DWORD64 ModuleBase, ULONG ModuleSize, PVOID UserContext) -{ - bkstring& buffer = *(bkstring*)UserContext; - - const HMODULE hModule = (HMODULE)ModuleBase; - - TCHAR path[MAX_PATH]; - GetModuleFileName(hModule, path, MAX_PATH); - - buffer.appendfmt(TEXT("%s %p - %p"), path, (LPVOID)ModuleBase, (LPVOID)(ModuleBase + ModuleSize)); - - GetVersionInfo(hModule, buffer); - - TCHAR timebuf[30] = TEXT(""); - GetLastWriteTime(path, timebuf, 30); - - buffer.appendfmt(TEXT(" [%s]\r\n"), timebuf); - - return TRUE; -} - -typedef struct _FindData -{ - DWORD64 Offset; IMAGEHLP_MODULE64* pModule; -} FindData; - - -BOOL CALLBACK LoadedModulesFind64(LPCSTR ModuleName, DWORD64 ModuleBase, ULONG ModuleSize, PVOID UserContext) -{ - FindData* data = (FindData*)UserContext; - - if ((DWORD)(data->Offset - ModuleBase) < ModuleSize) - { - const size_t len = SIZEOF(data->pModule->ModuleName); - strncpy(data->pModule->ModuleName, ModuleName, len); - data->pModule->ModuleName[len-1] = 0; - - data->pModule->BaseOfImage = ModuleBase; - - const HMODULE hModule = (HMODULE)ModuleBase; - GetModuleFileNameA(hModule, data->pModule->LoadedImageName, SIZEOF(data->pModule->LoadedImageName)); - - return FALSE; - } - return TRUE; -} - - -void GetLinkedModulesInfo(TCHAR *moduleName, bkstring &buffer) -{ - HANDLE hDllFile = CreateFile(moduleName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if (hDllFile == INVALID_HANDLE_VALUE) return; - - HANDLE hDllMapping = CreateFileMapping(hDllFile, NULL, PAGE_READONLY, 0, 0, NULL); - if (hDllMapping == INVALID_HANDLE_VALUE) - { - CloseHandle(hDllFile); - return; - } - - LPVOID dllAddr = MapViewOfFile(hDllMapping, FILE_MAP_READ, 0, 0, 0); - - - static const TCHAR format[] = TEXT(" Plugin statically linked to missing module: %S\r\n"); - - - __try - { - PIMAGE_NT_HEADERS nthdrs = ImageNtHeader(dllAddr); - - ULONG tableSize; - PIMAGE_IMPORT_DESCRIPTOR importData = (PIMAGE_IMPORT_DESCRIPTOR)ImageDirectoryEntryToData(dllAddr, FALSE, - IMAGE_DIRECTORY_ENTRY_IMPORT, &tableSize); - if (importData) - { - while (importData->Name) - { - char* moduleName = (char*)ImageRvaToVa(nthdrs, dllAddr, importData->Name, NULL); - if (!SearchPathA(NULL, moduleName, NULL, NULL, 0, NULL)) - { - buffer.appendfmt(format, moduleName); - } - importData++; //go to next record - } - } - - bool found = false; - PIMAGE_EXPORT_DIRECTORY exportData = (PIMAGE_EXPORT_DIRECTORY)ImageDirectoryEntryToData(dllAddr, FALSE, - IMAGE_DIRECTORY_ENTRY_EXPORT, &tableSize); - if (exportData) - { - ULONG* funcAddr = (ULONG*)ImageRvaToVa(nthdrs, dllAddr, exportData->AddressOfNames, NULL); - for(unsigned i=0; iNumberOfNames && !found; ++i) - { - char* funcName = (char*)ImageRvaToVa(nthdrs, dllAddr, funcAddr[i], NULL); - found = strcmp(funcName, "MirandaPluginInfoEx") == 0 || strcmp(funcName, "MirandaPluginInfo") == 0; - if (strcmp(funcName, "DatabasePluginInfo") == 0) - { - buffer.append(TEXT(" This dll is a Miranda database plugin, another database is active right now\r\n")); - found = true; - } - } - } - if (!found) - buffer.append(TEXT(" This dll is not a Miranda plugin and should be removed from plugins directory\r\n")); - } - __except(EXCEPTION_EXECUTE_HANDLER) {} - - UnmapViewOfFile(dllAddr); - CloseHandle(hDllMapping); - CloseHandle(hDllFile); -} - - -struct ListItem -{ - ListItem() : str(), next(NULL) {} - - bkstring str; - ListItem *next; -}; - -static void GetPluginsString(bkstring& buffer, unsigned& flags) -{ - buffer.appendfmt(TEXT("Service Mode: %s\r\n"), servicemode ? TEXT("Yes") : TEXT("No")); - - TCHAR path[MAX_PATH]; - GetModuleFileName(NULL, path, MAX_PATH); - - LPTSTR fname = _tcsrchr(path, TEXT('\\')); - if (fname == NULL) fname = path; - crs_sntprintf(fname, MAX_PATH-(fname-path), TEXT("\\plugins\\*.dll")); - - WIN32_FIND_DATA FindFileData; - HANDLE hFind = FindFirstFile(path, &FindFileData); - if (hFind == INVALID_HANDLE_VALUE) return; - - size_t count = 0, ucount = 0; - - bkstring ubuffer; - ListItem* dlllist = NULL; - - - static const TCHAR format[] = TEXT("%c %s v.%s%d.%d.%d.%d%s [%s] - %S %s\r\n"); - - - do - { - bool loaded = false; - crs_sntprintf(fname, MAX_PATH-(fname-path), TEXT("\\plugins\\%s"), FindFileData.cFileName); - HMODULE hModule = GetModuleHandle(path); - if (hModule == NULL && servicemode) - { - hModule = LoadLibrary(path); - loaded = true; - } - if (hModule == NULL) - { - if ((flags & VI_FLAG_PRNVAR) && IsPluginEnabled(FindFileData.cFileName)) - { - TCHAR timebuf[30] = TEXT(""); - GetLastWriteTime(&FindFileData.ftLastWriteTime, timebuf, 30); - - ubuffer.appendfmt(format, TEXT(' '), FindFileData.cFileName, - (flags & VI_FLAG_FORMAT) ? TEXT("[b]") : TEXT(""), - 0, 0, 0, 0, - (flags & VI_FLAG_FORMAT) ? TEXT("[/b]") : TEXT(""), - timebuf, "", TEXT("")); - - GetLinkedModulesInfo(path, ubuffer); - ubuffer.append(TEXT("\r\n")); - - ++ucount; - } - continue; - } - - PLUGININFOEX* pi = GetMirInfo(hModule); - if (pi != NULL) - { - TCHAR timebuf[30] = TEXT(""); - GetLastWriteTime(&FindFileData.ftLastWriteTime, timebuf, 30); - - bool ep = (size_t)pi->cbSize > sizeof(PLUGININFOEX); - const TCHAR *unica = (ep && ((PLUGININFOEX*)pi)->flags & 1) ? TEXT("|Unicode aware|") : TEXT(""); - - ListItem* lst = new ListItem; - DWORD ver = pi->version; - lst->str.appendfmt(format, ep ? TEXT('\xa4') : TEXT(' '), FindFileData.cFileName, - (flags & VI_FLAG_FORMAT) ? TEXT("[b]") : TEXT(""), - HIBYTE(HIWORD(ver)), LOBYTE(HIWORD(ver)), HIBYTE(LOWORD(ver)), LOBYTE(LOWORD(ver)), - (flags & VI_FLAG_FORMAT) ? TEXT("[/b]") : TEXT(""), - timebuf, pi->shortName ? pi->shortName : "", unica); - - ListItem* lsttmp = dlllist; - ListItem* lsttmppv = NULL; - while (lsttmp != NULL) - { - size_t sz = min(lsttmp->str.size(), lst->str.size()) - 2; - if (lsttmp->str.comparei(2, sz, lst->str, 2, sz) > 0) break; - lsttmppv = lsttmp; - lsttmp = lsttmp->next; - } - lst->next = lsttmp; - if (lsttmppv == NULL) - dlllist = lst; - else - lsttmppv->next = lst; - - if (_tcsicmp(FindFileData.cFileName, TEXT("weather.dll")) == 0) - flags |= VI_FLAG_WEATHER; - - ++count; - } - if (loaded) FreeLibrary(hModule); - } - while (FindNextFile(hFind, &FindFileData)); - FindClose(hFind); - - buffer.appendfmt(TEXT("\r\n%sActive Plugins (%u):%s\r\n"), - (flags & VI_FLAG_FORMAT) ? TEXT("[b]") : TEXT(""), count, (flags & VI_FLAG_FORMAT) ? TEXT("[/b]") : TEXT("")); - - ListItem* lsttmp = dlllist; - while (lsttmp != NULL) - { - buffer.append(lsttmp->str); - ListItem* lsttmp1 = lsttmp->next; - delete lsttmp; - lsttmp = lsttmp1; - } - - if (ucount) - { - buffer.appendfmt(TEXT("\r\n%sUnloadable Plugins (%u):%s\r\n"), - (flags & VI_FLAG_FORMAT) ? TEXT("[b]") : TEXT(""), ucount, (flags & VI_FLAG_FORMAT) ? TEXT("[/b]") : TEXT("")); - buffer.append(ubuffer); - } -} - - -struct ProtoCount -{ - char countse; - char countsd; - bool nloaded; -}; - -static void GetProtocolStrings(bkstring& buffer) -{ - PROTOACCOUNT **accList; - int accCount, protoCount; - int i, j; - - PROTOCOLDESCRIPTOR **protoList; - if (ProtoEnumAccounts(&accCount, &accList) == CALLSERVICE_NOTFOUND || (accCount > 0 && accList[0]->cbSize == 0)) - { - CallService(MS_PROTO_ENUMPROTOCOLS, (WPARAM)&protoCount, (LPARAM)&protoList); - for (i = 0; i < protoCount; i++) - { - if (protoList[i]->type != PROTOTYPE_PROTOCOL) continue; - - TCHAR* nm; - crsi_a2t(nm, protoList[i]->szName); - buffer.appendfmt(TEXT(" 1 - %s\r\n"), nm); - } - } - else - { - CallService(MS_PROTO_ENUMPROTOS, (WPARAM)&protoCount, (LPARAM)&protoList); - - int protoCountMy = 0; - char** protoListMy = (char**)alloca((protoCount + accCount) * sizeof(char*)); - - for (i = 0; i < protoCount; i++) - { - if (protoList[i]->type != PROTOTYPE_PROTOCOL) continue; - protoListMy[protoCountMy++] = protoList[i]->szName; - } - - for (j = 0; j < accCount; j++) - { - for (i = 0; i < protoCountMy; i++) - { - if (strcmp(protoListMy[i], accList[j]->szProtoName) == 0) - break; - } - if (i == protoCountMy) - protoListMy[protoCountMy++] = accList[j]->szProtoName; - } - - ProtoCount *protos = (ProtoCount*)alloca(sizeof(ProtoCount) * protoCountMy); - memset(protos, 0, sizeof(ProtoCount) * protoCountMy); - - for (j = 0; j < accCount; j++) - { - for (i = 0; i < protoCountMy; i++) - { - if (strcmp(protoListMy[i], accList[j]->szProtoName) == 0) - { - protos[i].nloaded = accList[j]->bDynDisabled != 0; - if (IsAccountEnabled(accList[j])) - ++protos[i].countse; - else - ++protos[i].countsd; - break; - } - } - } - for (i = 0; i < protoCountMy; i++) - { - TCHAR* nm; - crsi_a2t(nm, protoListMy[i]); - buffer.appendfmt(TEXT("%-24s %d - Enabled %d - Disabled %sLoaded\r\n"), nm, protos[i].countse, - protos[i].countsd, protos[i].nloaded ? _T("Not ") : _T("")); - } - } -} - - -static void GetWeatherStrings(bkstring& buffer, unsigned flags) -{ - TCHAR path[MAX_PATH]; - GetModuleFileName(NULL, path, MAX_PATH); - - LPTSTR fname = _tcsrchr(path, TEXT('\\')); - if (fname == NULL) fname = path; - crs_sntprintf(fname, MAX_PATH-(fname-path), TEXT("\\plugins\\weather\\*.ini")); - - WIN32_FIND_DATA FindFileData; - HANDLE hFind = FindFirstFile(path, &FindFileData); - if (hFind == INVALID_HANDLE_VALUE) return; - - do - { - if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue; - - crs_sntprintf(fname, MAX_PATH-(fname-path), TEXT("\\plugins\\weather\\%s"), FindFileData.cFileName); - HANDLE hDumpFile = CreateFile(path, GENERIC_READ, FILE_SHARE_READ, NULL, - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - - if (hDumpFile != INVALID_HANDLE_VALUE) - { - char buf[8192]; - - DWORD bytes = 0; - ReadFile(hDumpFile, buf, 8190, &bytes, NULL); - buf[bytes] = 0; - - char* ver = strstr(buf, "Version="); - if (ver != NULL) - { - char *endid = strchr(ver, '\r'); - if (endid != NULL) *endid = 0; - else - { - endid = strchr(ver, '\n'); - if (endid != NULL) *endid = 0; - } - ver += 8; - } - - char *id = strstr(buf, "Name="); - if (id != NULL) - { - char *endid = strchr(id, '\r'); - if (endid != NULL) *endid = 0; - else - { - endid = strchr(id, '\n'); - if (endid != NULL) *endid = 0; - } - id += 5; - } - - TCHAR timebuf[30] = TEXT(""); - GetLastWriteTime(&FindFileData.ftLastWriteTime, timebuf, 30); - - - static const TCHAR format[] = TEXT(" %s v.%s%S%s [%s] - %S\r\n"); - - buffer.appendfmt(format, FindFileData.cFileName, - (flags & VI_FLAG_FORMAT) ? TEXT("[b]") : TEXT(""), - ver, - (flags & VI_FLAG_FORMAT) ? TEXT("[/b]") : TEXT(""), - timebuf, id); - CloseHandle(hDumpFile); - } - } - while (FindNextFile(hFind, &FindFileData)); - FindClose(hFind); -} - - -static void GetIconStrings(bkstring& buffer) -{ - TCHAR path[MAX_PATH]; - GetModuleFileName(NULL, path, MAX_PATH); - - LPTSTR fname = _tcsrchr(path, TEXT('\\')); - if (fname == NULL) fname = path; - crs_sntprintf(fname, MAX_PATH-(fname-path), TEXT("\\Icons\\*.*")); - - WIN32_FIND_DATA FindFileData; - HANDLE hFind = FindFirstFile(path, &FindFileData); - if (hFind == INVALID_HANDLE_VALUE) return; - - do - { - if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue; - - TCHAR timebuf[30] = TEXT(""); - GetLastWriteTime(&FindFileData.ftLastWriteTime, timebuf, 30); - - buffer.appendfmt(TEXT(" %s [%s]\r\n"), FindFileData.cFileName, timebuf); - } - while (FindNextFile(hFind, &FindFileData)); - FindClose(hFind); -} - - -void PrintVersionInfo(bkstring& buffer, unsigned flags) -{ - GetProcessorString(buffer); - buffer.append(TEXT("\r\n")); - - GetFreeMemoryString(buffer); - buffer.append(TEXT("\r\n")); - - GetOSDisplayString(buffer); - buffer.append(TEXT("\r\n")); - - GetInternetExplorerVersion(buffer); - buffer.append(TEXT("\r\n")); - - GetAdminString(buffer); - buffer.append(TEXT("\r\n")); - - GetLanguageString(buffer); - buffer.append(TEXT("\r\n")); - - TCHAR *profpathfull = Utils_ReplaceVarsT(profpath); - if (flags & VI_FLAG_PRNVAR) - { - GetFreeDiskString(profpathfull, buffer); - buffer.append(TEXT("\r\n")); - } - - buffer.appendfmt(TEXT("\r\nMiranda IM Version: %s"), vertxt); - GetWow64String(buffer); - buffer.append(TEXT("\r\n")); - - TCHAR path[MAX_PATH], mirtime[30]; - GetModuleFileName(NULL, path, MAX_PATH); - GetLastWriteTime(path, mirtime, 30); - buffer.appendfmt(TEXT("Build time: %s\r\n"), mirtime); - - TCHAR profpn[MAX_PATH]; - crs_sntprintf(profpn, SIZEOF(profpn), TEXT("%s\\%s"), profpathfull, profname); - - buffer.appendfmt(TEXT("Profile: %s\r\n"), profpn); - - if (flags & VI_FLAG_PRNVAR) - { - WIN32_FIND_DATA FindFileData; - - HANDLE hFind = FindFirstFile(profpn, &FindFileData); - if (hFind != INVALID_HANDLE_VALUE) - { - FindClose(hFind); - - unsigned __int64 fsize = (unsigned __int64)FindFileData.nFileSizeHigh << 32 | FindFileData.nFileSizeLow; - buffer.appendfmt(TEXT("Profile size: %I64u Bytes\r\n"), fsize), - - GetLastWriteTime(&FindFileData.ftCreationTime, mirtime, 30); - buffer.appendfmt(TEXT("Profile creation date: %s\r\n"), mirtime); - } - } - mir_free(profpathfull); - - GetLanguagePackString(buffer); - buffer.append(TEXT("\r\n")); - - buffer.appendfmt(TEXT("Nightly: %s\r\n"), _tcsstr(vertxt, TEXT("alpha")) ? TEXT("Yes") : TEXT("No")); - buffer.appendfmt(TEXT("Unicode: %s\r\n"), _tcsstr(vertxt, TEXT("Unicode")) ? TEXT("Yes") : TEXT("No")); - - GetPluginsString(buffer, flags); - - if (flags & VI_FLAG_WEATHER) - { - buffer.appendfmt(TEXT("\r\n%sWeather ini files:%s\r\n-------------------------------------------------------------------------------\r\n"), - (flags & VI_FLAG_FORMAT) ? TEXT("[b]") : TEXT(""), - (flags & VI_FLAG_FORMAT) ? TEXT("[/b]") : TEXT("")); - GetWeatherStrings(buffer, flags); - } - - if (flags & VI_FLAG_PRNVAR && !servicemode) - { - buffer.appendfmt(TEXT("\r\n%sProtocols and Accounts:%s\r\n-------------------------------------------------------------------------------\r\n"), - (flags & VI_FLAG_FORMAT) ? TEXT("[b]") : TEXT(""), - (flags & VI_FLAG_FORMAT) ? TEXT("[/b]") : TEXT("")); - GetProtocolStrings(buffer); - } - - if (flags & VI_FLAG_PRNVAR) - { - buffer.appendfmt(TEXT("\r\n%sIcon Packs:%s\r\n-------------------------------------------------------------------------------\r\n"), - (flags & VI_FLAG_FORMAT) ? TEXT("[b]") : TEXT(""), - (flags & VI_FLAG_FORMAT) ? TEXT("[/b]") : TEXT("")); - GetIconStrings(buffer); - } - - if (flags & VI_FLAG_PRNDLL) - { - __try - { - buffer.append(TEXT("\r\nLoaded Modules:\r\n-------------------------------------------------------------------------------\r\n")); - EnumerateLoadedModules64(GetCurrentProcess(), LoadedModules64, &buffer); - } - __except(EXCEPTION_EXECUTE_HANDLER) {} - } - - if (flags & (VI_FLAG_PRNVAR | VI_FLAG_PRNDLL)) UnloadDbgHlp(); -} - - -void CreateCrashReport(HANDLE hDumpFile, PEXCEPTION_POINTERS exc_ptr, const TCHAR* msg) -{ - if (exc_ptr->ContextRecord == NULL || (exc_ptr->ContextRecord->ContextFlags & CONTEXT_CONTROL) == 0) - return; - - CONTEXT context = *exc_ptr->ContextRecord; - - STACKFRAME64 frame = {0}; - -#if defined(_AMD64_) -#define IMAGE_FILE_MACHINE IMAGE_FILE_MACHINE_AMD64 - frame.AddrPC.Offset = context.Rip; - frame.AddrFrame.Offset = context.Rbp; - frame.AddrStack.Offset = context.Rsp; -#elif defined(_IA64_) -#define IMAGE_FILE_MACHINE IMAGE_FILE_MACHINE_IA64 - frame.AddrPC.Offset = context.StIIP; - frame.AddrFrame.Offset = context.AddrBStore; - frame.AddrStack.Offset = context.SP; -#else -#define IMAGE_FILE_MACHINE IMAGE_FILE_MACHINE_I386 - frame.AddrPC.Offset = context.Eip; - frame.AddrFrame.Offset = context.Ebp; - frame.AddrStack.Offset = context.Esp; -#endif - - frame.AddrPC.Mode = AddrModeFlat; - frame.AddrFrame.Mode = AddrModeFlat; - frame.AddrStack.Mode = AddrModeFlat; - - const PLUGININFOEX *pluginInfoEx = GetPluginInfoEx(); - - bkstring buffer; - buffer.reserve(0x5000); - - TCHAR curtime[30]; - GetISO8061Time(NULL, curtime, 30); - - buffer.appendfmt(TEXT("Miranda Crash Report from %s. Crash Dumper v.%d.%d.%d.%d\r\n"), - curtime, - HIBYTE(HIWORD(pluginInfoEx->version)), LOBYTE(HIWORD(pluginInfoEx->version)), - HIBYTE(LOWORD(pluginInfoEx->version)), LOBYTE(LOWORD(pluginInfoEx->version))); - - size_t crashpos = buffer.size(); - - ReadableExceptionInfo(exc_ptr->ExceptionRecord, buffer); - buffer.append(TEXT("\r\n")); - - const HANDLE hProcess = GetCurrentProcess(); - - if (&SymSetOptions) - SymSetOptions(SYMOPT_UNDNAME | SYMOPT_DEFERRED_LOADS | SYMOPT_LOAD_LINES); - SymInitialize(hProcess, NULL, TRUE); - - buffer.append(TEXT("\r\nStack Trace:\r\n---------------------------------------------------------------\r\n")); - - for (int i=81; --i;) - { - /* - char symbuf[sizeof(SYMBOL_INFO) + MAX_SYM_NAME * sizeof(TCHAR) + 4] = {0}; - PSYMBOL_INFO pSym = (PSYMBOL_INFO)symbuf; - pSym->SizeOfStruct = sizeof(SYMBOL_INFO); - pSym->MaxNameLen = MAX_SYM_NAME; - */ - - char symbuf[sizeof(IMAGEHLP_SYMBOL64) + MAX_SYM_NAME * sizeof(TCHAR) + 4] = {0}; - PIMAGEHLP_SYMBOL64 pSym = (PIMAGEHLP_SYMBOL64)symbuf; - pSym->SizeOfStruct = sizeof(IMAGEHLP_SYMBOL64); - pSym->MaxNameLength = MAX_SYM_NAME; - - IMAGEHLP_LINE64 Line = {0}; - Line.SizeOfStruct = sizeof(Line); - - IMAGEHLP_MODULE64 Module = {0}; - Module.SizeOfStruct = sizeof(IMAGEHLP_MODULE64_V2); - - char undName[MAX_SYM_NAME] = ""; - char undFullName[MAX_SYM_NAME] = ""; - - DWORD64 offsetFromSmybol = 0; - DWORD offsetFromLine = 0; - - if (!StackWalk64(IMAGE_FILE_MACHINE, hProcess, GetCurrentThread(), &frame, &context, - NULL, SymFunctionTableAccess64, SymGetModuleBase64, NULL)) break; - - if (frame.AddrPC.Offset == frame.AddrReturn.Offset) break; - - if (frame.AddrPC.Offset != 0) - { - if (SymGetSymFromAddr64(hProcess, frame.AddrPC.Offset, &offsetFromSmybol, pSym)) - // if (SymFromAddr(hProcess, frame.AddrPC.Offset, &offsetFromSmybol, pSym)) - { - UnDecorateSymbolName(pSym->Name, undName, MAX_SYM_NAME, UNDNAME_NAME_ONLY); - UnDecorateSymbolName(pSym->Name, undFullName, MAX_SYM_NAME, UNDNAME_COMPLETE); - } - - SymGetLineFromAddr64(hProcess, frame.AddrPC.Offset, &offsetFromLine, &Line); - SymGetModuleInfo64(hProcess, frame.AddrPC.Offset, &Module); - if (Module.ModuleName[0] == 0) - { - FindData data; - data.Offset = frame.AddrPC.Offset; - data.pModule = &Module; - EnumerateLoadedModules64(hProcess, LoadedModulesFind64, &data); - } - } - - const char* name; - if (undFullName[0] != 0) - name = undFullName; - else if (undName[0] != 0) - name = undName; - else if (pSym->Name[0] != 0) - name = pSym->Name; - else - name = "(function-name not available)"; - - const char *lineFileName = Line.FileName ? Line.FileName : "(filename not available)"; - const char *moduleName = Module.ModuleName[0] ? Module.ModuleName : "(module-name not available)"; - - if (crashpos != 0) - { - HMODULE hModule = (HMODULE)Module.BaseOfImage; - PLUGININFOEX *pi = GetMirInfo(hModule); - if (pi != NULL) - { - - static const TCHAR formatc[] = TEXT("\r\nLikely cause of the crash plugin: %S\r\n\r\n"); - - if (pi->shortName) - { - bkstring crashcause; - crashcause.appendfmt(formatc, pi->shortName); - buffer.insert(crashpos, crashcause); - } - crashpos = 0; - } - } - - - static const TCHAR formatd[] = TEXT("%p (%S %p): %S (%d): %S\r\n"); - - buffer.appendfmt(formatd, - (LPVOID)frame.AddrPC.Offset, moduleName, (LPVOID)Module.BaseOfImage, - lineFileName, Line.LineNumber, name); - } - SymCleanup(hProcess); - buffer.append(TEXT("\r\n")); - - PrintVersionInfo(buffer, VI_FLAG_PRNDLL); - - - int len = WideCharToMultiByte(CP_UTF8, 0, buffer.c_str(), -1, NULL, 0, NULL, NULL); - char* dst = (char*)(len > 8192 ? malloc(len) : alloca(len)); - WideCharToMultiByte(CP_UTF8, 0, buffer.c_str(), -1, dst, len, NULL, NULL); - - WriteUtfFile(hDumpFile, dst); - - if (len > 8192) free(dst); - - - if (msg && MessageBox(NULL, msg, TEXT("Miranda Crash Dumper"), MB_YESNO | MB_ICONERROR | MB_TASKMODAL | MB_DEFBUTTON2 | MB_TOPMOST) == IDYES) - StoreStringToClip(buffer); -} diff --git a/plugins/Svc_crshdmp/exhndlr.cpp b/plugins/Svc_crshdmp/exhndlr.cpp deleted file mode 100644 index 93406efaa8..0000000000 --- a/plugins/Svc_crshdmp/exhndlr.cpp +++ /dev/null @@ -1,207 +0,0 @@ -#include "utils.h" -#include "crtdbg.h" - -static PVOID exchndlr, exchndlrv; -static pfnExceptionFilter threadfltr; -static PEXCEPTION_POINTERS lastptr; - -static HMODULE hKernel = GetModuleHandle(TEXT("kernel32.dll")); - -tAddVectoredExceptionHandler pAddVectoredExceptionHandler = (tAddVectoredExceptionHandler)GetProcAddress(hKernel, "AddVectoredExceptionHandler"); -tRemoveVectoredExceptionHandler pRemoveVectoredExceptionHandler = (tRemoveVectoredExceptionHandler)GetProcAddress(hKernel, "RemoveVectoredExceptionHandler"); -tRtlCaptureContext pRtlCaptureContext = (tRtlCaptureContext)GetProcAddress(hKernel, "RtlCaptureContext"); - -void SetExceptionHandler(void) -{ - // if (pAddVectoredExceptionHandler && !exchndlrv) - // exchndlrv = pAddVectoredExceptionHandler(0, myfilterv); - /*exchndlr = */ SetUnhandledExceptionFilter(myfilter); -} - -void RemoveExceptionHandler(void) -{ - if (pRemoveVectoredExceptionHandler && exchndlrv) - pRemoveVectoredExceptionHandler(exchndlrv); - SetUnhandledExceptionFilter((LPTOP_LEVEL_EXCEPTION_FILTER)exchndlr); - exchndlr = NULL; - exchndlrv = NULL; -} - -void UnloadDbgHlp(void) -{ -#ifdef _MSC_VER -#if _MSC_VER > 1200 - __FUnloadDelayLoadedDLL2("dbghelp.dll"); -#else - __FUnloadDelayLoadedDLL("dbghelp.dll"); -#endif -#endif -} - -int myDebugFilter(unsigned int code, PEXCEPTION_POINTERS ep) -{ - if (code == VcppException(ERROR_SEVERITY_ERROR, ERROR_MOD_NOT_FOUND) || - code == VcppException(ERROR_SEVERITY_ERROR, ERROR_PROC_NOT_FOUND)) - { - PDelayLoadInfo dlld = (PDelayLoadInfo)ep->ExceptionRecord->ExceptionInformation[0]; - - char str[256]; - int off = mir_snprintf(str, SIZEOF(str), "dbghelp.dll v.5.0 or later required to provide a crash report\n"); - off += mir_snprintf(str+off, SIZEOF(str)-off, "Missing Module: %s ", dlld->szDll); - - if (dlld->dlp.fImportByName) - mir_snprintf(str+off, SIZEOF(str)-off, "Function: %s ", dlld->dlp.szProcName); - else - mir_snprintf(str+off, SIZEOF(str)-off, "Ordinal: %x ", dlld->dlp.dwOrdinal); - - MessageBoxA(NULL, str, "Miranda Crash Dumper", MB_OK | MB_ICONERROR | MB_TASKMODAL | MB_TOPMOST); - } - - return EXCEPTION_EXECUTE_HANDLER; -} - - -void myfilterWorker(PEXCEPTION_POINTERS exc_ptr, bool notify) -{ - TCHAR path[MAX_PATH]; - SYSTEMTIME st; - HANDLE hDumpFile = NULL; - - GetLocalTime(&st); - CreateDirectoryTree(CrashLogFolder); - - __try - { - if (dtsubfldr) - { - crs_sntprintf(path, MAX_PATH, TEXT("%s\\%02d.%02d.%02d"), CrashLogFolder, st.wYear, st.wMonth, st.wDay); - CreateDirectory(path, NULL); - crs_sntprintf(path, MAX_PATH, TEXT("%s\\%02d.%02d.%02d\\crash%02d%02d%02d%02d%02d%02d.mdmp"), CrashLogFolder, - st.wYear, st.wMonth, st.wDay, st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond); - } - else - { - crs_sntprintf(path, MAX_PATH, TEXT("%s\\crash%02d%02d%02d%02d%02d%02d.mdmp"), CrashLogFolder, - st.wYear, st.wMonth, st.wDay, st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond); - } - hDumpFile = CreateFile(path, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL); - if (hDumpFile != INVALID_HANDLE_VALUE) - CreateMiniDump(hDumpFile, exc_ptr); - else if (GetLastError() != ERROR_ALREADY_EXISTS) - MessageBox(NULL, TranslateT("Crash Report write location is inaccesible"), - TEXT("Miranda Crash Dumper"), MB_OK | MB_ICONERROR | MB_TASKMODAL | MB_TOPMOST); - - } - __except(EXCEPTION_EXECUTE_HANDLER) {} - - bool empty = GetFileSize(hDumpFile, NULL) == 0; - CloseHandle(hDumpFile); - if (empty) DeleteFile(path); - - __try - { - if (dtsubfldr) - { - crs_sntprintf(path, MAX_PATH, TEXT("%s\\%02d.%02d.%02d"), CrashLogFolder, st.wYear, st.wMonth, st.wDay); - CreateDirectory(path, NULL); - crs_sntprintf(path, MAX_PATH, TEXT("%s\\%02d.%02d.%02d\\crash%02d%02d%02d%02d%02d%02d.txt"), CrashLogFolder, - st.wYear, st.wMonth, st.wDay, st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond); - } - else - { - crs_sntprintf(path, MAX_PATH, TEXT("%s\\crash%02d%02d%02d%02d%02d%02d.txt"), CrashLogFolder, - st.wYear, st.wMonth, st.wDay, st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond); - } - hDumpFile = CreateFile(path, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL); - - crs_sntprintf(path, MAX_PATH, TranslateT("Miranda crashed. Crash report stored in the folder:\n %s\n\n Would you like store it in the clipboard as well?"), CrashLogFolder); - - if (hDumpFile != INVALID_HANDLE_VALUE) - CreateCrashReport(hDumpFile, exc_ptr, notify ? path : NULL); - } - __except(myDebugFilter(GetExceptionCode(), GetExceptionInformation())) {} - - bool empty1 = GetFileSize(hDumpFile, NULL) == 0; - CloseHandle(hDumpFile); - if (empty1) DeleteFile(path); - - UnloadDbgHlp(); -} - -LONG WINAPI myfilter(PEXCEPTION_POINTERS exc_ptr) -{ - if (exc_ptr == lastptr) return EXCEPTION_EXECUTE_HANDLER; - lastptr = exc_ptr; - - myfilterWorker(exc_ptr, true); - - return exchndlr ? ((LPTOP_LEVEL_EXCEPTION_FILTER)exchndlr)(exc_ptr) : EXCEPTION_CONTINUE_SEARCH; -} - -LONG WINAPI myfilterv(PEXCEPTION_POINTERS exc_ptr) -{ - if (0xC0000000L <= exc_ptr->ExceptionRecord->ExceptionCode && 0xC0000500L >= exc_ptr->ExceptionRecord->ExceptionCode) - { - if (exc_ptr == lastptr) return EXCEPTION_EXECUTE_HANDLER; - lastptr = exc_ptr; - - myfilterWorker(exc_ptr, true); - } - return EXCEPTION_CONTINUE_SEARCH; -} - -DWORD MirandaThreadFilter(DWORD code, EXCEPTION_POINTERS* info) -{ - if (info != lastptr) - { - lastptr = info; - myfilterWorker(info, true); - } - return threadfltr(code, info); -} - -#if _MSC_VER >= 1400 -void InvalidParameterHandler(const wchar_t*, const wchar_t*, const wchar_t*, unsigned int, UINT_PTR) -{ - EXCEPTION_RECORD ExceptionRecord = {0}; - CONTEXT ContextRecord = {0}; - EXCEPTION_POINTERS info = { &ExceptionRecord, &ContextRecord }; - - if (pRtlCaptureContext) - pRtlCaptureContext(&ContextRecord); - else - { - ContextRecord.ContextFlags = CONTEXT_ALL; - GetThreadContext(GetCurrentThread(), &ContextRecord); - } - -#if defined(_AMD64_) - ExceptionRecord.ExceptionAddress = (PVOID)ContextRecord.Rip; -#elif defined(_IA64_) - ExceptionRecord.ExceptionAddress = (PVOID)ContextRecord.BrRp; -#else - ExceptionRecord.ExceptionAddress = (PVOID)ContextRecord.Eip; -#endif - - ExceptionRecord.ExceptionCode = STATUS_INVALID_CRUNTIME_PARAMETER; - ExceptionRecord.ExceptionFlags = EXCEPTION_NONCONTINUABLE; - - myfilterWorker(&info, true); -} -#endif - -void InitExceptionHandler(void) -{ -#if _MSC_VER >= 1400 - _set_invalid_parameter_handler(InvalidParameterHandler); -#endif - threadfltr = Miranda_SetExceptFilter(MirandaThreadFilter); - SetExceptionHandler(); -} - -void DestroyExceptionHandler(void) -{ - Miranda_SetExceptFilter(threadfltr); - RemoveExceptionHandler(); -} - diff --git a/plugins/Svc_crshdmp/resource.h b/plugins/Svc_crshdmp/resource.h deleted file mode 100644 index 83d8a491e4..0000000000 --- a/plugins/Svc_crshdmp/resource.h +++ /dev/null @@ -1,34 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by crshdmp.rc -// -#define IDD_VIEWVERSION 101 -#define IDR_CONTEXT 102 -#define IDI_VI 104 -#define IDI_VISHOW 105 -#define IDI_VITOCLIP 106 -#define IDI_VITOFILE 107 -#define IDI_VIUPLOAD 108 -#define IDD_OPTIONS 109 -#define IDC_VIEWVERSIONINFO 1001 -#define IDC_FILEVER 1003 -#define IDC_CLIPVER 1004 -#define IDC_USERNAME 1006 -#define IDC_PASSWORD 1007 -#define IDC_UPLOADCHN 1008 -#define IDC_CLASSICDATES 1009 -#define IDC_DATESUBFOLDER 1010 -#define IDM_COPY 40002 -#define IDM_COPYALL 40003 -#define IDM_SELECTALL 40004 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 110 -#define _APS_NEXT_COMMAND_VALUE 40005 -#define _APS_NEXT_CONTROL_VALUE 1011 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/plugins/Svc_crshdmp/sdkstuff.h b/plugins/Svc_crshdmp/sdkstuff.h deleted file mode 100644 index 536a00bc40..0000000000 --- a/plugins/Svc_crshdmp/sdkstuff.h +++ /dev/null @@ -1,124 +0,0 @@ -/* -Miranda Crash Dumper Plugin -Copyright (C) 2008 - 2012 Boris Krasnovskiy All Rights Reserved - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation version 2 -of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ - -#include - - -//#define DBGHELP_TRANSLATE_TCHAR - - -#ifndef __in_bcount_opt -#define __in_bcount_opt(x) -#endif - -#ifndef __out_bcount_opt -#define __out_bcount_opt(x) -#endif - -#include "dbghelp.h" - - -#ifndef PRODUCT_ULTIMATE - -#define PRODUCT_UNDEFINED 0x00000000 - -#define PRODUCT_ULTIMATE 0x00000001 -#define PRODUCT_HOME_BASIC 0x00000002 -#define PRODUCT_HOME_PREMIUM 0x00000003 -#define PRODUCT_ENTERPRISE 0x00000004 -#define PRODUCT_HOME_BASIC_N 0x00000005 -#define PRODUCT_BUSINESS 0x00000006 -#define PRODUCT_STANDARD_SERVER 0x00000007 -#define PRODUCT_DATACENTER_SERVER 0x00000008 -#define PRODUCT_SMALLBUSINESS_SERVER 0x00000009 -#define PRODUCT_ENTERPRISE_SERVER 0x0000000A -#define PRODUCT_STARTER 0x0000000B -#define PRODUCT_DATACENTER_SERVER_CORE 0x0000000C -#define PRODUCT_STANDARD_SERVER_CORE 0x0000000D -#define PRODUCT_ENTERPRISE_SERVER_CORE 0x0000000E -#define PRODUCT_ENTERPRISE_SERVER_IA64 0x0000000F -#define PRODUCT_BUSINESS_N 0x00000010 -#define PRODUCT_WEB_SERVER 0x00000011 -#define PRODUCT_CLUSTER_SERVER 0x00000012 -#define PRODUCT_HOME_SERVER 0x00000013 -#define PRODUCT_STORAGE_EXPRESS_SERVER 0x00000014 -#define PRODUCT_STORAGE_STANDARD_SERVER 0x00000015 -#define PRODUCT_STORAGE_WORKGROUP_SERVER 0x00000016 -#define PRODUCT_STORAGE_ENTERPRISE_SERVER 0x00000017 -#define PRODUCT_SERVER_FOR_SMALLBUSINESS 0x00000018 -#define PRODUCT_SMALLBUSINESS_SERVER_PREMIUM 0x00000019 - -#define PRODUCT_UNLICENSED 0xABCDABCD - -#define SM_TABLETPC 86 -#define SM_MEDIACENTER 87 -#define SM_STARTER 88 -#define SM_SERVERR2 89 - -#endif - -#ifndef VER_SUITE_STORAGE_SERVER -#define VER_SUITE_STORAGE_SERVER 0x00002000 -#define VER_SUITE_COMPUTE_SERVER 0x00004000 -#endif - -#ifndef PF_NX_ENABLED -#define PF_NX_ENABLED 12 -#endif - -typedef struct _IMAGEHLP_MODULE64_V2 { - DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_MODULE64) - DWORD64 BaseOfImage; // base load address of module - DWORD ImageSize; // virtual size of the loaded module - DWORD TimeDateStamp; // date/time stamp from pe header - DWORD CheckSum; // checksum from the pe header - DWORD NumSyms; // number of symbols in the symbol table - SYM_TYPE SymType; // type of symbols loaded - CHAR ModuleName[32]; // module name - CHAR ImageName[256]; // image name - CHAR LoadedImageName[256]; // symbol file name -} IMAGEHLP_MODULE64_V2; - -typedef struct _IMAGEHLP_MODULEW64_V2 { - DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_MODULE64) - DWORD64 BaseOfImage; // base load address of module - DWORD ImageSize; // virtual size of the loaded module - DWORD TimeDateStamp; // date/time stamp from pe header - DWORD CheckSum; // checksum from the pe header - DWORD NumSyms; // number of symbols in the symbol table - SYM_TYPE SymType; // type of symbols loaded - WCHAR ModuleName[32]; // module name - WCHAR ImageName[256]; // image name - WCHAR LoadedImageName[256]; // symbol file name -} IMAGEHLP_MODULEW64_V2; - -#ifdef DBGHELP_TRANSLATE_TCHAR -#define IMAGEHLP_MODULE64_V2 IMAGEHLP_MODULEW64_V2 -#endif - -typedef void (WINAPI *tGetNativeSystemInfo)(LPSYSTEM_INFO); -typedef BOOL (WINAPI *tGetProductInfo)(DWORD, DWORD, DWORD, DWORD, PDWORD); -typedef BOOL (WINAPI *tGlobalMemoryStatusEx)(LPMEMORYSTATUSEX lpBuffer); -typedef BOOL (WINAPI *tGetDiskFreeSpaceEx)(LPCTSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER); -typedef LANGID (WINAPI *tGetUserDefaultUILanguage)(void); -typedef LANGID (WINAPI *tGetSystemDefaultUILanguage)(void); -typedef BOOL (WINAPI *tIsWow64Process)(HANDLE, PBOOL); -typedef PVOID (WINAPI *tAddVectoredExceptionHandler)(ULONG FirstHandler, PVECTORED_EXCEPTION_HANDLER VectoredHandler); -typedef ULONG (WINAPI *tRemoveVectoredExceptionHandler)(PVOID Handler); -typedef BOOL (WINAPI *tIsProcessorFeaturePresent)(DWORD ProcessorFeature); -typedef VOID (WINAPI *tRtlCaptureContext)(PCONTEXT ContextRecord); diff --git a/plugins/Svc_crshdmp/svc_crshdmp-translation.txt b/plugins/Svc_crshdmp/svc_crshdmp-translation.txt deleted file mode 100644 index 18d251f699..0000000000 --- a/plugins/Svc_crshdmp/svc_crshdmp-translation.txt +++ /dev/null @@ -1,54 +0,0 @@ -; Common strings that belong to many files -;[] - -; ../../plugins/Svc_crshdmp/crshdmp.cpp -;[Copy Version Info to clipboard] -;[Copy to clipboard] -;[Open crash report directory] -;[Open miranda-vi.org] -;[Services] -;[Show] -;[Show Version Info] -;[Show Version Information] -;[Show with DLLs] -;[Store to file] -;[Upload] -;[Upload Version Information] -;[Version Information] -;[Version Information To Clipboard] -;[Version Information To File] -;[VersionInfo file %s is inaccessible] -;[VersionInfo stored into file %s] - -; ../../plugins/Svc_crshdmp/crshdmp.rc -;[&Copy] -;[Close] -;[Co&py All] -;[Copy To Clipboard] -;[Create reports in subfolders naming as current date] -;[General] -;[Password] -;[Select &All] -;[Support for miranda-vi.org] -;[To File] -;[Upload automatically when changed] -;[Use classic dates] -;[Username] -;[View] -;[View Version Information ] - -; ../../plugins/Svc_crshdmp/exhndlr.cpp -;[Crash Report write location is inaccesible] -;[Miranda crashed. Crash report stored in the folder:\n %s\n\n Would you like store it in the clipboard as well?] - -; ../../plugins/Svc_crshdmp/upload.cpp -;[Cannot upload VersionInfo. Daily upload limit exceeded] -;[Cannot upload VersionInfo. Host unreachable.] -;[Cannot upload VersionInfo. Incorrect username or password] -;[Cannot upload VersionInfo. Unknown error] -;[Cannot upload VersionInfo. User is banned] -;[Crash Dumper HTTP connections] -;[VersionInfo upload successful,\n %d old plugins] - -; ../../plugins/Svc_crshdmp/utils.cpp -;[More then one crash reporting plugin installed. This will result in inability of creating crash reports] diff --git a/plugins/Svc_crshdmp/ui.cpp b/plugins/Svc_crshdmp/ui.cpp deleted file mode 100644 index 00cf9c26cd..0000000000 --- a/plugins/Svc_crshdmp/ui.cpp +++ /dev/null @@ -1,327 +0,0 @@ -/* -Miranda Crash Dumper Plugin -Copyright (C) 2008 - 2012 Boris Krasnovskiy All Rights Reserved - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation version 2 -of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ - -#include "utils.h" -#include -#include -#include - -HWND hViewWnd; -extern HINSTANCE hInst; - - -HDWP MyResizeWindow (HDWP hDwp, HWND hwndDlg, HWND hwndCtrl, int nHorizontalOffset, int nVerticalOffset, - int nWidthOffset, int nHeightOffset) -{ - POINT pt; - RECT rcinit; - - // get current bounding rectangle - GetWindowRect(hwndCtrl, &rcinit); - - // get current top left point - pt.x = rcinit.left; - pt.y = rcinit.top; - ScreenToClient(hwndDlg, &pt); - - return DeferWindowPos(hDwp, hwndCtrl, NULL, - pt.x + nHorizontalOffset, - pt.y + nVerticalOffset, - rcinit.right - rcinit.left + nWidthOffset, - rcinit.bottom - rcinit.top + nHeightOffset, - SWP_NOZORDER); -} - -BOOL MyResizeGetOffset(HWND hwndCtrl, int nWidth, int nHeight, int* nDx, int* nDy) -{ - RECT rcinit; - - // get current bounding rectangle - GetWindowRect(hwndCtrl, &rcinit); - - // calculate offsets - *nDx = nWidth - (rcinit.right - rcinit.left); - *nDy = nHeight - (rcinit.bottom - rcinit.top); - - return rcinit.bottom != rcinit.top && nHeight > 0; -} - -INT_PTR CALLBACK DlgProcView(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - switch (msg) - { - case WM_INITDIALOG: - if (hViewWnd == NULL) - { - hViewWnd = hwndDlg; - TranslateDialogDefault(hwndDlg); - SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)LoadIconEx("versionInfo", true)); - SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)LoadIconEx("versionInfo")); - - CHARFORMAT2 chf; - chf.cbSize = sizeof(chf); - SendDlgItemMessage(hwndDlg, IDC_VIEWVERSIONINFO, EM_GETCHARFORMAT, SCF_DEFAULT, (LPARAM)&chf); - _tcscpy(chf.szFaceName, TEXT("Courier New")); - SendDlgItemMessage(hwndDlg, IDC_VIEWVERSIONINFO, EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&chf); - - bkstring buffer; - buffer.reserve(0x1800); - PrintVersionInfo(buffer, (unsigned int)lParam); - SetDlgItemText(hwndDlg, IDC_VIEWVERSIONINFO, buffer.c_str()); - SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); - - Utils_RestoreWindowPositionNoMove(hwndDlg, NULL, PluginName, "ViewInfo_"); - ShowWindow(hwndDlg, SW_SHOW); - } - else - DestroyWindow(hwndDlg); - break; - - case WM_SIZE: - { - int dx, dy, bsz; - HDWP hDwp; - RECT rc; - - GetWindowRect(GetDlgItem(hwndDlg, IDC_FILEVER), &rc); - bsz = rc.bottom - rc.top; - - if (MyResizeGetOffset(GetDlgItem(hwndDlg, IDC_VIEWVERSIONINFO), - LOWORD(lParam)-20, HIWORD(lParam)-30-bsz, &dx, &dy)) - { - hDwp = BeginDeferWindowPos(4); - hDwp = MyResizeWindow(hDwp, hwndDlg, GetDlgItem(hwndDlg, IDC_FILEVER), 0, dy, 0, 0); - hDwp = MyResizeWindow(hDwp, hwndDlg, GetDlgItem(hwndDlg, IDC_CLIPVER), dx/2, dy, 0, 0); - hDwp = MyResizeWindow(hDwp, hwndDlg, GetDlgItem(hwndDlg, IDCANCEL), dx, dy, 0, 0); - hDwp = MyResizeWindow(hDwp, hwndDlg, GetDlgItem(hwndDlg, IDC_VIEWVERSIONINFO), 0, 0, dx, dy); - EndDeferWindowPos(hDwp); - } - } - break; - - case WM_GETMINMAXINFO: - { - LPMINMAXINFO mmi = (LPMINMAXINFO)lParam; - - // The minimum width in points - mmi->ptMinTrackSize.x = 350; - // The minimum height in points - mmi->ptMinTrackSize.y = 300; - } - break; - - case WM_COMMAND: - switch(LOWORD(wParam)) - { - case IDC_CLIPVER: - CallService(MS_CRASHDUMPER_STORETOCLIP, 0, GetWindowLongPtr(hwndDlg, GWLP_USERDATA)); - break; - - case IDC_FILEVER: - CallService(MS_CRASHDUMPER_STORETOFILE, 0, GetWindowLongPtr(hwndDlg, GWLP_USERDATA)); - break; - - case IDCANCEL: - DestroyWindow(hwndDlg); - break; - } - break; - - case WM_CONTEXTMENU: - { - HWND hView = GetDlgItem(hwndDlg, IDC_VIEWVERSIONINFO); - RECT rc; - GetWindowRect(hView, &rc); - - POINT pt; - pt.x = LOWORD(lParam); - pt.y = HIWORD(lParam); - if (PtInRect(&rc, pt)) - { - static const CHARRANGE all = { 0, -1 }; - - HMENU hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_CONTEXT)); - HMENU hSubMenu = GetSubMenu(hMenu, 0); - TranslateMenu(hSubMenu); - - CHARRANGE sel; - SendMessage(hView, EM_EXGETSEL, 0, (LPARAM)&sel); - if (sel.cpMin == sel.cpMax) - EnableMenuItem(hSubMenu, IDM_COPY, MF_BYCOMMAND | MF_GRAYED); - - switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL)) - { - case IDM_COPY: - SendMessage(hView, WM_COPY, 0, 0); - break; - - case IDM_COPYALL: - SendMessage(hView, EM_EXSETSEL, 0, (LPARAM)&all); - SendMessage(hView, WM_COPY, 0, 0); - SendMessage(hView, EM_EXSETSEL, 0, (LPARAM)&sel); - break; - - case IDM_SELECTALL: - SendMessage(hView, EM_EXSETSEL, 0, (LPARAM)&all); - break; - } - DestroyMenu(hMenu); - } - } - break; - - case WM_DESTROY: - hViewWnd = NULL; - ReleaseIconEx((HICON)SendMessage(hwndDlg, WM_SETICON, ICON_BIG, 0)); - ReleaseIconEx((HICON)SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, 0)); - Utils_SaveWindowPosition(hwndDlg, NULL, PluginName, "ViewInfo_"); - if (servicemode) PostQuitMessage(0); - break; - } - return FALSE; -} - - -void DestroyAllWindows(void) -{ - if (hViewWnd != NULL) DestroyWindow(hViewWnd); - hViewWnd = NULL; -} - - -INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - switch (msg) - { - case WM_INITDIALOG: - { - TranslateDialogDefault(hwndDlg); - - DBVARIANT dbv; - if (DBGetContactSettingString(NULL, PluginName, "Username", &dbv) == 0) - { - SetDlgItemTextA(hwndDlg, IDC_USERNAME, dbv.pszVal); - DBFreeVariant(&dbv); - } - if (DBGetContactSettingString(NULL, PluginName, "Password", &dbv) == 0) - { - CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal)+1, (LPARAM)dbv.pszVal); - SetDlgItemTextA(hwndDlg, IDC_PASSWORD, dbv.pszVal); - DBFreeVariant(&dbv); - } - CheckDlgButton(hwndDlg, IDC_UPLOADCHN, DBGetContactSettingByte(NULL, PluginName, "UploadChanged", 0)); - CheckDlgButton(hwndDlg, IDC_CLASSICDATES, clsdates); - CheckDlgButton(hwndDlg, IDC_DATESUBFOLDER, dtsubfldr); - } - break; - - case WM_COMMAND: - if ((HIWORD(wParam) == EN_CHANGE || HIWORD(wParam) == BN_CLICKED) && (HWND)lParam == GetFocus()) - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - break; - - case WM_NOTIFY: - if (((LPNMHDR)lParam)->code == (unsigned)PSN_APPLY) - { - char szSetting[100]; - GetDlgItemTextA(hwndDlg, IDC_USERNAME, szSetting, SIZEOF(szSetting)); - DBWriteContactSettingString(NULL, PluginName, "Username", szSetting); - - GetDlgItemTextA(hwndDlg, IDC_PASSWORD, szSetting, SIZEOF(szSetting)); - CallService(MS_DB_CRYPT_ENCODESTRING, SIZEOF(szSetting), (LPARAM)szSetting); - DBWriteContactSettingString(NULL, PluginName, "Password", szSetting); - - DBWriteContactSettingByte(NULL, PluginName, "UploadChanged", - (BYTE)IsDlgButtonChecked(hwndDlg, IDC_UPLOADCHN)); - - clsdates = IsDlgButtonChecked(hwndDlg, IDC_CLASSICDATES) == BST_CHECKED; - if (clsdates) - DBWriteContactSettingByte(NULL, PluginName, "ClassicDates", 1); - else - DBDeleteContactSetting(NULL, PluginName, "ClassicDates"); - dtsubfldr = IsDlgButtonChecked(hwndDlg, IDC_DATESUBFOLDER) == BST_CHECKED; - if (dtsubfldr) - DBWriteContactSettingByte(NULL, PluginName, "SubFolders", 1); - else - DBDeleteContactSetting(NULL, PluginName, "SubFolders"); - } - break; - } - return FALSE; -} - - -LRESULT CALLBACK DlgProcPopup(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - switch (msg) - { - case WM_CONTEXTMENU: - PUDeletePopUp(hWnd); - break; - - case WM_COMMAND: - switch ((int)PUGetPluginData(hWnd)) - { - case 0: - OpenAuthUrl("http://www.miranda-vi.org/"); - break; - - case 1: - OpenAuthUrl("http://%s.miranda-vi.org/global"); - break; - - case 3: - TCHAR path[MAX_PATH]; - crs_sntprintf(path, MAX_PATH, TEXT("%s\\VersionInfo.txt"), VersionInfoFolder); - ShellExecute(NULL, TEXT("open"), path, NULL, NULL, SW_SHOW); - break; - - } - PUDeletePopUp(hWnd); - break; - - case UM_FREEPLUGINDATA: - ReleaseIconEx("versionInfo"); - break; - } - - return DefWindowProc(hWnd, msg, wParam, lParam); -} - -void ShowMessage(int type, const TCHAR* format, ...) -{ - POPUPDATAT pi = {0}; - - va_list va; - va_start(va, format); - int len = _vsntprintf(pi.lptzText, SIZEOF(pi.lptzText)-1, format, va); - pi.lptzText[len] = 0; - va_end(va); - - if (ServiceExists(MS_POPUP_ADDPOPUPT)) - { - _tcscpy(pi.lptzContactName, TEXT(PluginName)); - pi.lchIcon = LoadIconEx("versionInfo"); - pi.PluginWindowProc = DlgProcPopup; - pi.PluginData = (void*)type; - - PUAddPopUpT(&pi); - } - else - MessageBox(NULL, pi.lptzText, TEXT(PluginName), MB_OK | MB_ICONINFORMATION); -} diff --git a/plugins/Svc_crshdmp/upload.cpp b/plugins/Svc_crshdmp/upload.cpp deleted file mode 100644 index 498b5cb2f6..0000000000 --- a/plugins/Svc_crshdmp/upload.cpp +++ /dev/null @@ -1,292 +0,0 @@ -/* -Miranda Crash Dumper Plugin -Copyright (C) 2008 - 2012 Boris Krasnovskiy All Rights Reserved - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation version 2 -of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ - -#include "utils.h" -#include - -HANDLE hNetlibUser; - -static void arrayToHex(BYTE* data, size_t datasz, char* res) -{ - char* resptr = res; - for (unsigned i=0; i> 4); - *resptr++ = (char)((ch0 <= 9) ? ('0' + ch0) : (('a' - 10) + ch0)); - - const char ch1 = (char)(ch & 0xF); - *resptr++ = (char)((ch1 <= 9) ? ('0' + ch1) : (('a' - 10) + ch1)); - } - *resptr = '\0'; -} - -void GetLoginStr(char* user, size_t szuser, char* pass) -{ - DBVARIANT dbv; - - if (DBGetContactSettingString(NULL, PluginName, "Username", &dbv) == 0) - { - mir_snprintf(user, szuser, "%s", dbv.pszVal); - DBFreeVariant(&dbv); - } - else - user[0] = 0; - - if (DBGetContactSettingString(NULL, PluginName, "Password", &dbv) == 0) - { - CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal)+1, (LPARAM)dbv.pszVal); - - mir_md5_byte_t hash[16]; - mir_md5_state_t context; - - mir_md5_init(&context); - mir_md5_append(&context, (BYTE*)dbv.pszVal, (int)strlen(dbv.pszVal)); - mir_md5_finish(&context, hash); - - arrayToHex(hash, sizeof(hash), pass); - - DBFreeVariant(&dbv); - } - else - pass[0] = 0; -} - -void OpenAuthUrl(const char* url) -{ - char user[64], pass[40]; - GetLoginStr(user, sizeof(user), pass); - - if (user[0] && pass[0]) - { - char str[256]; - - mir_snprintf(str, sizeof(str), url, user); - char* eurl = (char*)CallService(MS_NETLIB_URLENCODE, 0, (LPARAM)str); - - mir_snprintf(str, sizeof(str), "http://www.miranda-vi.org/cdlogin?name=%s&pass=%s&redir=%s", user, pass, eurl); - CallService(MS_UTILS_OPENURL, 1, (LPARAM)str); - HeapFree(GetProcessHeap(), 0, eurl); - } - else - CallService(MS_UTILS_OPENURL, 1, (LPARAM)"http://www.miranda-vi.org/"); -} - -void CreateAuthString(char* auth) -{ - char user[64], pass[40]; - GetLoginStr(user, sizeof(user), pass); - - char str[110]; - int len = mir_snprintf(str, sizeof(str), "%s:%s", user, pass); - - strcpy(auth, "Basic "); - NETLIBBASE64 nlb = { auth+6, 250, (PBYTE)str, len }; - CallService(MS_NETLIB_BASE64ENCODE, 0, LPARAM(&nlb)); -} - - -bool InternetDownloadFile(const char *szUrl, VerTrnsfr* szReq) -{ - int result = 0xBADBAD; - char* szRedirUrl = NULL; - NETLIBHTTPREQUEST nlhr = {0}; - - // initialize the netlib request - nlhr.cbSize = sizeof(nlhr); - nlhr.requestType = REQUEST_POST; - nlhr.flags = NLHRF_HTTP11 | NLHRF_NODUMP; - nlhr.szUrl = (char*)szUrl; - - nlhr.headersCount = 6; - nlhr.headers=(NETLIBHTTPHEADER*)mir_alloc(sizeof(NETLIBHTTPHEADER)*nlhr.headersCount); - nlhr.headers[0].szName = "Connection"; - nlhr.headers[0].szValue = "close"; - nlhr.headers[1].szName = "Cache-Control"; - nlhr.headers[1].szValue = "no-cache"; - nlhr.headers[2].szName = "Pragma"; - nlhr.headers[2].szValue = "no-cache"; - nlhr.headers[3].szName = "Content-Type"; - nlhr.headers[3].szValue = "text/plain; charset=utf-8"; - nlhr.headers[4].szName = "AutoUpload"; - nlhr.headers[4].szValue = (char*)(szReq->autot ? "1" : "0"); - nlhr.headers[5].szName = "Authorization"; - - char auth[256]; - CreateAuthString(auth); - nlhr.headers[5].szValue = auth; - - nlhr.pData = szReq->buf; - nlhr.dataLength = (int)strlen(szReq->buf); - - while (result == 0xBADBAD) - { - // download the page - NETLIBHTTPREQUEST *nlhrReply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, - (WPARAM)hNetlibUser,(LPARAM)&nlhr); - - if (nlhrReply) - { - int i; - - // if the recieved code is 200 OK - switch(nlhrReply->resultCode) - { - case 200: - if (DBGetContactSettingByte(NULL, PluginName, "UploadChanged", 0)) - ProcessVIHash(true); - - for (i=nlhrReply->headersCount; i--; ) - { - if (_stricmp(nlhrReply->headers[i].szName, "OldPlugins") == 0) - { - i = atoi(nlhrReply->headers[i].szValue); - break; - } - } - - ShowMessage(1, TranslateT("VersionInfo upload successful,\n %d old plugins"), i); - result = 0; - break; - - case 401: - ShowMessage(0, TranslateT("Cannot upload VersionInfo. Incorrect username or password")); - result = 1; - break; - - case 510: - ShowMessage(0, TranslateT("Cannot upload VersionInfo. User is banned")); - result = 1; - break; - - case 511: - ShowMessage(0, TranslateT("Cannot upload VersionInfo. Daily upload limit exceeded")); - result = 1; - break; - - case 301: - case 302: - case 307: - // get the url for the new location and save it to szInfo - // look for the reply header "Location" - for (i=0; iheadersCount; i++) - { - if (!strcmp(nlhrReply->headers[i].szName, "Location")) - { - size_t rlen = 0; - if (nlhrReply->headers[i].szValue[0] == '/') - { - const char* szPath; - const char* szPref = strstr(szUrl, "://"); - szPref = szPref ? szPref + 3 : szUrl; - szPath = strchr(szPref, '/'); - rlen = szPath != NULL ? szPath - szUrl : strlen(szUrl); - } - - szRedirUrl = (char*)mir_realloc(szRedirUrl, - rlen + strlen(nlhrReply->headers[i].szValue)*3 + 1); - - strncpy(szRedirUrl, szUrl, rlen); - strcpy(szRedirUrl+rlen, nlhrReply->headers[i].szValue); - - nlhr.szUrl = szRedirUrl; - break; - } - } - break; - - default: - result = 1; - ShowMessage(0, TranslateT("Cannot upload VersionInfo. Unknown error")); - } - } - else - { - result = 1; - ShowMessage(0, TranslateT("Cannot upload VersionInfo. Host unreachable.")); - } - - CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,(LPARAM)nlhrReply); - } - - mir_free(szRedirUrl); - mir_free(nlhr.headers); - - return result == 0; -} - -void __cdecl VersionInfoUploadThread(void* arg) -{ - VerTrnsfr* trn = (VerTrnsfr*)arg; - InternetDownloadFile("http://www.miranda-vi.org/uploadpost", trn); - mir_free(trn->buf); - mir_free(trn); -} - - -void UploadInit(void) -{ - NETLIBUSER nlu = {0}; - nlu.cbSize = sizeof(nlu); - nlu.flags = NUF_OUTGOING | NUF_HTTPCONNS | NUF_NOHTTPSOPTION | NUF_TCHAR; - nlu.szSettingsModule = (char*)PluginName; - nlu.ptszDescriptiveName = TranslateT("Crash Dumper HTTP connections"); - hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu); -} - -void UploadClose(void) -{ - Netlib_CloseHandle(hNetlibUser); -} - -bool ProcessVIHash(bool store) -{ - bkstring buffer; - buffer.reserve(0x1800); - PrintVersionInfo(buffer, 0); - - mir_md5_byte_t hash[16]; - mir_md5_state_t context; - - mir_md5_init(&context); - mir_md5_append(&context, (PBYTE)buffer.c_str(), (int)buffer.sizebytes()); - mir_md5_finish(&context, hash); - - char hashstr[40]; - arrayToHex(hash, sizeof(hash), hashstr); - - bool result; - if (store) - { - DBWriteContactSettingString(NULL, PluginName, "VIHash", hashstr); - result = true; - } - else - { - DBVARIANT dbv; - if (DBGetContactSettingString(NULL, PluginName, "VIHash", &dbv) == 0) - { - result = strcmp(hashstr, dbv.pszVal) == 0; - DBFreeVariant(&dbv); - } - else - result = false; - } - return result; -} diff --git a/plugins/Svc_crshdmp/utils.cpp b/plugins/Svc_crshdmp/utils.cpp deleted file mode 100644 index d4dced7d70..0000000000 --- a/plugins/Svc_crshdmp/utils.cpp +++ /dev/null @@ -1,836 +0,0 @@ -/* -Miranda Crash Dumper Plugin -Copyright (C) 2008 - 2012 Boris Krasnovskiy All Rights Reserved - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation version 2 -of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ - -#include "utils.h" -#include - -static HMODULE hKernel = GetModuleHandle(TEXT("kernel32.dll")); - -tGetNativeSystemInfo pGetNativeSystemInfo = (tGetNativeSystemInfo)GetProcAddress(hKernel, "GetNativeSystemInfo"); -tGetProductInfo pGetProductInfo = (tGetProductInfo) GetProcAddress(hKernel, "GetProductInfo"); -tGlobalMemoryStatusEx pGlobalMemoryStatusEx = (tGlobalMemoryStatusEx) GetProcAddress(hKernel, "GlobalMemoryStatusEx"); -tGetUserDefaultUILanguage pGetUserDefaultUILanguage = (tGetUserDefaultUILanguage) GetProcAddress(hKernel, "GetUserDefaultUILanguage"); -tGetSystemDefaultUILanguage pGetSystemDefaultUILanguage = (tGetSystemDefaultUILanguage) GetProcAddress(hKernel, "GetSystemDefaultUILanguage"); -tIsWow64Process pIsWow64Process = (tIsWow64Process) GetProcAddress(hKernel, "IsWow64Process"); -tIsProcessorFeaturePresent pIsProcessorFeaturePresent = (tIsProcessorFeaturePresent) GetProcAddress(hKernel, "IsProcessorFeaturePresent"); - - -tGetDiskFreeSpaceEx pGetDiskFreeSpaceEx = (tGetDiskFreeSpaceEx) GetProcAddress(hKernel, "GetDiskFreeSpaceExW"); - - - -void CheckForOtherCrashReportingPlugins(void) -{ - HMODULE hModule = GetModuleHandle(TEXT("attache.dll")); - if (hModule == NULL) - hModule = GetModuleHandle(TEXT("crashrpt.dll")); - if (hModule == NULL) - hModule = GetModuleHandle(TEXT("crashdmp.dll")); - - if (hModule == NULL) return; - - MessageBox(NULL, TranslateT("More then one crash reporting plugin installed. This will result in inability of creating crash reports"), - TEXT("Miranda Crash Dumper"), MB_OK | MB_ICONERROR | MB_TASKMODAL | MB_TOPMOST); -} - -void GetOSDisplayString(bkstring& buffer) -{ - OSVERSIONINFOEX osvi = {0}; - SYSTEM_INFO si = {0}; - BOOL bOsVersionInfoEx; - DWORD dwType = 0; - - osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); - - bOsVersionInfoEx = GetVersionEx((OSVERSIONINFO*)&osvi); - if (!bOsVersionInfoEx) - { - osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - if (!GetVersionEx((OSVERSIONINFO*)&osvi)) - return; - } - - // Call GetNativeSystemInfo if supported or GetSystemInfo otherwise. - pGetNativeSystemInfo = (tGetNativeSystemInfo)GetProcAddress(hKernel, "GetNativeSystemInfo"); - if (NULL != pGetNativeSystemInfo) pGetNativeSystemInfo(&si); - else GetSystemInfo(&si); - - if (VER_PLATFORM_WIN32_NT == osvi.dwPlatformId && osvi.dwMajorVersion > 4) - { - buffer.append(TEXT("Operating System: Microsoft ")); - - // Test for the specific product. - if (osvi.dwMajorVersion == 6) - { - switch (osvi.dwMinorVersion) - { - case 0: - if (osvi.wProductType == VER_NT_WORKSTATION) - buffer.append(TEXT("Windows Vista ")); - else - buffer.append(TEXT("Windows Server 2008 ")); - break; - - case 1: - if (osvi.wProductType == VER_NT_WORKSTATION) - buffer.append(TEXT("Windows 7 ")); - else - buffer.append(TEXT("Windows Server 2008 R2 ")); - break; - - default: - if (osvi.wProductType == VER_NT_WORKSTATION) - buffer.append(TEXT("Windows 8 ")); - else - buffer.append(TEXT("Windows Server 2012 ")); - break; - } - - pGetProductInfo = (tGetProductInfo) GetProcAddress(hKernel, "GetProductInfo"); - if (pGetProductInfo != NULL) pGetProductInfo(6, 0, 0, 0, &dwType); - - switch(dwType) - { - case PRODUCT_ULTIMATE: - buffer.append(TEXT("Ultimate Edition")); - break; - case PRODUCT_HOME_PREMIUM: - buffer.append(TEXT("Home Premium Edition")); - break; - case PRODUCT_HOME_BASIC: - buffer.append(TEXT("Home Basic Edition")); - break; - case PRODUCT_ENTERPRISE: - buffer.append(TEXT("Enterprise Edition")); - break; - case PRODUCT_BUSINESS: - buffer.append(TEXT("Business Edition")); - break; - case PRODUCT_STARTER: - buffer.append(TEXT("Starter Edition")); - break; - case PRODUCT_CLUSTER_SERVER: - buffer.append(TEXT("Cluster Server Edition")); - break; - case PRODUCT_DATACENTER_SERVER: - buffer.append(TEXT("Datacenter Edition")); - break; - case PRODUCT_DATACENTER_SERVER_CORE: - buffer.append(TEXT("Datacenter Edition (core installation)")); - break; - case PRODUCT_ENTERPRISE_SERVER: - buffer.append(TEXT("Enterprise Edition")); - break; - case PRODUCT_ENTERPRISE_SERVER_CORE: - buffer.append(TEXT("Enterprise Edition (core installation)")); - break; - case PRODUCT_ENTERPRISE_SERVER_IA64: - buffer.append(TEXT("Enterprise Edition for Itanium-based Systems")); - break; - case PRODUCT_SMALLBUSINESS_SERVER: - buffer.append(TEXT("Small Business Server")); - break; - case PRODUCT_SMALLBUSINESS_SERVER_PREMIUM: - buffer.append(TEXT("Small Business Server Premium Edition")); - break; - case PRODUCT_STANDARD_SERVER: - buffer.append(TEXT("Standard Edition")); - break; - case PRODUCT_STANDARD_SERVER_CORE: - buffer.append(TEXT("Standard Edition (core installation)")); - break; - case PRODUCT_WEB_SERVER: - buffer.append(TEXT("Web Server Edition")); - break; - } - - if (si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64) - buffer.append(TEXT(", 64-bit")); - else if (si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_INTEL) - buffer.append(TEXT(", 32-bit")); - } - - if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2) - { - if (GetSystemMetrics(SM_SERVERR2)) - buffer.append(TEXT("Windows Server 2003 R2, ")); - else if (osvi.wSuiteMask==VER_SUITE_STORAGE_SERVER) - buffer.append(TEXT("Windows Storage Server 2003")); - else if (osvi.wProductType == VER_NT_WORKSTATION && - si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) - buffer.append(TEXT("Windows XP Professional x64 Edition")); - else buffer.append(TEXT("Windows Server 2003, ")); - - // Test for the server type. - if (osvi.wProductType != VER_NT_WORKSTATION) - { - if (si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_IA64) - { - if(osvi.wSuiteMask & VER_SUITE_DATACENTER) - buffer.append(TEXT("Datacenter Edition for Itanium-based Systems")); - else if(osvi.wSuiteMask & VER_SUITE_ENTERPRISE) - buffer.append(TEXT("Enterprise Edition for Itanium-based Systems")); - } - - else if (si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64) - { - if(osvi.wSuiteMask & VER_SUITE_DATACENTER) - buffer.append(TEXT("Datacenter x64 Edition")); - else if(osvi.wSuiteMask & VER_SUITE_ENTERPRISE) - buffer.append(TEXT("Enterprise x64 Edition")); - else buffer.append(TEXT("Standard x64 Edition")); - } - - else - { - if (osvi.wSuiteMask & VER_SUITE_COMPUTE_SERVER) - buffer.append(TEXT("Compute Cluster Edition")); - else if(osvi.wSuiteMask & VER_SUITE_DATACENTER) - buffer.append(TEXT("Datacenter Edition")); - else if(osvi.wSuiteMask & VER_SUITE_ENTERPRISE) - buffer.append(TEXT("Enterprise Edition")); - else if (osvi.wSuiteMask & VER_SUITE_BLADE) - buffer.append(TEXT("Web Edition")); - else buffer.append(TEXT("Standard Edition")); - } - } - } - - if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1) - { - buffer.append(TEXT("Windows XP ")); - if (osvi.wSuiteMask & VER_SUITE_PERSONAL) - buffer.append(TEXT("Home Edition")); - else - buffer.append(TEXT("Professional")); - } - - if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0) - { - buffer.append(TEXT("Windows 2000 ")); - - if (osvi.wProductType == VER_NT_WORKSTATION) - { - buffer.append(TEXT("Professional")); - } - else - { - if(osvi.wSuiteMask & VER_SUITE_DATACENTER) - buffer.append(TEXT("Datacenter Server")); - else if(osvi.wSuiteMask & VER_SUITE_ENTERPRISE) - buffer.append(TEXT("Advanced Server")); - else buffer.append(TEXT("Server")); - } - } - if (_tcslen(osvi.szCSDVersion) > 0) - { - buffer.append(TEXT(" ")); - buffer.append(osvi.szCSDVersion); - } - - buffer.appendfmt(TEXT(" (build %d)"), osvi.dwBuildNumber); - } - else - { - if (VER_PLATFORM_WIN32_NT == osvi.dwPlatformId) - { - buffer.append(TEXT("Microsoft Windows NT ")); - if (osvi.wProductType == VER_NT_WORKSTATION) - buffer.append(TEXT("Workstation 4.0 ")); - else if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE) - buffer.append(TEXT("Server 4.0, Enterprise Edition ")); - else - buffer.append(TEXT("Server 4.0 ")); - } - - if (osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS && osvi.dwMajorVersion == 4) - { - if (osvi.dwMinorVersion == 0) - { - buffer.append(TEXT("Microsoft Windows 95 ")); - if (osvi.szCSDVersion[1]==TEXT('C') || osvi.szCSDVersion[1]==TEXT('B')) - buffer.append(TEXT("OSR2 ")); - } - - if (osvi.dwMinorVersion == 10) - { - buffer.append(TEXT("Microsoft Windows 98 ")); - if (osvi.szCSDVersion[1]==TEXT('A') || osvi.szCSDVersion[1]==TEXT('B')) - buffer.append(TEXT("SE ")); - } - - if (osvi.dwMinorVersion == 90) - { - buffer.append(TEXT("Microsoft Windows Millennium Edition")); - } - buffer.appendfmt(TEXT("(build %d)"), LOWORD(osvi.dwBuildNumber)); - } - else if (osvi.dwPlatformId == VER_PLATFORM_WIN32s) - { - buffer.append(TEXT("Microsoft Win32s")); - } - } -} - -int GetTZOffset(void) -{ - TIME_ZONE_INFORMATION tzInfo = {0}; - DWORD type = GetTimeZoneInformation(&tzInfo); - - int offset = 0; - switch (type) - { - case TIME_ZONE_ID_DAYLIGHT: - offset = -(tzInfo.Bias + tzInfo.DaylightBias); - break; - - case TIME_ZONE_ID_STANDARD: - offset = -(tzInfo.Bias + tzInfo.StandardBias); - break; - - case TIME_ZONE_ID_UNKNOWN: - offset = -tzInfo.Bias; - break; - } - return offset; -} - -void GetISO8061Time(SYSTEMTIME* stLocal, LPTSTR lpszString, DWORD dwSize) -{ - SYSTEMTIME loctime; - if (stLocal == NULL) - { - stLocal = &loctime; - GetLocalTime(stLocal); - } - - if (clsdates) - { - GetDateFormat(LOCALE_INVARIANT, 0, stLocal, TEXT("d MMM yyyy"), lpszString, dwSize); - int dlen = (int)_tcslen(lpszString); - GetTimeFormat(LOCALE_INVARIANT, 0, stLocal, TEXT(" H:mm:ss"), lpszString+dlen, dwSize-dlen); - } - else - { - int offset = GetTZOffset(); - - // Build a string showing the date and time. - crs_sntprintf(lpszString, dwSize, TEXT("%d-%02d-%02d %02d:%02d:%02d%+03d%02d"), - stLocal->wYear, stLocal->wMonth, stLocal->wDay, - stLocal->wHour, stLocal->wMinute, stLocal->wSecond, - offset / 60, offset % 60); - } -} - -void GetLastWriteTime(FILETIME* ftime, LPTSTR lpszString, DWORD dwSize) -{ - FILETIME ftLocal; - SYSTEMTIME stLocal; - - // Convert the last-write time to local time. - FileTimeToLocalFileTime(ftime, &ftLocal); - FileTimeToSystemTime(&ftLocal, &stLocal); - - GetISO8061Time(&stLocal, lpszString, dwSize); -} - -void GetLastWriteTime(LPCTSTR fileName, LPTSTR lpszString, DWORD dwSize) -{ - WIN32_FIND_DATA FindFileData; - - HANDLE hFind = FindFirstFile(fileName, &FindFileData); - if (hFind == INVALID_HANDLE_VALUE) return; - FindClose(hFind); - - GetLastWriteTime(&FindFileData.ftLastWriteTime, lpszString, dwSize); -} - -typedef PLUGININFOEX * (__cdecl * Miranda_Plugin_Info) (DWORD mirandaVersion); - -PLUGININFOEX* GetMirInfo(HMODULE hModule) -{ - Miranda_Plugin_Info bpi = (Miranda_Plugin_Info)GetProcAddress(hModule, "MirandaPluginInfoEx"); - if (bpi == NULL) - return NULL; - - return bpi(mirandaVersion); -} - - -void GetInternetExplorerVersion(bkstring& buffer) -{ - HKEY hKey; - DWORD size; - - TCHAR ieVersion[1024] = {0}; - TCHAR ieBuild[512] = {0}; - TCHAR iVer[64] = {0}; - - if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Microsoft\\Internet Explorer"), 0, - KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) - { - size = sizeof(ieBuild)/sizeof(ieBuild[0]); - if (RegQueryValueEx(hKey, TEXT("Build"), NULL, NULL, (LPBYTE) ieBuild, &size) != ERROR_SUCCESS) - ieBuild[0] = 0; - - size = sizeof(ieVersion)/sizeof(ieVersion[0]); - if (RegQueryValueEx(hKey, TEXT("Version"), NULL, NULL, (LPBYTE) ieVersion, &size) != ERROR_SUCCESS) - ieVersion[0] = 0; - - size = sizeof(iVer)/sizeof(iVer[0]); - if (RegQueryValueEx(hKey, TEXT("IVer"), NULL, NULL, (LPBYTE) iVer, &size) != ERROR_SUCCESS) - iVer[0] = 0; - - RegCloseKey(hKey); - } - - buffer.append(TEXT("Internet Explorer: ")); - if (ieVersion[0] == 0) - { - if (iVer[0] == 0) - buffer.append(TEXT("")); - else if (_tcscmp(iVer, TEXT("100")) == 0) - buffer.append(TEXT("1.0")); - else if (_tcscmp(iVer, TEXT("101")) == 0) - buffer.append(TEXT("NT")); - else if (_tcscmp(iVer, TEXT("102")) == 0) - buffer.append(TEXT("2.0")); - else if (_tcscmp(iVer, TEXT("103")) == 0) - buffer.append(TEXT("3.0")); - } - else - { - buffer.append(ieVersion); - } - if (ieBuild[0] != 0) - { - buffer.appendfmt(TEXT(" (build %s)"), ieBuild); - } -} - - -void TrimMultiSpaces(TCHAR* str) -{ - TCHAR *src = str, *dest = str; - bool trimst = false; - - for (;;) - { - if (*src == TEXT(' ')) - { - if (!trimst) - { - trimst = true; - *dest++ = *src; - } - } - else - { - trimst = false; - *dest++ = *src; - } - if (*src++ == 0) break; - } -} - -void GetProcessorString(bkstring& buffer) -{ - HKEY hKey; - DWORD size; - - TCHAR cpuIdent[512] = {0}; - TCHAR cpuName[512] = {0}; - - if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("Hardware\\Description\\System\\CentralProcessor\\0"), 0, - KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) - { - size = sizeof(cpuName)/sizeof(cpuName[0]); - if (RegQueryValueEx(hKey, TEXT("ProcessorNameString"), NULL, NULL, (LPBYTE) cpuName, &size) != ERROR_SUCCESS) - _tcscpy(cpuName, TEXT("Unknown")); - - size = sizeof(cpuIdent)/sizeof(cpuIdent[0]); - if (RegQueryValueEx(hKey, TEXT("Identifier"), NULL, NULL, (LPBYTE) cpuIdent, &size) != ERROR_SUCCESS) - if (RegQueryValueEx(hKey, TEXT("VendorIdentifier"), NULL, NULL, (LPBYTE) cpuIdent, &size) != ERROR_SUCCESS) - _tcscpy(cpuIdent, TEXT("Unknown")); - - RegCloseKey(hKey); - } - TrimMultiSpaces(cpuName); - buffer.appendfmt(TEXT("CPU: %s [%s]"), cpuName, cpuIdent); - - if (pIsProcessorFeaturePresent && pIsProcessorFeaturePresent(PF_NX_ENABLED)) - buffer.append(TEXT(" [DEP Enabled]")); - - SYSTEM_INFO si = {0}; - GetSystemInfo(&si); - - if (si.dwNumberOfProcessors > 1) - buffer.appendfmt(TEXT(" [%u CPUs]"), si.dwNumberOfProcessors); -} - -void GetFreeMemoryString(bkstring& buffer) -{ - unsigned ram; - if (pGlobalMemoryStatusEx) - { - MEMORYSTATUSEX ms = {0}; - ms.dwLength = sizeof(ms); - pGlobalMemoryStatusEx(&ms); - ram = (unsigned int) ((ms.ullTotalPhys / (1024 * 1024)) + 1); - } - else - { - MEMORYSTATUS ms = {0}; - ZeroMemory(&ms, sizeof(ms)); - ms.dwLength = sizeof(ms); - GlobalMemoryStatus(&ms); - ram = (unsigned int)(ms.dwTotalPhys/(1024*1024))+1; - } - buffer.appendfmt(TEXT("Installed RAM: %u MBytes"), ram); -} - -void GetFreeDiskString(LPCTSTR dirname, bkstring& buffer) -{ - ULARGE_INTEGER tnb, tfb, fs = {0}; - if (pGetDiskFreeSpaceEx) - pGetDiskFreeSpaceEx(dirname, &fs, &tnb, &tfb); - else - { - DWORD SectorsPerCluster, BytesPerSector; - DWORD NumberOfFreeClusters, TotalNumberOfClusters; - - GetDiskFreeSpace(dirname, &SectorsPerCluster, &BytesPerSector, - &NumberOfFreeClusters, &TotalNumberOfClusters); - - fs.QuadPart = BytesPerSector * SectorsPerCluster; - fs.QuadPart *= NumberOfFreeClusters; - } - fs.QuadPart /= (1024*1024); - - buffer.appendfmt(TEXT("Free disk space on Miranda partition: %u MBytes"), fs.LowPart); -} - -void ReadableExceptionInfo(PEXCEPTION_RECORD excrec, bkstring& buffer) -{ - buffer.append(TEXT("Exception: ")); - - switch (excrec->ExceptionCode) - { - case EXCEPTION_BREAKPOINT: - buffer.append(TEXT("User Defined Breakpoint")); - break; - - case EXCEPTION_ACCESS_VIOLATION: - buffer.append(TEXT("Access Violation")); - break; - - case EXCEPTION_ARRAY_BOUNDS_EXCEEDED: - buffer.append(TEXT("Array Bounds Exceeded")); - break; - - case EXCEPTION_DATATYPE_MISALIGNMENT: - buffer.append(TEXT("Datatype Misalignment")); - break; - - case EXCEPTION_FLT_DENORMAL_OPERAND: - buffer.append(TEXT("Floating Point denormlized operand")); - break; - - case EXCEPTION_FLT_DIVIDE_BY_ZERO: - buffer.append(TEXT("Floating Point divide by 0")); - break; - - case EXCEPTION_FLT_INEXACT_RESULT: - buffer.append(TEXT("Floating Point inexact result")); - break; - - case EXCEPTION_FLT_INVALID_OPERATION: - buffer.append(TEXT("Floating Point invalid operation")); - break; - - case EXCEPTION_FLT_OVERFLOW: - buffer.append(TEXT("Floating Point overflow")); - break; - - case EXCEPTION_FLT_STACK_CHECK: - buffer.append(TEXT("Floating Point stack overflow/underflow")); - break; - - case EXCEPTION_FLT_UNDERFLOW: - buffer.append(TEXT("Floating Point underflow")); - break; - - case EXCEPTION_ILLEGAL_INSTRUCTION: - buffer.append(TEXT("Invalid instruction executed")); - break; - - case EXCEPTION_IN_PAGE_ERROR: - buffer.append(TEXT("Access to the not present page")); - break; - - case EXCEPTION_INT_DIVIDE_BY_ZERO: - buffer.append(TEXT("Integer divide by zero")); - break; - - case EXCEPTION_INT_OVERFLOW: - buffer.append(TEXT("Integer overflow")); - break; - - case EXCEPTION_PRIV_INSTRUCTION: - buffer.append(TEXT("Priveleged instruction executed")); - break; - - case EXCEPTION_STACK_OVERFLOW: - buffer.append(TEXT("Stack overflow")); - break; - - case 0xe06d7363: - buffer.append(TEXT("Unhandled C++ software exception")); - break; - - default: - buffer.appendfmt(TEXT("%x"), excrec->ExceptionCode); - break; - } - - buffer.appendfmt(TEXT(" at address %p."), excrec->ExceptionAddress); - - if (excrec->ExceptionCode == EXCEPTION_ACCESS_VIOLATION || - excrec->ExceptionCode == EXCEPTION_IN_PAGE_ERROR) - { - switch(excrec->ExceptionInformation[0]) - { - case 0: - buffer.appendfmt(TEXT(" Reading from address %p."), (LPVOID)excrec->ExceptionInformation[1]); - break; - - case 1: - buffer.appendfmt(TEXT(" Writing to address %p."), (LPVOID)excrec->ExceptionInformation[1]); - break; - - case 8: - buffer.appendfmt(TEXT(" DEP at address %p."), (LPVOID)excrec->ExceptionInformation[1]); - break; - } - } -} - -void GetAdminString(bkstring& buffer) -{ - BOOL b; - __try - { - SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY; - PSID AdministratorsGroup; - - b = AllocateAndInitializeSid(&NtAuthority, 2, SECURITY_BUILTIN_DOMAIN_RID, - DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &AdministratorsGroup); - if (b) - { - if (!CheckTokenMembership(NULL, AdministratorsGroup, &b)) - b = FALSE; - FreeSid(AdministratorsGroup); - } - else - b = GetLastError() == ERROR_CALL_NOT_IMPLEMENTED; - } - __except(EXCEPTION_EXECUTE_HANDLER) - { - b = TRUE; - } - - buffer.appendfmt(TEXT("Administrator privileges: %s"), b ? TEXT("Yes") : TEXT ("No")); -} - -void GetLanguageString(bkstring& buffer) -{ - TCHAR name1[256], name2[256], name3[256], name4[256]; - - GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SENGLANGUAGE, name1, 256); - GetLocaleInfo(LOCALE_SYSTEM_DEFAULT, LOCALE_SENGLANGUAGE, name2, 256); - - if (pGetUserDefaultUILanguage && pGetSystemDefaultUILanguage) - { - GetLocaleInfo(MAKELCID(pGetUserDefaultUILanguage(), SORT_DEFAULT), LOCALE_SENGLANGUAGE, name3, 256); - GetLocaleInfo(MAKELCID(pGetSystemDefaultUILanguage(), SORT_DEFAULT), LOCALE_SENGLANGUAGE, name4, 256); - } - else - { - _tcscpy(name3, name1); - _tcscpy(name4, name2); - } - - buffer.appendfmt(TEXT("OS Languages: (UI | Locale (User/System)) : %s/%s | %s/%s"), name3, name4, name1, name2); -} - -void GetLanguagePackString(bkstring& buffer) -{ - buffer.append(TEXT("Language pack: ")); - if (packlcid == LOCALE_USER_DEFAULT) - buffer.append(TEXT("No language pack installed")); - else - { - TCHAR path[MAX_PATH] = TEXT("Locale id invalid"); - GetLocaleInfo(packlcid, LOCALE_SENGLANGUAGE, path, MAX_PATH); - buffer.append(path); - - GetLocaleInfo(packlcid, LOCALE_SISO3166CTRYNAME, path, MAX_PATH); - buffer.appendfmt(TEXT(" (%s) [%04x]"), path, packlcid); - - GetModuleFileName(NULL, path, MAX_PATH); - - LPTSTR fname = _tcsrchr(path, TEXT('\\')); - if (fname == NULL) fname = path; - crs_sntprintf(fname, MAX_PATH-(fname-path), TEXT("\\langpack_*.txt")); - - WIN32_FIND_DATA FindFileData; - HANDLE hFind = FindFirstFile(path, &FindFileData); - if (hFind == INVALID_HANDLE_VALUE) return; - FindClose(hFind); - - crs_sntprintf(fname, MAX_PATH-(fname-path), TEXT("\\%s"), FindFileData.cFileName); - HANDLE hDumpFile = CreateFile(path, GENERIC_READ, FILE_SHARE_READ, NULL, - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - - if (hDumpFile != INVALID_HANDLE_VALUE) - { - char buf[8192]; - - DWORD bytes = 0; - ReadFile(hDumpFile, buf, 8190, &bytes, NULL); - buf[bytes] = 0; - - char *id = strstr(buf, "FLID:"); - if (id != NULL) - { - char *endid = strchr(id, '\r'); - if (endid != NULL) *endid = 0; - - endid = strchr(id, '\n'); - if (endid != NULL) *endid = 0; - - TCHAR mirtime[30]; - GetLastWriteTime(path, mirtime, 30); - - TCHAR* tid; - crsi_a2t(tid, id+5); - buffer.appendfmt(TEXT(", %s, modified: %s"), tid, mirtime); - } - CloseHandle(hDumpFile); - } - } -} - -void GetWow64String(bkstring& buffer) -{ - BOOL wow64 = 0; - if (pIsWow64Process) - { - if (!pIsWow64Process(GetCurrentProcess(), &wow64)) - { - wow64 = 0; - } - } - if (wow64) buffer.append(TEXT(" [running inside WOW64]")); -} - - -bool CreateDirectoryTree(LPTSTR szDir) -{ - DWORD dwAttr = GetFileAttributes(szDir); - if (dwAttr != INVALID_FILE_ATTRIBUTES && (dwAttr & FILE_ATTRIBUTE_DIRECTORY)) - return true; - - TCHAR* pszSlash = _tcsrchr(szDir, TEXT('\\')); - if (pszSlash == NULL) - return false; - - *pszSlash = 0; - bool res = CreateDirectoryTree(szDir); - *pszSlash = TEXT('\\'); - - if (res) res = CreateDirectory(szDir, NULL) != 0; - - return res; -} - -int crs_sntprintf(TCHAR *buffer, size_t count, const TCHAR* fmt, ...) -{ - va_list va; - va_start(va, fmt); - - int len = _vsntprintf(buffer, count-1, fmt, va); - buffer[len] = 0; - - va_end(va); - return len; -} - -void GetVersionInfo(HMODULE hLib, bkstring& buffer) -{ - HRSRC hVersion = FindResource(hLib, MAKEINTRESOURCE(VS_VERSION_INFO), RT_VERSION); - if (hVersion != NULL) - { - HGLOBAL hGlobal = LoadResource(hLib, hVersion); - if (hGlobal != NULL) - { - LPVOID versionInfo = LockResource(hGlobal); - if (versionInfo != NULL) - { - int vl = *(unsigned short*)versionInfo; - unsigned *res = (unsigned*)versionInfo; - while (*res != 0xfeef04bd && ((char*)res - (char*)versionInfo) < vl) ++res; - - if (((char*)res - (char*)versionInfo) < vl) - { - VS_FIXEDFILEINFO *vsInfo = (VS_FIXEDFILEINFO*)res; - buffer.appendfmt(TEXT(" v.%u.%u.%u.%u"), - HIWORD(vsInfo->dwFileVersionMS), LOWORD(vsInfo->dwFileVersionMS), - HIWORD(vsInfo->dwFileVersionLS), LOWORD(vsInfo->dwFileVersionLS)); - } - } - FreeResource(hGlobal); - } - } -} - -void StoreStringToClip(bkstring& buffer) -{ - HANDLE hData = GlobalAlloc(GMEM_MOVEABLE, buffer.sizebytes() + sizeof(TCHAR)); - LPSTR buf = (LPSTR)GlobalLock(hData); - - memcpy(buf, buffer.c_str(), buffer.sizebytes() + sizeof(TCHAR)); - - GlobalUnlock(hData); - - OpenClipboard(NULL); - EmptyClipboard(); - - - SetClipboardData(CF_UNICODETEXT, hData); - -} - -bool IsPluginEnabled(TCHAR* filename) -{ - char* fname; - crsi_t2a(fname, filename); - char* ext = strstr(_strlwr(fname), ".dll"); - bool res = ext && ext[4] == '\0' && DBGetContactSettingByte(NULL, "PluginDisable", fname, 0) == 0; - return res; -} diff --git a/plugins/Svc_crshdmp/utils.h b/plugins/Svc_crshdmp/utils.h deleted file mode 100644 index 9089f57571..0000000000 --- a/plugins/Svc_crshdmp/utils.h +++ /dev/null @@ -1,177 +0,0 @@ -/* -Miranda Crash Dumper Plugin -Copyright (C) 2008 - 2012 Boris Krasnovskiy All Rights Reserved - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation version 2 -of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ - -#define _CRT_SECURE_NO_WARNINGS -#define MIRANDA_VER 0x0A00 - -#include -#include "sdkstuff.h" - -#ifdef _MSC_VER -#include -#endif - -#include - -#include "resource.h" - -#include - -#ifdef _MSC_VER - -#pragma warning( push ) -#pragma warning( disable : 4201 4100 ) -#include -#pragma warning( pop ) - -#else - -#include - -#endif - -#ifdef __GNUC__ -#endif - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "bkstring.h" - -#define MS_PROTO_ENUMPROTOS "Proto/EnumProtos" - -int crs_sntprintf(TCHAR *buffer, size_t count, const TCHAR* fmt, ...); - -#define crsi_u2a(dst, src) \ -{ \ - int cbLen = WideCharToMultiByte(CP_ACP, 0, src, -1, NULL, 0, NULL, NULL); \ - dst = (char*)alloca(cbLen+1); \ - WideCharToMultiByte(CP_ACP, 0, src, -1, dst, cbLen, NULL, NULL); \ -} - -#define crsi_a2u(dst, src, alloc) \ -{ \ - int cbLen = MultiByteToWideChar(CP_ACP, 0, src, -1, NULL, 0); \ - dst = (wchar_t*)alloc(sizeof(wchar_t) * (cbLen+1)); \ - MultiByteToWideChar(CP_ACP, 0, src, -1, dst, cbLen); \ -} - - - -#define crsi_t2a(d,s) crsi_u2a(d,s) -#define crsi_a2t(d,s) crsi_a2u(d,s,alloca) -#define crs_a2t(d,s) crsi_a2u(d,s,mir_alloc) - - - -#define SIZEOF(X) (sizeof(X)/sizeof(X[0])) - -#define MS_CRASHDUMPER_STORETOFILE "CrashDmp/StoreVerInfoToFile" -#define MS_CRASHDUMPER_STORETOCLIP "CrashDmp/StoreVerInfoToClip" -#define MS_CRASHDUMPER_GETINFO "Versioninfo/GetInfo" -#define MS_CRASHDUMPER_VIEWINFO "CrashDmp/ViewInfo" -#define MS_CRASHDUMPER_UPLOAD "CrashDmp/UploadInfo" -#define MS_CRASHDUMPER_URL "CrashDmp/StartUrl" - -#define PluginName "Crash Dumper" - -#define VI_FLAG_FORMAT 1 -#define VI_FLAG_PRNVAR 2 -#define VI_FLAG_PRNDLL 4 -#define VI_FLAG_WEATHER 8 - -struct VerTrnsfr -{ - char* buf; - bool autot; -}; - -extern HMODULE hInst; -extern DWORD mirandaVersion; -extern LCID packlcid; -extern bool servicemode; -extern bool clsdates; -extern bool dtsubfldr; - -extern TCHAR CrashLogFolder[MAX_PATH]; -extern TCHAR VersionInfoFolder[MAX_PATH]; - -void WriteBBFile(bkstring& buffer, bool hdr); -void WriteUtfFile(HANDLE hDumpFile, char* bufu); -void UnloadDbgHlp(void); - -LONG WINAPI myfilter(PEXCEPTION_POINTERS exc_ptr); -LONG WINAPI myfilterv(PEXCEPTION_POINTERS exc_ptr); -DWORD MirandaThreadFilter(DWORD code, EXCEPTION_POINTERS* info); - -void GetOSDisplayString(bkstring& buffer); -void GetInternetExplorerVersion(bkstring& buffer); -void GetProcessorString(bkstring& buffer); -void GetFreeMemoryString(bkstring& buffer); -void GetFreeDiskString(LPCTSTR dirname, bkstring& buffer); -void GetAdminString(bkstring& buffer); -void GetLanguageString(bkstring& buffer); -void GetLanguagePackString(bkstring& buffer); -void GetWow64String(bkstring& buffer); -void GetVersionInfo(HMODULE hLib, bkstring& buffer); - -void GetISO8061Time(SYSTEMTIME* stLocal, LPTSTR lpszString, DWORD dwSize); - -void ReadableExceptionInfo(PEXCEPTION_RECORD excrec, bkstring& buffer); - -void GetLastWriteTime(LPCTSTR fileName, LPTSTR lpszString, DWORD dwSize); -void GetLastWriteTime(FILETIME* ftime, LPTSTR lpszString, DWORD dwSize); -bool CreateDirectoryTree(LPTSTR szDir); -void StoreStringToClip(bkstring& buffer); -void ShowMessage(int type, const TCHAR* format, ...); -bool IsPluginEnabled(TCHAR* filename); - -PLUGININFOEX* GetMirInfo(HMODULE hModule); -const PLUGININFOEX* GetPluginInfoEx(void); - -void CreateMiniDump (HANDLE hDumpFile, PEXCEPTION_POINTERS exc_ptr); -void CreateCrashReport(HANDLE hDumpFile, PEXCEPTION_POINTERS exc_ptr, const TCHAR* msg); -void PrintVersionInfo(bkstring& buffer, unsigned flags = VI_FLAG_PRNVAR); -bool ProcessVIHash(bool store); - -void InitExceptionHandler(void); -void DestroyExceptionHandler(void); -void SetExceptionHandler(void); -void RemoveExceptionHandler(void); -void CheckForOtherCrashReportingPlugins(void); - -INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); -INT_PTR CALLBACK DlgProcView(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); -void DestroyAllWindows(void); - -void UploadInit(void); -void UploadClose(void); -void OpenAuthUrl(const char* url); -void __cdecl VersionInfoUploadThread(void* arg); - -void InitIcons(void); -HICON LoadIconEx(const char* name, bool big = false); -HANDLE GetIconHandle(const char* name); -void ReleaseIconEx(const char* name); -void ReleaseIconEx(HICON hIcon); diff --git a/plugins/Svc_crshdmp/vc6/dbghelp.h b/plugins/Svc_crshdmp/vc6/dbghelp.h deleted file mode 100644 index d8a713060b..0000000000 --- a/plugins/Svc_crshdmp/vc6/dbghelp.h +++ /dev/null @@ -1,4532 +0,0 @@ -/*++ BUILD Version: 0000 Increment this if a change has global effects - -Copyright (c) Microsoft Corporation. All rights reserved. - -Module Name: - - dbghelp.h - -Abstract: - - This module defines the prototypes and constants required for the image - help routines. - - Contains debugging support routines that are redistributable. - -Revision History: - ---*/ - -#ifndef _DBGHELP_ -#define _DBGHELP_ - -#if _MSC_VER > 1020 -#pragma once -#endif - - -// As a general principal always call the 64 bit version -// of every API, if a choice exists. The 64 bit version -// works great on 32 bit platforms, and is forward -// compatible to 64 bit platforms. - -#ifdef _WIN64 -#ifndef _IMAGEHLP64 -#define _IMAGEHLP64 -#endif -#endif - -// For those without specstrings.h -// Since there are different versions of this header, I need to -// individually test each item and define it if it is not around. - -#ifndef __in - #define __in -#endif -#ifndef __out - #define __out -#endif -#ifndef __inout - #define __inout -#endif -#ifndef __in_opt - #define __in_opt -#endif -#ifndef __out_opt - #define __out_opt -#endif -#ifndef __inout_opt - #define __inout_opt -#endif -#ifndef __in_ecount - #define __in_ecount(x) -#endif -#ifndef __out_ecount - #define __out_ecount(x) -#endif -#ifndef __inout_ecount - #define __inout_ecount(x) -#endif -#ifndef __in_bcount - #define __in_bcount(x) -#endif -#ifndef __out_bcount - #define __out_bcount(x) -#endif -#ifndef __inout_bcount - #define __inout_bcount(x) -#endif -#ifndef __out_xcount - #define __out_xcount(x) -#endif -#ifndef __deref_opt_out - #define __deref_opt_out -#endif -#ifndef __deref_out - #define __deref_out -#endif -#ifndef __out_ecount_opt - #define __out_ecount_opt(x) -#endif - - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef _IMAGEHLP_SOURCE_ - #define IMAGEAPI __stdcall - #define DBHLP_DEPRECIATED -#else - #define IMAGEAPI DECLSPEC_IMPORT __stdcall - #if (_MSC_VER >= 1300) && !defined(MIDL_PASS) - #define DBHLP_DEPRECIATED __declspec(deprecated) - #else - #define DBHLP_DEPRECIATED - #endif -#endif - -#define DBHLPAPI IMAGEAPI - -#define IMAGE_SEPARATION (64*1024) - -// Observant readers may notice that 2 new fields, -// 'fReadOnly' and 'Version' have been added to -// the LOADED_IMAGE structure after 'fDOSImage'. -// This does not change the size of the structure -// from previous headers. That is because while -// 'fDOSImage' is a byte, it is padded by the -// compiler to 4 bytes. So the 2 new fields are -// slipped into the extra space. - -typedef struct _LOADED_IMAGE { - PSTR ModuleName; - HANDLE hFile; - PUCHAR MappedAddress; -#ifdef _IMAGEHLP64 - PIMAGE_NT_HEADERS64 FileHeader; -#else - PIMAGE_NT_HEADERS32 FileHeader; -#endif - PIMAGE_SECTION_HEADER LastRvaSection; - ULONG NumberOfSections; - PIMAGE_SECTION_HEADER Sections; - ULONG Characteristics; - BOOLEAN fSystemImage; - BOOLEAN fDOSImage; - BOOLEAN fReadOnly; - UCHAR Version; - LIST_ENTRY Links; - ULONG SizeOfImage; -} LOADED_IMAGE, *PLOADED_IMAGE; - -#define MAX_SYM_NAME 2000 - - -// Error codes set by dbghelp functions. Call GetLastError -// to see them. -// Dbghelp also sets error codes found in winerror.h - -#define ERROR_IMAGE_NOT_STRIPPED 0x8800 // the image is not stripped. No dbg file available. -#define ERROR_NO_DBG_POINTER 0x8801 // image is stripped but there is no pointer to a dbg file -#define ERROR_NO_PDB_POINTER 0x8802 // image does not point to a pdb file - -typedef BOOL -(CALLBACK *PFIND_DEBUG_FILE_CALLBACK)( - __in HANDLE FileHandle, - __in PCSTR FileName, - __in PVOID CallerData - ); - -HANDLE -IMAGEAPI -SymFindDebugInfoFile( - __in HANDLE hProcess, - __in PCSTR FileName, - __out_ecount(MAX_PATH + 1) PSTR DebugFilePath, - __in_opt PFIND_DEBUG_FILE_CALLBACK Callback, - __in_opt PVOID CallerData - ); - -typedef BOOL -(CALLBACK *PFIND_DEBUG_FILE_CALLBACKW)( - __in HANDLE FileHandle, - __in PCWSTR FileName, - __in PVOID CallerData - ); - -HANDLE -IMAGEAPI -SymFindDebugInfoFileW( - __in HANDLE hProcess, - __in PCWSTR FileName, - __out_ecount(MAX_PATH + 1) PWSTR DebugFilePath, - __in_opt PFIND_DEBUG_FILE_CALLBACKW Callback, - __in_opt PVOID CallerData - ); - -HANDLE -IMAGEAPI -FindDebugInfoFile ( - __in PCSTR FileName, - __in PCSTR SymbolPath, - __out_ecount(MAX_PATH + 1) PSTR DebugFilePath - ); - -HANDLE -IMAGEAPI -FindDebugInfoFileEx ( - __in PCSTR FileName, - __in PCSTR SymbolPath, - __out_ecount(MAX_PATH + 1) PSTR DebugFilePath, - __in_opt PFIND_DEBUG_FILE_CALLBACK Callback, - __in_opt PVOID CallerData - ); - -HANDLE -IMAGEAPI -FindDebugInfoFileExW ( - __in PCWSTR FileName, - __in PCWSTR SymbolPath, - __out_ecount(MAX_PATH + 1) PWSTR DebugFilePath, - __in_opt PFIND_DEBUG_FILE_CALLBACKW Callback, - __in_opt PVOID CallerData - ); - -typedef BOOL -(CALLBACK *PFINDFILEINPATHCALLBACK)( - PCSTR filename, - PVOID context - ); - -BOOL -IMAGEAPI -SymFindFileInPath( - __in HANDLE hprocess, - __in_opt PCSTR SearchPath, - __in PCSTR FileName, - __in_opt PVOID id, - __in DWORD two, - __in DWORD three, - __in DWORD flags, - __out_ecount(MAX_PATH + 1) PSTR FoundFile, - __in_opt PFINDFILEINPATHCALLBACK callback, - __in_opt PVOID context - ); - -typedef BOOL -(CALLBACK *PFINDFILEINPATHCALLBACKW)( - __in PCWSTR filename, - __in PVOID context - ); - -BOOL -IMAGEAPI -SymFindFileInPathW( - __in HANDLE hprocess, - __in_opt PCWSTR SearchPath, - __in PCWSTR FileName, - __in_opt PVOID id, - __in DWORD two, - __in DWORD three, - __in DWORD flags, - __out_ecount(MAX_PATH + 1) PWSTR FoundFile, - __in_opt PFINDFILEINPATHCALLBACKW callback, - __in_opt PVOID context - ); - -typedef BOOL -(CALLBACK *PFIND_EXE_FILE_CALLBACK)( - __in HANDLE FileHandle, - __in PCSTR FileName, - __in_opt PVOID CallerData - ); - -HANDLE -IMAGEAPI -SymFindExecutableImage( - __in HANDLE hProcess, - __in PCSTR FileName, - __out_ecount(MAX_PATH + 1) PSTR ImageFilePath, - __in PFIND_EXE_FILE_CALLBACK Callback, - __in PVOID CallerData - ); - -typedef BOOL -(CALLBACK *PFIND_EXE_FILE_CALLBACKW)( - __in HANDLE FileHandle, - __in PCWSTR FileName, - __in_opt PVOID CallerData - ); - -HANDLE -IMAGEAPI -SymFindExecutableImageW( - __in HANDLE hProcess, - __in PCWSTR FileName, - __out_ecount(MAX_PATH + 1) PWSTR ImageFilePath, - __in PFIND_EXE_FILE_CALLBACKW Callback, - __in PVOID CallerData - ); - -HANDLE -IMAGEAPI -FindExecutableImage( - __in PCSTR FileName, - __in PCSTR SymbolPath, - __out_ecount(MAX_PATH + 1) PSTR ImageFilePath - ); - -HANDLE -IMAGEAPI -FindExecutableImageEx( - __in PCSTR FileName, - __in PCSTR SymbolPath, - __out_ecount(MAX_PATH + 1) PSTR ImageFilePath, - __in_opt PFIND_EXE_FILE_CALLBACK Callback, - __in_opt PVOID CallerData - ); - -HANDLE -IMAGEAPI -FindExecutableImageExW( - __in PCWSTR FileName, - __in PCWSTR SymbolPath, - __out_ecount(MAX_PATH + 1) PWSTR ImageFilePath, - __in_opt PFIND_EXE_FILE_CALLBACKW Callback, - __in PVOID CallerData - ); - -PIMAGE_NT_HEADERS -IMAGEAPI -ImageNtHeader ( - __in PVOID Base - ); - -PVOID -IMAGEAPI -ImageDirectoryEntryToDataEx ( - __in PVOID Base, - __in BOOLEAN MappedAsImage, - __in USHORT DirectoryEntry, - __out PULONG Size, - __out_opt PIMAGE_SECTION_HEADER *FoundHeader - ); - -PVOID -IMAGEAPI -ImageDirectoryEntryToData ( - __in PVOID Base, - __in BOOLEAN MappedAsImage, - __in USHORT DirectoryEntry, - __out PULONG Size - ); - -PIMAGE_SECTION_HEADER -IMAGEAPI -ImageRvaToSection( - __in PIMAGE_NT_HEADERS NtHeaders, - __in PVOID Base, - __in ULONG Rva - ); - -PVOID -IMAGEAPI -ImageRvaToVa( - __in PIMAGE_NT_HEADERS NtHeaders, - __in PVOID Base, - __in ULONG Rva, - __in_opt OUT PIMAGE_SECTION_HEADER *LastRvaSection - ); - -#ifndef _WIN64 -// This api won't be ported to Win64 - Fix your code. - -typedef struct _IMAGE_DEBUG_INFORMATION { - LIST_ENTRY List; - DWORD ReservedSize; - PVOID ReservedMappedBase; - USHORT ReservedMachine; - USHORT ReservedCharacteristics; - DWORD ReservedCheckSum; - DWORD ImageBase; - DWORD SizeOfImage; - - DWORD ReservedNumberOfSections; - PIMAGE_SECTION_HEADER ReservedSections; - - DWORD ReservedExportedNamesSize; - PSTR ReservedExportedNames; - - DWORD ReservedNumberOfFunctionTableEntries; - PIMAGE_FUNCTION_ENTRY ReservedFunctionTableEntries; - DWORD ReservedLowestFunctionStartingAddress; - DWORD ReservedHighestFunctionEndingAddress; - - DWORD ReservedNumberOfFpoTableEntries; - PFPO_DATA ReservedFpoTableEntries; - - DWORD SizeOfCoffSymbols; - PIMAGE_COFF_SYMBOLS_HEADER CoffSymbols; - - DWORD ReservedSizeOfCodeViewSymbols; - PVOID ReservedCodeViewSymbols; - - PSTR ImageFilePath; - PSTR ImageFileName; - PSTR ReservedDebugFilePath; - - DWORD ReservedTimeDateStamp; - - BOOL ReservedRomImage; - PIMAGE_DEBUG_DIRECTORY ReservedDebugDirectory; - DWORD ReservedNumberOfDebugDirectories; - - DWORD ReservedOriginalFunctionTableBaseAddress; - - DWORD Reserved[ 2 ]; - -} IMAGE_DEBUG_INFORMATION, *PIMAGE_DEBUG_INFORMATION; - - -PIMAGE_DEBUG_INFORMATION -IMAGEAPI -MapDebugInformation( - __in_opt HANDLE FileHandle, - __in PCSTR FileName, - __in_opt PCSTR SymbolPath, - __in ULONG ImageBase - ); - -BOOL -IMAGEAPI -UnmapDebugInformation( - __out_xcount(unknown) PIMAGE_DEBUG_INFORMATION DebugInfo - ); - -#endif - -BOOL -IMAGEAPI -SearchTreeForFile( - __in PCSTR RootPath, - __in PCSTR InputPathName, - __out_ecount(MAX_PATH + 1) PSTR OutputPathBuffer - ); - -BOOL -IMAGEAPI -SearchTreeForFileW( - __in PCWSTR RootPath, - __in PCWSTR InputPathName, - __out_ecount(MAX_PATH + 1) PWSTR OutputPathBuffer - ); - -typedef BOOL -(CALLBACK *PENUMDIRTREE_CALLBACK)( - __in PCSTR FilePath, - __in_opt PVOID CallerData - ); - -BOOL -IMAGEAPI -EnumDirTree( - __in_opt HANDLE hProcess, - __in PCSTR RootPath, - __in PCSTR InputPathName, - __out_ecount_opt(MAX_PATH + 1) PSTR OutputPathBuffer, - __in_opt PENUMDIRTREE_CALLBACK cb, - __in_opt PVOID data - ); - -typedef BOOL -(CALLBACK *PENUMDIRTREE_CALLBACKW)( - __in PCWSTR FilePath, - __in_opt PVOID CallerData - ); - -BOOL -IMAGEAPI -EnumDirTreeW( - __in_opt HANDLE hProcess, - __in PCWSTR RootPath, - __in PCWSTR InputPathName, - __out_ecount_opt(MAX_PATH + 1) PWSTR OutputPathBuffer, - __in_opt PENUMDIRTREE_CALLBACKW cb, - __in_opt PVOID data - ); - -BOOL -IMAGEAPI -MakeSureDirectoryPathExists( - __in PCSTR DirPath - ); - -// -// UnDecorateSymbolName Flags -// - -#define UNDNAME_COMPLETE (0x0000) // Enable full undecoration -#define UNDNAME_NO_LEADING_UNDERSCORES (0x0001) // Remove leading underscores from MS extended keywords -#define UNDNAME_NO_MS_KEYWORDS (0x0002) // Disable expansion of MS extended keywords -#define UNDNAME_NO_FUNCTION_RETURNS (0x0004) // Disable expansion of return type for primary declaration -#define UNDNAME_NO_ALLOCATION_MODEL (0x0008) // Disable expansion of the declaration model -#define UNDNAME_NO_ALLOCATION_LANGUAGE (0x0010) // Disable expansion of the declaration language specifier -#define UNDNAME_NO_MS_THISTYPE (0x0020) // NYI Disable expansion of MS keywords on the 'this' type for primary declaration -#define UNDNAME_NO_CV_THISTYPE (0x0040) // NYI Disable expansion of CV modifiers on the 'this' type for primary declaration -#define UNDNAME_NO_THISTYPE (0x0060) // Disable all modifiers on the 'this' type -#define UNDNAME_NO_ACCESS_SPECIFIERS (0x0080) // Disable expansion of access specifiers for members -#define UNDNAME_NO_THROW_SIGNATURES (0x0100) // Disable expansion of 'throw-signatures' for functions and pointers to functions -#define UNDNAME_NO_MEMBER_TYPE (0x0200) // Disable expansion of 'static' or 'virtual'ness of members -#define UNDNAME_NO_RETURN_UDT_MODEL (0x0400) // Disable expansion of MS model for UDT returns -#define UNDNAME_32_BIT_DECODE (0x0800) // Undecorate 32-bit decorated names -#define UNDNAME_NAME_ONLY (0x1000) // Crack only the name for primary declaration; - // return just [scope::]name. Does expand template params -#define UNDNAME_NO_ARGUMENTS (0x2000) // Don't undecorate arguments to function -#define UNDNAME_NO_SPECIAL_SYMS (0x4000) // Don't undecorate special names (v-table, vcall, vector xxx, metatype, etc) - -DWORD -IMAGEAPI -WINAPI -UnDecorateSymbolName( - __in PCSTR name, - __out_ecount(maxStringLength) PSTR outputString, - __in DWORD maxStringLength, - __in DWORD flags - ); - -DWORD -IMAGEAPI -WINAPI -UnDecorateSymbolNameW( - __in PCWSTR name, - __out_ecount(maxStringLength) PWSTR outputString, - __in DWORD maxStringLength, - __in DWORD flags - ); - -// -// these values are used for synthesized file types -// that can be passed in as image headers instead of -// the standard ones from ntimage.h -// - -#define DBHHEADER_DEBUGDIRS 0x1 -#define DBHHEADER_CVMISC 0x2 - -typedef struct _MODLOAD_DATA { - DWORD ssize; // size of this struct - DWORD ssig; // signature identifying the passed data - PVOID data; // pointer to passed data - DWORD size; // size of passed data - DWORD flags; // options -} MODLOAD_DATA, *PMODLOAD_DATA; - -typedef struct _MODLOAD_CVMISC { - DWORD oCV; // ofset to the codeview record - size_t cCV; // size of the codeview record - DWORD oMisc; // offset to the misc record - size_t cMisc; // size of the misc record - DWORD dtImage; // datetime stamp of the image - DWORD cImage; // size of the image -} MODLOAD_CVMISC, *PMODLOAD_CVMISC; - -// -// StackWalking API -// - -typedef enum { - AddrMode1616, - AddrMode1632, - AddrModeReal, - AddrModeFlat -} ADDRESS_MODE; - -typedef struct _tagADDRESS64 { - DWORD64 Offset; - WORD Segment; - ADDRESS_MODE Mode; -} ADDRESS64, *LPADDRESS64; - -#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) -#define ADDRESS ADDRESS64 -#define LPADDRESS LPADDRESS64 -#else -typedef struct _tagADDRESS { - DWORD Offset; - WORD Segment; - ADDRESS_MODE Mode; -} ADDRESS, *LPADDRESS; - -__inline -void -Address32To64( - __in LPADDRESS a32, - __out LPADDRESS64 a64 - ) -{ - a64->Offset = (ULONG64)(LONG64)(LONG)a32->Offset; - a64->Segment = a32->Segment; - a64->Mode = a32->Mode; -} - -__inline -void -Address64To32( - __in LPADDRESS64 a64, - __out LPADDRESS a32 - ) -{ - a32->Offset = (ULONG)a64->Offset; - a32->Segment = a64->Segment; - a32->Mode = a64->Mode; -} -#endif - -// -// This structure is included in the STACKFRAME structure, -// and is used to trace through usermode callbacks in a thread's -// kernel stack. The values must be copied by the kernel debugger -// from the DBGKD_GET_VERSION and WAIT_STATE_CHANGE packets. -// - -// -// New KDHELP structure for 64 bit system support. -// This structure is preferred in new code. -// -typedef struct _KDHELP64 { - - // - // address of kernel thread object, as provided in the - // WAIT_STATE_CHANGE packet. - // - DWORD64 Thread; - - // - // offset in thread object to pointer to the current callback frame - // in kernel stack. - // - DWORD ThCallbackStack; - - // - // offset in thread object to pointer to the current callback backing - // store frame in kernel stack. - // - DWORD ThCallbackBStore; - - // - // offsets to values in frame: - // - // address of next callback frame - DWORD NextCallback; - - // address of saved frame pointer (if applicable) - DWORD FramePointer; - - - // - // Address of the kernel function that calls out to user mode - // - DWORD64 KiCallUserMode; - - // - // Address of the user mode dispatcher function - // - DWORD64 KeUserCallbackDispatcher; - - // - // Lowest kernel mode address - // - DWORD64 SystemRangeStart; - - // - // Address of the user mode exception dispatcher function. - // Added in API version 10. - // - DWORD64 KiUserExceptionDispatcher; - - // - // Stack bounds, added in API version 11. - // - DWORD64 StackBase; - DWORD64 StackLimit; - - DWORD64 Reserved[5]; - -} KDHELP64, *PKDHELP64; - -#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) -#define KDHELP KDHELP64 -#define PKDHELP PKDHELP64 -#else -typedef struct _KDHELP { - - // - // address of kernel thread object, as provided in the - // WAIT_STATE_CHANGE packet. - // - DWORD Thread; - - // - // offset in thread object to pointer to the current callback frame - // in kernel stack. - // - DWORD ThCallbackStack; - - // - // offsets to values in frame: - // - // address of next callback frame - DWORD NextCallback; - - // address of saved frame pointer (if applicable) - DWORD FramePointer; - - // - // Address of the kernel function that calls out to user mode - // - DWORD KiCallUserMode; - - // - // Address of the user mode dispatcher function - // - DWORD KeUserCallbackDispatcher; - - // - // Lowest kernel mode address - // - DWORD SystemRangeStart; - - // - // offset in thread object to pointer to the current callback backing - // store frame in kernel stack. - // - DWORD ThCallbackBStore; - - // - // Address of the user mode exception dispatcher function. - // Added in API version 10. - // - DWORD KiUserExceptionDispatcher; - - // - // Stack bounds, added in API version 11. - // - DWORD StackBase; - DWORD StackLimit; - - DWORD Reserved[5]; - -} KDHELP, *PKDHELP; - -__inline -void -KdHelp32To64( - __in PKDHELP p32, - __out PKDHELP64 p64 - ) -{ - p64->Thread = p32->Thread; - p64->ThCallbackStack = p32->ThCallbackStack; - p64->NextCallback = p32->NextCallback; - p64->FramePointer = p32->FramePointer; - p64->KiCallUserMode = p32->KiCallUserMode; - p64->KeUserCallbackDispatcher = p32->KeUserCallbackDispatcher; - p64->SystemRangeStart = p32->SystemRangeStart; - p64->KiUserExceptionDispatcher = p32->KiUserExceptionDispatcher; - p64->StackBase = p32->StackBase; - p64->StackLimit = p32->StackLimit; -} -#endif - -typedef struct _tagSTACKFRAME64 { - ADDRESS64 AddrPC; // program counter - ADDRESS64 AddrReturn; // return address - ADDRESS64 AddrFrame; // frame pointer - ADDRESS64 AddrStack; // stack pointer - ADDRESS64 AddrBStore; // backing store pointer - PVOID FuncTableEntry; // pointer to pdata/fpo or NULL - DWORD64 Params[4]; // possible arguments to the function - BOOL Far; // WOW far call - BOOL Virtual; // is this a virtual frame? - DWORD64 Reserved[3]; - KDHELP64 KdHelp; -} STACKFRAME64, *LPSTACKFRAME64; - -#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) -#define STACKFRAME STACKFRAME64 -#define LPSTACKFRAME LPSTACKFRAME64 -#else -typedef struct _tagSTACKFRAME { - ADDRESS AddrPC; // program counter - ADDRESS AddrReturn; // return address - ADDRESS AddrFrame; // frame pointer - ADDRESS AddrStack; // stack pointer - PVOID FuncTableEntry; // pointer to pdata/fpo or NULL - DWORD Params[4]; // possible arguments to the function - BOOL Far; // WOW far call - BOOL Virtual; // is this a virtual frame? - DWORD Reserved[3]; - KDHELP KdHelp; - ADDRESS AddrBStore; // backing store pointer -} STACKFRAME, *LPSTACKFRAME; -#endif - - -typedef -BOOL -(__stdcall *PREAD_PROCESS_MEMORY_ROUTINE64)( - __in HANDLE hProcess, - __in DWORD64 qwBaseAddress, - __out_bcount(nSize) PVOID lpBuffer, - __in DWORD nSize, - __out LPDWORD lpNumberOfBytesRead - ); - -typedef -PVOID -(__stdcall *PFUNCTION_TABLE_ACCESS_ROUTINE64)( - __in HANDLE ahProcess, - __in DWORD64 AddrBase - ); - -typedef -DWORD64 -(__stdcall *PGET_MODULE_BASE_ROUTINE64)( - __in HANDLE hProcess, - __in DWORD64 Address - ); - -typedef -DWORD64 -(__stdcall *PTRANSLATE_ADDRESS_ROUTINE64)( - __in HANDLE hProcess, - __in HANDLE hThread, - __in LPADDRESS64 lpaddr - ); - -BOOL -IMAGEAPI -StackWalk64( - __in DWORD MachineType, - __in HANDLE hProcess, - __in HANDLE hThread, - __inout LPSTACKFRAME64 StackFrame, - __inout PVOID ContextRecord, - __in_opt PREAD_PROCESS_MEMORY_ROUTINE64 ReadMemoryRoutine, - __in_opt PFUNCTION_TABLE_ACCESS_ROUTINE64 FunctionTableAccessRoutine, - __in_opt PGET_MODULE_BASE_ROUTINE64 GetModuleBaseRoutine, - __in_opt PTRANSLATE_ADDRESS_ROUTINE64 TranslateAddress - ); - -#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) - -#define PREAD_PROCESS_MEMORY_ROUTINE PREAD_PROCESS_MEMORY_ROUTINE64 -#define PFUNCTION_TABLE_ACCESS_ROUTINE PFUNCTION_TABLE_ACCESS_ROUTINE64 -#define PGET_MODULE_BASE_ROUTINE PGET_MODULE_BASE_ROUTINE64 -#define PTRANSLATE_ADDRESS_ROUTINE PTRANSLATE_ADDRESS_ROUTINE64 - -#define StackWalk StackWalk64 - -#else - -typedef -BOOL -(__stdcall *PREAD_PROCESS_MEMORY_ROUTINE)( - __in HANDLE hProcess, - __in DWORD lpBaseAddress, - __out_bcount(nSize) PVOID lpBuffer, - __in DWORD nSize, - __out PDWORD lpNumberOfBytesRead - ); - -typedef -PVOID -(__stdcall *PFUNCTION_TABLE_ACCESS_ROUTINE)( - __in HANDLE hProcess, - __in DWORD AddrBase - ); - -typedef -DWORD -(__stdcall *PGET_MODULE_BASE_ROUTINE)( - __in HANDLE hProcess, - __in DWORD Address - ); - -typedef -DWORD -(__stdcall *PTRANSLATE_ADDRESS_ROUTINE)( - __in HANDLE hProcess, - __in HANDLE hThread, - __out LPADDRESS lpaddr - ); - -BOOL -IMAGEAPI -StackWalk( - DWORD MachineType, - __in HANDLE hProcess, - __in HANDLE hThread, - __inout LPSTACKFRAME StackFrame, - __inout PVOID ContextRecord, - __in_opt PREAD_PROCESS_MEMORY_ROUTINE ReadMemoryRoutine, - __in_opt PFUNCTION_TABLE_ACCESS_ROUTINE FunctionTableAccessRoutine, - __in_opt PGET_MODULE_BASE_ROUTINE GetModuleBaseRoutine, - __in_opt PTRANSLATE_ADDRESS_ROUTINE TranslateAddress - ); - -#endif - - -#define API_VERSION_NUMBER 11 - -typedef struct API_VERSION { - USHORT MajorVersion; - USHORT MinorVersion; - USHORT Revision; - USHORT Reserved; -} API_VERSION, *LPAPI_VERSION; - -LPAPI_VERSION -IMAGEAPI -ImagehlpApiVersion( - VOID - ); - -LPAPI_VERSION -IMAGEAPI -ImagehlpApiVersionEx( - __in LPAPI_VERSION AppVersion - ); - -DWORD -IMAGEAPI -GetTimestampForLoadedLibrary( - __in HMODULE Module - ); - -// -// typedefs for function pointers -// -typedef BOOL -(CALLBACK *PSYM_ENUMMODULES_CALLBACK64)( - __in PCSTR ModuleName, - __in DWORD64 BaseOfDll, - __in_opt PVOID UserContext - ); - -typedef BOOL -(CALLBACK *PSYM_ENUMMODULES_CALLBACKW64)( - __in PCWSTR ModuleName, - __in DWORD64 BaseOfDll, - __in_opt PVOID UserContext - ); - -typedef BOOL -(CALLBACK *PENUMLOADED_MODULES_CALLBACK64)( - __in PCSTR ModuleName, - __in DWORD64 ModuleBase, - __in ULONG ModuleSize, - __in_opt PVOID UserContext - ); - -typedef BOOL -(CALLBACK *PENUMLOADED_MODULES_CALLBACKW64)( - __in PCWSTR ModuleName, - __in DWORD64 ModuleBase, - __in ULONG ModuleSize, - __in_opt PVOID UserContext - ); - -typedef BOOL -(CALLBACK *PSYM_ENUMSYMBOLS_CALLBACK64)( - __in PCSTR SymbolName, - __in DWORD64 SymbolAddress, - __in ULONG SymbolSize, - __in_opt PVOID UserContext - ); - -typedef BOOL -(CALLBACK *PSYM_ENUMSYMBOLS_CALLBACK64W)( - __in PCWSTR SymbolName, - __in DWORD64 SymbolAddress, - __in ULONG SymbolSize, - __in_opt PVOID UserContext - ); - -typedef BOOL -(CALLBACK *PSYMBOL_REGISTERED_CALLBACK64)( - __in HANDLE hProcess, - __in ULONG ActionCode, - __in_opt ULONG64 CallbackData, - __in_opt ULONG64 UserContext - ); - -typedef -PVOID -(CALLBACK *PSYMBOL_FUNCENTRY_CALLBACK)( - __in HANDLE hProcess, - __in DWORD AddrBase, - __in_opt PVOID UserContext - ); - -typedef -PVOID -(CALLBACK *PSYMBOL_FUNCENTRY_CALLBACK64)( - __in HANDLE hProcess, - __in ULONG64 AddrBase, - __in ULONG64 UserContext - ); - -#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) - -#define PSYM_ENUMMODULES_CALLBACK PSYM_ENUMMODULES_CALLBACK64 -#define PSYM_ENUMSYMBOLS_CALLBACK PSYM_ENUMSYMBOLS_CALLBACK64 -#define PSYM_ENUMSYMBOLS_CALLBACKW PSYM_ENUMSYMBOLS_CALLBACK64W -#define PENUMLOADED_MODULES_CALLBACK PENUMLOADED_MODULES_CALLBACK64 -#define PSYMBOL_REGISTERED_CALLBACK PSYMBOL_REGISTERED_CALLBACK64 -#define PSYMBOL_FUNCENTRY_CALLBACK PSYMBOL_FUNCENTRY_CALLBACK64 - -#else - -typedef BOOL -(CALLBACK *PSYM_ENUMMODULES_CALLBACK)( - __in PCSTR ModuleName, - __in ULONG BaseOfDll, - __in_opt PVOID UserContext - ); - -typedef BOOL -(CALLBACK *PSYM_ENUMSYMBOLS_CALLBACK)( - __in PCSTR SymbolName, - __in ULONG SymbolAddress, - __in ULONG SymbolSize, - __in_opt PVOID UserContext - ); - -typedef BOOL -(CALLBACK *PSYM_ENUMSYMBOLS_CALLBACKW)( - __in PCWSTR SymbolName, - __in ULONG SymbolAddress, - __in ULONG SymbolSize, - __in_opt PVOID UserContext - ); - -typedef BOOL -(CALLBACK *PENUMLOADED_MODULES_CALLBACK)( - __in PCSTR ModuleName, - __in ULONG ModuleBase, - __in ULONG ModuleSize, - __in_opt PVOID UserContext - ); - -typedef BOOL -(CALLBACK *PSYMBOL_REGISTERED_CALLBACK)( - __in HANDLE hProcess, - __in ULONG ActionCode, - __in_opt PVOID CallbackData, - __in_opt PVOID UserContext - ); - -#endif - - -// values found in SYMBOL_INFO.Tag -// -// This was taken from cvconst.h and should -// not override any values found there. -// -// #define _NO_CVCONST_H_ if you don't -// have access to that file... - -#ifdef _NO_CVCONST_H - -// DIA enums - -enum SymTagEnum -{ - SymTagNull, - SymTagExe, - SymTagCompiland, - SymTagCompilandDetails, - SymTagCompilandEnv, - SymTagFunction, - SymTagBlock, - SymTagData, - SymTagAnnotation, - SymTagLabel, - SymTagPublicSymbol, - SymTagUDT, - SymTagEnum, - SymTagFunctionType, - SymTagPointerType, - SymTagArrayType, - SymTagBaseType, - SymTagTypedef, - SymTagBaseClass, - SymTagFriend, - SymTagFunctionArgType, - SymTagFuncDebugStart, - SymTagFuncDebugEnd, - SymTagUsingNamespace, - SymTagVTableShape, - SymTagVTable, - SymTagCustom, - SymTagThunk, - SymTagCustomType, - SymTagManagedType, - SymTagDimension, - SymTagMax -}; - -#endif - -// -// flags found in SYMBOL_INFO.Flags -// - -#define SYMFLAG_VALUEPRESENT 0x00000001 -#define SYMFLAG_REGISTER 0x00000008 -#define SYMFLAG_REGREL 0x00000010 -#define SYMFLAG_FRAMEREL 0x00000020 -#define SYMFLAG_PARAMETER 0x00000040 -#define SYMFLAG_LOCAL 0x00000080 -#define SYMFLAG_CONSTANT 0x00000100 -#define SYMFLAG_EXPORT 0x00000200 -#define SYMFLAG_FORWARDER 0x00000400 -#define SYMFLAG_FUNCTION 0x00000800 -#define SYMFLAG_VIRTUAL 0x00001000 -#define SYMFLAG_THUNK 0x00002000 -#define SYMFLAG_TLSREL 0x00004000 -#define SYMFLAG_SLOT 0x00008000 -#define SYMFLAG_ILREL 0x00010000 -#define SYMFLAG_METADATA 0x00020000 -#define SYMFLAG_CLR_TOKEN 0x00040000 - -// this resets SymNext/Prev to the beginning -// of the module passed in the address field - -#define SYMFLAG_RESET 0x80000000 - -// -// symbol type enumeration -// -typedef enum { - SymNone = 0, - SymCoff, - SymCv, - SymPdb, - SymExport, - SymDeferred, - SymSym, // .sym file - SymDia, - SymVirtual, - NumSymTypes -} SYM_TYPE; - -// -// symbol data structure -// - -typedef struct _IMAGEHLP_SYMBOL64 { - DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_SYMBOL64) - DWORD64 Address; // virtual address including dll base address - DWORD Size; // estimated size of symbol, can be zero - DWORD Flags; // info about the symbols, see the SYMF defines - DWORD MaxNameLength; // maximum size of symbol name in 'Name' - CHAR Name[1]; // symbol name (null terminated string) -} IMAGEHLP_SYMBOL64, *PIMAGEHLP_SYMBOL64; - -typedef struct _IMAGEHLP_SYMBOL64_PACKAGE { - IMAGEHLP_SYMBOL64 sym; - CHAR name[MAX_SYM_NAME + 1]; -} IMAGEHLP_SYMBOL64_PACKAGE, *PIMAGEHLP_SYMBOL64_PACKAGE; - -typedef struct _IMAGEHLP_SYMBOLW64 { - DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_SYMBOLW64) - DWORD64 Address; // virtual address including dll base address - DWORD Size; // estimated size of symbol, can be zero - DWORD Flags; // info about the symbols, see the SYMF defines - DWORD MaxNameLength; // maximum size of symbol name in 'Name' - WCHAR Name[1]; // symbol name (null terminated string) -} IMAGEHLP_SYMBOLW64, *PIMAGEHLP_SYMBOLW64; - -typedef struct _IMAGEHLP_SYMBOLW64_PACKAGE { - IMAGEHLP_SYMBOLW64 sym; - WCHAR name[MAX_SYM_NAME + 1]; -} IMAGEHLP_SYMBOLW64_PACKAGE, *PIMAGEHLP_SYMBOLW64_PACKAGE; - -#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) - - #define IMAGEHLP_SYMBOL IMAGEHLP_SYMBOL64 - #define PIMAGEHLP_SYMBOL PIMAGEHLP_SYMBOL64 - #define IMAGEHLP_SYMBOL_PACKAGE IMAGEHLP_SYMBOL64_PACKAGE - #define PIMAGEHLP_SYMBOL_PACKAGE PIMAGEHLP_SYMBOL64_PACKAGE - #define IMAGEHLP_SYMBOLW IMAGEHLP_SYMBOLW64 - #define PIMAGEHLP_SYMBOLW PIMAGEHLP_SYMBOLW64 - #define IMAGEHLP_SYMBOLW_PACKAGE IMAGEHLP_SYMBOLW64_PACKAGE - #define PIMAGEHLP_SYMBOLW_PACKAGE PIMAGEHLP_SYMBOLW64_PACKAGE - -#else - - typedef struct _IMAGEHLP_SYMBOL { - DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_SYMBOL) - DWORD Address; // virtual address including dll base address - DWORD Size; // estimated size of symbol, can be zero - DWORD Flags; // info about the symbols, see the SYMF defines - DWORD MaxNameLength; // maximum size of symbol name in 'Name' - CHAR Name[1]; // symbol name (null terminated string) - } IMAGEHLP_SYMBOL, *PIMAGEHLP_SYMBOL; - - typedef struct _IMAGEHLP_SYMBOL_PACKAGE { - IMAGEHLP_SYMBOL sym; - CHAR name[MAX_SYM_NAME + 1]; - } IMAGEHLP_SYMBOL_PACKAGE, *PIMAGEHLP_SYMBOL_PACKAGE; - - typedef struct _IMAGEHLP_SYMBOLW { - DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_SYMBOLW) - DWORD Address; // virtual address including dll base address - DWORD Size; // estimated size of symbol, can be zero - DWORD Flags; // info about the symbols, see the SYMF defines - DWORD MaxNameLength; // maximum size of symbol name in 'Name' - WCHAR Name[1]; // symbol name (null terminated string) - } IMAGEHLP_SYMBOLW, *PIMAGEHLP_SYMBOLW; - - typedef struct _IMAGEHLP_SYMBOLW_PACKAGE { - IMAGEHLP_SYMBOLW sym; - WCHAR name[MAX_SYM_NAME + 1]; - } IMAGEHLP_SYMBOLW_PACKAGE, *PIMAGEHLP_SYMBOLW_PACKAGE; - -#endif - -// -// module data structure -// - -typedef struct _IMAGEHLP_MODULE64 { - DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_MODULE64) - DWORD64 BaseOfImage; // base load address of module - DWORD ImageSize; // virtual size of the loaded module - DWORD TimeDateStamp; // date/time stamp from pe header - DWORD CheckSum; // checksum from the pe header - DWORD NumSyms; // number of symbols in the symbol table - SYM_TYPE SymType; // type of symbols loaded - CHAR ModuleName[32]; // module name - CHAR ImageName[256]; // image name - CHAR LoadedImageName[256]; // symbol file name - // new elements: 07-Jun-2002 - CHAR LoadedPdbName[256]; // pdb file name - DWORD CVSig; // Signature of the CV record in the debug directories - CHAR CVData[MAX_PATH * 3]; // Contents of the CV record - DWORD PdbSig; // Signature of PDB - GUID PdbSig70; // Signature of PDB (VC 7 and up) - DWORD PdbAge; // DBI age of pdb - BOOL PdbUnmatched; // loaded an unmatched pdb - BOOL DbgUnmatched; // loaded an unmatched dbg - BOOL LineNumbers; // we have line number information - BOOL GlobalSymbols; // we have internal symbol information - BOOL TypeInfo; // we have type information - // new elements: 17-Dec-2003 - BOOL SourceIndexed; // pdb supports source server - BOOL Publics; // contains public symbols -} IMAGEHLP_MODULE64, *PIMAGEHLP_MODULE64; - -typedef struct _IMAGEHLP_MODULEW64 { - DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_MODULE64) - DWORD64 BaseOfImage; // base load address of module - DWORD ImageSize; // virtual size of the loaded module - DWORD TimeDateStamp; // date/time stamp from pe header - DWORD CheckSum; // checksum from the pe header - DWORD NumSyms; // number of symbols in the symbol table - SYM_TYPE SymType; // type of symbols loaded - WCHAR ModuleName[32]; // module name - WCHAR ImageName[256]; // image name - // new elements: 07-Jun-2002 - WCHAR LoadedImageName[256]; // symbol file name - WCHAR LoadedPdbName[256]; // pdb file name - DWORD CVSig; // Signature of the CV record in the debug directories - WCHAR CVData[MAX_PATH * 3]; // Contents of the CV record - DWORD PdbSig; // Signature of PDB - GUID PdbSig70; // Signature of PDB (VC 7 and up) - DWORD PdbAge; // DBI age of pdb - BOOL PdbUnmatched; // loaded an unmatched pdb - BOOL DbgUnmatched; // loaded an unmatched dbg - BOOL LineNumbers; // we have line number information - BOOL GlobalSymbols; // we have internal symbol information - BOOL TypeInfo; // we have type information - // new elements: 17-Dec-2003 - BOOL SourceIndexed; // pdb supports source server - BOOL Publics; // contains public symbols -} IMAGEHLP_MODULEW64, *PIMAGEHLP_MODULEW64; - -#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) -#define IMAGEHLP_MODULE IMAGEHLP_MODULE64 -#define PIMAGEHLP_MODULE PIMAGEHLP_MODULE64 -#define IMAGEHLP_MODULEW IMAGEHLP_MODULEW64 -#define PIMAGEHLP_MODULEW PIMAGEHLP_MODULEW64 -#else -typedef struct _IMAGEHLP_MODULE { - DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_MODULE) - DWORD BaseOfImage; // base load address of module - DWORD ImageSize; // virtual size of the loaded module - DWORD TimeDateStamp; // date/time stamp from pe header - DWORD CheckSum; // checksum from the pe header - DWORD NumSyms; // number of symbols in the symbol table - SYM_TYPE SymType; // type of symbols loaded - CHAR ModuleName[32]; // module name - CHAR ImageName[256]; // image name - CHAR LoadedImageName[256]; // symbol file name -} IMAGEHLP_MODULE, *PIMAGEHLP_MODULE; - -typedef struct _IMAGEHLP_MODULEW { - DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_MODULE) - DWORD BaseOfImage; // base load address of module - DWORD ImageSize; // virtual size of the loaded module - DWORD TimeDateStamp; // date/time stamp from pe header - DWORD CheckSum; // checksum from the pe header - DWORD NumSyms; // number of symbols in the symbol table - SYM_TYPE SymType; // type of symbols loaded - WCHAR ModuleName[32]; // module name - WCHAR ImageName[256]; // image name - WCHAR LoadedImageName[256]; // symbol file name -} IMAGEHLP_MODULEW, *PIMAGEHLP_MODULEW; -#endif - -// -// source file line data structure -// - -typedef struct _IMAGEHLP_LINE64 { - DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_LINE64) - PVOID Key; // internal - DWORD LineNumber; // line number in file - PCHAR FileName; // full filename - DWORD64 Address; // first instruction of line -} IMAGEHLP_LINE64, *PIMAGEHLP_LINE64; - -typedef struct _IMAGEHLP_LINEW64 { - DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_LINE64) - PVOID Key; // internal - DWORD LineNumber; // line number in file - PWSTR FileName; // full filename - DWORD64 Address; // first instruction of line -} IMAGEHLP_LINEW64, *PIMAGEHLP_LINEW64; - -#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) -#define IMAGEHLP_LINE IMAGEHLP_LINE64 -#define PIMAGEHLP_LINE PIMAGEHLP_LINE64 -#else -typedef struct _IMAGEHLP_LINE { - DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_LINE) - PVOID Key; // internal - DWORD LineNumber; // line number in file - PCHAR FileName; // full filename - DWORD Address; // first instruction of line -} IMAGEHLP_LINE, *PIMAGEHLP_LINE; - -typedef struct _IMAGEHLP_LINEW { - DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_LINE64) - PVOID Key; // internal - DWORD LineNumber; // line number in file - PCHAR FileName; // full filename - DWORD64 Address; // first instruction of line -} IMAGEHLP_LINEW, *PIMAGEHLP_LINEW; -#endif - -// -// source file structure -// - -typedef struct _SOURCEFILE { - DWORD64 ModBase; // base address of loaded module - PCHAR FileName; // full filename of source -} SOURCEFILE, *PSOURCEFILE; - -typedef struct _SOURCEFILEW { - DWORD64 ModBase; // base address of loaded module - PWSTR FileName; // full filename of source -} SOURCEFILEW, *PSOURCEFILEW; - -// -// data structures used for registered symbol callbacks -// - -#define CBA_DEFERRED_SYMBOL_LOAD_START 0x00000001 -#define CBA_DEFERRED_SYMBOL_LOAD_COMPLETE 0x00000002 -#define CBA_DEFERRED_SYMBOL_LOAD_FAILURE 0x00000003 -#define CBA_SYMBOLS_UNLOADED 0x00000004 -#define CBA_DUPLICATE_SYMBOL 0x00000005 -#define CBA_READ_MEMORY 0x00000006 -#define CBA_DEFERRED_SYMBOL_LOAD_CANCEL 0x00000007 -#define CBA_SET_OPTIONS 0x00000008 -#define CBA_EVENT 0x00000010 -#define CBA_DEFERRED_SYMBOL_LOAD_PARTIAL 0x00000020 -#define CBA_DEBUG_INFO 0x10000000 -#define CBA_SRCSRV_INFO 0x20000000 -#define CBA_SRCSRV_EVENT 0x40000000 - -typedef struct _IMAGEHLP_CBA_READ_MEMORY { - DWORD64 addr; // address to read from - PVOID buf; // buffer to read to - DWORD bytes; // amount of bytes to read - DWORD *bytesread; // pointer to store amount of bytes read -} IMAGEHLP_CBA_READ_MEMORY, *PIMAGEHLP_CBA_READ_MEMORY; - -enum { - sevInfo = 0, - sevProblem, - sevAttn, - sevFatal, - sevMax // unused -}; - -#define EVENT_SRCSPEW_START 100 -#define EVENT_SRCSPEW 100 -#define EVENT_SRCSPEW_END 199 - -typedef struct _IMAGEHLP_CBA_EVENT { - DWORD severity; // values from sevInfo to sevFatal - DWORD code; // numerical code IDs the error - PCHAR desc; // may contain a text description of the error - PVOID object; // value dependant upon the error code -} IMAGEHLP_CBA_EVENT, *PIMAGEHLP_CBA_EVENT; - -typedef struct _IMAGEHLP_CBA_EVENTW { - DWORD severity; // values from sevInfo to sevFatal - DWORD code; // numerical code IDs the error - PCWSTR desc; // may contain a text description of the error - PVOID object; // value dependant upon the error code -} IMAGEHLP_CBA_EVENTW, *PIMAGEHLP_CBA_EVENTW; - -typedef struct _IMAGEHLP_DEFERRED_SYMBOL_LOAD64 { - DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_DEFERRED_SYMBOL_LOAD64) - DWORD64 BaseOfImage; // base load address of module - DWORD CheckSum; // checksum from the pe header - DWORD TimeDateStamp; // date/time stamp from pe header - CHAR FileName[MAX_PATH]; // symbols file or image name - BOOLEAN Reparse; // load failure reparse - HANDLE hFile; // file handle, if passed - DWORD Flags; // -} IMAGEHLP_DEFERRED_SYMBOL_LOAD64, *PIMAGEHLP_DEFERRED_SYMBOL_LOAD64; - -typedef struct _IMAGEHLP_DEFERRED_SYMBOL_LOADW64 { - DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_DEFERRED_SYMBOL_LOADW64) - DWORD64 BaseOfImage; // base load address of module - DWORD CheckSum; // checksum from the pe header - DWORD TimeDateStamp; // date/time stamp from pe header - WCHAR FileName[MAX_PATH + 1]; // symbols file or image name - BOOLEAN Reparse; // load failure reparse - HANDLE hFile; // file handle, if passed - DWORD Flags; // -} IMAGEHLP_DEFERRED_SYMBOL_LOADW64, *PIMAGEHLP_DEFERRED_SYMBOL_LOADW64; - -#define DSLFLAG_MISMATCHED_PDB 0x1 -#define DSLFLAG_MISMATCHED_DBG 0x2 - -#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) -#define IMAGEHLP_DEFERRED_SYMBOL_LOAD IMAGEHLP_DEFERRED_SYMBOL_LOAD64 -#define PIMAGEHLP_DEFERRED_SYMBOL_LOAD PIMAGEHLP_DEFERRED_SYMBOL_LOAD64 -#else -typedef struct _IMAGEHLP_DEFERRED_SYMBOL_LOAD { - DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_DEFERRED_SYMBOL_LOAD) - DWORD BaseOfImage; // base load address of module - DWORD CheckSum; // checksum from the pe header - DWORD TimeDateStamp; // date/time stamp from pe header - CHAR FileName[MAX_PATH]; // symbols file or image name - BOOLEAN Reparse; // load failure reparse - HANDLE hFile; // file handle, if passed -} IMAGEHLP_DEFERRED_SYMBOL_LOAD, *PIMAGEHLP_DEFERRED_SYMBOL_LOAD; -#endif - -typedef struct _IMAGEHLP_DUPLICATE_SYMBOL64 { - DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_DUPLICATE_SYMBOL64) - DWORD NumberOfDups; // number of duplicates in the Symbol array - PIMAGEHLP_SYMBOL64 Symbol; // array of duplicate symbols - DWORD SelectedSymbol; // symbol selected (-1 to start) -} IMAGEHLP_DUPLICATE_SYMBOL64, *PIMAGEHLP_DUPLICATE_SYMBOL64; - -#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) -#define IMAGEHLP_DUPLICATE_SYMBOL IMAGEHLP_DUPLICATE_SYMBOL64 -#define PIMAGEHLP_DUPLICATE_SYMBOL PIMAGEHLP_DUPLICATE_SYMBOL64 -#else -typedef struct _IMAGEHLP_DUPLICATE_SYMBOL { - DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_DUPLICATE_SYMBOL) - DWORD NumberOfDups; // number of duplicates in the Symbol array - PIMAGEHLP_SYMBOL Symbol; // array of duplicate symbols - DWORD SelectedSymbol; // symbol selected (-1 to start) -} IMAGEHLP_DUPLICATE_SYMBOL, *PIMAGEHLP_DUPLICATE_SYMBOL; -#endif - -// If dbghelp ever needs to display graphical UI, it will use this as the parent window. - -BOOL -IMAGEAPI -SymSetParentWindow( - __in HWND hwnd - ); - -PCHAR -IMAGEAPI -SymSetHomeDirectory( - __in_opt HANDLE hProcess, - __in_opt PCSTR dir - ); - -PWSTR -IMAGEAPI -SymSetHomeDirectoryW( - __in_opt HANDLE hProcess, - __in_opt PCWSTR dir - ); - -PCHAR -IMAGEAPI -SymGetHomeDirectory( - __in DWORD type, - __out_ecount(size) PSTR dir, - __in size_t size - ); - -PWSTR -IMAGEAPI -SymGetHomeDirectoryW( - __in DWORD type, - __out_ecount(size) PWSTR dir, - __in size_t size - ); - -enum { - hdBase = 0, // root directory for dbghelp - hdSym, // where symbols are stored - hdSrc, // where source is stored - hdMax // end marker -}; - -typedef struct _OMAP { - ULONG rva; - ULONG rvaTo; -} OMAP, *POMAP; - -BOOL -IMAGEAPI -SymGetOmaps( - __in HANDLE hProcess, - __in DWORD64 BaseOfDll, - __out POMAP *OmapTo, - __out PDWORD64 cOmapTo, - __out POMAP *OmapFrom, - __out PDWORD64 cOmapFrom - ); - -// -// options that are set/returned by SymSetOptions() & SymGetOptions() -// these are used as a mask -// -#define SYMOPT_CASE_INSENSITIVE 0x00000001 -#define SYMOPT_UNDNAME 0x00000002 -#define SYMOPT_DEFERRED_LOADS 0x00000004 -#define SYMOPT_NO_CPP 0x00000008 -#define SYMOPT_LOAD_LINES 0x00000010 -#define SYMOPT_OMAP_FIND_NEAREST 0x00000020 -#define SYMOPT_LOAD_ANYTHING 0x00000040 -#define SYMOPT_IGNORE_CVREC 0x00000080 -#define SYMOPT_NO_UNQUALIFIED_LOADS 0x00000100 -#define SYMOPT_FAIL_CRITICAL_ERRORS 0x00000200 -#define SYMOPT_EXACT_SYMBOLS 0x00000400 -#define SYMOPT_ALLOW_ABSOLUTE_SYMBOLS 0x00000800 -#define SYMOPT_IGNORE_NT_SYMPATH 0x00001000 -#define SYMOPT_INCLUDE_32BIT_MODULES 0x00002000 -#define SYMOPT_PUBLICS_ONLY 0x00004000 -#define SYMOPT_NO_PUBLICS 0x00008000 -#define SYMOPT_AUTO_PUBLICS 0x00010000 -#define SYMOPT_NO_IMAGE_SEARCH 0x00020000 -#define SYMOPT_SECURE 0x00040000 -#define SYMOPT_NO_PROMPTS 0x00080000 -#define SYMOPT_OVERWRITE 0x00100000 -#define SYMOPT_IGNORE_IMAGEDIR 0x00200000 -#define SYMOPT_FLAT_DIRECTORY 0x00400000 -#define SYMOPT_FAVOR_COMPRESSED 0x00800000 -#define SYMOPT_ALLOW_ZERO_ADDRESS 0x01000000 -#define SYMOPT_DISABLE_SYMSRV_AUTODETECT 0x02000000 - -#define SYMOPT_DEBUG 0x80000000 - -DWORD -IMAGEAPI -SymSetOptions( - __in DWORD SymOptions - ); - -DWORD -IMAGEAPI -SymGetOptions( - VOID - ); - -BOOL -IMAGEAPI -SymCleanup( - __in HANDLE hProcess - ); - -BOOL -IMAGEAPI -SymMatchString( - __in PCSTR string, - __in PCSTR expression, - __in BOOL fCase - ); - -BOOL -IMAGEAPI -SymMatchStringA( - __in PCSTR string, - __in PCSTR expression, - __in BOOL fCase - ); - -BOOL -IMAGEAPI -SymMatchStringW( - __in PCWSTR string, - __in PCWSTR expression, - __in BOOL fCase - ); - -typedef BOOL -(CALLBACK *PSYM_ENUMSOURCEFILES_CALLBACK)( - __in PSOURCEFILE pSourceFile, - __in_opt PVOID UserContext - ); - -// for backwards compatibility - don't use this -#define PSYM_ENUMSOURCFILES_CALLBACK PSYM_ENUMSOURCEFILES_CALLBACK - -BOOL -IMAGEAPI -SymEnumSourceFiles( - __in HANDLE hProcess, - __in ULONG64 ModBase, - __in_opt PCSTR Mask, - __in PSYM_ENUMSOURCEFILES_CALLBACK cbSrcFiles, - __in_opt PVOID UserContext - ); - -typedef BOOL -(CALLBACK *PSYM_ENUMSOURCEFILES_CALLBACKW)( - __in PSOURCEFILEW pSourceFile, - __in_opt PVOID UserContext - ); - -BOOL -IMAGEAPI -SymEnumSourceFilesW( - __in HANDLE hProcess, - __in ULONG64 ModBase, - __in_opt PCWSTR Mask, - __in PSYM_ENUMSOURCEFILES_CALLBACKW cbSrcFiles, - __in_opt PVOID UserContext - ); - -BOOL -IMAGEAPI -SymEnumerateModules64( - __in HANDLE hProcess, - __in PSYM_ENUMMODULES_CALLBACK64 EnumModulesCallback, - __in_opt PVOID UserContext - ); - -BOOL -IMAGEAPI -SymEnumerateModulesW64( - __in HANDLE hProcess, - __in PSYM_ENUMMODULES_CALLBACKW64 EnumModulesCallback, - __in_opt PVOID UserContext - ); - -#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) -#define SymEnumerateModules SymEnumerateModules64 -#else -BOOL -IMAGEAPI -SymEnumerateModules( - __in HANDLE hProcess, - __in PSYM_ENUMMODULES_CALLBACK EnumModulesCallback, - __in_opt PVOID UserContext - ); -#endif - -BOOL -IMAGEAPI -EnumerateLoadedModulesEx( - __in HANDLE hProcess, - __in PENUMLOADED_MODULES_CALLBACK64 EnumLoadedModulesCallback, - __in_opt PVOID UserContext - ); - -BOOL -IMAGEAPI -EnumerateLoadedModulesExW( - __in HANDLE hProcess, - __in PENUMLOADED_MODULES_CALLBACKW64 EnumLoadedModulesCallback, - __in_opt PVOID UserContext - ); - -BOOL -IMAGEAPI -EnumerateLoadedModules64( - __in HANDLE hProcess, - __in PENUMLOADED_MODULES_CALLBACK64 EnumLoadedModulesCallback, - __in_opt PVOID UserContext - ); - -BOOL -IMAGEAPI -EnumerateLoadedModulesW64( - __in HANDLE hProcess, - __in PENUMLOADED_MODULES_CALLBACKW64 EnumLoadedModulesCallback, - __in_opt PVOID UserContext - ); - -#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) -#define EnumerateLoadedModules EnumerateLoadedModules64 -#else -BOOL -IMAGEAPI -EnumerateLoadedModules( - __in HANDLE hProcess, - __in PENUMLOADED_MODULES_CALLBACK EnumLoadedModulesCallback, - __in_opt PVOID UserContext - ); -#endif - -PVOID -IMAGEAPI -SymFunctionTableAccess64( - __in HANDLE hProcess, - __in DWORD64 AddrBase - ); - -#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) -#define SymFunctionTableAccess SymFunctionTableAccess64 -#else -PVOID -IMAGEAPI -SymFunctionTableAccess( - __in HANDLE hProcess, - __in DWORD AddrBase - ); -#endif - -BOOL -IMAGEAPI -SymGetUnwindInfo( - __in HANDLE hProcess, - __in DWORD64 Address, - __out_bcount_opt(*Size) PVOID Buffer, - __inout PULONG Size - ); - -BOOL -IMAGEAPI -SymGetModuleInfo64( - __in HANDLE hProcess, - __in DWORD64 qwAddr, - __out PIMAGEHLP_MODULE64 ModuleInfo - ); - -BOOL -IMAGEAPI -SymGetModuleInfoW64( - __in HANDLE hProcess, - __in DWORD64 qwAddr, - __out PIMAGEHLP_MODULEW64 ModuleInfo - ); - -#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) -#define SymGetModuleInfo SymGetModuleInfo64 -#define SymGetModuleInfoW SymGetModuleInfoW64 -#else -BOOL -IMAGEAPI -SymGetModuleInfo( - __in HANDLE hProcess, - __in DWORD dwAddr, - __out PIMAGEHLP_MODULE ModuleInfo - ); - -BOOL -IMAGEAPI -SymGetModuleInfoW( - __in HANDLE hProcess, - __in DWORD dwAddr, - __out PIMAGEHLP_MODULEW ModuleInfo - ); -#endif - -DWORD64 -IMAGEAPI -SymGetModuleBase64( - __in HANDLE hProcess, - __in DWORD64 qwAddr - ); - -#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) -#define SymGetModuleBase SymGetModuleBase64 -#else -DWORD -IMAGEAPI -SymGetModuleBase( - __in HANDLE hProcess, - __in DWORD dwAddr - ); -#endif - -typedef struct _SRCCODEINFO { - DWORD SizeOfStruct; // set to sizeof(SRCCODEINFO) - PVOID Key; // not used - DWORD64 ModBase; // base address of module this applies to - CHAR Obj[MAX_PATH + 1]; // the object file within the module - CHAR FileName[MAX_PATH + 1]; // full filename - DWORD LineNumber; // line number in file - DWORD64 Address; // first instruction of line -} SRCCODEINFO, *PSRCCODEINFO; - -typedef struct _SRCCODEINFOW { - DWORD SizeOfStruct; // set to sizeof(SRCCODEINFO) - PVOID Key; // not used - DWORD64 ModBase; // base address of module this applies to - WCHAR Obj[MAX_PATH + 1]; // the object file within the module - WCHAR FileName[MAX_PATH + 1]; // full filename - DWORD LineNumber; // line number in file - DWORD64 Address; // first instruction of line -} SRCCODEINFOW, *PSRCCODEINFOW; - -typedef BOOL -(CALLBACK *PSYM_ENUMLINES_CALLBACK)( - __in PSRCCODEINFO LineInfo, - __in_opt PVOID UserContext - ); - -BOOL -IMAGEAPI -SymEnumLines( - __in HANDLE hProcess, - __in ULONG64 Base, - __in_opt PCSTR Obj, - __in_opt PCSTR File, - __in PSYM_ENUMLINES_CALLBACK EnumLinesCallback, - __in_opt PVOID UserContext - ); - -typedef BOOL -(CALLBACK *PSYM_ENUMLINES_CALLBACKW)( - __in PSRCCODEINFOW LineInfo, - __in_opt PVOID UserContext - ); - -BOOL -IMAGEAPI -SymEnumLinesW( - __in HANDLE hProcess, - __in ULONG64 Base, - __in_opt PCWSTR Obj, - __in_opt PCWSTR File, - __in PSYM_ENUMLINES_CALLBACKW EnumLinesCallback, - __in_opt PVOID UserContext - ); - -BOOL -IMAGEAPI -SymGetLineFromAddr64( - __in HANDLE hProcess, - __in DWORD64 qwAddr, - __out PDWORD pdwDisplacement, - __out PIMAGEHLP_LINE64 Line64 - ); - -BOOL -IMAGEAPI -SymGetLineFromAddrW64( - __in HANDLE hProcess, - __in DWORD64 dwAddr, - __out PDWORD pdwDisplacement, - __out PIMAGEHLP_LINEW64 Line - ); - -BOOL -IMAGEAPI -SymEnumSourceLines( - __in HANDLE hProcess, - __in ULONG64 Base, - __in_opt PCSTR Obj, - __in_opt PCSTR File, - __in_opt DWORD Line, - __in DWORD Flags, - __in PSYM_ENUMLINES_CALLBACK EnumLinesCallback, - __in_opt PVOID UserContext - ); - -BOOL -IMAGEAPI -SymEnumSourceLinesW( - __in HANDLE hProcess, - __in ULONG64 Base, - __in_opt PCWSTR Obj, - __in_opt PCWSTR File, - __in_opt DWORD Line, - __in DWORD Flags, - __in PSYM_ENUMLINES_CALLBACKW EnumLinesCallback, - __in_opt PVOID UserContext - ); - -// flags for SymEnumSourceLines - -#define ESLFLAG_FULLPATH 0x1 -#define ESLFLAG_NEAREST 0x2 -#define ESLFLAG_PREV 0x4 -#define ESLFLAG_NEXT 0x8 - -#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) -#define SymGetLineFromAddr SymGetLineFromAddr64 -#define SymGetLineFromAddrW SymGetLineFromAddrW64 -#else -BOOL -IMAGEAPI -SymGetLineFromAddr( - __in HANDLE hProcess, - __in DWORD dwAddr, - __out PDWORD pdwDisplacement, - __out PIMAGEHLP_LINE Line - ); - -BOOL -IMAGEAPI -SymGetLineFromAddrW( - __in HANDLE hProcess, - __in DWORD dwAddr, - __out PDWORD pdwDisplacement, - __out PIMAGEHLP_LINEW Line - ); -#endif - -BOOL -IMAGEAPI -SymGetLineFromName64( - __in HANDLE hProcess, - __in_opt PCSTR ModuleName, - __in_opt PCSTR FileName, - __in DWORD dwLineNumber, - __out PLONG plDisplacement, - __inout PIMAGEHLP_LINE64 Line - ); - -BOOL -IMAGEAPI -SymGetLineFromNameW64( - __in HANDLE hProcess, - __in_opt PCWSTR ModuleName, - __in_opt PCWSTR FileName, - __in DWORD dwLineNumber, - __out PLONG plDisplacement, - __inout PIMAGEHLP_LINEW64 Line - ); - -#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) -#define SymGetLineFromName SymGetLineFromName64 -#else -BOOL -IMAGEAPI -SymGetLineFromName( - __in HANDLE hProcess, - __in_opt PCSTR ModuleName, - __in_opt PCSTR FileName, - __in DWORD dwLineNumber, - __out PLONG plDisplacement, - __inout PIMAGEHLP_LINE Line - ); -#endif - -BOOL -IMAGEAPI -SymGetLineNext64( - __in HANDLE hProcess, - __inout PIMAGEHLP_LINE64 Line - ); - -BOOL -IMAGEAPI -SymGetLineNextW64( - __in HANDLE hProcess, - __inout PIMAGEHLP_LINEW64 Line - ); - -#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) -#define SymGetLineNext SymGetLineNext64 -#else -BOOL -IMAGEAPI -SymGetLineNext( - __in HANDLE hProcess, - __inout PIMAGEHLP_LINE Line - ); - -BOOL -IMAGEAPI -SymGetLineNextW( - __in HANDLE hProcess, - __inout PIMAGEHLP_LINEW Line - ); -#endif - -BOOL -IMAGEAPI -SymGetLinePrev64( - __in HANDLE hProcess, - __inout PIMAGEHLP_LINE64 Line - ); - -BOOL -IMAGEAPI -SymGetLinePrevW64( - __in HANDLE hProcess, - __inout PIMAGEHLP_LINEW64 Line - ); - -#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) -#define SymGetLinePrev SymGetLinePrev64 -#else -BOOL -IMAGEAPI -SymGetLinePrev( - __in HANDLE hProcess, - __inout PIMAGEHLP_LINE Line - ); - -BOOL -IMAGEAPI -SymGetLinePrevW( - __in HANDLE hProcess, - __inout PIMAGEHLP_LINEW Line - ); -#endif - -ULONG -IMAGEAPI -SymGetFileLineOffsets64( - __in HANDLE hProcess, - __in_opt PCSTR ModuleName, - __in PCSTR FileName, - __out_ecount(BufferLines) PDWORD64 Buffer, - __in ULONG BufferLines - ); - -BOOL -IMAGEAPI -SymMatchFileName( - __in PCSTR FileName, - __in PCSTR Match, - __deref_opt_out PSTR *FileNameStop, - __deref_opt_out PSTR *MatchStop - ); - -BOOL -IMAGEAPI -SymMatchFileNameW( - __in PCWSTR FileName, - __in PCWSTR Match, - __deref_opt_out PWSTR *FileNameStop, - __deref_opt_out PWSTR *MatchStop - ); - -BOOL -IMAGEAPI -SymGetSourceFile( - __in HANDLE hProcess, - __in ULONG64 Base, - __in_opt PCSTR Params, - __in PCSTR FileSpec, - __out_ecount(Size) PSTR FilePath, - __in DWORD Size - ); - -BOOL -IMAGEAPI -SymGetSourceFileW( - __in HANDLE hProcess, - __in ULONG64 Base, - __in_opt PCWSTR Params, - __in PCWSTR FileSpec, - __out_ecount(Size) PWSTR FilePath, - __in DWORD Size - ); - -BOOL -IMAGEAPI -SymGetSourceFileToken( - __in HANDLE hProcess, - __in ULONG64 Base, - __in PCSTR FileSpec, - __deref_out PVOID *Token, - __out DWORD *Size - ); - -BOOL -IMAGEAPI -SymGetSourceFileTokenW( - __in HANDLE hProcess, - __in ULONG64 Base, - __in PCWSTR FileSpec, - __deref_out PVOID *Token, - __out DWORD *Size - ); - -BOOL -IMAGEAPI -SymGetSourceFileFromToken( - __in HANDLE hProcess, - __in PVOID Token, - __in_opt PCSTR Params, - __out_ecount(Size) PSTR FilePath, - __in DWORD Size - ); - -BOOL -IMAGEAPI -SymGetSourceFileFromTokenW( - __in HANDLE hProcess, - __in PVOID Token, - __in_opt PCWSTR Params, - __out_ecount(Size) PWSTR FilePath, - __in DWORD Size - ); - -BOOL -IMAGEAPI -SymGetSourceVarFromToken( - __in HANDLE hProcess, - __in PVOID Token, - __in_opt PCSTR Params, - __in PCSTR VarName, - __out_ecount(Size) PSTR Value, - __in DWORD Size - ); - -BOOL -IMAGEAPI -SymGetSourceVarFromTokenW( - __in HANDLE hProcess, - __in PVOID Token, - __in_opt PCWSTR Params, - __in PCWSTR VarName, - __out_ecount(Size) PWSTR Value, - __in DWORD Size - ); - -typedef BOOL (CALLBACK *PENUMSOURCEFILETOKENSCALLBACK)(__in PVOID token, __in size_t size); - -BOOL -IMAGEAPI -SymEnumSourceFileTokens( - __in HANDLE hProcess, - __in ULONG64 Base, - __in PENUMSOURCEFILETOKENSCALLBACK Callback - ); - -BOOL -IMAGEAPI -SymInitialize( - __in HANDLE hProcess, - __in_opt PCSTR UserSearchPath, - __in BOOL fInvadeProcess - ); - -BOOL -IMAGEAPI -SymInitializeW( - __in HANDLE hProcess, - __in_opt PCWSTR UserSearchPath, - __in BOOL fInvadeProcess - ); - -BOOL -IMAGEAPI -SymGetSearchPath( - __in HANDLE hProcess, - __out_ecount(SearchPathLength) PSTR SearchPath, - __in DWORD SearchPathLength - ); - -BOOL -IMAGEAPI -SymGetSearchPathW( - __in HANDLE hProcess, - __out_ecount(SearchPathLength) PWSTR SearchPath, - __in DWORD SearchPathLength - ); - -BOOL -IMAGEAPI -SymSetSearchPath( - __in HANDLE hProcess, - __in_opt PCSTR SearchPath - ); - -BOOL -IMAGEAPI -SymSetSearchPathW( - __in HANDLE hProcess, - __in_opt PCWSTR SearchPath - ); - -#define SLMFLAG_VIRTUAL 0x1 -#define SLMFLAG_ALT_INDEX 0x2 -#define SLMFLAG_NO_SYMBOLS 0x4 - -DWORD64 -IMAGEAPI -SymLoadModuleEx( - __in HANDLE hProcess, - __in_opt HANDLE hFile, - __in_opt PCSTR ImageName, - __in_opt PCSTR ModuleName, - __in DWORD64 BaseOfDll, - __in DWORD DllSize, - __in_opt PMODLOAD_DATA Data, - __in_opt DWORD Flags - ); - -DWORD64 -IMAGEAPI -SymLoadModuleExW( - __in HANDLE hProcess, - __in_opt HANDLE hFile, - __in_opt PCWSTR ImageName, - __in_opt PCWSTR ModuleName, - __in DWORD64 BaseOfDll, - __in DWORD DllSize, - __in_opt PMODLOAD_DATA Data, - __in_opt DWORD Flags - ); - -BOOL -IMAGEAPI -SymUnloadModule64( - __in HANDLE hProcess, - __in DWORD64 BaseOfDll - ); - -#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) -#define SymUnloadModule SymUnloadModule64 -#else -BOOL -IMAGEAPI -SymUnloadModule( - __in HANDLE hProcess, - __in DWORD BaseOfDll - ); -#endif - -BOOL -IMAGEAPI -SymUnDName64( - __in PIMAGEHLP_SYMBOL64 sym, // Symbol to undecorate - __out_ecount(UnDecNameLength) PSTR UnDecName, // Buffer to store undecorated name in - __in DWORD UnDecNameLength // Size of the buffer - ); - -#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) -#define SymUnDName SymUnDName64 -#else -BOOL -IMAGEAPI -SymUnDName( - __in PIMAGEHLP_SYMBOL sym, // Symbol to undecorate - __out_ecount(UnDecNameLength) PSTR UnDecName, // Buffer to store undecorated name in - __in DWORD UnDecNameLength // Size of the buffer - ); -#endif - -BOOL -IMAGEAPI -SymRegisterCallback64( - __in HANDLE hProcess, - __in PSYMBOL_REGISTERED_CALLBACK64 CallbackFunction, - __in ULONG64 UserContext - ); - -BOOL -IMAGEAPI -SymRegisterCallbackW64( - __in HANDLE hProcess, - __in PSYMBOL_REGISTERED_CALLBACK64 CallbackFunction, - __in ULONG64 UserContext - ); - -BOOL -IMAGEAPI -SymRegisterFunctionEntryCallback64( - __in HANDLE hProcess, - __in PSYMBOL_FUNCENTRY_CALLBACK64 CallbackFunction, - __in ULONG64 UserContext - ); - -#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) -#define SymRegisterCallback SymRegisterCallback64 -#define SymRegisterFunctionEntryCallback SymRegisterFunctionEntryCallback64 -#else -BOOL -IMAGEAPI -SymRegisterCallback( - __in HANDLE hProcess, - __in PSYMBOL_REGISTERED_CALLBACK CallbackFunction, - __in_opt PVOID UserContext - ); - -BOOL -IMAGEAPI -SymRegisterFunctionEntryCallback( - __in HANDLE hProcess, - __in PSYMBOL_FUNCENTRY_CALLBACK CallbackFunction, - __in_opt PVOID UserContext - ); -#endif - - -typedef struct _IMAGEHLP_SYMBOL_SRC { - DWORD sizeofstruct; - DWORD type; - char file[MAX_PATH]; -} IMAGEHLP_SYMBOL_SRC, *PIMAGEHLP_SYMBOL_SRC; - -typedef struct _MODULE_TYPE_INFO { // AKA TYPTYP - USHORT dataLength; - USHORT leaf; - BYTE data[1]; -} MODULE_TYPE_INFO, *PMODULE_TYPE_INFO; - -typedef struct _SYMBOL_INFO { - ULONG SizeOfStruct; - ULONG TypeIndex; // Type Index of symbol - ULONG64 Reserved[2]; - ULONG Index; - ULONG Size; - ULONG64 ModBase; // Base Address of module comtaining this symbol - ULONG Flags; - ULONG64 Value; // Value of symbol, ValuePresent should be 1 - ULONG64 Address; // Address of symbol including base address of module - ULONG Register; // register holding value or pointer to value - ULONG Scope; // scope of the symbol - ULONG Tag; // pdb classification - ULONG NameLen; // Actual length of name - ULONG MaxNameLen; - CHAR Name[1]; // Name of symbol -} SYMBOL_INFO, *PSYMBOL_INFO; - -typedef struct _SYMBOL_INFO_PACKAGE { - SYMBOL_INFO si; - CHAR name[MAX_SYM_NAME + 1]; -} SYMBOL_INFO_PACKAGE, *PSYMBOL_INFO_PACKAGE; - -typedef struct _SYMBOL_INFOW { - ULONG SizeOfStruct; - ULONG TypeIndex; // Type Index of symbol - ULONG64 Reserved[2]; - ULONG Index; - ULONG Size; - ULONG64 ModBase; // Base Address of module comtaining this symbol - ULONG Flags; - ULONG64 Value; // Value of symbol, ValuePresent should be 1 - ULONG64 Address; // Address of symbol including base address of module - ULONG Register; // register holding value or pointer to value - ULONG Scope; // scope of the symbol - ULONG Tag; // pdb classification - ULONG NameLen; // Actual length of name - ULONG MaxNameLen; - WCHAR Name[1]; // Name of symbol -} SYMBOL_INFOW, *PSYMBOL_INFOW; - -typedef struct _SYMBOL_INFO_PACKAGEW { - SYMBOL_INFOW si; - WCHAR name[MAX_SYM_NAME + 1]; -} SYMBOL_INFO_PACKAGEW, *PSYMBOL_INFO_PACKAGEW; - -typedef struct _IMAGEHLP_STACK_FRAME -{ - ULONG64 InstructionOffset; - ULONG64 ReturnOffset; - ULONG64 FrameOffset; - ULONG64 StackOffset; - ULONG64 BackingStoreOffset; - ULONG64 FuncTableEntry; - ULONG64 Params[4]; - ULONG64 Reserved[5]; - BOOL Virtual; - ULONG Reserved2; -} IMAGEHLP_STACK_FRAME, *PIMAGEHLP_STACK_FRAME; - -typedef VOID IMAGEHLP_CONTEXT, *PIMAGEHLP_CONTEXT; - - -BOOL -IMAGEAPI -SymSetContext( - __in HANDLE hProcess, - __in PIMAGEHLP_STACK_FRAME StackFrame, - __in_opt PIMAGEHLP_CONTEXT Context - ); - -BOOL -IMAGEAPI -SymSetScopeFromAddr( - __in HANDLE hProcess, - __in ULONG64 Address - ); - -BOOL -IMAGEAPI -SymSetScopeFromIndex( - __in HANDLE hProcess, - __in ULONG64 BaseOfDll, - __in DWORD Index - ); - -typedef BOOL -(CALLBACK *PSYM_ENUMPROCESSES_CALLBACK)( - __in HANDLE hProcess, - __in PVOID UserContext - ); - -BOOL -IMAGEAPI -SymEnumProcesses( - __in PSYM_ENUMPROCESSES_CALLBACK EnumProcessesCallback, - __in PVOID UserContext - ); - -BOOL -IMAGEAPI -SymFromAddr( - __in HANDLE hProcess, - __in DWORD64 Address, - __out_opt PDWORD64 Displacement, - __inout PSYMBOL_INFO Symbol - ); - -BOOL -IMAGEAPI -SymFromAddrW( - __in HANDLE hProcess, - __in DWORD64 Address, - __out_opt PDWORD64 Displacement, - __inout PSYMBOL_INFOW Symbol - ); - -BOOL -IMAGEAPI -SymFromToken( - __in HANDLE hProcess, - __in DWORD64 Base, - __in DWORD Token, - __inout PSYMBOL_INFO Symbol - ); - -BOOL -IMAGEAPI -SymFromTokenW( - __in HANDLE hProcess, - __in DWORD64 Base, - __in DWORD Token, - __inout PSYMBOL_INFOW Symbol - ); - -BOOL -IMAGEAPI -SymNext( - __in HANDLE hProcess, - __inout PSYMBOL_INFO si - ); - -BOOL -IMAGEAPI -SymNextW( - __in HANDLE hProcess, - __inout PSYMBOL_INFOW siw - ); - -BOOL -IMAGEAPI -SymPrev( - __in HANDLE hProcess, - __inout PSYMBOL_INFO si - ); - -BOOL -IMAGEAPI -SymPrevW( - __in HANDLE hProcess, - __inout PSYMBOL_INFOW siw - ); - -// While SymFromName will provide a symbol from a name, -// SymEnumSymbols can provide the same matching information -// for ALL symbols with a matching name, even regular -// expressions. That way you can search across modules -// and differentiate between identically named symbols. - -BOOL -IMAGEAPI -SymFromName( - __in HANDLE hProcess, - __in PCSTR Name, - __inout PSYMBOL_INFO Symbol - ); - -BOOL -IMAGEAPI -SymFromNameW( - __in HANDLE hProcess, - __in PCWSTR Name, - __inout PSYMBOL_INFOW Symbol - ); - -typedef BOOL -(CALLBACK *PSYM_ENUMERATESYMBOLS_CALLBACK)( - __in PSYMBOL_INFO pSymInfo, - __in ULONG SymbolSize, - __in_opt PVOID UserContext - ); - -BOOL -IMAGEAPI -SymEnumSymbols( - __in HANDLE hProcess, - __in ULONG64 BaseOfDll, - __in_opt PCSTR Mask, - __in PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback, - __in_opt PVOID UserContext - ); - -typedef BOOL -(CALLBACK *PSYM_ENUMERATESYMBOLS_CALLBACKW)( - __in PSYMBOL_INFOW pSymInfo, - __in ULONG SymbolSize, - __in_opt PVOID UserContext - ); - -BOOL -IMAGEAPI -SymEnumSymbolsW( - __in HANDLE hProcess, - __in ULONG64 BaseOfDll, - __in_opt PCWSTR Mask, - __in PSYM_ENUMERATESYMBOLS_CALLBACKW EnumSymbolsCallback, - __in_opt PVOID UserContext - ); - -BOOL -IMAGEAPI -SymEnumSymbolsForAddr( - __in HANDLE hProcess, - __in DWORD64 Address, - __in PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback, - __in_opt PVOID UserContext - ); - -BOOL -IMAGEAPI -SymEnumSymbolsForAddrW( - __in HANDLE hProcess, - __in DWORD64 Address, - __in PSYM_ENUMERATESYMBOLS_CALLBACKW EnumSymbolsCallback, - __in_opt PVOID UserContext - ); - -#define SYMSEARCH_MASKOBJS 0x01 // used internally to implement other APIs -#define SYMSEARCH_RECURSE 0X02 // recurse scopes -#define SYMSEARCH_GLOBALSONLY 0X04 // search only for global symbols -#define SYMSEARCH_ALLITEMS 0X08 // search for everything in the pdb, not just normal scoped symbols - -BOOL -IMAGEAPI -SymSearch( - __in HANDLE hProcess, - __in ULONG64 BaseOfDll, - __in_opt DWORD Index, - __in_opt DWORD SymTag, - __in_opt PCSTR Mask, - __in_opt DWORD64 Address, - __in PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback, - __in_opt PVOID UserContext, - __in DWORD Options - ); - -BOOL -IMAGEAPI -SymSearchW( - __in HANDLE hProcess, - __in ULONG64 BaseOfDll, - __in_opt DWORD Index, - __in_opt DWORD SymTag, - __in_opt PCWSTR Mask, - __in_opt DWORD64 Address, - __in PSYM_ENUMERATESYMBOLS_CALLBACKW EnumSymbolsCallback, - __in_opt PVOID UserContext, - __in DWORD Options - ); - -BOOL -IMAGEAPI -SymGetScope( - __in HANDLE hProcess, - __in ULONG64 BaseOfDll, - __in DWORD Index, - __inout PSYMBOL_INFO Symbol - ); - -BOOL -IMAGEAPI -SymGetScopeW( - __in HANDLE hProcess, - __in ULONG64 BaseOfDll, - __in DWORD Index, - __inout PSYMBOL_INFOW Symbol - ); - -BOOL -IMAGEAPI -SymFromIndex( - __in HANDLE hProcess, - __in ULONG64 BaseOfDll, - __in DWORD Index, - __inout PSYMBOL_INFO Symbol - ); - -BOOL -IMAGEAPI -SymFromIndexW( - __in HANDLE hProcess, - __in ULONG64 BaseOfDll, - __in DWORD Index, - __inout PSYMBOL_INFOW Symbol - ); - -typedef enum _IMAGEHLP_SYMBOL_TYPE_INFO { - TI_GET_SYMTAG, - TI_GET_SYMNAME, - TI_GET_LENGTH, - TI_GET_TYPE, - TI_GET_TYPEID, - TI_GET_BASETYPE, - TI_GET_ARRAYINDEXTYPEID, - TI_FINDCHILDREN, - TI_GET_DATAKIND, - TI_GET_ADDRESSOFFSET, - TI_GET_OFFSET, - TI_GET_VALUE, - TI_GET_COUNT, - TI_GET_CHILDRENCOUNT, - TI_GET_BITPOSITION, - TI_GET_VIRTUALBASECLASS, - TI_GET_VIRTUALTABLESHAPEID, - TI_GET_VIRTUALBASEPOINTEROFFSET, - TI_GET_CLASSPARENTID, - TI_GET_NESTED, - TI_GET_SYMINDEX, - TI_GET_LEXICALPARENT, - TI_GET_ADDRESS, - TI_GET_THISADJUST, - TI_GET_UDTKIND, - TI_IS_EQUIV_TO, - TI_GET_CALLING_CONVENTION, - TI_IS_CLOSE_EQUIV_TO, - TI_GTIEX_REQS_VALID, - TI_GET_VIRTUALBASEOFFSET, - TI_GET_VIRTUALBASEDISPINDEX, - TI_GET_IS_REFERENCE, - TI_GET_INDIRECTVIRTUALBASECLASS, - IMAGEHLP_SYMBOL_TYPE_INFO_MAX, -} IMAGEHLP_SYMBOL_TYPE_INFO; - -typedef struct _TI_FINDCHILDREN_PARAMS { - ULONG Count; - ULONG Start; - ULONG ChildId[1]; -} TI_FINDCHILDREN_PARAMS; - -BOOL -IMAGEAPI -SymGetTypeInfo( - __in HANDLE hProcess, - __in DWORD64 ModBase, - __in ULONG TypeId, - __in IMAGEHLP_SYMBOL_TYPE_INFO GetType, - __out PVOID pInfo - ); - -#define IMAGEHLP_GET_TYPE_INFO_UNCACHED 0x00000001 -#define IMAGEHLP_GET_TYPE_INFO_CHILDREN 0x00000002 - -typedef struct _IMAGEHLP_GET_TYPE_INFO_PARAMS { - IN ULONG SizeOfStruct; - IN ULONG Flags; - IN ULONG NumIds; - IN PULONG TypeIds; - IN ULONG64 TagFilter; - IN ULONG NumReqs; - IN IMAGEHLP_SYMBOL_TYPE_INFO* ReqKinds; - IN PULONG_PTR ReqOffsets; - IN PULONG ReqSizes; - IN ULONG_PTR ReqStride; - IN ULONG_PTR BufferSize; - OUT PVOID Buffer; - OUT ULONG EntriesMatched; - OUT ULONG EntriesFilled; - OUT ULONG64 TagsFound; - OUT ULONG64 AllReqsValid; - IN ULONG NumReqsValid; - OUT PULONG64 ReqsValid OPTIONAL; -} IMAGEHLP_GET_TYPE_INFO_PARAMS, *PIMAGEHLP_GET_TYPE_INFO_PARAMS; - -BOOL -IMAGEAPI -SymGetTypeInfoEx( - __in HANDLE hProcess, - __in DWORD64 ModBase, - __inout PIMAGEHLP_GET_TYPE_INFO_PARAMS Params - ); - -BOOL -IMAGEAPI -SymEnumTypes( - __in HANDLE hProcess, - __in ULONG64 BaseOfDll, - __in PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback, - __in_opt PVOID UserContext - ); - -BOOL -IMAGEAPI -SymEnumTypesW( - __in HANDLE hProcess, - __in ULONG64 BaseOfDll, - __in PSYM_ENUMERATESYMBOLS_CALLBACKW EnumSymbolsCallback, - __in_opt PVOID UserContext - ); - -BOOL -IMAGEAPI -SymEnumTypesByName( - __in HANDLE hProcess, - __in ULONG64 BaseOfDll, - __in_opt PCSTR mask, - __in PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback, - __in_opt PVOID UserContext - ); - -BOOL -IMAGEAPI -SymEnumTypesByNameW( - __in HANDLE hProcess, - __in ULONG64 BaseOfDll, - __in_opt PCWSTR mask, - __in PSYM_ENUMERATESYMBOLS_CALLBACKW EnumSymbolsCallback, - __in_opt PVOID UserContext - ); - -BOOL -IMAGEAPI -SymGetTypeFromName( - __in HANDLE hProcess, - __in ULONG64 BaseOfDll, - __in PCSTR Name, - __inout PSYMBOL_INFO Symbol - ); - -BOOL -IMAGEAPI -SymGetTypeFromNameW( - __in HANDLE hProcess, - __in ULONG64 BaseOfDll, - __in PCWSTR Name, - __inout PSYMBOL_INFOW Symbol - ); - -BOOL -IMAGEAPI -SymAddSymbol( - __in HANDLE hProcess, - __in ULONG64 BaseOfDll, - __in PCSTR Name, - __in DWORD64 Address, - __in DWORD Size, - __in DWORD Flags - ); - -BOOL -IMAGEAPI -SymAddSymbolW( - __in HANDLE hProcess, - __in ULONG64 BaseOfDll, - __in PCWSTR Name, - __in DWORD64 Address, - __in DWORD Size, - __in DWORD Flags - ); - -BOOL -IMAGEAPI -SymDeleteSymbol( - __in HANDLE hProcess, - __in ULONG64 BaseOfDll, - __in_opt PCSTR Name, - __in DWORD64 Address, - __in DWORD Flags - ); - -BOOL -IMAGEAPI -SymDeleteSymbolW( - __in HANDLE hProcess, - __in ULONG64 BaseOfDll, - __in_opt PCWSTR Name, - __in DWORD64 Address, - __in DWORD Flags - ); - -BOOL -IMAGEAPI -SymRefreshModuleList( - __in HANDLE hProcess - ); - -BOOL -IMAGEAPI -SymAddSourceStream( - __in HANDLE hProcess, - __in ULONG64 Base, - __in_opt PCSTR StreamFile, - __in_bcount_opt(Size) PBYTE Buffer, - __in size_t Size - ); - -typedef BOOL (WINAPI *SYMADDSOURCESTREAM)(HANDLE, ULONG64, PCSTR, PBYTE, size_t); - -BOOL -IMAGEAPI -SymAddSourceStreamA( - __in HANDLE hProcess, - __in ULONG64 Base, - __in_opt PCSTR StreamFile, - __in_bcount_opt(Size) PBYTE Buffer, - __in size_t Size - ); - -typedef BOOL (WINAPI *SYMADDSOURCESTREAMA)(HANDLE, ULONG64, PCSTR, PBYTE, size_t); - -BOOL -IMAGEAPI -SymAddSourceStreamW( - __in HANDLE hProcess, - __in ULONG64 Base, - __in_opt PCWSTR FileSpec, - __in_bcount_opt(Size) PBYTE Buffer, - __in size_t Size - ); - -BOOL -IMAGEAPI -SymSrvIsStoreW( - __in_opt HANDLE hProcess, - __in PCWSTR path - ); - -BOOL -IMAGEAPI -SymSrvIsStore( - __in_opt HANDLE hProcess, - __in PCSTR path - ); - -PCSTR -IMAGEAPI -SymSrvDeltaName( - __in HANDLE hProcess, - __in_opt PCSTR SymPath, - __in PCSTR Type, - __in PCSTR File1, - __in PCSTR File2 - ); - -PCWSTR -IMAGEAPI -SymSrvDeltaNameW( - __in HANDLE hProcess, - __in_opt PCWSTR SymPath, - __in PCWSTR Type, - __in PCWSTR File1, - __in PCWSTR File2 - ); - -PCSTR -IMAGEAPI -SymSrvGetSupplement( - __in HANDLE hProcess, - __in_opt PCSTR SymPath, - __in PCSTR Node, - __in PCSTR File - ); - -PCWSTR -IMAGEAPI -SymSrvGetSupplementW( - __in HANDLE hProcess, - __in_opt PCWSTR SymPath, - __in PCWSTR Node, - __in PCWSTR File - ); - -BOOL -IMAGEAPI -SymSrvGetFileIndexes( - __in PCSTR File, - __out GUID *Id, - __out PDWORD Val1, - __out_opt PDWORD Val2, - __in DWORD Flags - ); - -BOOL -IMAGEAPI -SymSrvGetFileIndexesW( - __in PCWSTR File, - __out GUID *Id, - __out PDWORD Val1, - __out_opt PDWORD Val2, - __in DWORD Flags - ); - -BOOL -IMAGEAPI -SymSrvGetFileIndexStringW( - __in HANDLE hProcess, - __in_opt PCWSTR SrvPath, - __in PCWSTR File, - __out_ecount(Size) PWSTR Index, - __in size_t Size, - __in DWORD Flags - ); - -BOOL -IMAGEAPI -SymSrvGetFileIndexString( - __in HANDLE hProcess, - __in_opt PCSTR SrvPath, - __in PCSTR File, - __out_ecount(Size) PSTR Index, - __in size_t Size, - __in DWORD Flags - ); - -typedef struct { - DWORD sizeofstruct; - char file[MAX_PATH +1]; - BOOL stripped; - DWORD timestamp; - DWORD size; - char dbgfile[MAX_PATH +1]; - char pdbfile[MAX_PATH + 1]; - GUID guid; - DWORD sig; - DWORD age; -} SYMSRV_INDEX_INFO, *PSYMSRV_INDEX_INFO; - -typedef struct { - DWORD sizeofstruct; - WCHAR file[MAX_PATH +1]; - BOOL stripped; - DWORD timestamp; - DWORD size; - WCHAR dbgfile[MAX_PATH +1]; - WCHAR pdbfile[MAX_PATH + 1]; - GUID guid; - DWORD sig; - DWORD age; -} SYMSRV_INDEX_INFOW, *PSYMSRV_INDEX_INFOW; - -BOOL -IMAGEAPI -SymSrvGetFileIndexInfo( - __in PCSTR File, - __out PSYMSRV_INDEX_INFO Info, - __in DWORD Flags - ); - -BOOL -IMAGEAPI -SymSrvGetFileIndexInfoW( - __in PCWSTR File, - __out PSYMSRV_INDEX_INFOW Info, - __in DWORD Flags - ); - -PCSTR -IMAGEAPI -SymSrvStoreSupplement( - __in HANDLE hProcess, - __in_opt PCSTR SrvPath, - __in PCSTR Node, - __in PCSTR File, - __in DWORD Flags - ); - -PCWSTR -IMAGEAPI -SymSrvStoreSupplementW( - __in HANDLE hProcess, - __in_opt PCWSTR SymPath, - __in PCWSTR Node, - __in PCWSTR File, - __in DWORD Flags - ); - -PCSTR -IMAGEAPI -SymSrvStoreFile( - __in HANDLE hProcess, - __in_opt PCSTR SrvPath, - __in PCSTR File, - __in DWORD Flags - ); - -PCWSTR -IMAGEAPI -SymSrvStoreFileW( - __in HANDLE hProcess, - __in_opt PCWSTR SrvPath, - __in PCWSTR File, - __in DWORD Flags - ); - -// used by SymGetSymbolFile's "Type" parameter - -enum { - sfImage = 0, - sfDbg, - sfPdb, - sfMpd, - sfMax -}; - -BOOL -IMAGEAPI -SymGetSymbolFile( - __in_opt HANDLE hProcess, - __in_opt PCSTR SymPath, - __in PCSTR ImageFile, - __in DWORD Type, - __out_ecount(cSymbolFile) PSTR SymbolFile, - __in size_t cSymbolFile, - __out_ecount(cDbgFile) PSTR DbgFile, - __in size_t cDbgFile - ); - -BOOL -IMAGEAPI -SymGetSymbolFileW( - __in_opt HANDLE hProcess, - __in_opt PCWSTR SymPath, - __in PCWSTR ImageFile, - __in DWORD Type, - __out_ecount(cSymbolFile) PWSTR SymbolFile, - __in size_t cSymbolFile, - __out_ecount(cDbgFile) PWSTR DbgFile, - __in size_t cDbgFile - ); - -// -// Full user-mode dump creation. -// - -typedef BOOL (WINAPI *PDBGHELP_CREATE_USER_DUMP_CALLBACK)( - __in DWORD DataType, - __in PVOID* Data, - __out LPDWORD DataLength, - __in_opt PVOID UserData - ); - -BOOL -WINAPI -DbgHelpCreateUserDump( - __in_opt LPCSTR FileName, - __in PDBGHELP_CREATE_USER_DUMP_CALLBACK Callback, - __in_opt PVOID UserData - ); - -BOOL -WINAPI -DbgHelpCreateUserDumpW( - __in_opt LPCWSTR FileName, - __in PDBGHELP_CREATE_USER_DUMP_CALLBACK Callback, - __in_opt PVOID UserData - ); - -// ----------------------------------------------------------------- -// The following 4 legacy APIs are fully supported, but newer -// ones are recommended. SymFromName and SymFromAddr provide -// much more detailed info on the returned symbol. - -BOOL -IMAGEAPI -SymGetSymFromAddr64( - __in HANDLE hProcess, - __in DWORD64 qwAddr, - __out_opt PDWORD64 pdwDisplacement, - __inout PIMAGEHLP_SYMBOL64 Symbol - ); - - -#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) -#define SymGetSymFromAddr SymGetSymFromAddr64 -#else -BOOL -IMAGEAPI -SymGetSymFromAddr( - __in HANDLE hProcess, - __in DWORD dwAddr, - __out_opt PDWORD pdwDisplacement, - __inout PIMAGEHLP_SYMBOL Symbol - ); -#endif - -// While following two APIs will provide a symbol from a name, -// SymEnumSymbols can provide the same matching information -// for ALL symbols with a matching name, even regular -// expressions. That way you can search across modules -// and differentiate between identically named symbols. - -BOOL -IMAGEAPI -SymGetSymFromName64( - __in HANDLE hProcess, - __in PCSTR Name, - __inout PIMAGEHLP_SYMBOL64 Symbol - ); - -#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) -#define SymGetSymFromName SymGetSymFromName64 -#else -BOOL -IMAGEAPI -SymGetSymFromName( - __in HANDLE hProcess, - __in PCSTR Name, - __inout PIMAGEHLP_SYMBOL Symbol - ); -#endif - - -// Symbol server exports - -typedef BOOL (WINAPI *PSYMBOLSERVERPROC)(PCSTR, PCSTR, PVOID, DWORD, DWORD, PSTR); -typedef BOOL (WINAPI *PSYMBOLSERVERPROCA)(PCSTR, PCSTR, PVOID, DWORD, DWORD, PSTR); -typedef BOOL (WINAPI *PSYMBOLSERVERPROCW)(PCWSTR, PCWSTR, PVOID, DWORD, DWORD, PWSTR); -typedef BOOL (WINAPI *PSYMBOLSERVERBYINDEXPROC)(PCSTR, PCSTR, PCSTR, PSTR); -typedef BOOL (WINAPI *PSYMBOLSERVERBYINDEXPROCA)(PCSTR, PCSTR, PCSTR, PSTR); -typedef BOOL (WINAPI *PSYMBOLSERVERBYINDEXPROCW)(PCWSTR, PCWSTR, PCWSTR, PWSTR); -typedef BOOL (WINAPI *PSYMBOLSERVEROPENPROC)(VOID); -typedef BOOL (WINAPI *PSYMBOLSERVERCLOSEPROC)(VOID); -typedef BOOL (WINAPI *PSYMBOLSERVERSETOPTIONSPROC)(UINT_PTR, ULONG64); -typedef BOOL (WINAPI *PSYMBOLSERVERSETOPTIONSWPROC)(UINT_PTR, ULONG64); -typedef BOOL (CALLBACK WINAPI *PSYMBOLSERVERCALLBACKPROC)(UINT_PTR action, ULONG64 data, ULONG64 context); -typedef UINT_PTR (WINAPI *PSYMBOLSERVERGETOPTIONSPROC)(); -typedef BOOL (WINAPI *PSYMBOLSERVERPINGPROC)(PCSTR); -typedef BOOL (WINAPI *PSYMBOLSERVERPINGPROCA)(PCSTR); -typedef BOOL (WINAPI *PSYMBOLSERVERPINGPROCW)(PCWSTR); -typedef BOOL (WINAPI *PSYMBOLSERVERGETVERSION)(LPAPI_VERSION); -typedef BOOL (WINAPI *PSYMBOLSERVERDELTANAME)(PCSTR, PVOID, DWORD, DWORD, PVOID, DWORD, DWORD, PSTR, size_t); -typedef BOOL (WINAPI *PSYMBOLSERVERDELTANAMEW)(PCWSTR, PVOID, DWORD, DWORD, PVOID, DWORD, DWORD, PWSTR, size_t); -typedef BOOL (WINAPI *PSYMBOLSERVERGETSUPPLEMENT)(PCSTR, PCSTR, PCSTR, PSTR, size_t); -typedef BOOL (WINAPI *PSYMBOLSERVERGETSUPPLEMENTW)(PCWSTR, PCWSTR, PCWSTR, PWSTR, size_t); -typedef BOOL (WINAPI *PSYMBOLSERVERSTORESUPPLEMENT)(PCSTR, PCSTR, PCSTR, PSTR, size_t, DWORD); -typedef BOOL (WINAPI *PSYMBOLSERVERSTORESUPPLEMENTW)(PCWSTR, PCWSTR, PCWSTR, PWSTR, size_t, DWORD); -typedef BOOL (WINAPI *PSYMBOLSERVERGETINDEXSTRING)(PVOID, DWORD, DWORD, PSTR, size_t); -typedef BOOL (WINAPI *PSYMBOLSERVERGETINDEXSTRINGW)(PVOID, DWORD, DWORD, PWSTR, size_t); -typedef BOOL (WINAPI *PSYMBOLSERVERSTOREFILE)(PCSTR, PCSTR, PVOID, DWORD, DWORD, PSTR, size_t, DWORD); -typedef BOOL (WINAPI *PSYMBOLSERVERSTOREFILEW)(PCWSTR, PCWSTR, PVOID, DWORD, DWORD, PWSTR, size_t, DWORD); -typedef BOOL (WINAPI *PSYMBOLSERVERISSTORE)(PCSTR); -typedef BOOL (WINAPI *PSYMBOLSERVERISSTOREW)(PCWSTR); -typedef DWORD (WINAPI *PSYMBOLSERVERVERSION)(); -typedef BOOL (CALLBACK WINAPI *PSYMBOLSERVERMESSAGEPROC)(UINT_PTR action, ULONG64 data, ULONG64 context); - -#define SYMSRV_VERSION 2 - -#define SSRVOPT_CALLBACK 0x00000001 -#define SSRVOPT_DWORD 0x00000002 -#define SSRVOPT_DWORDPTR 0x00000004 -#define SSRVOPT_GUIDPTR 0x00000008 -#define SSRVOPT_OLDGUIDPTR 0x00000010 -#define SSRVOPT_UNATTENDED 0x00000020 -#define SSRVOPT_NOCOPY 0x00000040 -#define SSRVOPT_GETPATH 0x00000040 -#define SSRVOPT_PARENTWIN 0x00000080 -#define SSRVOPT_PARAMTYPE 0x00000100 -#define SSRVOPT_SECURE 0x00000200 -#define SSRVOPT_TRACE 0x00000400 -#define SSRVOPT_SETCONTEXT 0x00000800 -#define SSRVOPT_PROXY 0x00001000 -#define SSRVOPT_DOWNSTREAM_STORE 0x00002000 -#define SSRVOPT_OVERWRITE 0x00004000 -#define SSRVOPT_RESETTOU 0x00008000 -#define SSRVOPT_CALLBACKW 0x00010000 -#define SSRVOPT_FLAT_DEFAULT_STORE 0x00020000 -#define SSRVOPT_PROXYW 0x00040000 -#define SSRVOPT_MESSAGE 0x00080000 -#define SSRVOPT_SERVICE 0x00100000 // deprecated -#define SSRVOPT_FAVOR_COMPRESSED 0x00200000 -#define SSRVOPT_STRING 0x00400000 -#define SSRVOPT_WINHTTP 0x00800000 -#define SSRVOPT_WININET 0x01000000 - -#define SSRVOPT_MAX 0x0100000 - -#define SSRVOPT_RESET ((ULONG_PTR)-1) - - -#define NUM_SSRVOPTS 30 - -#define SSRVACTION_TRACE 1 -#define SSRVACTION_QUERYCANCEL 2 -#define SSRVACTION_EVENT 3 -#define SSRVACTION_EVENTW 4 -#define SSRVACTION_SIZE 5 - -#define SYMSTOREOPT_COMPRESS 0x01 -#define SYMSTOREOPT_OVERWRITE 0x02 -#define SYMSTOREOPT_RETURNINDEX 0x04 -#define SYMSTOREOPT_POINTER 0x08 -#define SYMSTOREOPT_ALT_INDEX 0x10 -#define SYMSTOREOPT_UNICODE 0x20 -#define SYMSTOREOPT_PASS_IF_EXISTS 0x40 - -#ifdef DBGHELP_TRANSLATE_TCHAR - #define SymInitialize SymInitializeW - #define SymAddSymbol SymAddSymbolW - #define SymDeleteSymbol SymDeleteSymbolW - #define SearchTreeForFile SearchTreeForFileW - #define UnDecorateSymbolName UnDecorateSymbolNameW - #define SymGetLineFromName64 SymGetLineFromNameW64 - #define SymGetLineFromAddr64 SymGetLineFromAddrW64 - #define SymGetLineNext64 SymGetLineNextW64 - #define SymGetLinePrev64 SymGetLinePrevW64 - #define SymFromName SymFromNameW - #define SymFindExecutableImage SymFindExecutableImageW - #define FindExecutableImageEx FindExecutableImageExW - #define SymSearch SymSearchW - #define SymEnumLines SymEnumLinesW - #define SymEnumSourceLines SymEnumSourceLinesW - #define SymGetTypeFromName SymGetTypeFromNameW - #define SymEnumSymbolsForAddr SymEnumSymbolsForAddrW - #define SymFromAddr SymFromAddrW - #define SymMatchString SymMatchStringW - #define SymEnumSourceFiles SymEnumSourceFilesW - #define SymEnumSymbols SymEnumSymbolsW - #define SymLoadModuleEx SymLoadModuleExW - #define SymSetSearchPath SymSetSearchPathW - #define SymGetSearchPath SymGetSearchPathW - #define EnumDirTree EnumDirTreeW - #define SymFromToken SymFromTokenW - #define SymFromIndex SymFromIndexW - #define SymGetScope SymGetScopeW - #define SymNext SymNextW - #define SymPrev SymPrevW - #define SymEnumTypes SymEnumTypesW - #define SymEnumTypesByName SymEnumTypesByNameW - #define SymRegisterCallback64 SymRegisterCallbackW64 - #define SymFindDebugInfoFile SymFindDebugInfoFileW - #define FindDebugInfoFileEx FindDebugInfoFileExW - #define SymFindFileInPath SymFindFileInPathW - #define SymEnumerateModules64 SymEnumerateModulesW64 - #define SymSetHomeDirectory SymSetHomeDirectoryW - #define SymGetHomeDirectory SymGetHomeDirectoryW - #define SymGetSourceFile SymGetSourceFileW - #define SymGetSourceFileToken SymGetSourceFileTokenW - #define SymGetSourceFileFromToken SymGetSourceFileFromTokenW - #define SymGetSourceVarFromToken SymGetSourceVarFromTokenW - #define SymGetSourceFileToken SymGetSourceFileTokenW - #define SymGetFileLineOffsets64 SymGetFileLineOffsetsW64 - #define SymFindFileInPath SymFindFileInPathW - #define SymMatchFileName SymMatchFileNameW - #define SymGetSourceFileFromToken SymGetSourceFileFromTokenW - #define SymGetSourceVarFromToken SymGetSourceVarFromTokenW - #define SymGetModuleInfo64 SymGetModuleInfoW64 - #define SymSrvIsStore SymSrvIsStoreW - #define SymSrvDeltaName SymSrvDeltaNameW - #define SymSrvGetSupplement SymSrvGetSupplementW - #define SymSrvStoreSupplement SymSrvStoreSupplementW - #define SymSrvGetFileIndexes SymSrvGetFileIndexes - #define SymSrvGetFileIndexString SymSrvGetFileIndexStringW - #define SymSrvStoreFile SymSrvStoreFileW - #define SymGetSymbolFile SymGetSymbolFileW - #define EnumerateLoadedModules64 EnumerateLoadedModulesW64 - #define EnumerateLoadedModulesEx EnumerateLoadedModulesExW - #define SymSrvGetFileIndexInfo SymSrvGetFileIndexInfoW - - #define IMAGEHLP_LINE64 IMAGEHLP_LINEW64 - #define PIMAGEHLP_LINE64 PIMAGEHLP_LINEW64 - #define SYMBOL_INFO SYMBOL_INFOW - #define PSYMBOL_INFO PSYMBOL_INFOW - #define SYMBOL_INFO_PACKAGE SYMBOL_INFO_PACKAGEW - #define PSYMBOL_INFO_PACKAGE PSYMBOL_INFO_PACKAGEW - #define FIND_EXE_FILE_CALLBACK FIND_EXE_FILE_CALLBACKW - #define PFIND_EXE_FILE_CALLBACK PFIND_EXE_FILE_CALLBACKW - #define SYM_ENUMERATESYMBOLS_CALLBACK SYM_ENUMERATESYMBOLS_CALLBACKW - #define PSYM_ENUMERATESYMBOLS_CALLBACK PSYM_ENUMERATESYMBOLS_CALLBACKW - #define SRCCODEINFO SRCCODEINFOW - #define PSRCCODEINFO PSRCCODEINFOW - #define SOURCEFILE SOURCEFILEW - #define PSOURCEFILE PSOURCEFILEW - #define SYM_ENUMSOURECFILES_CALLBACK SYM_ENUMSOURCEFILES_CALLBACKW - #define PSYM_ENUMSOURCEFILES_CALLBACK PSYM_ENUMSOURECFILES_CALLBACKW - #define IMAGEHLP_CBA_EVENT IMAGEHLP_CBA_EVENTW - #define PIMAGEHLP_CBA_EVENT PIMAGEHLP_CBA_EVENTW - #define PENUMDIRTREE_CALLBACK PENUMDIRTREE_CALLBACKW - #define IMAGEHLP_DEFERRED_SYMBOL_LOAD64 IMAGEHLP_DEFERRED_SYMBOL_LOADW64 - #define PIMAGEHLP_DEFERRED_SYMBOL_LOAD64 PIMAGEHLP_DEFERRED_SYMBOL_LOADW64 - #define PFIND_DEBUG_FILE_CALLBACK PFIND_DEBUG_FILE_CALLBACKW - #define PFINDFILEINPATHCALLBACK PFINDFILEINPATHCALLBACKW - #define IMAGEHLP_MODULE64 IMAGEHLP_MODULEW64 - #define PIMAGEHLP_MODULE64 PIMAGEHLP_MODULEW64 - #define SYMSRV_INDEX_INFO SYMSRV_INDEX_INFOW - #define PSYMSRV_INDEX_INFO PSYMSRV_INDEX_INFOW - - #define PSYMBOLSERVERPROC PSYMBOLSERVERPROCW - #define PSYMBOLSERVERPINGPROC PSYMBOLSERVERPINGPROCW -#endif - -// ----------------------------------------------------------------- -// The following APIs exist only for backwards compatibility -// with a pre-release version documented in an MSDN release. - -// You should use SymFindFileInPath if you want to maintain -// future compatibility. - -DBHLP_DEPRECIATED -BOOL -IMAGEAPI -FindFileInPath( - __in HANDLE hprocess, - __in PCSTR SearchPath, - __in PCSTR FileName, - __in PVOID id, - __in DWORD two, - __in DWORD three, - __in DWORD flags, - __out_ecount(MAX_PATH + 1) PSTR FilePath - ); - -// You should use SymFindFileInPath if you want to maintain -// future compatibility. - -DBHLP_DEPRECIATED -BOOL -IMAGEAPI -FindFileInSearchPath( - __in HANDLE hprocess, - __in PCSTR SearchPath, - __in PCSTR FileName, - __in DWORD one, - __in DWORD two, - __in DWORD three, - __out_ecount(MAX_PATH + 1) PSTR FilePath - ); - -DBHLP_DEPRECIATED -BOOL -IMAGEAPI -SymEnumSym( - __in HANDLE hProcess, - __in ULONG64 BaseOfDll, - __in PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback, - __in_opt PVOID UserContext - ); - -DBHLP_DEPRECIATED -BOOL -IMAGEAPI -SymEnumerateSymbols64( - __in HANDLE hProcess, - __in ULONG64 BaseOfDll, - __in PSYM_ENUMSYMBOLS_CALLBACK64 EnumSymbolsCallback, - __in_opt PVOID UserContext - ); - -DBHLP_DEPRECIATED -BOOL -IMAGEAPI -SymEnumerateSymbolsW64( - __in HANDLE hProcess, - __in ULONG64 BaseOfDll, - __in PSYM_ENUMSYMBOLS_CALLBACK64W EnumSymbolsCallback, - __in_opt PVOID UserContext - ); - - -#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) -#define SymEnumerateSymbols SymEnumerateSymbols64 -#define SymEnumerateSymbolsW SymEnumerateSymbolsW64 -#else -DBHLP_DEPRECIATED -BOOL -IMAGEAPI -SymEnumerateSymbols( - __in HANDLE hProcess, - __in ULONG BaseOfDll, - __in PSYM_ENUMSYMBOLS_CALLBACK EnumSymbolsCallback, - __in_opt PVOID UserContext - ); - -DBHLP_DEPRECIATED -BOOL -IMAGEAPI -SymEnumerateSymbolsW( - __in HANDLE hProcess, - __in ULONG BaseOfDll, - __in PSYM_ENUMSYMBOLS_CALLBACKW EnumSymbolsCallback, - __in_opt PVOID UserContext - ); -#endif - -// use SymLoadModuleEx - -DWORD64 -IMAGEAPI -SymLoadModule64( - __in HANDLE hProcess, - __in_opt HANDLE hFile, - __in_opt PCSTR ImageName, - __in_opt PCSTR ModuleName, - __in DWORD64 BaseOfDll, - __in DWORD SizeOfDll - ); - -#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) -#define SymLoadModule SymLoadModule64 -#else -DWORD -IMAGEAPI -SymLoadModule( - __in HANDLE hProcess, - __in_opt HANDLE hFile, - __in_opt PCSTR ImageName, - __in_opt PCSTR ModuleName, - __in DWORD BaseOfDll, - __in DWORD SizeOfDll - ); -#endif - -BOOL -IMAGEAPI -SymGetSymNext64( - __in HANDLE hProcess, - __inout PIMAGEHLP_SYMBOL64 Symbol - ); - -BOOL -IMAGEAPI -SymGetSymNextW64( - __in HANDLE hProcess, - __inout PIMAGEHLP_SYMBOLW64 Symbol - ); - -#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) -#define SymGetSymNext SymGetSymNext64 -#define SymGetSymNextW SymGetSymNextW64 -#else -BOOL -IMAGEAPI -SymGetSymNext( - __in HANDLE hProcess, - __inout PIMAGEHLP_SYMBOL Symbol - ); - -BOOL -IMAGEAPI -SymGetSymNextW( - __in HANDLE hProcess, - __inout PIMAGEHLP_SYMBOLW Symbol - ); -#endif - -BOOL -IMAGEAPI -SymGetSymPrev64( - __in HANDLE hProcess, - __inout PIMAGEHLP_SYMBOL64 Symbol - ); - -BOOL -IMAGEAPI -SymGetSymPrevW64( - __in HANDLE hProcess, - __inout PIMAGEHLP_SYMBOLW64 Symbol - ); - -#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64) -#define SymGetSymPrev SymGetSymPrev64 -#define SymGetSymPrevW SymGetSymPrevW64 -#else -BOOL -IMAGEAPI -SymGetSymPrev( - __in HANDLE hProcess, - __inout PIMAGEHLP_SYMBOL Symbol - ); - -BOOL -IMAGEAPI -SymGetSymPrevW( - __in HANDLE hProcess, - __inout PIMAGEHLP_SYMBOLW Symbol - ); -#endif - - -// These values should not be used. -// They have been replaced by SYMFLAG_ values. - -#define SYMF_OMAP_GENERATED 0x00000001 -#define SYMF_OMAP_MODIFIED 0x00000002 -#define SYMF_REGISTER 0x00000008 -#define SYMF_REGREL 0x00000010 -#define SYMF_FRAMEREL 0x00000020 -#define SYMF_PARAMETER 0x00000040 -#define SYMF_LOCAL 0x00000080 -#define SYMF_CONSTANT 0x00000100 -#define SYMF_EXPORT 0x00000200 -#define SYMF_FORWARDER 0x00000400 -#define SYMF_FUNCTION 0x00000800 -#define SYMF_VIRTUAL 0x00001000 -#define SYMF_THUNK 0x00002000 -#define SYMF_TLSREL 0x00004000 - -// These values should also not be used. -// They have been replaced by SYMFLAG_ values. - -#define IMAGEHLP_SYMBOL_INFO_VALUEPRESENT 1 -#define IMAGEHLP_SYMBOL_INFO_REGISTER SYMF_REGISTER // 0x0008 -#define IMAGEHLP_SYMBOL_INFO_REGRELATIVE SYMF_REGREL // 0x0010 -#define IMAGEHLP_SYMBOL_INFO_FRAMERELATIVE SYMF_FRAMEREL // 0x0020 -#define IMAGEHLP_SYMBOL_INFO_PARAMETER SYMF_PARAMETER // 0x0040 -#define IMAGEHLP_SYMBOL_INFO_LOCAL SYMF_LOCAL // 0x0080 -#define IMAGEHLP_SYMBOL_INFO_CONSTANT SYMF_CONSTANT // 0x0100 -#define IMAGEHLP_SYMBOL_FUNCTION SYMF_FUNCTION // 0x0800 -#define IMAGEHLP_SYMBOL_VIRTUAL SYMF_VIRTUAL // 0x1000 -#define IMAGEHLP_SYMBOL_THUNK SYMF_THUNK // 0x2000 -#define IMAGEHLP_SYMBOL_INFO_TLSRELATIVE SYMF_TLSREL // 0x4000 - - -#include - -#if defined(_MSC_VER) -#if _MSC_VER >= 800 -#if _MSC_VER >= 1200 -#pragma warning(push) -#endif -#pragma warning(disable:4200) /* Zero length array */ -#pragma warning(disable:4201) /* Nameless struct/union */ -#endif -#endif - -#define MINIDUMP_SIGNATURE ('PMDM') -#define MINIDUMP_VERSION (42899) -typedef DWORD RVA; -typedef ULONG64 RVA64; - -typedef struct _MINIDUMP_LOCATION_DESCRIPTOR { - ULONG32 DataSize; - RVA Rva; -} MINIDUMP_LOCATION_DESCRIPTOR; - -typedef struct _MINIDUMP_LOCATION_DESCRIPTOR64 { - ULONG64 DataSize; - RVA64 Rva; -} MINIDUMP_LOCATION_DESCRIPTOR64; - - -typedef struct _MINIDUMP_MEMORY_DESCRIPTOR { - ULONG64 StartOfMemoryRange; - MINIDUMP_LOCATION_DESCRIPTOR Memory; -} MINIDUMP_MEMORY_DESCRIPTOR, *PMINIDUMP_MEMORY_DESCRIPTOR; - -// DESCRIPTOR64 is used for full-memory minidumps where -// all of the raw memory is laid out sequentially at the -// end of the dump. There is no need for individual RVAs -// as the RVA is the base RVA plus the sum of the preceeding -// data blocks. -typedef struct _MINIDUMP_MEMORY_DESCRIPTOR64 { - ULONG64 StartOfMemoryRange; - ULONG64 DataSize; -} MINIDUMP_MEMORY_DESCRIPTOR64, *PMINIDUMP_MEMORY_DESCRIPTOR64; - - -typedef struct _MINIDUMP_HEADER { - ULONG32 Signature; - ULONG32 Version; - ULONG32 NumberOfStreams; - RVA StreamDirectoryRva; - ULONG32 CheckSum; - union { - ULONG32 Reserved; - ULONG32 TimeDateStamp; - }; - ULONG64 Flags; -} MINIDUMP_HEADER, *PMINIDUMP_HEADER; - -// -// The MINIDUMP_HEADER field StreamDirectoryRva points to -// an array of MINIDUMP_DIRECTORY structures. -// - -typedef struct _MINIDUMP_DIRECTORY { - ULONG32 StreamType; - MINIDUMP_LOCATION_DESCRIPTOR Location; -} MINIDUMP_DIRECTORY, *PMINIDUMP_DIRECTORY; - - -typedef struct _MINIDUMP_STRING { - ULONG32 Length; // Length in bytes of the string - WCHAR Buffer [0]; // Variable size buffer -} MINIDUMP_STRING, *PMINIDUMP_STRING; - - - -// -// The MINIDUMP_DIRECTORY field StreamType may be one of the following types. -// Types will be added in the future, so if a program reading the minidump -// header encounters a stream type it does not understand it should ignore -// the data altogether. Any tag above LastReservedStream will not be used by -// the system and is reserved for program-specific information. -// - -typedef enum _MINIDUMP_STREAM_TYPE { - - UnusedStream = 0, - ReservedStream0 = 1, - ReservedStream1 = 2, - ThreadListStream = 3, - ModuleListStream = 4, - MemoryListStream = 5, - ExceptionStream = 6, - SystemInfoStream = 7, - ThreadExListStream = 8, - Memory64ListStream = 9, - CommentStreamA = 10, - CommentStreamW = 11, - HandleDataStream = 12, - FunctionTableStream = 13, - UnloadedModuleListStream = 14, - MiscInfoStream = 15, - MemoryInfoListStream = 16, - ThreadInfoListStream = 17, - HandleOperationListStream = 18, - - ceStreamNull = 0x8000, - ceStreamSystemInfo = 0x8001, - ceStreamException = 0x8002, - ceStreamModuleList = 0x8003, - ceStreamProcessList = 0x8004, - ceStreamThreadList = 0x8005, - ceStreamThreadContextList = 0x8006, - ceStreamThreadCallStackList = 0x8007, - ceStreamMemoryVirtualList = 0x8008, - ceStreamMemoryPhysicalList = 0x8009, - ceStreamBucketParameters = 0x800A, - - LastReservedStream = 0xffff - -} MINIDUMP_STREAM_TYPE; - - -// -// The minidump system information contains processor and -// Operating System specific information. -// - -// -// CPU information is obtained from one of two places. -// -// 1) On x86 computers, CPU_INFORMATION is obtained from the CPUID -// instruction. You must use the X86 portion of the union for X86 -// computers. -// -// 2) On non-x86 architectures, CPU_INFORMATION is obtained by calling -// IsProcessorFeatureSupported(). -// - -typedef union _CPU_INFORMATION { - - // - // X86 platforms use CPUID function to obtain processor information. - // - - struct { - - // - // CPUID Subfunction 0, register EAX (VendorId [0]), - // EBX (VendorId [1]) and ECX (VendorId [2]). - // - - ULONG32 VendorId [ 3 ]; - - // - // CPUID Subfunction 1, register EAX - // - - ULONG32 VersionInformation; - - // - // CPUID Subfunction 1, register EDX - // - - ULONG32 FeatureInformation; - - - // - // CPUID, Subfunction 80000001, register EBX. This will only - // be obtained if the vendor id is "AuthenticAMD". - // - - ULONG32 AMDExtendedCpuFeatures; - - } X86CpuInfo; - - // - // Non-x86 platforms use processor feature flags. - // - - struct { - - ULONG64 ProcessorFeatures [ 2 ]; - - } OtherCpuInfo; - -} CPU_INFORMATION, *PCPU_INFORMATION; - -typedef struct _MINIDUMP_SYSTEM_INFO { - - // - // ProcessorArchitecture, ProcessorLevel and ProcessorRevision are all - // taken from the SYSTEM_INFO structure obtained by GetSystemInfo( ). - // - - USHORT ProcessorArchitecture; - USHORT ProcessorLevel; - USHORT ProcessorRevision; - - union { - USHORT Reserved0; - struct { - UCHAR NumberOfProcessors; - UCHAR ProductType; - }; - }; - - // - // MajorVersion, MinorVersion, BuildNumber, PlatformId and - // CSDVersion are all taken from the OSVERSIONINFO structure - // returned by GetVersionEx( ). - // - - ULONG32 MajorVersion; - ULONG32 MinorVersion; - ULONG32 BuildNumber; - ULONG32 PlatformId; - - // - // RVA to a CSDVersion string in the string table. - // - - RVA CSDVersionRva; - - union { - ULONG32 Reserved1; - struct { - USHORT SuiteMask; - USHORT Reserved2; - }; - }; - - CPU_INFORMATION Cpu; - -} MINIDUMP_SYSTEM_INFO, *PMINIDUMP_SYSTEM_INFO; - - -// -// The minidump thread contains standard thread -// information plus an RVA to the memory for this -// thread and an RVA to the CONTEXT structure for -// this thread. -// - - -// -// ThreadId must be 4 bytes on all architectures. -// - -C_ASSERT (sizeof ( ((PPROCESS_INFORMATION)0)->dwThreadId ) == 4); - -typedef struct _MINIDUMP_THREAD { - ULONG32 ThreadId; - ULONG32 SuspendCount; - ULONG32 PriorityClass; - ULONG32 Priority; - ULONG64 Teb; - MINIDUMP_MEMORY_DESCRIPTOR Stack; - MINIDUMP_LOCATION_DESCRIPTOR ThreadContext; -} MINIDUMP_THREAD, *PMINIDUMP_THREAD; - -// -// The thread list is a container of threads. -// - -typedef struct _MINIDUMP_THREAD_LIST { - ULONG32 NumberOfThreads; - MINIDUMP_THREAD Threads [0]; -} MINIDUMP_THREAD_LIST, *PMINIDUMP_THREAD_LIST; - - -typedef struct _MINIDUMP_THREAD_EX { - ULONG32 ThreadId; - ULONG32 SuspendCount; - ULONG32 PriorityClass; - ULONG32 Priority; - ULONG64 Teb; - MINIDUMP_MEMORY_DESCRIPTOR Stack; - MINIDUMP_LOCATION_DESCRIPTOR ThreadContext; - MINIDUMP_MEMORY_DESCRIPTOR BackingStore; -} MINIDUMP_THREAD_EX, *PMINIDUMP_THREAD_EX; - -// -// The thread list is a container of threads. -// - -typedef struct _MINIDUMP_THREAD_EX_LIST { - ULONG32 NumberOfThreads; - MINIDUMP_THREAD_EX Threads [0]; -} MINIDUMP_THREAD_EX_LIST, *PMINIDUMP_THREAD_EX_LIST; - - -// -// The MINIDUMP_EXCEPTION is the same as EXCEPTION on Win64. -// - -typedef struct _MINIDUMP_EXCEPTION { - ULONG32 ExceptionCode; - ULONG32 ExceptionFlags; - ULONG64 ExceptionRecord; - ULONG64 ExceptionAddress; - ULONG32 NumberParameters; - ULONG32 __unusedAlignment; - ULONG64 ExceptionInformation [ EXCEPTION_MAXIMUM_PARAMETERS ]; -} MINIDUMP_EXCEPTION, *PMINIDUMP_EXCEPTION; - - -// -// The exception information stream contains the id of the thread that caused -// the exception (ThreadId), the exception record for the exception -// (ExceptionRecord) and an RVA to the thread context where the exception -// occured. -// - -typedef struct MINIDUMP_EXCEPTION_STREAM { - ULONG32 ThreadId; - ULONG32 __alignment; - MINIDUMP_EXCEPTION ExceptionRecord; - MINIDUMP_LOCATION_DESCRIPTOR ThreadContext; -} MINIDUMP_EXCEPTION_STREAM, *PMINIDUMP_EXCEPTION_STREAM; - - -// -// The MINIDUMP_MODULE contains information about a -// a specific module. It includes the CheckSum and -// the TimeDateStamp for the module so the module -// can be reloaded during the analysis phase. -// - -typedef struct _MINIDUMP_MODULE { - ULONG64 BaseOfImage; - ULONG32 SizeOfImage; - ULONG32 CheckSum; - ULONG32 TimeDateStamp; - RVA ModuleNameRva; - VS_FIXEDFILEINFO VersionInfo; - MINIDUMP_LOCATION_DESCRIPTOR CvRecord; - MINIDUMP_LOCATION_DESCRIPTOR MiscRecord; - ULONG64 Reserved0; // Reserved for future use. - ULONG64 Reserved1; // Reserved for future use. -} MINIDUMP_MODULE, *PMINIDUMP_MODULE; - - -// -// The minidump module list is a container for modules. -// - -typedef struct _MINIDUMP_MODULE_LIST { - ULONG32 NumberOfModules; - MINIDUMP_MODULE Modules [ 0 ]; -} MINIDUMP_MODULE_LIST, *PMINIDUMP_MODULE_LIST; - - -// -// Memory Ranges -// - -typedef struct _MINIDUMP_MEMORY_LIST { - ULONG32 NumberOfMemoryRanges; - MINIDUMP_MEMORY_DESCRIPTOR MemoryRanges [0]; -} MINIDUMP_MEMORY_LIST, *PMINIDUMP_MEMORY_LIST; - -typedef struct _MINIDUMP_MEMORY64_LIST { - ULONG64 NumberOfMemoryRanges; - RVA64 BaseRva; - MINIDUMP_MEMORY_DESCRIPTOR64 MemoryRanges [0]; -} MINIDUMP_MEMORY64_LIST, *PMINIDUMP_MEMORY64_LIST; - - -// -// Support for user supplied exception information. -// - -typedef struct _MINIDUMP_EXCEPTION_INFORMATION { - DWORD ThreadId; - PEXCEPTION_POINTERS ExceptionPointers; - BOOL ClientPointers; -} MINIDUMP_EXCEPTION_INFORMATION, *PMINIDUMP_EXCEPTION_INFORMATION; - -typedef struct _MINIDUMP_EXCEPTION_INFORMATION64 { - DWORD ThreadId; - ULONG64 ExceptionRecord; - ULONG64 ContextRecord; - BOOL ClientPointers; -} MINIDUMP_EXCEPTION_INFORMATION64, *PMINIDUMP_EXCEPTION_INFORMATION64; - - -// -// Support for capturing system handle state at the time of the dump. -// - -// Per-handle object information varies according to -// the OS, the OS version, the processor type and -// so on. The minidump gives a minidump identifier -// to each possible data format for identification -// purposes but does not control nor describe the actual data. -typedef enum _MINIDUMP_HANDLE_OBJECT_INFORMATION_TYPE { - MiniHandleObjectInformationNone, - MiniThreadInformation1, - MiniMutantInformation1, - MiniMutantInformation2, - MiniProcessInformation1, - MiniProcessInformation2, - MiniHandleObjectInformationTypeMax -} MINIDUMP_HANDLE_OBJECT_INFORMATION_TYPE; - -typedef struct _MINIDUMP_HANDLE_OBJECT_INFORMATION { - RVA NextInfoRva; - ULONG32 InfoType; - ULONG32 SizeOfInfo; - // Raw information follows. -} MINIDUMP_HANDLE_OBJECT_INFORMATION; - -typedef struct _MINIDUMP_HANDLE_DESCRIPTOR { - ULONG64 Handle; - RVA TypeNameRva; - RVA ObjectNameRva; - ULONG32 Attributes; - ULONG32 GrantedAccess; - ULONG32 HandleCount; - ULONG32 PointerCount; -} MINIDUMP_HANDLE_DESCRIPTOR, *PMINIDUMP_HANDLE_DESCRIPTOR; - -typedef struct _MINIDUMP_HANDLE_DESCRIPTOR_2 { - ULONG64 Handle; - RVA TypeNameRva; - RVA ObjectNameRva; - ULONG32 Attributes; - ULONG32 GrantedAccess; - ULONG32 HandleCount; - ULONG32 PointerCount; - RVA ObjectInfoRva; - ULONG32 Reserved0; -} MINIDUMP_HANDLE_DESCRIPTOR_2, *PMINIDUMP_HANDLE_DESCRIPTOR_2; - -// The latest MINIDUMP_HANDLE_DESCRIPTOR definition. -typedef MINIDUMP_HANDLE_DESCRIPTOR_2 MINIDUMP_HANDLE_DESCRIPTOR_N; -typedef MINIDUMP_HANDLE_DESCRIPTOR_N *PMINIDUMP_HANDLE_DESCRIPTOR_N; - -typedef struct _MINIDUMP_HANDLE_DATA_STREAM { - ULONG32 SizeOfHeader; - ULONG32 SizeOfDescriptor; - ULONG32 NumberOfDescriptors; - ULONG32 Reserved; -} MINIDUMP_HANDLE_DATA_STREAM, *PMINIDUMP_HANDLE_DATA_STREAM; - -// Some operating systems can track the last operations -// performed on a handle. For example, Application Verifier -// can enable this for some versions of Windows. The -// handle operation list collects handle operations -// known for the dump target. -// Each entry is an AVRF_HANDLE_OPERATION. -typedef struct _MINIDUMP_HANDLE_OPERATION_LIST { - ULONG32 SizeOfHeader; - ULONG32 SizeOfEntry; - ULONG32 NumberOfEntries; - ULONG32 Reserved; -} MINIDUMP_HANDLE_OPERATION_LIST, *PMINIDUMP_HANDLE_OPERATION_LIST; - - -// -// Support for capturing dynamic function table state at the time of the dump. -// - -typedef struct _MINIDUMP_FUNCTION_TABLE_DESCRIPTOR { - ULONG64 MinimumAddress; - ULONG64 MaximumAddress; - ULONG64 BaseAddress; - ULONG32 EntryCount; - ULONG32 SizeOfAlignPad; -} MINIDUMP_FUNCTION_TABLE_DESCRIPTOR, *PMINIDUMP_FUNCTION_TABLE_DESCRIPTOR; - -typedef struct _MINIDUMP_FUNCTION_TABLE_STREAM { - ULONG32 SizeOfHeader; - ULONG32 SizeOfDescriptor; - ULONG32 SizeOfNativeDescriptor; - ULONG32 SizeOfFunctionEntry; - ULONG32 NumberOfDescriptors; - ULONG32 SizeOfAlignPad; -} MINIDUMP_FUNCTION_TABLE_STREAM, *PMINIDUMP_FUNCTION_TABLE_STREAM; - - -// -// The MINIDUMP_UNLOADED_MODULE contains information about a -// a specific module that was previously loaded but no -// longer is. This can help with diagnosing problems where -// callers attempt to call code that is no longer loaded. -// - -typedef struct _MINIDUMP_UNLOADED_MODULE { - ULONG64 BaseOfImage; - ULONG32 SizeOfImage; - ULONG32 CheckSum; - ULONG32 TimeDateStamp; - RVA ModuleNameRva; -} MINIDUMP_UNLOADED_MODULE, *PMINIDUMP_UNLOADED_MODULE; - - -// -// The minidump unloaded module list is a container for unloaded modules. -// - -typedef struct _MINIDUMP_UNLOADED_MODULE_LIST { - ULONG32 SizeOfHeader; - ULONG32 SizeOfEntry; - ULONG32 NumberOfEntries; -} MINIDUMP_UNLOADED_MODULE_LIST, *PMINIDUMP_UNLOADED_MODULE_LIST; - - -// -// The miscellaneous information stream contains a variety -// of small pieces of information. A member is valid if -// it's within the available size and its corresponding -// bit is set. -// - -#define MINIDUMP_MISC1_PROCESS_ID 0x00000001 -#define MINIDUMP_MISC1_PROCESS_TIMES 0x00000002 -#define MINIDUMP_MISC1_PROCESSOR_POWER_INFO 0x00000004 - -typedef struct _MINIDUMP_MISC_INFO { - ULONG32 SizeOfInfo; - ULONG32 Flags1; - ULONG32 ProcessId; - ULONG32 ProcessCreateTime; - ULONG32 ProcessUserTime; - ULONG32 ProcessKernelTime; -} MINIDUMP_MISC_INFO, *PMINIDUMP_MISC_INFO; - -typedef struct _MINIDUMP_MISC_INFO_2 { - ULONG32 SizeOfInfo; - ULONG32 Flags1; - ULONG32 ProcessId; - ULONG32 ProcessCreateTime; - ULONG32 ProcessUserTime; - ULONG32 ProcessKernelTime; - ULONG32 ProcessorMaxMhz; - ULONG32 ProcessorCurrentMhz; - ULONG32 ProcessorMhzLimit; - ULONG32 ProcessorMaxIdleState; - ULONG32 ProcessorCurrentIdleState; -} MINIDUMP_MISC_INFO_2, *PMINIDUMP_MISC_INFO_2; - -// The latest MINIDUMP_MISC_INFO definition. -typedef MINIDUMP_MISC_INFO_2 MINIDUMP_MISC_INFO_N; -typedef MINIDUMP_MISC_INFO_N* PMINIDUMP_MISC_INFO_N; - - -// -// The memory information stream contains memory region -// description information. This stream corresponds to -// what VirtualQuery would return for the process the -// dump was created for. -// - -typedef struct _MINIDUMP_MEMORY_INFO { - ULONG64 BaseAddress; - ULONG64 AllocationBase; - ULONG32 AllocationProtect; - ULONG32 __alignment1; - ULONG64 RegionSize; - ULONG32 State; - ULONG32 Protect; - ULONG32 Type; - ULONG32 __alignment2; -} MINIDUMP_MEMORY_INFO, *PMINIDUMP_MEMORY_INFO; - -typedef struct _MINIDUMP_MEMORY_INFO_LIST { - ULONG SizeOfHeader; - ULONG SizeOfEntry; - ULONG64 NumberOfEntries; -} MINIDUMP_MEMORY_INFO_LIST, *PMINIDUMP_MEMORY_INFO_LIST; - - -// -// The memory information stream contains memory region -// description information. This stream corresponds to -// what VirtualQuery would return for the process the -// dump was created for. -// - -// Thread dump writer status flags. -#define MINIDUMP_THREAD_INFO_ERROR_THREAD 0x00000001 -#define MINIDUMP_THREAD_INFO_WRITING_THREAD 0x00000002 -#define MINIDUMP_THREAD_INFO_EXITED_THREAD 0x00000004 -#define MINIDUMP_THREAD_INFO_INVALID_INFO 0x00000008 -#define MINIDUMP_THREAD_INFO_INVALID_CONTEXT 0x00000010 -#define MINIDUMP_THREAD_INFO_INVALID_TEB 0x00000020 - -typedef struct _MINIDUMP_THREAD_INFO { - ULONG32 ThreadId; - ULONG32 DumpFlags; - ULONG32 DumpError; - ULONG32 ExitStatus; - ULONG64 CreateTime; - ULONG64 ExitTime; - ULONG64 KernelTime; - ULONG64 UserTime; - ULONG64 StartAddress; - ULONG64 Affinity; -} MINIDUMP_THREAD_INFO, *PMINIDUMP_THREAD_INFO; - -typedef struct _MINIDUMP_THREAD_INFO_LIST { - ULONG SizeOfHeader; - ULONG SizeOfEntry; - ULONG NumberOfEntries; -} MINIDUMP_THREAD_INFO_LIST, *PMINIDUMP_THREAD_INFO_LIST; - - -// -// Support for arbitrary user-defined information. -// - -typedef struct _MINIDUMP_USER_RECORD { - ULONG32 Type; - MINIDUMP_LOCATION_DESCRIPTOR Memory; -} MINIDUMP_USER_RECORD, *PMINIDUMP_USER_RECORD; - - -typedef struct _MINIDUMP_USER_STREAM { - ULONG32 Type; - ULONG BufferSize; - PVOID Buffer; - -} MINIDUMP_USER_STREAM, *PMINIDUMP_USER_STREAM; - - -typedef struct _MINIDUMP_USER_STREAM_INFORMATION { - ULONG UserStreamCount; - PMINIDUMP_USER_STREAM UserStreamArray; -} MINIDUMP_USER_STREAM_INFORMATION, *PMINIDUMP_USER_STREAM_INFORMATION; - -// -// Callback support. -// - -typedef enum _MINIDUMP_CALLBACK_TYPE { - ModuleCallback, - ThreadCallback, - ThreadExCallback, - IncludeThreadCallback, - IncludeModuleCallback, - MemoryCallback, - CancelCallback, - WriteKernelMinidumpCallback, - KernelMinidumpStatusCallback, - RemoveMemoryCallback, - IncludeVmRegionCallback, - IoStartCallback, - IoWriteAllCallback, - IoFinishCallback, - ReadMemoryFailureCallback, - SecondaryFlagsCallback, -} MINIDUMP_CALLBACK_TYPE; - - -typedef struct _MINIDUMP_THREAD_CALLBACK { - ULONG ThreadId; - HANDLE ThreadHandle; - CONTEXT Context; - ULONG SizeOfContext; - ULONG64 StackBase; - ULONG64 StackEnd; -} MINIDUMP_THREAD_CALLBACK, *PMINIDUMP_THREAD_CALLBACK; - - -typedef struct _MINIDUMP_THREAD_EX_CALLBACK { - ULONG ThreadId; - HANDLE ThreadHandle; - CONTEXT Context; - ULONG SizeOfContext; - ULONG64 StackBase; - ULONG64 StackEnd; - ULONG64 BackingStoreBase; - ULONG64 BackingStoreEnd; -} MINIDUMP_THREAD_EX_CALLBACK, *PMINIDUMP_THREAD_EX_CALLBACK; - - -typedef struct _MINIDUMP_INCLUDE_THREAD_CALLBACK { - ULONG ThreadId; -} MINIDUMP_INCLUDE_THREAD_CALLBACK, *PMINIDUMP_INCLUDE_THREAD_CALLBACK; - - -typedef enum _THREAD_WRITE_FLAGS { - ThreadWriteThread = 0x0001, - ThreadWriteStack = 0x0002, - ThreadWriteContext = 0x0004, - ThreadWriteBackingStore = 0x0008, - ThreadWriteInstructionWindow = 0x0010, - ThreadWriteThreadData = 0x0020, - ThreadWriteThreadInfo = 0x0040, -} THREAD_WRITE_FLAGS; - -typedef struct _MINIDUMP_MODULE_CALLBACK { - PWCHAR FullPath; - ULONG64 BaseOfImage; - ULONG SizeOfImage; - ULONG CheckSum; - ULONG TimeDateStamp; - VS_FIXEDFILEINFO VersionInfo; - PVOID CvRecord; - ULONG SizeOfCvRecord; - PVOID MiscRecord; - ULONG SizeOfMiscRecord; -} MINIDUMP_MODULE_CALLBACK, *PMINIDUMP_MODULE_CALLBACK; - - -typedef struct _MINIDUMP_INCLUDE_MODULE_CALLBACK { - ULONG64 BaseOfImage; -} MINIDUMP_INCLUDE_MODULE_CALLBACK, *PMINIDUMP_INCLUDE_MODULE_CALLBACK; - - -typedef enum _MODULE_WRITE_FLAGS { - ModuleWriteModule = 0x0001, - ModuleWriteDataSeg = 0x0002, - ModuleWriteMiscRecord = 0x0004, - ModuleWriteCvRecord = 0x0008, - ModuleReferencedByMemory = 0x0010, - ModuleWriteTlsData = 0x0020, - ModuleWriteCodeSegs = 0x0040, -} MODULE_WRITE_FLAGS; - - -typedef struct _MINIDUMP_IO_CALLBACK { - HANDLE Handle; - ULONG64 Offset; - PVOID Buffer; - ULONG BufferBytes; -} MINIDUMP_IO_CALLBACK, *PMINIDUMP_IO_CALLBACK; - - -typedef struct _MINIDUMP_READ_MEMORY_FAILURE_CALLBACK -{ - ULONG64 Offset; - ULONG Bytes; - HRESULT FailureStatus; -} MINIDUMP_READ_MEMORY_FAILURE_CALLBACK, - *PMINIDUMP_READ_MEMORY_FAILURE_CALLBACK; - - -typedef struct _MINIDUMP_CALLBACK_INPUT { - ULONG ProcessId; - HANDLE ProcessHandle; - ULONG CallbackType; - union { - HRESULT Status; - MINIDUMP_THREAD_CALLBACK Thread; - MINIDUMP_THREAD_EX_CALLBACK ThreadEx; - MINIDUMP_MODULE_CALLBACK Module; - MINIDUMP_INCLUDE_THREAD_CALLBACK IncludeThread; - MINIDUMP_INCLUDE_MODULE_CALLBACK IncludeModule; - MINIDUMP_IO_CALLBACK Io; - MINIDUMP_READ_MEMORY_FAILURE_CALLBACK ReadMemoryFailure; - ULONG SecondaryFlags; - }; -} MINIDUMP_CALLBACK_INPUT, *PMINIDUMP_CALLBACK_INPUT; - -typedef struct _MINIDUMP_CALLBACK_OUTPUT { - union { - ULONG ModuleWriteFlags; - ULONG ThreadWriteFlags; - ULONG SecondaryFlags; - struct { - ULONG64 MemoryBase; - ULONG MemorySize; - }; - struct { - BOOL CheckCancel; - BOOL Cancel; - }; - HANDLE Handle; - struct { - MINIDUMP_MEMORY_INFO VmRegion; - BOOL Continue; - }; - HRESULT Status; - }; -} MINIDUMP_CALLBACK_OUTPUT, *PMINIDUMP_CALLBACK_OUTPUT; - - -// -// A normal minidump contains just the information -// necessary to capture stack traces for all of the -// existing threads in a process. -// -// A minidump with data segments includes all of the data -// sections from loaded modules in order to capture -// global variable contents. This can make the dump much -// larger if many modules have global data. -// -// A minidump with full memory includes all of the accessible -// memory in the process and can be very large. A minidump -// with full memory always has the raw memory data at the end -// of the dump so that the initial structures in the dump can -// be mapped directly without having to include the raw -// memory information. -// -// Stack and backing store memory can be filtered to remove -// data unnecessary for stack walking. This can improve -// compression of stacks and also deletes data that may -// be private and should not be stored in a dump. -// Memory can also be scanned to see what modules are -// referenced by stack and backing store memory to allow -// omission of other modules to reduce dump size. -// In either of these modes the ModuleReferencedByMemory flag -// is set for all modules referenced before the base -// module callbacks occur. -// -// On some operating systems a list of modules that were -// recently unloaded is kept in addition to the currently -// loaded module list. This information can be saved in -// the dump if desired. -// -// Stack and backing store memory can be scanned for referenced -// pages in order to pick up data referenced by locals or other -// stack memory. This can increase the size of a dump significantly. -// -// Module paths may contain undesired information such as user names -// or other important directory names so they can be stripped. This -// option reduces the ability to locate the proper image later -// and should only be used in certain situations. -// -// Complete operating system per-process and per-thread information can -// be gathered and stored in the dump. -// -// The virtual address space can be scanned for various types -// of memory to be included in the dump. -// -// Code which is concerned with potentially private information -// getting into the minidump can set a flag that automatically -// modifies all existing and future flags to avoid placing -// unnecessary data in the dump. Basic data, such as stack -// information, will still be included but optional data, such -// as indirect memory, will not. -// -// When doing a full memory dump it's possible to store all -// of the enumerated memory region descriptive information -// in a memory information stream. -// -// Additional thread information beyond the basic thread -// structure can be collected if desired. -// -// A minidump with code segments includes all of the code -// and code-related sections from loaded modules in order -// to capture executable content. -// -// MiniDumpWithoutAuxiliaryState turns off any secondary, -// auxiliary-supported memory gathering. -// -// MiniDumpWithFullAuxiliaryState asks any present auxiliary -// data providers to include all of their state in the dump. -// The exact set of what is provided depends on the auxiliary. -// This can be quite large. -// - -typedef enum _MINIDUMP_TYPE { - MiniDumpNormal = 0x00000000, - MiniDumpWithDataSegs = 0x00000001, - MiniDumpWithFullMemory = 0x00000002, - MiniDumpWithHandleData = 0x00000004, - MiniDumpFilterMemory = 0x00000008, - MiniDumpScanMemory = 0x00000010, - MiniDumpWithUnloadedModules = 0x00000020, - MiniDumpWithIndirectlyReferencedMemory = 0x00000040, - MiniDumpFilterModulePaths = 0x00000080, - MiniDumpWithProcessThreadData = 0x00000100, - MiniDumpWithPrivateReadWriteMemory = 0x00000200, - MiniDumpWithoutOptionalData = 0x00000400, - MiniDumpWithFullMemoryInfo = 0x00000800, - MiniDumpWithThreadInfo = 0x00001000, - MiniDumpWithCodeSegs = 0x00002000, - MiniDumpWithoutAuxiliaryState = 0x00004000, - MiniDumpWithFullAuxiliaryState = 0x00008000, - - MiniDumpValidTypeFlags = 0x0000ffff, -} MINIDUMP_TYPE; - -// -// In addition to the primary flags provided to -// MiniDumpWriteDump there are additional, less -// frequently used options queried via the secondary -// flags callback. -// -// MiniSecondaryWithoutPowerInfo suppresses the minidump -// query that retrieves processor power information for -// MINIDUMP_MISC_INFO. -// - -typedef enum _MINIDUMP_SECONDARY_FLAGS { - MiniSecondaryWithoutPowerInfo = 0x00000001, - - MiniSecondaryValidFlags = 0x00000001, -} MINIDUMP_SECONDARY_FLAGS; - - -// -// The minidump callback should modify the FieldsToWrite parameter to reflect -// what portions of the specified thread or module should be written to the -// file. -// - -typedef -BOOL -(WINAPI * MINIDUMP_CALLBACK_ROUTINE) ( - IN PVOID CallbackParam, - IN CONST PMINIDUMP_CALLBACK_INPUT CallbackInput, - IN OUT PMINIDUMP_CALLBACK_OUTPUT CallbackOutput - ); - -typedef struct _MINIDUMP_CALLBACK_INFORMATION { - MINIDUMP_CALLBACK_ROUTINE CallbackRoutine; - PVOID CallbackParam; -} MINIDUMP_CALLBACK_INFORMATION, *PMINIDUMP_CALLBACK_INFORMATION; - - - -//++ -// -// PVOID -// RVA_TO_ADDR( -// PVOID Mapping, -// ULONG Rva -// ) -// -// Routine Description: -// -// Map an RVA that is contained within a mapped file to it's associated -// flat address. -// -// Arguments: -// -// Mapping - Base address of mapped file containing the RVA. -// -// Rva - An Rva to fixup. -// -// Return Values: -// -// A pointer to the desired data. -// -//-- - -#define RVA_TO_ADDR(Mapping,Rva) ((PVOID)(((ULONG_PTR) (Mapping)) + (Rva))) - -BOOL -WINAPI -MiniDumpWriteDump( - IN HANDLE hProcess, - IN DWORD ProcessId, - IN HANDLE hFile, - IN MINIDUMP_TYPE DumpType, - IN CONST PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam, OPTIONAL - IN CONST PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam, OPTIONAL - IN CONST PMINIDUMP_CALLBACK_INFORMATION CallbackParam OPTIONAL - ); - -BOOL -WINAPI -MiniDumpReadDumpStream( - IN PVOID BaseOfDump, - IN ULONG StreamNumber, - OUT PMINIDUMP_DIRECTORY * Dir, OPTIONAL - OUT PVOID * StreamPointer, OPTIONAL - OUT ULONG * StreamSize OPTIONAL - ); - -#if defined(_MSC_VER) -#if _MSC_VER >= 800 -#if _MSC_VER >= 1200 -#pragma warning(pop) -#else -#pragma warning(default:4200) /* Zero length array */ -#pragma warning(default:4201) /* Nameless struct/union */ -#endif -#endif -#endif - -#include - -#ifdef __cplusplus -} -#endif - - -#endif // _DBGHELP_ diff --git a/plugins/Svc_crshdmp/vc6/dbghelp.lib b/plugins/Svc_crshdmp/vc6/dbghelp.lib deleted file mode 100644 index 5d50c3f74d..0000000000 Binary files a/plugins/Svc_crshdmp/vc6/dbghelp.lib and /dev/null differ diff --git a/plugins/Svc_crshdmp/version.h b/plugins/Svc_crshdmp/version.h deleted file mode 100644 index 776e30e404..0000000000 --- a/plugins/Svc_crshdmp/version.h +++ /dev/null @@ -1,3 +0,0 @@ -#define __FILEVERSION_STRING 0,0,4,21 -#define __VERSION_STRING "0.0.4.21" -#define __VERSION_DWORD PLUGIN_MAKE_VERSION(0, 0, 4, 21) diff --git a/plugins/Svc_dbepp/Res/Contacts.ico b/plugins/Svc_dbepp/Res/Contacts.ico deleted file mode 100644 index f3de15b54b..0000000000 Binary files a/plugins/Svc_dbepp/Res/Contacts.ico and /dev/null differ diff --git a/plugins/Svc_dbepp/Res/Icon_1.ico b/plugins/Svc_dbepp/Res/Icon_1.ico deleted file mode 100644 index a99fe06619..0000000000 Binary files a/plugins/Svc_dbepp/Res/Icon_1.ico and /dev/null differ diff --git a/plugins/Svc_dbepp/Res/Icon_14.ico b/plugins/Svc_dbepp/Res/Icon_14.ico deleted file mode 100644 index d14e4a1f96..0000000000 Binary files a/plugins/Svc_dbepp/Res/Icon_14.ico and /dev/null differ diff --git a/plugins/Svc_dbepp/Res/Icon_15.ico b/plugins/Svc_dbepp/Res/Icon_15.ico deleted file mode 100644 index 343fd1aaf0..0000000000 Binary files a/plugins/Svc_dbepp/Res/Icon_15.ico and /dev/null differ diff --git a/plugins/Svc_dbepp/Res/Icon_16.ico b/plugins/Svc_dbepp/Res/Icon_16.ico deleted file mode 100644 index 6cd2cd8e58..0000000000 Binary files a/plugins/Svc_dbepp/Res/Icon_16.ico and /dev/null differ diff --git a/plugins/Svc_dbepp/Res/Icon_17.ico b/plugins/Svc_dbepp/Res/Icon_17.ico deleted file mode 100644 index e11509e6cb..0000000000 Binary files a/plugins/Svc_dbepp/Res/Icon_17.ico and /dev/null differ diff --git a/plugins/Svc_dbepp/Res/Icon_18.ico b/plugins/Svc_dbepp/Res/Icon_18.ico deleted file mode 100644 index e25d704f71..0000000000 Binary files a/plugins/Svc_dbepp/Res/Icon_18.ico and /dev/null differ diff --git a/plugins/Svc_dbepp/Res/Icon_4.ico b/plugins/Svc_dbepp/Res/Icon_4.ico deleted file mode 100644 index cac9a01f7e..0000000000 Binary files a/plugins/Svc_dbepp/Res/Icon_4.ico and /dev/null differ diff --git a/plugins/Svc_dbepp/Res/Red.ico b/plugins/Svc_dbepp/Res/Red.ico deleted file mode 100644 index f6431fc7c1..0000000000 Binary files a/plugins/Svc_dbepp/Res/Red.ico and /dev/null differ diff --git a/plugins/Svc_dbepp/Res/Red_open.ico b/plugins/Svc_dbepp/Res/Red_open.ico deleted file mode 100644 index 1aa476a9d6..0000000000 Binary files a/plugins/Svc_dbepp/Res/Red_open.ico and /dev/null differ diff --git a/plugins/Svc_dbepp/Res/UserMenu.ico b/plugins/Svc_dbepp/Res/UserMenu.ico deleted file mode 100644 index acc2af901c..0000000000 Binary files a/plugins/Svc_dbepp/Res/UserMenu.ico and /dev/null differ diff --git a/plugins/Svc_dbepp/Res/Yellow.ico b/plugins/Svc_dbepp/Res/Yellow.ico deleted file mode 100644 index 378bdb3909..0000000000 Binary files a/plugins/Svc_dbepp/Res/Yellow.ico and /dev/null differ diff --git a/plugins/Svc_dbepp/Res/Yellow_open.ico b/plugins/Svc_dbepp/Res/Yellow_open.ico deleted file mode 100644 index df3ae478c2..0000000000 Binary files a/plugins/Svc_dbepp/Res/Yellow_open.ico and /dev/null differ diff --git a/plugins/Svc_dbepp/Res/dbepp.ico b/plugins/Svc_dbepp/Res/dbepp.ico deleted file mode 100644 index 817dba66f4..0000000000 Binary files a/plugins/Svc_dbepp/Res/dbepp.ico and /dev/null differ diff --git a/plugins/Svc_dbepp/Res/handle.ico b/plugins/Svc_dbepp/Res/handle.ico deleted file mode 100644 index 5a4448f8a7..0000000000 Binary files a/plugins/Svc_dbepp/Res/handle.ico and /dev/null differ diff --git a/plugins/Svc_dbepp/Res/handle1.ico b/plugins/Svc_dbepp/Res/handle1.ico deleted file mode 100644 index 705cbd3028..0000000000 Binary files a/plugins/Svc_dbepp/Res/handle1.ico and /dev/null differ diff --git a/plugins/Svc_dbepp/Res/ico_RegEdit.ico b/plugins/Svc_dbepp/Res/ico_RegEdit.ico deleted file mode 100644 index 6d1287ddd2..0000000000 Binary files a/plugins/Svc_dbepp/Res/ico_RegEdit.ico and /dev/null differ diff --git a/plugins/Svc_dbepp/Res/offline2.ico b/plugins/Svc_dbepp/Res/offline2.ico deleted file mode 100644 index e31abd9905..0000000000 Binary files a/plugins/Svc_dbepp/Res/offline2.ico and /dev/null differ diff --git a/plugins/Svc_dbepp/Res/online2.ico b/plugins/Svc_dbepp/Res/online2.ico deleted file mode 100644 index c30bcee643..0000000000 Binary files a/plugins/Svc_dbepp/Res/online2.ico and /dev/null differ diff --git a/plugins/Svc_dbepp/Res/unicode.ico b/plugins/Svc_dbepp/Res/unicode.ico deleted file mode 100644 index c65c3f0875..0000000000 Binary files a/plugins/Svc_dbepp/Res/unicode.ico and /dev/null differ diff --git a/plugins/Svc_dbepp/Version.h b/plugins/Svc_dbepp/Version.h deleted file mode 100644 index 565dddb582..0000000000 --- a/plugins/Svc_dbepp/Version.h +++ /dev/null @@ -1,20 +0,0 @@ -#define __MAJOR_VERSION 3 -#define __MINOR_VERSION 2 -#define __RELEASE_NUM 0 -#define __BUILD_NUM 0 - -#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM -#define __FILEVERSION_DOTS __MAJOR_VERSION.__MINOR_VERSION.__RELEASE_NUM.__BUILD_NUM - -#define __STRINGIFY_IMPL(x) #x -#define __STRINGIFY(x) __STRINGIFY_IMPL(x) -#define __VERSION_STRING __STRINGIFY(__FILEVERSION_DOTS) - -#define __PLUGIN_NAME "Database Editor++" -#define __INTERNAL_NAME "DBEditor" -#define __FILENAME "Svc_dbepp.dll" -#define __DESCRIPTION "Advanced Database Editor." -#define __AUTHOR "Bio, Jonathan Gordon" -#define __AUTHOREMAIL "bio@msx.ru, jdgordy@gmail.com" -#define __AUTHORWEB "http://addons.miranda-im.org/details.php?action=viewfile&id=2957" -#define __COPYRIGHT "© 2003-2011 Bio, Jonathan Gordon" diff --git a/plugins/Svc_dbepp/Version.rc b/plugins/Svc_dbepp/Version.rc deleted file mode 100644 index d1da5e8d6a..0000000000 --- a/plugins/Svc_dbepp/Version.rc +++ /dev/null @@ -1,42 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#ifdef APSTUDIO_INVOKED -#error this file is not editable by Microsoft Visual C++ -#endif //APSTUDIO_INVOKED - -#include "afxres.h" -#include "version.h" - -#ifdef _WIN32 -LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL -#endif //_WIN32 - -VS_VERSION_INFO VERSIONINFO - FILEVERSION __FILEVERSION_STRING - PRODUCTVERSION __FILEVERSION_STRING - FILEFLAGSMASK 0x17L -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x0L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "000004b0" - BEGIN - VALUE "FileDescription", __DESCRIPTION - VALUE "InternalName", __PLUGIN_NAME - VALUE "LegalCopyright", __COPYRIGHT - VALUE "OriginalFilename", __FILENAME - VALUE "ProductName", __PLUGIN_NAME - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x0, 1200 - END -END diff --git a/plugins/Svc_dbepp/addeditsettingsdlg.cpp b/plugins/Svc_dbepp/addeditsettingsdlg.cpp deleted file mode 100644 index 6c21fe498c..0000000000 --- a/plugins/Svc_dbepp/addeditsettingsdlg.cpp +++ /dev/null @@ -1,458 +0,0 @@ -#include "headers.h" - - -static BOOL Convert(HANDLE hContact, char* module, char* setting, int value, int toType) // 0 = byte, 1 = word, 2 = dword, 3 = string -{ - int Result = 1; - char temp[64]; - - switch (toType) - { - case 0: - if (value > 0xFF) - Result = 0; - else - DBWriteContactSettingByte(hContact, module, setting, (BYTE)value); - break; - case 1: - if (value > 0xFFFF) - Result = 0; - else - DBWriteContactSettingWord(hContact, module, setting, (WORD)value); - break; - case 2: - DBWriteContactSettingDword(hContact, module, setting, (DWORD)value); - break; - case 3: - DBDeleteContactSetting(hContact, module, setting); - DBWriteContactSettingString(hContact, module, setting, itoa(value,temp,10)); - break; - } - return Result; -} - - -BOOL convertSetting(HANDLE hContact, char* module, char* setting, int toType) // 0 = byte, 1 = word, 2 = dword, 3 = string, 4 = unicode -{ - DBVARIANT dbv = {0}; - BOOL Result = 0; - - if (!GetSetting(hContact, module, setting, &dbv)) - { - switch (dbv.type) - { - case DBVT_BYTE: - Result = Convert(hContact, module, setting, dbv.bVal, toType); - break; - - case DBVT_WORD: - Result = Convert(hContact, module, setting, dbv.wVal, toType); - break; - - case DBVT_DWORD: - Result = Convert(hContact, module, setting, dbv.dVal, toType); - break; - - case DBVT_ASCIIZ: - if (toType == 4) // convert to UNICODE - { - int len = (int)strlen(dbv.pszVal) + 1; - WCHAR *wc = (WCHAR*)_alloca(len*sizeof(WCHAR)); - MultiByteToWideChar(CP_ACP, 0, dbv.pszVal, -1, wc, len); - Result = !DBWriteContactSettingWString(hContact, module, setting, wc); - } - else - if (strlen(dbv.pszVal) < 11 && toType != 3) - { - int val = atoi(dbv.pszVal); - if (val == 0 && dbv.pszVal[0] != '0') - break; - - Result = Convert(hContact, module, setting, val, toType); - } - break; - case DBVT_UTF8: - if (toType == 3 && UOS) // convert to ANSI - { - int len = (int)strlen(dbv.pszVal) + 1; - char *sz = (char*)_alloca(len*3); - WCHAR *wc = (WCHAR*)_alloca(len*sizeof(WCHAR)); - MultiByteToWideChar(CP_UTF8, 0, dbv.pszVal, -1, wc, len); - WideCharToMultiByte(CP_ACP, 0, wc, -1, sz, len, NULL, NULL); - Result = !DBWriteContactSettingString(hContact, module, setting, sz); - } - break; - } - - if (!Result) - msg(Translate("Cannot Convert!"), modFullname); - - DBFreeVariant(&dbv); - } - - return Result; -} - - -int saveAsType(HWND hwnd) -{ - if(IsDlgButtonChecked(hwnd, CHK_BYTE)) - return 0; - else if(IsDlgButtonChecked(hwnd, CHK_WORD)) - return 1; - else if(IsDlgButtonChecked(hwnd, CHK_DWORD)) - return 2; - else if(IsDlgButtonChecked(hwnd, CHK_STRING)) - return 3; - return 3; -} - - -INT_PTR CALLBACK EditSettingDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - switch(msg) - { - case WM_INITDIALOG: - { - char tmp[32]; - SetWindowLongPtr(hwnd,GWLP_USERDATA,(LPARAM)lParam); - switch (((struct DBsetting*)lParam)->dbv.type) - { - case DBVT_BYTE: - ShowWindow(GetDlgItem(hwnd, IDC_STRING),SW_HIDE); - if (!((struct DBsetting*)lParam)->setting[0]) - { - SetWindowText(hwnd, Translate("New BYTE value")); - } - else - { - SetWindowText(hwnd, Translate("Edit BYTE value")); - SetDlgItemText(hwnd, IDC_SETTINGNAME, ((struct DBsetting*)lParam)->setting); - SetDlgItemText(hwnd, IDC_SETTINGVALUE, itoa(((struct DBsetting*)lParam)->dbv.bVal, tmp, 10)); - } - CheckRadioButton(hwnd, CHK_HEX, CHK_DECIMAL, CHK_DECIMAL); - CheckRadioButton(hwnd, CHK_BYTE, CHK_STRING, CHK_BYTE); - break; - case DBVT_WORD: - ShowWindow(GetDlgItem(hwnd, IDC_STRING),SW_HIDE); - if (!((struct DBsetting*)lParam)->setting[0]) - { - SetWindowText(hwnd, Translate("New WORD value")); - } - else - { - SetWindowText(hwnd, Translate("Edit WORD value")); - SetDlgItemText(hwnd, IDC_SETTINGNAME, ((struct DBsetting*)lParam)->setting); - SetDlgItemText(hwnd, IDC_SETTINGVALUE, itoa(((struct DBsetting*)lParam)->dbv.wVal, tmp, 10)); - } - CheckRadioButton(hwnd, CHK_HEX, CHK_DECIMAL, CHK_DECIMAL); - CheckRadioButton(hwnd, CHK_BYTE, CHK_STRING, CHK_WORD); - break; - case DBVT_DWORD: - ShowWindow(GetDlgItem(hwnd, IDC_STRING),SW_HIDE); - if (!((struct DBsetting*)lParam)->setting[0]) - { - SetWindowText(hwnd, Translate("New DWORD value")); - } - else - { - char text[32]; - SetWindowText(hwnd, Translate("Edit DWORD value")); - SetDlgItemText(hwnd, IDC_SETTINGNAME, ((struct DBsetting*)lParam)->setting); - mir_snprintf(text, SIZEOF(text), "%X", ((struct DBsetting*)lParam)->dbv.dVal); - SetDlgItemText(hwnd, IDC_SETTINGVALUE, text); - } - CheckRadioButton(hwnd, CHK_HEX, CHK_DECIMAL, CHK_HEX); - CheckRadioButton(hwnd, CHK_BYTE, CHK_STRING, CHK_DWORD); - break; - case DBVT_ASCIIZ: - ShowWindow(GetDlgItem(hwnd, IDC_STRING),SW_SHOW); - ShowWindow(GetDlgItem(hwnd, IDC_SETTINGVALUE),SW_HIDE); - ShowWindow(GetDlgItem(hwnd, CHK_HEX),SW_HIDE); - ShowWindow(GetDlgItem(hwnd, CHK_DECIMAL),SW_HIDE); - ShowWindow(GetDlgItem(hwnd, GRP_BASE),SW_HIDE); - ShowWindow(GetDlgItem(hwnd, GRP_TYPE),SW_HIDE); - ShowWindow(GetDlgItem(hwnd, CHK_BYTE),SW_HIDE); - ShowWindow(GetDlgItem(hwnd, CHK_WORD),SW_HIDE); - ShowWindow(GetDlgItem(hwnd, CHK_DWORD),SW_HIDE); - ShowWindow(GetDlgItem(hwnd, CHK_STRING),SW_HIDE); - if (!((struct DBsetting*)lParam)->setting[0]) - { - SetWindowText(hwnd, Translate("New STRING value")); - } - else - { - SetWindowText(hwnd, Translate("Edit STRING value")); - SetDlgItemText(hwnd, IDC_SETTINGNAME, ((struct DBsetting*)lParam)->setting); - SetDlgItemText(hwnd, IDC_STRING, ((struct DBsetting*)lParam)->dbv.pszVal); - } - break; - case DBVT_UTF8: - ShowWindow(GetDlgItem(hwnd, IDC_STRING),SW_SHOW); - ShowWindow(GetDlgItem(hwnd, IDC_SETTINGVALUE),SW_HIDE); - ShowWindow(GetDlgItem(hwnd, CHK_HEX),SW_HIDE); - ShowWindow(GetDlgItem(hwnd, CHK_DECIMAL),SW_HIDE); - ShowWindow(GetDlgItem(hwnd, GRP_BASE),SW_HIDE); - ShowWindow(GetDlgItem(hwnd, GRP_TYPE),SW_HIDE); - ShowWindow(GetDlgItem(hwnd, CHK_BYTE),SW_HIDE); - ShowWindow(GetDlgItem(hwnd, CHK_WORD),SW_HIDE); - ShowWindow(GetDlgItem(hwnd, CHK_DWORD),SW_HIDE); - ShowWindow(GetDlgItem(hwnd, CHK_STRING),SW_HIDE); - if (!((struct DBsetting*)lParam)->setting[0]) - { - SetWindowText(hwnd, Translate("New UNICODE value")); - } - else - { - char *tmp = (((struct DBsetting*)lParam)->dbv.pszVal); - if (UOS) - { - int length = (int)strlen(tmp) + 1; - WCHAR *wc = (WCHAR*)_alloca(length*sizeof(WCHAR)); - MultiByteToWideChar(CP_UTF8, 0, tmp, -1, wc, length); - SendMessageW(GetDlgItem(hwnd, IDC_STRING), WM_SETTEXT, 0, (LPARAM)wc); - } - else { - // convert from UTF8 - SetDlgItemText(hwnd, IDC_STRING, tmp); - } - SetWindowText(hwnd, Translate("Edit UNICODE value")); - SetDlgItemText(hwnd, IDC_SETTINGNAME, ((struct DBsetting*)lParam)->setting); - } - break; - case DBVT_BLOB: - { - ShowWindow(GetDlgItem(hwnd, IDC_STRING),SW_HIDE); - ShowWindow(GetDlgItem(hwnd, IDC_SETTINGVALUE),SW_HIDE); - ShowWindow(GetDlgItem(hwnd, IDC_BLOB),SW_SHOW); - - if (!((struct DBsetting*)lParam)->setting[0]) - { - SetWindowText(hwnd, Translate("New BLOB value")); - } - else - { - int j; - char tmp[16]; - int len = ((struct DBsetting*)lParam)->dbv.cpbVal; - char *data = (char*)_alloca(3*(len+1)+10); - BYTE *p = ((struct DBsetting*)lParam)->dbv.pbVal; - - if (!data) return TRUE; - data[0] = '\0'; - - for(j=0; jsetting); - SetDlgItemText(hwnd, IDC_BLOB, data); - } - ShowWindow(GetDlgItem(hwnd, CHK_HEX),SW_HIDE); - ShowWindow(GetDlgItem(hwnd, CHK_DECIMAL),SW_HIDE); - ShowWindow(GetDlgItem(hwnd, GRP_BASE),SW_HIDE); - ShowWindow(GetDlgItem(hwnd, GRP_TYPE),SW_HIDE); - ShowWindow(GetDlgItem(hwnd, CHK_BYTE),SW_HIDE); - ShowWindow(GetDlgItem(hwnd, CHK_WORD),SW_HIDE); - ShowWindow(GetDlgItem(hwnd, CHK_DWORD),SW_HIDE); - ShowWindow(GetDlgItem(hwnd, CHK_STRING),SW_HIDE); - } - break; - default: return TRUE; - } - TranslateDialogDefault(hwnd); - } - return TRUE; - case WM_COMMAND: - switch(LOWORD(wParam)) - { - case CHK_BYTE: - case CHK_WORD: - case CHK_DWORD: - EnableWindow(GetDlgItem(hwnd, CHK_HEX),1); - EnableWindow(GetDlgItem(hwnd, CHK_DECIMAL),1); - CheckRadioButton(hwnd, CHK_BYTE, CHK_STRING, LOWORD(wParam)); - break; - case CHK_STRING: - EnableWindow(GetDlgItem(hwnd, CHK_HEX),0); - EnableWindow(GetDlgItem(hwnd, CHK_DECIMAL),0); - CheckRadioButton(hwnd, CHK_BYTE, CHK_STRING, LOWORD(wParam)); - break; - - case CHK_HEX: - case CHK_DECIMAL: - CheckRadioButton(hwnd,CHK_HEX, CHK_DECIMAL, LOWORD(wParam)); - { - char *setting, temp[32]; - int settingLength, tmp; - settingLength = GetWindowTextLength(GetDlgItem(hwnd, IDC_SETTINGVALUE)); - if (settingLength) - { - setting = (char*)_alloca(settingLength + 1); - if (setting) - { - // havta convert it with sprintf() - GetWindowText(GetDlgItem(hwnd, IDC_SETTINGVALUE), setting, settingLength+1); - if (LOWORD(wParam) == CHK_DECIMAL && IsDlgButtonChecked(hwnd, CHK_DECIMAL)) - { - sscanf(setting, "%X", &tmp); - mir_snprintf(temp, SIZEOF(temp), "%ld", tmp); - } - else - { - sscanf(setting, "%d", &tmp); - mir_snprintf(temp, SIZEOF(temp), "%X", tmp); - } - SetWindowText(GetDlgItem(hwnd, IDC_SETTINGVALUE), temp); - } - } - } - break; - case IDOK: - { - struct DBsetting *dbsetting = (struct DBsetting*)GetWindowLongPtr(hwnd,GWLP_USERDATA); - char *setting, *value; - int settingLength, valueLength, valueID = IDC_SETTINGVALUE; - settingLength = GetWindowTextLength(GetDlgItem(hwnd, IDC_SETTINGNAME)); - - if (IsWindowVisible(GetDlgItem(hwnd,IDC_STRING))) - valueID = IDC_STRING; - else - if (IsWindowVisible(GetDlgItem(hwnd,IDC_SETTINGVALUE))) - valueID = IDC_SETTINGVALUE; - else - if (IsWindowVisible(GetDlgItem(hwnd,IDC_BLOB))) - valueID = IDC_BLOB; - else - break; - - valueLength = GetWindowTextLength(GetDlgItem(hwnd, valueID)); - - if (dbsetting->dbv.type == DBVT_UTF8 && UOS) - valueLength *= sizeof(WCHAR); - - if (settingLength) - { - int settingValue; - setting = (char*)_alloca(settingLength + 1); - - if (valueLength) - value = (char*)_alloca(valueLength + 2); - else - value = (char*)_alloca(2); - - if (!setting || !value) - { - msg(Translate("Couldnt allocate enough memory!"), modFullname); - DestroyWindow(hwnd); - break; - } - - GetWindowText(GetDlgItem(hwnd, IDC_SETTINGNAME), setting, settingLength+1); - - if (valueLength) - { - if (dbsetting->dbv.type == DBVT_UTF8 && UOS) - SendMessageW(GetDlgItem(hwnd, valueID), WM_GETTEXT, valueLength+2, (LPARAM)value); - else - GetWindowText(GetDlgItem(hwnd, valueID), value, valueLength+1); - } - else - if (IsWindowVisible(GetDlgItem(hwnd,IDC_STRING)) || (saveAsType(hwnd)==3)) - memcpy(value,"\0\0",2); - else - strcpy(value,"0"); - - // delete the old setting - if (mir_strcmp(setting, dbsetting->setting) && dbsetting->setting && (dbsetting->setting)[0] != 0) - DBDeleteContactSetting(dbsetting->hContact, dbsetting->module, dbsetting->setting); - - // delete the setting if we are saving as a different type - switch (dbsetting->dbv.type) - { - case DBVT_BYTE: - if (saveAsType(hwnd) != 0) DBDeleteContactSetting(dbsetting->hContact, dbsetting->module, setting); - break; - case DBVT_WORD: - if (saveAsType(hwnd) != 1) DBDeleteContactSetting(dbsetting->hContact, dbsetting->module, setting); - break; - case DBVT_DWORD: - if (saveAsType(hwnd) != 2) DBDeleteContactSetting(dbsetting->hContact, dbsetting->module, setting); - break; - //case DBVT_ASCIIZ: - //DBWriteContactSettingString(dbsetting->hContact, dbsetting->module, setting, value); - //break; - } - // write the setting - switch (saveAsType(hwnd)) - { - case 0: - if (IsDlgButtonChecked(hwnd, CHK_HEX)) sscanf(value, "%x", &settingValue); - else sscanf(value, "%d", &settingValue); - DBWriteContactSettingByte(dbsetting->hContact, dbsetting->module, setting, (BYTE)settingValue); - break; - case 1: - if (IsDlgButtonChecked(hwnd, CHK_HEX)) sscanf(value, "%x", &settingValue); - else sscanf(value, "%d", &settingValue); - DBWriteContactSettingWord(dbsetting->hContact, dbsetting->module, setting, (WORD)settingValue); - break; - case 2: - if (IsDlgButtonChecked(hwnd, CHK_HEX)) sscanf(value, "%x", &settingValue); - else sscanf(value, "%d", &settingValue); - DBWriteContactSettingDword(dbsetting->hContact, dbsetting->module, setting, (DWORD)settingValue); - break; - case 3: - if (dbsetting->dbv.type == DBVT_UTF8) - { - if (UOS) - DBWriteContactSettingWString(dbsetting->hContact, dbsetting->module, setting, (WCHAR*)value); - else - DBWriteContactSettingStringUtf(dbsetting->hContact, dbsetting->module, setting, value); - } - else - if (dbsetting->dbv.type == DBVT_BLOB) - WriteBlobFromString(dbsetting->hContact,dbsetting->module,setting,value,valueLength); - else - if (dbsetting->dbv.type == DBVT_ASCIIZ) - DBWriteContactSettingString(dbsetting->hContact, dbsetting->module, setting, value); - break; - } - - } - } // fall through - case IDCANCEL: - { - struct DBsetting *dbsetting = (struct DBsetting*)GetWindowLongPtr(hwnd,GWLP_USERDATA); - mir_free(dbsetting->module); - mir_free(dbsetting->setting); - mir_free(dbsetting); - DestroyWindow(hwnd); - } - break; - } - break; - } - return 0; -} - -void editSetting(HANDLE hContact, char* module, char* setting) -{ - DBVARIANT dbv = {0}; // freed in the dialog - if (!GetSetting(hContact,module, setting, &dbv)) - { - struct DBsetting *dbsetting = (struct DBsetting *)mir_alloc(sizeof(struct DBsetting)); // gets free()ed in the window proc - - dbsetting->dbv = dbv; // freed in the dialog - dbsetting->hContact = hContact; - dbsetting->module = mir_tstrdup(module); - dbsetting->setting = mir_tstrdup(setting); - - if (dbv.type == DBVT_UTF8 && UOS) - CreateDialogParamW(hInst, MAKEINTRESOURCEW(IDD_EDIT_SETTING), hwnd2mainWindow, EditSettingDlgProc, (LPARAM)dbsetting); - else - CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_EDIT_SETTING), hwnd2mainWindow, EditSettingDlgProc, (LPARAM)dbsetting); - } -} \ No newline at end of file diff --git a/plugins/Svc_dbepp/copymodule.cpp b/plugins/Svc_dbepp/copymodule.cpp deleted file mode 100644 index 25489a7f52..0000000000 --- a/plugins/Svc_dbepp/copymodule.cpp +++ /dev/null @@ -1,197 +0,0 @@ -#include "headers.h" - -void copyModule(char* module, HANDLE hContactFrom, HANDLE hContactTo) -{ - ModuleSettingLL msll; - struct ModSetLinkLinkItem *setting; - - EnumSettings(hContactFrom,module, &msll); - - setting = msll.first; - while(setting) - { - DBVARIANT dbv; - if (!GetSetting(hContactFrom, module, setting->name, &dbv)) - { - switch (dbv.type) - { - case DBVT_BYTE: - DBWriteContactSettingByte(hContactTo, module, setting->name, dbv.bVal); - break; - case DBVT_WORD: - DBWriteContactSettingWord(hContactTo, module, setting->name, dbv.wVal); - break; - case DBVT_DWORD: - DBWriteContactSettingDword(hContactTo, module, setting->name, dbv.dVal); - break; - case DBVT_ASCIIZ: - DBWriteContactSettingString(hContactTo, module, setting->name, dbv.pszVal); - break; - case DBVT_UTF8: - DBWriteContactSettingStringUtf(hContactTo, module, setting->name, dbv.pszVal); - break; - case DBVT_BLOB: - DBWriteContactSettingBlob(hContactTo, module, setting->name, dbv.pbVal, dbv.cpbVal); - break; - } - } - DBFreeVariant(&dbv); - setting = (struct ModSetLinkLinkItem *)setting->next; - } - FreeModuleSettingLL(&msll); -} - -INT_PTR CALLBACK copyModDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - ModuleAndContact *mac = (ModuleAndContact *)GetWindowLongPtr(hwnd,GWLP_USERDATA); - if (msg == WM_INITDIALOG) - { - int index, loaded; - char szProto[256]; - HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); - - while (hContact) - { - if (GetValue(hContact,"Protocol","p",szProto,SIZEOF(szProto))) - loaded = IsProtocolLoaded(szProto); - else - loaded = 0; - - // filter - if ((loaded && Mode == MODE_UNLOADED) || (!loaded && Mode == MODE_LOADED)) - { - hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); - continue; - } - - // contacts name - if (UOS) - { - DBVARIANT dbv ={0}; - WCHAR nick[256]; - WCHAR protoW[256]; // unicode proto - - if (szProto[0]) - a2u(szProto, protoW, SIZEOF(protoW)); - else - protoW[0] = 0; - - if (!szProto[0] || !loaded) - { - if (protoW) - { - if (Order) - mir_snwprintf(nick, SIZEOF(nick), L"(%s) %s %s", protoW, GetContactName(hContact, szProto, 1), L"(UNLOADED)"); - else - mir_snwprintf(nick, SIZEOF(nick), L"%s (%s) %s", GetContactName(hContact, szProto, 1), protoW, L"(UNLOADED)"); - } - else - wcscpy(nick, nick_unknownW); - } - else - { - if (Order) - mir_snwprintf(nick, SIZEOF(nick), L"(%s) %s", protoW, GetContactName(hContact, szProto, 1)); - else - mir_snwprintf(nick, SIZEOF(nick), L"%s (%s)", GetContactName(hContact, szProto, 1), protoW); - } - - index = SendMessageW(GetDlgItem(hwnd, IDC_CONTACTS), CB_ADDSTRING, 0, (LPARAM)nick); - SendMessageW(GetDlgItem(hwnd, IDC_CONTACTS), CB_SETITEMDATA, index, (LPARAM)hContact); - } - else - { - char nick[256]; - - if (!szProto[0] || !loaded) - { - if (szProto[0]) - { - if (Order) - mir_snprintf(nick, SIZEOF(nick), "(%s) %s %s", szProto, (char*)GetContactName(hContact, szProto, 0), "(UNLOADED)"); - else - mir_snprintf(nick, SIZEOF(nick), "%s (%s) %s", (char*)GetContactName(hContact, szProto, 0), szProto, "(UNLOADED)"); - } - else - strcpy(nick, nick_unknown); - } - else - { - if (Order) - mir_snprintf(nick, SIZEOF(nick), "(%s) %s", szProto, (char*)GetContactName(hContact, szProto, 0)); - else - mir_snprintf(nick, SIZEOF(nick), "%s (%s)", (char*)GetContactName(hContact, szProto, 0), szProto); - } - - index = SendMessage(GetDlgItem(hwnd, IDC_CONTACTS), CB_ADDSTRING, 0, (LPARAM)nick); - SendMessage(GetDlgItem(hwnd, IDC_CONTACTS), CB_SETITEMDATA, index, (LPARAM)hContact); - } - - hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)(HANDLE)hContact, 0); - } - - index = (int)SendMessage(GetDlgItem(hwnd, IDC_CONTACTS), CB_INSERTSTRING, 0, (LPARAM)(char*)Translate("Settings")); - SendMessage(GetDlgItem(hwnd, IDC_CONTACTS), CB_SETITEMDATA, index, (LPARAM)0); - SendMessage(GetDlgItem(hwnd, IDC_CONTACTS), CB_SETCURSEL, index, 0); - - SetWindowLongPtr(hwnd,GWLP_USERDATA,lParam); - TranslateDialogDefault(hwnd); - } - else - if (msg == WM_COMMAND) - { - switch(LOWORD(wParam)) - { - case CHK_COPY2ALL: - EnableWindow(GetDlgItem(hwnd, IDC_CONTACTS),!IsDlgButtonChecked(hwnd,CHK_COPY2ALL)); - break; - case IDOK: - { - HANDLE hContact; - - if (!IsDlgButtonChecked(hwnd,CHK_COPY2ALL)) - { - hContact = (HANDLE)SendMessage(GetDlgItem(hwnd, IDC_CONTACTS), CB_GETITEMDATA, SendMessage(GetDlgItem(hwnd, IDC_CONTACTS), CB_GETCURSEL, 0, 0), 0); - copyModule(mac->module, mac->hContact, hContact); - } - else - { - SetCursor(LoadCursor(NULL,IDC_WAIT)); - hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); - - while (hContact) - { - copyModule(mac->module, mac->hContact, hContact); - hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)(HANDLE)hContact, 0); - } - - SetCursor(LoadCursor(NULL,IDC_ARROW)); - } - mir_free(mac); - refreshTree(1); - DestroyWindow(hwnd); - } - break; - case IDCANCEL: - { - mir_free(mac); - DestroyWindow(hwnd); - } - break; - } - } - return 0; -} - -void copyModuleMenuItem(char* module, HANDLE hContact) -{ - HWND hwnd; - ModuleAndContact *mac = (ModuleAndContact *)mir_calloc(sizeof(ModuleAndContact)); - mac->hContact = hContact; - strncpy(mac->module, module, 255); - - if (UOS) - hwnd = CreateDialogParamW(hInst, MAKEINTRESOURCEW(IDD_COPY_MOD), 0, copyModDlgProc, (LPARAM)mac); - else - hwnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_COPY_MOD), 0, copyModDlgProc, (LPARAM)mac); -} \ No newline at end of file diff --git a/plugins/Svc_dbepp/dbeditorpp_10.vcxproj b/plugins/Svc_dbepp/dbeditorpp_10.vcxproj deleted file mode 100644 index 776ea53f7e..0000000000 --- a/plugins/Svc_dbepp/dbeditorpp_10.vcxproj +++ /dev/null @@ -1,231 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - Svc_dbepp - {9C6040B8-1173-40FA-A3DB-DE044CCD8250} - - - - DynamicLibrary - MultiByte - true - - - DynamicLibrary - MultiByte - true - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(SolutionDir)$(Configuration)\Plugins\ - $(SolutionDir)$(Configuration)64\Plugins\ - $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ - $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ - $(SolutionDir)$(Configuration)\Plugins\ - $(SolutionDir)$(Configuration)64\Plugins\ - $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ - $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ - true - - - - Disabled - ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;DBEDITORPP_EXPORTS;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebugDLL - Use - headers.h - Level3 - EditAndContinue - 4996;%(DisableSpecificWarnings) - - - _DEBUG;%(PreprocessorDefinitions) - ..\..\include\msapi - - - true - false - $(IntDir)$(TargetName).lib - Windows - shlwapi.lib;comctl32.lib;%(AdditionalDependencies) - $(SolutionDir)\lib - - - - - Disabled - ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - WIN64;_DEBUG;_WINDOWS;_USRDLL;DBEDITORPP_EXPORTS;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebugDLL - Use - headers.h - Level3 - 4996;%(DisableSpecificWarnings) - - - _DEBUG;%(PreprocessorDefinitions) - ..\..\include\msapi - - - shlwapi.lib;comctl32.lib;%(AdditionalDependencies) - true - false - $(IntDir)$(TargetName).lib - Windows - $(SolutionDir)\lib - - - - - Full - OnlyExplicitInline - Size - ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;DBEDITORPP_EXPORTS;%(PreprocessorDefinitions) - true - true - Use - headers.h - Level3 - 4996;%(DisableSpecificWarnings) - - - NDEBUG;%(PreprocessorDefinitions) - ..\..\include\msapi - - - shlwapi.lib;comctl32.lib;%(AdditionalDependencies) - true - true - true - false - $(IntDir)$(TargetName).lib - Windows - $(SolutionDir)\lib - - - - - Full - OnlyExplicitInline - Size - ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - WIN64;NDEBUG;_WINDOWS;_USRDLL;DBEDITORPP_EXPORTS;%(PreprocessorDefinitions) - true - true - Use - headers.h - Level3 - 4996;%(DisableSpecificWarnings) - - - NDEBUG;%(PreprocessorDefinitions) - ..\..\include\msapi - - - shlwapi.lib;comctl32.lib;%(AdditionalDependencies) - true - true - true - false - $(IntDir)$(TargetName).lib - Windows - $(SolutionDir)\lib - - - - - - - - Create - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/plugins/Svc_dbepp/dbeditorpp_10.vcxproj.filters b/plugins/Svc_dbepp/dbeditorpp_10.vcxproj.filters deleted file mode 100644 index f0f8d79957..0000000000 --- a/plugins/Svc_dbepp/dbeditorpp_10.vcxproj.filters +++ /dev/null @@ -1,142 +0,0 @@ - - - - - {bc4414ca-bfab-4385-a016-6239272b67ab} - cpp;c;cxx;rc;def;r;odl;idl;hpj;bat - - - {8ba4deb9-307a-4c99-9c87-2243a0ef802e} - - - {b1b3b1b6-9fe0-435d-b8ab-1715cc5e7430} - - - {adcc58df-dacb-48fe-a36b-59f8221cb71e} - h;hpp;hxx;hm;inl - - - {fb09bf3d-d973-466d-b87b-0b785885753b} - ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files\ModSetting Enuming - - - Source Files\dialogs - - - Source Files\dialogs - - - Source Files\dialogs - - - Source Files\dialogs - - - Source Files\dialogs - - - Source Files\dialogs - - - Source Files\dialogs - - - Source Files\dialogs - - - Source Files\dialogs - - - - - Source Files\ModSetting Enuming - - - Header Files - - - Header Files - - - Header Files - - - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - - - Resource Files - - - \ No newline at end of file diff --git a/plugins/Svc_dbepp/dbeditorpp_readme.txt b/plugins/Svc_dbepp/dbeditorpp_readme.txt deleted file mode 100644 index 774560721d..0000000000 --- a/plugins/Svc_dbepp/dbeditorpp_readme.txt +++ /dev/null @@ -1,143 +0,0 @@ -Database Editor ++ -------------------- - -Database Editor ++ allows you to easily modify your database settings (which is a good and bad thing..). Be carefull editing values that you dont know what they are used for... you couldnt couse Miranda IM to not work if you change the wrong setting... -YOU HAVE BEEN WARNED... - -A summary of what DBE++ can do.. (each will be explained below) -- Edit every database setting (not history) -- export / import your entire (or partial) database to/from a txt file -- Remove an entire module from the database -- Find and replace a value in string variables.. -- Find text (numbers or letters) in any module, setting name or value -- Keep a list of variables you need to watch (usefull for developers) -- display modules which are not currently being used (if the plugin that uses that module isnt loaded) -- clone a contact -- copy a module to a contact -- rename module and settings -- change a variable type -- show popups when a certain setting changes -- show encrypted strings decrypted (as well as encrypt/decrypt any string variable) -and more.... - -Editing Variables ------------------ -The easiest way to edit or rename a setting is to dowuble click the setting's icon, a new window will popup and you can edit it there... -well, i lie.. the easiest way to edit/rename the settings is a bit more complicated :) -if you click twice the setting name a edit window should popup where you can rename the setting... pressing escape will cancel it, everything else will accpet your changes without confirmation. -Same goes for the setting value (2nd column) except you can do nifty stuff here which needs to be explained... -just typing a number will keep the vairable type the same and change the value to your new number (it does not check if your new number is larger that the type's largest possible number). -Typeing anything other than numbers will convert the variable to a string with your new data as the value. -Typeing a number into a string variable will keep the variable as a string. - -You can force a variable to a type by prepending the value with a letter. -'b' or 'B' to force a BYTE variable. -'w' or 'W' to force a WORD variable. -'d' or 'D' to force a DWORD variable. -If your new data starts with a ' or " the setting will be converted to a string, so if you actually want to start the value with a ' you need to put 2 ' marks at the start!.. -unless a number starts with 0x or 0X the number is assumed to be decimal, with a 0x/0X it is hexidecimal. - -Exporting / Importing ---------------------- -To export the entire database go Actions > Export / Import > Export entire database (in the DBE++ window), you can choose any file extension you want, it just saves as a plaintext file, so .txt is logical :) -To export only a certain module or contact right click it and go export.. - -Importing is a bit more complex... -there are two ways to import settings, either useing the import window, or just importing an entire file. -Using the import window lets you choose exactly which modules/settings to import into the selected contact. -Importing an entire file will start importing all the settings into the selected contact (the Settings contact if you do it from the actions menu item). - -Every time a line starting with "CONTACT:" is read a new contact is created and the following modules/settings get imported into that contact... there is one exception tho. if the line is "CONTACT: Settings" then the following modules/settings get imported into the Settings contact ( a new contact is not created..) - -Remove an entire module from the database ----------------------------------------------- -To remove a module from the database use the actions > Delete module menu item. If you have alot of modules this window can take a few seconds to finish setting up. when it finishes loading all the modules just choose the one u want to delete and press ok. there is no confirmation here so be careful... Also its a good idea to run dbtool after doing this as you may have lots of wasted space in the DB... - -Find and replace a value in string variables.. ----------------------------------------------- -Actions > find > find and replace... -This searches every string value in the DB and will replace the find text with the new text.. it does not replace text in value names, and there is no confirmation... - -Find text (numbers or letters) in any module, setting name or value ----------------------------------------------------------- -Actions > find > find -This window lets you search the entire database for any text (numbers included..) in module names, setting names and setting values... -Double clicking any of the found items will cause the main DBE++ window to select that item... - -Keep a list of variables you need to watch (AKA watch list) -------------------------------------------- -if there is a variable you want to keep an eye on (testing something?) then right click the setting in the list and go "watch". (you can also watch entire modules by right clicking them). To then see the watch list use the watches > view all menu item. A new window will apear with all the watched settings. double clicking any of them will find the item in the main window. If you have chosen to be notified with popups then any watched setting that changes will create a popup (even if the DBE++ and watch list windows are not open) -Currently there is no way to save the list after a restart... - -display modules which are not currently being used (AKA known modules list) ---------------------------------------------------------------------------- -If a module has the yellow folder icon it means that the module is currently being used, e.g the DBEditorpp module will always be yellow because its being used by this plugin... but the Chat module will only be yellow if you have the chat plugin enabled and installed... If you dont care whether a module is being used or not then u can turn this feature off in the options... -Unfortuantly, the only way to know which modules are being used is by other plugins letting DBE++ know... so untill more plugins get updated to use this feature you can add module names to the edit box in options > plugins > Database Editor++ (changeing this requires a restart to take effect), OR you can use an mbot script to add modules "on the fly" (read below) -Plugin developers please read below how to add your modules... - -Renameing modules ------------------ -Select the module you want to rename and press f2 or click the name again and you can type a new name, pressing esc will cancel the change, anything else will accept the change with no confirmation. - -Other Stuff ----------- -Everything else should be self-explanatory or easily done by context menu items.... - - -ADDING YOUR MODULES TO THE KNOWN MODULES LIST ------------------------------------------------- -If your plugin only uses ONE module then you can use the "DBEditorpp/RegisterSingleModule" Service function like this: -CallService("DBEditorpp/RegisterSingleModule",(WPARAM)"modName",0); -If you have more than one module then use the "DBEditorpp/RegisterModule" with the WPARAM char** and LPARAM int being the number of modules to register.. -e.g -{ - char *mods[4] = {"module1","Module2","Module3"}; - CallService("DBEditorpp/RegisterModule",(WPARAM)mods,(LPARAM)3); -} -REMEMBER TO DO THIS IN OR AFTER ME_SYSTEM_MODULESLOADED HAS BEEN TRIGGERED.... - -DOING IT WITH MSP (formerly mBot).. -If you want to add modules "on-the-fly" you can add them with an mbot script like this: - -then refresh the module tree and the module will be known.. - -Translation ------------ -ive added a translation.txt file in the archive... apart from the text in the windows i tihnk it has everything... - -Changelog ---------- -3.1 -- added icon manager support coz you people are annoying... btw huge thanx to Angeli-ka for the icons -- fixed a bug in the find and replace code... -- added a fix to disallow inline setting editing on win98 and winME to stop crashes -- big thanx to Std for pointing out (and fixing) some stupid bugs in the export/import code -- menu should be translatable now -- added a bit more room in the options dialog for tranlsators -- added in bio's code changes which seems to have fixed the popup module crash problem... (hopefully) (THANX BIO) -- the old "KnownModules" module is now used again... any modules in that are added -- still trying to work out how to not save the window size if it was maximised... -- added a "add module to known list" menu item -- modules added in the options page can now have a space in their name (put a \ before the space for it to work) -- fixed the options page a bit -- now asks to overwrite files when you export... -- no more contact proto icons in the contact list -- fixed various translation problems - -3.0 -- 99% recode and now it all works nicely :) - -1.0->2.0 -- old stuff.... not relevant anymore - ------------------------------- - -(c) 2005 Jonathan Gordon (jdgordy@gmail.com) - -contact me on ICQ, MSN, Email or Telepathy... just make sure you tell me who you are or youll get blocked :) -ICQ: 98791178 -MSN: jonnog@hotmail.com -Jabber: jdgordy@jabber.zim.net.au - diff --git a/plugins/Svc_dbepp/dbeditorpp_translation.txt b/plugins/Svc_dbepp/dbeditorpp_translation.txt deleted file mode 100644 index 6d90341b35..0000000000 --- a/plugins/Svc_dbepp/dbeditorpp_translation.txt +++ /dev/null @@ -1,38 +0,0 @@ -Database Editor++ -Error Loading Module List -Couldnt create the image list... -Error Loading Setting List -Settings -(UNLOADED) -(UNKNOWN) -Contacts - -Are you sure you want to delete module \"%s\"? -Confirm Module Deletion - -Name -Data -Type -Size -BLOB -BYTE -WORD -DWORD -STRING - -Delete module from Database -Delete module from Database... Loading -Enter a string to search the DB for - -Found Module \"%s\" in contact \"%s\" ; <- module, contact name -Found Setting \"%s\" in module \"%s\" in contact \"%s\" ; <- setting, module, contact name -Found in Setting \"%s\" in module \"%s\" in contact \"%s\" ; <-setting,module, contact name -Finished. %d items found - - -Closed Known Module -Open Known Module -Closed Unknown Module -Open Unknown Module -Contacts Group -Unknown Contact \ No newline at end of file diff --git a/plugins/Svc_dbepp/deletemodule.cpp b/plugins/Svc_dbepp/deletemodule.cpp deleted file mode 100644 index a0eddf73a1..0000000000 --- a/plugins/Svc_dbepp/deletemodule.cpp +++ /dev/null @@ -1,148 +0,0 @@ -#include "headers.h" - -static int working; -static HWND hwnd2Delete = NULL; - -int deleteModule(char* module, HANDLE hContact, int fromMenu) -{ - char msg[1024]; - ModuleSettingLL settinglist; - struct ModSetLinkLinkItem *setting; - - if (!module) return 0; - - if (!fromMenu) - { - mir_snprintf(msg, SIZEOF(msg), Translate("Are you sure you want to delete module \"%s\"?"), module); - if (DBGetContactSettingByte(NULL,modname, "WarnOnDelete",1)) - { - if (MessageBox(0,msg, Translate("Confirm Module Deletion"), MB_YESNO|MB_ICONEXCLAMATION) == IDNO) - return 0; - } - } - - if (!EnumSettings(hContact,module,&settinglist)) return 0; - - setting = settinglist.first; - while (setting) - { - DBDeleteContactSetting(hContact, module, setting->name); - setting = (struct ModSetLinkLinkItem *)setting->next; - } - FreeModuleSettingLL(&settinglist); - return 1; -} - -void __cdecl PopulateModuleDropListThreadFunc(LPVOID di) -{ - HWND hwnd = (HWND)di; - ModuleSettingLL msll; - struct ModSetLinkLinkItem *module; - HANDLE hContact; - int moduleEmpty; - if (!EnumModules(&msll)) DestroyWindow(hwnd); - module = msll.first; - while (module && working) - { - moduleEmpty = 1; - // check the null - if (!IsModuleEmpty(NULL,module->name)) - { - SendDlgItemMessage(hwnd,IDC_CONTACTS,CB_ADDSTRING,0,(LPARAM)module->name); - moduleEmpty = 0; - module = (struct ModSetLinkLinkItem *)module->next; - continue; - } - for (hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);moduleEmpty && hContact;hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0)) - { - if (!IsModuleEmpty(hContact,module->name)) - { - SendDlgItemMessage(hwnd,IDC_CONTACTS,CB_ADDSTRING,0,(LPARAM)module->name); - moduleEmpty = 0; - break; - } - } - - module = (struct ModSetLinkLinkItem *)module->next; - SendDlgItemMessage(hwnd,IDC_CONTACTS,CB_SETCURSEL,0,0); - } - SendDlgItemMessage(hwnd,IDC_CONTACTS,CB_SETCURSEL,0,0); - FreeModuleSettingLL(&msll); - SetWindowText(hwnd,Translate("Delete module from Database")); - EnableWindow(GetDlgItem(hwnd,IDC_CONTACTS),1); - EnableWindow(GetDlgItem(hwnd,IDOK),1); - EnableWindow(GetDlgItem(hwnd,IDCANCEL),1); - - if (!working) - PostMessage(hwnd, WM_COMMAND, (WPARAM)IDCANCEL, 0); - else - working = 2; -} - -INT_PTR CALLBACK DeleteModuleDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - switch(msg) - { - case WM_INITDIALOG: - { - SetWindowText(hwnd,Translate("Delete module from Database... Loading")); - EnableWindow(GetDlgItem(hwnd,IDC_CONTACTS),0); - EnableWindow(GetDlgItem(hwnd,IDOK),0); - SetDlgItemText(hwnd,IDC_INFOTEXT,"Delete module from Database"); - SetDlgItemText(hwnd,CHK_COPY2ALL,"Delete module from all contacts (Includes Setting)"); - EnableWindow(GetDlgItem(hwnd,CHK_COPY2ALL),0); - CheckDlgButton(hwnd,CHK_COPY2ALL,1); - TranslateDialogDefault(hwnd); - working = 1; - forkthread(PopulateModuleDropListThreadFunc,0,hwnd); - } - return TRUE; - case WM_COMMAND: - switch(LOWORD(wParam)) - { - case IDOK: - { - char text[128]; - HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); - GetDlgItemText(hwnd,IDC_CONTACTS,text,128); - SetCursor(LoadCursor(NULL,IDC_WAIT)); - while (hContact) - { - deleteModule(text,hContact,1); - hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); - } - // do the null - deleteModule(text,NULL,1); - SetCursor(LoadCursor(NULL,IDC_ARROW)); - refreshTree(1); - } - // fall through - case IDCANCEL: - { - if (working == 1) - { - working = 0; - EnableWindow(GetDlgItem(hwnd,IDCANCEL),0); - } - else - DestroyWindow(hwnd); - } - break; - } - break; - case WM_DESTROY: - hwnd2Delete = NULL; - break; - } - return 0; -} - - - -void deleteModuleGui() -{ - if (!hwnd2Delete) - hwnd2Delete = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_COPY_MOD), hwnd2mainWindow, DeleteModuleDlgProc, (LPARAM)0); - else - SetForegroundWindow(hwnd2Delete); -} \ No newline at end of file diff --git a/plugins/Svc_dbepp/exportimport.cpp b/plugins/Svc_dbepp/exportimport.cpp deleted file mode 100644 index ad9f508a21..0000000000 --- a/plugins/Svc_dbepp/exportimport.cpp +++ /dev/null @@ -1,745 +0,0 @@ -#include "headers.h" - -int Mode; -HWND hwnd2importWindow; - -int Openfile(char *outputFile, const char *module) -{ - OPENFILENAME ofn = {0}; - char filename[MAX_PATH] = ""; - char filter[MAX_PATH]; - mir_snprintf(filter, SIZEOF(filter), "%s%c*.ini%c%s%c*.*%c", Translate("INI Files"), 0, 0, Translate("All Files"), 0, 0); - char *title = Translate("Export to file"); - - if (module) - { - int n = 0; - mir_strncpy(filename, module, MAX_PATH); - - while(filename[n]) - { - switch(filename[n]) - { - case '*': - case ':': - case '/': - case '?': - case '|': - case '\\': - filename[n] = '_'; - break; - } - n++; - } - } - - ofn.lStructSize = sizeof(ofn); - ofn.lpstrFile = filename; - ofn.lpstrFilter = filter; - ofn.Flags = OFN_HIDEREADONLY | OFN_SHAREAWARE | OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT; - ofn.lpstrTitle = title; - ofn.nMaxFile = MAX_PATH; - ofn.lpstrDefExt = "ini"; - - if (!GetSaveFileName(&ofn)) - return 0; - lstrcpy(outputFile,filename); - return 1; -} - -char* StrReplace (char* Search, char* Replace, char* Resource) -{ - int i = 0; - int SearchLen = (int)_tcslen(Search); - char* Work = mir_tstrdup(Replace); - int ReplaceLen = (int)_tcslen(Work); - - char* Pointer = _tcsstr(Resource, Search); - - while (Pointer != NULL) - { - int PointerLen = (int)_tcslen(Pointer); - int ResourceLen = (int)_tcslen(Resource); - - char* NewText = (char*)mir_calloc((ResourceLen - SearchLen + ReplaceLen + 1)*sizeof(char)); - - _tcsncpy(NewText, Resource, ResourceLen - PointerLen); - _tcscat(NewText, Work); - _tcscat(NewText, Pointer + SearchLen); - - Resource = (char*)mir_realloc(Resource, (ResourceLen - SearchLen + ReplaceLen + 1)*sizeof(char)); - - for (i = 0; i < (ResourceLen - SearchLen + ReplaceLen); i++) - Resource[i] = NewText[i]; - Resource[i] = 0; - mir_free(NewText); - - Pointer = _tcsstr(Resource + (ResourceLen - PointerLen + ReplaceLen), Search); - } - mir_free(Work); - - return Resource; -} - -void exportModule(HANDLE hContact, char* module, FILE* file) -{ - char tmp[32]; - ModuleSettingLL settinglist; - struct ModSetLinkLinkItem *setting; - - EnumSettings(hContact,module,&settinglist); - - // print the module header.. - fprintf(file, "\n[%s]", module); - setting = settinglist.first; - while(setting) - { - DBVARIANT dbv; - if (!GetSetting(hContact, module, setting->name, &dbv)) - { - switch (dbv.type) - { - case DBVT_BYTE: - fprintf(file, "\n%s=b%s", setting->name, itoa(dbv.bVal,tmp,10)); - DBFreeVariant(&dbv); - break; - case DBVT_WORD: - fprintf(file, "\n%s=w%s", setting->name, itoa(dbv.wVal,tmp,10)); - DBFreeVariant(&dbv); - break; - case DBVT_DWORD: - fprintf(file, "\n%s=d%s", setting->name, itoa(dbv.dVal,tmp,10)); - DBFreeVariant(&dbv); - break; - case DBVT_ASCIIZ: - case DBVT_UTF8: - if (strchr(dbv.pszVal, '\r')) - { - char *end = StrReplace("\\", "\\\\", dbv.pszVal); - end = StrReplace("\r", "\\r", end); - end = StrReplace("\n", "\\n", end); - fprintf(file, "\n%s=g%s", setting->name, end); - break; - } - if (dbv.type == DBVT_UTF8) - fprintf(file, "\n%s=u%s", setting->name, dbv.pszVal); - else - fprintf(file, "\n%s=s%s", setting->name, dbv.pszVal); - DBFreeVariant(&dbv); - break; - case DBVT_BLOB: - { - int j; - char *data = NULL; - if (!(data = (char*)mir_alloc( 3*(dbv.cpbVal+1)*sizeof(char)))) - break; - data[0] = '\0'; - for (j=0; jname , data); - mir_free(data); - } - DBFreeVariant(&dbv); - break; - } - } - setting = (struct ModSetLinkLinkItem *)setting->next; - } - FreeModuleSettingLL(&settinglist); -} - - -char *NickFromHContact(HANDLE hContact) -{ - static char nick[512] = ""; - - if (hContact) - { - char szProto[256]; - int loaded = 0; - - if (GetValue(hContact,"Protocol","p",szProto,SIZEOF(szProto))) - loaded = IsProtocolLoaded(szProto); - - if (!szProto[0] || !loaded) - { - char name[256]; - - if (szProto[0]) - { - if (GetValue(hContact,szProto,"Nick",name,SIZEOF(name))) - mir_snprintf(nick, SIZEOF(nick),"%s (%s)", name, szProto); - else - mir_snprintf(nick, SIZEOF(nick),"(UNKNOWN) (%s)", szProto); - } - else - mir_snprintf(nick, SIZEOF(nick),"(UNKNOWN)"); - } - else - { - char *uid; - char szUID[256]; - - uid = (char*)CallProtoService(szProto,PS_GETCAPS,PFLAG_UNIQUEIDSETTING,0); - if ((int)uid!=CALLSERVICE_NOTFOUND && uid) - { - GetValue(hContact, szProto, uid, szUID, SIZEOF(szUID)); - mir_snprintf(nick, SIZEOF(nick), "%s *(%s)*<%s>*{%s}*", (char*)GetContactName(hContact,szProto,0), szProto, uid, szUID); - } - else - mir_snprintf(nick, SIZEOF(nick), "%s (%s)", (char*)GetContactName(hContact,szProto,0), szProto); - } - } - - return nick; -} - - -void exportDB(HANDLE hContact, char* module) // hContact == -1 export entire db. module == NULL export entire contact. -{ // hContact == -1, module == "" - all contacts - FILE* file = NULL; - char fileName[MAX_PATH]; - int nullcontactDone = 0; - ModuleSettingLL modlist; - struct ModSetLinkLinkItem *mod; - - // enum all the modules - if (!EnumModules(&modlist)) { msg(Translate("Error Loading Module List"),modFullname); return;} - - if (Openfile(fileName, ((int)hContact==-1)?NULL:module)) - { - if (!(file = fopen(fileName, "wt"))) { msg(Translate("Couldn't open file for writing"), modFullname); return; } - - SetCursor(LoadCursor(NULL,IDC_WAIT)); - - // exporting entire db - if (hContact == INVALID_HANDLE_VALUE) - { - hContact = NULL; - - if (module == NULL) - { - fprintf(file, "SETTINGS:\n"); - mod = modlist.first; - while(mod) - { - if (IsModuleEmpty(hContact, mod->name)) - { - mod = (struct ModSetLinkLinkItem *)mod->next; - continue; - } - exportModule(hContact, mod->name, file); - mod = (struct ModSetLinkLinkItem *)mod->next; - if (mod) - fprintf(file, "\n"); - } - } - else - { - if (module == "") module = NULL; // reset module for all contacts export - } - - hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); - - while (hContact) - { - if (!hContact) continue; - - // filter - if (Mode != MODE_ALL) - { - char szProto[256]; - int loaded = 0; - - if (GetValue(hContact,"Protocol","p",szProto,SIZEOF(szProto))) - loaded = IsProtocolLoaded(szProto); - - if ((loaded && Mode == MODE_UNLOADED) || (!loaded && Mode == MODE_LOADED)) - { - hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); - continue; - } - } - - fprintf(file, "CONTACT: %s\n", NickFromHContact(hContact)); - - if (module == NULL) // export all modules - { - mod = modlist.first; - while(mod) - { - if (IsModuleEmpty(hContact, mod->name)) - { - mod = (struct ModSetLinkLinkItem *)mod->next; - continue; - } - exportModule(hContact, mod->name, file); - mod = (struct ModSetLinkLinkItem *)mod->next; - if (mod) - fprintf(file, "\n"); - } - } - else // export module - { - exportModule(hContact, module, file); - } - hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)(HANDLE)hContact, 0); - } - } - // exporting a contact - else - { - if (!module) // exporting every module - { - if (hContact) - fprintf(file, "CONTACT: %s\n", NickFromHContact(hContact)); - else - fprintf(file, "SETTINGS:\n"); - - mod = modlist.first; - while(mod) - { - if (IsModuleEmpty(hContact, mod->name)) - { - mod = (struct ModSetLinkLinkItem *)mod->next; - continue; - } - exportModule(hContact, mod->name, file); - mod = (struct ModSetLinkLinkItem *)mod->next; - if (mod) - fprintf(file, "\n"); - } - } - else - { - if (hContact) - fprintf(file, "FROM CONTACT: %s\n", NickFromHContact(hContact)); - else - fprintf(file, "SETTINGS:\n"); - - exportModule(hContact, module, file); - } - } - fclose(file); - - SetCursor(LoadCursor(NULL,IDC_ARROW)); - } - - FreeModuleSettingLL(&modlist); -} - - -HANDLE CheckNewContact(char *myProto, char *uid, char *myName) -{ - char szProto[256], szName[256]; - HANDLE resultHandle = INVALID_HANDLE_VALUE; - HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); - - while (hContact) - { - //szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); - if (DBGetContactSettingStringStatic(hContact, "Protocol", "p", szProto, 256)) - { - if (!mir_strcmp(szProto, myProto)) - { - if (GetValue(hContact, szProto, uid, szName, SIZEOF(szName)) && - !mir_strcmp(szName, myName)) - { - //char msg[1024]; - //_snprintf(msg, 1024, Translate("Do you want to overwrite it \"%s\"?"), szName); - //if (MessageBox(0,msg, Translate("Contact already exists"), MB_YESNO|MB_ICONEXCLAMATION) == IDYES) - resultHandle = hContact; - break; - } - } - } - - hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); - } - - return resultHandle; - -} - -HANDLE Clist_GroupExists(WCHAR *tszGroup) -{ - unsigned int i = 0; - WCHAR* _t = 0; - char str[10]; - INT_PTR result = 0; - DBVARIANT dbv = {0}; - int match; - - do { - _itoa(i, str, 10); - result = DBGetContactSettingTString(0, "CListGroups", str, &dbv); - if (!result) { - match = (!lstrcmpW(tszGroup, (LPCWSTR)&dbv.ptszVal[1]) && (lstrlenW(tszGroup) == lstrlenW((LPCWSTR)&dbv.ptszVal[1]))); - DBFreeVariant(&dbv); - if(match) - return((HANDLE)(i + 1)); - } - i++; - } - while(result == 0); - return(0); -} - -void importSettings(HANDLE hContact, char *importstring ) -{ - char module[256] = "", setting[256] = "", *end; - int i=0, value, type; - importstring = strtok(importstring, "\n"); - - SetCursor(LoadCursor(NULL,IDC_WAIT)); - - while (importstring != NULL) - { - i=0; - rtrim(importstring); - if (importstring[i] == '\0') - { - importstring = strtok(NULL, "\n"); - continue; - } - else if (!strncmp(&importstring[i],"SETTINGS:",strlen("SETTINGS:"))) - { - importstring = strtok(NULL, "\n"); - continue; - } - else if (!strncmp(&importstring[i],"CONTACT:", strlen("CONTACT:"))) - { - int len, add = 1; - hContact = INVALID_HANDLE_VALUE; - - i = i + (int)strlen("CONTACT:"); - len = (int)strlen(&importstring[i]); - - if (len > 10) - { - char uid[256]="",szUID[256]="",szProto[512]=""; - char *p1,*p2; - - p1 = strrchr(&importstring[i], '>*{'); - p2 = strrchr(&importstring[i], '}*'); - - if (p1 && p2 && p1+3 < p2 && p2-p1 < SIZEOF(szUID)) - { - strncpy(szUID, p1+1, p2-p1-2); - - p1 = strrchr(&importstring[i], ')*<'); - p2 = strrchr(&importstring[i], '>*{'); - - if (p1 && p2 && p1+3 < p2 && p2-p1 < SIZEOF(uid)) - { - strncpy(uid, p1+1, p2-p1-3); - - p1 = strrchr(&importstring[i], ' *('); - p2 = strrchr(&importstring[i], ')*<'); - - if (p1 && p2 && p1+3 < p2 && p2-p1 < SIZEOF(szProto)) - { - char *protouid; - strncpy(szProto, p1+1, p2-p1-3); - - protouid = (char*)CallProtoService(szProto,PS_GETCAPS,PFLAG_UNIQUEIDSETTING,0); - if ((int)protouid!=CALLSERVICE_NOTFOUND) - { - if (!mir_strcmp(protouid, uid)) - hContact = CheckNewContact(szProto, uid, szUID); - } - else - hContact = CheckNewContact(szProto, uid, szUID); - } - } - } - } - - if (hContact == INVALID_HANDLE_VALUE) - { - HANDLE temp = (HANDLE)CallService(MS_DB_CONTACT_ADD,0,0); - if (temp) - hContact = temp; - } - } - else if (importstring[i] == '[' && !strchr(&importstring[i+1],'='))// get the module - { - if (end = strpbrk(&importstring[i+1], "]")) { - if ((end+1) != '\0') *end = '\0'; - strcpy(module, &importstring[i+1]); - } - } - else if (importstring[i] == '-' && importstring[i+1] == '[' && - !strchr(&importstring[i+2],'='))// get the module - { - if (end = strpbrk(&importstring[i+2], "]")) { - if ((end+1) != '\0') *end = '\0'; - strcpy(module, &importstring[i+2]); - deleteModule(module, hContact, 1); - } - } - else if (strstr(&importstring[i], "=") && module[0]) // get the setting - { - if (end = strpbrk(&importstring[i+1], "=")) { - if ((end+1) != '\0') *end = '\0'; - strcpy(setting, &importstring[i]); - - // get the type - type = *(end+1); - if (lstrcmp(module, "CList") == 0 && lstrcmp(setting, "Group") == 0) - { - WCHAR* GroupName = mir_a2u(end+2); - if (!GroupName) - continue; - HANDLE GroupHandle = Clist_GroupExists(GroupName); - if(GroupHandle == 0) { - GroupHandle = (HANDLE)CallService(MS_CLIST_GROUPCREATE, 0, (LPARAM)GroupName); - - if(GroupHandle) { - CallService(MS_CLUI_GROUPADDED, (WPARAM)GroupHandle, 0); - CallService(MS_CLIST_GROUPSETEXPANDED, (WPARAM)GroupHandle, 1); - } - } - mir_free(GroupName); - } - switch (type) - { - case 'b': - case 'B': - if (sscanf((end+2), "%d", &value) == 1) - DBWriteContactSettingByte(hContact, module, setting, (BYTE)value); - break; - case 'w': - case 'W': - if (sscanf((end+2), "%d", &value) == 1) - DBWriteContactSettingWord(hContact, module, setting, (WORD)value); - break; - case 'd': - case 'D': - if (sscanf((end+2), "%d", &value) == 1) - DBWriteContactSettingDword(hContact, module, setting, (DWORD)value); - break; - case 's': - case 'S': - DBWriteContactSettingString(hContact,module, setting, (end+2)); - break; - case 'g': - case 'G': - { char *pstr; - for(pstr=end+2;*pstr;pstr++) { - if (*pstr=='\\') { - switch(pstr[1]) { - case 'n': *pstr='\n'; break; - case 't': *pstr='\t'; break; - case 'r': *pstr='\r'; break; - default: *pstr=pstr[1]; break; - } - MoveMemory(pstr+1,pstr+2,lstrlenA(pstr+2)+1); - } } } - case 'u': - case 'U': - DBWriteContactSettingStringUtf(hContact,module, setting, (end+2)); - break; - case 'l': - case 'L': - DBDeleteContactSetting(hContact, module, setting); - break; - case 'n': - case 'N': - WriteBlobFromString(hContact, module, setting, (end+2), (int)strlen((end+2))); - break; - } - } - } - importstring = strtok(NULL, "\n"); - } - SetCursor(LoadCursor(NULL,IDC_ARROW)); -} - -INT_PTR CALLBACK ImportDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - switch(msg) - { - case WM_INITDIALOG: - { - hwnd2importWindow = hwnd; - SetWindowLongPtr(hwnd,GWLP_USERDATA,lParam); - TranslateDialogDefault(hwnd); - SendDlgItemMessage(hwnd, IDC_TEXT, EM_LIMITTEXT, (WPARAM)sizeof(TCHAR)*0x7FFFFFFF, 0); - } - break; - - case WM_COMMAND: - { - switch(LOWORD(wParam)) - { - case IDC_CRLF: - { - int length = GetWindowTextLength(GetDlgItem(hwnd, IDC_TEXT)); - char *string = (char*)_alloca(length+3); - int Pos = 2; - - if (length) - { - int Range = SendDlgItemMessage(hwnd,IDC_TEXT,EM_GETSEL,0,0); - int Min = LOWORD(Range); - int Max = HIWORD(Range); - - - GetDlgItemText(hwnd, IDC_TEXT, string, length+1); - - if (Min == -1) - memcpy(string, crlf_string, SIZEOF(crlf_string)); - else - if (Max == -1 || Max >= length) - memcpy(&string[Min], crlf_string, SIZEOF(crlf_string)); - else - if (Max-Min > 2) - { - memcpy(&string[Min], crlf_string, SIZEOF(crlf_string)); - memmove(&string[Min+2], &string[Max], length - Max + 1); - } - else - { - memmove(&string[Min+2], &string[Max], length - Max + 1); - memcpy(&string[Min], crlf_string, SIZEOF(crlf_string)); - } - - if (Min) Pos += Min; - } - else - memcpy(string, crlf_string, SIZEOF(crlf_string)); - - SetDlgItemText(hwnd, IDC_TEXT, string); - SendDlgItemMessage(hwnd,IDC_TEXT,EM_SETSEL,Pos,Pos); - SetFocus(GetDlgItem(hwnd, IDC_TEXT)); - } - break; - - case IDOK: - { - HANDLE hContact = (HANDLE)GetWindowLongPtr(hwnd,GWLP_USERDATA); - int length = GetWindowTextLength(GetDlgItem(hwnd, IDC_TEXT)); - char *string; - if (length) - { - string = (char*)_alloca(length+1); - if (!string) {msg(Translate("Couldnt allocate enough memory!"), modFullname); DestroyWindow(hwnd); } - GetDlgItemText(hwnd, IDC_TEXT, string, length+1); - importSettings(hContact, string); - refreshTree(1); - } - } - break; - - case IDCANCEL: - DestroyWindow(hwnd); - hwnd2importWindow = 0; - break; - } - } - break; - } - return 0; -} - -void ImportSettingsMenuItem(HANDLE hContact) -{ - if (hwnd2importWindow) - DestroyWindow(hwnd2importWindow); - - CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_IMPORT), 0, ImportDlgProc, (LPARAM)hContact); -} - -int Openfile2Import(char *outputFiles) -{ - OPENFILENAME ofn = {0}; - char filter[MAX_PATH]; - mir_snprintf(filter, SIZEOF(filter), "%s%c*.ini%c%s%c*.*%c", Translate("INI Files"), 0, 0, Translate("All Files"), 0, 0); - char *title = Translate("Import from files"); - - ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; - ofn.lpstrFilter = filter; - ofn.hwndOwner = 0; - ofn.lpstrFile = outputFiles; - ofn.nMaxFile = MAX_PATH*10; - ofn.nMaxFileTitle = MAX_PATH; - ofn.Flags = OFN_HIDEREADONLY | OFN_SHAREAWARE | OFN_PATHMUSTEXIST | OFN_ALLOWMULTISELECT | OFN_EXPLORER; - ofn.lpstrTitle = title; - if (!GetOpenFileName(&ofn)) - return 0; - - return ofn.nFileOffset; -} - -BOOL Exists(LPCTSTR strName) -{ - return GetFileAttributes(strName) != INVALID_FILE_ATTRIBUTES; -} - -void ImportSettingsFromFileMenuItem(HANDLE hContact, char* FilePath) -{ - char szFileNames[MAX_PATH*10] = {0}; - char szPath[MAX_PATH] = ""; - char szFile[MAX_PATH]; - int index = 0; - HANDLE hFile, hMap; - PBYTE pFile = NULL; - DWORD offset = 0; - if (lstrcmp(FilePath, "") == 0) - offset = Openfile2Import(szFileNames); - else - { - if(Exists(FilePath)) - lstrcpy(szFileNames, FilePath); - else - lstrcpy(szFileNames, ""); - } - - if (!lstrcmp(szFileNames, "") == 0) - { - if ((DWORD)lstrlenA(szFileNames) < offset) - { - index += offset; - strncpy(szPath, szFileNames, offset); - strcat(szPath, "\\"); - } - - while(szFileNames[index]) - { - strcpy(szFile, szPath); - strcat(szFile, &szFileNames[index]); - index += (int)strlen(&szFileNames[index])+1; - - hFile = CreateFile(szFile, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); - if (hFile != INVALID_HANDLE_VALUE) - { - if (GetFileSize(hFile, NULL) > 0) - { - hMap = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL); - - if (hMap) { - pFile = (PBYTE)MapViewOfFile(hMap, FILE_MAP_COPY, 0, 0 ,0); - - if (pFile) { - importSettings(hContact, (char*)pFile); - UnmapViewOfFile(pFile); - } - CloseHandle(hMap); - } - - } - CloseHandle(hFile); - } - else - break; - - } - if (lstrcmp(FilePath, "") == 0) - refreshTree(1); - } -} diff --git a/plugins/Svc_dbepp/findwindow.cpp b/plugins/Svc_dbepp/findwindow.cpp deleted file mode 100644 index b9957cd246..0000000000 --- a/plugins/Svc_dbepp/findwindow.cpp +++ /dev/null @@ -1,725 +0,0 @@ -#include "headers.h" - -void __cdecl FindSettings(LPVOID di); - -static int working; -static int replace; - -#define FW_CASE 1 -#define FW_EXACT 2 -#define FW_MODNAME 4 -#define FW_SETNAME 8 -#define FW_SETVAL 16 - -#define FW_REPLACED 0x100 -#define FW_DELETED 0x200 - -#define RW_MODULE 1 -#define RW_SETNAME 2 -#define RW_SETVAL 4 -#define RW_FOUND 8 - -#define RW_FULL 0x100 -#define RW_CASE 0x200 - -typedef struct { - HWND hwnd; // hwnd 2 item list - char* text; // text to find - int options; // or'd about items - char* replace; // text to replace - int mode; // replace mode -} FindInfo; - - -int FindDialogResize(HWND hwnd,LPARAM lParam,UTILRESIZECONTROL *urc) -{ - switch(urc->wId) { - case IDC_LIST: - return RD_ANCHORX_WIDTH|RD_ANCHORY_HEIGHT; - case IDC_SBAR: - return RD_ANCHORX_WIDTH|RD_ANCHORY_BOTTOM; - default: - return RD_ANCHORX_LEFT|RD_ANCHORY_TOP; - } -} - - -void freeItems(HWND hwnd) -{ - int i; - ItemInfo *ii; - for (i=0;ihwnd = GetDlgItem(hwnd,IDC_LIST); - fi->options = (IsDlgButtonChecked(hwnd,IDC_CASESENSITIVE)?FW_CASE:0)| - (IsDlgButtonChecked(hwnd,IDC_EXACT)?FW_EXACT:0)| - (IsDlgButtonChecked(hwnd,IDC_MODNAME)?FW_MODNAME:0)| - (IsDlgButtonChecked(hwnd,IDC_SETTINGNAME)?FW_SETNAME:0)| - (IsDlgButtonChecked(hwnd,IDC_SETTINGVALUE)?FW_SETVAL:0); - - if (GetWindowLongPtr(GetDlgItem(hwnd,IDC_REPLACE),GWLP_USERDATA)) - { - if (IsDlgButtonChecked(hwnd,IDC_FOUND)) - fi->mode = RW_FOUND; - else - if (IsDlgButtonChecked(hwnd,IDC_MODNAME2)) - fi->mode = RW_MODULE; - else - if (IsDlgButtonChecked(hwnd,IDC_SETTINGNAME2)) - fi->mode = RW_SETNAME; - else - if (IsDlgButtonChecked(hwnd,IDC_SETTINGVALUE2)) - fi->mode = RW_SETVAL; - - if (IsDlgButtonChecked(hwnd,IDC_ENTIRELY)) - fi->mode |= RW_FULL; - - fi->replace = mir_tstrdup(replace); - - SetWindowText(GetDlgItem(hwnd,IDOK),Translate("Stop")); - EnableWindow(GetDlgItem(hwnd,IDC_SEARCH),0); - - if (IsDlgButtonChecked(hwnd,IDC_CASESENSITIVE)) - fi->mode |= RW_CASE; - } - else - { - SetWindowText(GetDlgItem(hwnd,IDC_SEARCH),Translate("Stop")); - EnableWindow(GetDlgItem(hwnd,IDOK),0); - } - - fi->text = mir_tstrdup(text); - - SendDlgItemMessage(hwnd,IDC_LIST,LB_RESETCONTENT,0,0); - SetWindowLongPtr(GetDlgItem(hwnd,IDC_SEARCH),GWLP_USERDATA,1); - - EnableWindow(GetDlgItem(hwnd,IDCANCEL),0); - forkthread(FindSettings,0,fi); - } - } - break; - case IDCANCEL: - DestroyWindow(hwnd); - break; - case IDC_LIST: - if (HIWORD(wParam) == LBN_DBLCLK) - { - int i = SendDlgItemMessage(hwnd,IDC_LIST,LB_GETCURSEL,0,0); - ItemInfo *ii =(ItemInfo*)SendDlgItemMessage(hwnd,IDC_LIST,LB_GETITEMDATA,i,0); - if (!ii) break; - SendMessage(GetParent(hwnd),WM_FINDITEM,(WPARAM)ii,0); - } - break; - } - break; - case WM_GETMINMAXINFO: - { - MINMAXINFO *mmi=(MINMAXINFO*)lParam; - mmi->ptMinTrackSize.x=520; - mmi->ptMinTrackSize.y=300; - return 0; - } - case WM_SIZE: - { - UTILRESIZEDIALOG urd; - ZeroMemory(&urd,sizeof(urd)); - urd.cbSize=sizeof(urd); - urd.hInstance=hInst; - urd.hwndDlg=hwnd; - urd.lpTemplate=MAKEINTRESOURCE(IDD_FIND); - urd.pfnResizer=FindDialogResize; - CallService(MS_UTILS_RESIZEDIALOG,0,(LPARAM)&urd); - } - break; - case WM_DESTROY: - freeItems(hwnd); - break; - } - return 0; -} - - -void ItemFound(HWND hwnd, HANDLE hContact,const char *module,const char *setting,const char* value,int type) -{ - ItemInfo *ii = (ItemInfo*)mir_calloc(sizeof(ItemInfo)); - int index; - char text[256] = ""; - int result = 0; - char szValue[256]; - char *name, *mode; - - if (!ii) return; - - if (type & FW_REPLACED) - mode = Translate("Replaced with"); - else - if (type & FW_DELETED) - mode = Translate("Deleted"); - else - mode = Translate("Found"); - - name = hContact?(char*)GetContactName(hContact,NULL,0):Translate("Settings"); - - switch (type & 0xFF) - { - case FW_MODULE: - ii->type = FW_MODULE; - mir_snprintf(text, SIZEOF(text), Translate("%s Module \"%s\" in contact \"%s\""), mode, module, name); - break; - case FW_SETTINGNAME: - mir_strncpy(ii->setting,setting,256); - ii->type = FW_SETTINGNAME; - if (GetValue(hContact,module,setting, szValue, SIZEOF(szValue))) - mir_snprintf(text, SIZEOF(text), Translate("%s Setting \"%s\" in module \"%s\" in contact \"%s\" - \"%s\""), mode, setting, module, name, szValue); - else - mir_snprintf(text, SIZEOF(text), Translate("%s Setting \"%s\" in module \"%s\" in contact \"%s\""), mode, setting, module, name); - break; - case FW_SETTINGVALUE: - mir_strncpy(ii->setting,setting,256); - ii->type = FW_SETTINGVALUE; - mir_snprintf(text, SIZEOF(text), Translate("%s \"%s\" in Setting \"%s\" in module \"%s\" in contact \"%s\""), mode, value, setting, module, name); - break; - } - - index = SendMessage(hwnd,LB_ADDSTRING,0,(LPARAM)text); - if (type & FW_DELETED) - { - SendMessage(hwnd,LB_SETITEMDATA,index,0); - mir_free(ii); - } - else - { - ii->hContact= hContact; - mir_strncpy(ii->module,module,256); - SendMessage(hwnd,LB_SETITEMDATA,index,(LPARAM)ii); - } -} - - -char *multiReplace(const char* value, const char *find, const char *replace, int cs) -{ - char *head, *temp, *string; - - int len = (int)strlen(find); - int replen = (int)strlen(replace); - - if (head = (char*)(cs?strstr(value, find):StrStrI(value, find))) // only should be 1 '=' sign there... - { - string = (char*)value; - temp = (char*)mir_alloc(1*sizeof(char)); - temp[0] = '\0'; - - while (head) - { - temp = (char*)mir_realloc(temp, strlen(temp) + strlen(string) + replen + 1); - if (!temp) mir_tstrdup(value); - - strncat(temp, string, (head - string)); - string = head + len; - strcat(temp, replace); - - head = (cs?strstr(string, find):StrStrI(string, find)); - } - strcat(temp, string); - - return temp; - } - - return mir_tstrdup(value); -} - - -int replaceValue(HWND hwnd, HANDLE hContact, const char *module, const char *setting, DBVARIANT *dbv, const char *find, const char *replace, int mode) -{ - - int count = 0; - - DWORD num = 0; - BOOL write = 0; - int isNumeric; - char *myreplace = NULL; - DBCONTACTWRITESETTING cws = {0}; - - if (!dbv->type || dbv->type == DBVT_BLOB) - return 0; - - if (!replace[0]) - isNumeric = 1; - else - isNumeric = sscanf(replace,"%d",&num); - - cws.szModule=module; - cws.szSetting=setting; - cws.value.type=dbv->type; - - switch(dbv->type) - { - case DBVT_UTF8: - case DBVT_ASCIIZ: - if (mode & RW_FULL) - cws.value.pszVal = (char*)replace; - else - { - myreplace = multiReplace(dbv->pszVal, find, replace, mode & RW_CASE); - cws.value.pszVal=myreplace; - } - break; - - case DBVT_BYTE: - if (isNumeric && num < 0x100) - cws.value.bVal = (BYTE)num; - else - return 0; - break; - - case DBVT_WORD: - if (isNumeric && num < 0x10000) - cws.value.wVal = (WORD)num; - else - return 0; - break; - - case DBVT_DWORD: - if (isNumeric) - cws.value.dVal = num; - else - return 0; - break; - - default: - return 0; - } - - if ((!cws.value.pszVal && !replace[0]) || (cws.value.pszVal && !cws.value.pszVal[0])) - { - ItemFound(hwnd,hContact,module,setting,NULL,FW_SETTINGNAME|FW_DELETED); - DBDeleteContactSetting(hContact,module,setting); - mir_free(myreplace); - return 1; - } - - if (!CallService(MS_DB_CONTACT_WRITESETTING,(WPARAM)hContact,(LPARAM)&cws)) - { - count++; - ItemFound(hwnd,hContact,module,setting,myreplace?myreplace:(char*)replace,FW_SETTINGVALUE|FW_REPLACED); - } - - mir_free(myreplace); - - return count; -} - - -int replaceSetting(HWND hwnd, HANDLE hContact, const char *module, const char *setting, DBVARIANT *dbv, const char *find, const char *replace, int mode) -{ - DBCONTACTWRITESETTING cws; - char *myreplace = NULL; - int count = 0; - DBVARIANT dbv2; - - if (!dbv->type) return 0; - - if (mode & RW_FULL) - cws.szSetting = (char*)replace; - else - { - myreplace = multiReplace(setting, find, replace, mode & RW_CASE); - cws.szSetting = myreplace; - } - - if (cws.szSetting[0]==0) - { - ItemFound(hwnd,hContact,module,setting,NULL,FW_SETTINGNAME|FW_DELETED); - DBDeleteContactSetting(hContact,module,setting); - mir_free(myreplace); - return 1; - } - - // check & write - if (GetSetting(hContact, module, myreplace, &dbv2)) - { - cws.szModule=module; - cws.value.type=dbv->type; - cws.value.pszVal=dbv->pszVal; - cws.value.bVal=dbv->bVal; - cws.value.wVal=dbv->wVal; - cws.value.dVal=dbv->dVal; - cws.value.pbVal = dbv->pbVal; - cws.value.cpbVal = dbv->cpbVal; - - if (!CallService(MS_DB_CONTACT_WRITESETTING,(WPARAM)hContact,(LPARAM)&cws)) - { - count++; - DBDeleteContactSetting(hContact,module,setting); - ItemFound(hwnd,hContact,module,cws.szSetting,NULL,FW_SETTINGNAME|FW_REPLACED); - } - } - else - DBFreeVariant(&dbv2); - - mir_free(myreplace); - - return count; -} - - -int replaceModule(HWND hwnd, HANDLE hContact, const char *module, const char *find, const char *replace, int mode) -{ - - ModuleSettingLL msll; - struct ModSetLinkLinkItem *setting; - char *myreplace = NULL; - char *newModule; - int count = 0; - - if (mode & RW_FULL) - newModule = (char*)replace; - else - { - myreplace = multiReplace(module, find, replace, mode & RW_CASE); - newModule = myreplace; - } - - if (newModule[0]==0) - { - ItemFound(hwnd,hContact,module,NULL,NULL,FW_MODULE|FW_DELETED); - deleteModule((char*)module, hContact, 1); - replaceTreeItem(GetDlgItem(hwnd2mainWindow,IDC_MODULES), hContact, module, NULL); - mir_free(myreplace); - return 1; - } - - if (!IsModuleEmpty(hContact, newModule)) - return 0; - - if (EnumSettings(hContact,(char*)module,&msll)) - { - setting = msll.first; - - while(setting) - { - DBVARIANT dbv; - - if (!GetSetting(hContact, module, setting->name, &dbv)) - { - switch (dbv.type) - { - case DBVT_BYTE: - DBWriteContactSettingByte(hContact, newModule, setting->name, dbv.bVal); - break; - case DBVT_WORD: - DBWriteContactSettingWord(hContact, newModule, setting->name, dbv.wVal); - break; - case DBVT_DWORD: - DBWriteContactSettingDword(hContact, newModule, setting->name, dbv.dVal); - break; - case DBVT_ASCIIZ: - DBWriteContactSettingString(hContact, newModule, setting->name, dbv.pszVal); - break; - case DBVT_UTF8: - DBWriteContactSettingStringUtf(hContact, newModule, setting->name, dbv.pszVal); - break; - case DBVT_BLOB: - DBWriteContactSettingBlob(hContact, newModule, setting->name, dbv.pbVal, dbv.cpbVal); - break; - } - - DBFreeVariant(&dbv); - DBDeleteContactSetting(hContact, module, setting->name); - } - - setting = (struct ModSetLinkLinkItem *)setting->next; - } - FreeModuleSettingLL(&msll); - - replaceTreeItem(GetDlgItem(hwnd2mainWindow,IDC_MODULES), hContact, module, newModule); - - ItemFound(hwnd,hContact,newModule,NULL,NULL,FW_MODULE|FW_REPLACED); - count++; - } - - mir_free(myreplace); - - return count; -} - - -char* stringToUpper(char* in, char* out, int maxlen) -{ - int i; - int len; - - if (maxlen>0) - len = maxlen - 1; - else - len = 0x10000; - - for (i=0;in[i] && i='a' && in[i]<='z')?toupper(in[i]):in[i]; - out[i] = '\0'; - - return out; -} - - -void __cdecl FindSettings(LPVOID di) -{ - char* text = ((FindInfo*)di)->text; - char* replace = ((FindInfo*)di)->replace; - int mode = ((FindInfo*)di)->mode; - HWND hwnd = ((FindInfo*)di)->hwnd; - HWND prnthwnd = GetParent(hwnd); - int options = ((FindInfo*)di)->options; - ModuleSettingLL ModuleList, SettingList; - struct ModSetLinkLinkItem *module, *setting; - HANDLE hContact; - DBVARIANT dbv = {0}; - int caseSensitive = options&FW_CASE; - int exactMatch = options&FW_EXACT; - int inModuleName = options&FW_MODNAME; - int inSettingName = options&FW_SETNAME; - int inSettingValue = options&FW_SETVAL; - int foundCount = 0; - int replaceCount = 0; - char szTmp[128]; - int settingValue, isNumber, NULLContactDone = 0; - - freeItems(hwnd); - if (!text) return; - - if (!EnumModules(&ModuleList)) { msg(Translate("Error Loading Module List"),modFullname); mir_free(di); return;} - - SendMessage(GetDlgItem(GetParent(hwnd),IDC_SBAR),SB_SETTEXT,0,(LPARAM)Translate("Searching...")); - - hContact = 0; - - isNumber = sscanf(text,"%d",&settingValue); - - while (GetWindowLongPtr(GetDlgItem(prnthwnd,IDC_SEARCH),GWLP_USERDATA)) - { - if (!hContact) - { - if (NULLContactDone) break; - else - { - NULLContactDone = 1; - hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); - } - } - else hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); - - module = ModuleList.first; - while (module) - { - if (IsModuleEmpty(hContact, module->name)) - { - module = (struct ModSetLinkLinkItem *)module->next; - continue; - } - - if (!EnumSettings(hContact,module->name,&SettingList)) - { - msg(Translate("Error Loading Setting List"),modFullname); - mir_free(text); - mir_free(di); - FreeModuleSettingLL(&ModuleList); - return; - } - setting = SettingList.first; - - // check in settings value - while (setting) - { - if (inSettingValue) - { - dbv.type = 0; - // check the setting value - if (!GetSetting(hContact,module->name,setting->name,&dbv)) - { - switch (dbv.type) - { - case DBVT_UTF8: // no conversion atm - case DBVT_ASCIIZ: - if ((exactMatch && !(caseSensitive?strcmp(dbv.pszVal,text):strcmpi(dbv.pszVal,text))) || (!exactMatch && (caseSensitive?strstr(dbv.pszVal,text):StrStrI(dbv.pszVal,text)))) - { - if ((mode & RW_FOUND) || (mode & RW_SETVAL)) - replaceCount += replaceValue(hwnd, hContact, module->name, setting->name, &dbv, text, replace, mode); - else - ItemFound(hwnd,hContact,module->name,setting->name,dbv.pszVal,FW_SETTINGVALUE); - - foundCount++; - } - break; - - case DBVT_BYTE: - if (isNumber && settingValue == dbv.bVal) - { - if ((mode & RW_FOUND) || (mode & RW_SETVAL)) - replaceCount += replaceValue(hwnd, hContact, module->name, setting->name, &dbv, NULL, replace, mode); - else - ItemFound(hwnd,hContact,module->name,setting->name,text,FW_SETTINGVALUE); - foundCount++; - } - break; - - case DBVT_WORD: - if (isNumber && settingValue == dbv.wVal) - { - if ((mode & RW_FOUND) || (mode & RW_SETVAL)) - replaceCount += replaceValue(hwnd, hContact, module->name, setting->name, &dbv, NULL, replace, mode); - else - ItemFound(hwnd,hContact,module->name,setting->name,text,FW_SETTINGVALUE); - foundCount++; - } - break; - - case DBVT_DWORD: - if (isNumber && settingValue == (int)dbv.dVal) - { - if ((mode & RW_FOUND) || (mode & RW_SETVAL)) - replaceCount += replaceValue(hwnd, hContact, module->name, setting->name, &dbv, NULL, replace, mode); - else - ItemFound(hwnd,hContact,module->name,setting->name,text,FW_SETTINGVALUE); - foundCount++; - } - break; - - } - DBFreeVariant(&dbv); - } - } - - // check in setting name - if (inSettingName) - { - if ((exactMatch && !(caseSensitive?strcmp(setting->name,text):strcmpi(setting->name,text))) || (!exactMatch && (caseSensitive?StrStrI(setting->name,text):StrStrI(setting->name,text)))) - { - if ((mode & RW_FOUND) || (mode & RW_SETNAME)) - { - if (!GetSetting(hContact,module->name,setting->name,&dbv)) - { - replaceCount += replaceSetting(hwnd, hContact, module->name, setting->name, &dbv, text, replace, mode); - DBFreeVariant(&dbv); - } - } - else - ItemFound(hwnd,hContact,module->name,setting->name, NULL, FW_SETTINGNAME); - foundCount++; - } - } - - setting = (struct ModSetLinkLinkItem *)setting->next; - } - - // check in module name - if (inModuleName) - { - if ((exactMatch && !(caseSensitive?strcmp(module->name,text):strcmpi(module->name,text))) || (!exactMatch && (caseSensitive?strstr(module->name,text):StrStrI(module->name,text)))) - { - if ((mode & RW_FOUND) || (mode & RW_MODULE)) - replaceCount += replaceModule(hwnd, hContact, module->name, text, replace, mode); - else - ItemFound(hwnd,hContact,module->name,0, 0, FW_MODULE); - foundCount++; - } - } - - FreeModuleSettingLL(&SettingList); - module = (struct ModSetLinkLinkItem *)module->next; - } - } - - if (mode) - { - if (!replace[0]) - mir_snprintf(szTmp, SIZEOF(szTmp), Translate("Finished. %d items were found, %d items were deleted."), foundCount, replaceCount); - else - mir_snprintf(szTmp, SIZEOF(szTmp), Translate("Finished. %d items were found, %d items were replaced."), foundCount, replaceCount); - } - else - mir_snprintf(szTmp, SIZEOF(szTmp), Translate("Finished. %d items were found."), foundCount); - - SendMessage(GetDlgItem(prnthwnd,IDC_SBAR),SB_SETTEXT,0,(LPARAM)szTmp); - - SetWindowLongPtr(GetDlgItem(prnthwnd,IDC_SEARCH),GWLP_USERDATA,0); - - if (GetWindowLongPtr(GetDlgItem(prnthwnd,IDC_REPLACE),GWLP_USERDATA)) - { - SetWindowLongPtr(GetDlgItem(prnthwnd,IDC_REPLACE),GWLP_USERDATA, 0); - EnableWindow(GetDlgItem(prnthwnd,IDC_SEARCH),1); - SetWindowText(GetDlgItem(prnthwnd,IDOK),Translate("&Replace")); - } - else - { - SetWindowText(GetDlgItem(prnthwnd,IDC_SEARCH),Translate("&Search")); - EnableWindow(GetDlgItem(prnthwnd,IDOK),1); - } - - mir_free(replace); - mir_free(text); - mir_free(di); - FreeModuleSettingLL(&ModuleList); - - EnableWindow(GetDlgItem(prnthwnd,IDCANCEL),1); - -} diff --git a/plugins/Svc_dbepp/headers.h b/plugins/Svc_dbepp/headers.h deleted file mode 100644 index 0815c16c10..0000000000 --- a/plugins/Svc_dbepp/headers.h +++ /dev/null @@ -1,257 +0,0 @@ -#ifndef _COMMONHEADERS_H -#define _COMMONHEADERS_H -//===================================================== -// Includes -//===================================================== - -#define _WIN32_WINNT 0x0501 -#define MIRANDA_VER 0x0A00 - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "m_toptoolbar.h" - -#include "resource.h" -#include "Version.h" -#include "modsettingenum.h" - -#define DEF_ICON 7 -#define crlf_string "\r\n\0" - -/////// icons support - -void addIcons(TCHAR* szModuleFileName); -HICON LoadSkinnedDBEIcon(int icon); -int AddIconToList(HIMAGELIST hil, HICON hIcon); -void AddProtoIconsToList(HIMAGELIST hil, int newshift); -int GetProtoIcon(char *szProto); -extern HANDLE hRestore; -extern HANDLE hUserMenu; -///////////////////// - -#ifndef NDEBUG - #define new new(_NORMAL_BLOCK, __FILE__, __LINE__) -#endif - -//======================================================= -// Definitions -//======================================================= -#define modname "DBEditorpp" -#define modFullname "Database Editor++" -#define msg(a,b) MessageBoxA(0,a,b,MB_OK) -#define nick_unknown "(UNKNOWN)" -#define nick_unknownW L"(UNKNOWN)" - - -#define WM_FINDITEM (WM_USER+1) // onyl for the main window, wparam is ItemIfno* lparam is 0 - -#define mir_strlen(ptr) ((ptr==NULL)?0:(int)strlen(ptr)) -#define mir_strncpy(dst, src, len) strncpy(dst, src, len)[len-1]=0; -#define mir_strcmp(ptr1, ptr2) ((ptr1 && ptr2)?strcmp(ptr1, ptr2):1) // (ptr1||ptr2) - -#define ListView_SetItemTextW(hwndLV, i, iSubItem_, pszText_) \ -{ LV_ITEMW _ms_lvi;\ - _ms_lvi.iSubItem = iSubItem_;\ - _ms_lvi.pszText = pszText_;\ - SendMessageW((hwndLV), LVM_SETITEMTEXTW, (WPARAM)(i), (LPARAM)(LV_ITEMW *)&_ms_lvi);\ -} - -#define ListView_InsertItemW(hwnd, pitem) \ - SendMessageW((hwnd), LVM_INSERTITEMW, 0, (LPARAM)(const LV_ITEMW *)(pitem)) - - -#define TreeView_InsertItemW(hwnd, lpis) \ - (HTREEITEM)SendMessageW((hwnd), TVM_INSERTITEMW, 0, (LPARAM)(LPTV_INSERTSTRUCTW)(lpis)) - -/*********************** - ModuleTreeInfoStruct - this gets dumped as the lparam for each module tree item -************************/ -// types -#define CONTACT_ROOT_ITEM 0 -#define CONTACT 1 -#define MODULE 0x2 -#define KNOWN_MODULE 2 -#define UNKNOWN_MODULE 3 -#define STUB 4 -#define EMPTY 8 - -typedef struct { - int type; // from above types - HANDLE hContact; -} ModuleTreeInfoStruct; - -typedef struct { - HANDLE hContact; - char* module; - HWND hwnd2Edit; - int selectedItem; // item that is currently selected - int clicks; // set to 0 when selection changes, 1 after another click.. cant edit till this is 1 -} SettingListInfo; - -#define WATCH_MODULE 1 -#define WATCH_SETTING 0 - -struct DBsetting { - DBVARIANT dbv; - HANDLE hContact; - char *module; - char *setting; - int WatchModule; // above defines -}; - -typedef struct { - char module[256]; - HANDLE hContact; -} ModuleAndContact; - -// find window -#define FW_MODULE 0 -#define FW_SETTINGNAME 1 -#define FW_SETTINGVALUE 2 - -typedef struct { - int type; // above types - HANDLE hContact; - char module[256]; - char setting[256]; -} ItemInfo; - -// watchwindow -struct WatchListArrayStruct{ - struct DBsetting *item; // gotta malloc this - int count; - int size; -}; -extern WatchListArrayStruct WatchListArray; - -//======================================================= -// Variables -//======================================================= -extern HINSTANCE hInst; -extern HWND hwnd2mainWindow, hwnd2watchedVarsWindow, hwnd2importWindow; -extern HIMAGELIST himl; -extern HIMAGELIST himl2; -extern int Mode; -extern int Hex; -extern int Order; -extern BOOL UDB, UOS; - -extern BOOL usePopUps; - -#define NAMEORDERCOUNT 8 - -#define MODE_UNLOADED 1 -#define MODE_LOADED 2 -#define MODE_ALL 3 - -#define HEX_BYTE 1 -#define HEX_WORD 2 -#define HEX_DWORD 4 - -//main.c -int DBGetContactSettingStringStatic(HANDLE hContact, char* szModule, char* szSetting, char* value, int maxLength); -int WriteBlobFromString(HANDLE hContact,const char *szModule,const char *szSetting, const char *Value, int len); -int GetSetting(HANDLE hContact, const char *szModule, const char *szSetting, DBVARIANT *dbv); -int GetValue(HANDLE hContact, const char* szModule, const char* szSetting, char* Value, int length); -int GetValueW(HANDLE hContact, const char* szModule, const char* szSetting, WCHAR* Value, int length); -char* u2a( wchar_t* src ); -wchar_t *a2u( char* src , wchar_t *buffer, int len ); -int mir_snwprintf(WCHAR *buffer, size_t count, const WCHAR* fmt, ...); -WCHAR *GetContactName(HANDLE hContact, const char *szProto, int unicode); -BOOL IsProtocolLoaded(char* pszProtocolName); - -// main_window.c -INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); - -// modules.c -int deleteModule(char* module, HANDLE hContact, int fromMenu); -void deleteModuleGui(); -void renameModule(char* oldName, char* newName, HANDLE hContact); -INT_PTR CALLBACK AddModDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); -int CloneContact(HANDLE hContact); - -// moduletree.c -void replaceTreeItem(HWND hwnd, HANDLE hContact, const char *module, const char *newModule); -void refreshTree(BOOL restore); -void __cdecl PopulateModuleTreeThreadFunc(LPVOID di); -void freeTree(HWND hwnd2Tree, HANDLE hContact); -int findItemInTree(HWND hwnd2Tree, HANDLE hContact, char* module); - -// settinglist.c -void setupSettingsList(HWND hwnd2List); -void saveListSettings(HWND hwnd2List); -void ClearListview(HWND hwnd2Settings); -void DeleteSettingsFromList(HWND hSettings, HANDLE hContact, char *module, char *setting); -void PopulateSettings(HWND hwnd2Settings, HANDLE hContact, char* module); -void SelectSetting(char* setting); - -// addeditsettingsdlg.c -INT_PTR CALLBACK EditSettingDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); -void editSetting(HANDLE hContact, char* module, char* setting); -BOOL convertSetting(HANDLE hContact, char* module, char* setting, int toType); // 0 = byte, 1 = word, 2 = dword, 3 = string - -// exportimport.c -void exportDB(HANDLE hContact, char* module); // hContact == -1 export entire db. module == NULL export entire contact -void ImportSettingsMenuItem(HANDLE hContact); -void ImportSettingsFromFileMenuItem(HANDLE hContact, char* FilePath); - -// find window.c -INT_PTR CALLBACK FindWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); - -// knownmodules.c -extern BYTE UseKnownModList; -INT_PTR RegisterModule(WPARAM wParam, LPARAM lParam); -INT_PTR RegisterSingleModule(WPARAM wParam, LPARAM lParam); -void FreeKnownModuleList(); -int IsModuleKnown(char* moduleName); -void doOldKnownModulesList(); - -// copymodule.c -void copyModuleMenuItem(char* module, HANDLE hContact); -void copyModule(char* module, HANDLE hContactFrom, HANDLE hContactTo); - -// options.c -int OptInit(WPARAM wParam,LPARAM lParam); - -// watchlist -int addSettingToWatchList(HANDLE hContact, char* module, char* setting); -void freeWatchListItem(int item); -void PopulateWatchedWindow(HWND hwnd); -void freeAllWatches(); -INT_PTR CALLBACK WatchDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); -void popupWatchedVar(HANDLE hContact,const char* module,const char* setting); - -#endif //_COMMONHEADERS_H \ No newline at end of file diff --git a/plugins/Svc_dbepp/icons.cpp b/plugins/Svc_dbepp/icons.cpp deleted file mode 100644 index 6da3723bfe..0000000000 --- a/plugins/Svc_dbepp/icons.cpp +++ /dev/null @@ -1,143 +0,0 @@ -#include "headers.h" - -HIMAGELIST himl; - -void addIcons(TCHAR* szModuleFileName) -{ - SKINICONDESC sid={0}; - char name[32]; - sid.cbSize = sizeof(sid); - sid.ptszSection = _T(modFullname); - sid.ptszDefaultFile = szModuleFileName; - sid.flags = SIDF_ALL_TCHAR; - - // closed known module - sid.ptszDescription = LPGENT("Closed Known Module"); - mir_snprintf(name, SIZEOF(name), "DBE++_%d", ICO_KNOWN); - sid.pszName = name; - sid.iDefaultIndex = -ICO_KNOWN; - Skin_AddIcon(&sid); - - // open known module - sid.ptszDescription = LPGENT("Open Known Module"); - mir_snprintf(name, SIZEOF(name), "DBE++_%d", ICO_KNOWNOPEN); - sid.pszName = name; - sid.iDefaultIndex = -ICO_KNOWNOPEN; - Skin_AddIcon(&sid); - - // closed unknown module - sid.ptszDescription = LPGENT("Closed Unknown Module"); - mir_snprintf(name, SIZEOF(name), "DBE++_%d", ICO_UNKNOWN); - sid.pszName = name; - sid.iDefaultIndex = -ICO_UNKNOWN; - Skin_AddIcon(&sid); - - // open unknown module - sid.ptszDescription = LPGENT("Open Unknown Module"); - mir_snprintf(name, SIZEOF(name), "DBE++_%d", ICO_UNKNOWNOPEN); - sid.pszName = name; - sid.iDefaultIndex = -ICO_UNKNOWNOPEN; - Skin_AddIcon(&sid); - - // settings contact - sid.ptszDescription = LPGENT("Settings"); - mir_snprintf(name, SIZEOF(name), "DBE++_%d", ICO_SETTINGS); - sid.pszName = name; - sid.iDefaultIndex = -ICO_SETTINGS; - Skin_AddIcon(&sid); - - // contact group - sid.ptszDescription = LPGENT("Contacts Group"); - mir_snprintf(name, SIZEOF(name), "DBE++_%d", ICO_CONTACTS); - sid.pszName = name; - sid.iDefaultIndex = -ICO_CONTACTS; - Skin_AddIcon(&sid); - - // unknwon contact - sid.ptszDescription = LPGENT("Unknown Contact"); - mir_snprintf(name, SIZEOF(name), "DBE++_%d", ICO_OFFLINE); - sid.pszName = name; - sid.iDefaultIndex = -ICO_OFFLINE; - Skin_AddIcon(&sid); - - // known contact - sid.ptszDescription = LPGENT("Known Contact"); - mir_snprintf(name, SIZEOF(name), "DBE++_%d", ICO_ONLINE); - sid.pszName = name; - sid.iDefaultIndex = -ICO_ONLINE; - Skin_AddIcon(&sid); -} - -HICON LoadSkinnedDBEIcon(int icon) -{ - char name[32]; - mir_snprintf(name, SIZEOF(name), "DBE++_%d", icon); - HICON hIcon = (HICON)CallService(MS_SKIN2_GETICON,0,(LPARAM)name); - return (hIcon) ? hIcon : LoadIcon(hInst, MAKEINTRESOURCE(icon)); -} - - -int AddIconToList(HIMAGELIST hil, HICON hIcon) -{ - if (!hIcon || !hil) - return 0; - - ImageList_AddIcon(hil, hIcon); - return 1; -} - -static PROTOCOLDESCRIPTOR **protocols = NULL; -static int protoCount = 0; -static int shift = 0; - -void AddProtoIconsToList(HIMAGELIST hil, int newshift) -{ - shift = newshift; - - CallService(MS_PROTO_ENUMPROTOCOLS,(WPARAM)&protoCount,(LPARAM)&protocols); - - for (int i = 0; i < protoCount; i++) { - if (protocols[i]->type != PROTOTYPE_PROTOCOL) - continue; - - HICON hIcon; - if (hIcon=LoadSkinnedProtoIcon(protocols[i]->szName, ID_STATUS_ONLINE)) - AddIconToList(hil, hIcon); - else - AddIconToList(himl, LoadSkinnedDBEIcon(ICO_ONLINE)); - } -} - -int GetProtoIcon(char *szProto) -{ - if ( !protoCount || !protocols || !szProto) - return DEF_ICON; - - int n = 0; - - for (int i = 0; i < protoCount; i++) { - if (protocols[i]->type != PROTOTYPE_PROTOCOL) - continue; - - if (!mir_strcmp(protocols[i]->szName, szProto)) - return n + shift; - - n++; - } - - return DEF_ICON; -} - -BOOL IsProtocolLoaded(char* pszProtocolName) -{ - if (protoCount) - for(int i = 0; i < protoCount; i++) { - if (protocols[i]->type != PROTOTYPE_PROTOCOL) - continue; - - if (!mir_strcmp(protocols[i]->szName, pszProtocolName)) - return TRUE; - } - - return FALSE; -} diff --git a/plugins/Svc_dbepp/knownmodules.cpp b/plugins/Svc_dbepp/knownmodules.cpp deleted file mode 100644 index 13c4379f6b..0000000000 --- a/plugins/Svc_dbepp/knownmodules.cpp +++ /dev/null @@ -1,84 +0,0 @@ -#include "headers.h" - -BYTE UseKnownModList; - -#define MAXMODS 1024 -char *KnownModules[MAXMODS]; -int KnownModulesCount = 0; - -INT_PTR RegisterModule(WPARAM wParam, LPARAM lParam) -{ - char **mods = (char**)wParam; - int count = lParam; - int i; - for (i=0;iname,&dbv) && dbv.type == DBVT_ASCIIZ) - { - temp = (char*)mir_alloc((strlen(dbv.pszVal)+5)*sizeof(char)); - if (!temp) break; - strcpy(temp,dbv.pszVal); - strcat(temp,",\0"); - var = strtok(temp,", "); - while (var) - { - if (KnownModulesCountnext; - } - FreeModuleSettingLL(&msll); - - UseKnownModList = DBGetContactSettingByte(NULL,modname,"UseKnownModList",0); -} diff --git a/plugins/Svc_dbepp/main.cpp b/plugins/Svc_dbepp/main.cpp deleted file mode 100644 index 51c64d0ae7..0000000000 --- a/plugins/Svc_dbepp/main.cpp +++ /dev/null @@ -1,669 +0,0 @@ -#include "headers.h" - -// {A8A417EF-07AA-4f37-869F-7BFD74886534} -#define MIID_DBEDITOR {0xa8a417ef, 0x7aa, 0x4f37, { 0x86, 0x9f, 0x7b, 0xfd, 0x74, 0x88, 0x65, 0x34}} - - -HINSTANCE hInst = NULL; - -HANDLE hTTBButt = NULL; -BOOL bServiceMode = FALSE; -BOOL usePopUps; -HWND hwnd2watchedVarsWindow; -int UDB; -int hLangpack; -BYTE nameOrder[NAMEORDERCOUNT]; -HANDLE hUserMenu; -HANDLE hRestore; -WatchListArrayStruct WatchListArray; -HANDLE sMenuCommand, sRegisterModule, sRegisterSingleModule, sImport, sServicemodeLaunch; -HANDLE hModulesLoadedHook = NULL, hSettingsChangedHook=NULL, hOptInitHook=NULL, hPreShutdownHook=NULL, hTTBHook = NULL; - -//======================== -// MirandaPluginInfo -//======================== -PLUGININFOEX pluginInfoEx={ - sizeof(PLUGININFOEX), - __PLUGIN_NAME, - PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM), - __DESCRIPTION, - __AUTHOR, - __AUTHOREMAIL, - __COPYRIGHT, - __AUTHORWEB, - UNICODE_AWARE, - MIID_DBEDITOR -}; - -extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) -{ - return &pluginInfoEx; -} - -// we implement service mode interface -extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = {MIID_SERVICEMODE, MIID_LAST}; - -//======================== -// WINAPI DllMain -//======================== -BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved) -{ - hInst=hinstDLL; - return TRUE; -} - -void settingChanged(HWND hwnd2Settings, HANDLE hContact, char* module, char* setting); - -int DBSettingChanged(WPARAM wParam,LPARAM lParam) -{ - DBCONTACTWRITESETTING *cws=(DBCONTACTWRITESETTING*)lParam; - HANDLE hContact = (HANDLE)wParam; - char *setting; - int i; - SettingListInfo* info; - - if (hwnd2mainWindow) - { - HWND hwnd2Settings = GetDlgItem(hwnd2mainWindow, IDC_SETTINGS); - if (info = (SettingListInfo*)GetWindowLongPtr(hwnd2Settings,GWLP_USERDATA)) - { - if ((hContact == info->hContact) && !mir_strcmp(info->module, cws->szModule)) - { - setting = mir_strdup(cws->szSetting); - if (cws->value.type == DBVT_DELETED) - { - LVFINDINFO lvfi; - int index; - lvfi.flags = LVFI_STRING; - lvfi.psz = setting; - lvfi.vkDirection = VK_DOWN; - index = ListView_FindItem(hwnd2Settings,-1,&lvfi); - if (index > -1) - ListView_DeleteItem(hwnd2Settings, index); - mir_free(setting); - return 0; - } - settingChanged(hwnd2Settings, hContact, info->module, setting); - mir_free(setting); - } - } - } - // watch list - if (!hwnd2watchedVarsWindow && !usePopUps) return 0; - - for (i=0; iszModule, WatchListArray.item[i].module)) - { - if (!WatchListArray.item[i].setting || !mir_strcmp(cws->szSetting, WatchListArray.item[i].setting)) - { - if (usePopUps) - popupWatchedVar(hContact, cws->szModule, cws->szSetting); - if (hwnd2watchedVarsWindow) - PopulateWatchedWindow(GetDlgItem(hwnd2watchedVarsWindow, IDC_VARS)); - break; - } - } - } - } - return 0; -} - -INT_PTR DBEditorppMenuCommand(WPARAM wParam, LPARAM lParam) -{ - - if (!hwnd2mainWindow) // so only opens 1 at a time - { - hRestore = (HANDLE)wParam; - SetCursor(LoadCursor(NULL,IDC_WAIT)); - CreateDialog(hInst, MAKEINTRESOURCE(IDD_MAIN), 0, MainDlgProc); - } - else - { - ShowWindow(hwnd2mainWindow, SW_RESTORE); - SetForegroundWindow(hwnd2mainWindow); - if (!hRestore && wParam) { - hRestore = (HANDLE)wParam; - refreshTree(4); - } - } - - if (hTTBButt) - CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)hTTBButt, (LPARAM)(TTBST_RELEASED)); - - return 0; -} - -BOOL IsCP_UTF8(void) -{ - CPINFO CPInfo; - - return GetCPInfo(CP_UTF8, &CPInfo); -} - -static int OnTTBLoaded(WPARAM wParam,LPARAM lParam) -{ - TTBButton ttbb = {0}; - HICON ico = LoadIcon(hInst, MAKEINTRESOURCE(ICO_DBE_BUTT)); - UnhookEvent(hTTBHook); - - ttbb.cbSize = sizeof(ttbb); - ttbb.dwFlags = TTBBF_VISIBLE | TTBBF_SHOWTOOLTIP; - ttbb.pszService = "DBEditorpp/MenuCommand"; - ttbb.name = LPGEN("Database Editor++"); - ttbb.hIconUp = ico; - ttbb.pszTooltipUp = LPGEN("Show DataBase Editor"); - hTTBButt = TopToolbar_AddButton(&ttbb); - return 0; -} - -int ModulesLoaded(WPARAM wParam,LPARAM lParam) -{ - DBVARIANT dbv; - char *coreMods = ""; - char *mods; - char mod[64] = ""; - TCHAR szModuleFileName[MAX_PATH]; - int i=0, len; - if (!DBGetContactSetting(NULL,modname,"CoreModules",&dbv) && dbv.type == DBVT_ASCIIZ) - mods = dbv.pszVal; - else - { - DBWriteContactSettingString(NULL,modname,"CoreModules",coreMods); - mods = coreMods; - } - - len = (int)strlen(mods); - while (i < len) - { - if (mods[i] == '\\' && mods[i+1] == ' ') - { - strcat(mod," "); - i++; - } - else if (mods[i] == ' ' || mods[i] == ',' || mods[i] == '\r' || mods[i] == '\n'|| mods[i] == '\0') - { - if (mod[0]) - CallService("DBEditorpp/RegisterSingleModule",(WPARAM)mod,0); - mod[0] = '\0'; - } - else strncat(mod,&mods[i],1); - i++; - } - if (mod[0]) CallService("DBEditorpp/RegisterSingleModule",(WPARAM)mod,0); - - doOldKnownModulesList(); // add the old plugins which havnt been changed over yet.. - - // icons - if (GetModuleFileName(hInst, szModuleFileName, MAX_PATH)) - addIcons(szModuleFileName); - - DBFreeVariant(&dbv); - UnhookEvent(hModulesLoadedHook); - - usePopUps = DBGetContactSettingByte(NULL,modname,"UsePopUps",0); - - // Load the name order - for(i=0;i='0' && b<='9') || - (b>='A' && b<='F') || - (b>='a' && b<='f')) - { - if (sscanf(&szValue[j], "%02X", &tmp) == 1) - { - data[i++] = (BYTE)tmp; - j++; - } - } - j++; - } - - if (i) - return DBWriteContactSettingBlob(hContact,szModule,szSetting, data, (WORD)i); - - return 0; -} - - -int GetSetting(HANDLE hContact, const char *szModule, const char *szSetting, DBVARIANT *dbv) -{ - DBCONTACTGETSETTING cgs; - - cgs.szModule=szModule; - cgs.szSetting=szSetting; - cgs.pValue=dbv; - dbv->type = 0; - - if (UDB) - return CallService(MS_DB_CONTACT_GETSETTING_STR,(WPARAM)hContact,(LPARAM)&cgs); - else - { - int rr = CallService(MS_DB_CONTACT_GETSETTING,(WPARAM)hContact,(LPARAM)&cgs); - - if (dbv->type != DBVT_UTF8) - return rr; - else - return 1; - } -} - - -int GetValue(HANDLE hContact, const char* szModule, const char* szSetting, char* Value, int length) -{ - DBVARIANT dbv = {0}; - - if (Value && length >= 10 && !GetSetting(hContact, szModule, szSetting, &dbv)) - { - switch(dbv.type) { - case DBVT_UTF8: - if (UOS) - { - int len = (int)strlen(dbv.pszVal)+1; - char *sz = (char*)_alloca(len*3); - WCHAR *wc = (WCHAR*)_alloca(len*sizeof(WCHAR)); - MultiByteToWideChar(CP_UTF8, 0, dbv.pszVal, -1, wc, len); - WideCharToMultiByte(CP_ACP, 0, wc, -1, sz, len, NULL, NULL); - strncpy(Value, sz, length); - break; - }// else fall through - case DBVT_ASCIIZ: - strncpy(Value, dbv.pszVal, length); - break; - case DBVT_DWORD: - _itoa(dbv.dVal,Value,10); - break; - case DBVT_BYTE: - _itoa(dbv.bVal,Value,10); - break; - case DBVT_WORD: - _itoa(dbv.wVal,Value,10); - break; - } - - DBFreeVariant(&dbv); - - Value[length-1] = 0; - return 1; - } - - if (Value) - Value[0] = 0; - - return 0; -} - - -int GetValueW(HANDLE hContact, const char* szModule, const char* szSetting, WCHAR* Value, int length) -{ - DBVARIANT dbv ={0}; - - if (Value && length >= 10 && !GetSetting(hContact, szModule, szSetting, &dbv)) - { - switch(dbv.type) { - case DBVT_UTF8: - { - int len = (int)strlen(dbv.pszVal) + 1; - WCHAR *wc = (WCHAR*)_alloca(length*sizeof(WCHAR)); - MultiByteToWideChar(CP_UTF8, 0, dbv.pszVal, -1, wc, len); - wcsncpy((WCHAR*)Value, wc, length); - } - break; - case DBVT_ASCIIZ: - { - int len = (int)strlen(dbv.pszVal) + 1; - WCHAR *wc = (WCHAR*)_alloca(len*sizeof(WCHAR)); - MultiByteToWideChar(CP_ACP, 0, dbv.pszVal, -1, wc, len); - wcsncpy((WCHAR*)Value, wc, length); - } - break; - case DBVT_DWORD: - _itow(dbv.dVal,Value,10); - break; - case DBVT_BYTE: - _itow(dbv.bVal,Value,10); - break; - case DBVT_WORD: - _itow(dbv.wVal,Value,10); - break; - } - - DBFreeVariant(&dbv); - - Value[length-1] = 0; - return 1; - } - - if (Value) - Value[0] = 0; - - return 0; -} - - -char *u2a( wchar_t* src ) -{ - if (src) - { - int cbLen = WideCharToMultiByte( CP_ACP, 0, src, -1, NULL, 0, NULL, NULL ); - char* result = (char*)mir_calloc((cbLen+1)*sizeof(char)); - if ( result == NULL ) - return NULL; - - WideCharToMultiByte( CP_ACP, 0, src, -1, result, cbLen, NULL, NULL ); - result[ cbLen ] = 0; - return result; - } - else - return NULL; -} - - -wchar_t *a2u( char* src , wchar_t *buffer, int len ) -{ - wchar_t *result = buffer; - if ( result == NULL || len < 3) - return NULL; - - MultiByteToWideChar( CP_ACP, 0, src, -1, result, len - 1 ); - result[ len - 1 ] = 0; - - return result; -} - -int mir_snwprintf(WCHAR *buffer, size_t count, const WCHAR* fmt, ...) -{ - va_list va; - int len; - - va_start(va, fmt); - len = _vsnwprintf(buffer, count-1, fmt, va); - va_end(va); - - buffer[count-1] = 0; - - return len; -} - - -int GetDatabaseString(HANDLE hContact, const char *szModule, const char* szSetting, WCHAR *Value, int length, BOOL unicode) -{ - if (unicode) - return GetValueW(hContact, szModule, szSetting, Value, length); - else - return GetValue(hContact, szModule, szSetting, (char*)Value, length); -} - - -WCHAR *GetContactName(HANDLE hContact, const char *szProto, int unicode) -{ - - int i, r = 0; - static WCHAR res[512]; - char *proto = (char*)szProto; - char name[256]; - - if (hContact && !proto) - { - if (GetValue(hContact,"Protocol","p",name,SIZEOF(name))) - proto = name; - } - - if (proto) - { - - for(i=0;i 1) - r |= GetDatabaseString(hContact,proto,"LastName",&res[len],SIZEOF(res)-len,unicode); - - break; - } - } - - if (r) return res; - } - } - - if (unicode) - return nick_unknownW; - else - return (WCHAR*)nick_unknown; -} diff --git a/plugins/Svc_dbepp/main_window.cpp b/plugins/Svc_dbepp/main_window.cpp deleted file mode 100644 index d7fdb75256..0000000000 --- a/plugins/Svc_dbepp/main_window.cpp +++ /dev/null @@ -1,673 +0,0 @@ -#include "headers.h" - -HWND hwnd2mainWindow; -int Order; -HIMAGELIST himl2; -int Hex; - -#define GC_SPLITTERMOVED (WM_USER+101) - -extern BOOL bServiceMode; - -static WNDPROC SettingListSubClass, ModuleTreeSubClass, SplitterSubClass; - -void moduleListWM_NOTIFY(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam); -void SettingsListWM_NOTIFY(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam); - -int DialogResize(HWND hwnd,LPARAM lParam,UTILRESIZECONTROL *urc) -{ - switch(urc->wId) - { - case IDC_MODULES: - urc->rcItem.right = lParam-3; - urc->rcItem.top = 0; - urc->rcItem.left = 0; - urc->rcItem.bottom = urc->dlgNewSize.cy; - return RD_ANCHORX_CUSTOM|RD_ANCHORY_CUSTOM; - case IDC_SPLITTER: - urc->rcItem.top = 0; - urc->rcItem.bottom = urc->dlgNewSize.cy; - urc->rcItem.right = lParam; - urc->rcItem.left = lParam-3; - return RD_ANCHORX_CUSTOM|RD_ANCHORY_CUSTOM; - case IDC_SETTINGS: - urc->rcItem.top = 0; - urc->rcItem.bottom = urc->dlgNewSize.cy; - urc->rcItem.left = lParam; - urc->rcItem.right = urc->dlgNewSize.cx; - return RD_ANCHORX_CUSTOM|RD_ANCHORY_CUSTOM; - case IDC_VARS: - urc->rcItem.top = 0; - urc->rcItem.bottom = urc->dlgNewSize.cy; - urc->rcItem.left = 0; - urc->rcItem.right = urc->dlgNewSize.cx; - return RD_ANCHORY_CUSTOM|RD_ANCHORX_CUSTOM; - } - return RD_ANCHORX_LEFT|RD_ANCHORY_TOP; - -} - -static LRESULT CALLBACK SplitterSubclassProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam) -{ - switch(msg) { - case WM_NCHITTEST: - return HTCLIENT; - case WM_SETCURSOR: - { RECT rc; - GetClientRect(hwnd,&rc); - SetCursor(rc.right>rc.bottom?LoadCursor(NULL, IDC_SIZENS):LoadCursor(NULL, IDC_SIZEWE)); - return TRUE; - } - case WM_LBUTTONDOWN: - SetCapture(hwnd); - return 0; - case WM_MOUSEMOVE: - if(GetCapture()==hwnd) { - RECT rc; - GetClientRect(hwnd,&rc); - SendMessage(GetParent(hwnd),GC_SPLITTERMOVED,rc.right>rc.bottom?(short)HIWORD(GetMessagePos())+rc.bottom/2:(short)LOWORD(GetMessagePos())+rc.right/2,(LPARAM)hwnd); - } - return 0; - case WM_LBUTTONUP: - ReleaseCapture(); - return 0; - } - return CallWindowProc(SplitterSubClass,hwnd,msg,wParam,lParam); -} -LRESULT CALLBACK ModuleTreeSubclassProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam) -{ - switch(msg) { - case WM_RBUTTONDOWN: - { - TVHITTESTINFO hti; - hti.pt.x=(short)LOWORD(GetMessagePos()); - hti.pt.y=(short)HIWORD(GetMessagePos()); - ScreenToClient(hwnd,&hti.pt); - - if(TreeView_HitTest(hwnd,&hti)) - { - if(hti.flags&TVHT_ONITEM) - TreeView_SelectItem(hwnd, hti.hItem); - } - } - break; - case WM_CHAR: - if (GetKeyState(VK_CONTROL)&0x8000 && wParam == 6) - CreateDialog(hInst, MAKEINTRESOURCE(IDD_FIND), hwnd, FindWindowDlgProc); - break; - case WM_KEYUP: - { - if (wParam == VK_DELETE || - wParam == VK_F2 || - //wParam == VK_UP || - //wParam == VK_DOWN || - wParam == VK_F5 || - wParam == VK_F3) - - { - TVITEM tvi; - char module[256]; - tvi.mask=TVIF_HANDLE|TVIF_PARAM|TVIF_TEXT; - tvi.hItem=TreeView_GetSelection(hwnd); - tvi.pszText = module; - tvi.cchTextMax = 255; - if (TreeView_GetItem(hwnd,&tvi) && tvi.lParam) - { - ModuleTreeInfoStruct *mtis = (ModuleTreeInfoStruct*)tvi.lParam; - HANDLE hContact = mtis->hContact; - if (wParam == VK_DELETE) - { - if ((mtis->type) & MODULE) - { - if (deleteModule(module, hContact,0)) - { - mir_free(mtis); - TreeView_DeleteItem(hwnd,tvi.hItem); - } - } - else if ((mtis->type == CONTACT) && hContact) - { - if (DBGetContactSettingByte(NULL,"CList", "ConfirmDelete",1)) - { - char msg[1024]; - mir_snprintf(msg, SIZEOF(msg), Translate("Are you sure you want to delete contact \"%s\"?"), module); - if (MessageBox(0,msg, Translate("Confirm Contact Delete"), MB_YESNO|MB_ICONEXCLAMATION) == IDNO) - break; - } - CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact,0); - freeTree(hwnd,mtis->hContact); - TreeView_DeleteItem(hwnd,tvi.hItem); - } - } - else if (wParam == VK_F2 && (mtis->type == MODULE || mtis->type == UNKNOWN_MODULE)) - TreeView_EditLabel(hwnd,tvi.hItem); - else if (wParam == VK_F5) - { - refreshTree(1); - break; - } - - else if (wParam == VK_F3) - { - CreateDialog(hInst, MAKEINTRESOURCE(IDD_FIND), hwnd, FindWindowDlgProc); - break; - } - } - } - } - break; - default:break; - } - return CallWindowProc(ModuleTreeSubClass,hwnd,msg,wParam,lParam); -} -static LRESULT CALLBACK SettingListSubclassProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam) -{ - switch(msg) { - case WM_CHAR: - if (GetKeyState(VK_CONTROL)&0x8000 && wParam == 6) - CreateDialog(hInst, MAKEINTRESOURCE(IDD_FIND), hwnd, FindWindowDlgProc); - break; - case WM_KEYDOWN: - if (wParam == VK_DELETE || wParam == VK_F5 || (wParam == VK_F2 && ListView_GetSelectedCount(hwnd) == 1)) - { - char *module, setting[256]; - HANDLE hContact; - SettingListInfo* sli = (SettingListInfo*)GetWindowLongPtr(hwnd,GWLP_USERDATA); - if (!sli) break; - hContact = sli->hContact; - module = sli->module; - ListView_GetItemText(hwnd, ListView_GetSelectionMark(hwnd), 0, setting, 256); - - if (wParam == VK_F2) - editSetting(hContact,module, setting); - else if (wParam == VK_F5) - { - char *szModule = mir_tstrdup(module); // need to do this, otheriwse the setlist stays empty - PopulateSettings(hwnd,hContact,szModule); - mir_free(szModule); - } - else if (wParam == VK_DELETE) - DeleteSettingsFromList(hwnd, hContact, module, setting); - - return 0; - } - else if (wParam == VK_F3) - CreateDialog(hInst, MAKEINTRESOURCE(IDD_FIND), hwnd, FindWindowDlgProc); - break; - - default: break; - } - return CallWindowProc(SettingListSubClass,hwnd,msg,wParam,lParam); -} - -INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - switch(msg) - { - case WM_INITDIALOG: - { - int i; - HMENU hMenu = GetMenu(hwnd); - - hwnd2mainWindow = hwnd; - // do the icon - SendMessage(hwnd,WM_SETICON,ICON_BIG,(LPARAM)LoadIcon(hInst,MAKEINTRESOURCE(ICO_REGEDIT))); - if (UOS) - SetWindowText(hwnd, Translate("Database Editor++ (unicode mode)")); - else - SetWindowText(hwnd, Translate("Database Editor++ (ansi mode)")); - // setup the splitter - SetWindowLongPtr(GetDlgItem(hwnd,IDC_SPLITTER),GWLP_USERDATA,(LPARAM)DBGetContactSettingWord(NULL, modname, "Splitter", 300)); - SendMessage(hwnd, GC_SPLITTERMOVED, 0,0); - SplitterSubClass=(WNDPROC)SetWindowLongPtr(GetDlgItem(hwnd,IDC_SPLITTER),GWLP_WNDPROC,(LONG)SplitterSubclassProc); - // module tree - TreeView_SetUnicodeFormat(GetDlgItem(hwnd,IDC_MODULES), UOS); - ModuleTreeSubClass=(WNDPROC)SetWindowLongPtr(GetDlgItem(hwnd,IDC_MODULES),GWLP_WNDPROC,(LONG)ModuleTreeSubclassProc); - //setting list - setupSettingsList(GetDlgItem(hwnd,IDC_SETTINGS)); - SettingListSubClass=(WNDPROC)SetWindowLongPtr(GetDlgItem(hwnd,IDC_SETTINGS),GWLP_WNDPROC,(LONG)SettingListSubclassProc); - // traslation stuff - TranslateDialogDefault(hwnd); - TranslateMenu(hMenu); - - for (i=0;i<6;i++) - { - TranslateMenu(GetSubMenu(hMenu,i)); - } - - // move the dialog to the users position - MoveWindow(hwnd,DBGetContactSettingDword(NULL,modname,"x",0),DBGetContactSettingDword(NULL,modname,"y",0),DBGetContactSettingDword(NULL,modname,"width",500),DBGetContactSettingDword(NULL,modname,"height",250),0); - if (DBGetContactSettingByte(NULL,modname,"Maximised",0)) - { - WINDOWPLACEMENT wp; - wp.length = sizeof(WINDOWPLACEMENT); - wp.flags = WPF_RESTORETOMAXIMIZED; - wp.showCmd = SW_SHOWMAXIMIZED; - - SetWindowPlacement(hwnd,&wp); - } - SetCursor(LoadCursor(NULL,IDC_ARROW)); - - Mode = MODE_ALL; - CheckMenuItem(GetSubMenu(hMenu,5),MENU_FILTER_ALL,MF_BYCOMMAND|MF_CHECKED); - - Hex = DBGetContactSettingByte(NULL,modname,"HexMode",0); - CheckMenuItem(GetSubMenu(hMenu,5),MENU_BYTE_HEX,MF_BYCOMMAND|((Hex & HEX_BYTE)?MF_CHECKED:MF_UNCHECKED)); - CheckMenuItem(GetSubMenu(hMenu,5),MENU_WORD_HEX,MF_BYCOMMAND|((Hex & HEX_WORD)?MF_CHECKED:MF_UNCHECKED)); - CheckMenuItem(GetSubMenu(hMenu,5),MENU_DWORD_HEX,MF_BYCOMMAND|((Hex & HEX_DWORD)?MF_CHECKED:MF_UNCHECKED)); - - CheckMenuItem(GetSubMenu(GetMenu(hwnd),5),MENU_SAVE_POSITION,MF_BYCOMMAND|(DBGetContactSettingByte(NULL,modname,"RestoreOnOpen",1)?MF_CHECKED:MF_UNCHECKED)); - - Order = DBGetContactSettingByte(NULL,modname,"SortMode",1); - CheckMenuItem(GetSubMenu(GetMenu(hwnd),5),MENU_SORT_ORDER,MF_BYCOMMAND|(Order?MF_CHECKED:MF_UNCHECKED)); - - - - // image list - { - int numberOfIcons = 0; - himl = NULL; - - if (himl = ImageList_Create(16, 16, IsWinVerXPPlus() ? ILC_COLOR32 | ILC_MASK : ILC_COLOR8 | ILC_MASK, 10, 0)) - { - if (AddIconToList(himl, LoadSkinnedDBEIcon(ICO_SETTINGS))) - numberOfIcons++; - if (AddIconToList(himl, LoadSkinnedDBEIcon(ICO_KNOWN))) - numberOfIcons++; - if (AddIconToList(himl, LoadSkinnedDBEIcon(ICO_KNOWNOPEN))) - numberOfIcons++; - if (AddIconToList(himl, LoadSkinnedDBEIcon(ICO_CONTACTS))) - numberOfIcons++; - if (AddIconToList(himl, LoadSkinnedDBEIcon(ICO_OFFLINE))) - numberOfIcons++; - if (AddIconToList(himl, LoadSkinnedDBEIcon(ICO_UNKNOWN))) - numberOfIcons++; - if (AddIconToList(himl, LoadSkinnedDBEIcon(ICO_UNKNOWNOPEN))) - numberOfIcons++; - if (AddIconToList(himl, LoadSkinnedDBEIcon(ICO_ONLINE))) - numberOfIcons++; - - if (numberOfIcons < DEF_ICON + 1) - { - if (numberOfIcons) - ImageList_Destroy(himl); - himl = NULL; - } - - AddProtoIconsToList(himl, numberOfIcons); - - } - - himl2 = NULL; - numberOfIcons = 0; - - if (himl2 = ImageList_Create(16, 16, IsWinVerXPPlus() ? ILC_COLOR32 | ILC_MASK : ILC_COLOR8 | ILC_MASK, 5, 0)) - { - - if (AddIconToList(himl2, LoadIcon(hInst, MAKEINTRESOURCE(ICO_BINARY)))) - numberOfIcons++; - if (AddIconToList(himl2, LoadIcon(hInst, MAKEINTRESOURCE(ICO_BYTE)))) - numberOfIcons++; - if (AddIconToList(himl2, LoadIcon(hInst, MAKEINTRESOURCE(ICO_WORD)))) - numberOfIcons++; - if (AddIconToList(himl2, LoadIcon(hInst, MAKEINTRESOURCE(ICO_DWORD)))) - numberOfIcons++; - if (AddIconToList(himl2, LoadIcon(hInst, MAKEINTRESOURCE(ICO_STRING)))) - numberOfIcons++; - if (AddIconToList(himl2, LoadIcon(hInst, MAKEINTRESOURCE(ICO_UNICODE)))) - numberOfIcons++; - if (AddIconToList(himl2, LoadIcon(hInst, MAKEINTRESOURCE(ICO_HANDLE)))) - numberOfIcons++; - - if (numberOfIcons < 7) - { - if (numberOfIcons) - ImageList_Destroy(himl2); - himl2 = NULL; - } - } - } - - { - int restore; - - if (hRestore) - restore = 3; - else - if (DBGetContactSettingByte(NULL,modname,"RestoreOnOpen",1)) - restore = 2; - else - restore = 0; - - refreshTree(restore); - } - - } - return TRUE; - case GC_SPLITTERMOVED: - { - POINT pt; - RECT rc; - RECT rc2; - - int splitterPos = GetWindowLongPtr(GetDlgItem(hwnd,IDC_SPLITTER),GWLP_USERDATA); - - GetWindowRect(hwnd,&rc2); - - if ((HWND)lParam==GetDlgItem(hwnd,IDC_SPLITTER)) - { - GetClientRect(hwnd,&rc); - pt.x=wParam; pt.y=0; - ScreenToClient(hwnd,&pt); - - splitterPos=rc.left+pt.x+1; - if (splitterPos<65) splitterPos=65; - if (splitterPos > rc2.right-rc2.left-65) splitterPos=rc2.right-rc2.left-65; - SetWindowLongPtr(GetDlgItem(hwnd,IDC_SPLITTER),GWLP_USERDATA, splitterPos); - DBWriteContactSettingWord(NULL, modname, "Splitter",(WORD)splitterPos); - } - PostMessage(hwnd,WM_SIZE,0,0); - } - break; - case WM_GETMINMAXINFO: - { - MINMAXINFO *mmi=(MINMAXINFO*)lParam; - int splitterPos = GetWindowLongPtr(GetDlgItem(hwnd,IDC_SPLITTER),GWLP_USERDATA); - - if(splitterPos+40 > 200) - mmi->ptMinTrackSize.x=splitterPos+65; - else - mmi->ptMinTrackSize.x=200; - mmi->ptMinTrackSize.y=150; - return 0; - } - case WM_MOVE: - case WM_SIZE: - { - UTILRESIZEDIALOG urd; - - ZeroMemory(&urd,sizeof(urd)); - urd.cbSize=sizeof(urd); - urd.hInstance=hInst; - urd.hwndDlg=hwnd; - urd.lParam=(LPARAM)GetWindowLongPtr(GetDlgItem(hwnd,IDC_SPLITTER),GWLP_USERDATA); - urd.lpTemplate=MAKEINTRESOURCE(IDD_MAIN); - urd.pfnResizer=DialogResize; - CallService(MS_UTILS_RESIZEDIALOG,0,(LPARAM)&urd); - - if (msg == WM_SIZE && wParam == SIZE_MAXIMIZED || wParam == SIZE_MINIMIZED) - { - DBWriteContactSettingByte(NULL,modname,"Maximised",1); - } - else if (msg == WM_SIZE && wParam == SIZE_RESTORED) - { - DBWriteContactSettingByte(NULL,modname,"Maximised",0); - } - - } - break; - case WM_DESTROY: // free our shit! - - if (DBGetContactSettingByte(NULL,modname,"RestoreOnOpen",1)) - { - HTREEITEM item; - HWND hwnd2Tree = GetDlgItem(hwnd,IDC_MODULES); - char module[256] = {0}; - if (item = TreeView_GetSelection(hwnd2Tree)) - { - int type = MODULE; - TVITEM tvi = {0}; - HANDLE hContact = NULL; - tvi.mask=TVIF_HANDLE|TVIF_PARAM|TVIF_TEXT; - tvi.pszText = module; - tvi.cchTextMax = 255; - tvi.hItem=item; - - if (TreeView_GetItem(hwnd2Tree, &tvi)) - { - if (tvi.lParam) - { - ModuleTreeInfoStruct *mtis = (ModuleTreeInfoStruct *)tvi.lParam; - hContact = mtis->hContact; - type = mtis->type; - } - - DBWriteContactSettingDword(NULL,modname,"LastContact",(DWORD)hContact); - - if (type == CONTACT) - DBWriteContactSettingString(NULL,modname,"LastModule",""); - else - DBWriteContactSettingString(NULL,modname,"LastModule",module); - } - else - { - DBDeleteContactSetting(NULL,modname,"LastContact"); - DBDeleteContactSetting(NULL,modname,"LastModule"); - } - - // setting list - { - HWND hwnd2Settings = GetDlgItem(hwnd, IDC_SETTINGS); - int pos = ListView_GetSelectionMark(hwnd2Settings); - - if (pos != -1) - { - char text[256]; - - ListView_GetItemText(hwnd2Settings, pos, 0, text, SIZEOF(text)); - - DBWriteContactSettingString(NULL,modname,"LastSetting",text); - } - else - DBDeleteContactSetting(NULL,modname,"LastSetting"); - } - } - } - DBWriteContactSettingByte(NULL,modname,"HexMode",(byte)Hex); - DBWriteContactSettingByte(NULL,modname,"SortMode",(byte)Order); - saveListSettings(GetDlgItem(hwnd,IDC_SETTINGS)); - hwnd2mainWindow = 0; - ClearListview(GetDlgItem(hwnd,IDC_SETTINGS)); - freeTree(GetDlgItem(hwnd,IDC_MODULES),0); - if (himl) - ImageList_Destroy(himl); - if (himl2) - ImageList_Destroy(himl2); - SetWindowLongPtr(GetDlgItem(hwnd,IDC_SETTINGS),GWLP_WNDPROC,(LONG)SettingListSubClass); - SetWindowLongPtr(GetDlgItem(hwnd,IDC_MODULES),GWLP_WNDPROC,(LONG)ModuleTreeSubClass); - SetWindowLongPtr(GetDlgItem(hwnd,IDC_SPLITTER),GWLP_WNDPROC,(LONG)SplitterSubClass); - if (!DBGetContactSettingByte(NULL,modname,"Maximised",0)) - { - RECT rc; - GetWindowRect(hwnd,&rc); - DBWriteContactSettingDword(NULL,modname,"x",rc.left); - DBWriteContactSettingDword(NULL,modname,"y",rc.top); - DBWriteContactSettingDword(NULL,modname,"width",rc.right-rc.left); - DBWriteContactSettingDword(NULL,modname,"height",rc.bottom-rc.top); - } - if (hwnd2importWindow) { - DestroyWindow(hwnd2importWindow); - hwnd2importWindow = 0; - } - if ( bServiceMode ) { - PostQuitMessage(0); - } - - return 0; - case WM_COMMAND: - if (GetKeyState(VK_ESCAPE) & 0x8000) return TRUE; // this needs to be changed to c if htere is a label edit happening.. - switch(LOWORD(wParam)) - { - case MENU_REFRESH_MODS: - refreshTree(1); - break; - case MENU_REFRESH_SETS: - { - TVITEM tvi; - ModuleTreeInfoStruct *mtis; - char module[256]; - tvi.mask=TVIF_HANDLE|TVIF_PARAM|TVIF_TEXT; - tvi.hItem=TreeView_GetSelection(GetDlgItem(hwnd, IDC_MODULES)); - tvi.pszText = module; - tvi.cchTextMax = 255; - if (!TreeView_GetItem(GetDlgItem(hwnd, IDC_MODULES),&tvi)) break; - if (tvi.lParam) - { - mtis = (ModuleTreeInfoStruct *)tvi.lParam; - if (mtis->type == MODULE || mtis->type == UNKNOWN_MODULE) - PopulateSettings(GetDlgItem(hwnd, IDC_SETTINGS), mtis->hContact, module); - else ClearListview(GetDlgItem(hwnd, IDC_SETTINGS)); - } - else ClearListview(GetDlgItem(hwnd, IDC_SETTINGS)); - } - break; - ///////////////////////// // watches - case MENU_VIEW_WATCHES: - { - if (!hwnd2watchedVarsWindow) // so only opens 1 at a time - hwnd2watchedVarsWindow = CreateDialog(hInst, MAKEINTRESOURCE(IDD_WATCH_DIAG), 0, WatchDlgProc); - else SetForegroundWindow(hwnd2watchedVarsWindow); - } - break; - case MENU_REMALL_WATCHES: - freeAllWatches(); - break; - case MENU_EXPORTDB: // all db - exportDB(INVALID_HANDLE_VALUE,0); - break; - case MENU_EXPORTCONTACT: // all contacts - exportDB(INVALID_HANDLE_VALUE, ""); - break; - case MENU_EXPORTMODULE: // all settings - exportDB(NULL, 0); - break; - case MENU_IMPORTFROMFILE: - ImportSettingsFromFileMenuItem(NULL, ""); - break; - case MENU_IMPORTFROMTEXT: - ImportSettingsMenuItem(NULL); - break; - case MENU_EXIT: - case IDCANCEL: - DestroyWindow(hwnd); - break; - case MENU_DELETE: - deleteModuleGui(); - break; - case MENU_FINDANDREPLACE: - CreateDialog(hInst, MAKEINTRESOURCE(IDD_FIND), hwnd, FindWindowDlgProc); - break; - case MENU_FILTER_ALL: - if (Mode != MODE_ALL) - { - HMENU hMenu = GetMenu(hwnd); - CheckMenuItem(GetSubMenu(hMenu,5),MENU_FILTER_ALL,MF_BYCOMMAND|MF_CHECKED); - CheckMenuItem(GetSubMenu(hMenu,5),MENU_FILTER_LOADED,MF_BYCOMMAND|MF_UNCHECKED); - CheckMenuItem(GetSubMenu(hMenu,5),MENU_FILTER_UNLOADED,MF_BYCOMMAND|MF_UNCHECKED); - Mode = MODE_ALL; - refreshTree(1); - } - break; - case MENU_FILTER_LOADED: - if (Mode != MODE_LOADED) - { - HMENU hMenu = GetMenu(hwnd); - CheckMenuItem(GetSubMenu(hMenu,5),MENU_FILTER_ALL,MF_BYCOMMAND|MF_UNCHECKED); - CheckMenuItem(GetSubMenu(hMenu,5),MENU_FILTER_LOADED,MF_BYCOMMAND|MF_CHECKED); - CheckMenuItem(GetSubMenu(hMenu,5),MENU_FILTER_UNLOADED,MF_BYCOMMAND|MF_UNCHECKED); - Mode = MODE_LOADED; - refreshTree(1); - } - break; - case MENU_FILTER_UNLOADED: - if (Mode != MODE_UNLOADED) - { - HMENU hMenu = GetMenu(hwnd); - CheckMenuItem(GetSubMenu(hMenu,5),MENU_FILTER_ALL,MF_BYCOMMAND|MF_UNCHECKED); - CheckMenuItem(GetSubMenu(hMenu,5),MENU_FILTER_LOADED,MF_BYCOMMAND|MF_UNCHECKED); - CheckMenuItem(GetSubMenu(hMenu,5),MENU_FILTER_UNLOADED,MF_BYCOMMAND|MF_CHECKED); - Mode = MODE_UNLOADED; - refreshTree(1); - } - break; - case MENU_BYTE_HEX: - { - Hex ^= HEX_BYTE; - CheckMenuItem(GetSubMenu(GetMenu(hwnd),5),MENU_BYTE_HEX,MF_BYCOMMAND|((Hex & HEX_BYTE)?MF_CHECKED:MF_UNCHECKED)); - } - break; - case MENU_WORD_HEX: - { - Hex ^= HEX_WORD; - CheckMenuItem(GetSubMenu(GetMenu(hwnd),5),MENU_WORD_HEX,MF_BYCOMMAND|((Hex & HEX_WORD)?MF_CHECKED:MF_UNCHECKED)); - } - break; - case MENU_DWORD_HEX: - { - Hex ^= HEX_DWORD; - CheckMenuItem(GetSubMenu(GetMenu(hwnd),5),MENU_DWORD_HEX,MF_BYCOMMAND|((Hex & HEX_DWORD)?MF_CHECKED:MF_UNCHECKED)); - } - break; - case MENU_SAVE_POSITION: - { - BOOL save = !DBGetContactSettingByte(NULL,modname,"RestoreOnOpen",1); - CheckMenuItem(GetSubMenu(GetMenu(hwnd),5),MENU_SAVE_POSITION,MF_BYCOMMAND|(save?MF_CHECKED:MF_UNCHECKED)); - DBWriteContactSettingByte(NULL,modname,"RestoreOnOpen", (byte)save); - } - break; - case MENU_SORT_ORDER: - Order = !Order; - CheckMenuItem(GetSubMenu(GetMenu(hwnd),5),MENU_SORT_ORDER,MF_BYCOMMAND|(Order?MF_CHECKED:MF_UNCHECKED)); - refreshTree(1); - break; - case MENU_OPEN_OPTIONS: - OPENOPTIONSDIALOG odp = {0}; - odp.cbSize = sizeof(odp); - odp.pszGroup = "Services"; - odp.pszPage = modFullname; - odp.pszTab = 0; - CallService(MS_OPT_OPENOPTIONS,0,(LPARAM)&odp); - break; - } - return TRUE; // case WM_COMMAND - case WM_NOTIFY: - switch(LOWORD(wParam)) - { - case IDC_MODULES: - moduleListWM_NOTIFY(hwnd,msg,wParam,lParam); - break; - case IDC_SETTINGS: - SettingsListWM_NOTIFY(hwnd,msg,wParam,lParam); - break; - } - return TRUE; // case WM_NOTIFY - case WM_FINDITEM: - { - ItemInfo *ii = (ItemInfo*)wParam; - HWND hwnd2Settings = GetDlgItem(hwnd,IDC_SETTINGS); - int hItem = findItemInTree(GetDlgItem(hwnd,IDC_MODULES),ii->hContact,ii->module); - - if (hItem != -1) - { - TreeView_SelectItem(GetDlgItem(hwnd,IDC_MODULES), (HTREEITEM)hItem); - if (ii->type != FW_MODULE) - { - LVITEM lvItem; - LVFINDINFO lvfi; - - lvfi.flags = LVFI_STRING; - lvfi.psz = ii->setting; - lvfi.vkDirection = VK_DOWN; - - lvItem.mask = LVIF_TEXT|LVIF_IMAGE; - lvItem.iItem = ListView_FindItem(hwnd2Settings,-1,&lvfi); - lvItem.iSubItem = 0; - if (lvItem.iItem >= 0) - ListView_SetItemState(hwnd2Settings,lvItem.iItem, LVIS_SELECTED, LVIS_SELECTED); - } - } - } - break; - } // switch(msg) - return 0; -} diff --git a/plugins/Svc_dbepp/modsettingenum.cpp b/plugins/Svc_dbepp/modsettingenum.cpp deleted file mode 100644 index 7eaecdd1a0..0000000000 --- a/plugins/Svc_dbepp/modsettingenum.cpp +++ /dev/null @@ -1,88 +0,0 @@ -#include "headers.h" - -void FreeModuleSettingLL(ModuleSettingLL* msll) -{ - if (msll) - { - - struct ModSetLinkLinkItem *item = msll->first; - struct ModSetLinkLinkItem *temp; - - while (item) - { - mir_free(item->name); - temp = item; - item = (struct ModSetLinkLinkItem *)item->next; - mir_free(temp); - } - - msll->first = 0; - msll->last = 0; - } -} - -int enumModulesSettingsProc( const char *szName , DWORD ofsModuleName , LPARAM lParam) -{ - ModuleSettingLL *msll = (ModuleSettingLL *)lParam; - if (!msll->first) - { - msll->first = (struct ModSetLinkLinkItem *)mir_alloc(sizeof(struct ModSetLinkLinkItem)); - if (!msll->first) return 1; - msll->first->name = mir_tstrdup(szName); - msll->first->next = 0; - msll->last = msll->first; - } - else - { - struct ModSetLinkLinkItem *item = (struct ModSetLinkLinkItem *)mir_alloc(sizeof(struct ModSetLinkLinkItem)); - if (!item) return 1; - msll->last->next = (BYTE*)item; - msll->last = (struct ModSetLinkLinkItem *)item; - item->name = mir_tstrdup(szName); - item->next = 0; - } - return 0; -} - -int EnumModules(ModuleSettingLL *msll) // 1 = success, 0 = fail -{ - msll->first = 0; - msll->last = 0; - return !CallService(MS_DB_MODULES_ENUM, (WPARAM)msll,(WPARAM)enumModulesSettingsProc); -} - - -int enumSettingsProc(const char *szSetting,LPARAM lParam) -{ - return enumModulesSettingsProc(szSetting,0,lParam); -} - - -int EnumSettings(HANDLE hContact, char* module, ModuleSettingLL *msll) -{ - DBCONTACTENUMSETTINGS dbces; - // enum all setting the contact has for the module - dbces.pfnEnumProc = enumSettingsProc; - dbces.szModule = module; - dbces.lParam = (LPARAM)msll; - msll->first = 0; - msll->last = 0; - return !CallService(MS_DB_CONTACT_ENUMSETTINGS, (WPARAM)hContact,(LPARAM)&dbces); -} - -int CheckIfModuleIsEmptyProc(const char *szSetting,LPARAM lParam) -{ - return 1; -} - -int IsModuleEmpty(HANDLE hContact, char* szModule) -{ - DBCONTACTENUMSETTINGS dbces; - int retVal; - dbces.pfnEnumProc = CheckIfModuleIsEmptyProc; - dbces.szModule = szModule; - retVal = CallService(MS_DB_CONTACT_ENUMSETTINGS, (WPARAM)hContact,(LPARAM)&dbces); - if (retVal >= 0) - return 0; - else return 1; -} \ No newline at end of file diff --git a/plugins/Svc_dbepp/modsettingenum.h b/plugins/Svc_dbepp/modsettingenum.h deleted file mode 100644 index 0ef32f8cc5..0000000000 --- a/plugins/Svc_dbepp/modsettingenum.h +++ /dev/null @@ -1,17 +0,0 @@ -struct ModSetLinkLinkItem { - char *name; - BYTE *next; //struct ModSetLinkLinkItem - int known; -}; - -typedef struct { - struct ModSetLinkLinkItem *first; - struct ModSetLinkLinkItem *last; -} ModuleSettingLL; - -int EnumModules(ModuleSettingLL *msll); -int EnumSettings(HANDLE hContact, char* module, ModuleSettingLL *msll); - -void FreeModuleSettingLL(ModuleSettingLL *msll); - -int IsModuleEmpty(HANDLE hContact, char* szModule); \ No newline at end of file diff --git a/plugins/Svc_dbepp/modules.cpp b/plugins/Svc_dbepp/modules.cpp deleted file mode 100644 index 4053180038..0000000000 --- a/plugins/Svc_dbepp/modules.cpp +++ /dev/null @@ -1,109 +0,0 @@ -#include "headers.h" - - -void renameModule(char* oldName, char* newName, HANDLE hContact) -{ - DBVARIANT dbv; - ModuleSettingLL settinglist; - struct ModSetLinkLinkItem *setting; - - if (!EnumSettings(hContact,oldName,&settinglist)) { msg(Translate("Error Loading Setting List"),modFullname); return;} - - setting = settinglist.first; - while (setting) - { - if (!GetSetting(hContact,oldName,setting->name,&dbv)) - { - switch (dbv.type) - { - case DBVT_BYTE: - DBWriteContactSettingByte(hContact, newName, setting->name, dbv.bVal); - break; - case DBVT_WORD: - DBWriteContactSettingWord(hContact, newName, setting->name, dbv.wVal); - break; - case DBVT_DWORD: - DBWriteContactSettingDword(hContact, newName, setting->name, dbv.dVal); - break; - case DBVT_ASCIIZ: - DBWriteContactSettingString(hContact, newName, setting->name, dbv.pszVal); - break; - case DBVT_UTF8: - DBWriteContactSettingStringUtf(hContact, newName, setting->name, dbv.pszVal); - break; - case DBVT_BLOB: - DBWriteContactSettingBlob(hContact, newName, setting->name, dbv.pbVal, dbv.cpbVal); - break; - - } - DBDeleteContactSetting(hContact, oldName, setting->name); - } - DBFreeVariant(&dbv); - setting = (struct ModSetLinkLinkItem *)setting->next; - } - FreeModuleSettingLL(&settinglist); -} - -INT_PTR CALLBACK AddModDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - if (msg == WM_INITDIALOG) - { - SetWindowLongPtr(hwnd,GWLP_USERDATA,lParam); - TranslateDialogDefault(hwnd); - } - if (msg == WM_COMMAND) - { - switch(LOWORD(wParam)) - { - case IDOK: - { - if (GetWindowTextLength(GetDlgItem(hwnd, IDC_MODNAME))) - { - char modulename[256]; - GetDlgItemText(hwnd, IDC_MODNAME, modulename, 256); - if (IsDlgButtonChecked(hwnd,CHK_ADD2ALL)) - { - HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); - // null contact - DBWriteContactSettingByte(NULL, modulename, "(Default)", 0); - while (hContact) - { - DBWriteContactSettingByte(hContact, modulename, "(Default)", 0); - hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)(HANDLE)hContact, 0); - } - } - else - { - DBWriteContactSettingByte((HANDLE)GetWindowLongPtr(hwnd,GWLP_USERDATA), modulename, "(Default)", 0); - } - refreshTree(1); - } - } - // fall through - case IDCANCEL: - DestroyWindow(hwnd); - break; - } - } - return 0; -} - -int CloneContact(HANDLE hContact) -{ - HANDLE newContact = (HANDLE)CallService(MS_DB_CONTACT_ADD,0,0); - - ModuleSettingLL modlist; - struct ModSetLinkLinkItem *mod; - if (!newContact) return 0; - // enum all the modules - if (!EnumModules(&modlist)) { msg(Translate("Error Loading Module List"),modFullname); return 0;} - - mod = modlist.first; - while (mod) - { - copyModule(mod->name,hContact,newContact); - mod = (struct ModSetLinkLinkItem *)mod->next; - } - FreeModuleSettingLL(&modlist); - return 1; -} \ No newline at end of file diff --git a/plugins/Svc_dbepp/moduletree.cpp b/plugins/Svc_dbepp/moduletree.cpp deleted file mode 100644 index b5554cabc5..0000000000 --- a/plugins/Svc_dbepp/moduletree.cpp +++ /dev/null @@ -1,1132 +0,0 @@ -#include "headers.h" - -static BOOL populating = 0; -int Select = 0; -static ModuleTreeInfoStruct contacts_mtis = {CONTACT_ROOT_ITEM, 0}; -static ModuleTreeInfoStruct settings_mtis = {CONTACT, 0}; - - -int doContacts(HWND hwnd2Tree,HTREEITEM contactsRoot,ModuleSettingLL *modlist, HANDLE hSelectedContact, char *SelectedModule, char *SelectedSetting) -{ - TVINSERTSTRUCT tvi; - char szProto[256]; - HANDLE hContact; - HTREEITEM contact; - ModuleTreeInfoStruct *lParam; - struct ModSetLinkLinkItem *module; - int count = CallService(MS_DB_CONTACT_GETCOUNT, 0, 0); - int itemscount = 0; - int loaded, i = 0, icon = 0; - HWND hwnd = GetParent(hwnd2Tree); - int hItem = -1; - -// char percent[96], title[64]; -// mir_snprintf(title, sizeof(title),Translate("Loading contacts...")); - SetWindowText(hwnd2mainWindow, Translate("Loading contacts...")); - - hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); - - tvi.hInsertAfter = TVI_SORT; - tvi.item.cChildren = 1; - - while (hContact && hwnd2mainWindow) // break after null contact - { - - if (GetValue(hContact,"Protocol","p",szProto,SIZEOF(szProto))) - { - icon = GetProtoIcon(szProto); - loaded = (icon != DEF_ICON); - } - else - { - icon = DEF_ICON; - loaded = 0; - } - - i++; - - // filter - if ((loaded && Mode == MODE_UNLOADED) || (!loaded && Mode == MODE_LOADED)) - { - hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); - continue; - } - - // Caption -// mir_snprintf(percent,sizeof(percent),"%s %d%%",title,(int)(100*i/count)); -// SetWindowText(hwnd2mainWindow, percent); - - // add the contact - lParam = (ModuleTreeInfoStruct *)mir_calloc(sizeof(ModuleTreeInfoStruct)); - lParam->hContact = hContact; - lParam->type = CONTACT; - tvi.item.mask = TVIF_TEXT|TVIF_CHILDREN|TVIF_PARAM|TVIF_IMAGE|TVIF_SELECTEDIMAGE; - tvi.item.lParam = (LPARAM)lParam; - tvi.hParent = contactsRoot; - - if (hSelectedContact != hContact) - lParam->type |= EMPTY; - - // contacts name - if (UOS) - { - DBVARIANT dbv ={0}; - WCHAR nick[256]; - WCHAR protoW[256]; // unicode proto - - if (szProto[0]) - a2u(szProto, protoW, SIZEOF(protoW)); - else - protoW[0] = 0; - - if (!szProto[0] || !loaded) - { - tvi.item.iSelectedImage = (tvi.item.iImage = 4); - - if (protoW) - { - if (Order) - mir_snwprintf(nick, SIZEOF(nick), L"(%s) %s %s", protoW, GetContactName(hContact, szProto, 1), L"(UNLOADED)"); - else - mir_snwprintf(nick, SIZEOF(nick), L"%s (%s) %s", GetContactName(hContact, szProto, 1), protoW, L"(UNLOADED)"); - } - else - wcscpy(nick, nick_unknownW); - } - else - { - tvi.item.iSelectedImage = (tvi.item.iImage = icon); //GetProtoIcon(szProto, 7)); - if (Order) - mir_snwprintf(nick, SIZEOF(nick), L"(%s) %s", protoW, GetContactName(hContact, szProto, 1)); - else - mir_snwprintf(nick, SIZEOF(nick), L"%s (%s)", GetContactName(hContact, szProto, 1), protoW); - } - - tvi.item.pszText = (char*)nick; - contact = TreeView_InsertItemW(hwnd2Tree, &tvi); - } - else - { - char nick[256]; - - if (!szProto[0] || !loaded) - { - tvi.item.iSelectedImage = (tvi.item.iImage = 4); - - if (szProto[0]) - { - if (Order) - mir_snprintf(nick, SIZEOF(nick), "(%s) %s %s", szProto, (char*)GetContactName(hContact, szProto, 0), "(UNLOADED)"); - else - mir_snprintf(nick, SIZEOF(nick), "%s (%s) %s", (char*)GetContactName(hContact, szProto, 0), szProto, "(UNLOADED)"); - } - else - strcpy(nick, nick_unknown); - } - else - { - tvi.item.iSelectedImage = (tvi.item.iImage = icon); //GetProtoIcon(szProto, 7)); - if (Order) - mir_snprintf(nick, SIZEOF(nick), "(%s) %s", szProto, (char*)GetContactName(hContact, szProto, 0)); - else - mir_snprintf(nick, SIZEOF(nick), "%s (%s)", (char*)GetContactName(hContact, szProto, 0), szProto); - } - - tvi.item.pszText = nick; - contact = TreeView_InsertItem(hwnd2Tree, &tvi); - } - - itemscount++; - - if (hSelectedContact == hContact) - { - - module = modlist->first; - while(module && hwnd2mainWindow) - { - if (module->name[0] && !IsModuleEmpty(hContact,module->name)) - { - tvi.hParent = contact; - tvi.hInsertAfter = TVI_SORT; - tvi.item.mask = TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_PARAM; - tvi.item.pszText = module->name; - - lParam = (ModuleTreeInfoStruct *)mir_calloc(sizeof(ModuleTreeInfoStruct)); - lParam->hContact = hContact; - - if (!module->known) - { - tvi.item.iImage = 5; - tvi.item.iSelectedImage = 6; - lParam->type = UNKNOWN_MODULE; - } - else - { - tvi.item.iImage = 1; - tvi.item.iSelectedImage = 2; - lParam->type = KNOWN_MODULE; - } - - tvi.item.lParam = (LPARAM)lParam; - TreeView_InsertItem(hwnd2Tree, &tvi); - } - module = (struct ModSetLinkLinkItem *)module->next; - } - - hItem = findItemInTree(hwnd2Tree, hSelectedContact, SelectedModule); - - } - - hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); - } - - - if (hItem != -1) - { - TreeView_SelectItem(hwnd2Tree, (HTREEITEM)hItem); - TreeView_Expand(hwnd2Tree,hItem,TVE_EXPAND); - if (SelectedSetting[0]) SelectSetting(SelectedSetting); - } - -// if (UOS) -// SetWindowText(hwnd, Translate("Database Editor++ (unicode mode)")); -// else -// SetWindowText(hwnd, Translate("Database Editor++ (ansi mode)")); - - - return itemscount; -} - - - -void doItems(HWND hwnd2Tree,ModuleSettingLL *modlist, int count) -{ - TVINSERTSTRUCT tvi; - TVITEM item ={0}; - HANDLE hContact; - HTREEITEM contact; - ModuleTreeInfoStruct *lParam; - struct ModSetLinkLinkItem *module; - char percent[96], title[64]; - HWND hwnd = GetParent(hwnd2Tree); - int i = 0; - - mir_snprintf(title, SIZEOF(title), Translate("Loading modules...")); - - item.mask = TVIF_STATE|TVIF_PARAM; - - contact = TreeView_GetChild( hwnd2Tree, TVI_ROOT ); - contact = TreeView_GetNextSibling(hwnd2Tree, contact); - contact = TreeView_GetChild(hwnd2Tree, contact); - - while (contact && hwnd2mainWindow) - { - i++; - item.hItem = contact; - contact = TreeView_GetNextSibling(hwnd2Tree, contact); - - if (TreeView_GetItem( hwnd2Tree, &item ) && - item.lParam) // && item.state != TVE_EXPAND) - { - ModuleTreeInfoStruct *mtis = (ModuleTreeInfoStruct *)item.lParam; - hContact = mtis->hContact; - if (hContact == NULL || mtis->type != (CONTACT|EMPTY)) - continue; - else - mtis->type = CONTACT; - } - else continue; - - // Caption - mir_snprintf(percent, SIZEOF(percent), "%s %d%%", title, (int)(100*i/count)); - SetWindowText(hwnd, percent); - - module = modlist->first; - while(module && hwnd2mainWindow) - { - if (module->name[0] && !IsModuleEmpty(hContact,module->name)) - { - tvi.hParent = item.hItem; - tvi.hInsertAfter = TVI_SORT; - tvi.item.mask = TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_PARAM; - tvi.item.pszText = module->name; - - lParam = (ModuleTreeInfoStruct *)mir_calloc(sizeof(ModuleTreeInfoStruct)); - lParam->hContact = hContact; - - if (!module->known) - { - tvi.item.iImage = 5; - tvi.item.iSelectedImage = 6; - lParam->type = UNKNOWN_MODULE; - } - else - { - tvi.item.iImage = 1; - tvi.item.iSelectedImage = 2; - lParam->type = KNOWN_MODULE; - } - - tvi.item.lParam = (LPARAM)lParam; - TreeView_InsertItem(hwnd2Tree, &tvi); - } - module = (struct ModSetLinkLinkItem *)module->next; - } - - } - - if (UOS) - SetWindowText(hwnd, Translate("Database Editor++ (unicode mode)")); - else - SetWindowText(hwnd, Translate("Database Editor++ (ansi mode)")); - - -} - - -int findItemInTree(HWND hwnd2Tree, HANDLE hContact, char* module) -/* the following code to go through the whole tree is nicked from codeguru.. -http://www.codeguru.com/Cpp/controls/treeview/treetraversal/comments.php/c683/?thread=7680 */ -{ - TVITEM item; - char text[265]; - HTREEITEM lastItem; - if (!TreeView_GetCount(hwnd2Tree)) return 0; - - item.mask = TVIF_STATE|TVIF_PARAM|TVIF_TEXT; - item.hItem = TVI_ROOT; - item.pszText = text; - item.cchTextMax = 264; - do - { - do - { - lastItem = item.hItem; - if (lastItem != TVI_ROOT) - { -/* these next 2 lines are not from code guru..... */ - if (TreeView_GetItem( hwnd2Tree, &item) && item.lParam) - { - if ((hContact == ((ModuleTreeInfoStruct *)item.lParam)->hContact) && (!module[0] || !mir_strcmp(module,text))) - { - //TreeView_SelectItem(hwnd2Tree,item.hItem); - return (int)item.hItem; - } - } -/* back to coduguru's code*/ - } - } while ( (item.hItem = TreeView_GetChild( hwnd2Tree, lastItem ))); - while ( (! (item.hItem = TreeView_GetNextSibling( hwnd2Tree, lastItem ))) && (lastItem = item.hItem = TreeView_GetParent( hwnd2Tree, lastItem ))) {} - - } while ( item.hItem ); -/*****************************************************************************/ - - return -1; -} - -void freeTree(HWND hwnd2Tree, HANDLE hContact) -/* the following code to go through the whole tree is nicked from codeguru.. -http://www.codeguru.com/Cpp/controls/treeview/treetraversal/comments.php/c683/?thread=7680 */ -{ - TVITEM item; - HTREEITEM lastItem; - if (!TreeView_GetCount(hwnd2Tree)) return; - - item.mask = TVIF_STATE|TVIF_PARAM; - item.hItem = TVI_ROOT; - do - { - do - { - lastItem = item.hItem; - if (lastItem != TVI_ROOT) - { - TreeView_GetItem( hwnd2Tree, &item ); -/* these next 2 lines are not from code guru..... */ - if (item.lParam) - { - ModuleTreeInfoStruct *mtis = (ModuleTreeInfoStruct *)item.lParam; - - if (!hContact || (hContact == mtis->hContact)) - { - if (hContact != NULL) { - TreeView_DeleteItem(hwnd2Tree,item.hItem); - mir_free(mtis); - } else - mtis->type = STUB; - } - } -/* back to coduguru's code*/ - } - } while ( (item.hItem = TreeView_GetChild( hwnd2Tree, lastItem ))); - while ( (! (item.hItem = TreeView_GetNextSibling( hwnd2Tree, lastItem ))) && (lastItem = item.hItem = TreeView_GetParent( hwnd2Tree, lastItem ))) {} - - } while ( item.hItem ); -/*****************************************************************************/ -} - -BOOL findAndRemoveDuplicates(HWND hwnd2Tree, HANDLE hContact, char* module) -/* the following code to go through the whole tree is nicked from codeguru.. -http://www.codeguru.com/Cpp/controls/treeview/treetraversal/comments.php/c683/?thread=7680 */ -{ - TVITEM item; - HTREEITEM lastItem, prelastItem; - BOOL Result = 0; - char text[265]; - if (!TreeView_GetCount(hwnd2Tree)) return Result; - - item.mask = TVIF_STATE|TVIF_PARAM|TVIF_TEXT; - item.hItem = TVI_ROOT; - item.pszText = text; - item.cchTextMax = 264; - prelastItem = item.hItem; - - do - { - do - { - lastItem = item.hItem; - if (lastItem != TVI_ROOT) - { - TreeView_GetItem( hwnd2Tree, &item ); -/* these next lines are not from code guru..... */ - if (item.lParam) - { - ModuleTreeInfoStruct *mtis = (ModuleTreeInfoStruct *)item.lParam; - if (hContact == mtis->hContact && !mir_strcmp(text,module)) - { - mir_free(mtis); - TreeView_DeleteItem(hwnd2Tree,item.hItem); - lastItem = prelastItem; - Result = 1; - } - else - prelastItem = lastItem; - } -/* back to coduguru's code*/ - } - } while ( (item.hItem = TreeView_GetChild( hwnd2Tree, lastItem ))); - while ( (! (item.hItem = TreeView_GetNextSibling( hwnd2Tree, lastItem ))) && (lastItem = item.hItem = TreeView_GetParent( hwnd2Tree, lastItem ))) {} - - } while ( item.hItem ); -/*****************************************************************************/ - - return Result; -} - - -void replaceTreeItem(HWND hwnd, HANDLE hContact, const char *module, const char *newModule) -{ - int hItem = findItemInTree(hwnd, hContact, (char*)module); - HTREEITEM hParent; - - if (hItem == -1) return; - - hParent = TreeView_GetParent(hwnd,(HTREEITEM)hItem); - - { - TVITEM item; - item.mask = TVIF_PARAM; - item.hItem = (HTREEITEM)hItem; - - if (TreeView_GetItem(hwnd, &item)) - mir_free((ModuleTreeInfoStruct *)item.lParam); - TreeView_DeleteItem(hwnd,item.hItem); - } - - if (hParent && newModule) - { - TVINSERTSTRUCT tvi = {0}; - ModuleTreeInfoStruct *lParam; - - tvi.hParent = hParent; - tvi.hInsertAfter = TVI_SORT; - tvi.item.mask = TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_PARAM; - tvi.item.pszText = (char*)newModule; - - lParam = (ModuleTreeInfoStruct *)mir_calloc(sizeof(ModuleTreeInfoStruct)); - lParam->hContact = hContact; - lParam->type = IsModuleKnown((char*)newModule)?KNOWN_MODULE:UNKNOWN_MODULE; - if (lParam->type == UNKNOWN_MODULE) - { - tvi.item.iImage = 5; - tvi.item.iSelectedImage = 6; - } - else - { - tvi.item.iImage = 1; - tvi.item.iSelectedImage = 2; - } - - tvi.item.lParam = (LPARAM)lParam; - - TreeView_InsertItem(hwnd, &tvi); - } -} - -void refreshTree(int restore) -{ - UseKnownModList = DBGetContactSettingByte(NULL,modname,"UseKnownModList",0); - if (populating) return; - populating = 1; - forkthread(PopulateModuleTreeThreadFunc,0,(HWND)restore); -} - -void __cdecl PopulateModuleTreeThreadFunc(LPVOID di) -{ - TVINSERTSTRUCT tvi; - HWND hwnd2Tree = GetDlgItem(hwnd2mainWindow,IDC_MODULES); - char SelectedModule[256] = {0}; - char SelectedSetting[256] = {0}; - HANDLE hSelectedContact = hRestore; - HANDLE hContact; - HTREEITEM contact, contactsRoot; - int count; - - // item lParams - ModuleTreeInfoStruct *lParam; - - // module list - struct ModSetLinkLinkItem *module; - ModuleSettingLL modlist; - - hRestore = NULL; - - if (!hwnd2Tree) { msg(Translate("Module tree not found"),modFullname); return;} - - Select = 0; - - switch((int)di) { - case 1: // restore after rebuild - { - HTREEITEM item; - if (item = TreeView_GetSelection(hwnd2Tree)) - { - TVITEM tvi = {0}; - - tvi.mask=TVIF_HANDLE|TVIF_PARAM|TVIF_TEXT; - tvi.pszText = SelectedModule; - tvi.cchTextMax = 255; - tvi.hItem=item; - - TreeView_GetItem(hwnd2Tree, &tvi); - if (tvi.lParam) - { - ModuleTreeInfoStruct *mtis = (ModuleTreeInfoStruct *)tvi.lParam; - hSelectedContact = mtis->hContact; - if (mtis->type == CONTACT) SelectedModule[0] = 0; - Select = 1; - } - } - break; - } - case 2: // restore saved - if (GetValue(NULL,modname,"LastModule",SelectedModule,SIZEOF(SelectedModule))) - { - hSelectedContact = (HANDLE)DBGetContactSettingDword(NULL,modname,"LastContact",(DWORD)INVALID_HANDLE_VALUE); - if (hSelectedContact != INVALID_HANDLE_VALUE) - Select = 1; - GetValue(NULL,modname,"LastSetting",SelectedSetting,SIZEOF(SelectedSetting)); - } - break; - case 3: // restore from user menu - case 4: // jump from user menu - { - if (hSelectedContact && hSelectedContact != INVALID_HANDLE_VALUE) - { - Select = 1; - } - break; - } - } // switch - - if ((int)di != 4) // do not rebuild on just going to another setting - { - - if (!EnumModules(&modlist)) { msg(Translate("Error Loading Module List"),modFullname); return;} - - // remove all items (incase there are items there... - freeTree(hwnd2Tree,0); - TreeView_DeleteAllItems(hwnd2Tree); - TreeView_SelectItem(hwnd2Tree,0); - - //image list - TreeView_SetImageList(hwnd2Tree, himl, TVSIL_NORMAL); - - /// contact root item - contacts_mtis.type = CONTACT_ROOT_ITEM; - tvi.item.lParam = (LPARAM)&contacts_mtis; - tvi.hParent = NULL; - tvi.item.mask = TVIF_TEXT|TVIF_CHILDREN|TVIF_STATE|TVIF_PARAM|TVIF_IMAGE|TVIF_SELECTEDIMAGE; - tvi.item.state = TVIS_BOLD; - tvi.item.stateMask = TVIS_BOLD; - tvi.item.cChildren = 1; - tvi.hInsertAfter = TVI_FIRST; - - tvi.item.pszText = Translate("Contacts"); - tvi.item.iImage = 3; - tvi.item.iSelectedImage = 3; - contactsRoot = TreeView_InsertItem(hwnd2Tree, &tvi); - - // add the settings item - settings_mtis.type = STUB; - tvi.item.lParam = (LPARAM)&settings_mtis; - tvi.item.mask = TVIF_TEXT|TVIF_CHILDREN|TVIF_PARAM|TVIF_IMAGE|TVIF_SELECTEDIMAGE; - tvi.item.cChildren = 1; - tvi.hParent = NULL; - tvi.hInsertAfter = TVI_FIRST; - tvi.item.pszText = Translate("Settings"); - tvi.item.iSelectedImage = (tvi.item.iImage = 0); - contact = TreeView_InsertItem(hwnd2Tree, &tvi); - - // to fix bug with CHANGE NOTIFY on window activation - TreeView_SelectItem(hwnd2Tree, contact); - settings_mtis.type = CONTACT; - - hContact = 0; - module = modlist.first; - while (module) - { - // set the module status type for the icon - module->known = IsModuleKnown(module->name); - - if (!IsModuleEmpty(hContact,module->name)) - { - tvi.hParent = contact; - tvi.hInsertAfter = TVI_SORT; - tvi.item.mask = TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_PARAM; - tvi.item.pszText = module->name; - - lParam = (ModuleTreeInfoStruct *)mir_calloc(sizeof(ModuleTreeInfoStruct)); - lParam->hContact = hContact; - if (!module->known) - { - tvi.item.iImage = 5; - tvi.item.iSelectedImage = 6; - lParam->type = UNKNOWN_MODULE; - } - else - { - tvi.item.iImage = 1; - tvi.item.iSelectedImage = 2; - lParam->type = KNOWN_MODULE; - } - - tvi.item.lParam = (LPARAM)lParam; - - TreeView_InsertItem(hwnd2Tree, &tvi); - } - module = (struct ModSetLinkLinkItem *)module->next; - } - - if (DBGetContactSettingByte(NULL,modname,"ExpandSettingsOnOpen",0)) - TreeView_Expand(hwnd2Tree,contact,TVE_EXPAND); - - if (Select && hSelectedContact == NULL) - { - int hItem = findItemInTree(hwnd2Tree, hSelectedContact, SelectedModule); - if (hItem != -1) - { - TreeView_SelectItem(hwnd2Tree, (HTREEITEM)hItem); - TreeView_Expand(hwnd2Tree,hItem,TVE_EXPAND); - if (SelectedSetting[0]) SelectSetting(SelectedSetting); - } - Select = 0; - } - - count = doContacts(hwnd2Tree,contactsRoot,&modlist, Select?hSelectedContact:NULL, SelectedModule, SelectedSetting); - Select = 0; - doItems(hwnd2Tree,&modlist,count); - - FreeModuleSettingLL(&modlist); - } - - if (Select) - { - int hItem = findItemInTree(hwnd2Tree, hSelectedContact, SelectedModule); - if (hItem != -1) - { - TreeView_SelectItem(hwnd2Tree, (HTREEITEM)hItem); - TreeView_Expand(hwnd2Tree,hItem,TVE_EXPAND); - if (SelectedSetting[0]) SelectSetting(SelectedSetting); - } - } - - populating = 0; - -} - - -static WNDPROC ModuleTreeLabelEditSubClass; - -static LRESULT CALLBACK ModuleTreeLabelEditSubClassProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam) -{ - switch(msg) { - case WM_KEYUP: - switch (wParam) - { - case VK_RETURN: - TreeView_EndEditLabelNow(GetParent(hwnd),0); - return 0; - case VK_ESCAPE: - TreeView_EndEditLabelNow(GetParent(hwnd),1); - return 0; - } - break; - } - return CallWindowProc(ModuleTreeLabelEditSubClass,hwnd,msg,wParam,lParam); -} -void moduleListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam); - -void moduleListWM_NOTIFY(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)// hwnd here is to the main window, NOT the treview -{ - switch(((NMHDR*)lParam)->code) - { - case TVN_ITEMEXPANDINGA: - case TVN_ITEMEXPANDINGW: - if (populating && ((LPNMTREEVIEW)lParam)->action == TVE_EXPAND) - { - ModuleTreeInfoStruct *mtis = (ModuleTreeInfoStruct *)((LPNMTREEVIEW)lParam)->itemNew.lParam; - if (mtis && (mtis->type == (CONTACT | EMPTY))) - { - TVINSERTSTRUCT tvi; - HTREEITEM item = {0}; - ModuleTreeInfoStruct *_lParam; - HWND hwnd2Tree = GetDlgItem(hwnd2mainWindow,IDC_MODULES); - struct ModSetLinkLinkItem *module; - ModuleSettingLL modlist; - HANDLE hContact = mtis->hContact; - - mtis->type = CONTACT; - - if (!EnumModules(&modlist)) { msg(Translate("Error Loading Module List"),modFullname); break;} - - module = modlist.first; - while(module && hwnd2mainWindow) - { - if (module->name[0] && !IsModuleEmpty(hContact,module->name)) - { - tvi.hParent = ((LPNMTREEVIEW)lParam)->itemNew.hItem; - tvi.hInsertAfter = TVI_SORT; - tvi.item.mask = TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_PARAM; - tvi.item.pszText = module->name; - - _lParam = (ModuleTreeInfoStruct *)mir_calloc(sizeof(ModuleTreeInfoStruct)); - _lParam->hContact = hContact; - - if (IsModuleKnown(module->name)) - { - tvi.item.iImage = 5; - tvi.item.iSelectedImage = 6; - _lParam->type = KNOWN_MODULE; - } - else - { - tvi.item.iImage = 1; - tvi.item.iSelectedImage = 2; - _lParam->type = UNKNOWN_MODULE; - } - - tvi.item.lParam = (LPARAM)_lParam; - TreeView_InsertItem(hwnd2Tree, &tvi); - } - module = (struct ModSetLinkLinkItem *)module->next; - } - - FreeModuleSettingLL(&modlist); - } - - } - break; - - case TVN_SELCHANGEDA: - case TVN_SELCHANGEDW: - { - ModuleTreeInfoStruct *mtis; - LPNMTREEVIEW pnmtv = (LPNMTREEVIEW)lParam; - TVITEM tvi = {0}; - char text[264]; - HANDLE hContact; - HWND hwnd2Settings = GetDlgItem(hwnd, IDC_SETTINGS); - tvi.mask = TVIF_HANDLE|TVIF_PARAM|TVIF_TEXT; - tvi.hItem = pnmtv->itemNew.hItem; - tvi.pszText = text; - tvi.cchTextMax = 264; - TreeView_GetItem(pnmtv->hdr.hwndFrom,&tvi); - - if (tvi.lParam) - { - mtis = (ModuleTreeInfoStruct *)tvi.lParam; - hContact = mtis->hContact; - - if (mtis->type == STUB) break; - - if (populating) Select = 0; - - if (mtis->type == MODULE || mtis->type == UNKNOWN_MODULE) - { - SettingListInfo *info = (SettingListInfo*)GetWindowLongPtr(hwnd2Settings,GWLP_USERDATA); - BOOL refresh = 1; - - if (info) - { - if (info->hContact == hContact && - !mir_strcmp(info->module, text)) - refresh = 0; - } - - if (refresh) - PopulateSettings(hwnd2Settings, hContact, text); - } - else - if (((mtis->type & CONTACT) == CONTACT && hContact) || - (mtis->type == CONTACT_ROOT_ITEM && !hContact)) - { - char data[32], szProto[256]; - int index, loaded, multi = 0; - LVITEM lvi = {0}; - lvi.mask = LVIF_IMAGE|LVIF_TEXT|LVIF_PARAM; - lvi.iImage = 6; - - ClearListview(hwnd2Settings); - SetWindowLongPtr(hwnd2Settings,GWLP_USERDATA, (LONG)NULL); - if (himl2) ListView_SetImageList(hwnd2Settings, himl2, LVSIL_SMALL); - - if (mtis->type == CONTACT_ROOT_ITEM && !hContact) - { - multi = 1; - hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); - } - - while(hContact && hwnd2mainWindow) - { - if (multi) - { - // filter - if (GetValue(hContact,"Protocol","p",szProto,SIZEOF(szProto))) - loaded = IsProtocolLoaded(szProto); - else - loaded = 0; - - if ((loaded && Mode == MODE_UNLOADED) || (!loaded && Mode == MODE_LOADED)) - { - hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); - continue; - } - } - - lvi.iItem = 0; - lvi.pszText = (char*)GetContactName(hContact,NULL,UOS); - - if (UOS) - index = ListView_InsertItemW(hwnd2Settings,&lvi); - else - index = ListView_InsertItem(hwnd2Settings,&lvi); - - mir_snprintf(data, SIZEOF(data), "0x%08X (%ld)", hContact, hContact); - - ListView_SetItemText(hwnd2Settings,index,1,data); - ListView_SetItemText(hwnd2Settings,index,2,Translate("HANDLE")); - ListView_SetItemText(hwnd2Settings,index,3,"0x0004 (4)"); - - if (!multi) break; - - hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); - } - - } - else - ClearListview(hwnd2Settings); - } - else - { - // clear any settings that may be there... - ClearListview(hwnd2Settings); - } - } - break; //TVN_SELCHANGED: - case NM_RCLICK: - if (((NMHDR*)lParam)->code == NM_RCLICK) - moduleListRightClick(hwnd,wParam,lParam); - break; - case TVN_BEGINLABELEDITA: // subclass it.. - case TVN_BEGINLABELEDITW: - { - LPNMTVDISPINFO ptvdi = (LPNMTVDISPINFO) lParam; - ModuleTreeInfoStruct *mtis = (ModuleTreeInfoStruct *)ptvdi->item.lParam; - HWND hwnd2Edit = TreeView_GetEditControl(GetDlgItem(hwnd, IDC_MODULES)); - if (!mtis->type || (mtis->type == CONTACT)) - { - SetWindowLongPtr(hwnd, DWLP_MSGRESULT, TRUE); - break; - } - ModuleTreeLabelEditSubClass = (WNDPROC)SetWindowLongPtr(hwnd2Edit, GWLP_WNDPROC, (LONG)ModuleTreeLabelEditSubClassProc); - SetWindowLongPtr(hwnd, DWLP_MSGRESULT, FALSE); - } - break; - case TVN_ENDLABELEDITA: - case TVN_ENDLABELEDITW: - { - LPNMTVDISPINFO ptvdi = (LPNMTVDISPINFO) lParam; - TVITEM tvi = {0}; - char text[264]; - char *newtext; - ModuleTreeInfoStruct *mtis; - tvi.mask=TVIF_HANDLE|TVIF_TEXT|TVIF_PARAM; - tvi.hItem=ptvdi->item.hItem; - tvi.pszText = text; - tvi.cchTextMax = 264; - TreeView_GetItem(((LPNMHDR)lParam)->hwndFrom,&tvi); - mtis = (ModuleTreeInfoStruct *)ptvdi->item.lParam; - - if (UOS) - newtext = u2a((WCHAR*)ptvdi->item.pszText); - else - newtext = mir_tstrdup(ptvdi->item.pszText); - - if (!newtext || // edit control failed - !mtis->type || // its a root item - mtis->type == CONTACT || // its a contact - *newtext == 0) // empty string - SetWindowLongPtr(hwnd, DWLP_MSGRESULT, FALSE); - else - { - if (mir_strcmp(tvi.pszText, newtext)) - { - renameModule(tvi.pszText, newtext, mtis->hContact); - - findAndRemoveDuplicates(((LPNMHDR)lParam)->hwndFrom,mtis->hContact,newtext); - - if (TreeView_GetItem(((LPNMHDR)lParam)->hwndFrom,&tvi)) - { - tvi.mask = TVIF_IMAGE|TVIF_SELECTEDIMAGE; - if (!IsModuleKnown(newtext)) - { - tvi.iImage = 5; - tvi.iSelectedImage = 6; - } - else - { - tvi.iImage = 1; - tvi.iSelectedImage = 2; - } - TreeView_SetItem(((LPNMHDR)lParam)->hwndFrom, &tvi); - - PopulateSettings(GetDlgItem(hwnd, IDC_SETTINGS), mtis->hContact, newtext); - } - } - SetWindowLongPtr(hwnd, DWLP_MSGRESULT, TRUE); - } - - mir_free(newtext); - } - break; - } -} - -void moduleListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam) // hwnd here is to the main window, NOT the treview -{ - TVHITTESTINFO hti; - hti.pt.x=(short)LOWORD(GetMessagePos()); - hti.pt.y=(short)HIWORD(GetMessagePos()); - ScreenToClient(((LPNMHDR)lParam)->hwndFrom,&hti.pt); - - if(TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom,&hti)) - { - if(hti.flags&TVHT_ONITEM) - { - TVITEM tvi = {0}; - HMENU hMenu,hSubMenu; - int menuNumber; - char module[256]; - tvi.mask=TVIF_HANDLE|TVIF_PARAM|TVIF_TEXT; - tvi.hItem=hti.hItem; - tvi.pszText = module; - tvi.cchTextMax = 255; - TreeView_GetItem(((LPNMHDR)lParam)->hwndFrom,&tvi); - if (tvi.lParam) - { - ModuleTreeInfoStruct *mtis = (ModuleTreeInfoStruct *)tvi.lParam; - HANDLE hContact = mtis->hContact; - GetCursorPos(&(hti.pt)); - hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_CONTEXTMENU)); - TranslateMenu(hMenu); - if (mtis->type == CONTACT && hContact) menuNumber = 2; - else if ((mtis->type == MODULE || mtis->type == UNKNOWN_MODULE) && !hContact) menuNumber = 1; - else if (mtis->type == CONTACT && !hContact) menuNumber = 3; - else if (mtis->type == CONTACT_ROOT_ITEM && !hContact) menuNumber = 4; - else if ((mtis->type == MODULE || mtis->type == UNKNOWN_MODULE) && hContact) menuNumber = 5; - else return; - hSubMenu = GetSubMenu(hMenu, menuNumber); - - TranslateMenu(hSubMenu); - switch (menuNumber) - { - case 1: // null module - case 5: // contact module - { - // check if we r already watching the module - int i; - int watching = 0; - // check if the setting is being watched and if it is then check the menu item - if (WatchListArray.item) - for (i=0; ihwndFrom,hti.hItem); - mir_free(mtis); - } - break; - case MENU_COPY_MOD: - copyModuleMenuItem(module, hContact); - break; -////////////////////////////////////////////////////////////////////// divider - case MENU_WATCH_ITEM: - if (!watching) - addSettingToWatchList(hContact,module,0); - else freeWatchListItem(i); - if (hwnd2watchedVarsWindow) - PopulateWatchedWindow(GetDlgItem(hwnd2watchedVarsWindow, IDC_VARS)); - break; - case MENU_EXPORTMODULE: - exportDB(hContact, module); - break; - case MENU_EXPORTDB: - exportDB(INVALID_HANDLE_VALUE, module); - break; - case MENU_ADDKNOWN: - { - DBVARIANT dbv; - char *moduletemp = (char*)_alloca(strlen(module)*3); - unsigned int i; - moduletemp[0] = '\0'; - for(i=0;ihwndFrom,hContact); - TreeView_DeleteItem(((LPNMHDR)lParam)->hwndFrom,tvi.hItem); - } - } - else - { - CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact,0); - freeTree(((LPNMHDR)lParam)->hwndFrom,hContact); - TreeView_DeleteItem(((LPNMHDR)lParam)->hwndFrom,tvi.hItem); - } - break; -////////////////////////////////////////////////////////////////////// divider - case MENU_EXPORTCONTACT: - exportDB(hContact, 0); - break; - case MENU_IMPORTFROMTEXT: - ImportSettingsMenuItem(hContact); - break; - case MENU_IMPORTFROMFILE: - ImportSettingsFromFileMenuItem(hContact, ""); - break; -////////////////////////////////////////////////////////////////////// divider - case MENU_ADD_MODULE: - { - HWND AddModhwnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ADD_MODULE), hwnd, AddModDlgProc, (LPARAM)hContact); - char msg[1024]; - mir_snprintf(msg, SIZEOF(msg), Translate("Add module to contact \"%s\""), module); - SetWindowText(AddModhwnd, module); - } - break; - } - break; - case 3: // NULL contact - switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, hti.pt.x, hti.pt.y, 0, hwnd, NULL)) - { - case MENU_ADD_MODULE: - { - HWND AddModhwnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ADD_MODULE), hwnd, AddModDlgProc, (LPARAM)hContact); - char msg[1024]; - mir_snprintf(msg, SIZEOF(msg), Translate("Add module to contact \"%s\""), module); - SetWindowText(AddModhwnd, module); - } - break; - case MENU_EXPORTCONTACT: - exportDB(NULL, 0); - break; - case MENU_IMPORTFROMTEXT: - ImportSettingsMenuItem(NULL); - break; - case MENU_IMPORTFROMFILE: - ImportSettingsFromFileMenuItem(NULL, ""); - break; - } - break; - case 4: // Contacts root - switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, hti.pt.x, hti.pt.y, 0, hwnd, NULL)) - { - case MENU_EXPORTCONTACT: - exportDB(INVALID_HANDLE_VALUE, ""); - break; - case MENU_IMPORTFROMTEXT: - ImportSettingsMenuItem(NULL); - break; - case MENU_IMPORTFROMFILE: - ImportSettingsFromFileMenuItem(NULL, ""); - break; - } - break; - } - DestroyMenu(hMenu); - } - } // if (tvi.lParam) - } // if(hti.flags&TVHT_ONITEM) -} \ No newline at end of file diff --git a/plugins/Svc_dbepp/options.cpp b/plugins/Svc_dbepp/options.cpp deleted file mode 100644 index 0630fa353c..0000000000 --- a/plugins/Svc_dbepp/options.cpp +++ /dev/null @@ -1,94 +0,0 @@ -#include "headers.h" - -INT_PTR CALLBACK DlgProcOpts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - switch(msg) - { - case WM_INITDIALOG: - { - DBVARIANT dbv; - CheckDlgButton(hwnd,IDC_EXPANDSETTINGS,DBGetContactSettingByte(NULL,modname,"ExpandSettingsOnOpen",0)); - CheckDlgButton(hwnd,IDC_RESTORESETTINGS,DBGetContactSettingByte(NULL,modname,"RestoreOnOpen",1)); - CheckDlgButton(hwnd,IDC_USEKNOWNMODS,DBGetContactSettingByte(NULL,modname,"UseKnownModList",0)); - CheckDlgButton(hwnd,IDC_WARNONDEL,DBGetContactSettingByte(NULL,modname,"WarnOnDelete",1)); - CheckDlgButton(hwnd,IDC_MENU,DBGetContactSettingByte(NULL,modname,"UserMenuItem",0)); - CheckDlgButton(hwnd,IDC_POPUPS,usePopUps); - if (!DBGetContactSetting(NULL,modname,"CoreModules",&dbv) && dbv.type == DBVT_ASCIIZ) - SetDlgItemText(hwnd,IDC_MODULES,dbv.pszVal); - DBFreeVariant(&dbv); - SetDlgItemInt(hwnd,IDC_POPUPTIMEOUT,DBGetContactSettingWord(NULL,modname,"PopupDelay",4),0); - SendDlgItemMessage(hwnd, IDC_COLOUR, CPM_SETCOLOUR, 0, (LPARAM)DBGetContactSettingDword(NULL,modname,"PopupColour",RGB(255,0,0))); - TranslateDialogDefault(hwnd); - } - return TRUE; - case WM_COMMAND: - switch(LOWORD(wParam)) - { - case IDC_RESTORESETTINGS: - case IDC_EXPANDSETTINGS: - case IDC_USEKNOWNMODS: - case IDC_MODULES: - case IDC_MENU: - case IDC_POPUPS: - case IDC_WARNONDEL: - case IDC_COLOUR: - case IDC_POPUPTIMEOUT: - SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0); - break; - } - break; - case WM_NOTIFY: - switch(((LPNMHDR)lParam)->idFrom) - { - case 0: - switch (((LPNMHDR)lParam)->code) - { - case PSN_APPLY: - { - CLISTMENUITEM mi = {0}; - char mods[4096]; - DBWriteContactSettingByte(NULL,modname,"ExpandSettingsOnOpen",(BYTE)IsDlgButtonChecked(hwnd,IDC_EXPANDSETTINGS)); - DBWriteContactSettingByte(NULL,modname,"RestoreOnOpen",(BYTE)IsDlgButtonChecked(hwnd,IDC_RESTORESETTINGS)); - DBWriteContactSettingByte(NULL,modname,"WarnOnDelete",(BYTE)IsDlgButtonChecked(hwnd,IDC_WARNONDEL)); - DBWriteContactSettingByte(NULL,modname,"UserMenuItem",(BYTE)IsDlgButtonChecked(hwnd,IDC_MENU)); - DBWriteContactSettingByte(NULL,modname,"UseKnownModList",(BYTE)IsDlgButtonChecked(hwnd,IDC_USEKNOWNMODS)); - usePopUps = IsDlgButtonChecked(hwnd,IDC_POPUPS); - DBWriteContactSettingByte(NULL,modname,"UsePopUps",(BYTE)usePopUps); - if (GetDlgItemText(hwnd,IDC_MODULES,mods,4096)) - DBWriteContactSettingString(NULL,modname,"CoreModules",mods); - DBWriteContactSettingWord(NULL,modname,"PopupDelay",(WORD)GetDlgItemInt(hwnd,IDC_POPUPTIMEOUT,NULL,0)); - DBWriteContactSettingDword(NULL,modname,"PopupColour",(DWORD)SendDlgItemMessage(hwnd, IDC_COLOUR, CPM_GETCOLOUR, 0, 0)); - - mi.cbSize = sizeof(mi); - - if (!IsDlgButtonChecked(hwnd,IDC_MENU)) - mi.flags = CMIM_FLAGS | CMIF_HIDDEN; - else - mi.flags = CMIM_FLAGS; - - CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM) hUserMenu, (LPARAM) & mi); - - } - return TRUE; - } - break; - } - break; - } - return FALSE; -} - -INT OptInit(WPARAM wParam,LPARAM lParam) -{ - OPTIONSDIALOGPAGE odp = { 0 }; - odp.cbSize = sizeof(odp); - odp.hInstance = hInst; - odp.pszTemplate = MAKEINTRESOURCE(IDD_OPTIONS); - odp.pszGroup = LPGEN("Services"); - odp.pszTitle = modFullname; - odp.pfnDlgProc = DlgProcOpts; - odp.flags = ODPF_BOLDGROUPS; - Options_AddPage(wParam, &odp); - - return 0; -} \ No newline at end of file diff --git a/plugins/Svc_dbepp/resource.h b/plugins/Svc_dbepp/resource.h deleted file mode 100644 index c32d146126..0000000000 --- a/plugins/Svc_dbepp/resource.h +++ /dev/null @@ -1,157 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by resource.rc -// -#define ICO_REGEDIT 1 -#define ICO_UNICODE 2 -#define ICO_DBE_BUTT 3 -#define ICO_REGUSER 4 -#define ICO_STRING 5 -#define ICO_BINARY 6 -#define ICO_DWORD 7 -#define ICO_BYTE 8 -#define ICO_WORD 9 -#define ICO_HANDLE 10 -#define IDD_MAIN 101 -#define IDR_MAINMENU 103 -#define IDR_CONTEXTMENU 104 -#define ICO_CONTACTS 106 -#define ICO_OFFLINE 107 -#define IDD_ADD_MODULE 108 -#define IDD_EDIT_SETTING 109 -#define IDD_WATCH_DIAG 110 -#define IDR_WATCHWINDOWMENU 112 -#define ICO_UNLOADED 115 -#define IDD_COPY_MOD 116 -#define IDD_IMPORT 118 -#define IDD_CHANGE_ARRAYSIZE 120 -#define IDD_FIND 121 -#define IDD_OPTIONS 122 -#define ICO_KNOWN 124 -#define ICO_KNOWNOPEN 125 -#define ICO_UNKNOWNOPEN 126 -#define ICO_UNKNOWN 127 -#define ICO_SETTINGS 128 -#define ICO_ONLINE 129 -#define IDC_MODULES 1000 -#define IDC_SETTINGS 1001 -#define IDC_MENU 1002 -#define IDC_MODNAME 1004 -#define CHK_ADD2ALL 1005 -#define IDC_MODNAME2 1005 -#define IDC_SETTINGNAME 1006 -#define IDC_SPLITTER 1006 -#define IDC_STRING 1007 -#define IDC_SETTINGNAME2 1007 -#define GRP_BASE 1008 -#define CHK_HEX 1009 -#define CHK_DECIMAL 1010 -#define IDC_SETTINGVALUE 1011 -#define GRP_TYPE 1012 -#define IDC_SETTINGVALUE2 1012 -#define CHK_BYTE 1013 -#define IDC_SETTINGVALUE3 1013 -#define CHK_WORD 1014 -#define CHK_DWORD 1015 -#define CHK_STRING 1016 -#define IDC_VARS 1017 -#define IDC_ADDMODNAMESTATIC 1020 -#define IDC_CONTACTS 1021 -#define CHK_COPY2ALL 1022 -#define IDC_TEXT 1025 -#define IDC_FIND 1026 -#define IDC_REPLACE 1027 -#define IDC_CASE_SENSITIVE 1027 -#define IDC_REQUIRED 1028 -#define IDC_ARRAYSIZE 1030 -#define IDC_CURRENTSIZE 1032 -#define IDC_INFOTEXT 1033 -#define IDC_CRLF 1035 -#define IDC_CASESENSITIVE 1040 -#define IDC_LIST 1041 -#define IDC_SEARCH 1042 -#define IDC_EXACT 1043 -#define IDC_EXPANDSETTINGS 1044 -#define IDC_USEKNOWNMODS 1045 -#define IDC_WARNONDEL 1047 -#define IDC_POPUPS 1048 -#define IDC_POPUPTIMEOUT 1049 -#define IDC_COLOUR 1050 -#define IDC_RESTORESETTINGS 1051 -#define IDC_BLOB 1052 -#define IDC_FOUND 1056 -#define IDC_SBAR 1057 -#define IDC_ENTIRELY 1058 -#define MENU_REFRESH_MODS 40001 -#define MENU_REFRESH_SETS 40002 -#define MENU_EXIT 40003 -#define MENU_CHANGE2UNICODE 40004 -#define MENU_ADD_UNICODE 40005 -#define MENU_RENAME_SET 40006 -#define MENU_EDIT_SET 40007 -#define MENU_CHANGE2BYTE 40008 -#define MENU_CHANGE2WORD 40009 -#define MENU_CHANGE2DWORD 40010 -#define MENU_CHANGE2STRING 40011 -#define MENU_DELETE_SET 40012 -#define MENU_DELETE_MOD 40013 -#define MENU_CREATE_MOD 40014 -#define MENU_VIEW_WATCHES 40016 -#define MENU_REMALL_WATCHES 40017 -#define MENU_ADD_WATCH 40018 -#define MENU_WATCH_ITEM 40018 -#define MENU_WATCH_MOD 40019 -#define MENU_ADD_BLOB 40020 -#define MENU_CLONE_CONTACT 40021 -#define MENU_DELETE_CONTACT 40022 -#define MENU_ADD_MODULE 40023 -#define MENU_ADD_BYTE 40024 -#define MENU_ADD_WORD 40025 -#define MENU_ADD_DWORD 40026 -#define MENU_ADD_STRING 40027 -#define MENU_SAVE_WATCHES 40028 -#define MENU_RENAME_MOD 40030 -#define MENU_COPY_MOD 40032 -#define MENU_USE_MODLIST 40033 -#define MENU_USE_POPUPS 40034 -#define MENU_SORT_ORDER 40035 -#define MENU_EXPORTDB 40036 -#define MENU_EXPORTMODULE 40037 -#define MENU_EXPORTCONTACT 40038 -#define MENU_SAVE_POSITION 40039 -#define MENU_IMPORTSETTINGS 40040 -#define MENU_ADDCONTACT 40041 -#define MENU_WARNONDEL 40042 -#define MENU_LOAD_WATCHES 40043 -#define MENU_WORD_HEX 40044 -#define MENU_DECRYPT 40045 -#define MENU_ENCRYPT 40046 -#define MENU_VIEWDECRYPT 40047 -#define MENU_VIEWENCRYPT 40048 -#define MENU_LOGTODISK 40049 -#define MENU_FINDANDREPLACE 40050 -#define MENU_FINDMODSETTING 40051 -#define MENU_DWORD_HEX 40052 -#define MENU_IMPORTFROMFILE 40053 -#define MENU_IMPORTFROMTEXT 40054 -#define MENU_CHANGEARRAYSIZE 40055 -#define MENU_OPTIONS 40056 -#define MENU_DELETE 40057 -#define MENU_REFRESH 40058 -#define MENU_ADDKNOWN 40059 -#define MENU_FILTER_ALL 40060 -#define MENU_FILTER_LOADED 40061 -#define MENU_FILTER_UNLOADED 40062 -#define MENU_BYTE_HEX 40063 -#define MENU_OPEN_OPTIONS 40064 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 131 -#define _APS_NEXT_COMMAND_VALUE 40065 -#define _APS_NEXT_CONTROL_VALUE 1059 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/plugins/Svc_dbepp/resource.rc b/plugins/Svc_dbepp/resource.rc deleted file mode 100644 index 26ac45f0eb..0000000000 --- a/plugins/Svc_dbepp/resource.rc +++ /dev/null @@ -1,516 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// Ŕíăëčéńęčé (ŃŘŔ) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_FIND DIALOGEX 0, 0, 340, 249 -STYLE DS_SETFONT | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME -CAPTION "Database Editor++ Search and Replace" -FONT 8, "MS Shell Dlg", 0, 0, 0x0 -BEGIN - EDITTEXT IDC_TEXT,40,13,216,12,ES_AUTOHSCROLL - CONTROL "Case Sensitive",IDC_CASESENSITIVE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,40,30,72,10 - CONTROL "Module Name",IDC_MODNAME,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,40,44,73,10 - CONTROL "Exact Match",IDC_EXACT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,115,30,64,10 - CONTROL "Setting Name",IDC_SETTINGNAME,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,115,44,72,10 - CONTROL "Setting Value",IDC_SETTINGVALUE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,194,44,69,10 - DEFPUSHBUTTON "&Search",IDC_SEARCH,277,5,60,14 - EDITTEXT IDC_REPLACE,40,72,216,12,ES_AUTOHSCROLL - CONTROL "Module Name",IDC_MODNAME2,"Button",BS_AUTORADIOBUTTON | NOT WS_VISIBLE | WS_DISABLED | WS_GROUP | WS_TABSTOP,40,90,73,10 - CONTROL "Setting Name",IDC_SETTINGNAME2,"Button",BS_AUTORADIOBUTTON | NOT WS_VISIBLE | WS_DISABLED | WS_TABSTOP,115,90,72,10 - CONTROL "Setting Value",IDC_SETTINGVALUE2,"Button",BS_AUTORADIOBUTTON | NOT WS_VISIBLE | WS_DISABLED | WS_TABSTOP,194,90,67,10 - CONTROL "Found field",IDC_FOUND,"Button",BS_AUTORADIOBUTTON | NOT WS_VISIBLE | WS_TABSTOP,267,90,65,10 - PUSHBUTTON "&Replace",IDOK,277,25,60,14 - PUSHBUTTON "&Cancel",IDCANCEL,277,45,60,14 - LISTBOX IDC_LIST,3,95,334,136,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP - GROUPBOX "Search For",IDC_STATIC,3,1,268,58 - LTEXT "Text:",IDC_STATIC,10,15,26,8 - LTEXT "In:",IDC_STATIC,10,30,23,8 - GROUPBOX "Replace With",IDC_STATIC,3,60,334,30 - LTEXT "Text:",IDC_STATIC,10,74,26,8 - LTEXT "In:",IDC_STATIC,10,90,23,8,NOT WS_VISIBLE - CONTROL "",IDC_SBAR,"msctls_statusbar32",WS_TABSTOP | 0x100,3,237,334,12 - CONTROL "Entirely",IDC_ENTIRELY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,262,74,67,10 -END - -IDD_OPTIONS DIALOGEX 0, 0, 314, 239 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE -FONT 8, "MS Shell Dlg", 0, 0, 0x0 -BEGIN - CONTROL "Restore last opened position",IDC_RESTORESETTINGS, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,13,283,10 - CONTROL "Automatically expand ""settings"" when Database Editor ++ starts",IDC_EXPANDSETTINGS, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,26,283,10 - CONTROL "Use known modules list",IDC_USEKNOWNMODS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,39,253,10 - CONTROL "Warn when deleting modules",IDC_WARNONDEL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,52,280,10 - CONTROL """Open user tree in DBE++"" menu item",IDC_MENU,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,65,280,10 - CONTROL "Use popups when watched settings change values",IDC_POPUPS, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,78,275,10 - EDITTEXT IDC_POPUPTIMEOUT,144,89,20,12,ES_NUMBER - CONTROL "",IDC_COLOUR,"ColourPicker",WS_TABSTOP,257,89,26,12 - EDITTEXT IDC_MODULES,12,140,288,46,ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN | WS_VSCROLL - GROUPBOX "Modules to ALWAYS mark as known (e.g core modules)",IDC_STATIC,7,105,300,96 - LTEXT "Put a space or comma between each module name",IDC_STATIC,12,116,286,8 - LTEXT "Changes to this list will take effect next time miranda starts",IDC_STATIC,12,189,284,8 - RTEXT "Popup timeout (0 for infinite)",IDC_STATIC,35,91,103,8 - RTEXT "Background Colour",IDC_STATIC,177,91,77,8 - LTEXT "If the module name has a space in it, put a \\ before the space. eg ""aaa\\ bbb""",IDC_STATIC,12,127,286,8 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_FIND, DIALOG - BEGIN - LEFTMARGIN, 3 - RIGHTMARGIN, 337 - VERTGUIDE, 10 - VERTGUIDE, 40 - VERTGUIDE, 115 - VERTGUIDE, 194 - VERTGUIDE, 277 - TOPMARGIN, 7 - HORZGUIDE, 18 - HORZGUIDE, 35 - HORZGUIDE, 48 - HORZGUIDE, 68 - HORZGUIDE, 95 - END - - IDD_OPTIONS, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 307 - VERTGUIDE, 12 - TOPMARGIN, 7 - BOTTOMMARGIN, 232 - HORZGUIDE, 68 - END -END -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -ICO_KNOWN ICON "res\\Yellow.ico" -ICO_KNOWNOPEN ICON "res\\Yellow_open.ico" -ICO_UNKNOWNOPEN ICON "res\\Red_open.ico" -ICO_UNKNOWN ICON "res\\Red.ico" -ICO_SETTINGS ICON "res\\Icon_4.ico" -ICO_ONLINE ICON "res\\online2.ico" -#endif // Ŕíăëčéńęčé (ŃŘŔ) resources -///////////////////////////////////////////////////////////////////////////// - - -///////////////////////////////////////////////////////////////////////////// -// Ŕíăëčéńęčé (Ŕâńňđŕëč˙) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENA) -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_AUS -#pragma code_page(1252) - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_ADD_MODULE DIALOGEX 0, 0, 186, 67 -STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "Add a module to contact" -FONT 8, "MS Shell Dlg", 0, 0, 0x0 -BEGIN - EDITTEXT IDC_MODNAME,7,17,172,12,ES_AUTOHSCROLL - LTEXT "Add a module named",IDC_ADDMODNAMESTATIC,7,6,124,8 - CONTROL "Add to all contacts (Includes Settings)",CHK_COPY2ALL, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,35,172,10 - DEFPUSHBUTTON "OK",IDOK,29,49,50,14 - PUSHBUTTON "Cancel",IDCANCEL,107,49,50,14 -END - -IDD_EDIT_SETTING DIALOGEX 0, 0, 252, 121 -STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION -CAPTION "Edit Setting" -FONT 8, "MS Shell Dlg", 0, 0, 0x0 -BEGIN - EDITTEXT IDC_SETTINGNAME,7,18,238,14,ES_AUTOHSCROLL - EDITTEXT IDC_SETTINGVALUE,7,49,159,14,ES_AUTOHSCROLL - EDITTEXT IDC_STRING,49,37,196,61,ES_MULTILINE | ES_WANTRETURN | NOT WS_VISIBLE | WS_VSCROLL | WS_HSCROLL - EDITTEXT IDC_BLOB,49,37,196,61,ES_MULTILINE | NOT WS_VISIBLE | WS_VSCROLL - RADIOBUTTON "Byte",CHK_BYTE,13,81,30,10 - RADIOBUTTON "Word",CHK_WORD,50,81,33,10 - RADIOBUTTON "Dword",CHK_DWORD,90,81,37,10 - RADIOBUTTON "String",CHK_STRING,132,81,34,10 - DEFPUSHBUTTON "OK",IDOK,70,102,50,14 - PUSHBUTTON "Cancel",IDCANCEL,132,102,50,14 - RADIOBUTTON "Hexadecimal",CHK_HEX,182,49,57,10 - RADIOBUTTON "Decimal",CHK_DECIMAL,182,62,41,10 - LTEXT "Value Name:",IDC_STATIC,7,7,42,8 - LTEXT "Value Data:",IDC_STATIC,7,37,38,8 - GROUPBOX "Base",GRP_BASE,174,37,71,38 - GROUPBOX "Save Value as:",GRP_TYPE,7,67,160,29 -END - -IDD_WATCH_DIAG DIALOGEX 0, 0, 414, 190 -STYLE DS_SETFONT | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CLIPCHILDREN | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME -CAPTION "Watched Database Variables" -MENU IDR_WATCHWINDOWMENU -FONT 8, "MS Shell Dlg", 0, 0, 0x0 -BEGIN - CONTROL "List1",IDC_VARS,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_SORTDESCENDING | LVS_SHAREIMAGELISTS | LVS_AUTOARRANGE | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,0,0,414,190 -END - -IDD_COPY_MOD DIALOGEX 0, 0, 186, 67 -STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "Copy module to contact" -FONT 8, "MS Shell Dlg", 0, 0, 0x0 -BEGIN - COMBOBOX IDC_CONTACTS,7,17,172,99,CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL | WS_TABSTOP - CONTROL "Copy to all contacts (Includes Settings)",CHK_COPY2ALL, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,35,172,10 - DEFPUSHBUTTON "OK",IDOK,29,49,50,14 - PUSHBUTTON "Cancel",IDCANCEL,107,49,50,14 - LTEXT "Contact to copy module and settings to",IDC_INFOTEXT,7,6,124,8 -END - -IDD_IMPORT DIALOGEX 0, 0, 268, 170 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "Import Module/Settings" -FONT 8, "MS Shell Dlg", 0, 0, 0x0 -BEGIN - EDITTEXT IDC_TEXT,7,18,254,124,ES_MULTILINE | ES_WANTRETURN | WS_VSCROLL | WS_HSCROLL - DEFPUSHBUTTON "Import",IDOK,153,149,50,14 - PUSHBUTTON "Cancel",IDCANCEL,211,149,50,14 - PUSHBUTTON "Insert &CR/LF",IDC_CRLF,20,149,58,14 - LTEXT "Paste the Settings to import here.",IDC_STATIC,7,7,105,8 -END - -IDD_MAIN DIALOGEX 0, 0, 408, 225 -STYLE DS_ABSALIGN | DS_SETFONT | DS_FIXEDSYS | DS_CENTER | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CLIPCHILDREN | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME -CAPTION "DBEditor++" -MENU IDR_MAINMENU -FONT 8, "MS Shell Dlg", 0, 0, 0x0 -BEGIN - CONTROL "Tree1",IDC_MODULES,"SysTreeView32",TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT | TVS_EDITLABELS | TVS_DISABLEDRAGDROP | TVS_SHOWSELALWAYS | WS_BORDER | WS_HSCROLL | WS_TABSTOP,0,3,102,222 - CONTROL "List1",IDC_SETTINGS,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_SORTASCENDING | LVS_SHAREIMAGELISTS | WS_BORDER | WS_TABSTOP,103,3,305,222 - CONTROL "",IDC_SPLITTER,"Static",SS_ENHMETAFILE,102,3,1,222 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_ADD_MODULE, DIALOG - BEGIN - LEFTMARGIN, 7 - TOPMARGIN, 7 - BOTTOMMARGIN, 63 - END - - IDD_EDIT_SETTING, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 245 - VERTGUIDE, 166 - VERTGUIDE, 174 - VERTGUIDE, 182 - TOPMARGIN, 7 - BOTTOMMARGIN, 116 - HORZGUIDE, 37 - HORZGUIDE, 49 - HORZGUIDE, 67 - HORZGUIDE, 75 - HORZGUIDE, 81 - END - - IDD_COPY_MOD, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 179 - TOPMARGIN, 7 - BOTTOMMARGIN, 63 - END - - IDD_IMPORT, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 261 - TOPMARGIN, 7 - BOTTOMMARGIN, 163 - END - - IDD_MAIN, DIALOG - BEGIN - VERTGUIDE, 102 - VERTGUIDE, 103 - TOPMARGIN, 3 - END -END -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -ICO_REGEDIT ICON "res\\Icon_1.ico" -ICO_DBE_BUTT ICON "res\\dbepp.ico" -ICO_REGUSER ICON "res\\usermenu.ico" -ICO_STRING ICON "res\\Icon_14.ico" -ICO_CONTACTS ICON "res\\Contacts.ico" -ICO_BINARY ICON "res\\Icon_15.ico" -ICO_DWORD ICON "res\\Icon_16.ico" -ICO_BYTE ICON "res\\Icon_17.ico" -ICO_WORD ICON "res\\Icon_18.ico" -ICO_OFFLINE ICON "res\\offline2.ico" -ICO_UNICODE ICON "res\\unicode.ico" -ICO_HANDLE ICON "res\\handle.ico" - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Menu -// - -IDR_MAINMENU MENU -BEGIN - POPUP "&Main" - BEGIN - MENUITEM "&Refresh Modules", MENU_REFRESH_MODS - MENUITEM "Refresh &Settings", MENU_REFRESH_SETS - MENUITEM SEPARATOR - MENUITEM "E&xit", MENU_EXIT - END - POPUP "&Actions" - BEGIN - MENUITEM "&Search and Replace", MENU_FINDANDREPLACE - MENUITEM SEPARATOR - MENUITEM "&Delete Module", MENU_DELETE - END - POPUP "&Watches" - BEGIN - MENUITEM "&View all", MENU_VIEW_WATCHES - MENUITEM "&Delete all", MENU_REMALL_WATCHES - END - POPUP "&Export" - BEGIN - MENUITEM "Entire &Database", MENU_EXPORTDB - MENUITEM "All &Settings", MENU_EXPORTMODULE - MENUITEM "All &Contacts", MENU_EXPORTCONTACT - END - POPUP "&Import" - BEGIN - MENUITEM "From a &file", MENU_IMPORTFROMFILE - MENUITEM "From pasted &text", MENU_IMPORTFROMTEXT - END - POPUP "&Options" - BEGIN - MENUITEM "&Sort by protocol", MENU_SORT_ORDER - MENUITEM SEPARATOR - MENUITEM "Show &All", MENU_FILTER_ALL - MENUITEM "Show only &Loaded", MENU_FILTER_LOADED - MENUITEM "Show only &Unloaded", MENU_FILTER_UNLOADED - MENUITEM SEPARATOR - MENUITEM "Edit &Bytes in Hex", MENU_BYTE_HEX - MENUITEM "Edit &Words in Hex", MENU_WORD_HEX - MENUITEM "Edit &Dwords in Hex", MENU_DWORD_HEX - MENUITEM SEPARATOR - MENUITEM "&Restore position", MENU_SAVE_POSITION - MENUITEM "&Open Options", MENU_OPEN_OPTIONS - END -END - -IDR_CONTEXTMENU MENU -BEGIN - POPUP "Item context" - BEGIN - MENUITEM "&Edit / Rename", MENU_EDIT_SET - MENUITEM SEPARATOR - POPUP "NEW" - BEGIN - MENUITEM "&Byte", MENU_ADD_BYTE - MENUITEM "&Word", MENU_ADD_WORD - MENUITEM "&Dword", MENU_ADD_DWORD - MENUITEM "&String", MENU_ADD_STRING - MENUITEM "&Unicode", MENU_ADD_UNICODE - MENUITEM "BL&OB", MENU_ADD_BLOB - END - POPUP "&Convert to" - BEGIN - MENUITEM "&Byte", MENU_CHANGE2BYTE - MENUITEM "&Word", MENU_CHANGE2WORD - MENUITEM "&Dword", MENU_CHANGE2DWORD - MENUITEM "&String", MENU_CHANGE2STRING - MENUITEM "&Unicode", MENU_CHANGE2UNICODE - END - POPUP "Encyption" - BEGIN - MENUITEM "View Decrypted String", MENU_VIEWDECRYPT - MENUITEM "View Encrypted String", MENU_VIEWENCRYPT - MENUITEM "Decrypt String", MENU_DECRYPT - MENUITEM "Encrypt String", MENU_ENCRYPT - END - MENUITEM SEPARATOR - MENUITEM "&Watch", MENU_WATCH_ITEM - MENUITEM "&Delete", MENU_DELETE_SET - END - POPUP "Null Mod context" - BEGIN - MENUITEM "&Rename", MENU_RENAME_MOD - MENUITEM "Copy To Contact", MENU_COPY_MOD - MENUITEM SEPARATOR - MENUITEM "Export Module", MENU_EXPORTMODULE - MENUITEM "Add To Known Modules", MENU_ADDKNOWN - MENUITEM SEPARATOR - MENUITEM "&Watch", MENU_WATCH_ITEM - MENUITEM "&Delete", MENU_DELETE_MOD - END - POPUP "Contact menu" - BEGIN - MENUITEM "&Clone", MENU_CLONE_CONTACT - MENUITEM "&Delete", MENU_DELETE_CONTACT - MENUITEM SEPARATOR - MENUITEM "Export Contact", MENU_EXPORTCONTACT - POPUP "Import Settings" - BEGIN - MENUITEM "From a file", MENU_IMPORTFROMFILE - MENUITEM "From pasted text", MENU_IMPORTFROMTEXT - END - MENUITEM SEPARATOR - MENUITEM "&Add Module", MENU_ADD_MODULE - END - POPUP "NULL contact menu" - BEGIN - MENUITEM "&Add Module", MENU_ADD_MODULE - MENUITEM "Export Settings", MENU_EXPORTCONTACT - POPUP "Import Settings" - BEGIN - MENUITEM "From a file", MENU_IMPORTFROMFILE - MENUITEM "From pasted text", MENU_IMPORTFROMTEXT - END - END - POPUP "Contacts menu" - BEGIN - MENUITEM "Export Contacts", MENU_EXPORTCONTACT - POPUP "Import Contacts" - BEGIN - MENUITEM "From a file", MENU_IMPORTFROMFILE - MENUITEM "From pasted text", MENU_IMPORTFROMTEXT - END - END - POPUP "Contact Mod context" - BEGIN - MENUITEM "&Rename", MENU_RENAME_MOD - MENUITEM "Copy To Contact", MENU_COPY_MOD - MENUITEM SEPARATOR - MENUITEM "Export Module", MENU_EXPORTMODULE - MENUITEM "Export Module from all contacts", MENU_EXPORTDB - MENUITEM "Add To Known Modules", MENU_ADDKNOWN - MENUITEM SEPARATOR - MENUITEM "&Watch", MENU_WATCH_ITEM - MENUITEM "&Delete", MENU_DELETE_MOD - END - POPUP "new item" - BEGIN - POPUP "NEW" - BEGIN - MENUITEM "&Byte", MENU_ADD_BYTE - MENUITEM "&Word", MENU_ADD_WORD - MENUITEM "&Dword", MENU_ADD_DWORD - MENUITEM "&String", MENU_ADD_STRING - MENUITEM "&Unicode", MENU_ADD_UNICODE - MENUITEM "BL&OB", MENU_ADD_BLOB - END - END -END - -IDR_WATCHWINDOWMENU MENU -BEGIN - POPUP "Watch Window" - BEGIN - MENUITEM "Reload Watch List", MENU_REFRESH - MENUITEM "&Delete all", MENU_REMALL_WATCHES - MENUITEM SEPARATOR - MENUITEM "E&xit", MENU_EXIT - END -END - -#endif // Ŕíăëčéńęčé (Ŕâńňđŕëč˙) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/plugins/Svc_dbepp/settinglist.cpp b/plugins/Svc_dbepp/settinglist.cpp deleted file mode 100644 index 5fff4fed21..0000000000 --- a/plugins/Svc_dbepp/settinglist.cpp +++ /dev/null @@ -1,1261 +0,0 @@ -#include "headers.h" - -int UOS; - -void setupSettingsList(HWND hwnd2List) -{ - LVCOLUMN sLC; - - ListView_SetUnicodeFormat(hwnd2List, UOS); - - sLC.fmt = LVCFMT_LEFT; - ListView_SetExtendedListViewStyle(hwnd2List, 32|LVS_EX_SUBITEMIMAGES); //LVS_EX_FULLROWSELECT - sLC.mask = LVCF_FMT | LVCF_TEXT | LVCF_SUBITEM | LVCF_WIDTH; - - sLC.pszText = Translate("Name"); - sLC.cx = DBGetContactSettingWord(NULL, modname, "Column0width", 145); - ListView_InsertColumn(hwnd2List,0,&sLC); - sLC.pszText = Translate("Data"); - sLC.cx = DBGetContactSettingWord(NULL, modname, "Column1width", 145); - ListView_InsertColumn(hwnd2List,1,&sLC); - sLC.pszText = Translate("Type"); - sLC.cx = DBGetContactSettingWord(NULL, modname, "Column2width", 60); - ListView_InsertColumn(hwnd2List,2,&sLC); - sLC.pszText = Translate("Size"); - sLC.cx = DBGetContactSettingWord(NULL, modname, "Column3width", 80); - ListView_InsertColumn(hwnd2List,3,&sLC); -} - - -void saveListSettings(HWND hwnd2List) -{ - int i; - LVCOLUMN sLC = {0}; - char tmp[33]; tmp[32] = 0; - - sLC.mask = LVCF_WIDTH; - - for (i=0; i <= 3; i++) - if (ListView_GetColumn(hwnd2List,i,&sLC)) - { - mir_snprintf(tmp, SIZEOF(tmp), "Column%dwidth", i); - DBWriteContactSettingWord(NULL, modname, tmp, (WORD)sLC.cx); - } - -} - - -void ClearListview(HWND hwnd2Settings) -{ - SettingListInfo *info = (SettingListInfo*)GetWindowLongPtr(hwnd2Settings,GWLP_USERDATA); - if (info && ListView_GetItemCount(hwnd2Settings)) - { - mir_free(info->module); - if (info->hwnd2Edit) - { - SendMessage(info->hwnd2Edit,WM_COMMAND,MAKEWPARAM(IDCANCEL,0),0); - info->hwnd2Edit = NULL; - } - mir_free(info); - SetWindowLongPtr(hwnd2Settings,GWLP_USERDATA, 0); - } - ListView_DeleteAllItems(hwnd2Settings); -} - -void DeleteSettingsFromList(HWND hSettings, HANDLE hContact, char *module, char *setting) -{ - int count = ListView_GetSelectedCount(hSettings); - - if (!count) return; - else - if (count == 1) - { - DBDeleteContactSetting(hContact,module,setting); - } - else - { - int items = ListView_GetItemCount(hSettings); - int i = 0; - char text[256]; - - while(i")); - ListView_SetItemText(hwnd2Settings,index,2,Translate("UNICODE")); - ListView_SetItemText(hwnd2Settings,index,3,Translate("")); - } - else - ListView_DeleteItem(hwnd2Settings,index); - - DBFreeVariant(&dbv); - mir_free(data); -} - -void PopulateSettings(HWND hwnd2Settings, HANDLE hContact, char* module) -{ - SettingListInfo* info = (SettingListInfo*)mir_calloc(sizeof(SettingListInfo)); - LVITEM lvItem; - - struct ModSetLinkLinkItem *setting; - ModuleSettingLL setlist; - if (!EnumSettings(hContact,module,&setlist)) { msg(Translate("Error Loading Setting List"),modFullname); mir_free(info); return;} - - // clear any settings that may be there... - ClearListview(hwnd2Settings); - - info->hContact = hContact; - info->module = mir_tstrdup(module); - SetWindowLongPtr(hwnd2Settings,GWLP_USERDATA, (LONG)info); - - // icons - if (himl2) ListView_SetImageList(hwnd2Settings, himl2, LVSIL_SMALL); - - lvItem.mask = LVIF_TEXT; - lvItem.iItem = 0; - lvItem.iSubItem = 0; - setting = setlist.first; - - while (setting) - { - lvItem.pszText = setting->name; - additem(hwnd2Settings,hContact,module, setting->name, ListView_InsertItem(hwnd2Settings,&lvItem)); - setting = (struct ModSetLinkLinkItem *)setting->next; - } - - FreeModuleSettingLL(&setlist); -} - - -void SelectSetting(char* setting) -{ - LVITEM lvItem; - LVFINDINFO lvfi; - HWND hwnd2Settings = GetDlgItem(hwnd2mainWindow,IDC_SETTINGS); - - lvfi.flags = LVFI_STRING; - lvfi.psz = setting; - lvfi.vkDirection = VK_DOWN; - - lvItem.mask = LVIF_TEXT; - lvItem.iItem = ListView_FindItem(hwnd2Settings,-1,&lvfi); - if (lvItem.iItem != -1) - { - lvItem.mask = LVIF_STATE; - lvItem.state = LVIS_SELECTED | LVIS_FOCUSED; - lvItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED; - ListView_SetItem(hwnd2Settings,&lvItem); - } -} - -void settingChanged(HWND hwnd2Settings, HANDLE hContact, char* module, char* setting) -{ - LVITEM lvItem; - LVFINDINFO lvfi; - - lvfi.flags = LVFI_STRING; - lvfi.psz = setting; - lvfi.vkDirection = VK_DOWN; - - lvItem.mask = LVIF_TEXT|LVIF_IMAGE; - lvItem.iItem = ListView_FindItem(hwnd2Settings,-1,&lvfi); - lvItem.iSubItem = 0; - - if (lvItem.iItem == -1) - { - lvItem.iItem = 0; - lvItem.pszText = setting; - lvItem.cchTextMax = mir_strlen(setting); - lvItem.iItem = ListView_InsertItem(hwnd2Settings,&lvItem); - } - additem(hwnd2Settings,hContact,module, setting,lvItem.iItem); -} - -static WNDPROC SettingLabelEditSubClass; - -typedef struct { - HANDLE hContact; - char module[256]; - char setting[256]; - int item; - int subitem; - HWND hwnd; - int unicode; -} EditLabelInfoStruct; - -void writeStandardTextfromLabel(EditLabelInfoStruct* info, char* value, WCHAR *wc, int type) -{ - if (type != DBVT_ASCIIZ && type != DBVT_UTF8) - DBDeleteContactSetting(info->hContact,info->module,info->setting); - if (type == DBVT_UTF8 && wc) - { - DBWriteContactSettingWString(info->hContact,info->module,info->setting,wc); - mir_free(wc); - } - else - DBWriteContactSettingString(info->hContact,info->module,info->setting,value); - -} - -static LRESULT CALLBACK SettingLabelEditSubClassProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam) -{ - EditLabelInfoStruct* info = (EditLabelInfoStruct*)GetWindowLongPtr(hwnd,GWLP_USERDATA); - switch(msg) { - case WM_KEYDOWN: - switch (wParam) - { - case VK_RETURN: - if (GetKeyState(VK_CONTROL)&0x8000) // ctrl is pressed - break; - SendMessage(hwnd,WM_COMMAND,MAKEWPARAM(IDOK,0),0); - return 0; - case VK_ESCAPE: - SendMessage(hwnd,WM_COMMAND,MAKEWPARAM(IDCANCEL,0),0); - return 0; - } - break; - case WM_USER: - SetWindowLongPtr(hwnd,GWLP_USERDATA,lParam); - SetFocus(hwnd); - SendMessage(hwnd, WM_SETFONT, SendMessage(GetParent(hwnd), WM_GETFONT, 0, 0), 1); - info = ((EditLabelInfoStruct*)lParam); - if (info->subitem) - SendMessage(hwnd, EM_LIMITTEXT, (WPARAM)65535, 0); - else - SendMessage(hwnd, EM_LIMITTEXT, (WPARAM)255, 0); - SendMessage(hwnd, EM_SETSEL,0,-1); - break; - case WM_PAINT: - break; - case WM_COMMAND: - switch (LOWORD(wParam)) - { - case IDOK: - { - int len = GetWindowTextLength(hwnd)+1; - char *value = (char*)_alloca(len); - WCHAR *wc = NULL; - DBVARIANT dbv = {0}; - - GetWindowText(hwnd,value,len); - - if (info->unicode) - wc = mir_a2u(value); - - if (len <= 1 || GetSetting(info->hContact,info->module,info->setting,&dbv)) - { - SendMessage(hwnd,WM_COMMAND,MAKEWPARAM(IDCANCEL,0),0); - return 0; - } - - switch (info->subitem) - { - case 0:// setting name - if (!mir_strcmp(info->setting,value) || mir_strlen(value)>255) - { - DBFreeVariant(&dbv); - SendMessage(hwnd,WM_COMMAND,MAKEWPARAM(IDCANCEL,0),0); - return 0; - } - switch (dbv.type) - { - case DBVT_UTF8: - DBWriteContactSettingStringUtf(info->hContact,info->module,value,dbv.pszVal); - break; - case DBVT_ASCIIZ: - DBWriteContactSettingString(info->hContact,info->module,value,dbv.pszVal); - break; - case DBVT_BYTE: - DBWriteContactSettingByte(info->hContact,info->module,value,dbv.bVal); - break; - case DBVT_WORD: - DBWriteContactSettingWord(info->hContact,info->module,value,dbv.wVal); - break; - case DBVT_DWORD: - DBWriteContactSettingDword(info->hContact,info->module,value,dbv.dVal); - break; - case DBVT_BLOB: - DBWriteContactSettingBlob(info->hContact,info->module,value,dbv.pbVal,dbv.cpbVal); - break; - } - DBDeleteContactSetting(info->hContact,info->module,info->setting); - { - LVFINDINFO lvfi; - int item; - - lvfi.flags = LVFI_STRING; - lvfi.psz = info->setting; - lvfi.vkDirection = VK_DOWN; - - item = ListView_FindItem(info->hwnd,-1,&lvfi); - ListView_DeleteItem(info->hwnd,item); - } - break; - case 1: // value - { - int val; - int i = 0; - - if (dbv.type == DBVT_BLOB) - { - WriteBlobFromString(info->hContact,info->module,info->setting,value,len); - break; - } - - switch (value[0]) - { - case 'b': - case 'B': - if (value[1] == '0' && (value[2] == 'x' || value[2] == 'X')) - sscanf(&value[3],"%x",&val); - else if (value[1] >= '0' && value[1] <= '9') - { - val = atoi(&value[1]); - if (dbv.type == DBVT_ASCIIZ || dbv.type == DBVT_UTF8) - DBDeleteContactSetting(info->hContact,info->module,info->setting); - - DBWriteContactSettingByte(info->hContact,info->module,info->setting,(BYTE)val); - } - else - writeStandardTextfromLabel(info, value, wc, dbv.type); - break; - case 'w': - case 'W': - if (value[1] == '0' && (value[2] == 'x' || value[2] == 'X')) - sscanf(&value[3],"%x",&val); - else if (value[1] >= '0' && value[1] <= '9') - { - val = atoi(&value[1]); - if (dbv.type == DBVT_ASCIIZ || dbv.type == DBVT_UTF8) - DBDeleteContactSetting(info->hContact,info->module,info->setting); - DBWriteContactSettingWord(info->hContact,info->module,info->setting,(WORD)val); - } - else - writeStandardTextfromLabel(info, value, wc, dbv.type); - break; - case 'd': - case 'D': - if (value[1] == '0' && (value[2] == 'x' || value[2] == 'X')) - sscanf(&value[3],"%x",&val); - else if (value[1] >= '0' && value[1] <= '9') - { - val = atoi(&value[1]); - if (dbv.type == DBVT_ASCIIZ || dbv.type == DBVT_UTF8) - DBDeleteContactSetting(info->hContact,info->module,info->setting); - DBWriteContactSettingDword(info->hContact,info->module,info->setting,val); - } - else - writeStandardTextfromLabel(info, value, wc, dbv.type); - break; - case '0': - i=1; - case 'x': - case 'X': - if (value[i] == 'x' || value[i] == 'X') - { - - sscanf(&value[i+1],"%x",&val); - switch (dbv.type) - { - case DBVT_UTF8: - case DBVT_ASCIIZ: - writeStandardTextfromLabel(info, value, wc, dbv.type); - break; - case DBVT_BYTE: - DBWriteContactSettingByte(info->hContact,info->module,info->setting,(BYTE)val); - break; - case DBVT_WORD: - DBWriteContactSettingWord(info->hContact,info->module,info->setting,(WORD)val); - break; - case DBVT_DWORD: - DBWriteContactSettingDword(info->hContact,info->module,info->setting,(DWORD)val); - break; - } - } - else - { - val = atoi(value); - switch (dbv.type) - { - case DBVT_ASCIIZ: - case DBVT_UTF8: - writeStandardTextfromLabel(info, value, wc, dbv.type); - break; - case DBVT_BYTE: - DBWriteContactSettingByte(info->hContact,info->module,info->setting,(BYTE)val); - break; - case DBVT_WORD: - DBWriteContactSettingWord(info->hContact,info->module,info->setting,(WORD)val); - break; - case DBVT_DWORD: - DBWriteContactSettingDword(info->hContact,info->module,info->setting,(DWORD)val); - break; - } - } - break; - case '\"': - case '\'': - { - int nlen = mir_strlen(value); - int sh = 0; - if (nlen > 3) - { - if (value[nlen-1] == value[0]) - { - value[nlen-1] = '\0'; - sh = 1; - } - } - writeStandardTextfromLabel(info, &value[sh], wc, dbv.type); - } - break; - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case '-': - val = atoi(value); - switch (dbv.type) - { - case DBVT_ASCIIZ: - case DBVT_UTF8: - writeStandardTextfromLabel(info, value, wc, dbv.type); - break; - case DBVT_BYTE: - DBWriteContactSettingByte(info->hContact,info->module,info->setting,(BYTE)val); - break; - case DBVT_WORD: - DBWriteContactSettingWord(info->hContact,info->module,info->setting,(WORD)val); - break; - case DBVT_DWORD: - DBWriteContactSettingDword(info->hContact,info->module,info->setting,(DWORD)val); - break; - } - break; - default: - writeStandardTextfromLabel(info, value, wc, dbv.type); - break; - } // switch (value[0]) - } - break; // case 1: - } - DBFreeVariant(&dbv); - } // fall through - case IDCANCEL: - { - SettingListInfo *sli = (SettingListInfo*)GetWindowLongPtr(info->hwnd,GWLP_USERDATA); - - if (sli && sli->hwnd2Edit==hwnd) - sli->hwnd2Edit = NULL; - - mir_free(info); - DestroyWindow(hwnd); - } - return 0; - } - break; // wm_command - case WM_GETDLGCODE: - return DLGC_WANTALLKEYS; - } - if (UOS) - return CallWindowProcW(SettingLabelEditSubClass,hwnd,msg,wParam,lParam); - else - return CallWindowProc(SettingLabelEditSubClass,hwnd,msg,wParam,lParam); -} - - -void EditLabel(HWND hwnd2List, int item, int subitem) -{ - RECT rc; - LVITEM lvi; - char setting[256], value[16] = {0}; - DBVARIANT dbv; - SettingListInfo* info = (SettingListInfo*)GetWindowLongPtr(hwnd2List,GWLP_USERDATA); - EditLabelInfoStruct *data = (EditLabelInfoStruct*)mir_calloc(sizeof(EditLabelInfoStruct)); - if (!data || !info) return; - if (info->hwnd2Edit) - { - SendMessage(info->hwnd2Edit,WM_COMMAND,MAKEWPARAM(IDCANCEL,0),0); // ignore the new value of the last edit - info->hwnd2Edit = NULL; - } - lvi.mask = LVIF_TEXT; - lvi.iItem = item; - lvi.iSubItem = 0; - lvi.pszText = setting; - lvi.cchTextMax = 256; - - if (!ListView_GetItem(hwnd2List, &lvi) || - !ListView_GetSubItemRect - (hwnd2List,item,subitem,LVIR_LABEL,&rc) || - GetSetting(info->hContact,info->module,setting,&dbv)) - { - mir_free(data); - return; - } - - data->hContact = info->hContact; - strcpy(data->module, info->module); - strcpy(data->setting, setting); - data->item = item; - data->subitem = subitem; - data->hwnd = hwnd2List; - - // fix size for long strings - - switch (dbv.type) - { - case DBVT_UTF8: - if (subitem && UOS) - { - int len = mir_strlen(dbv.pszVal)+1; - WCHAR *wc = (WCHAR*)_alloca(len*sizeof(WCHAR)); - MultiByteToWideChar(CP_UTF8, 0, dbv.pszVal, -1, wc, len); - data->unicode = 1; - info->hwnd2Edit = CreateWindowW(L"EDIT",wc,WS_BORDER|WS_VISIBLE|WS_CHILD|WS_VSCROLL|ES_MULTILINE|ES_AUTOHSCROLL, rc.left,rc.top,(int)((rc.right - rc.left)*1.5),(rc.bottom - rc.top)*3,hwnd2List, 0,hInst,0); - break; - } - // fall through - case DBVT_ASCIIZ: - if (subitem) { - // convert from UTF8 - info->hwnd2Edit = CreateWindow("EDIT",dbv.pszVal,WS_BORDER|WS_VISIBLE|WS_CHILD|WS_VSCROLL|ES_MULTILINE|ES_AUTOHSCROLL, rc.left,rc.top,(int)((rc.right - rc.left)*1.5),(rc.bottom - rc.top)*3,hwnd2List, 0,hInst,0); - } - else - info->hwnd2Edit = CreateWindow("EDIT",setting,WS_BORDER|WS_VISIBLE|WS_CHILD|ES_AUTOHSCROLL, rc.left,rc.top,(rc.right - rc.left),(rc.bottom - rc.top),hwnd2List, 0,hInst,0); - break; - case DBVT_BYTE: - if (Hex&HEX_BYTE) - mir_snprintf(value, SIZEOF(value), "0x%02X", dbv.bVal); - else - itoa(dbv.bVal,value,10); - info->hwnd2Edit = CreateWindow("EDIT",!subitem?setting:value,WS_BORDER|WS_VISIBLE|WS_CHILD|ES_AUTOHSCROLL, rc.left,rc.top,(rc.right - rc.left),(rc.bottom - rc.top),hwnd2List, 0,hInst,0); - break; - case DBVT_WORD: - if (Hex&HEX_WORD) - mir_snprintf(value, SIZEOF(value), "0x%04X", dbv.wVal); - else - itoa(dbv.wVal,value,10); - info->hwnd2Edit = CreateWindow("EDIT",!subitem?setting:value,WS_BORDER|WS_VISIBLE|WS_CHILD|ES_AUTOHSCROLL, rc.left,rc.top,(rc.right - rc.left),(rc.bottom - rc.top),hwnd2List, 0,hInst,0); - break; - case DBVT_DWORD: - if (Hex&HEX_DWORD) - mir_snprintf(value, SIZEOF(value), "0x%08X", dbv.dVal); - else - itoa(dbv.dVal,value,10); - info->hwnd2Edit = CreateWindow("EDIT",!subitem?setting:value,WS_BORDER|WS_VISIBLE|WS_CHILD|ES_AUTOHSCROLL, rc.left,rc.top,(rc.right - rc.left),(rc.bottom - rc.top),hwnd2List, 0,hInst,0); - break; - case DBVT_BLOB: - if (!subitem) - info->hwnd2Edit = CreateWindow("EDIT",setting,WS_BORDER|WS_VISIBLE|WS_CHILD|ES_AUTOHSCROLL, rc.left,rc.top,(rc.right - rc.left),(rc.bottom - rc.top),hwnd2List, 0,hInst,0); - else - { - int j; - char tmp[16]; - char *data = (char*)_alloca(3*(dbv.cpbVal+1)+10); - - if (!data) {msg(Translate("Couldnt allocate enough memory!"), modFullname); return;} - data[0] = '\0'; - - for(j=0; jhwnd2Edit = CreateWindow("EDIT",data,WS_BORDER|WS_VISIBLE|WS_CHILD|WS_VSCROLL|ES_MULTILINE, rc.left,rc.top,(int)((rc.right - rc.left)*1.5),(rc.bottom - rc.top)*3,hwnd2List,0,hInst,0); - } - break; - default: return; - } - - DBFreeVariant(&dbv); - - if (UOS) - SettingLabelEditSubClass=(WNDPROC)SetWindowLongPtrW(info->hwnd2Edit,GWLP_WNDPROC,(LONG)SettingLabelEditSubClassProc); - else - SettingLabelEditSubClass=(WNDPROC)SetWindowLongPtr(info->hwnd2Edit,GWLP_WNDPROC,(LONG)SettingLabelEditSubClassProc); - - SendMessage(info->hwnd2Edit,WM_USER,0,(LPARAM)data); -} - -static int test; -void SettingsListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam); -static int lastColumn = -1; - -struct SettingsSortParams{ - HWND hList; - int column; -}; - -INT_PTR CALLBACK SettingsCompare(LPARAM lParam1, LPARAM lParam2, LPARAM myParam) -{ - SettingsSortParams params = *(SettingsSortParams *) myParam; - const int maxSize = 1024; - TCHAR text1[maxSize]; - TCHAR text2[maxSize]; - ListView_GetItemText(params.hList, (int) lParam1, params.column, text1, maxSize); - ListView_GetItemText(params.hList, (int) lParam2, params.column, text2, maxSize); - - int res = _tcsicmp(text1, text2); - res = (params.column == lastColumn) ? -res : res; - return res; -} - -void SettingsListWM_NOTIFY(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam) -{ - switch(((NMHDR*)lParam)->code) - { - case NM_CLICK: - { - SettingListInfo* info = (SettingListInfo*)GetWindowLongPtr(GetDlgItem(hwnd,IDC_SETTINGS),GWLP_USERDATA); - - LVHITTESTINFO hti; - hti.pt=((NMLISTVIEW*)lParam)->ptAction; - if (DBGetContactSettingByte(NULL,modname,"DontAllowInLineEdit",0) || !IsWinVer2000Plus()) /* fix for TioDuke and win98 */ - break; - if (info && ListView_SubItemHitTest(GetDlgItem(hwnd,IDC_SETTINGS),&hti) >-1) - { - if (hti.iSubItem < 2 && hti.flags != LVHT_ONITEMICON) - { - if (info->selectedItem == hti.iItem) - EditLabel(GetDlgItem(hwnd,IDC_SETTINGS),hti.iItem,hti.iSubItem); - else if (info->hwnd2Edit) - { - SendMessage(info->hwnd2Edit,WM_COMMAND,MAKEWPARAM(IDOK,0),0); - info->hwnd2Edit = NULL; - info->selectedItem = hti.iItem; - } - else info->selectedItem = hti.iItem; - } - else - { - if (info->hwnd2Edit) - { - SendMessage(info->hwnd2Edit,WM_COMMAND,MAKEWPARAM(IDOK,0),0); - info->hwnd2Edit = NULL; - } - info->selectedItem = hti.iItem; - } - } - else if (info && info->hwnd2Edit) - { - SendMessage(info->hwnd2Edit,WM_COMMAND,MAKEWPARAM(IDOK,0),0); - info->hwnd2Edit = NULL; - info->selectedItem = 0; - } - break; - } - - case NM_DBLCLK: - { - SettingListInfo* info = (SettingListInfo*)GetWindowLongPtr(GetDlgItem(hwnd,IDC_SETTINGS),GWLP_USERDATA); - - LVHITTESTINFO hti; - - hti.pt=((NMLISTVIEW*)lParam)->ptAction; - if (info && ListView_SubItemHitTest(GetDlgItem(hwnd,IDC_SETTINGS),&hti) >-1) - { - if ((hti.iSubItem > 1 || hti.flags == LVHT_ONITEMICON) || (DBGetContactSettingByte(NULL,modname,"DontAllowInLineEdit",0) || !IsWinVer2000Plus()/* fix for TioDuke and win98 */ )) - { - char setting[256]; - SendMessage(info->hwnd2Edit,WM_COMMAND,MAKEWPARAM(IDOK,0),0); - info->hwnd2Edit = NULL; - ListView_GetItemText(GetDlgItem(hwnd, IDC_SETTINGS), hti.iItem, 0, setting, 256); - editSetting(info->hContact,info->module, setting); - } - else EditLabel(GetDlgItem(hwnd,IDC_SETTINGS),hti.iItem,hti.iSubItem); - } - break; - } - - case NM_RCLICK: - SettingsListRightClick(hwnd,wParam,lParam); - break; - - case LVN_COLUMNCLICK: - { - LPNMLISTVIEW lv = (LPNMLISTVIEW) lParam; - SettingsSortParams params = {0}; - params.hList = GetDlgItem(hwnd, IDC_SETTINGS); - params.column = lv->iSubItem; - ListView_SortItemsEx(params.hList, SettingsCompare, (LPARAM) ¶ms); - lastColumn = (params.column == lastColumn) ? -1 : params.column; - break; - } - - } // switch(((NMHDR*)lParam)->code) -} - -void SettingsListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam) // hwnd here is to the main window, NOT the listview -{ - HWND hSettings = GetDlgItem(hwnd,IDC_SETTINGS); - SettingListInfo* info = (SettingListInfo*)GetWindowLongPtr(hSettings,GWLP_USERDATA); - char setting[256], *module; - HANDLE hContact; - LVHITTESTINFO hti; - POINT pt; - HMENU hMenu, hSubMenu; - - if (!info) return; - module = info->module; - hContact = info->hContact; - - hti.pt=((NMLISTVIEW*)lParam)->ptAction; - if (ListView_SubItemHitTest(hSettings,&hti) == -1) - { - // nowhere.. new item menu - GetCursorPos(&pt); - hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_CONTEXTMENU)); - hSubMenu = GetSubMenu(hMenu, 6); - TranslateMenu(hSubMenu); - - if (!UDB) - RemoveMenu(hSubMenu, MENU_ADD_UNICODE, MF_BYCOMMAND); - - switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwnd, NULL)) - { - case MENU_ADD_BYTE: - { - struct DBsetting *dbsetting = (struct DBsetting *)mir_alloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc - DBVARIANT dbv = {0}; // freed in the dialog - dbv.type = DBVT_BYTE; - dbsetting->dbv = dbv; - dbsetting->hContact = hContact; - dbsetting->module = mir_tstrdup(module); - dbsetting->setting = mir_tstrdup(""); - CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); - } - break; - case MENU_ADD_WORD: - { - struct DBsetting *dbsetting = (struct DBsetting *)mir_alloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc - DBVARIANT dbv = {0}; // freed in the dialog - dbv.type = DBVT_WORD; - dbsetting->dbv = dbv; - dbsetting->hContact = hContact; - dbsetting->module = mir_tstrdup(module); - dbsetting->setting = mir_tstrdup(""); - CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); - } - break; - case MENU_ADD_DWORD: - { - struct DBsetting *dbsetting = (struct DBsetting *)mir_alloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc - DBVARIANT dbv = {0}; // freed in the dialog - dbv.type = DBVT_DWORD; - dbsetting->dbv = dbv; - dbsetting->hContact = hContact; - dbsetting->module = mir_tstrdup(module); - dbsetting->setting = mir_tstrdup(""); - CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); - } - break; - case MENU_ADD_STRING: - { - struct DBsetting *dbsetting = (struct DBsetting *)mir_alloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc - DBVARIANT dbv = {0}; // freed in the dialog - dbv.type = DBVT_ASCIIZ; - dbsetting->dbv = dbv; - dbsetting->hContact = hContact; - dbsetting->module = mir_tstrdup(module); - dbsetting->setting = mir_tstrdup(""); - CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); - } - break; - case MENU_ADD_UNICODE: - if (UDB) - { - struct DBsetting *dbsetting = (struct DBsetting *)mir_alloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc - DBVARIANT dbv = {0}; // freed in the dialog - dbv.type = DBVT_UTF8; - dbsetting->dbv = dbv; - dbsetting->hContact = hContact; - dbsetting->module = mir_tstrdup(module); - dbsetting->setting = mir_tstrdup(""); - if (UOS) - CreateDialogParamW(hInst,MAKEINTRESOURCEW(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); - else - CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); - } - break; - case MENU_ADD_BLOB: - { - struct DBsetting *dbsetting = (struct DBsetting *)mir_alloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc - DBVARIANT dbv = {0}; // freed in the dialog - dbv.type = DBVT_BLOB; - dbsetting->dbv = dbv; - dbsetting->hContact = hContact; - dbsetting->module = mir_tstrdup(module); - dbsetting->setting = mir_tstrdup(""); - CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); - } - break; - - } // switch - } - else // on item - { - char type[8]; - LVITEM lvi; - int i; - int watching = 0; - GetCursorPos(&pt); - hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_CONTEXTMENU)); - hSubMenu = GetSubMenu(hMenu, 0); - TranslateMenu(hSubMenu); - - lvi.mask = LVIF_IMAGE|LVIF_TEXT; - lvi.iItem = hti.iItem; - lvi.iSubItem = 0; - lvi.pszText = setting; - lvi.cchTextMax = 256; - - ListView_GetItem(hSettings,&lvi); - ListView_GetItemText(hSettings, hti.iItem, 2, type, 8); - - if (!UDB) - { - RemoveMenu(hSubMenu, MENU_ADD_UNICODE, MF_BYCOMMAND); - RemoveMenu(hSubMenu, MENU_CHANGE2UNICODE, MF_BYCOMMAND); - } - - switch(lvi.iImage) { - case 4: // STRING - RemoveMenu(hSubMenu, MENU_CHANGE2STRING, MF_BYCOMMAND); - break; - case 1: // BYTE - RemoveMenu(hSubMenu, 4, MF_BYPOSITION); - RemoveMenu(hSubMenu, MENU_CHANGE2BYTE, MF_BYCOMMAND); - RemoveMenu(hSubMenu, MENU_CHANGE2UNICODE, MF_BYCOMMAND); - break; - case 2: // WORD - RemoveMenu(hSubMenu, 4, MF_BYPOSITION); - RemoveMenu(hSubMenu, MENU_CHANGE2WORD, MF_BYCOMMAND); - RemoveMenu(hSubMenu, MENU_CHANGE2UNICODE, MF_BYCOMMAND); - break; - case 3: // DWORD - RemoveMenu(hSubMenu, 4, MF_BYPOSITION); - RemoveMenu(hSubMenu, MENU_CHANGE2DWORD, MF_BYCOMMAND); - RemoveMenu(hSubMenu, MENU_CHANGE2UNICODE, MF_BYCOMMAND); - break; - case 0: // BLOB - RemoveMenu(hSubMenu, 3, MF_BYPOSITION); - RemoveMenu(hSubMenu, 1, MF_BYPOSITION); - RemoveMenu(hSubMenu, 2, MF_BYPOSITION); - RemoveMenu(hSubMenu, MENU_EDIT_SET, MF_BYCOMMAND); - break; - case 5: // UTF8 - RemoveMenu(hSubMenu, 4, MF_BYPOSITION); - RemoveMenu(hSubMenu, MENU_CHANGE2DWORD, MF_BYCOMMAND); - RemoveMenu(hSubMenu, MENU_CHANGE2WORD, MF_BYCOMMAND); - RemoveMenu(hSubMenu, MENU_CHANGE2BYTE, MF_BYCOMMAND); - if (!UDB) - { - RemoveMenu(hSubMenu, 3, MF_BYPOSITION); - RemoveMenu(hSubMenu, 1, MF_BYPOSITION); - RemoveMenu(hSubMenu, 2, MF_BYPOSITION); - RemoveMenu(hSubMenu, MENU_EDIT_SET, MF_BYCOMMAND); - RemoveMenu(hSubMenu, MENU_WATCH_ITEM, MF_BYCOMMAND); - } - else - RemoveMenu(hSubMenu, MENU_CHANGE2UNICODE, MF_BYCOMMAND); - break; - } - - // watch list stuff - - if (ListView_GetSelectedCount(hSettings) >1) - { - RemoveMenu(hSubMenu, 3, MF_BYPOSITION); - RemoveMenu(hSubMenu, 1, MF_BYPOSITION); - RemoveMenu(hSubMenu, 3, MF_BYPOSITION); - RemoveMenu(hSubMenu, MENU_EDIT_SET, MF_BYCOMMAND); - } - - // check if the setting is being watched and if it is then check the menu item - for (i=0; ihContact,info->module, setting); - break; -///////////////////////// divider -//////////////////////// NEW item submenu - case MENU_ADD_BYTE: - { - struct DBsetting *dbsetting = (struct DBsetting *)mir_alloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc - DBVARIANT dbv = {0}; // freed in the dialog - dbv.type = DBVT_BYTE; - dbsetting->dbv = dbv; - dbsetting->hContact = hContact; - dbsetting->module = mir_tstrdup(module); - dbsetting->setting = mir_tstrdup(""); - CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); - } - break; - case MENU_ADD_WORD: - { - struct DBsetting *dbsetting = (struct DBsetting *)mir_alloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc - DBVARIANT dbv = {0}; // freed in the dialog - dbv.type = DBVT_WORD; - dbsetting->dbv = dbv; - dbsetting->hContact = hContact; - dbsetting->module = mir_tstrdup(module); - dbsetting->setting = mir_tstrdup(""); - CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); - } - break; - case MENU_ADD_DWORD: - { - struct DBsetting *dbsetting = (struct DBsetting *)mir_alloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc - DBVARIANT dbv = {0}; // freed in the dialog - dbv.type = DBVT_DWORD; - dbsetting->dbv = dbv; - dbsetting->hContact = hContact; - dbsetting->module = mir_tstrdup(module); - dbsetting->setting = mir_tstrdup(""); - CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); - } - break; - case MENU_ADD_STRING: - { - struct DBsetting *dbsetting = (struct DBsetting *)mir_alloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc - DBVARIANT dbv = {0}; // freed in the dialog - dbv.type = DBVT_ASCIIZ; - dbsetting->dbv = dbv; - dbsetting->hContact = hContact; - dbsetting->module = mir_tstrdup(module); - dbsetting->setting = mir_tstrdup(""); - CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); - } - break; - case MENU_ADD_UNICODE: - if (UDB) - { - struct DBsetting *dbsetting = (struct DBsetting *)mir_alloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc - DBVARIANT dbv = {0}; // freed in the dialog - dbv.type = DBVT_UTF8; - dbsetting->dbv = dbv; - dbsetting->hContact = hContact; - dbsetting->module = mir_tstrdup(module); - dbsetting->setting = mir_tstrdup(""); - if (UOS) - CreateDialogParamW(hInst,MAKEINTRESOURCEW(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); - else - CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); - } - break; - case MENU_ADD_BLOB: - { - struct DBsetting *dbsetting = (struct DBsetting *)mir_alloc(sizeof(struct DBsetting)); // gets safe_free()ed in the window proc - DBVARIANT dbv = {0}; // freed in the dialog - dbv.type = DBVT_BLOB; - dbsetting->dbv = dbv; - dbsetting->hContact = hContact; - dbsetting->module = mir_tstrdup(module); - dbsetting->setting = mir_tstrdup(""); - CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_EDIT_SETTING),hwnd,EditSettingDlgProc, (LPARAM)dbsetting); - } - break; -///////////////////////// convert to submenu - case MENU_CHANGE2BYTE: - if (convertSetting(hContact, module, setting, 0)) - { - lvi.iImage = 1; - ListView_SetItem(hSettings,&lvi); - } - break; - case MENU_CHANGE2WORD: - if (convertSetting(hContact, module, setting, 1)) - { - lvi.iImage = 2; - ListView_SetItem(hSettings,&lvi); - } - break; - case MENU_CHANGE2DWORD: - if (convertSetting(hContact, module, setting, 2)) - { - lvi.iImage = 3; - ListView_SetItem(hSettings,&lvi); - } - break; - case MENU_CHANGE2STRING: - if (convertSetting(hContact, module, setting, 3)) - { - lvi.iImage = 4; - ListView_SetItem(hSettings,&lvi); - } - break; - case MENU_CHANGE2UNICODE: - if (convertSetting(hContact, module, setting, 4)) - { - lvi.iImage = 5; - ListView_SetItem(hSettings,&lvi); - } - break; -///////////////////////// convert to submenu - case MENU_VIEWDECRYPT: - { - DBVARIANT dbv; - if (!DBGetContactSetting(hContact,module,setting,&dbv) && dbv.type==DBVT_ASCIIZ) - { - if (lstrcmpA(setting, "LoginPassword")) - { - char *text = mir_strdup(dbv.pszVal); - CallService(MS_DB_CRYPT_DECODESTRING, (WPARAM)lstrlenA(dbv.pszVal)+1, (LPARAM)text); - msg(text, Translate("Decoded string..")); - mir_free(text); - } - else - { - char *str = mir_strdup(dbv.pszVal); - char *str1 = str; - for (;*str1; ++str1) - { - const char c = *str1 ^ 0xc3; - if (c) *str1 = c; - } - if (UOS) - { - WCHAR *res = mir_utf8decodeW(str); - MessageBoxW(0, res, TranslateW(L"Decoded string.."),MB_OK); - mir_free(res); - } - else - { - mir_utf8decode(str, NULL); - MessageBoxA(0, str, Translate("Decoded string.."),MB_OK); - } - mir_free(str); - } - } - DBFreeVariant(&dbv); - } - break; - case MENU_VIEWENCRYPT: - { - DBVARIANT dbv; - char *text; - if (!DBGetContactSetting(hContact,module,setting,&dbv) && dbv.type==DBVT_ASCIIZ) - { - text = mir_tstrdup(dbv.pszVal); - CallService(MS_DB_CRYPT_ENCODESTRING, (WPARAM)strlen(dbv.pszVal)+1, (LPARAM)text); - msg(text, Translate("Encoded string..")); - mir_free(text); - } - DBFreeVariant(&dbv); - } - break; - case MENU_DECRYPT: - { - DBVARIANT dbv; - char *text; - if (!DBGetContactSetting(hContact,module,setting,&dbv) && dbv.type==DBVT_ASCIIZ) - { - text = mir_tstrdup(dbv.pszVal); - CallService(MS_DB_CRYPT_DECODESTRING, (WPARAM)strlen(dbv.pszVal)+1, (LPARAM)text); - DBWriteContactSettingString(hContact,module,setting,text); - mir_free(text); - } - DBFreeVariant(&dbv); - } - break; - case MENU_ENCRYPT: - { - DBVARIANT dbv; - char *text; - if (!DBGetContactSetting(hContact,module,setting,&dbv) && dbv.type==DBVT_ASCIIZ) - { - text = mir_tstrdup(dbv.pszVal); - CallService(MS_DB_CRYPT_ENCODESTRING, (WPARAM)strlen(dbv.pszVal)+1, (LPARAM)text); - DBWriteContactSettingString(hContact,module,setting,text); - mir_free(text); - } - DBFreeVariant(&dbv); - } - break; -///////////////////////// divider - case MENU_WATCH_ITEM: - - if (!watching) - { - addSettingToWatchList(hContact,module,setting); - } - else freeWatchListItem(i); - if (hwnd2watchedVarsWindow) - PopulateWatchedWindow(GetDlgItem(hwnd2watchedVarsWindow, IDC_VARS)); - break; - case MENU_DELETE_SET: - DeleteSettingsFromList(hSettings, hContact, module, setting); - break; - } - } -} \ No newline at end of file diff --git a/plugins/Svc_dbepp/svc_dbepp-translation.txt b/plugins/Svc_dbepp/svc_dbepp-translation.txt deleted file mode 100644 index dbdf205b20..0000000000 --- a/plugins/Svc_dbepp/svc_dbepp-translation.txt +++ /dev/null @@ -1,219 +0,0 @@ -; Common strings that belong to many files -;[&Replace] -;[&Search] -;[Are you sure you want to delete contact \"%s\"?] -;[Confirm Contact Delete] -;[Couldnt allocate enough memory!] -;[Data] -;[Database Editor++ (ansi mode)] -;[Database Editor++ (unicode mode)] -;[Error Loading Module List] -;[Error Loading Setting List] -;[Settings] -;[Type] - -; ../../plugins/Svc_dbepp/addeditsettingsdlg.cpp -;[Cannot Convert!] -;[Edit BLOB value] -;[Edit BYTE value] -;[Edit DWORD value] -;[Edit STRING value] -;[Edit UNICODE value] -;[Edit WORD value] -;[New BLOB value] -;[New BYTE value] -;[New DWORD value] -;[New STRING value] -;[New UNICODE value] -;[New WORD value] - -; ../../plugins/Svc_dbepp/deletemodule.cpp -;[Are you sure you want to delete module \"%s\"?] -;[Confirm Module Deletion] -;[Delete module from Database] -;[Delete module from Database... Loading] - -; ../../plugins/Svc_dbepp/exportimport.cpp -;[All Files] -;[Contact already exists] -;[Couldn't open file for writing] -;[Do you want to overwrite it \"%s\"?] -;[Export to file] -;[INI Files] -;[Import from files] - -; ../../plugins/Svc_dbepp/findwindow.cpp -;[%s Module \"%s\" in contact \"%s\"] -;[%s Setting \"%s\" in module \"%s\" in contact \"%s\"] -;[%s Setting \"%s\" in module \"%s\" in contact \"%s\" - \"%s\"] -;[%s \"%s\" in Setting \"%s\" in module \"%s\" in contact \"%s\"] -;[Deleted] -;[Enter a string to search the DB for] -;[Finished. %d items were found, %d items were deleted.] -;[Finished. %d items were found, %d items were replaced.] -;[Finished. %d items were found.] -;[Found] -;[Replaced with] -;[Searching...] -;[Stop] - -; ../../plugins/Svc_dbepp/icons.cpp -;[Closed Known Module] -;[Closed Unknown Module] -;[Contacts Group] -;[Known Contact] -;[Open Known Module] -;[Open Unknown Module] -;[Unknown Contact] - -; ../../plugins/Svc_dbepp/main.cpp -;[Database Editor++] -;[Open Database Editor] -;[Open user tree in DBE++] -;[Show DataBase Editor] - -; ../../plugins/Svc_dbepp/moduletree.cpp -;[Add module to contact \"%s\"] -;[Contacts] -;[HANDLE] -;[Loading contacts...] -;[Loading modules...] -;[Module tree not found] - -; ../../plugins/Svc_dbepp/options.cpp -;[Services] - -; ../../plugins/Svc_dbepp/resource.rc -;[&Actions] -;[&Add Module] -;[&Byte] -;[&Cancel] -;[&Clone] -;[&Convert to] -;[&Delete] -;[&Delete Module] -;[&Delete all] -;[&Dword] -;[&Edit / Rename] -;[&Export] -;[&Import] -;[&Main] -;[&Open Options] -;[&Options] -;[&Refresh Modules] -;[&Rename] -;[&Restore position] -;[&Search and Replace] -;[&Sort by protocol] -;[&String] -;[&Unicode] -;[&View all] -;[&Watch] -;[&Watches] -;[&Word] -;[Add To Known Modules] -;[Add a module named] -;[Add a module to contact] -;[Add to all contacts (Includes Settings)] -;[All &Contacts] -;[All &Settings] -;[Automatically expand \"settings\" when Database Editor ++ starts] -;[BL&OB] -;[Background Colour] -;[Base] -;[Cancel] -;[Case Sensitive] -;[Changes to this list will take effect next time miranda starts] -;[Contact Mod context] -;[Contact menu] -;[Contact to copy module and settings to] -;[Contacts menu] -;[Copy To Contact] -;[Copy module to contact] -;[Copy to all contacts (Includes Settings)] -;[DBEditor++] -;[Database Editor++ Search and Replace] -;[Decrypt String] -;[E&xit] -;[Edit &Bytes in Hex] -;[Edit &Dwords in Hex] -;[Edit &Words in Hex] -;[Edit Setting] -;[Encrypt String] -;[Encyption] -;[Entire &Database] -;[Entirely] -;[Exact Match] -;[Export Contact] -;[Export Contacts] -;[Export Module] -;[Export Module from all contacts] -;[Export Settings] -;[Found field] -;[From a &file] -;[From a file] -;[From pasted &text] -;[From pasted text] -;[If the module name has a space in it, put a \\ before the space. eg \"aaa\\ bbb\"] -;[Import] -;[Import Contacts] -;[Import Module/Settings] -;[Import Settings] -;[In:] -;[Insert &CR/LF] -;[Item context] -;[Module Name] -;[Modules to ALWAYS mark as known (e.g core modules)] -;[NEW] -;[NULL contact menu] -;[Null Mod context] -;[OK] -;[Paste the Settings to import here.] -;[Popup timeout (0 for infinite)] -;[Put a space or comma between each module name] -;[Refresh &Settings] -;[Reload Watch List] -;[Replace With] -;[Restore last opened position] -;[Save Value as:] -;[Search For] -;[Setting Name] -;[Setting Value] -;[Show &All] -;[Show only &Loaded] -;[Show only &Unloaded] -;[Text:] -;[Use known modules list] -;[Use popups when watched settings change values] -;[Value Data:] -;[Value Name:] -;[View Decrypted String] -;[View Encrypted String] -;[Warn when deleting modules] -;[Watch Window] -;[Watched Database Variables] -;[new item] - -; ../../plugins/Svc_dbepp/settinglist.cpp -;[] -;[] -;[BLOB] -;[BYTE] -;[DWORD] -;[Decoded string..] -;[Encoded string..] -;[Name] -;[STRING] -;[Size] -;[UNICODE] -;[WORD] - -; ../../plugins/Svc_dbepp/watchedvars.cpp -;[Contact] -;[Database Setting Changed: \nModule: \"%s\" , Setting: \"%s\"\nNew Value (UTF8): \"%s\"] -;[Database Setting Changed: \nModule: \"%s\" , Setting: \"%s\"\nNew Value: (BYTE) %d] -;[Database Setting Changed: \nModule: \"%s\" , Setting: \"%s\"\nNew Value: (DWORD) 0x%X] -;[Database Setting Changed: \nModule: \"%s\" , Setting: \"%s\"\nNew Value: (WORD) %d] -;[Database Setting Changed: \nModule: \"%s\" , Setting: \"%s\"\nNew Value: \"%s\"] -;[Module] -;[Setting] diff --git a/plugins/Svc_dbepp/threads.cpp b/plugins/Svc_dbepp/threads.cpp deleted file mode 100644 index 7ac144adc4..0000000000 --- a/plugins/Svc_dbepp/threads.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include "headers.h" - -// thread stuff - -struct FORK_ARG { - HANDLE hEvent; - void (__cdecl *threadcode)(void*); - unsigned (__stdcall *threadcodeex)(void*); - void *arg; -}; - -void __cdecl forkthread_r(void *param) -{ - struct FORK_ARG *fa=(struct FORK_ARG*)param; - void (*callercode)(void*)=fa->threadcode; - void *arg=fa->arg; - - CallService(MS_SYSTEM_THREAD_PUSH,0,0); - - SetEvent(fa->hEvent); - - __try { - callercode(arg); - } __finally { - CallService(MS_SYSTEM_THREAD_POP,0,0); - } - - return; -} - -unsigned long forkthread ( void (__cdecl *threadcode)(void*),unsigned long stacksize,void *arg) -{ - unsigned long rc; - struct FORK_ARG fa; - - fa.hEvent=CreateEvent(NULL,FALSE,FALSE,NULL); - fa.threadcode=threadcode; - fa.arg=arg; - - rc=_beginthread(forkthread_r,stacksize,&fa); - - if ((unsigned long)-1L != rc) { - WaitForSingleObject(fa.hEvent,INFINITE); - } - CloseHandle(fa.hEvent); - - return rc; -} diff --git a/plugins/Svc_dbepp/watchedvars.cpp b/plugins/Svc_dbepp/watchedvars.cpp deleted file mode 100644 index b7d2cf6b73..0000000000 --- a/plugins/Svc_dbepp/watchedvars.cpp +++ /dev/null @@ -1,358 +0,0 @@ -#include "headers.h" - -int addSettingToWatchList(HANDLE hContact, char* module, char* setting) -{ - if (WatchListArray.count == WatchListArray.size) - { - WatchListArray.size += 32; - WatchListArray.item = (struct DBsetting*)mir_realloc(WatchListArray.item, sizeof(struct DBsetting)*WatchListArray.size); - } - if (!WatchListArray.item) return 0; - if (setting && DBGetContactSetting(hContact,module, setting, &(WatchListArray.item[WatchListArray.count].dbv))) return 0; - WatchListArray.item[WatchListArray.count].hContact = hContact; - WatchListArray.item[WatchListArray.count].module = mir_tstrdup(module); - if (setting) WatchListArray.item[WatchListArray.count].setting = mir_tstrdup(setting); - else WatchListArray.item[WatchListArray.count].setting = 0; - - WatchListArray.item[WatchListArray.count].WatchModule = setting?WATCH_SETTING:WATCH_MODULE; - WatchListArray.count++; - return 1; -} - -void freeWatchListItem(int item) -{ - if (WatchListArray.item[item].module) mir_free(WatchListArray.item[item].module); - WatchListArray.item[item].module = 0; - if (WatchListArray.item[item].setting) mir_free(WatchListArray.item[item].setting); - WatchListArray.item[item].setting = 0; - DBFreeVariant(&(WatchListArray.item[item].dbv)); - WatchListArray.item[item].hContact = 0; -} - - -void addwatchtolist(HWND hwnd2list, struct DBsetting *lParam) -{ - LVITEM lvItem; - int index; - char data[32], tmp[32]; - DBVARIANT *dbv = &(lParam->dbv); - HANDLE hContact = lParam->hContact; - char *module = lParam->module; - char *setting = lParam->setting; - if (!module) return; - lvItem.lParam = (LPARAM)lParam->hContact; - lvItem.mask = LVIF_TEXT|LVIF_PARAM; - lvItem.iItem = 0; - lvItem.iSubItem = 0; - - if (!setting || (int)(lParam->setting) == WATCH_MODULE) // add every item in the module and return - { - ModuleSettingLL settinglist; - struct DBsetting dummy; - struct ModSetLinkLinkItem *setting; - if (!EnumSettings(hContact,module,&settinglist)) return; - dummy.hContact = hContact; - dummy.module = mir_tstrdup(module); - setting = settinglist.first; - while (setting) - { - dummy.setting = setting->name; - addwatchtolist(hwnd2list, &dummy); - setting = (struct ModSetLinkLinkItem *)setting->next; - } - mir_free(dummy.module); - FreeModuleSettingLL(&settinglist); - return; - } - DBFreeVariant(&(lParam->dbv)); - if (GetSetting(hContact, module, setting, &(lParam->dbv))) return; - - if (!hContact) - lvItem.pszText = "NULL"; - else - lvItem.pszText = (char*)GetContactName(hContact,NULL,UOS); - - index = ListView_InsertItem(hwnd2list,&lvItem); - - if (UOS) - { - WCHAR* ptszText = mir_a2u(lvItem.pszText); - ListView_SetItemTextW(hwnd2list, index, 0, ptszText); - mir_free(ptszText); - } - - ListView_SetItemText(hwnd2list,index,1,module); - ListView_SetItemText(hwnd2list,index,2,setting); - - switch (dbv->type) - { - case DBVT_BLOB: - { - int j; - char *data = NULL; - if (!(data = (char*)mir_realloc(data, 3*(dbv->cpbVal+1)) )) - return; - data[0] = '\0'; - for (j=0; jcpbVal; j++) - { - char tmp[16]; - mir_snprintf(tmp, SIZEOF(tmp), "%02X ", (BYTE)dbv->pbVal[j]); - strcat(data, tmp); - } - ListView_SetItemText(hwnd2list,index,4,data); - ListView_SetItemText(hwnd2list,index,3,"BLOB"); - mir_free(data); - } - break; - case DBVT_BYTE: - mir_snprintf(data, 32, "0x%02X (%s)", dbv->bVal, itoa(dbv->bVal,tmp,10)); - ListView_SetItemText(hwnd2list,index,4,data); - ListView_SetItemText(hwnd2list,index,3,"BYTE"); - break; - case DBVT_WORD: - mir_snprintf(data, 32, "0x%04X (%s)", dbv->wVal, itoa(dbv->wVal,tmp,10)); - ListView_SetItemText(hwnd2list,index,4,data); - ListView_SetItemText(hwnd2list,index,3,"WORD"); - break; - case DBVT_DWORD: - mir_snprintf(data, 32, "0x%08X (%s)", dbv->dVal, itoa(dbv->dVal,tmp,10)); - ListView_SetItemText(hwnd2list,index,4,data); - ListView_SetItemText(hwnd2list,index,3,"DWORD"); - break; - case DBVT_ASCIIZ: - ListView_SetItemText(hwnd2list,index,4,dbv->pszVal); - ListView_SetItemText(hwnd2list,index,3,"STRING"); - break; - case DBVT_UTF8: - { - if (UOS) - { - int length = (int)strlen(dbv->pszVal) + 1; - WCHAR *wc = (WCHAR*)_alloca(length*sizeof(WCHAR)); - MultiByteToWideChar(CP_UTF8, 0, dbv->pszVal, -1, wc, length); - ListView_SetItemTextW(hwnd2list,index,4,wc); - } - else { - // convert from UTF8 - ListView_SetItemText(hwnd2list,index,4,dbv->pszVal); - } - ListView_SetItemText(hwnd2list,index,3,"UNICODE"); - } - break; - - } -} - -void PopulateWatchedWindow(HWND hwnd) -{ - int i; - ListView_DeleteAllItems(hwnd); - for (i=0;iwId) - { - case IDC_VARS: - urc->rcItem.top = 0; - urc->rcItem.bottom = urc->dlgNewSize.cy; - urc->rcItem.left = 0; - urc->rcItem.right = urc->dlgNewSize.cx; - return RD_ANCHORY_CUSTOM|RD_ANCHORX_CUSTOM; - } - return RD_ANCHORX_LEFT|RD_ANCHORY_TOP; -} - -INT_PTR CALLBACK WatchDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - switch(msg) - { - case WM_INITDIALOG: - { - // setup the list... - LVCOLUMN sLC; - - sLC.fmt = LVCFMT_LEFT; - ListView_SetExtendedListViewStyle(GetDlgItem(hwnd, IDC_VARS), 32|LVS_EX_SUBITEMIMAGES); //LVS_EX_FULLROWSELECT - sLC.mask = LVCF_FMT | LVCF_TEXT | LVCF_SUBITEM | LVCF_WIDTH; - - sLC.pszText = Translate("Contact"); sLC.cx = 80; - ListView_InsertColumn(GetDlgItem(hwnd, IDC_VARS),0,&sLC); - sLC.pszText = Translate("Module"); sLC.cx = 80; - ListView_InsertColumn(GetDlgItem(hwnd, IDC_VARS),1,&sLC); - sLC.pszText = Translate("Setting"); sLC.cx = 80; - ListView_InsertColumn(GetDlgItem(hwnd, IDC_VARS),2,&sLC); - sLC.pszText = Translate("Type"); sLC.cx = 60; - ListView_InsertColumn(GetDlgItem(hwnd, IDC_VARS),3,&sLC); - sLC.pszText = Translate("Data"); sLC.cx = 300; - ListView_InsertColumn(GetDlgItem(hwnd, IDC_VARS),4,&sLC); - - PopulateWatchedWindow(GetDlgItem(hwnd, IDC_VARS)); - - TranslateMenu(GetMenu(hwnd)); - TranslateMenu(GetSubMenu(GetMenu(hwnd),0)); - TranslateDialogDefault(hwnd); - // do the icon - SendMessage(hwnd,WM_SETICON,ICON_BIG,(LPARAM)LoadIcon(hInst,MAKEINTRESOURCE(ICO_REGEDIT))); - } - return TRUE; - // for the resize - case WM_GETMINMAXINFO: - { - MINMAXINFO *mmi=(MINMAXINFO*)lParam; - mmi->ptMinTrackSize.x=200; - mmi->ptMinTrackSize.y=90; - return 0; - } - case WM_SIZE: - { - UTILRESIZEDIALOG urd; - ZeroMemory(&urd,sizeof(urd)); - urd.cbSize=sizeof(urd); - urd.hInstance=hInst; - urd.hwndDlg=hwnd; - urd.lParam=(LPARAM)0; - urd.lpTemplate=MAKEINTRESOURCE(IDD_WATCH_DIAG); - urd.pfnResizer=WatchDialogResize; - CallService(MS_UTILS_RESIZEDIALOG,0,(LPARAM)&urd); - break; - - } - case WM_COMMAND: - switch(LOWORD(wParam)) - { - case MENU_REMALL_WATCHES: - freeAllWatches(); - ListView_DeleteAllItems(GetDlgItem(hwnd, IDC_VARS)); - break; - case MENU_EXIT: - case IDCANCEL: - hwnd2watchedVarsWindow = 0; - DestroyWindow(hwnd); - break; - case MENU_REFRESH: - PopulateWatchedWindow(GetDlgItem(hwnd, IDC_VARS)); - } - break; - - case WM_NOTIFY: - switch(LOWORD(wParam)) - { - case IDC_VARS: - switch(((NMHDR*)lParam)->code) - { - case NM_DBLCLK: - { - LVHITTESTINFO hti; - LVITEM lvi; - hti.pt=((NMLISTVIEW*)lParam)->ptAction; - if (ListView_SubItemHitTest(GetDlgItem(hwnd,IDC_VARS),&hti) >-1) - { - if (hti.flags&LVHT_ONITEM) - { - lvi.mask = LVIF_PARAM; - lvi.iItem = hti.iItem; - lvi.iSubItem = 0; - if (ListView_GetItem(GetDlgItem(hwnd,IDC_VARS),&lvi)) - { - ItemInfo ii; - ii.hContact = (HANDLE)lvi.lParam; - ListView_GetItemText(GetDlgItem(hwnd,IDC_VARS),hti.iItem,1,ii.module,128); - ListView_GetItemText(GetDlgItem(hwnd,IDC_VARS),hti.iItem,2,ii.setting,128); - ii.type = FW_SETTINGNAME; - SendMessage(hwnd2mainWindow,WM_FINDITEM,(WPARAM)&ii,0); - } - } - } - } - break; - } - break; - } - break; - } - return 0; -} - - -void popupWatchedVar(HANDLE hContact,const char* module,const char* setting) -{ - POPUPDATAEX ppd = {0}; - HICON hIcon = LoadIcon(hInst, MAKEINTRESOURCE(ICO_REGEDIT)); - char lpzContactName[MAX_CONTACTNAME]; - char lpzText[MAX_SECONDLINE]; - COLORREF colorBack = DBGetContactSettingDword(NULL,modname,"PopupColour",RGB(255,0,0)); - COLORREF colorText = RGB(0,0,0); - DBVARIANT dbv; - int timeout = DBGetContactSettingByte(NULL,modname,"PopupDelay",3); - - if (hContact) - { - // contacts nick - char szProto[256]; - if (GetValue(hContact,"Protocol","p",szProto,SIZEOF(szProto))) - mir_snprintf(lpzContactName, MAX_SECONDLINE, "%s (%s)", (char*)GetContactName(hContact, szProto, 0), szProto); - else - mir_snprintf(lpzContactName, MAX_SECONDLINE, nick_unknown); - } - else - { - strcpy(lpzContactName,Translate("Settings")); - } - // 2nd line - if (!GetSetting(hContact, module, setting, &dbv)) - { - switch (dbv.type) - { - case DBVT_BYTE: - mir_snprintf(lpzText, SIZEOF(lpzText), Translate("Database Setting Changed: \nModule: \"%s\" , Setting: \"%s\"\nNew Value: (BYTE) %d"), module, setting, dbv.bVal); - break; - case DBVT_WORD: - mir_snprintf(lpzText, SIZEOF(lpzText), Translate("Database Setting Changed: \nModule: \"%s\" , Setting: \"%s\"\nNew Value: (WORD) %d"), module, setting, dbv.wVal); - break; - case DBVT_DWORD: - mir_snprintf(lpzText, SIZEOF(lpzText), Translate("Database Setting Changed: \nModule: \"%s\" , Setting: \"%s\"\nNew Value: (DWORD) 0x%X"), module, setting, dbv.dVal); - break; - case DBVT_ASCIIZ: - mir_snprintf(lpzText, SIZEOF(lpzText), Translate("Database Setting Changed: \nModule: \"%s\" , Setting: \"%s\"\nNew Value: \"%s\""), module, setting, dbv.pszVal); - break; - case DBVT_UTF8: - mir_snprintf(lpzText, SIZEOF(lpzText), Translate("Database Setting Changed: \nModule: \"%s\" , Setting: \"%s\"\nNew Value (UTF8): \"%s\""), module, setting, dbv.pszVal); - break; - default: - return; - } - } - else return; - - DBFreeVariant(&dbv); - - ppd.lchContact = (HANDLE)hContact; - ppd.lchIcon = hIcon; - lstrcpyn(ppd.lpzContactName, lpzContactName,MAX_CONTACTNAME); - lstrcpyn(ppd.lpzText, lpzText,MAX_SECONDLINE); - ppd.colorBack = colorBack; - ppd.colorText = colorText; - ppd.PluginWindowProc = NULL; - ppd.PluginData = NULL; - ppd.iSeconds = timeout?timeout:-1; - - //Now that every field has been filled, we want to see the popup. - CallService(MS_POPUP_ADDPOPUPEX, (WPARAM)&ppd, 0); -} diff --git a/plugins/Svc_vi/AggressiveOptimize.h b/plugins/Svc_vi/AggressiveOptimize.h deleted file mode 100644 index 1b646c301c..0000000000 --- a/plugins/Svc_vi/AggressiveOptimize.h +++ /dev/null @@ -1,58 +0,0 @@ - -////////////////////////////// -// Version 1.10 -// Jan 23rd, 2000 -// Version 1.00 -// May 20th, 1999 -// Todd C. Wilson, Fresh Ground Software -// (todd@nopcode.com) -// This header file will kick in settings for Visual C++ 5 and 6 that will (usually) -// result in smaller exe's. -// The "trick" is to tell the compiler to not pad out the function calls; this is done -// by not using the /O1 or /O2 option - if you do, you implicitly use /Gy, which pads -// out each and every function call. In one single 500k dll, I managed to cut out 120k -// by this alone! -// The other two "tricks" are telling the Linker to merge all data-type segments together -// in the exe file. The relocation, read-only (constants) data, and code section (.text) -// sections can almost always be merged. Each section merged can save 4k in exe space, -// since each section is padded out to 4k chunks. This is very noticable with smaller -// exes, since you could have only 700 bytes of data, 300 bytes of code, 94 bytes of -// strings - padded out, this could be 12k of runtime, for 1094 bytes of stuff! -// Note that if you're using MFC static or some other 3rd party libs, you may get poor -// results with merging the readonly (.rdata) section - the exe may grow larger. -// To use this feature, define _MERGE_DATA_ in your project or before this header is used. -// With Visual C++ 5, the program uses a file alignement of 512 bytes, which results -// in a small exe. Under VC6, the program instead uses 4k, which is the same as the -// section size. The reason (from what I understand) is that 4k is the chunk size of -// the virtual memory manager, and that WinAlign (an end-user tuning tool for Win98) -// will re-align the programs on this boundary. The problem with this is that all of -// Microsoft's system exes and dlls are not tuned like this, and using 4k causes serious -// exe bloat. Very noticable for smaller programs. -// The "trick" for this is to use the undocumented FILEALIGN linker parm to change the -// padding from 4k to 1/2k, which results in a much smaller exe - anywhere from 20%-75% -// depending on the size. - - -#ifdef NDEBUG -// /Og (global optimizations), /Os (favor small code), /Oy (no frame pointers) -#pragma optimize("gsy",on) - -#pragma comment(linker,"/RELEASE") - -// Note that merging the .rdata section will result in LARGER exe's if you using -// MFC (esp. static link). If this is desirable, define _MERGE_RDATA_ in your project. -#ifdef _MERGE_RDATA_ -#pragma comment(linker,"/merge:.rdata=.data") -#endif // _MERGE_RDATA_ - -#pragma comment(linker,"/merge:.text=.data") -#pragma comment(linker,"/merge:.reloc=.data") - -#if _MSC_VER >= 1000 -// Only supported/needed with VC6; VC5 already does 0x200 for release builds. -// Totally undocumented! And if you set it lower than 512 bytes, the program crashes. -// Either leave at 0x200 or 0x1000 -#pragma comment(linker,"/FILEALIGN:0x200") -#endif // _MSC_VER >= 1000 - -#endif // NDEBUG diff --git a/plugins/Svc_vi/CPlugin.cpp b/plugins/Svc_vi/CPlugin.cpp deleted file mode 100644 index 56dc3e994a..0000000000 --- a/plugins/Svc_vi/CPlugin.cpp +++ /dev/null @@ -1,137 +0,0 @@ -/* -Version information plugin for Miranda IM - -Copyright © 2002-2006 Luca Santarelli, Cristian Libotean - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "CPlugin.h" -//#include "AggressiveOptimize.h" - -#include "common.h" - -const int cPLUGIN_UUID_MARK = 4; -TCHAR PLUGIN_UUID_MARK[cPLUGIN_UUID_MARK]; - -#define PLUGIN_UNCERTAIN_MARK "?" - -#define RJUST 70 - -CPlugin::CPlugin() { - pluginID = UUID_NULL; -} - -CPlugin::CPlugin(LPCTSTR eFileName, LPCTSTR eShortName, MUUID pluginID, LPCTSTR eUnicodeInfo, DWORD eVersion, LPCTSTR eTimestamp, LPCTSTR eLinkedModules) { - lpzFileName = eFileName; - lpzShortName = eShortName; - lpzUnicodeInfo = eUnicodeInfo; - lpzTimestamp = eTimestamp; - lpzLinkedModules = eLinkedModules; - - TCHAR aux[128]; - mir_sntprintf(aux, SIZEOF(aux), _T("%d.%d.%d.%d"), (eVersion>>24)&0xFF, (eVersion>>16)&0xFF, (eVersion>>8)&0xFF, (eVersion)&0xFF); - lpzVersion = aux; - - this->pluginID = pluginID; -}; - -CPlugin::CPlugin(const CPlugin& other) { - lpzFileName = other.lpzFileName; - lpzShortName = other.lpzShortName; - lpzUnicodeInfo = other.lpzUnicodeInfo; - lpzVersion = other.lpzVersion; - lpzTimestamp = other.lpzTimestamp; - lpzLinkedModules = other.lpzLinkedModules; - pluginID = other.pluginID; -} - -CPlugin::~CPlugin() { - //Debug information -// char str[64]; wsprintf(str, "~CPlugin(): %s", lpzFileName.c_str()); -// MB(str); - // - lpzFileName.~basic_string(); - lpzShortName.~basic_string(); - lpzVersion.~basic_string(); - lpzUnicodeInfo.~basic_string(); - lpzTimestamp.~basic_string(); - lpzLinkedModules.~basic_string(); -} - -void CPlugin::SetErrorMessage(LPCTSTR error) -{ - lpzLinkedModules = error; -} - -bool CPlugin::operator<(CPlugin &anotherPlugin) -{ - std::tstring anotherFileName = anotherPlugin.getFileName(); - - TCHAR szThis[MAX_PATH]; lstrcpy(szThis, lpzFileName.c_str()); - TCHAR szThat[MAX_PATH]; lstrcpy(szThat, anotherFileName.c_str()); - - if (lstrcmpi(szThis, szThat) < 0) - return TRUE; - else - return FALSE; -} - -bool CPlugin::operator>(CPlugin &anotherPlugin) -{ - return !((*this) < anotherPlugin); -} -bool CPlugin::operator==(CPlugin &anotherPlugin) -{ - return !((*this) < anotherPlugin || (*this) > anotherPlugin); -} - -std::tstring CPlugin::getFileName() -{ - return this->lpzFileName; -} - -std::tstring CPlugin::getInformations(DWORD flags, TCHAR *szHighlightHeader, TCHAR *szHighlightFooter) -{ - std::tstring lpzInformations; - if (flags & VISF_SHOWUUID) - { - TCHAR aux[128]; - UUIDToString(pluginID, aux, SIZEOF(aux)); - lpzInformations = aux; - } - else lpzInformations = (IsUUIDNull(pluginID)) ? _T(" ") : PLUGIN_UUID_MARK; - - lpzInformations += std::tstring(_T(" ") + lpzFileName + _T(" v.") + szHighlightHeader + lpzVersion + szHighlightFooter + _T(" [") + lpzTimestamp + _T("] - ") + lpzShortName); - if (lpzUnicodeInfo.size() > 0) - { - TCHAR *lwr = _tcslwr(_tcsdup(lpzShortName.c_str())); - if ( !_tcsstr(lwr, _T("unicode")) && !_tcsstr(lwr, _T("2in1"))) - lpzInformations.append( _T(" |") + lpzUnicodeInfo + _T("|")); - - free(lwr); - } - //lpzInformations.append("\t"); - //lpzInformations.append(lpzPluginID); - lpzInformations.append( _T("\r\n")); - - if (lpzLinkedModules.size() > 0) - { - lpzInformations.append(lpzLinkedModules); - lpzInformations.append( _T("\r\n")); - } -// std::string lpzInformations = std::string(lpzFileName + " - " + lpzShortName + " [" + lpzTimestamp + " · " + lpzVersion +"]\r\n"); - return lpzInformations; -}; \ No newline at end of file diff --git a/plugins/Svc_vi/CPlugin.h b/plugins/Svc_vi/CPlugin.h deleted file mode 100644 index 5da1b1dc6b..0000000000 --- a/plugins/Svc_vi/CPlugin.h +++ /dev/null @@ -1,73 +0,0 @@ -/* -Version information plugin for Miranda IM - -Copyright © 2002-2006 Luca Santarelli, Cristian Libotean - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - - -#ifndef CPLUGIN_H -#define CPLUGIN_H - -//#define STRICT -#define WIN32_LEAN_AND_MEAN - -#define _CRT_SECURE_NO_DEPRECATE - -#include -#include - -#ifndef M_NEWPLUGINAPI_H__ - #include "newpluginapi.h" -#endif - -#define DEF_UUID_CHARMARK "¤" - -extern const int cPLUGIN_UUID_MARK; -extern TCHAR PLUGIN_UUID_MARK[]; - -//using namespace std; - - - #define tstring wstring - - -class CPlugin { - private: - std::tstring lpzFileName; - std::tstring lpzShortName; - std::tstring lpzVersion; - std::tstring lpzUnicodeInfo; //aditional info, Unicode aware ... - std::tstring lpzTimestamp; //to show the last modified timestamp - std::tstring lpzLinkedModules; //to show linked modules that aren't found - MUUID pluginID; - - public: - CPlugin(); - CPlugin(LPCTSTR fileName, LPCTSTR shortName, MUUID pluginID, LPCTSTR unicodeInfo, DWORD version, LPCTSTR timestamp, LPCTSTR linkedModules); - CPlugin(const CPlugin&); - ~CPlugin(); - std::tstring getFileName(); - std::tstring getInformations(DWORD, TCHAR *, TCHAR *); - - void SetErrorMessage(LPCTSTR error); - - //Operators - bool operator<(CPlugin&); - bool operator>(CPlugin&); - bool operator==(CPlugin&); -}; -#endif \ No newline at end of file diff --git a/plugins/Svc_vi/CVersionInfo.cpp b/plugins/Svc_vi/CVersionInfo.cpp deleted file mode 100644 index d35c0c5c01..0000000000 --- a/plugins/Svc_vi/CVersionInfo.cpp +++ /dev/null @@ -1,1198 +0,0 @@ -/* -Version information plugin for Miranda IM - -Copyright © 2002-2006 Luca Santarelli, Cristian Libotean - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - - -#include "CVersionInfo.h" -//#include "AggressiveOptimize.h" - -#include "common.h" -#include "resource.h" - -//using namespace std; - -BOOL (WINAPI *MyGetDiskFreeSpaceEx)(LPCTSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER); -BOOL (WINAPI *MyIsWow64Process)(HANDLE, PBOOL); -void (WINAPI *MyGetSystemInfo)(LPSYSTEM_INFO); -BOOL (WINAPI *MyGlobalMemoryStatusEx)(LPMEMORYSTATUSEX lpBuffer) = NULL; - -LANGID (WINAPI *MyGetUserDefaultUILanguage)() = NULL; -LANGID (WINAPI *MyGetSystemDefaultUILanguage)() = NULL; - -static int ValidExtension(TCHAR *fileName, TCHAR *extension) -{ - TCHAR *dot = _tcschr(fileName, '.'); - if ( dot != NULL && !lstrcmpi(dot + 1, extension)) - if (dot[lstrlen(extension) + 1] == 0) - return 1; - - return 0; -} - -void FillLocalTime(std::tstring &output, FILETIME *fileTime) -{ - TIME_ZONE_INFORMATION tzInfo = {0}; - FILETIME local = {0}; - SYSTEMTIME sysTime; - TCHAR date[1024]; - TCHAR time[256]; - - FileTimeToLocalFileTime(fileTime, &local); - FileTimeToSystemTime(&local, &sysTime); - - GetDateFormat(EnglishLocale, 0, &sysTime, _T("dd' 'MMM' 'yyyy"), date, SIZEOF(date)); - GetTimeFormat(NULL, TIME_FORCE24HOURFORMAT, &sysTime, _T("HH':'mm':'ss"), time, SIZEOF(time)); //americans love 24hour format ;) - output = std::tstring(date) + _T(" at ") + std::tstring(time); - - int res = GetTimeZoneInformation(&tzInfo); - char tzName[32] = {0}; - TCHAR tzOffset[64] = {0}; - int offset = 0; - switch (res) { - case TIME_ZONE_ID_DAYLIGHT: - offset = -(tzInfo.Bias + tzInfo.DaylightBias); - WideCharToMultiByte(CP_ACP, 0, tzInfo.DaylightName, -1, tzName, SIZEOF(tzName), NULL, NULL); - break; - - case TIME_ZONE_ID_STANDARD: - WideCharToMultiByte(CP_ACP, 0, tzInfo.StandardName, -1, tzName, SIZEOF(tzName), NULL, NULL); - offset = -(tzInfo.Bias + tzInfo.StandardBias); - break; - - case TIME_ZONE_ID_UNKNOWN: - WideCharToMultiByte(CP_ACP, 0, tzInfo.StandardName, -1, tzName, SIZEOF(tzName), NULL, NULL); - offset = -tzInfo.Bias; - break; - } - - mir_sntprintf(tzOffset, SIZEOF(tzOffset), _T("UTC %+02d:%02d"), offset / 60, offset % 60); - output += _T(" (") + std::tstring(tzOffset) + _T(")"); -} - -CVersionInfo::CVersionInfo() -{ - luiFreeDiskSpace = 0; - bDEPEnabled = 0; -} - -CVersionInfo::~CVersionInfo() -{ - listInactivePlugins.clear(); - listActivePlugins.clear(); - listUnloadablePlugins.clear(); - - lpzMirandaVersion.~basic_string(); - lpzNightly.~basic_string(); - lpzUnicodeBuild.~basic_string(); - lpzBuildTime.~basic_string(); - lpzOSVersion.~basic_string(); - lpzMirandaPath.~basic_string(); - lpzCPUName.~basic_string(); - lpzCPUIdentifier.~basic_string(); -}; - -void CVersionInfo::Initialize() -{ -#ifdef _DEBUG - if (verbose) PUShowMessage("Before GetMirandaVersion().", SM_NOTIFY); -#endif - GetMirandaVersion(); - -#ifdef _DEBUG - if (verbose) PUShowMessage("Before GetProfileSettings().", SM_NOTIFY); -#endif - GetProfileSettings(); - -#ifdef _DEBUG - if (verbose) PUShowMessage("Before GetLangpackInfo().", SM_NOTIFY); -#endif - GetOSLanguages(); - GetLangpackInfo(); - -#ifdef _DEBUG - if (verbose) PUShowMessage("Before GetPluginLists().", SM_NOTIFY); -#endif - GetPluginLists(); - -#ifdef _DEBUG - if (verbose) PUShowMessage("Before GetOSVersion().", SM_NOTIFY); -#endif - GetOSVersion(); - -#ifdef _DEBUG - if (verbose) PUShowMessage("Before GetHWSettings().", SM_NOTIFY); -#endif - GetHWSettings(); - -#ifdef _DEBUG - if (verbose) PUShowMessage("Done with GetHWSettings().", SM_NOTIFY); -#endif -} - -bool CVersionInfo::GetMirandaVersion() -{ - //Miranda version - const BYTE str_size = 64; - char str[str_size]; - CallService(MS_SYSTEM_GETVERSIONTEXT, (WPARAM)str_size, (LPARAM)str); - this->lpzMirandaVersion = _A2T(str); - //Is it a nightly? - if (lpzMirandaVersion.find( _T("alpha"),0) != std::string::npos) - lpzNightly = _T("Yes"); - else - lpzNightly = _T("No"); - - if (lpzMirandaVersion.find( _T("Unicode"), 0) != std::string::npos) - lpzUnicodeBuild = _T("Yes"); - else - lpzUnicodeBuild = _T("No"); - - TCHAR time[128], date[128]; - GetModuleTimeStamp(date, time); - lpzBuildTime = std::tstring(time) + _T(" (UTC) on ") + std::tstring(date); - return TRUE; -} - -bool CVersionInfo::GetOSVersion() -{ - //Operating system informations - OSVERSIONINFO osvi = { 0 }; - osvi.dwOSVersionInfoSize = sizeof(osvi); - GetVersionEx(&osvi); - - //Now fill the private members. - TCHAR aux[256]; - wsprintf(aux, _T("%d.%d.%d %s"), osvi.dwMajorVersion, osvi.dwMinorVersion, LOWORD(osvi.dwBuildNumber), osvi.szCSDVersion); - lpzOSVersion = aux; - - //OSName - //Let's read the registry. - HKEY hKey; - TCHAR szKey[MAX_PATH], szValue[MAX_PATH]; - lstrcpyn(szKey, _T("Hardware\\Description\\System\\CentralProcessor\\0"), MAX_PATH); - if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, szKey, 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) { - DWORD type, size, result; - - lstrcpyn(szValue, _T("Identifier"), MAX_PATH); - result = RegQueryValueEx(hKey, szValue, 0, &type, NULL, &size); - if (result == ERROR_SUCCESS) { - TCHAR *aux = new TCHAR[size+1]; - result = RegQueryValueEx(hKey, szValue, 0, &type, (LPBYTE) aux, &size); - lpzCPUIdentifier = aux; - delete[] aux; - } - else { - NotifyError(GetLastError(), _T("RegQueryValueEx()"), __LINE__); - lpzCPUIdentifier = _T(""); - } - - lstrcpyn(szValue, _T("ProcessorNameString"), MAX_PATH); - result = RegQueryValueEx(hKey, szValue, 0, &type, NULL, &size); //get the size - if (result == ERROR_SUCCESS) { - TCHAR *aux = new TCHAR[size+1]; - result = RegQueryValueEx(hKey, szValue, 0, &type, (LPBYTE) aux, &size); - lpzCPUName = aux; - delete[] aux; - } - else { //else try to use cpuid instruction to get the proc name - char szName[50]; - #if (!defined(WIN64) && !defined(_WIN64)) - __asm - { - push eax //save the registers - push ebx - push ecx - push edx - - xor eax, eax //get simple name - cpuid - mov DWORD PTR szName[0], ebx - mov DWORD PTR szName[4], edx - mov DWORD PTR szName[8], ecx - mov DWORD PTR szName[12], 0 - - mov eax, 0x80000000 //try to get pretty name - cpuid - - cmp eax, 0x80000004 - jb end //if we don't have the extension end the check - - mov DWORD PTR szName[0], 0 //make the string null - - mov eax, 0x80000002 //first part of the string - cpuid - mov DWORD PTR szName[0], eax - mov DWORD PTR szName[4], ebx - mov DWORD PTR szName[8], ecx - mov DWORD PTR szName[12], edx - - mov eax, 0x80000003 //second part of the string - cpuid - mov DWORD PTR szName[16], eax - mov DWORD PTR szName[20], ebx - mov DWORD PTR szName[24], ecx - mov DWORD PTR szName[28], edx - - mov eax, 0x80000004 //third part of the string - cpuid - mov DWORD PTR szName[32], eax - mov DWORD PTR szName[36], ebx - mov DWORD PTR szName[40], ecx - mov DWORD PTR szName[44], edx - -end: - pop edx //load them back - pop ecx - pop ebx - pop eax - } - szName[SIZEOF(szName) - 1] = '\0'; - #else - szName[0] = 0; - #endif - - if ( !szName[0] ) - lpzCPUName = _T(""); - else - lpzCPUName = _A2T(szName); - } - } - - bDEPEnabled = IsProcessorFeaturePresent(PF_NX_ENABLED); - - switch (osvi.dwPlatformId) { - case VER_PLATFORM_WIN32_WINDOWS: - lstrcpyn(szKey, _T("Software\\Microsoft\\Windows\\CurrentVersion"), MAX_PATH); - lstrcpyn(szValue, _T("Version"), MAX_PATH); - break; - case VER_PLATFORM_WIN32_NT: - - lstrcpyn(szKey, _T("Software\\Microsoft\\Windows NT\\CurrentVersion"), MAX_PATH); - lstrcpyn(szValue, _T("ProductName"), MAX_PATH); - break; - } - - RegCloseKey(hKey); - if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,szKey,0,KEY_QUERY_VALUE,&hKey) == ERROR_SUCCESS) { - DWORD type, size, result; - //Get the size of the value we'll read. - result = RegQueryValueEx((HKEY)hKey,szValue,(LPDWORD)NULL, (LPDWORD)&type,(LPBYTE)NULL, - (LPDWORD)&size); - if (result == ERROR_SUCCESS) { - //Read it. - TCHAR *aux = new TCHAR[size+1]; - result = RegQueryValueEx((HKEY)hKey,szValue,(LPDWORD)NULL, (LPDWORD)&type,(LPBYTE)aux,(LPDWORD)&size); - lpzOSName = aux; - delete[] aux; - } - else { - NotifyError(GetLastError(), _T("RegQueryValueEx()"), __LINE__); - lpzOSName = _T(""); - } - } - else { - NotifyError(GetLastError(), _T("RegOpenKeyEx()"), __LINE__); - lpzOSName = _T(""); - } - - //Now we can improve it if we can. - switch (LOWORD(osvi.dwBuildNumber)) { - case 950: lpzOSName = _T("Microsoft Windows 95"); break; - case 1111: lpzOSName = _T("Microsoft Windows 95 OSR2"); break; - case 1998: lpzOSName = _T("Microsoft Windows 98"); break; - case 2222: lpzOSName = _T("Microsoft Windows 98 SE"); break; - case 3000: lpzOSName = _T("Microsoft Windows ME"); break; //Even if this is wrong, we have already read it in the registry. - case 1381: lpzOSName = _T("Microsoft Windows NT"); break; //What about service packs? - case 2195: lpzOSName = _T("Microsoft Windows 2000"); break; //What about service packs? - case 2600: lpzOSName = _T("Microsoft Windows XP"); break; - case 3790: - if ( GetSystemMetrics( 89 )) //R2 ? - lpzOSName = _T("Microsoft Windows 2003 R2"); - else - lpzOSName = _T("Microsoft Windows 2003"); - - break; //added windows 2003 info - } - - return TRUE; -} - -bool CVersionInfo::GetHWSettings() { - //Free space on Miranda Partition. - TCHAR szMirandaPath[MAX_PATH] = { 0 }; - { - GetModuleFileName(GetModuleHandle(NULL), szMirandaPath, SIZEOF(szMirandaPath)); - TCHAR* str2 = _tcsrchr(szMirandaPath,'\\'); - if ( str2 != NULL) *str2=0; - } - HMODULE hKernel32; - hKernel32 = LoadLibraryA("kernel32.dll"); - if (hKernel32) { - - MyGetDiskFreeSpaceEx = (BOOL (WINAPI *)(LPCTSTR,PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER))GetProcAddress(hKernel32, "GetDiskFreeSpaceExW"); - - - MyIsWow64Process = (BOOL (WINAPI *) (HANDLE, PBOOL)) GetProcAddress(hKernel32, "IsWow64Process"); - MyGetSystemInfo = (void (WINAPI *) (LPSYSTEM_INFO)) GetProcAddress(hKernel32, "GetNativeSystemInfo"); - MyGlobalMemoryStatusEx = (BOOL (WINAPI *) (LPMEMORYSTATUSEX)) GetProcAddress(hKernel32, "GlobalMemoryStatusEx"); - if ( !MyGetSystemInfo ) - MyGetSystemInfo = GetSystemInfo; - - FreeLibrary(hKernel32); - } - if ( MyGetDiskFreeSpaceEx ) { - ULARGE_INTEGER FreeBytes, a, b; - MyGetDiskFreeSpaceEx(szMirandaPath, &FreeBytes, &a, &b); - //Now we need to convert it. - __int64 aux = FreeBytes.QuadPart; - aux /= (1024*1024); - luiFreeDiskSpace = (unsigned long int)aux; - } - else luiFreeDiskSpace = 0; - - TCHAR szInfo[1024]; - GetWindowsShell(szInfo, SIZEOF(szInfo)); - lpzShell = szInfo; - GetInternetExplorerVersion(szInfo, SIZEOF(szInfo)); - lpzIEVersion = szInfo; - - - lpzAdministratorPrivileges = (IsCurrentUserLocalAdministrator()) ? _T("Yes") : _T("No"); - - bIsWOW64 = 0; - if (MyIsWow64Process) - if (!MyIsWow64Process(GetCurrentProcess(), &bIsWOW64)) - bIsWOW64 = 0; - - SYSTEM_INFO sysInfo = {0}; - GetSystemInfo(&sysInfo); - luiProcessors = sysInfo.dwNumberOfProcessors; - - //Installed RAM - if (MyGlobalMemoryStatusEx) { //windows 2000+ - MEMORYSTATUSEX ms = {0}; - ms.dwLength = sizeof(ms); - MyGlobalMemoryStatusEx(&ms); - luiRAM = (unsigned int) ((ms.ullTotalPhys / (1024 * 1024)) + 1); - } - else { - MEMORYSTATUS ms = {0}; - ms.dwLength = sizeof(ms); - GlobalMemoryStatus(&ms); - luiRAM = (ms.dwTotalPhys/(1024*1024))+1; //Ugly hack!!!! - } - - return TRUE; -} - -bool CVersionInfo::GetProfileSettings() -{ - TCHAR* tszProfileName = Utils_ReplaceVarsT(_T("%miranda_userdata%\\%miranda_profilename%.dat")); - lpzProfilePath = tszProfileName; - - WIN32_FIND_DATA fd; - if ( FindFirstFile(tszProfileName, &fd) != INVALID_HANDLE_VALUE ) { - TCHAR number[40]; - mir_sntprintf( number, SIZEOF(number), _T("%.2f KBytes"), double(fd.nFileSizeLow) / 1024 ); - lpzProfileSize = number; - - FillLocalTime(lpzProfileCreationDate, &fd.ftCreationTime); - } - else { - DWORD error = GetLastError(); - TCHAR tmp[1024]; - wsprintf(tmp, _T("%d"), error); - lpzProfileCreationDate = _T("") + std::tstring(tszProfileName); - lpzProfileSize = _T("") + std::tstring(tszProfileName); - } - - mir_free( tszProfileName ); - return true; -} - -static TCHAR szSystemLocales[4096] = {0}; -static WORD systemLangID; -#define US_LANG_ID 0x00000409 - -BOOL CALLBACK EnumSystemLocalesProc(TCHAR *szLocale) -{ - DWORD locale = _ttoi(szLocale); - TCHAR *name = GetLanguageName(locale); - if ( !_tcsstr(szSystemLocales, name)) { - _tcscat(szSystemLocales, name); - _tcscat(szSystemLocales, _T(", ")); - } - - return TRUE; -} - -BOOL CALLBACK EnumResLangProc(HMODULE hModule, LPCTSTR lpszType, LPCTSTR lpszName, WORD wIDLanguage, LONG_PTR lParam) -{ - if (!lpszName) - return FALSE; - - if (wIDLanguage != US_LANG_ID) - systemLangID = wIDLanguage; - - return TRUE; -} - -bool CVersionInfo::GetOSLanguages() -{ - lpzOSLanguages = _T("(UI | Locale (User/System)) : "); - - LANGID UILang; - - OSVERSIONINFO os = {0}; - os.dwOSVersionInfoSize = sizeof(os); - GetVersionEx(&os); - if (os.dwMajorVersion == 4) { - if (os.dwPlatformId == VER_PLATFORM_WIN32_NT) { //Win NT - HMODULE hLib = LoadLibraryA("ntdll.dll"); - - if (hLib) { - EnumResourceLanguages(hLib, RT_VERSION, MAKEINTRESOURCE(1), EnumResLangProc, NULL); - - FreeLibrary(hLib); - - if (systemLangID == US_LANG_ID) { - UINT uiACP; - - uiACP = GetACP(); - switch (uiACP) - { - case 874: // Thai code page activated, it's a Thai enabled system - systemLangID = MAKELANGID(LANG_THAI, SUBLANG_DEFAULT); - break; - - case 1255: // Hebrew code page activated, it's a Hebrew enabled system - systemLangID = MAKELANGID(LANG_HEBREW, SUBLANG_DEFAULT); - break; - - case 1256: // Arabic code page activated, it's a Arabic enabled system - systemLangID = MAKELANGID(LANG_ARABIC, SUBLANG_ARABIC_SAUDI_ARABIA); - break; - - default: - break; - } - } - } - } - else { //Win 95-Me - HKEY hKey = NULL; - TCHAR szLangID[128] = _T("0x"); - DWORD size = SIZEOF(szLangID) - 2; - TCHAR err[512]; - - if (RegOpenKeyEx(HKEY_CURRENT_USER, _T("Control Panel\\Desktop\\ResourceLocale"), 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) { - if (RegQueryValueEx(hKey, _T(""), 0, NULL, (LPBYTE) &szLangID + 2, &size) == ERROR_SUCCESS) - _tscanf(szLangID, _T("%lx"), &systemLangID); - else { - FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 0, GetLastError(), LANG_SYSTEM_DEFAULT, err, size, NULL); - MessageBox(0, err, _T("Error at RegQueryValueEx()"), MB_OK); - } - RegCloseKey(hKey); - } - else { - FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 0, GetLastError(), LANG_SYSTEM_DEFAULT, err, size, NULL); - MessageBox(0, err, _T("Error at RegOpenKeyEx()"), MB_OK); - } - } - - lpzOSLanguages += GetLanguageName(systemLangID); - } - else { - HMODULE hKernel32 = LoadLibraryA("kernel32.dll"); - if (hKernel32) { - MyGetUserDefaultUILanguage = (LANGID (WINAPI *)()) GetProcAddress(hKernel32, "GetUserDefaultUILanguage"); - MyGetSystemDefaultUILanguage = (LANGID (WINAPI *)()) GetProcAddress(hKernel32, "GetSystemDefaultUILanguage"); - - FreeLibrary(hKernel32); - } - - if ((MyGetUserDefaultUILanguage) && (MyGetSystemDefaultUILanguage)) { - UILang = MyGetUserDefaultUILanguage(); - lpzOSLanguages += GetLanguageName(UILang); - lpzOSLanguages += _T("/"); - UILang = MyGetSystemDefaultUILanguage(); - lpzOSLanguages += GetLanguageName(UILang); - } - else lpzOSLanguages += _T("Missing functions in kernel32.dll (GetUserDefaultUILanguage, GetSystemDefaultUILanguage)"); - } - - lpzOSLanguages += _T(" | "); - lpzOSLanguages += GetLanguageName(LOCALE_USER_DEFAULT); - lpzOSLanguages += _T("/"); - lpzOSLanguages += GetLanguageName(LOCALE_SYSTEM_DEFAULT); - - if (DBGetContactSettingByte(NULL, ModuleName, "ShowInstalledLanguages", 0)) { - szSystemLocales[0] = '\0'; - lpzOSLanguages += _T(" ["); - EnumSystemLocales(EnumSystemLocalesProc, LCID_INSTALLED); - if (_tcslen(szSystemLocales) > 2) - szSystemLocales[ _tcslen(szSystemLocales) - 2] = '\0'; - - lpzOSLanguages += szSystemLocales; - lpzOSLanguages += _T("]"); - } - - return true; -} - -int SaveInfo(const char *data, const char *lwrData, const char *search, TCHAR *dest, int size) -{ - const char *pos = strstr(lwrData, search); - int res = 1; - if (pos == lwrData) { - _tcsncpy(dest, _A2T(&data[strlen(search)]), size); - res = 0; - } - - return res; -} - -bool CVersionInfo::GetLangpackInfo() -{ - TCHAR langpackPath[MAX_PATH] = {0}; - TCHAR search[MAX_PATH] = {0}; - - lpzLangpackModifiedDate = _T(""); - GetModuleFileName(GetModuleHandle(NULL), langpackPath, SIZEOF(langpackPath)); - TCHAR* p = _tcsrchr(langpackPath, '\\'); - if (p) { - WIN32_FIND_DATA data = {0}; - HANDLE hLangpack; - - p[1] = '\0'; - _tcscpy(search, langpackPath); - _tcscat(search, _T("langpack_*.txt")); - hLangpack = FindFirstFile(search, &data); - if (hLangpack != INVALID_HANDLE_VALUE) { - char buffer[1024]; - char temp[1024]; - FillLocalTime(lpzLangpackModifiedDate, &data.ftLastWriteTime); - - TCHAR locale[128] = {0}; - TCHAR language[128] = {0}; - TCHAR version[128] = {0}; - _tcscpy(version, _T("N/A")); - - _tcsncpy(language, data.cFileName, SIZEOF(language)); - p = _tcsrchr(language, '.'); - p[0] = '\0'; - - _tcscat(langpackPath, data.cFileName); - FILE *fin = _tfopen(langpackPath, _T("rt")); - if (fin) { - size_t len; - while (!feof(fin)) { - fgets(buffer, SIZEOF(buffer), fin); - len = strlen(buffer); - if (buffer[len - 1] == '\n') buffer[len - 1] = '\0'; - strncpy(temp, buffer, SIZEOF(temp)); - _strlwr(temp); - if (SaveInfo(buffer, temp, "language: ", language, SIZEOF(language))) { - if (SaveInfo(buffer, temp, "locale: ", locale, SIZEOF(locale))) { - char* p = strstr(buffer, "; FLID: "); - if (p) { - int ok = 1; - int i; - for (i = 0; ((i < 3) && (ok)); i++) { - p = strrchr(temp, '.'); - if (p) - p[0] = '\0'; - else - ok = 0; - } - p = strrchr(temp, ' '); - if ((ok) && (p)) - _tcsncpy(version, _A2T(&buffer[p - temp + 1]), SIZEOF(version)); - else - _tcsncpy(version, _T(""), SIZEOF(version)); - } } } } - - lpzLangpackInfo = std::tstring(language) + _T(" [") + std::tstring(locale) + _T("]"); - if ( version[0] ) - lpzLangpackInfo += _T(" v. ") + std::tstring(version); - - fclose(fin); - } - else { - int err = GetLastError(); - lpzLangpackInfo = _T(" Could not open file " + std::tstring(data.cFileName)); - } - FindClose(hLangpack); - } - else lpzLangpackInfo = _T("No language pack installed"); - } - - return true; -} - -std::tstring GetPluginTimestamp(FILETIME *fileTime) -{ - SYSTEMTIME sysTime; - FileTimeToSystemTime(fileTime, &sysTime); //convert the file tyme to system time - - //char time[256]; - TCHAR date[256]; //lovely - GetDateFormat(EnglishLocale, 0, &sysTime, _T("dd' 'MMM' 'yyyy"), date, SIZEOF(date)); - return date; -} - -bool CVersionInfo::GetPluginLists() -{ - HANDLE hFind; - TCHAR szMirandaPath[MAX_PATH] = { 0 }, szSearchPath[MAX_PATH] = { 0 }; //For search purpose - WIN32_FIND_DATA fd; - TCHAR szMirandaPluginsPath[MAX_PATH] = { 0 }, szPluginPath[MAX_PATH] = { 0 }; //For info reading purpose - BYTE PluginIsEnabled = 0; - HINSTANCE hInstPlugin = NULL; - PLUGININFOEX *(*MirandaPluginInfo)(DWORD); //These two are used to get informations from the plugin. - PLUGININFOEX *pluginInfo = NULL; //Read above. - DWORD mirandaVersion = 0; - BOOL asmCheckOK = FALSE; - DWORD loadError; - // SYSTEMTIME sysTime; //for timestamp - - mirandaVersion=(DWORD)CallService(MS_SYSTEM_GETVERSION,0,0); - { - GetModuleFileName(GetModuleHandle(NULL), szMirandaPath, SIZEOF(szMirandaPath)); - TCHAR* str2 = _tcsrchr(szMirandaPath,'\\'); - if(str2!=NULL) *str2=0; - } - lpzMirandaPath = szMirandaPath; - - //We got Miranda path, now we'll use it for two different purposes. - //1) finding plugins. - //2) Reading plugin infos - lstrcpyn(szSearchPath,szMirandaPath, MAX_PATH); //We got the path, now we copy it into szSearchPath. We'll use szSearchPath as am auxiliary variable, while szMirandaPath will keep a "fixed" value. - lstrcat(szSearchPath, _T("\\Plugins\\*.dll")); - - lstrcpyn(szMirandaPluginsPath, szMirandaPath, MAX_PATH); - lstrcat(szMirandaPluginsPath, _T("\\Plugins\\")); - - hFind=FindFirstFile(szSearchPath,&fd); - if ( hFind != INVALID_HANDLE_VALUE) { - do { - if (verbose) PUShowMessageT(fd.cFileName, SM_NOTIFY); - if (!ValidExtension(fd.cFileName, _T("dll"))) - continue; //do not report plugins that do not have extension .dll - - hInstPlugin = GetModuleHandle(fd.cFileName); //try to get the handle of the module - - if (hInstPlugin) //if we got it then the dll is loaded (enabled) - PluginIsEnabled = 1; - else { - PluginIsEnabled = 0; - lstrcpyn(szPluginPath, szMirandaPluginsPath, MAX_PATH); // szPluginPath becomes "drive:\path\Miranda\Plugins\" - lstrcat(szPluginPath, fd.cFileName); // szPluginPath becomes "drive:\path\Miranda\Plugins\popup.dll" - hInstPlugin = LoadLibrary(szPluginPath); - } - if (!hInstPlugin) { //It wasn't loaded. - loadError = GetLastError(); - int bUnknownError = 1; //assume plugin didn't load because of unknown error - //Some error messages. - //get the dlls the plugin statically links to - if (DBGetContactSettingByte(NULL, ModuleName, "CheckForDependencies", TRUE)) - { - std::tstring linkedModules; - - lstrcpyn(szPluginPath, szMirandaPluginsPath, MAX_PATH); // szPluginPath becomes "drive:\path\Miranda\Plugins\" - lstrcat(szPluginPath, fd.cFileName); // szPluginPath becomes "drive:\path\Miranda\Plugins\popup.dll" - if (GetLinkedModulesInfo(szPluginPath, linkedModules)) { - std::tstring time = GetPluginTimestamp(&fd.ftLastWriteTime); - CPlugin thePlugin(fd.cFileName, _T(""), UUID_NULL, _T(""), 0, time.c_str(), linkedModules.c_str()); - AddPlugin(thePlugin, listUnloadablePlugins); - bUnknownError = 0; //we know why the plugin didn't load - } - } - if (bUnknownError) { //if cause is unknown then report it - std::tstring time = GetPluginTimestamp(&fd.ftLastWriteTime); - TCHAR buffer[4096]; - TCHAR error[2048]; - //DWORD_PTR arguments[2] = {loadError, 0}; - FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ARGUMENT_ARRAY, NULL, loadError, 0, error, SIZEOF(error), NULL); - wsprintf(buffer, _T(" Error %ld - %s"), loadError, error); - CPlugin thePlugin( fd.cFileName, _T(""), UUID_NULL, _T(""), 0, time.c_str(), buffer); - AddPlugin(thePlugin, listUnloadablePlugins); - } - } - else { //It was successfully loaded. - MirandaPluginInfo = (PLUGININFOEX *(*)(DWORD))GetProcAddress(hInstPlugin, "MirandaPluginInfoEx"); - if (!MirandaPluginInfo) - MirandaPluginInfo = (PLUGININFOEX *(*)(DWORD))GetProcAddress(hInstPlugin, "MirandaPluginInfo"); - - if (!MirandaPluginInfo) //There is no function: it's not a valid plugin. Let's move on to the next file. - continue; - - //It's a valid plugin, since we could find MirandaPluginInfo - #if (!defined(WIN64) && !defined(_WIN64)) - asmCheckOK = FALSE; - __asm { - push mirandaVersion - push mirandaVersion - call MirandaPluginInfo - pop eax - pop eax - cmp eax, mirandaVersion - jne a1 - mov asmCheckOK, 0xffffffff - a1: - } - #else - asmCheckOK = TRUE; - #endif - if (asmCheckOK) - pluginInfo = CopyPluginInfo(MirandaPluginInfo(mirandaVersion)); - else { - ZeroMemory(&pluginInfo, sizeof(pluginInfo)); - MessageBox(NULL, fd.cFileName, _T("Invalid plugin"), MB_OK); - } } - - //Let's get the info. - if (MirandaPluginInfo != NULL) {//a valid miranda plugin - if (pluginInfo != NULL) { - //We have loaded the informations into pluginInfo. - std::tstring timedate = GetPluginTimestamp(&fd.ftLastWriteTime); - CPlugin thePlugin(fd.cFileName, _A2T(pluginInfo->shortName), pluginInfo->uuid, (pluginInfo->flags & 1) ? _T("Unicode aware") : _T(""), (DWORD) pluginInfo->version, timedate.c_str(), _T("")); - - if (PluginIsEnabled) - AddPlugin(thePlugin, listActivePlugins); - else { - if ((IsUUIDNull(pluginInfo->uuid)) && (mirandaVersion >= PLUGIN_MAKE_VERSION(0,8,0,9))) { - thePlugin.SetErrorMessage( _T(" Plugin does not have an UUID and will not work with Miranda 0.8.\r\n")); - AddPlugin(thePlugin, listUnloadablePlugins); - } - else AddPlugin(thePlugin, listInactivePlugins); - - FreeLibrary(hInstPlugin); //We don't need it anymore. - } - FreePluginInfo(pluginInfo); - MirandaPluginInfo = NULL; - #ifdef _DEBUG - if (verbose) { - TCHAR szMsg[4096] = { 0 }; - wsprintf(szMsg, _T("Done with: %s"), fd.cFileName); - PUShowMessageT(szMsg, SM_NOTIFY); - } - #endif - } - else { //pluginINFO == NULL - pluginInfo = CopyPluginInfo(MirandaPluginInfo(PLUGIN_MAKE_VERSION(9, 9, 9, 9))); //let's see if the plugin likes this miranda version - char *szShortName = ""; - std::tstring time = GetPluginTimestamp(&fd.ftLastWriteTime); //get the plugin timestamp; - DWORD version = 0; - if (pluginInfo) { - szShortName = pluginInfo->shortName; - version = pluginInfo->version; - } - - CPlugin thePlugin(fd.cFileName, _A2T(szShortName), (pluginInfo) ? pluginInfo->uuid : UUID_NULL, (((pluginInfo) && (pluginInfo->flags & 1)) ? _T("Unicode aware") : _T("")), version, time.c_str(), _T(" Plugin refuses to load. Miranda version too old.")); - - AddPlugin(thePlugin, listUnloadablePlugins); - if (pluginInfo) - FreePluginInfo(pluginInfo); - } } - } - while (FindNextFile(hFind,&fd)); - FindClose(hFind); - } - return TRUE; -} - -bool CVersionInfo::AddPlugin(CPlugin &aPlugin, std::list &aList) { - std::list::iterator pos = aList.begin(); - bool inserted = FALSE; - - if (aList.begin() == aList.end()) { //It's empty - aList.push_back(aPlugin); - return TRUE; - } - else { //It's not empty - while (pos != aList.end()) { - //It can be either < or >, not equal. - if (aPlugin < (*pos)) { - aList.insert(pos, aPlugin); - return TRUE; - } - - //It's greater: we need to insert it. - pos++; - } } - - if (inserted == FALSE) { - aList.push_back(aPlugin); - return TRUE; - } - return TRUE; -}; - -static char *GetStringFromRVA(DWORD RVA, const LOADED_IMAGE *image) -{ - char *moduleName; - moduleName = (char *) ImageRvaToVa(image->FileHeader, image->MappedAddress, RVA, NULL); - return moduleName; -} - -bool CVersionInfo::GetLinkedModulesInfo(TCHAR *moduleName, std::tstring &linkedModules) -{ - LOADED_IMAGE image; - ULONG importTableSize; - IMAGE_IMPORT_DESCRIPTOR *importData; - //HMODULE dllModule; - linkedModules = _T(""); - bool result = false; - TCHAR szError[20]; - char* szModuleName = mir_t2a(moduleName); - if (MapAndLoad(szModuleName, NULL, &image, TRUE, TRUE) == FALSE) { - wsprintf(szError, _T("%d"), GetLastError()); - mir_free( szModuleName ); - linkedModules = _T("\r\n"); - return result; - } - mir_free( szModuleName ); - importData = (IMAGE_IMPORT_DESCRIPTOR *) ImageDirectoryEntryToData(image.MappedAddress, FALSE, IMAGE_DIRECTORY_ENTRY_IMPORT, &importTableSize); - if (!importData) { - wsprintf(szError, _T("%d"), GetLastError()); - linkedModules = _T("\r\n"); - } - else { - while (importData->Name) { - char *moduleName; - moduleName = GetStringFromRVA(importData->Name, &image); - if (!DoesDllExist(moduleName)) { - linkedModules.append( _T(" Plugin statically links to missing dll file: ") + std::tstring(_A2T(moduleName)) + _T("\r\n")); - result = true; - } - - importData++; //go to next record - } } - - // FreeLibrary(dllModule); - UnMapAndLoad(&image); //unload the image - return result; -} - -std::tstring CVersionInfo::GetListAsString(std::list &aList, DWORD flags, int beautify) { - std::list::iterator pos = aList.begin(); - std::tstring out = _T(""); -#ifdef _DEBUG - if (verbose) PUShowMessage("CVersionInfo::GetListAsString, begin.", SM_NOTIFY); -#endif - - TCHAR szHeader[32] = {0}; - TCHAR szFooter[32] = {0}; - if ((((flags & VISF_FORUMSTYLE) == VISF_FORUMSTYLE) || beautify) && (DBGetContactSettingByte(NULL, ModuleName, "BoldVersionNumber", TRUE))) { - GetStringFromDatabase("BoldBegin", _T("[b]"), szHeader, SIZEOF(szHeader)); - GetStringFromDatabase("BoldEnd", _T("[/b]"), szFooter, SIZEOF(szFooter)); - } - - while (pos != aList.end()) { - out.append(std::tstring((*pos).getInformations(flags, szHeader, szFooter))); - pos++; - } - #ifdef _DEBUG - if (verbose) PUShowMessage("CVersionInfo::GetListAsString, end.", SM_NOTIFY); - #endif - return out; -}; - -void CVersionInfo::BeautifyReport(int beautify, LPCTSTR szBeautifyText, LPCTSTR szNonBeautifyText, std::tstring &out) -{ - if (beautify) - out.append(szBeautifyText); - else - out.append(szNonBeautifyText); -} - -void CVersionInfo::AddInfoHeader(int suppressHeader, int forumStyle, int beautify, std::tstring &out) -{ - if (forumStyle) { //forum style - TCHAR szSize[256], szQuote[256]; - - GetStringFromDatabase("SizeBegin", _T("[size=1]"), szSize, SIZEOF(szSize)); - GetStringFromDatabase("QuoteBegin", _T("[quote]"), szQuote, SIZEOF(szQuote)); - out.append(szQuote); - out.append(szSize); - } - else out = _T(""); - - if (!suppressHeader) { - out.append( _T("Miranda IM - VersionInformation plugin by Hrk, modified by Eblis\r\n")); - if (!forumStyle) { - out.append( _T("Miranda's homepage: http://www.miranda-im.org/\r\n")); //changed homepage - out.append( _T("Miranda tools: http://miranda-im.org/download/\r\n\r\n")); //was missing a / before download - } } - - TCHAR buffer[1024]; //for beautification - GetStringFromDatabase("BeautifyHorizLine", _T("
"), buffer, SIZEOF(buffer)); - BeautifyReport(beautify, buffer, _T(""), out); - GetStringFromDatabase("BeautifyBlockStart", _T("
"), buffer, SIZEOF(buffer)); - BeautifyReport(beautify, buffer, _T(""), out); - if (!suppressHeader) { - //Time of report: - TCHAR lpzTime[12]; GetTimeFormat(LOCALE_USER_DEFAULT, 0, NULL, _T("HH':'mm':'ss"), lpzTime, SIZEOF(lpzTime)); - TCHAR lpzDate[32]; GetDateFormat(EnglishLocale, 0, NULL, _T("dd' 'MMMM' 'yyyy"), lpzDate, SIZEOF(lpzDate)); - out.append( _T("Report generated at: ") + std::tstring(lpzTime) + _T(" on ") + std::tstring(lpzDate) + _T("\r\n\r\n")); - } - - //Operating system - out.append(_T("CPU: ") + lpzCPUName + _T(" [") + lpzCPUIdentifier + _T("]")); - if (bDEPEnabled) - out.append(_T(" [DEP enabled]")); - - if (luiProcessors > 1) { - TCHAR noProcs[128]; - wsprintf(noProcs, _T(" [%d CPUs]"), luiProcessors); - out.append(noProcs); - } - out.append( _T("\r\n")); - - //RAM - TCHAR szRAM[64]; wsprintf(szRAM, _T("%d"), luiRAM); - out.append( _T("Installed RAM: ") + std::tstring(szRAM) + _T(" MBytes\r\n")); - - //operating system - out.append( _T("Operating System: ") + lpzOSName + _T(" [version: ") + lpzOSVersion + _T("]\r\n")); - - //shell, IE, administrator - out.append( _T("Shell: ") + lpzShell + _T(", Internet Explorer ") + lpzIEVersion + _T("\r\n")); - out.append( _T("Administrator privileges: ") + lpzAdministratorPrivileges + _T("\r\n")); - - //languages - out.append( _T("OS Languages: ") + lpzOSLanguages + _T("\r\n")); - - //FreeDiskSpace - if (luiFreeDiskSpace) { - TCHAR szDiskSpace[64]; wsprintf(szDiskSpace, _T("%d"), luiFreeDiskSpace); - out.append( _T("Free disk space on Miranda partition: ") + std::tstring(szDiskSpace) + _T(" MBytes\r\n")); - } - - //Miranda - out.append( _T("Miranda path: ") + lpzMirandaPath + _T("\r\n")); - out.append( _T("Miranda IM version: ") + lpzMirandaVersion); - if (bIsWOW64) - out.append( _T(" [running inside WOW64]")); - if (bServiceMode) - out.append( _T(" [service mode]")); - - out.append( _T("\r\nBuild time: ") + lpzBuildTime + _T("\r\n")); - out.append( _T("Profile path: ") + lpzProfilePath + _T("\r\n")); - out.append( _T("Profile size: ") + lpzProfileSize + _T("\r\n")); - out.append( _T("Profile creation date: ") + lpzProfileCreationDate + _T("\r\n")); - out.append( _T("Language pack: ") + lpzLangpackInfo); - out.append((lpzLangpackModifiedDate.size() > 0) ? _T(", modified: ") + lpzLangpackModifiedDate : _T("")); - out.append( _T("\r\n")); - - out.append( _T("Nightly: ") + lpzNightly + _T("\r\n")); - out.append( _T("Unicode core: ") + lpzUnicodeBuild); - - GetStringFromDatabase("BeautifyBlockEnd", _T("
"), buffer, SIZEOF(buffer)); - BeautifyReport(beautify, buffer, _T("\r\n"), out); -} - -void CVersionInfo::AddInfoFooter(int suppressFooter, int forumStyle, int beautify, std::tstring &out) -{ - //End of report - TCHAR buffer[1024]; //for beautification purposes - GetStringFromDatabase("BeautifyHorizLine", _T("
"), buffer, SIZEOF(buffer)); - if (!suppressFooter) { - BeautifyReport(beautify, buffer, _T("\r\n"), out); - out.append( _T("\r\nEnd of report.\r\n")); - } - - if (!forumStyle) { - if (!suppressFooter) - out.append( TranslateT("If you are going to use this report to submit a bug, remember to check the website for questions or help the developers may need.\r\nIf you don't check your bug report and give feedback, it will not be fixed!")); - } - else { - TCHAR szSize[256], szQuote[256]; - GetStringFromDatabase("SizeEnd", _T("[/size]"), szSize, SIZEOF(szSize)); - GetStringFromDatabase("QuoteEnd", _T("[/quote]"), szQuote, SIZEOF(szQuote)); - out.append(szSize); - out.append(szQuote); - } -} - -static void AddSectionAndCount(std::list list, LPCTSTR listText, std::tstring &out) -{ - TCHAR tmp[64]; - wsprintf(tmp, _T(" (%u)"), list.size()); - out.append(listText); - out.append( tmp ); - out.append( _T(":")); -} - -std::tstring CVersionInfo::GetInformationsAsString(int bDisableForumStyle) { - //Begin of report - std::tstring out; - int forumStyle = (bDisableForumStyle) ? 0 : DBGetContactSettingByte(NULL, ModuleName, "ForumStyle", TRUE); - int showUUID = DBGetContactSettingByte(NULL, ModuleName, "ShowUUIDs", FALSE); - int beautify = DBGetContactSettingByte(NULL, ModuleName, "Beautify", 0) & (!forumStyle); - int suppressHeader = DBGetContactSettingByte(NULL, ModuleName, "SuppressHeader", TRUE); - - DWORD flags = (forumStyle) | (showUUID << 1); - - AddInfoHeader(suppressHeader, forumStyle, beautify, out); - TCHAR normalPluginsStart[1024]; //for beautification purposes, for normal plugins text (start) - TCHAR normalPluginsEnd[1024]; //for beautification purposes, for normal plugins text (end) - TCHAR horizLine[1024]; //for beautification purposes - TCHAR buffer[1024]; //for beautification purposes - - TCHAR headerHighlightStart[10] = _T(""); - TCHAR headerHighlightEnd[10] = _T(""); - if (forumStyle) { - TCHAR start[128], end[128]; - GetStringFromDatabase("BoldBegin", _T("[b]"), start, SIZEOF(start)); - GetStringFromDatabase("BoldEnd", _T("[/b]"), end, SIZEOF(end)); - _tcsncpy(headerHighlightStart, start, SIZEOF(headerHighlightStart)); - _tcsncpy(headerHighlightEnd, end, SIZEOF(headerHighlightEnd)); - } - - //Plugins: list of active (enabled) plugins. - GetStringFromDatabase("BeautifyHorizLine", _T("
"), horizLine, SIZEOF(horizLine)); - BeautifyReport(beautify, horizLine, _T("\r\n"), out); - GetStringFromDatabase("BeautifyActiveHeaderBegin", _T(""), buffer, SIZEOF(buffer)); - BeautifyReport(beautify, buffer, headerHighlightStart, out); - AddSectionAndCount(listActivePlugins, _T("Active Plugins"), out); - GetStringFromDatabase("BeautifyActiveHeaderEnd", _T(""), buffer, SIZEOF(buffer)); - BeautifyReport(beautify, buffer, headerHighlightEnd, out); - out.append( _T("\r\n")); - - GetStringFromDatabase("BeautifyPluginsBegin", _T(""), normalPluginsStart, SIZEOF(normalPluginsStart)); - BeautifyReport(beautify, normalPluginsStart, _T(""), out); - out.append(GetListAsString(listActivePlugins, flags, beautify)); - GetStringFromDatabase("BeautifyPluginsEnd", _T(""), normalPluginsEnd, SIZEOF(normalPluginsEnd)); - BeautifyReport(beautify, normalPluginsEnd, _T(""), out); - //Plugins: list of inactive (disabled) plugins. - if ((!forumStyle) && ((DBGetContactSettingByte(NULL, ModuleName, "ShowInactive", TRUE)) || (bServiceMode))) { - BeautifyReport(beautify, horizLine, _T("\r\n"), out); - GetStringFromDatabase("BeautifyInactiveHeaderBegin", _T(""), buffer, SIZEOF(buffer)); - BeautifyReport(beautify, buffer, headerHighlightStart, out); - AddSectionAndCount(listInactivePlugins, _T("Inactive Plugins"), out); - GetStringFromDatabase("BeautifyInactiveHeaderEnd", _T(""), buffer, SIZEOF(buffer)); - BeautifyReport(beautify, buffer, headerHighlightEnd, out); - out.append( _T("\r\n")); - BeautifyReport(beautify, normalPluginsStart, _T(""), out); - out.append(GetListAsString(listInactivePlugins, flags, beautify)); - BeautifyReport(beautify, normalPluginsEnd, _T(""), out); - } - if (listUnloadablePlugins.size() > 0) { - BeautifyReport(beautify, horizLine, _T("\r\n"), out); - GetStringFromDatabase("BeautifyUnloadableHeaderBegin", _T(""), buffer, SIZEOF(buffer)); - BeautifyReport(beautify, buffer, headerHighlightStart, out); - AddSectionAndCount(listUnloadablePlugins, _T("Unloadable Plugins"), out); - GetStringFromDatabase("BeautifyUnloadableHeaderEnd", _T(""), buffer, SIZEOF(buffer)); - BeautifyReport(beautify, buffer, headerHighlightEnd, out); - out.append( _T("\r\n")); - BeautifyReport(beautify, normalPluginsStart, _T(""), out); - out.append(GetListAsString(listUnloadablePlugins, flags, beautify)); - BeautifyReport(beautify, normalPluginsEnd, _T(""), out); - } - AddInfoFooter(suppressHeader, forumStyle, beautify, out); - return out; -} - -//========== Print functions ===== - -void CVersionInfo::PrintInformationsToFile(const TCHAR *info) -{ - TCHAR buffer[MAX_PATH], outputFileName[MAX_PATH]; - if (bFoldersAvailable) { - FoldersGetCustomPathT(hOutputLocation, buffer, SIZEOF(buffer), _T("%miranda_path%")); - _tcscat(buffer, _T("\\VersionInfo.txt")); - } - else GetStringFromDatabase("OutputFile", _T("VersionInfo.txt"), buffer, SIZEOF(buffer)); - - RelativePathToAbsolute(buffer, outputFileName, SIZEOF(buffer)); - - FILE *fp = _tfopen(outputFileName, _T("wb")); - if ( fp != NULL ) { - char* utf = mir_utf8encodeT( info ); - fputs( "\xEF\xBB\xBF", fp); - fputs( utf, fp ); - fclose(fp); - - TCHAR mex[512]; - mir_sntprintf(mex, SIZEOF(mex), TranslateT("Information successfully written to file: \"%s\"."), outputFileName); - Log(mex); - } - else { - TCHAR mex[512]; - mir_sntprintf(mex, SIZEOF(mex), TranslateT("Error during the creation of file \"%s\". Disk may be full or write protected."), outputFileName); - Log(mex); - } -} - -void CVersionInfo::PrintInformationsToFile() -{ - PrintInformationsToFile( GetInformationsAsString().c_str()); -} - -void CVersionInfo::PrintInformationsToMessageBox() -{ - MessageBox(NULL, GetInformationsAsString().c_str(), _T("VersionInfo"), MB_OK); -} - -void CVersionInfo::PrintInformationsToOutputDebugString() -{ - OutputDebugString( GetInformationsAsString().c_str()); -} - - -void CVersionInfo::PrintInformationsToDialogBox() -{ - HWND DialogBox = CreateDialogParam(hInst, - MAKEINTRESOURCE(IDD_DIALOGINFO), - NULL, DialogBoxProc, (LPARAM) this); - - SetDlgItemText(DialogBox, IDC_TEXT, GetInformationsAsString().c_str()); -} - -void CVersionInfo::PrintInformationsToClipboard(bool showLog) -{ - if (GetOpenClipboardWindow()) { - Log( TranslateT("The clipboard is not available, retry.")); - return; - } - - OpenClipboard(NULL); - //Ok, let's begin, then. - EmptyClipboard(); - //Storage data we'll use. - LPTSTR lptstrCopy; - std::tstring aux = GetInformationsAsString(); - size_t length = aux.length() + 1; - HANDLE hData = GlobalAlloc(GMEM_MOVEABLE, length*sizeof(TCHAR) + 5); - //Lock memory, copy it, release it. - lptstrCopy = (LPTSTR)GlobalLock(hData); - lstrcpy(lptstrCopy, aux.c_str()); - lptstrCopy[length] = '\0'; - GlobalUnlock(hData); - //Now set the clipboard data. - - SetClipboardData(CF_UNICODETEXT, hData); - - //Remove the lock on the clipboard. - CloseClipboard(); - if (showLog) - Log( TranslateT("Information successfully copied into clipboard.")); -} diff --git a/plugins/Svc_vi/CVersionInfo.h b/plugins/Svc_vi/CVersionInfo.h deleted file mode 100644 index eb55b808fc..0000000000 --- a/plugins/Svc_vi/CVersionInfo.h +++ /dev/null @@ -1,115 +0,0 @@ -/* -Version information plugin for Miranda IM - -Copyright © 2002-2006 Luca Santarelli, Cristian Libotean - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#ifndef CVERSIONINFO_H -#define CVERSIONINFO_H - -//#define STRICT -#define WIN32_LEAN_AND_MEAN -//#include "AggressiveOptimize.h" - -#define _CRT_SECURE_NO_DEPRECATE - -#ifndef PF_NX_ENABLED - #define PF_NX_ENABLED 12 -#endif - -#include -#include -//using namespace std; - -#include "CPlugin.h" - -class CVersionInfo -{ - private: - //Informations related to Miranda: main informations. - std::tstring lpzMirandaVersion; - std::tstring lpzMirandaPath; - std::tstring lpzProfilePath; - std::tstring lpzProfileSize; - std::tstring lpzProfileCreationDate; - std::tstring lpzNightly; - std::tstring lpzUnicodeBuild; - std::tstring lpzCPUName; - std::tstring lpzCPUIdentifier; - std::tstring lpzBuildTime; - std::tstring lpzShell; - std::tstring lpzIEVersion; - std::tstring lpzAdministratorPrivileges; - std::tstring lpzOSLanguages; - std::tstring lpzLangpackInfo; - std::tstring lpzLangpackModifiedDate; - //Informations related to plugins - std::list listActivePlugins; - std::list listInactivePlugins; - std::list listUnloadablePlugins; - //OS and hardware informations. - std::tstring lpzOSVersion; - std::tstring lpzOSName; - unsigned int luiProcessors; - unsigned int luiRAM; - unsigned int luiFreeDiskSpace; - int bDEPEnabled; - BOOL bIsWOW64; - //Additional Miranda informations. - unsigned int luiContacts; - unsigned int luiEvents; - unsigned int luiUnreadEvents; - unsigned int luiDBSize; - bool bExpertSettingsOn; - //Configuration - - bool GetLinkedModulesInfo(TCHAR *moduleName, std::tstring &linkedModules); - - public: - //Constructor/Destructor - CVersionInfo(); - ~CVersionInfo(); - void Initialize(); - //Miranda informations - bool GetMirandaVersion(); - bool GetProfileSettings(); - bool GetOSLanguages(); - bool GetLangpackInfo(); - bool GetPluginLists(); - bool GetEventCount(); //TODO - //OSInformations - bool GetOSVersion(); - bool GetHWSettings(); - //Plugins - bool AddPlugin(CPlugin&, std::list&); - //Prints - - void PrintInformationsToFile(); - void PrintInformationsToFile(const TCHAR *info); - void PrintInformationsToDialogBox(); - void PrintInformationsToMessageBox(); - void PrintInformationsToOutputDebugString(); - void PrintInformationsToClipboard(bool); - - std::tstring GetListAsString(std::list&, DWORD flags, int beautify); - std::tstring GetInformationsAsString(int bDisableForumStyle = 0); - void BeautifyReport(int, LPCTSTR, LPCTSTR, std::tstring &); - void AddInfoHeader(int, int, int, std::tstring &); - void AddInfoFooter(int, int, int, std::tstring &); -}; - -#endif \ No newline at end of file diff --git a/plugins/Svc_vi/VersionInfo.html b/plugins/Svc_vi/VersionInfo.html deleted file mode 100644 index a955874979..0000000000 --- a/plugins/Svc_vi/VersionInfo.html +++ /dev/null @@ -1,11 +0,0 @@ - - - -
-

Version Information Test Page

- -

Version Information version 1.4.3.2

-

VersionInfo.zip

-
- - diff --git a/plugins/Svc_vi/VersionInfo.ico b/plugins/Svc_vi/VersionInfo.ico deleted file mode 100644 index b026d584c2..0000000000 Binary files a/plugins/Svc_vi/VersionInfo.ico and /dev/null differ diff --git a/plugins/Svc_vi/VersionInfo_10.vcxproj b/plugins/Svc_vi/VersionInfo_10.vcxproj deleted file mode 100644 index 89490b37fa..0000000000 --- a/plugins/Svc_vi/VersionInfo_10.vcxproj +++ /dev/null @@ -1,210 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - Svc_vi - {3CE5572B-B7B0-4D1C-9D10-4622FBA6198E} - - - - DynamicLibrary - Unicode - true - - - DynamicLibrary - Unicode - - - DynamicLibrary - true - Unicode - - - DynamicLibrary - Unicode - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(SolutionDir)$(Configuration)\Plugins\ - $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ - $(SolutionDir)$(Configuration)\Plugins\ - $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ - $(SolutionDir)$(Configuration)64\Plugins\ - $(SolutionDir)$(Configuration)64\Plugins\ - $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ - $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ - true - - - - Disabled - ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;VERSIONINFO_EXPORTS;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebugDLL - Level3 - EditAndContinue - 4996;%(DisableSpecificWarnings) - Use - common.h - - - _DEBUG;%(PreprocessorDefinitions) - ..\..\include\msapi - - - imagehlp.lib;%(AdditionalDependencies) - true - 0x25040000 - false - $(IntDir)$(TargetName).lib - Windows - $(SolutionDir)\lib - - - - - Full - OnlyExplicitInline - Size - ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;VERSIONINFO_EXPORTS;%(PreprocessorDefinitions) - true - true - Use - Level3 - 4996;%(DisableSpecificWarnings) - common.h - - - NDEBUG;%(PreprocessorDefinitions) - ..\..\include\msapi - - - imagehlp.lib;%(AdditionalDependencies) - true - true - true - 0x25040000 - false - $(IntDir)$(TargetName).lib - Windows - $(SolutionDir)\lib - - - - - ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - EnableFastChecks - MultiThreadedDebugDLL - Disabled - Use - common.h - WIN64;_DEBUG;_WINDOWS;_USRDLL;VERSIONINFO_EXPORTS;%(PreprocessorDefinitions) - Level3 - - - $(IntDir)$(TargetName).lib - imagehlp.lib;%(AdditionalDependencies) - true - Windows - 0x25040000 - false - $(SolutionDir)\lib - - - ..\..\include\msapi - _DEBUG;%(PreprocessorDefinitions) - - - - - ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - Full - OnlyExplicitInline - Size - Use - common.h - WIN64;NDEBUG;_WINDOWS;_USRDLL;VERSIONINFO_EXPORTS;%(PreprocessorDefinitions) - Level3 - true - true - - - $(IntDir)$(TargetName).lib - true - true - imagehlp.lib;%(AdditionalDependencies) - true - Windows - 0x25040000 - false - $(SolutionDir)\lib - - - ..\..\include\msapi - NDEBUG;%(PreprocessorDefinitions) - - - - - - - - - Create - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/plugins/Svc_vi/VersionInfo_10.vcxproj.filters b/plugins/Svc_vi/VersionInfo_10.vcxproj.filters deleted file mode 100644 index e0c4f5db2e..0000000000 --- a/plugins/Svc_vi/VersionInfo_10.vcxproj.filters +++ /dev/null @@ -1,67 +0,0 @@ - - - - - {0740347a-255e-4fb6-9e9a-14397010e8ad} - cpp;c;cxx;rc;def;r;odl;idl;hpj;bat - - - {691f667c-7c8a-4c3e-8990-a9b456b12230} - h;hpp;hxx;hm;inl - - - {b90941c8-389b-4c91-9298-f201b8740872} - ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - Resource Files - - - - - Resource Files - - - \ No newline at end of file diff --git a/plugins/Svc_vi/common.h b/plugins/Svc_vi/common.h deleted file mode 100644 index 3182abc660..0000000000 --- a/plugins/Svc_vi/common.h +++ /dev/null @@ -1,96 +0,0 @@ -/* -Version information plugin for Miranda IM - -Copyright © 2002-2006 Luca Santarelli, Cristian Libotean - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#ifndef M_VERSIONINFO_COMMON_H -#define M_VERSIONINFO_COMMON_H - -#pragma warning(disable:4005) -#define _CRT_SECURE_NO_DEPRECATE -#pragma warning(default:4005) - -#define VIPF_NONE 0x0000 -#define VIPF_UNCERTAIN 0x0010 - -#define VISF_FORUMSTYLE 0x0001 -#define VISF_SHOWUUID 0x0002 -#define VISF_SHOWFLAGS 0x0004 - -#include -#include - -#include -#include -#include -#include - -#include -//using namespace std; - -#include "version.h" - -#include "m_versioninfo.h" -#include "hooked_events.h" -#include "services.h" -#include "dlgHandlers.h" - -#include "newpluginapi.h" -#include "m_system.h" -#include "m_langpack.h" -#include "m_database.h" -#include "m_skin.h" -#include "m_clist.h" -#include "m_options.h" -#include "m_popup.h" - -#include "m_utils.h" -#include "m_folders.h" -#include "win2k.h" - -#include "utils.h" - -#ifndef MS_DB_GETPROFILEPATH_BASIC //db3xSA -#define MS_DB_GETPROFILEPATH_BASIC "DB/GetProfilePathBasic" -#endif - -//main.cpp -extern HINSTANCE hInst; - -//main.cpp -extern HICON hiVIIcon; - -//main.cpp -extern DWORD EnglishLocale; - -//for folders support -extern BOOL bFoldersAvailable; -extern HANDLE hOutputLocation; - -//services.cpp -extern int bServiceMode; - -//main.cpp -extern char ModuleName[]; -extern BOOL verbose; - -#define DEFAULT_UPLOAD_PORT 51234 - -const MUUID UUID_NULL = {0x00000000, 0x0000, 0x0000, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}; - -#endif \ No newline at end of file diff --git a/plugins/Svc_vi/dlgHandlers.cpp b/plugins/Svc_vi/dlgHandlers.cpp deleted file mode 100644 index a1a81e6a51..0000000000 --- a/plugins/Svc_vi/dlgHandlers.cpp +++ /dev/null @@ -1,589 +0,0 @@ -/* -Version information plugin for Miranda IM - -Copyright © 2002-2006 Luca Santarelli, Cristian Libotean - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "common.h" -#include "dlgHandlers.h" - -const char *szQuoteStrings[] = {"[quote] | [/quote]", "[code] | [/code]", ""}; -const char *szSizeStrings[] = {"[size=1] | [/size]", "[size=1px] | [/size]", "[size=12] | [/size]", "[size=80] | [/size]", ""}; -const char *szBoldStrings[] = {"[b] | [/b]", "[u] | [/u]", "[b][u] | [/u][/b]", " | ", " | ", " | "}; -const int nQuoteCount = SIZEOF(szQuoteStrings); //get the number of quote strings -const int nSizeCount = SIZEOF(szSizeStrings); //get the number of size strings -const int nBoldCount = SIZEOF(szBoldStrings); //get the number of bold strings - -#define MAX_TEXT 4096*4 - -int AddInfoToComboboxes(HWND hWnd, int nQuotesComboBox, int nSizesComboBox, int nBoldComboBox) -{ - int i; - for (i = 0; i < nQuoteCount; i++) - SendDlgItemMessageA(hWnd, nQuotesComboBox, CB_ADDSTRING, 0, (LPARAM) szQuoteStrings[i]); - - for (i = 0; i < nSizeCount; i++) - SendDlgItemMessageA(hWnd, nSizesComboBox, CB_ADDSTRING, 0, (LPARAM) szSizeStrings[i]); - - for (i = 0; i < nBoldCount; i++) - SendDlgItemMessageA(hWnd, nBoldComboBox, CB_ADDSTRING, 0, (LPARAM) szBoldStrings[i]); - - return 0; -} - -void EnableAskComboboxes(HWND hWnd, int bEnable) -{ - EnableWindow(GetDlgItem(hWnd, IDC_ASK_BOLDCOMBOBOX), bEnable); - EnableWindow(GetDlgItem(hWnd, IDC_ASK_QUOTECOMBOBOX), bEnable); - EnableWindow(GetDlgItem(hWnd, IDC_ASK_SIZECOMBOBOX), bEnable); -} - -INT_PTR CALLBACK AskDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - const int MAX_SIZE = 128; - static int oldFSFValue; - static TCHAR oldQuoteBegin[MAX_SIZE], oldQuoteEnd[MAX_SIZE]; - static TCHAR oldSizeBegin[MAX_SIZE], oldSizeEnd[MAX_SIZE]; - static TCHAR oldBoldBegin[MAX_SIZE], oldBoldEnd[MAX_SIZE]; - - switch (msg) { - case WM_INITDIALOG: - SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM) hiVIIcon); - - TranslateDialogDefault(hWnd); - - oldFSFValue = DBGetContactSettingByte(NULL, ModuleName, "ForumStyle", 1); - - AddInfoToComboboxes(hWnd, IDC_ASK_QUOTECOMBOBOX, IDC_ASK_SIZECOMBOBOX, IDC_ASK_BOLDCOMBOBOX); - - CheckDlgButton(hWnd, IDC_ASK_TODIALOGBOX, BST_CHECKED); - - CheckDlgButton(hWnd, IDC_ASK_FORUMSTYLE, (oldFSFValue) ? BST_CHECKED : BST_UNCHECKED); - EnableAskComboboxes(hWnd, oldFSFValue); - { - TCHAR buffer[1024]; - GetStringFromDatabase("QuoteBegin", _T("[quote]"), oldQuoteBegin, MAX_SIZE); - GetStringFromDatabase("QuoteEnd", _T("[/quote]"), oldQuoteEnd, MAX_SIZE); - mir_sntprintf(buffer, SIZEOF(buffer), _T("%s | %s"), oldQuoteBegin, oldQuoteEnd); - SendDlgItemMessage(hWnd, IDC_ASK_QUOTECOMBOBOX, CB_SELECTSTRING, -1, (LPARAM) buffer); - - GetStringFromDatabase("SizeBegin", _T("[size=1]"), oldSizeBegin, MAX_SIZE); - GetStringFromDatabase("SizeEnd", _T("[/size]"), oldSizeEnd, MAX_SIZE); - mir_sntprintf(buffer, SIZEOF(buffer), _T("%s | %s"), oldSizeBegin, oldSizeEnd); - SendDlgItemMessage(hWnd, IDC_ASK_SIZECOMBOBOX, CB_SELECTSTRING, -1, (LPARAM) buffer); - - GetStringFromDatabase("BoldBegin", _T("[b]"), oldBoldBegin, MAX_SIZE); - GetStringFromDatabase("BoldEnd", _T("[/b]"), oldBoldEnd, MAX_SIZE); - mir_sntprintf(buffer, SIZEOF(buffer), _T("%s | %s"), oldBoldBegin, oldBoldEnd); - SendDlgItemMessage(hWnd, IDC_ASK_BOLDCOMBOBOX, CB_SELECTSTRING, -1, (LPARAM) buffer); - } - - return TRUE; - - case WM_CLOSE: - DestroyWindow(hWnd); - break; - - case WM_COMMAND: - switch (LOWORD(wParam)) { - case IDC_ASK_FORUMSTYLE: - EnableAskComboboxes(hWnd, IsDlgButtonChecked(hWnd, IDC_ASK_FORUMSTYLE)); - break; - - case IDC_ASK_CANCEL: - DestroyWindow(hWnd); - break; - - case IDC_ASK_OK: - TCHAR quoteBegin[MAX_SIZE], quoteEnd[MAX_SIZE]; - TCHAR sizeBegin[MAX_SIZE], sizeEnd[MAX_SIZE]; - TCHAR boldBegin[MAX_SIZE], boldEnd[MAX_SIZE]; - TCHAR buffer[1024]; - - SendDlgItemMessage(hWnd, IDC_ASK_QUOTECOMBOBOX, WM_GETTEXT, SIZEOF(buffer), (LPARAM) buffer); - SplitStringInfo(buffer, quoteBegin, quoteEnd); - SendDlgItemMessage(hWnd, IDC_ASK_SIZECOMBOBOX, WM_GETTEXT, SIZEOF(buffer), (LPARAM) buffer); - SplitStringInfo(buffer, sizeBegin, sizeEnd); - SendDlgItemMessage(hWnd, IDC_ASK_BOLDCOMBOBOX, WM_GETTEXT, SIZEOF(buffer), (LPARAM) buffer); - SplitStringInfo(buffer, boldBegin, boldEnd); - - int newFSFValue = IsDlgButtonChecked(hWnd, IDC_ASK_FORUMSTYLE); - if (newFSFValue != oldFSFValue) - DBWriteContactSettingByte(NULL, ModuleName, "ForumStyle", newFSFValue); //temporary store the new value - - if (newFSFValue) { - DBWriteContactSettingTString(NULL, ModuleName, "QuoteBegin", quoteBegin); - DBWriteContactSettingTString(NULL, ModuleName, "QuoteEnd", quoteEnd); - - DBWriteContactSettingTString(NULL, ModuleName, "SizeBegin", sizeBegin); - DBWriteContactSettingTString(NULL, ModuleName, "SizeEnd", sizeEnd); - - DBWriteContactSettingTString(NULL, ModuleName, "BoldBegin", boldBegin); - DBWriteContactSettingTString(NULL, ModuleName, "BoldEnd", boldEnd); - } - - int debugTo = TO_DIALOGBOX; //just to be safe - if (IsDlgButtonChecked(hWnd, IDC_ASK_TOFILE)) - debugTo = TO_FILE; - if (IsDlgButtonChecked(hWnd, IDC_ASK_TOMESSAGEBOX)) - debugTo = TO_MESSAGEBOX; - if (IsDlgButtonChecked(hWnd, IDC_ASK_TODIALOGBOX)) - debugTo = TO_DIALOGBOX; - if (IsDlgButtonChecked(hWnd, IDC_ASK_TOOUTPUTDEBUGSTRING)) - debugTo = TO_DEBUGSTRING; - if (IsDlgButtonChecked(hWnd, IDC_ASK_TOCLIPBOARD)) - debugTo = TO_CLIPBOARD; - if (IsDlgButtonChecked(hWnd, IDC_ASK_TOUPLOAD)) - debugTo = TO_UPLOAD; - - DoDebugTo(debugTo); - - if (newFSFValue != oldFSFValue) - DBWriteContactSettingByte(NULL, ModuleName, "ForumStyle", oldFSFValue); - - if (newFSFValue) { - DBWriteContactSettingTString(NULL, ModuleName, "QuoteBegin", oldQuoteBegin); - DBWriteContactSettingTString(NULL, ModuleName, "QuoteEnd", oldQuoteEnd); - - DBWriteContactSettingTString(NULL, ModuleName, "SizeBegin", oldSizeBegin); - DBWriteContactSettingTString(NULL, ModuleName, "SizeEnd", oldSizeEnd); - - DBWriteContactSettingTString(NULL, ModuleName, "BoldBegin", oldBoldBegin); - DBWriteContactSettingTString(NULL, ModuleName, "BoldEnd", oldBoldEnd); - } - - DestroyWindow(hWnd); - break; - } - break; - } - return 0; -} - -int DoDebugTo(int debugTo) -{ - HWND parent = NULL; - HWND askDialog; - CVersionInfo myInfo;// = CVersionInfo(); - if (verbose) PUShowMessage("I am going to read the information.", SM_NOTIFY); - if (debugTo != TO_ASK) - myInfo.Initialize(); - - if (verbose) PUShowMessage("I have read the information, I will now print them.", SM_NOTIFY); - - switch(debugTo) { - case TO_ASK: - askDialog = CreateDialog(hInst, MAKEINTRESOURCE(IDD_ASKDIALOG), parent, AskDlgProc); - ShowWindow(askDialog, SW_SHOW); - break; - - case TO_FILE: - myInfo.PrintInformationsToFile(); - break; - - case TO_MESSAGEBOX: - myInfo.PrintInformationsToMessageBox(); - break; - - case TO_DIALOGBOX: - myInfo.PrintInformationsToDialogBox(); - break; - - case TO_DEBUGSTRING: - myInfo.PrintInformationsToOutputDebugString(); - break; - - case TO_CLIPBOARD: - myInfo.PrintInformationsToClipboard(true); - break; - - default: - myInfo.PrintInformationsToFile(); - break; - } - - if ((debugTo != TO_CLIPBOARD) && (DBGetContactSettingByte(NULL, ModuleName, "ClipboardAlways", FALSE))) - myInfo.PrintInformationsToClipboard(false); - - if ((bServiceMode) && (debugTo != TO_DIALOGBOX) && (debugTo != TO_ASK)) //close miranda if in service mode and no dialog was shown - PostQuitMessage(0); - - return 0; -} - -void EnableUploadSettings(HWND hWnd, int bEnable) -{ - EnableWindow(GetDlgItem(hWnd, IDC_UPLOAD_SERVER), bEnable); - EnableWindow(GetDlgItem(hWnd, IDC_UPLOAD_PORT), bEnable); - EnableWindow(GetDlgItem(hWnd, IDC_UPLOAD_USERNAME), bEnable); - EnableWindow(GetDlgItem(hWnd, IDC_UPLOAD_PASSWORD), bEnable); -} - -INT_PTR CALLBACK DlgProcOpts(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - static int bOptionsInitializing = 0; - switch(msg) { - case WM_INITDIALOG: - bOptionsInitializing = 1; - TranslateDialogDefault(hWnd); - AddInfoToComboboxes(hWnd, IDC_QUOTECOMBOBOX, IDC_SIZECOMBOBOX, IDC_BOLDCOMBOBOX); - - CheckDlgButton(hWnd, IDC_FORUMSTYLE, (BOOL) DBGetContactSettingByte(NULL, ModuleName, "ForumStyle", TRUE) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hWnd, IDC_DISABLEDTOO, (BOOL) DBGetContactSettingByte(NULL, ModuleName, "ShowInactive", TRUE) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hWnd, IDC_SHOWUUIDS, (BOOL) DBGetContactSettingByte(NULL, ModuleName, "ShowUUIDs", FALSE) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hWnd, IDC_SHOWINSTALLEDLANGUAGES, (BOOL) DBGetContactSettingByte(NULL, ModuleName, "ShowInstalledLanguages", FALSE) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hWnd, IDC_SUPPRESSHEADER, (BOOL) DBGetContactSettingByte(NULL, ModuleName, "SuppressHeader", TRUE) ? BST_CHECKED : BST_UNCHECKED); - - CheckDlgButton(hWnd, IDC_SHOWINTASKBAR, (BOOL) DBGetContactSettingByte(NULL, ModuleName, "ShowInTaskbar", TRUE) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hWnd, IDC_CLIPBOARDALSO, (BOOL) DBGetContactSettingByte(NULL, ModuleName, "ClipboardAlways", FALSE) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hWnd, IDC_BOLDVERSION, (BOOL) DBGetContactSettingByte(NULL, ModuleName, "BoldVersionNumber", TRUE) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hWnd, IDC_CHECKUNLOADABLE, (BOOL) DBGetContactSettingByte(NULL, ModuleName, "CheckForDependencies", TRUE) ? BST_CHECKED : BST_UNCHECKED); - SetFocus(GetDlgItem(hWnd, IDC_FORUMSTYLE)); - { - DBVARIANT dbv = { 0 }; - bOptionsInitializing = 1; - TCHAR buffer[1024]; - TCHAR notFound[1024]; - - if (DBGetContactSettingTString(NULL, ModuleName, "OutputFile", &dbv) == 0) - RelativePathToAbsolute(dbv.ptszVal, notFound, SIZEOF(notFound)); - else - RelativePathToAbsolute( _T("VersionInfo.txt"), notFound, SIZEOF(notFound)); - - if (bFoldersAvailable) - _tcscpy(buffer, TranslateT("Customize using folders plugin")); - else - _tcsncpy(buffer, notFound, SIZEOF(notFound)); - - SetDlgItemText(hWnd, IDC_FILENAME, buffer); - - TCHAR start[256], end[256]; - GetStringFromDatabase("QuoteBegin", _T("[quote]"), start, SIZEOF(start)); - GetStringFromDatabase("QuoteEnd", _T("[/quote]"), end, SIZEOF(end)); - mir_sntprintf(buffer, SIZEOF(buffer), _T("%s | %s"), start, end); - SendDlgItemMessage(hWnd, IDC_QUOTECOMBOBOX, CB_SELECTSTRING, -1, (LPARAM) buffer); - - GetStringFromDatabase("SizeBegin", _T("[size=1]"), start, SIZEOF(start)); - GetStringFromDatabase("SizeEnd", _T("[/size]"), end, SIZEOF(end)); - mir_sntprintf(buffer, SIZEOF(buffer), _T("%s | %s"), start, end); - SendDlgItemMessage(hWnd, IDC_SIZECOMBOBOX, CB_SELECTSTRING, -1, (LPARAM) buffer); - - GetStringFromDatabase("BoldBegin", _T("[b]"), start, SIZEOF(start)); - GetStringFromDatabase("BoldEnd", _T("[/b]"), end, SIZEOF(end)); - mir_sntprintf(buffer, SIZEOF(buffer), _T("%s | %s"), start, end); - SendDlgItemMessage(hWnd, IDC_BOLDCOMBOBOX, CB_SELECTSTRING, -1, (LPARAM) buffer); - //to add stuff - - //upload server settings - GetStringFromDatabase("UploadServer", _T("vi.cass.cz"), buffer, SIZEOF(buffer)); - SetWindowText(GetDlgItem(hWnd, IDC_UPLOAD_SERVER), buffer); - - int port = DBGetContactSettingWord(NULL, ModuleName, "UploadPort", DEFAULT_UPLOAD_PORT); - _itot(port, buffer, 10); - SetWindowText(GetDlgItem(hWnd, IDC_UPLOAD_PORT), buffer); - - GetStringFromDatabase("UploadUser", _T(""), buffer, SIZEOF(buffer)); - SetWindowText(GetDlgItem(hWnd, IDC_UPLOAD_USERNAME), buffer); - - GetStringFromDatabase("UploadPassword", _T(""), buffer, SIZEOF(buffer)); - CallService(MS_DB_CRYPT_DECODESTRING, SIZEOF(buffer), (LPARAM) buffer); - SetWindowText(GetDlgItem(hWnd, IDC_UPLOAD_PASSWORD), buffer); - } - - switch(DBGetContactSettingByte(NULL, ModuleName, "DebugTo", TO_DIALOGBOX)) { - case TO_FILE: - CheckDlgButton(hWnd, IDC_TOFILE, BST_CHECKED); - break; - - case TO_MESSAGEBOX: - CheckDlgButton(hWnd, IDC_TOMESSAGEBOX, BST_CHECKED); - break; - - case TO_DIALOGBOX: - CheckDlgButton(hWnd, IDC_TODIALOGBOX, BST_CHECKED); - break; - - case TO_DEBUGSTRING: - CheckDlgButton(hWnd, IDC_TODEBUGSTRING, BST_CHECKED); - break; - - case TO_CLIPBOARD: - CheckDlgButton(hWnd, IDC_TOCLIPBOARD, BST_CHECKED); - break; - - case TO_UPLOAD: - CheckDlgButton(hWnd, IDC_TOUPLOAD, BST_CHECKED); - break; - - case TO_ASK: - CheckDlgButton(hWnd, IDC_ASKEVERYTIME, BST_CHECKED); - break; - - default: - CheckDlgButton(hWnd, IDC_TODIALOGBOX, BST_CHECKED); - break; - } - - EnableWindow(GetDlgItem(hWnd, IDC_QUOTECOMBOBOX), IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE) ? TRUE : FALSE); //forum style only - EnableWindow(GetDlgItem(hWnd, IDC_SIZECOMBOBOX), IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE) ? TRUE : FALSE); //forum style only - EnableWindow(GetDlgItem(hWnd, IDC_BOLDVERSION), IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE) ? TRUE : FALSE); //forum style only - EnableWindow(GetDlgItem(hWnd, IDC_BOLDCOMBOBOX), (IsDlgButtonChecked(hWnd, IDC_BOLDVERSION) & IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE)) ? TRUE : FALSE);//both forum style and bold version checked - EnableWindow(GetDlgItem(hWnd, IDC_SHOWINTASKBAR), IsDlgButtonChecked(hWnd, IDC_TODIALOGBOX) ? TRUE : FALSE); //only enable for to dialog box - EnableWindow(GetDlgItem(hWnd, IDC_DISABLEDTOO), IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE) ? FALSE : TRUE); //if forum style disable show disabled plugins - EnableWindow(GetDlgItem(hWnd, IDC_CLIPBOARDALSO), IsDlgButtonChecked(hWnd, IDC_TOCLIPBOARD) ? FALSE : TRUE); //don't enable always clipboard if we're printing to clipboard - EnableWindow(GetDlgItem(hWnd, IDC_FILENAME), ((IsDlgButtonChecked(hWnd, IDC_TOFILE)) && (!bFoldersAvailable)) ? TRUE : FALSE); - EnableUploadSettings(hWnd, IsDlgButtonChecked(hWnd, IDC_TOUPLOAD) ? TRUE : FALSE); - { - OSVERSIONINFO osvi = { 0 }; - osvi.dwOSVersionInfoSize = sizeof(osvi); - GetVersionEx(&osvi); - - if (osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) - EnableWindow(GetDlgItem(hWnd, IDC_CHECKUNLOADABLE), FALSE); - } - - CheckDlgButton(hWnd, IDC_DEBUG, (BOOL) verbose == TRUE ? BST_CHECKED : BST_UNCHECKED); - - SetFocus(GetDlgItem(hWnd, IDC_GETINFONOW)); - - bOptionsInitializing = 0; - break; - - case WM_COMMAND: - switch(LOWORD(wParam)) { - case IDC_ASKEVERYTIME: - case IDC_TOFILE: - case IDC_TOMESSAGEBOX: - case IDC_TODIALOGBOX: - case IDC_TODEBUGSTRING: - case IDC_TOCLIPBOARD: - case IDC_TOUPLOAD: - case IDC_FORUMSTYLE: - case IDC_BOLDVERSION: - EnableWindow(GetDlgItem(hWnd, IDC_QUOTECOMBOBOX), IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE) ? TRUE : FALSE); //forum style only - EnableWindow(GetDlgItem(hWnd, IDC_SIZECOMBOBOX), IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE) ? TRUE : FALSE); //forum style only - EnableWindow(GetDlgItem(hWnd, IDC_BOLDVERSION), IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE) ? TRUE : FALSE); //forum style only - EnableWindow(GetDlgItem(hWnd, IDC_BOLDCOMBOBOX), (IsDlgButtonChecked(hWnd, IDC_BOLDVERSION) & IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE)) ? TRUE : FALSE); //both forum style and bold version checked - EnableWindow(GetDlgItem(hWnd, IDC_FILENAME), ((IsDlgButtonChecked(hWnd, IDC_TOFILE)) && (!bFoldersAvailable)) ? TRUE : FALSE); - EnableWindow(GetDlgItem(hWnd, IDC_SHOWINTASKBAR), IsDlgButtonChecked(hWnd, IDC_TODIALOGBOX) ? TRUE : FALSE); //only enable for to dialog box - EnableWindow(GetDlgItem(hWnd, IDC_DISABLEDTOO), IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE) ? FALSE : TRUE); //if forum style disable show disabled plugins - EnableWindow(GetDlgItem(hWnd, IDC_CLIPBOARDALSO), IsDlgButtonChecked(hWnd, IDC_TOCLIPBOARD) ? FALSE : TRUE); //don't enable always clipboard if we're printing to clipboard - EnableUploadSettings(hWnd, IsDlgButtonChecked(hWnd, IDC_TOUPLOAD) ? TRUE : FALSE); - - case IDC_SHOWUUIDS: - if (IsDlgButtonChecked(hWnd, IDC_SHOWUUIDS) && MessageBox(hWnd, - TranslateT("Are you sure you want to enable this option ?\nPlease only enable this option if you really know what you're doing and what the option is for or if someone asked you to do it."), - TranslateT("Show plugin UUIDs ?"), MB_YESNO | MB_ICONWARNING) == IDNO) - { - CheckDlgButton(hWnd, IDC_SHOWUUIDS, FALSE); - - break; - }//else fallthrough - case IDC_DISABLEDTOO: - case IDC_SHOWINTASKBAR: - case IDC_CLIPBOARDALSO: - case IDC_CHECKUNLOADABLE: - case IDC_SUPPRESSHEADER: - case IDC_SHOWINSTALLEDLANGUAGES: - EnableWindow(GetDlgItem(hWnd, IDC_GETINFONOW), FALSE); - - case IDC_QUOTECOMBOBOX: - case IDC_SIZECOMBOBOX: - case IDC_BOLDCOMBOBOX: - if (!bOptionsInitializing) - SendMessage(GetParent(hWnd), PSM_CHANGED,0,0); - break; - - case IDC_FILENAME: - case IDC_UPLOAD_USERNAME: - case IDC_UPLOAD_PASSWORD: - case IDC_UPLOAD_PORT: - case IDC_UPLOAD_SERVER: - if ( HIWORD(wParam) == EN_CHANGE && !bOptionsInitializing) { - SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0); - EnableWindow(GetDlgItem(hWnd, IDC_GETINFONOW), FALSE); - } - break; - - case IDC_GETINFONOW: - //Call the plugin menu command routine. - PluginMenuCommand(0,0); - break; - - case IDC_DEBUG: - verbose = !verbose; - break; - } - - break; - - case WM_NOTIFY: - switch(((LPNMHDR)lParam)->idFrom) { - case 0: - switch (((LPNMHDR)lParam)->code) { - case PSN_APPLY: - { - TCHAR buffer[1024]; - TCHAR start[256], end[256]; - SendDlgItemMessage(hWnd, IDC_QUOTECOMBOBOX, WM_GETTEXT, SIZEOF(buffer), (LPARAM) buffer); - SplitStringInfo(buffer, start, end); - DBWriteContactSettingTString(NULL, ModuleName, "QuoteBegin", start); - DBWriteContactSettingTString(NULL, ModuleName, "QuoteEnd", end); - SendDlgItemMessage(hWnd, IDC_SIZECOMBOBOX, WM_GETTEXT, SIZEOF(buffer), (LPARAM) buffer); - SplitStringInfo(buffer, start, end); - DBWriteContactSettingTString(NULL, ModuleName, "SizeBegin", start); - DBWriteContactSettingTString(NULL, ModuleName, "SizeEnd", end); - SendDlgItemMessage(hWnd, IDC_BOLDCOMBOBOX, WM_GETTEXT, SIZEOF(buffer), (LPARAM) buffer); - SplitStringInfo(buffer, start, end); - DBWriteContactSettingTString(NULL, ModuleName, "BoldBegin", start); - DBWriteContactSettingTString(NULL, ModuleName, "BoldEnd", end); - } - - DBWriteContactSettingByte(NULL, ModuleName, "CheckForDependencies", IsDlgButtonChecked(hWnd, IDC_CHECKUNLOADABLE) ? TRUE : FALSE); - DBWriteContactSettingByte(NULL, ModuleName, "BoldVersionNumber", IsDlgButtonChecked(hWnd, IDC_BOLDVERSION) ? TRUE : FALSE); - DBWriteContactSettingByte(NULL, ModuleName, "ForumStyle", IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE) ? TRUE : FALSE); - DBWriteContactSettingByte(NULL, ModuleName, "ClipboardAlways", IsDlgButtonChecked(hWnd, IDC_CLIPBOARDALSO) ? TRUE : FALSE); - DBWriteContactSettingByte(NULL, ModuleName, "SuppressHeader", IsDlgButtonChecked(hWnd, IDC_SUPPRESSHEADER) ? TRUE : FALSE); - DBWriteContactSettingByte(NULL, ModuleName, "ShowUUIDs", IsDlgButtonChecked(hWnd, IDC_SHOWUUIDS) ? TRUE : FALSE); - DBWriteContactSettingByte(NULL, ModuleName, "ShowInstalledLanguages", IsDlgButtonChecked(hWnd, IDC_SHOWINSTALLEDLANGUAGES) ? TRUE : FALSE); - - if (!bFoldersAvailable) { - TCHAR filePath[MAX_PATH], fileName[MAX_PATH]; - GetDlgItemText(hWnd, IDC_FILENAME, fileName, MAX_PATH); - AbsolutePathToRelative(fileName, filePath, SIZEOF(filePath)); - - DBWriteContactSettingTString(NULL, ModuleName, "OutputFile", filePath); //store relative path - } - DBWriteContactSettingByte(NULL, ModuleName, "ShowInTaskbar", IsDlgButtonChecked(hWnd, IDC_SHOWINTASKBAR) ? TRUE : FALSE); - //Debug to: - if (IsDlgButtonChecked(hWnd, IDC_TOFILE)) - DBWriteContactSettingByte(NULL, ModuleName, "DebugTo", TO_FILE); - else if (IsDlgButtonChecked(hWnd, IDC_TOMESSAGEBOX)) - DBWriteContactSettingByte(NULL, ModuleName, "DebugTo", TO_MESSAGEBOX); - else if (IsDlgButtonChecked(hWnd, IDC_TODIALOGBOX)) - DBWriteContactSettingByte(NULL, ModuleName, "DebugTo", TO_DIALOGBOX); - else if (IsDlgButtonChecked(hWnd, IDC_TODEBUGSTRING)) - DBWriteContactSettingByte(NULL, ModuleName, "DebugTo", TO_DEBUGSTRING); - else if (IsDlgButtonChecked(hWnd, IDC_TOCLIPBOARD)) - DBWriteContactSettingByte(NULL, ModuleName, "DebugTo", TO_CLIPBOARD); - else if (IsDlgButtonChecked(hWnd, IDC_TOUPLOAD)) - DBWriteContactSettingByte(NULL, ModuleName, "DebugTo", TO_UPLOAD); - else if (IsDlgButtonChecked(hWnd, IDC_ASKEVERYTIME)) - DBWriteContactSettingByte(NULL, ModuleName, "DebugTo", TO_ASK); - - EnableWindow(GetDlgItem(hWnd, IDC_GETINFONOW), TRUE); - //Disabled plugins too? - DBWriteContactSettingByte(NULL, ModuleName, "ShowInactive", IsDlgButtonChecked(hWnd, IDC_DISABLEDTOO)?TRUE:FALSE); - - GetStringFromDatabase("UUIDCharMark", _T(DEF_UUID_CHARMARK), PLUGIN_UUID_MARK, cPLUGIN_UUID_MARK); - } } - - break; - } - return 0; -} - -INT_PTR CALLBACK DialogBoxProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - static CVersionInfo *myInfo = NULL; - switch(msg) { - case WM_INITDIALOG: - SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM) hiVIIcon); - - myInfo = (CVersionInfo *) lParam; - if (DBGetContactSettingByte(NULL, ModuleName, "ShowInTaskbar", TRUE)) { - DWORD ws; - ws = GetWindowLongPtr(hWnd, GWL_EXSTYLE); - SetWindowLongPtr(hWnd, GWL_EXSTYLE, ws | WS_EX_APPWINDOW); - //SetWindowLongPtr(hWnd, GWL_STYLE, ws | WS_DLGFRAME | WS_POPUPWINDOW); - } - - TranslateDialogDefault(hWnd); - { - DBVARIANT dbv = { 0 }; - LOGFONT lf = { 0 }; - - dbv.type = DBVT_BLOB; - if (DBGetContactSetting(NULL, "OptionFont", "Font", &dbv) == 0) - lf=*(LOGFONT*)dbv.pbVal; - else { - HFONT hFont = (HFONT)SendDlgItemMessage(hWnd,IDC_CLOSE,WM_GETFONT,0,0); - GetObject(hFont,sizeof(lf),&lf); - } - SendDlgItemMessage(hWnd,IDC_TEXT,WM_SETFONT,(WPARAM)CreateFontIndirect(&lf),0); - } - - return TRUE; - - case WM_CLOSE: - DestroyWindow(hWnd); - break; - - case WM_COMMAND: { - switch(LOWORD(wParam)) { - case IDC_CLOSE: - DestroyWindow(hWnd); - break; - - case IDC_COPYTEXT: - SetLastError(0); - if (GetOpenClipboardWindow()) - Log( TranslateT("The clipboard is not available, retry.")); - else { - OpenClipboard(hWnd); - //Ok, let's begin, then. - EmptyClipboard(); - //Storage data we'll use. - TCHAR text[MAX_TEXT]; - LPTSTR lptstrCopy; - GetDlgItemText(hWnd, IDC_TEXT, text, MAX_TEXT); - int length = lstrlen(text) + 1; - HANDLE hData = GlobalAlloc(GMEM_MOVEABLE, (length + 5)*sizeof( TCHAR )); - //Lock memory, copy it, release it. - lptstrCopy = (LPTSTR)GlobalLock(hData); - lstrcpyn(lptstrCopy, text, length); - lptstrCopy[length] = '\0'; - GlobalUnlock(hData); - //Now set the clipboard data. - - SetClipboardData(CF_UNICODETEXT, hData); - - //Remove the lock on the clipboard. - CloseClipboard(); - } - - break; - - case IDC_SAVETOFILE: - TCHAR text[MAX_TEXT]; - GetDlgItemText(hWnd, IDC_TEXT, text, MAX_TEXT); - myInfo->PrintInformationsToFile(text); - break; - } - - break; - } - case WM_DESTROY: - DeleteObject((HFONT)SendDlgItemMessage(hWnd,IDC_TEXT,WM_GETFONT,0,0)); - myInfo = NULL; - if (bServiceMode) //close miranda if in service mode - PostQuitMessage(0); - - break; - } - return 0; -} diff --git a/plugins/Svc_vi/dlgHandlers.h b/plugins/Svc_vi/dlgHandlers.h deleted file mode 100644 index bab1876ea2..0000000000 --- a/plugins/Svc_vi/dlgHandlers.h +++ /dev/null @@ -1,43 +0,0 @@ -/* -Version information plugin for Miranda IM - -Copyright © 2002-2006 Luca Santarelli, Cristian Libotean - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#ifndef M_VERSIONINFO_DLGHEADERS_H -#define M_VERSIONINFO_DLGHEADERS_H - -#include "resource.h" -#include "CVersionInfo.h" - -#define TO_ASK 0 -#define TO_FILE 1 -#define TO_MESSAGEBOX 2 -#define TO_DIALOGBOX 3 -#define TO_DEBUGSTRING 4 -#define TO_CLIPBOARD 5 -#define TO_UPLOAD 6 - -extern INT_PTR PluginMenuCommand(WPARAM, LPARAM); -extern INT_PTR OptionsInitialise(WPARAM, LPARAM); - - -int DoDebugTo(int debugTo); -INT_PTR CALLBACK AskDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); -INT_PTR CALLBACK DlgProcOpts(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); -INT_PTR CALLBACK DialogBoxProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); -#endif \ No newline at end of file diff --git a/plugins/Svc_vi/docs/readme_versioninfo.txt b/plugins/Svc_vi/docs/readme_versioninfo.txt deleted file mode 100644 index 8a7d49fe7a..0000000000 --- a/plugins/Svc_vi/docs/readme_versioninfo.txt +++ /dev/null @@ -1,433 +0,0 @@ -VersionInfo, v.1.4.3.4 - by Luca "Hrk" Santarelli, Cristian Libotean - hrk@users.sf.net, eblis102@yahoo.com - Thanks go to: StormLord, Cyreve, Strickz, Wintime98 - All of them helped me somehow. - -- INFO - - -Hi :-) - -This plugin is born from a feature request on the Open Discussion forum. -Its purpose is to display some informations related to Miranda and to the OS -so that you can copy/paste them in a bug report. - -Remember: submitting a bug report DOES NOT mean that it will be fixed. -You need to check the bug report because developers may need your cooperation, -testing debug builds or making other tests. - -The displayed informations are: -§ Date/Time of report -§ System cpu type -§ OS name and version (major, minor, build, additional data) -§ Installed RAM -§ Miranda version, being it or not a nightly and/or unicode. -§ List of enabled plugins (filename, short name, version and last modified date) -§ List of disabled plugins (filename, short name, version and last modified date). Optional. - - -- USE - - -!!! For bugs and/or suggestions please email me, eblis102@yahoo.com (please don't spam hrk as -he's not working on this anymore). - -Click on the button in the main menu or the one in the options... and you're done. -You can choose where to debug: text file, message box (no copy/paste), dialog -box (copy/paste), OutputDebugString(), Clipboard directly. You can also check to print -to clipboard while printing to any of the other options (except clipboard, of course :) ) - - -- CHANGES - - -+ : new feature -* : changed -! : bufgix -- : feature removed or disabled because of pending bugs - -v. 1.4.3.4 - 2009/11/13 - + x64 support (not tested !!) - -v.1.4.3.3 - 2008/02/15 - ! Plugins that do not have the extension .dll will not be listed anymore - -v.1.4.3.2 - 2008/01/31 - * Report plugins without UUIDs in Miranda 0.8 #9 or later as Unloadable instead of Inactive - -v.1.4.3.1 - 2008/01/30 - * When in service mode enable showing of disabled plugins if 'forum style formatting' is disabled, regardless if the option to show disabled plugins in the options is checked or not. - ! Ignore case when checking dll name. - -v.1.4.3.0 - 2008/01/29 - * Show messages using a popup if a popup plugin is available - + Added service mode functionality - requires miranda 0.8 #9 or later. - WARNING: Please rename the plugin back to svc_vi.dll if you're using Updater to update your plugins. - -v.1.4.2.7 - 2008/01/25 - ! Fixed crash when displaying information for unloadable plugins - -v.1.4.2.6 - 2008/01/24 - * Changed beta versions server. - -v.1.4.2.5 - 2007/10/24 - + Added profile path to VersionInfo report. - -v.1.4.2.4 - 2007/09/26 - * Show warning message when user tries to activate 'Show plugin UUIDs' option. - -v.1.4.2.3 - 2007/07/25 - ! Fixed time zone offset calculation. - ! Fixed negative time zones display. - -v.1.4.2.2 - 2007/07/24 - + Added time zone information for profile creation date and language pack modified date. - -v.1.4.2.1 - 2007/06/22 - * Show menu item is always checked (to disable use the menu editor). - * Enabled unicode flag since plugin is 2in1. - -v.1.4.2.0 - 2007/06/22 - * Show UUIDs checkbox is now visible only when 'show expert options' is checked. - * Added checkbox to enable/disable showing installed languages - visible only when 'show expert options' is checked. - -v.1.4.1.5 - 2007/06/21 - * Removed installed languages info from report (still available using the hidden setting 'ShowInstalledLanguages') - -v 1.4.1.4 - 2007/05/11 - ! Show more than 2g of memory if available. - -v. 1.4.1.3 - 2007/03/27 - * Fix for database plugins returning non standard profile path (dbxSA). - -v. 1.4.1.2 - 2007/03/22 - ! Fix Unicode plugin detection. - -v. 1.4.1.1 - 2007/03/07 - + Added icon to output dialog window. - * Make 'Customize using folders plugin' translatable. - -v. 1.4.1.0 - 2007/03/07 - * Changed plugin UUID ( {2f174488-489c-4fe1-940d-596cf0f35e65} ). - + Added VERSIONINFO interface. - -v. 1.4.0.4 - 2007/03/06 - + Option to show UUID info. - + Added VI UUID. - + Added hidden setting to change the character shown if plugin has a UUID defined (UUIDCharMark). - ! Do not enable Apply when first entering the options. - -v. 1.4.0.3 - 2007/02/12 - + Read plugin Unicode aware flag. Only shown if plugin name doesn't contain 'unicode' or '2in1'. - -v. 1.4.0.2 - 2007/01/31 - * Changed beta URL. - -v. 1.4.0.1 - 2007/01/28 - + Added InternetExplorer version - -v. 1.4.0.0 - 2007/01/28 - + Added Windows shell information. - ! Fix for profile creation date and size on Windows 98 - -v. 1.3.2.2 - 2007/01/07 - + New version resource file. - + Added OS languages info: {User UI language/}System UI language | Current user locale/System locale [available system languages]. User UI language is not available for Windows 95, 98, Me and NT. - + Folders support. - ! Close thread handle. - -v. 1.3.2.1 - 2006/12/07 - * Changed controls tab order. - -v. 1.3.2.0 - 2006/11/26 - * Reorganised the post a bit. - + Added empty blockquote style. - ! Fixed version number highlighting. - + Added dll version info. - -v. 1.3.1.1 - 2006/11/15 - * "Ask every time", not "Ask everytime" :) - + Added administrator privileges information. - + Added "Save to file" button to dialog. - * Disabled the "Upload" button. - -v. 1.3.1.0 - 2006/11/1 - + Added multiple CPUs info. - + Added WOW64 info. - ! Don't get plugin information twice. - * Moved main menu entry near Help. - * Default output location changed to dialog. - -v. 1.3.0.4 - 2006/10/16 - * Made langpack retrieval more robust. - + Show langpack info. - * No more dependency on winsock2 (removed upload feature for now, support isn't available anyway) - -v. 1.3.0.1 - 2006/09/25 - + Updater support (beta versions) - ! Enable the Apply button when combobox items are changed. - + Added quote, size and bold comboboxes to ask dialog. - * Sections now use the same highlighting method as the plugins. - * Changed text displayed when plugins don't want to load with current Miranda version. - -v. 1.3.0.0 - 2006/08/08 - * Use relative paths. The file path in the options will show as absolute but it's saved in the database as relative - uses the services in m_utils.h. - + New versioninfo icon - thanks Faith Healer. - + Option to automatically upload VI post to vi.cass.cz :) - currently there's no support on the site for it - + Show plugins that fail to load for unknown reasons. - * Use mir_snprintf where possible. - + Added checkbox for forum style formatting in ask dialog. - * Changed plugin section to "Services" - -v. 1.2.0.4 - 2006/07/26 - * 'Attempt to find unloadable plugins' is checked by default now and is grayed out on Win 98. - + Added check for Windows 2003 R2. - -v. 1.2.0.3 - 2006/06/01 - + Added a service to get the VersionInfo post as a string. - -v. 1.2.0.2 - 2006/05/20 - ! Fixed a bug when notifing of errors - thanks for the patch Peter (UnregistereD). - -v. 1.2.0.1 - 2006/05/17 - * People reported they don't have PF_NX_ENABLED defined so i created a workaround for those who want to build VI from sources. - ! Destroy services the proper way. - -v. 1.2.0.0 - 2006/05/01 - + Added DEP information. - * Show message if CPU doesn't recognize cpuid extension. - -v. 1.0.1.19 - 2006/03/23 - ! Fixed "Do it now" being disabled when first entering the options window. - -v. 1.0.1.18 - 2006/03/09 - + Added a new size option for phpBB forums. - + Added a new highlight option (bold and underline). - + Added a new option to suppress header and footer information - will make the post a bit smaller. - ! Fixed a bug when information was copied to clipboard. - -v. 1.0.1.17 - 2006/01/01 - + Added check to find out plugin information for plugins that refuse to load. - ! Fixed a new line issue (happened when Unloadable plugins entry was visible). - -v. 1.0.1.16 - 2006/01/31 - * Removed the static edge from the dialog buttons. - + Added check for plugins that refuse to load. - * Updated the translation strings. - -v. 1.0.1.15 - 2005/10/17 - + Added some hidden beautification settings. You need to use dbeditor to add these settings to - VersionInfo. All settings are strings and they should either be bbcodes or html codes. (do a default - output for an example). Check the changes in version 1.0.1.14 to see how you can activate this output. - ~ BeautifyHorizLine - code for a horizontal line - (default:
) - ~ BeautifyBlockStart - code for a blockquote (start code) that separates the hw and miranda settings from the plugins - (default:
) - ~ BeautifyBlockEnd - code for a blockquote (end code) that separates the hw and miranda settings from the plugins - (default:
) - ~ BeautifyActiveHeaderBegin - code for the font and size of the active header text (start code) - (default: ) - ~ BeautifyActiveHeaderEnd - code for the font and size of the active header text (end code) - (default: ) - ~ BeautifyInactiveHeaderBegin - code for the font and size of the inactive header text (start code) - (default: ) - ~ BeautifyInactiveHeaderEnd - code for the font and size of the inactive header text (end code) - (default: ) - ~ BeautifyUnloadableHeaderBegin - code for the font and size of the unloadable header text (start code) - (default: ) - ~ BeautifyUnloadableHeaderEnd - code for the font and size of the unloadable header text (end code) - (default: ) - ~ BeautifyPluginsBegin - code for the font and size of plugins (start code) - (default: ) - ~ BeautifyPluginsEnd - code for the font and size of plugins (end code) - (default: ) - How it works: - $starting info [Miranda IM ... Miranda's homepage ... Miranda tools] - {Horizontal line}{block start}Report generated at: $date - $hardware, os and miranda settings - {block end}{horizontal line}{active header start}Active Plugins (#):{active header end} - {plugins start} - $plugins - {plugins end}{horizontal line}{inactive header start}Inactive Plugins (#):{inactive header end} - {plugins start} - $plugins - {plugins end}{horizontal line}{unloadable header start}Unloadable Plugins (#):{unloadable header end} - {plugins start} - $plugins - {plugins end}{horizontal line} - $end info [End of report ...] - -v. 1.0.1.14 - 2005/10/16 - - Removed the logging functions used when attempting to find an unloadable plugin. - + Added hidden option to beautify the output. You need to use dbeditor and add a new - byte value to VersionInfo called Beautify and set it to 1 for the setting to take effect. - Forum style formatting must be OFF; although forum style is unchecked it will get the - highlighting information from the appropriate checkbox so be sure to set it - accordingly (usually to or . The formatting is hardcoded at the moment - (it's set to html tags), i might add some strings in the database for it later on. - + Added option to select how to highlight version number; currently you can - select from bold or underline. - -v. 1.0.1.13 - 2005/10/14 - + Added option to ask where to print the output. - -v. 1.0.1.12 - 2005/10/06 - * Changed the way versioninfo scans for enabled/disabled plugins. - Now it should be able to detect even plugin that were reported as inactive before (like aim toc2 and clist_nicerW+) - + Added profile size and creation date. - + Added information about missing statically linked dll files. Use with care, might crash miranda on some systems. - This function might not work (correctly) on windows 98 and below. If you check this option a file named - 'versioninfo.log' will appear in miranda's folder; in case of a crash please post this info in the forums - (thread Plugins->Versioninfo format style) using [code][/code] bbcodes. - -v. 1.0.1.11 - 2005/09/24 - + Added option to print version number in bold or not. - + Added [code] bbcode and empty size field (if the forum doesn't strip other bbcodes from inside a [code]) - -v. 1.0.1.10 - 2005/09/25 - ! Fixed issue that prevented the apply button to be enabled when changing the filename. - + Added options to select forum bbcodes. - -v. 1.0.1.9 - 2005/09/22 :) - + Added a new CPU check. Might be unstable and can't detect very old processors (like pentium mmx) - * Changed hidden settings strings to QuoteBegin, QuoteEnd, SizeBegin, SizeEnd. - ! Fixed updater issue - older versions should be detected as well (thanks sje). Plugin should - comply with updater rules from now on. - -v. 1.0.1.8 - 2005/09/22 - * Changed month number to month short name (english locale) - + Added "hidden" settings for 'quote' and 'size' strings (only valid when using forum style formatting). - You need to use dbeditor++ to add these. - "QuoteHeader" - String value containing the starting quote string. - You can use this if you want to change the "[quote]" string to "[code]" for example. - If the setting is not present it reverts to "[quote]" - "SizeHeader" - String value containing the starting size string. - You should use this if the forum software doesn't recognize "[size=1]" and needs - something like "[size=1px]". If the setting is not present it reverts to "[size=1]". - "QuoteFooter" - String value containing the ending quote string. If the setting is not present it reverts to "[/quote]" - "SizeFooter" - String value containing the ending size string. If the setting is not present it reverts to "[/size]" - !If you change the header for one of these don't forget to change the footer as well (and vice versa). - + When using forum style formatting the version number will be bold. - + Added active and inactive plugins count (it can't hurt :) ) - -v. 1.0.1.7 - 2005/09/21 - ! Fixed double enter issue - ! Fixed unicode detection problem - - -1.0.1.6 - 2005/09/11 - * Changed miranda's homepage from 'http://miranda-icq.sourceforge.net/' to 'miranda-im.org' - * Changed miranda tools link. - * Changed some strings (date and time related). - + Added check for unicode core. - + Added miranda path to versioninfo output. - + Added plugin's last modified date to versioninfo output. - + Added plugin's short name to versioninfo output. - + Added os check for windows 2003. - + Added option to show information window in taskbar - + Added option to always copy to clipboard - + Added CPU info - Should still work with amd 64 (unsure) - -1.0.1.5 * Works on AMD64 now. - * Fixed some typos in the text and URLs. - * Changed some default settings. - -1.0.1.4 * Fixed the crashes when a .dll file was found but was not a plugin. - * Filesize somehow increased to 80KB... don't ask me why. - + Added support for MirandaInstaller/Wassup by Tornado. - -1.0.1.3 * No change at all, but it now works for everyone. Don't ask me how. - -1.0.1.2 * Fixed NT detection. - * Fixed click on X button in dialogbox. - -1.0.1.1 * Changed the option page UI to reflect Miranda's one and to have a - more intuitive usage. - * Size has increased, but there's not anymore the need for that - external DLL. :-) - -1.0.1.0 + Added "DialogBox" as output (Cyreve, Stormlord, myself) - + Added "OutputDebugString()" as output - + Added "Clipboard" as output - + Added the missing button in the options - + Added a cool icon - + Added OS name (Wintime98, myself) - + Added Miranda build time (Wintime98) - + Added free disk space on Miranda partition (Stormlord, myself) - * Changed "Debug to:" to "Output to:" because of its meaning - -1.0.0.0 First release. - DialogBox is not yet selectable. - Developers, read the REBASE information. - - -- TRANSLATION - - -The strings you can translate are these: - -for version 1.4.2.4 -;Plugin description: -;[Collects and prints information related to Miranda, the plugins and the OS.] -; -;Option dialog -;[Plugins] -;[Version Information] -;[Output to:] -;[Text file] -;[MessageBox()] -;[DialogBox] -;[Show window in taskbar] -;[OutputDebugString()] -;[Clipboard] -;[Upload to site] -;[Ask every time] -;[Also copy info to clipboard] -;[Forum style formatting] -;[Highlight version number using] -;[Show disabled plugins too] -;[Show plugin UUIDs] -;[Attempt to find unloadable plugins (doesn't work on Windows 98)] -;[Suppress header information] -;[Add a menu item to the main Miranda Menu] -;[You will need to restart Miranda to add/remove the menu item.] -;[Do it now] -;[Upload site settings] -;[Username] -;[Password] -;[Customize using folders plugin] -;[Are you sure you want to enable this option ?\nPlease only enable this option if you really know what you're doing and what the option is for or if someone asked you to do it.] -;[Show plugin UUIDs ?] -; -;Dialog box -;[Upload] -;[Close] -;[Copy text] -; -;Miscellanea -;[If you are going to use this report to submit a bug, remember to check the website for questions or help the developers may need.\r\nIf you don't check your bug report and give feedback, it will not be fixed!] -;[Information successfully written to file: \"%s\".] -;[Error during the creation of file \"%s\". Disk may be full or write protected.] - -;[Ok, something went wrong in the \"%s\" setting. Report back the following values:\nFacility: %X\nError code: %X\nLine number: %d] - -;[The clipboard is not available, retry.] -;[Information successfully copied into clipboard.] -;[Miranda Version Information] - -- DISCLAIMER - - -This plugin works just fine on my machine, it should work just fine on yours -without conflicting with other plugins. Should you have any trouble, write me -at hrk@users.sf.net where "sf" must be changed to "sourceforge". -Anyway, if you are a smart programmer, give a look at the code and tell me -the changes you'd make. If I like them, I'll put them inside. :-) - -This plugin is released under the GPL license, I'm too lazy to copy it, though. -Anyway, if you do have Miranda (and you should, otherwise this plugin is -pretty useless) you already have a file called GPL.txt with tis license. -Being GPLed you are free to modify or change the source code (you can find it -here: http://nortiq.com/miranda/ and look for the source section) but you -cannot sell it. -As I already wrote: if you do modify it, notify me, I don't see a good reason -not to share the improvements with the Miranda community. :-) - -Yes, I have made a quite long disclaimer, I can save the file now. :-) diff --git a/plugins/Svc_vi/docs/rebase_versioninfo.txt b/plugins/Svc_vi/docs/rebase_versioninfo.txt deleted file mode 100644 index fd71ab0526..0000000000 --- a/plugins/Svc_vi/docs/rebase_versioninfo.txt +++ /dev/null @@ -1,33 +0,0 @@ -=§= TO PLUGIN DEVELOPERS =§= - -This plugin has its Base Address set to: -0x25040000 - -Please, avoid using this BaseAddress for your plugins: using the same addresses -will slow Miranda. -Read "pluginguidelines.txt" under miranda0100/miranda32/doc/ in the CVS. - -This Base Address is built this way: - -0x25 040000 -^^^^ ^^^^^^ -My radix Incremental value related to my plugins. - -Range for base address is 0x10000000 to 0x50000000, so 0x25040000 fits well there. - -040000 is an incremental value which represents VersionInfo. -[Note: 000000 is used for RePosition, 010000 for NewStatusNotify, 030000 for PicPlugin and so on.] - -Why do I call 0x25 "My radix"? - -HRK = H + R + K -H = 8th letter in the english alphabet. -R = 18th letter in the english alphabet. -K = 11th letter in the english alphabet. - -8 + 18 + 11 = 37. -37(dec) = 25(Hex) - -Base Address can be found/configured: -§ MSVC++ 6.0 - Project->Settings->Link->Output->Base Address \ No newline at end of file diff --git a/plugins/Svc_vi/docs/versioninfo.gif b/plugins/Svc_vi/docs/versioninfo.gif deleted file mode 100644 index a0e1f8eadb..0000000000 Binary files a/plugins/Svc_vi/docs/versioninfo.gif and /dev/null differ diff --git a/plugins/Svc_vi/hooked_events.cpp b/plugins/Svc_vi/hooked_events.cpp deleted file mode 100644 index 77d72e6a97..0000000000 --- a/plugins/Svc_vi/hooked_events.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/* -Version information plugin for Miranda IM - -Copyright © 2002-2006 Luca Santarelli, Cristian Libotean - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "common.h" -#include "hooked_events.h" - -HANDLE hModulesLoaded; -HANDLE hOptionsInitialize; - -#define HOST "http://eblis.tla.ro/projects" - -#define VERSIONINFO_VERSION_URL HOST "/miranda/VersionInfo/updater/VersionInfo.html" -#define VERSIONINFO_UPDATE_URL HOST "/miranda/VersionInfo/updater/VersionInfo.zip" -#define VERSIONINFO_VERSION_PREFIX "Version Information version " - -int HookEvents() -{ - hModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded); - hOptionsInitialize = HookEvent(ME_OPT_INITIALISE, OnOptionsInitialise); - //hPreShutdown = HookEvent(ME_SYSTEM_PRESHUTDOWN, OnPreShutdown); - - return 0; -} - -int UnhookEvents() -{ - UnhookEvent(hModulesLoaded); - UnhookEvent(hOptionsInitialize); - - return 0; -} - -int OnModulesLoaded(WPARAM wParam, LPARAM lParam) -{ - - bFoldersAvailable = ServiceExists(MS_FOLDERS_REGISTER_PATH); - hOutputLocation = FoldersRegisterCustomPathT("VersionInfo", "Output folder", _T("%miranda_path%")); - - GetStringFromDatabase("UUIDCharMark", _T(DEF_UUID_CHARMARK), PLUGIN_UUID_MARK, cPLUGIN_UUID_MARK); - return 0; -} - -static UINT uiExpertOnlyControls[] = { IDC_SHOWUUIDS, IDC_SHOWINSTALLEDLANGUAGES }; - -int OnOptionsInitialise(WPARAM wParam, LPARAM lParam) -{ - OPTIONSDIALOGPAGE odp = { 0 }; - odp.cbSize = sizeof(odp); - odp.position = 100000000; - odp.hInstance = hInst; - odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_VERSIONINFO); - odp.pszTitle = LPGEN("Version Information"); - odp.pszGroup = LPGEN("Services"); - odp.groupPosition = 910000000; - odp.flags = ODPF_BOLDGROUPS; - odp.pfnDlgProc = DlgProcOpts; - odp.expertOnlyControls = uiExpertOnlyControls; - odp.nExpertOnlyControls = SIZEOF(uiExpertOnlyControls); - - Options_AddPage(wParam, &odp); - - return 0; -} \ No newline at end of file diff --git a/plugins/Svc_vi/hooked_events.h b/plugins/Svc_vi/hooked_events.h deleted file mode 100644 index b75b5e59a8..0000000000 --- a/plugins/Svc_vi/hooked_events.h +++ /dev/null @@ -1,33 +0,0 @@ -/* -Version information plugin for Miranda IM - -Copyright © 2002-2006 Luca Santarelli, Cristian Libotean - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#ifndef M_VERSIONINFO_HOOKED_EVENTS_H -#define M_VERSIONINFO_HOOKED_EVENTS_H - -extern HANDLE hModulesLoaded; -extern HANDLE hOptionsInitialise; - -int HookEvents(); -int UnhookEvents(); - -int OnModulesLoaded(WPARAM wParam, LPARAM lParam); -int OnOptionsInitialise(WPARAM wParam, LPARAM lParam); - -#endif \ No newline at end of file diff --git a/plugins/Svc_vi/main.cpp b/plugins/Svc_vi/main.cpp deleted file mode 100644 index c244ba2db6..0000000000 --- a/plugins/Svc_vi/main.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/* -Version information plugin for Miranda IM - -Copyright © 2002-2006 Luca Santarelli, Cristian Libotean - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#define STRICT -#define WIN32_LEAN_AND_MEAN - -#define _CRT_SECURE_NO_DEPRECATE - -#include "common.h" - -#include "CVersionInfo.h" - -HINSTANCE hInst; - -int hLangpack; - -HICON hiVIIcon; - -DWORD EnglishLocale; - -BOOL bFoldersAvailable = FALSE; -HANDLE hOutputLocation = NULL; //for folders plugin - -void * (* MirandaMalloc)(size_t); -void * (* MirandaRealloc)(void *, size_t); -void (* MirandaFree)(void *); - -char ModuleName[] = "VersionInfo"; - -#ifdef _DEBUG - BOOL verbose = FALSE;//TRUE; -#else - BOOL verbose = FALSE; -#endif - -PLUGININFOEX pluginInfo={ - sizeof(PLUGININFOEX), - __PLUGIN_DISPLAY_NAME, - VERSION, - __DESC, - __AUTHOR, - __AUTHOREMAIL, - __COPYRIGHT, - __AUTHORWEB, - UNICODE_AWARE, - // {2f174488-489c-4fe1-940d-596cf0f35e65} - {0x2f174488, 0x489c, 0x4fe1, {0x94, 0x0d, 0x59, 0x6c, 0xf0, 0xf3, 0x5e, 0x65}} -}; - -extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = {MIID_VERSIONINFO, MIID_SERVICEMODE, MIID_LAST}; - -bool WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved) -{ - hInst=hinstDLL; - if (fdwReason == DLL_PROCESS_ATTACH) DisableThreadLibraryCalls(hinstDLL); - EnglishLocale = MAKELCID(MAKELANGID(0x09, 0x01), SORT_DEFAULT); //create our english locale and use it everywhere it's needed - return TRUE; -} - -extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) -{ - return &pluginInfo; -} - -extern "C" int __declspec(dllexport) Load(void) -{ - - mir_getLP(&pluginInfo); - - InitServices(); - HookEvents(); - - hiVIIcon = LoadIcon(hInst,MAKEINTRESOURCE(IDI_MAIN)); - - //get the name of the dll itself - TCHAR filePath[512] = {0}; - GetModuleFileName(hInst, filePath, SIZEOF(filePath)); - TCHAR *fileName = NULL; - size_t i = _tcslen(filePath) - 1; - _tcslwr(filePath); - - //check that the name begins with svc_ - while ((i > 0) && (filePath[i] != '\\')) { i--; } - if (i > 0) - { - filePath[i] = 0; - fileName = filePath + i + 1; - - if (_tcsstr(fileName, _T("svc_")) != fileName) - { - TCHAR buffer[1024]; - mir_sntprintf(buffer, SIZEOF(buffer), TranslateT("Please rename the plugin '%s' to 'svc_vi.dll' to enable service mode functionality."), fileName); - MessageBox(NULL, buffer, TranslateT("Version Information"), MB_OK | MB_ICONEXCLAMATION); - } - } - - //Menu item - CLISTMENUITEM mi = { 0 }; - mi.cbSize = sizeof(mi); - mi.position = mi.popupPosition = 2000089999; - mi.flags = 0; - mi.hIcon = hiVIIcon; - mi.pszName = Translate("Version Information"); - mi.pszService = MS_VERSIONINFO_MENU_COMMAND; - Menu_AddMainMenuItem(&mi); - - if (LoadLibraryA("RichEd32.dll") == NULL) - MessageBoxA(NULL, "d'oh", "d'oh", MB_OK); - - return 0; -} - -extern "C" int __declspec(dllexport) Unload(void) -{ - UnhookEvents(); - DestroyServices(); - return 0; -} \ No newline at end of file diff --git a/plugins/Svc_vi/resource.h b/plugins/Svc_vi/resource.h deleted file mode 100644 index b282e8bca6..0000000000 --- a/plugins/Svc_vi/resource.h +++ /dev/null @@ -1,71 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by resource.rc -// -#define IDD_DIALOG1 101 -#define IDD_OPT_VERSIONINFO 102 -#define IDD_DIALOGBOX 103 -#define IDD_DIALOGINFO 103 -#define IDI_ICON1 104 -#define IDI_MAIN 104 -#define IDD_ASKDIALOG 106 -#define IDC_MENUITEM 1000 -#define IDC_TOFILE 1001 -#define IDC_TOMESSAGEBOX 1002 -#define IDC_TODIALOGBOX 1003 -#define IDC_DISABLEDTOO 1004 -#define IDC_FILENAME 1005 -#define IDC_TEXT 1006 -#define IDC_TODEBUGSTRING 1006 -#define IDC_CLOSE 1007 -#define IDC_TOCLIPBOARD 1007 -#define IDC_GETINFONOW 1009 -#define IDC_TOUPLOAD 1010 -#define IDC_GETINFONOW2 1011 -#define IDC_COPYTEXT 1012 -#define IDC_DEBUG 1013 -#define IDC_FORUMSTYLE 1014 -#define IDC_CLIPBOARDALSO 1015 -#define IDC_SHOWINTASKBAR 1016 -#define IDC_QUOTECOMBOBOX 1017 -#define IDC_SIZECOMBOBOX 1018 -#define IDC_BOLDVERSION 1020 -#define IDC_CHECKUNLOADABLE 1021 -#define IDC_ASKEVERYTIME 1022 -#define IDC_ASK_TOFILE 1023 -#define IDC_ASK_TOMESSAGEBOX 1024 -#define IDC_ASK_TODIALOGBOX 1025 -#define IDC_ASK_TOOUTPUTDEBUGSTRING 1026 -#define IDC_ASK_TOCLIPBOARD 1027 -#define IDC_ASK_CANCEL 1028 -#define IDC_ASK_OK 1029 -#define IDC_BOLDCOMBOBOX 1030 -#define IDC_SUPPRESSHEADER 1031 -#define IDC_SHOWHARDWAREINFO 1033 -#define IDC_UPLOAD 1034 -#define IDC_ASK_UPLOAD 1036 -#define IDC_ASK_TOUPLOAD 1036 -#define IDC_UPLOAD_SERVER 1038 -#define IDC_UPLOAD_PORT 1039 -#define IDC_UPLOAD_USERNAME 1040 -#define IDC_UPLOAD_PASSWORD 1041 -#define IDC_TEMPORARY_FORUMSTYLE 1042 -#define IDC_ASK_FORUMSTYLE 1042 -#define IDC_ASK_QUOTECOMBOBOX 1043 -#define IDC_ASK_SIZECOMBOBOX 1044 -#define IDC_ASK_BOLDCOMBOBOX 1045 -#define IDC_SAVETOFILE 1046 -#define IDC_SHOWUUIDS 1048 -#define IDC_CHECK1 1049 -#define IDC_SHOWINSTALLEDLANGUAGES 1049 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 107 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1050 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/plugins/Svc_vi/resource.rc b/plugins/Svc_vi/resource.rc deleted file mode 100644 index b4a8eb819a..0000000000 --- a/plugins/Svc_vi/resource.rc +++ /dev/null @@ -1,225 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_ASKDIALOG DIALOGEX 0, 0, 231, 146 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Output to:" -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - DEFPUSHBUTTON "OK",IDC_ASK_OK,63,125,50,14 - PUSHBUTTON "Cancel",IDC_ASK_CANCEL,117,125,50,14 - CONTROL "Text file",IDC_ASK_TOFILE,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,15,17,206,10 - CONTROL "MessageBox()",IDC_ASK_TOMESSAGEBOX,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,15,27,206,10 - CONTROL "DialogBox",IDC_ASK_TODIALOGBOX,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,15,37,206,10 - CONTROL "OutputDebugString()",IDC_ASK_TOOUTPUTDEBUGSTRING,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,15,47,206,10 - CONTROL "Clipboard",IDC_ASK_TOCLIPBOARD,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,15,57,206,10 - GROUPBOX "Select output:",IDC_STATIC,7,7,217,72 - CONTROL "Upload to site",IDC_ASK_TOUPLOAD,"Button",BS_AUTORADIOBUTTON | WS_DISABLED | WS_TABSTOP,15,67,206,10 - CONTROL "Forum style formatting",IDC_ASK_FORUMSTYLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,92,206,9 - GROUPBOX "Aditional options:",IDC_STATIC,7,81,217,39 - COMBOBOX IDC_ASK_QUOTECOMBOBOX,15,104,75,50,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - COMBOBOX IDC_ASK_SIZECOMBOBOX,93,104,71,48,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - COMBOBOX IDC_ASK_BOLDCOMBOBOX,167,104,54,47,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_ASKDIALOG, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 224 - VERTGUIDE, 15 - VERTGUIDE, 221 - TOPMARGIN, 7 - BOTTOMMARGIN, 139 - HORZGUIDE, 116 - END -END -#endif // APSTUDIO_INVOKED - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - -///////////////////////////////////////////////////////////////////////////// -// Italian (Italy) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ITA) -#ifdef _WIN32 -LANGUAGE LANG_ITALIAN, SUBLANG_ITALIAN -#pragma code_page(1252) -#endif //_WIN32 - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_OPT_VERSIONINFO DIALOGEX 0, 0, 315, 222 -STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE -EXSTYLE WS_EX_CONTROLPARENT -FONT 8, "MS Shell Dlg", 0, 0, 0x0 -BEGIN - PUSHBUTTON "Do it now",IDC_GETINFONOW,265,4,48,13 - GROUPBOX "Output to:",IDC_STATIC,5,4,197,130 - CONTROL "Text file",IDC_TOFILE,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,16,186,10 - EDITTEXT IDC_FILENAME,24,26,150,14,ES_AUTOHSCROLL - CONTROL "MessageBox()",IDC_TOMESSAGEBOX,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,40,186,10 - CONTROL "DialogBox",IDC_TODIALOGBOX,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,51,186,10 - CONTROL "Show window in taskbar",IDC_SHOWINTASKBAR,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,21,62,177,10 - CONTROL "OutputDebugString()",IDC_TODEBUGSTRING,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,73,186,10 - CONTROL "Clipboard",IDC_TOCLIPBOARD,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,84,186,10 - CONTROL "Upload to site",IDC_TOUPLOAD,"Button",BS_AUTORADIOBUTTON | WS_DISABLED | WS_TABSTOP,12,95,186,10 - CONTROL "Ask every time",IDC_ASKEVERYTIME,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,106,186,10 - CONTROL "Also copy info to clipboard",IDC_CLIPBOARDALSO,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,121,186,10 - GROUPBOX "Upload site settings",IDC_STATIC,205,74,108,60 - EDITTEXT IDC_UPLOAD_SERVER,209,83,71,14,ES_AUTOHSCROLL | WS_DISABLED - EDITTEXT IDC_UPLOAD_PORT,281,83,27,14,ES_AUTOHSCROLL | WS_DISABLED - LTEXT "Username",IDC_STATIC,209,103,42,8 - EDITTEXT IDC_UPLOAD_USERNAME,253,99,55,14,ES_AUTOHSCROLL | WS_DISABLED - LTEXT "Password",IDC_STATIC,209,118,43,8 - EDITTEXT IDC_UPLOAD_PASSWORD,253,115,55,14,ES_PASSWORD | ES_AUTOHSCROLL | WS_DISABLED - CONTROL "Forum style formatting",IDC_FORUMSTYLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,5,139,149,10 - COMBOBOX IDC_QUOTECOMBOBOX,159,137,75,58,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - COMBOBOX IDC_SIZECOMBOBOX,238,137,75,58,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - CONTROL "Highlight version number using",IDC_BOLDVERSION,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,5,153,216,10 - COMBOBOX IDC_BOLDCOMBOBOX,252,153,61,37,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - CONTROL "Show disabled plugins too",IDC_DISABLEDTOO,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,5,164,232,10 - CONTROL "Attempt to find unloadable plugins (doesn't work on Windows 98)",IDC_CHECKUNLOADABLE, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,5,174,272,10 - CONTROL "Suppress header information",IDC_SUPPRESSHEADER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,5,184,274,10 - CONTROL "Enable debug messages",IDC_DEBUG,"Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_DISABLED | WS_TABSTOP,220,207,93,10 - CONTROL "Show plugin UUIDs",IDC_SHOWUUIDS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,5,195,272,10 - CONTROL "Show installed languages",IDC_SHOWINSTALLEDLANGUAGES, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,5,206,273,10 -END - -IDD_DIALOGINFO DIALOGEX 0, 0, 373, 217 -STYLE DS_LOCALEDIT | DS_SETFONT | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -EXSTYLE WS_EX_TOOLWINDOW | WS_EX_CONTROLPARENT -CAPTION "Miranda Version Information" -FONT 8, "MS Shell Dlg", 0, 0, 0x0 -BEGIN - CONTROL "",IDC_TEXT,"RICHEDIT",TCS_HOTTRACK | TCS_FOCUSONBUTTONDOWN | TCS_MULTISELECT | WS_BORDER | WS_VSCROLL | WS_TABSTOP,7,7,298,203 - PUSHBUTTON "Close",IDC_CLOSE,316,7,50,14 - PUSHBUTTON "&Copy text",IDC_COPYTEXT,316,26,50,14 - PUSHBUTTON "Upload",IDC_UPLOAD,316,196,50,14,WS_DISABLED - PUSHBUTTON "&Save to file",IDC_SAVETOFILE,316,45,50,14 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_OPT_VERSIONINFO, DIALOG - BEGIN - LEFTMARGIN, 5 - RIGHTMARGIN, 313 - VERTGUIDE, 12 - VERTGUIDE, 198 - VERTGUIDE, 202 - VERTGUIDE, 205 - VERTGUIDE, 304 - VERTGUIDE, 308 - TOPMARGIN, 4 - BOTTOMMARGIN, 217 - HORZGUIDE, 149 - END - - IDD_DIALOGINFO, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 366 - TOPMARGIN, 7 - BOTTOMMARGIN, 210 - END -END -#endif // APSTUDIO_INVOKED - - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDI_MAIN ICON "VersionInfo.ico" -#endif // Italian (Italy) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/plugins/Svc_vi/services.cpp b/plugins/Svc_vi/services.cpp deleted file mode 100644 index 4efa482404..0000000000 --- a/plugins/Svc_vi/services.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/* -Version information plugin for Miranda IM - -Copyright © 2002-2006 Luca Santarelli, Cristian Libotean - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "common.h" -#include "services.h" - -HANDLE hsMenuCommand; -HANDLE hsGetInfo; -HANDLE hsServiceMode; - -int bServiceMode = 0; //true only if plugin is running in service mode - -int InitServices() -{ - hsMenuCommand = CreateServiceFunction(MS_VERSIONINFO_MENU_COMMAND, PluginMenuCommand); - hsGetInfo = CreateServiceFunction(MS_VERSIONINFO_GETINFO, GetInfoService); - hsServiceMode = CreateServiceFunction(MS_SERVICEMODE_LAUNCH, ServiceModeService); - return 0; -} - -int DestroyServices() -{ - DestroyServiceFunction(hsMenuCommand); - DestroyServiceFunction(hsGetInfo); - DestroyServiceFunction(hsServiceMode); - return 0; -} - -INT_PTR PluginMenuCommand(WPARAM wParam, LPARAM lParam) -{ - int debugTo = DBGetContactSettingByte(NULL, ModuleName, "DebugTo", TO_DIALOGBOX); - DoDebugTo(debugTo); - if (verbose) PUShowMessage("I have printed the information.", SM_NOTIFY); -/* char *data; - CallService(MS_VERSIONINFO_GETINFO, 1, (LPARAM) &data); */ - return 0; -} - -INT_PTR GetInfoService(WPARAM wParam, LPARAM lParam) -{ - int result = 1; //failure - if (lParam != NULL) { - CVersionInfo myInfo; - myInfo.Initialize(); - std::tstring VI = myInfo.GetInformationsAsString(wParam); - char **retData = (char **) lParam; - *retData = mir_utf8encodeT( VI.c_str()); - if (*retData) - result = 0; //success - } - return result; -} - -INT_PTR ServiceModeService(WPARAM wParam, LPARAM lParam) -{ - bServiceMode = 1; - DoDebugTo(TO_ASK); - return 0; -} diff --git a/plugins/Svc_vi/services.h b/plugins/Svc_vi/services.h deleted file mode 100644 index 38acbc7731..0000000000 --- a/plugins/Svc_vi/services.h +++ /dev/null @@ -1,31 +0,0 @@ -/* -Version information plugin for Miranda IM - -Copyright © 2002-2006 Luca Santarelli, Cristian Libotean - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#ifndef M_VERSIONINFO_SERVICES_H -#define M_VERSIONINFO_SERVICES_H - -int InitServices(); -int DestroyServices(); - -INT_PTR PluginMenuCommand(WPARAM wParam, LPARAM lParam); -INT_PTR GetInfoService(WPARAM wParam, LPARAM lParam); -INT_PTR ServiceModeService(WPARAM wParam, LPARAM lParam); - -#endif //M_VERSIONINFO_SERVICES_H \ No newline at end of file diff --git a/plugins/Svc_vi/svc_vi-translation.txt b/plugins/Svc_vi/svc_vi-translation.txt deleted file mode 100644 index 719f0beb2c..0000000000 --- a/plugins/Svc_vi/svc_vi-translation.txt +++ /dev/null @@ -1,56 +0,0 @@ -; Common strings that belong to many files -;[The clipboard is not available, retry.] -;[Version Information] - -; ../../plugins/Svc_vi/CVersionInfo.cpp -;[Error during the creation of file \"%s\". Disk may be full or write protected.] -;[If you are going to use this report to submit a bug, remember to check the website for questions or help the developers may need.\r\nIf you don't check your bug report and give feedback, it will not be fixed!] -;[Information successfully copied into clipboard.] -;[Information successfully written to file: \"%s\".] - -; ../../plugins/Svc_vi/dlgHandlers.cpp -;[Are you sure you want to enable this option ?\nPlease only enable this option if you really know what you're doing and what the option is for or if someone asked you to do it.] -;[Customize using folders plugin] -;[Show plugin UUIDs ?] - -; ../../plugins/Svc_vi/hooked_events.cpp -;[Services] - -; ../../plugins/Svc_vi/main.cpp -;[Please rename the plugin '%s' to 'svc_vi.dll' to enable service mode functionality.] - -; ../../plugins/Svc_vi/resource.rc -;[&Copy text] -;[&Save to file] -;[Aditional options:] -;[Also copy info to clipboard] -;[Ask every time] -;[Attempt to find unloadable plugins (doesn't work on Windows 98)] -;[Cancel] -;[Clipboard] -;[Close] -;[DialogBox] -;[Do it now] -;[Enable debug messages] -;[Forum style formatting] -;[Highlight version number using] -;[MessageBox()] -;[Miranda Version Information] -;[OK] -;[Output to:] -;[OutputDebugString()] -;[Password] -;[Select output:] -;[Show disabled plugins too] -;[Show installed languages] -;[Show plugin UUIDs] -;[Show window in taskbar] -;[Suppress header information] -;[Text file] -;[Upload] -;[Upload site settings] -;[Upload to site] -;[Username] - -; ../../plugins/Svc_vi/utils.cpp -;[Ok, something went wrong in the \"%s\" setting. Report back the following values:\nFacility: %X\nError code: %X\nLine number: %d] diff --git a/plugins/Svc_vi/utils.cpp b/plugins/Svc_vi/utils.cpp deleted file mode 100644 index 9be552c8cc..0000000000 --- a/plugins/Svc_vi/utils.cpp +++ /dev/null @@ -1,526 +0,0 @@ -/* -Version information plugin for Miranda IM - -Copyright © 2002-2006 Luca Santarelli, Cristian Libotean - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -//#define USE_LOG_FUNCTIONS - -#define STRICT -#define WIN32_LEAN_AND_MEAN - -#include "common.h" -#include "utils.h" - -/* -My usual MessageBoxes :-) -*/ -void MB(const TCHAR* message) -{ - if (verbose) MessageBox(NULL, message, _T("VersionInfo"), MB_OK | MB_ICONEXCLAMATION); -} - -void Log(const TCHAR* message) -{ - if (ServiceExists(MS_POPUP_ADDPOPUPT)) { - POPUPDATAT pu = {0}; - pu.lchIcon = hiVIIcon; - _tcsncpy(pu.lptzContactName, TranslateT("Version Information"), MAX_CONTACTNAME); - _tcsncpy(pu.lptzText, message, MAX_SECONDLINE); - PUAddPopUpT(&pu); - } - else MessageBox(NULL, message, _T("VersionInfo"), MB_OK | MB_ICONINFORMATION); -} - -int SplitStringInfo(const TCHAR *szWholeText, TCHAR *szStartText, TCHAR *szEndText) -{ - const TCHAR *pos = _tcschr(szWholeText, '|'); - if (pos) { - size_t index = pos - szWholeText; - lstrcpyn(szStartText, szWholeText, (int)index); - szStartText[index] = '\0'; - StrTrim(szStartText, _T(" ")); - lstrcpyn(szEndText, pos + 1, (int)_tcslen(pos)); //copies the \0 as well ... :) - StrTrim(szEndText, _T(" ")); - } - else szStartText[0] = szEndText[0] = '\0'; - - return 0; -} - -int GetStringFromDatabase(char *szSettingName, TCHAR *szError, TCHAR *szResult, size_t size) -{ - DBVARIANT dbv = {0}; - int res = 1; - size_t len; - if ( DBGetContactSettingTString(NULL, ModuleName, szSettingName, &dbv) == 0) { - res = 0; - size_t tmp = _tcslen(dbv.ptszVal); - len = (tmp < size - 1) ? tmp : size - 1; - _tcsncpy(szResult, dbv.ptszVal, len); - szResult[len] = '\0'; - mir_free(dbv.ptszVal); - } - else { - res = 1; - size_t tmp = _tcslen(szError); - len = (tmp < size - 1) ? tmp : size - 1; - _tcsncpy(szResult, szError, len); - szResult[len] = '\0'; - } - return res; -} - -TCHAR *RelativePathToAbsolute(TCHAR *szRelative, TCHAR *szAbsolute, size_t size) -{ - if (size < MAX_PATH) { - TCHAR buffer[MAX_PATH]; //new path should be at least MAX_PATH chars - CallService(MS_UTILS_PATHTOABSOLUTET, (WPARAM) szRelative, (LPARAM) buffer); - _tcsncpy(szAbsolute, buffer, size); - } - else CallService(MS_UTILS_PATHTOABSOLUTET, (WPARAM) szRelative, (LPARAM) szAbsolute); - - return szAbsolute; -} - -TCHAR *AbsolutePathToRelative(TCHAR *szAbsolute, TCHAR *szRelative, size_t size) -{ - if (size < MAX_PATH) { - TCHAR buffer[MAX_PATH]; - CallService(MS_UTILS_PATHTORELATIVET, (WPARAM) szAbsolute, (LPARAM) szRelative); - _tcsncpy(szRelative, buffer, size); - } - else CallService(MS_UTILS_PATHTORELATIVET, (WPARAM) szAbsolute, (LPARAM) szRelative); - - return szRelative; -} - -#define GetFacility(dwError) (HIWORD(dwError) && 0x0000111111111111) -#define GetErrorCode(dwError) (LOWORD(dwError)) - -void NotifyError(DWORD dwError, const TCHAR* szSetting, int iLine) -{ - TCHAR str[1024]; - mir_sntprintf(str, SIZEOF(str), TranslateT("Ok, something went wrong in the \"%s\" setting. Report back the following values:\nFacility: %X\nError code: %X\nLine number: %d"), szSetting, GetFacility(dwError), GetErrorCode(dwError), iLine); - Log(str); -} - -TCHAR *StrTrim(TCHAR *szText, const TCHAR *szTrimChars) -{ - size_t i = _tcslen(szText) - 1; - while (i >= 0 && _tcschr(szTrimChars, szText[i])) - szText[i--] = '\0'; - - i = 0; - while (((unsigned int )i < _tcslen(szText)) && _tcschr(szTrimChars, szText[i])) - i++; - - if (i) { - size_t size = _tcslen(szText); - size_t j; - for (j = i; j <= size; j++) //shift the \0 as well - szText[j - i] = szText[j]; - } - return szText; -} - -bool DoesDllExist(char *dllName) -{ - HMODULE dllHandle; - dllHandle = LoadLibraryExA(dllName, NULL, DONT_RESOLVE_DLL_REFERENCES); - if (dllHandle) - { - FreeLibrary(dllHandle); - return true; - } - return false; -} - -//========== From Cyreve ========== -PLUGININFOEX *GetPluginInfo(const TCHAR *filename,HINSTANCE *hPlugin) -{ - TCHAR szMirandaPath[MAX_PATH], szPluginPath[MAX_PATH]; - PLUGININFOEX *(*MirandaPluginInfo)(DWORD); - PLUGININFOEX *pPlugInfo; - HMODULE hLoadedModule; - DWORD mirandaVersion = CallService(MS_SYSTEM_GETVERSION,0,0); - - GetModuleFileName(GetModuleHandle(NULL), szMirandaPath, SIZEOF(szMirandaPath)); - TCHAR* str2 = _tcsrchr(szMirandaPath,'\\'); - if(str2!=NULL) *str2=0; - - hLoadedModule = GetModuleHandle(filename); - if(hLoadedModule!=NULL) { - *hPlugin=NULL; - MirandaPluginInfo=(PLUGININFOEX *(*)(DWORD))GetProcAddress(hLoadedModule,"MirandaPluginInfo"); - return MirandaPluginInfo(mirandaVersion); - } - wsprintf(szPluginPath, _T("%s\\Plugins\\%s"), szMirandaPath, filename); - *hPlugin=LoadLibrary(szPluginPath); - if (*hPlugin==NULL) return NULL; - MirandaPluginInfo=(PLUGININFOEX *(*)(DWORD))GetProcAddress(*hPlugin,"MirandaPluginInfo"); - if(MirandaPluginInfo==NULL) {FreeLibrary(*hPlugin); *hPlugin=NULL; return NULL;} - pPlugInfo=MirandaPluginInfo(mirandaVersion); - if(pPlugInfo==NULL) {FreeLibrary(*hPlugin); *hPlugin=NULL; return NULL;} - if(pPlugInfo->cbSize != sizeof(PLUGININFOEX)) {FreeLibrary(*hPlugin); *hPlugin=NULL; return NULL;} - return pPlugInfo; -} - -//========== from Frank Cheng (wintime98) ========== -// I've changed something to suit VersionInfo :-) -#include - -void TimeStampToSysTime(DWORD Unix,SYSTEMTIME* SysTime) -{ - SYSTEMTIME S; - DWORDLONG FileReal,UnixReal; - S.wYear=1970; - S.wMonth=1; - S.wDay=1; - S.wHour=0; - S.wMinute=0; - S.wSecond=0; - S.wMilliseconds=0; - SystemTimeToFileTime(&S,(FILETIME*)&FileReal); - UnixReal = Unix; - UnixReal*=10000000; - FileReal+=UnixReal; - FileTimeToSystemTime((FILETIME*)&FileReal,SysTime); -} - -void GetModuleTimeStamp(TCHAR* ptszDate, TCHAR* ptszTime) -{ - TCHAR tszModule[MAX_PATH]; - HANDLE mapfile,file; - DWORD timestamp,filesize; - LPVOID mapmem; - SYSTEMTIME systime; - GetModuleFileName(NULL,tszModule,SIZEOF(tszModule)); - file = CreateFile(tszModule,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL); - filesize = GetFileSize(file,NULL); - mapfile = CreateFileMapping(file, NULL, PAGE_READONLY, 0, filesize, NULL); - mapmem = MapViewOfFile(mapfile, FILE_MAP_READ, 0, 0, 0); - timestamp = GetTimestampForLoadedLibrary((HINSTANCE)mapmem); - TimeStampToSysTime(timestamp,&systime); - GetTimeFormat(LOCALE_USER_DEFAULT, 0, &systime, _T("HH':'mm':'ss"), ptszTime, 40 ); - GetDateFormat(EnglishLocale, 0, &systime, _T("dd' 'MMMM' 'yyyy"), ptszDate, 40); - UnmapViewOfFile(mapmem); - CloseHandle(mapfile); - CloseHandle(file); -} - -//From Egodust or Cyreve... I don't really know. -PLUGININFOEX *CopyPluginInfo(PLUGININFOEX *piSrc) -{ - if(piSrc==NULL) - return NULL; - - PLUGININFOEX *pi = (PLUGININFOEX *)malloc(sizeof(PLUGININFOEX)); - *pi = *piSrc; - - if (piSrc->cbSize >= sizeof(PLUGININFOEX)) - pi->uuid = piSrc->uuid; - else - pi->uuid = UUID_NULL; - - if (pi->author) pi->author = _strdup(pi->author); - if (pi->authorEmail) pi->authorEmail = _strdup(pi->authorEmail); - if (pi->copyright) pi->copyright = _strdup(pi->copyright); - if (pi->description) pi->description = _strdup(pi->description); - if (pi->homepage) pi->homepage = _strdup(pi->homepage); - if (pi->shortName) pi->shortName = _strdup(pi->shortName); - return pi; -} - -void FreePluginInfo(PLUGININFOEX *pi) -{ - if (pi->author) free(pi->author); - if (pi->authorEmail) free(pi->authorEmail); - if (pi->copyright) free(pi->copyright); - if (pi->description) free(pi->description); - if (pi->homepage) free(pi->homepage); - if (pi->shortName) free(pi->shortName); - free(pi); -} - -BOOL IsCurrentUserLocalAdministrator(void) -{ - BOOL fReturn = FALSE; - DWORD dwStatus; - DWORD dwAccessMask; - DWORD dwAccessDesired; - DWORD dwACLSize; - DWORD dwStructureSize = sizeof(PRIVILEGE_SET); - PACL pACL = NULL; - PSID psidAdmin = NULL; - - HANDLE hToken = NULL; - HANDLE hImpersonationToken = NULL; - - PRIVILEGE_SET ps; - GENERIC_MAPPING GenericMapping; - - PSECURITY_DESCRIPTOR psdAdmin = NULL; - SID_IDENTIFIER_AUTHORITY SystemSidAuthority = SECURITY_NT_AUTHORITY; - - /* - Determine if the current thread is running as a user that is a member of - the local admins group. To do this, create a security descriptor that - has a DACL which has an ACE that allows only local aministrators access. - Then, call AccessCheck with the current thread's token and the security - descriptor. It will say whether the user could access an object if it - had that security descriptor. Note: you do not need to actually create - the object. Just checking access against the security descriptor alone - will be sufficient. - */ - const DWORD ACCESS_READ = 1; - const DWORD ACCESS_WRITE = 2; - - - __try - { - - /* - AccessCheck() requires an impersonation token. We first get a primary - token and then create a duplicate impersonation token. The - impersonation token is not actually assigned to the thread, but is - used in the call to AccessCheck. Thus, this function itself never - impersonates, but does use the identity of the thread. If the thread - was impersonating already, this function uses that impersonation context. - */ - if (!OpenThreadToken(GetCurrentThread(), TOKEN_DUPLICATE|TOKEN_QUERY, TRUE, &hToken)) - { - if (GetLastError() != ERROR_NO_TOKEN) - __leave; - - if (!OpenProcessToken(GetCurrentProcess(), TOKEN_DUPLICATE|TOKEN_QUERY, &hToken)) - __leave; - } - - if (!DuplicateToken (hToken, SecurityImpersonation, &hImpersonationToken)) - __leave; - - - /* - Create the binary representation of the well-known SID that - represents the local administrators group. Then create the security - descriptor and DACL with an ACE that allows only local admins access. - After that, perform the access check. This will determine whether - the current user is a local admin. - */ - if (!AllocateAndInitializeSid(&SystemSidAuthority, 2, SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &psidAdmin)) - __leave; - - psdAdmin = LocalAlloc(LPTR, SECURITY_DESCRIPTOR_MIN_LENGTH); - if (psdAdmin == NULL) - __leave; - - if (!InitializeSecurityDescriptor(psdAdmin, SECURITY_DESCRIPTOR_REVISION)) - __leave; - - // Compute size needed for the ACL. - dwACLSize = sizeof(ACL) + sizeof(ACCESS_ALLOWED_ACE) + GetLengthSid(psidAdmin) - sizeof(DWORD); - - pACL = (PACL)LocalAlloc(LPTR, dwACLSize); - if (pACL == NULL) - __leave; - - if (!InitializeAcl(pACL, dwACLSize, ACL_REVISION2)) - __leave; - - dwAccessMask= ACCESS_READ | ACCESS_WRITE; - - if (!AddAccessAllowedAce(pACL, ACL_REVISION2, dwAccessMask, psidAdmin)) - __leave; - - if (!SetSecurityDescriptorDacl(psdAdmin, TRUE, pACL, FALSE)) - __leave; - - /* - AccessCheck validates a security descriptor somewhat; set the group - and owner so that enough of the security descriptor is filled out to - make AccessCheck happy. - */ - SetSecurityDescriptorGroup(psdAdmin, psidAdmin, FALSE); - SetSecurityDescriptorOwner(psdAdmin, psidAdmin, FALSE); - - if (!IsValidSecurityDescriptor(psdAdmin)) - __leave; - - dwAccessDesired = ACCESS_READ; - - /* - Initialize GenericMapping structure even though you - do not use generic rights. - */ - GenericMapping.GenericRead = ACCESS_READ; - GenericMapping.GenericWrite = ACCESS_WRITE; - GenericMapping.GenericExecute = 0; - GenericMapping.GenericAll = ACCESS_READ | ACCESS_WRITE; - - if (!AccessCheck(psdAdmin, hImpersonationToken, dwAccessDesired, &GenericMapping, &ps, &dwStructureSize, &dwStatus, &fReturn)) - { - fReturn = FALSE; - __leave; - } - } - __finally - { - // Clean up. - if (pACL) LocalFree(pACL); - if (psdAdmin) LocalFree(psdAdmin); - if (psidAdmin) FreeSid(psidAdmin); - if (hImpersonationToken) CloseHandle (hImpersonationToken); - if (hToken) CloseHandle (hToken); - } - - return fReturn; -} - -BOOL GetWindowsShell(TCHAR *shellPath, size_t shSize) -{ - OSVERSIONINFO vi = {0}; - vi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - GetVersionEx(&vi); - - TCHAR szShell[1024] = {0}; - DWORD size = SIZEOF(szShell); - - if (vi.dwPlatformId == VER_PLATFORM_WIN32_NT) - { - HKEY hKey; - if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\IniFileMapping\\system.ini\\boot"), 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) - { - RegQueryValueEx(hKey, _T("Shell"), NULL, NULL, (LPBYTE) szShell, &size); - _tcslwr(szShell); - HKEY hRootKey = ( _tcsstr(szShell, _T("sys:")) == szShell) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; - RegCloseKey(hKey); - - _tcscpy(szShell, _T("")); - if (RegOpenKeyEx(hRootKey, _T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon"), 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) - { - size = SIZEOF(szShell); - RegQueryValueEx(hKey, _T("Shell"), NULL, NULL, (LPBYTE) szShell, &size); - RegCloseKey(hKey); - } - } - } - else{ - TCHAR szSystemIniPath[2048]; - GetWindowsDirectory(szSystemIniPath, SIZEOF(szSystemIniPath)); - size_t len = lstrlen(szSystemIniPath); - if (len > 0) - { - if (szSystemIniPath[len - 1] == '\\') { szSystemIniPath[--len] = '\0'; } - _tcscat(szSystemIniPath, _T("\\system.ini")); - GetPrivateProfileString( _T("boot"), _T("shell"), _T(""), szShell, size, szSystemIniPath); - } - } - - TCHAR *pos = _tcsrchr(szShell, '\\'); - TCHAR *res = (pos) ? pos + 1 : szShell; - _tcsncpy(shellPath, res, shSize); - - return TRUE; -} - -BOOL GetInternetExplorerVersion(TCHAR *ieVersion, size_t ieSize) -{ - HKEY hKey; - TCHAR ieVer[1024]; - DWORD size = SIZEOF(ieVer); - TCHAR ieBuild[64] = {0}; - - _tcsncpy(ieVer, _T(""), size); - - if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Internet Explorer"), 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) - { - if (RegQueryValueEx(hKey, _T("Version"), NULL, NULL, (LPBYTE) ieVer, &size) == ERROR_SUCCESS) - { - TCHAR *pos = _tcschr(ieVer, '.'); - if (pos) - { - pos = _tcschr(pos + 1, '.'); - if (pos) { *pos = 0; } - _tcsncpy(ieBuild, pos + 1, SIZEOF(ieBuild)); - pos = _tcschr(ieBuild, '.'); - if (pos) { *pos = 0; } - } - } - else{ - size = SIZEOF(ieVer); - if (RegQueryValueEx(hKey, _T("Build"), NULL, NULL, (LPBYTE) ieVer, &size) == ERROR_SUCCESS) - { - TCHAR *pos = ieVer + 1; - _tcsncpy(ieBuild, pos, SIZEOF(ieBuild)); - *pos = 0; - pos = _tcschr(ieBuild, '.'); - if (pos) { *pos = 0; } - } - else{ - _tcsncpy(ieVer, _T(""), size); - } - } - RegCloseKey(hKey); - } - - _tcsncpy(ieVersion, ieVer, ieSize); - if ( ieBuild[0] ) - { - _tcsncat(ieVersion, _T("."), ieSize); - _tcsncat(ieVersion, ieBuild, ieSize); - } - - return TRUE; -} - - -TCHAR *GetLanguageName(LANGID language) -{ - LCID lc = MAKELCID(language, SORT_DEFAULT); - return GetLanguageName(lc); -} - -extern TCHAR *GetLanguageName(LCID locale) -{ - static TCHAR name[1024]; - GetLocaleInfo(locale, LOCALE_SENGLANGUAGE, name, SIZEOF(name)); - return name; -} - -BOOL UUIDToString(MUUID uuid, TCHAR *str, size_t len) -{ - if ( len < sizeof(MUUID) || !str ) - return 0; - - mir_sntprintf(str, len, _T("{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}"), uuid.a, uuid.b, uuid.c, uuid.d[0], uuid.d[1], uuid.d[2], uuid.d[3], uuid.d[4], uuid.d[5], uuid.d[6], uuid.d[7]); - return 1; -} - -BOOL IsUUIDNull(MUUID uuid) -{ - int i; - for (i = 0; i < sizeof(uuid.d); i++) - { - if (uuid.d[i]) - { - return 0; - } - } - - return ((uuid.a == 0) && (uuid.b == 0) && (uuid.c == 0)); -} \ No newline at end of file diff --git a/plugins/Svc_vi/utils.h b/plugins/Svc_vi/utils.h deleted file mode 100644 index 5db4b1a811..0000000000 --- a/plugins/Svc_vi/utils.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef _M_VERSIONINFO_UTILS_H -#define _M_VERSIONINFO_UTILS_H - -#include "common.h" - -//utils.cpp -void MB(const TCHAR*); -void Log(const TCHAR*); -TCHAR *StrTrim(TCHAR *, const TCHAR *); - -//utils.cpp -TCHAR *RelativePathToAbsolute(TCHAR *szRelative, TCHAR *szAbsolute, size_t size); -TCHAR *AbsolutePathToRelative(TCHAR *szAbsolute, TCHAR *szRelative, size_t size); - -//returns a string from the database and uses MirandaFree to deallocate the string, leaving only the local copy -//utils.cpp -int GetStringFromDatabase(char *szSettingName, TCHAR *szError, TCHAR *szResult, size_t size); - -//a string of the form %s(start) | %s(end) is split into the two strings (start and end) -//utils.cpp -int SplitStringInfo(const TCHAR *szWholeText, TCHAR *szStartText, TCHAR *szEndText); - -//utils.cpp -bool DoesDllExist(char *dllName); - -//utils.cpp -void GetModuleTimeStamp(TCHAR*, TCHAR*); -void NotifyError(DWORD, const TCHAR*, int); - -//utils.cpp -PLUGININFOEX *GetPluginInfo(const char *,HINSTANCE *); -PLUGININFOEX *CopyPluginInfo(PLUGININFOEX *); -void FreePluginInfo(PLUGININFOEX *); - -//utils.cpp - -BOOL IsCurrentUserLocalAdministrator(); - -TCHAR *GetLanguageName(LANGID language); -TCHAR *GetLanguageName(LCID locale); - -BOOL GetWindowsShell(TCHAR *shellPath, size_t shSize); -BOOL GetInternetExplorerVersion(TCHAR *ieVersion, size_t ieSize); - -BOOL UUIDToString(MUUID uuid, TCHAR *str, size_t len); - -BOOL IsUUIDNull(MUUID uuid); - -#endif \ No newline at end of file diff --git a/plugins/Svc_vi/version.h b/plugins/Svc_vi/version.h deleted file mode 100644 index 200ac05349..0000000000 --- a/plugins/Svc_vi/version.h +++ /dev/null @@ -1,44 +0,0 @@ -/* -Version information plugin for Miranda IM - -Copyright © 2002-2005 Luca Santarelli, © 2005-2008 Cristian Libotean - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#ifndef M_VERSIONINFO_VERSION_H -#define M_VERSIONINFO_VERSION_H - -#define __MAJOR_VERSION 1 -#define __MINOR_VERSION 5 -#define __RELEASE_NUM 0 -#define __BUILD_NUM 2 - -#define VERSION PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM) - -#define __PLUGINVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM -#define __PLUGINVERSION_STRING_DOTS __MAJOR_VERSION.__MINOR_VERSION.__RELEASE_NUM.__BUILD_NUM -#define __STRINGIFY_(x) #x -#define __STRINGIFY(x) __STRINGIFY_(x) -#define __VERSION_STRING __STRINGIFY(__PLUGINVERSION_STRING_DOTS) - -#define __DESC "Collects and prints information related to Miranda, the plugins and the OS." -#define __AUTHOR "Luca Santarelli, Cristian Libotean, George Hazan" -#define __AUTHOREMAIL "hrk@users.sourceforge.net, eblis102@yahoo.com, ghazan@miranda.im" -#define __COPYRIGHT "© 2002-2005 Luca Santarelli, © 2005-2009 Cristian Libotean" -#define __AUTHORWEB "http://www.miranda-im.org/" -#define __PLUGIN_DISPLAY_NAME "Version Information" - -#endif //M_VERSIONINFO_VERSION_H diff --git a/plugins/Svc_vi/version.rc b/plugins/Svc_vi/version.rc deleted file mode 100644 index cd65db2ee3..0000000000 --- a/plugins/Svc_vi/version.rc +++ /dev/null @@ -1,104 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#ifdef APSTUDIO_INVOKED -#error this file is not editable by Microsoft Visual C++ -#endif //APSTUDIO_INVOKED - -#include "resource.h" -#include "version.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource1.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION __PLUGINVERSION_STRING - PRODUCTVERSION __PLUGINVERSION_STRING - FILEFLAGSMASK 0x17L -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x2L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "Author", __AUTHOR - VALUE "FileDescription", __DESC - VALUE "FileVersion", __VERSION_STRING - VALUE "InternalName", __PLUGIN_DISPLAY_NAME - VALUE "LegalCopyright", __COPYRIGHT - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/plugins/VersionInfo/AggressiveOptimize.h b/plugins/VersionInfo/AggressiveOptimize.h new file mode 100644 index 0000000000..1b646c301c --- /dev/null +++ b/plugins/VersionInfo/AggressiveOptimize.h @@ -0,0 +1,58 @@ + +////////////////////////////// +// Version 1.10 +// Jan 23rd, 2000 +// Version 1.00 +// May 20th, 1999 +// Todd C. Wilson, Fresh Ground Software +// (todd@nopcode.com) +// This header file will kick in settings for Visual C++ 5 and 6 that will (usually) +// result in smaller exe's. +// The "trick" is to tell the compiler to not pad out the function calls; this is done +// by not using the /O1 or /O2 option - if you do, you implicitly use /Gy, which pads +// out each and every function call. In one single 500k dll, I managed to cut out 120k +// by this alone! +// The other two "tricks" are telling the Linker to merge all data-type segments together +// in the exe file. The relocation, read-only (constants) data, and code section (.text) +// sections can almost always be merged. Each section merged can save 4k in exe space, +// since each section is padded out to 4k chunks. This is very noticable with smaller +// exes, since you could have only 700 bytes of data, 300 bytes of code, 94 bytes of +// strings - padded out, this could be 12k of runtime, for 1094 bytes of stuff! +// Note that if you're using MFC static or some other 3rd party libs, you may get poor +// results with merging the readonly (.rdata) section - the exe may grow larger. +// To use this feature, define _MERGE_DATA_ in your project or before this header is used. +// With Visual C++ 5, the program uses a file alignement of 512 bytes, which results +// in a small exe. Under VC6, the program instead uses 4k, which is the same as the +// section size. The reason (from what I understand) is that 4k is the chunk size of +// the virtual memory manager, and that WinAlign (an end-user tuning tool for Win98) +// will re-align the programs on this boundary. The problem with this is that all of +// Microsoft's system exes and dlls are not tuned like this, and using 4k causes serious +// exe bloat. Very noticable for smaller programs. +// The "trick" for this is to use the undocumented FILEALIGN linker parm to change the +// padding from 4k to 1/2k, which results in a much smaller exe - anywhere from 20%-75% +// depending on the size. + + +#ifdef NDEBUG +// /Og (global optimizations), /Os (favor small code), /Oy (no frame pointers) +#pragma optimize("gsy",on) + +#pragma comment(linker,"/RELEASE") + +// Note that merging the .rdata section will result in LARGER exe's if you using +// MFC (esp. static link). If this is desirable, define _MERGE_RDATA_ in your project. +#ifdef _MERGE_RDATA_ +#pragma comment(linker,"/merge:.rdata=.data") +#endif // _MERGE_RDATA_ + +#pragma comment(linker,"/merge:.text=.data") +#pragma comment(linker,"/merge:.reloc=.data") + +#if _MSC_VER >= 1000 +// Only supported/needed with VC6; VC5 already does 0x200 for release builds. +// Totally undocumented! And if you set it lower than 512 bytes, the program crashes. +// Either leave at 0x200 or 0x1000 +#pragma comment(linker,"/FILEALIGN:0x200") +#endif // _MSC_VER >= 1000 + +#endif // NDEBUG diff --git a/plugins/VersionInfo/CPlugin.cpp b/plugins/VersionInfo/CPlugin.cpp new file mode 100644 index 0000000000..56dc3e994a --- /dev/null +++ b/plugins/VersionInfo/CPlugin.cpp @@ -0,0 +1,137 @@ +/* +Version information plugin for Miranda IM + +Copyright © 2002-2006 Luca Santarelli, Cristian Libotean + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include "CPlugin.h" +//#include "AggressiveOptimize.h" + +#include "common.h" + +const int cPLUGIN_UUID_MARK = 4; +TCHAR PLUGIN_UUID_MARK[cPLUGIN_UUID_MARK]; + +#define PLUGIN_UNCERTAIN_MARK "?" + +#define RJUST 70 + +CPlugin::CPlugin() { + pluginID = UUID_NULL; +} + +CPlugin::CPlugin(LPCTSTR eFileName, LPCTSTR eShortName, MUUID pluginID, LPCTSTR eUnicodeInfo, DWORD eVersion, LPCTSTR eTimestamp, LPCTSTR eLinkedModules) { + lpzFileName = eFileName; + lpzShortName = eShortName; + lpzUnicodeInfo = eUnicodeInfo; + lpzTimestamp = eTimestamp; + lpzLinkedModules = eLinkedModules; + + TCHAR aux[128]; + mir_sntprintf(aux, SIZEOF(aux), _T("%d.%d.%d.%d"), (eVersion>>24)&0xFF, (eVersion>>16)&0xFF, (eVersion>>8)&0xFF, (eVersion)&0xFF); + lpzVersion = aux; + + this->pluginID = pluginID; +}; + +CPlugin::CPlugin(const CPlugin& other) { + lpzFileName = other.lpzFileName; + lpzShortName = other.lpzShortName; + lpzUnicodeInfo = other.lpzUnicodeInfo; + lpzVersion = other.lpzVersion; + lpzTimestamp = other.lpzTimestamp; + lpzLinkedModules = other.lpzLinkedModules; + pluginID = other.pluginID; +} + +CPlugin::~CPlugin() { + //Debug information +// char str[64]; wsprintf(str, "~CPlugin(): %s", lpzFileName.c_str()); +// MB(str); + // + lpzFileName.~basic_string(); + lpzShortName.~basic_string(); + lpzVersion.~basic_string(); + lpzUnicodeInfo.~basic_string(); + lpzTimestamp.~basic_string(); + lpzLinkedModules.~basic_string(); +} + +void CPlugin::SetErrorMessage(LPCTSTR error) +{ + lpzLinkedModules = error; +} + +bool CPlugin::operator<(CPlugin &anotherPlugin) +{ + std::tstring anotherFileName = anotherPlugin.getFileName(); + + TCHAR szThis[MAX_PATH]; lstrcpy(szThis, lpzFileName.c_str()); + TCHAR szThat[MAX_PATH]; lstrcpy(szThat, anotherFileName.c_str()); + + if (lstrcmpi(szThis, szThat) < 0) + return TRUE; + else + return FALSE; +} + +bool CPlugin::operator>(CPlugin &anotherPlugin) +{ + return !((*this) < anotherPlugin); +} +bool CPlugin::operator==(CPlugin &anotherPlugin) +{ + return !((*this) < anotherPlugin || (*this) > anotherPlugin); +} + +std::tstring CPlugin::getFileName() +{ + return this->lpzFileName; +} + +std::tstring CPlugin::getInformations(DWORD flags, TCHAR *szHighlightHeader, TCHAR *szHighlightFooter) +{ + std::tstring lpzInformations; + if (flags & VISF_SHOWUUID) + { + TCHAR aux[128]; + UUIDToString(pluginID, aux, SIZEOF(aux)); + lpzInformations = aux; + } + else lpzInformations = (IsUUIDNull(pluginID)) ? _T(" ") : PLUGIN_UUID_MARK; + + lpzInformations += std::tstring(_T(" ") + lpzFileName + _T(" v.") + szHighlightHeader + lpzVersion + szHighlightFooter + _T(" [") + lpzTimestamp + _T("] - ") + lpzShortName); + if (lpzUnicodeInfo.size() > 0) + { + TCHAR *lwr = _tcslwr(_tcsdup(lpzShortName.c_str())); + if ( !_tcsstr(lwr, _T("unicode")) && !_tcsstr(lwr, _T("2in1"))) + lpzInformations.append( _T(" |") + lpzUnicodeInfo + _T("|")); + + free(lwr); + } + //lpzInformations.append("\t"); + //lpzInformations.append(lpzPluginID); + lpzInformations.append( _T("\r\n")); + + if (lpzLinkedModules.size() > 0) + { + lpzInformations.append(lpzLinkedModules); + lpzInformations.append( _T("\r\n")); + } +// std::string lpzInformations = std::string(lpzFileName + " - " + lpzShortName + " [" + lpzTimestamp + " · " + lpzVersion +"]\r\n"); + return lpzInformations; +}; \ No newline at end of file diff --git a/plugins/VersionInfo/CPlugin.h b/plugins/VersionInfo/CPlugin.h new file mode 100644 index 0000000000..5da1b1dc6b --- /dev/null +++ b/plugins/VersionInfo/CPlugin.h @@ -0,0 +1,73 @@ +/* +Version information plugin for Miranda IM + +Copyright © 2002-2006 Luca Santarelli, Cristian Libotean + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + + +#ifndef CPLUGIN_H +#define CPLUGIN_H + +//#define STRICT +#define WIN32_LEAN_AND_MEAN + +#define _CRT_SECURE_NO_DEPRECATE + +#include +#include + +#ifndef M_NEWPLUGINAPI_H__ + #include "newpluginapi.h" +#endif + +#define DEF_UUID_CHARMARK "¤" + +extern const int cPLUGIN_UUID_MARK; +extern TCHAR PLUGIN_UUID_MARK[]; + +//using namespace std; + + + #define tstring wstring + + +class CPlugin { + private: + std::tstring lpzFileName; + std::tstring lpzShortName; + std::tstring lpzVersion; + std::tstring lpzUnicodeInfo; //aditional info, Unicode aware ... + std::tstring lpzTimestamp; //to show the last modified timestamp + std::tstring lpzLinkedModules; //to show linked modules that aren't found + MUUID pluginID; + + public: + CPlugin(); + CPlugin(LPCTSTR fileName, LPCTSTR shortName, MUUID pluginID, LPCTSTR unicodeInfo, DWORD version, LPCTSTR timestamp, LPCTSTR linkedModules); + CPlugin(const CPlugin&); + ~CPlugin(); + std::tstring getFileName(); + std::tstring getInformations(DWORD, TCHAR *, TCHAR *); + + void SetErrorMessage(LPCTSTR error); + + //Operators + bool operator<(CPlugin&); + bool operator>(CPlugin&); + bool operator==(CPlugin&); +}; +#endif \ No newline at end of file diff --git a/plugins/VersionInfo/CVersionInfo.cpp b/plugins/VersionInfo/CVersionInfo.cpp new file mode 100644 index 0000000000..d35c0c5c01 --- /dev/null +++ b/plugins/VersionInfo/CVersionInfo.cpp @@ -0,0 +1,1198 @@ +/* +Version information plugin for Miranda IM + +Copyright © 2002-2006 Luca Santarelli, Cristian Libotean + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + + +#include "CVersionInfo.h" +//#include "AggressiveOptimize.h" + +#include "common.h" +#include "resource.h" + +//using namespace std; + +BOOL (WINAPI *MyGetDiskFreeSpaceEx)(LPCTSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER); +BOOL (WINAPI *MyIsWow64Process)(HANDLE, PBOOL); +void (WINAPI *MyGetSystemInfo)(LPSYSTEM_INFO); +BOOL (WINAPI *MyGlobalMemoryStatusEx)(LPMEMORYSTATUSEX lpBuffer) = NULL; + +LANGID (WINAPI *MyGetUserDefaultUILanguage)() = NULL; +LANGID (WINAPI *MyGetSystemDefaultUILanguage)() = NULL; + +static int ValidExtension(TCHAR *fileName, TCHAR *extension) +{ + TCHAR *dot = _tcschr(fileName, '.'); + if ( dot != NULL && !lstrcmpi(dot + 1, extension)) + if (dot[lstrlen(extension) + 1] == 0) + return 1; + + return 0; +} + +void FillLocalTime(std::tstring &output, FILETIME *fileTime) +{ + TIME_ZONE_INFORMATION tzInfo = {0}; + FILETIME local = {0}; + SYSTEMTIME sysTime; + TCHAR date[1024]; + TCHAR time[256]; + + FileTimeToLocalFileTime(fileTime, &local); + FileTimeToSystemTime(&local, &sysTime); + + GetDateFormat(EnglishLocale, 0, &sysTime, _T("dd' 'MMM' 'yyyy"), date, SIZEOF(date)); + GetTimeFormat(NULL, TIME_FORCE24HOURFORMAT, &sysTime, _T("HH':'mm':'ss"), time, SIZEOF(time)); //americans love 24hour format ;) + output = std::tstring(date) + _T(" at ") + std::tstring(time); + + int res = GetTimeZoneInformation(&tzInfo); + char tzName[32] = {0}; + TCHAR tzOffset[64] = {0}; + int offset = 0; + switch (res) { + case TIME_ZONE_ID_DAYLIGHT: + offset = -(tzInfo.Bias + tzInfo.DaylightBias); + WideCharToMultiByte(CP_ACP, 0, tzInfo.DaylightName, -1, tzName, SIZEOF(tzName), NULL, NULL); + break; + + case TIME_ZONE_ID_STANDARD: + WideCharToMultiByte(CP_ACP, 0, tzInfo.StandardName, -1, tzName, SIZEOF(tzName), NULL, NULL); + offset = -(tzInfo.Bias + tzInfo.StandardBias); + break; + + case TIME_ZONE_ID_UNKNOWN: + WideCharToMultiByte(CP_ACP, 0, tzInfo.StandardName, -1, tzName, SIZEOF(tzName), NULL, NULL); + offset = -tzInfo.Bias; + break; + } + + mir_sntprintf(tzOffset, SIZEOF(tzOffset), _T("UTC %+02d:%02d"), offset / 60, offset % 60); + output += _T(" (") + std::tstring(tzOffset) + _T(")"); +} + +CVersionInfo::CVersionInfo() +{ + luiFreeDiskSpace = 0; + bDEPEnabled = 0; +} + +CVersionInfo::~CVersionInfo() +{ + listInactivePlugins.clear(); + listActivePlugins.clear(); + listUnloadablePlugins.clear(); + + lpzMirandaVersion.~basic_string(); + lpzNightly.~basic_string(); + lpzUnicodeBuild.~basic_string(); + lpzBuildTime.~basic_string(); + lpzOSVersion.~basic_string(); + lpzMirandaPath.~basic_string(); + lpzCPUName.~basic_string(); + lpzCPUIdentifier.~basic_string(); +}; + +void CVersionInfo::Initialize() +{ +#ifdef _DEBUG + if (verbose) PUShowMessage("Before GetMirandaVersion().", SM_NOTIFY); +#endif + GetMirandaVersion(); + +#ifdef _DEBUG + if (verbose) PUShowMessage("Before GetProfileSettings().", SM_NOTIFY); +#endif + GetProfileSettings(); + +#ifdef _DEBUG + if (verbose) PUShowMessage("Before GetLangpackInfo().", SM_NOTIFY); +#endif + GetOSLanguages(); + GetLangpackInfo(); + +#ifdef _DEBUG + if (verbose) PUShowMessage("Before GetPluginLists().", SM_NOTIFY); +#endif + GetPluginLists(); + +#ifdef _DEBUG + if (verbose) PUShowMessage("Before GetOSVersion().", SM_NOTIFY); +#endif + GetOSVersion(); + +#ifdef _DEBUG + if (verbose) PUShowMessage("Before GetHWSettings().", SM_NOTIFY); +#endif + GetHWSettings(); + +#ifdef _DEBUG + if (verbose) PUShowMessage("Done with GetHWSettings().", SM_NOTIFY); +#endif +} + +bool CVersionInfo::GetMirandaVersion() +{ + //Miranda version + const BYTE str_size = 64; + char str[str_size]; + CallService(MS_SYSTEM_GETVERSIONTEXT, (WPARAM)str_size, (LPARAM)str); + this->lpzMirandaVersion = _A2T(str); + //Is it a nightly? + if (lpzMirandaVersion.find( _T("alpha"),0) != std::string::npos) + lpzNightly = _T("Yes"); + else + lpzNightly = _T("No"); + + if (lpzMirandaVersion.find( _T("Unicode"), 0) != std::string::npos) + lpzUnicodeBuild = _T("Yes"); + else + lpzUnicodeBuild = _T("No"); + + TCHAR time[128], date[128]; + GetModuleTimeStamp(date, time); + lpzBuildTime = std::tstring(time) + _T(" (UTC) on ") + std::tstring(date); + return TRUE; +} + +bool CVersionInfo::GetOSVersion() +{ + //Operating system informations + OSVERSIONINFO osvi = { 0 }; + osvi.dwOSVersionInfoSize = sizeof(osvi); + GetVersionEx(&osvi); + + //Now fill the private members. + TCHAR aux[256]; + wsprintf(aux, _T("%d.%d.%d %s"), osvi.dwMajorVersion, osvi.dwMinorVersion, LOWORD(osvi.dwBuildNumber), osvi.szCSDVersion); + lpzOSVersion = aux; + + //OSName + //Let's read the registry. + HKEY hKey; + TCHAR szKey[MAX_PATH], szValue[MAX_PATH]; + lstrcpyn(szKey, _T("Hardware\\Description\\System\\CentralProcessor\\0"), MAX_PATH); + if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, szKey, 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) { + DWORD type, size, result; + + lstrcpyn(szValue, _T("Identifier"), MAX_PATH); + result = RegQueryValueEx(hKey, szValue, 0, &type, NULL, &size); + if (result == ERROR_SUCCESS) { + TCHAR *aux = new TCHAR[size+1]; + result = RegQueryValueEx(hKey, szValue, 0, &type, (LPBYTE) aux, &size); + lpzCPUIdentifier = aux; + delete[] aux; + } + else { + NotifyError(GetLastError(), _T("RegQueryValueEx()"), __LINE__); + lpzCPUIdentifier = _T(""); + } + + lstrcpyn(szValue, _T("ProcessorNameString"), MAX_PATH); + result = RegQueryValueEx(hKey, szValue, 0, &type, NULL, &size); //get the size + if (result == ERROR_SUCCESS) { + TCHAR *aux = new TCHAR[size+1]; + result = RegQueryValueEx(hKey, szValue, 0, &type, (LPBYTE) aux, &size); + lpzCPUName = aux; + delete[] aux; + } + else { //else try to use cpuid instruction to get the proc name + char szName[50]; + #if (!defined(WIN64) && !defined(_WIN64)) + __asm + { + push eax //save the registers + push ebx + push ecx + push edx + + xor eax, eax //get simple name + cpuid + mov DWORD PTR szName[0], ebx + mov DWORD PTR szName[4], edx + mov DWORD PTR szName[8], ecx + mov DWORD PTR szName[12], 0 + + mov eax, 0x80000000 //try to get pretty name + cpuid + + cmp eax, 0x80000004 + jb end //if we don't have the extension end the check + + mov DWORD PTR szName[0], 0 //make the string null + + mov eax, 0x80000002 //first part of the string + cpuid + mov DWORD PTR szName[0], eax + mov DWORD PTR szName[4], ebx + mov DWORD PTR szName[8], ecx + mov DWORD PTR szName[12], edx + + mov eax, 0x80000003 //second part of the string + cpuid + mov DWORD PTR szName[16], eax + mov DWORD PTR szName[20], ebx + mov DWORD PTR szName[24], ecx + mov DWORD PTR szName[28], edx + + mov eax, 0x80000004 //third part of the string + cpuid + mov DWORD PTR szName[32], eax + mov DWORD PTR szName[36], ebx + mov DWORD PTR szName[40], ecx + mov DWORD PTR szName[44], edx + +end: + pop edx //load them back + pop ecx + pop ebx + pop eax + } + szName[SIZEOF(szName) - 1] = '\0'; + #else + szName[0] = 0; + #endif + + if ( !szName[0] ) + lpzCPUName = _T(""); + else + lpzCPUName = _A2T(szName); + } + } + + bDEPEnabled = IsProcessorFeaturePresent(PF_NX_ENABLED); + + switch (osvi.dwPlatformId) { + case VER_PLATFORM_WIN32_WINDOWS: + lstrcpyn(szKey, _T("Software\\Microsoft\\Windows\\CurrentVersion"), MAX_PATH); + lstrcpyn(szValue, _T("Version"), MAX_PATH); + break; + case VER_PLATFORM_WIN32_NT: + + lstrcpyn(szKey, _T("Software\\Microsoft\\Windows NT\\CurrentVersion"), MAX_PATH); + lstrcpyn(szValue, _T("ProductName"), MAX_PATH); + break; + } + + RegCloseKey(hKey); + if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,szKey,0,KEY_QUERY_VALUE,&hKey) == ERROR_SUCCESS) { + DWORD type, size, result; + //Get the size of the value we'll read. + result = RegQueryValueEx((HKEY)hKey,szValue,(LPDWORD)NULL, (LPDWORD)&type,(LPBYTE)NULL, + (LPDWORD)&size); + if (result == ERROR_SUCCESS) { + //Read it. + TCHAR *aux = new TCHAR[size+1]; + result = RegQueryValueEx((HKEY)hKey,szValue,(LPDWORD)NULL, (LPDWORD)&type,(LPBYTE)aux,(LPDWORD)&size); + lpzOSName = aux; + delete[] aux; + } + else { + NotifyError(GetLastError(), _T("RegQueryValueEx()"), __LINE__); + lpzOSName = _T(""); + } + } + else { + NotifyError(GetLastError(), _T("RegOpenKeyEx()"), __LINE__); + lpzOSName = _T(""); + } + + //Now we can improve it if we can. + switch (LOWORD(osvi.dwBuildNumber)) { + case 950: lpzOSName = _T("Microsoft Windows 95"); break; + case 1111: lpzOSName = _T("Microsoft Windows 95 OSR2"); break; + case 1998: lpzOSName = _T("Microsoft Windows 98"); break; + case 2222: lpzOSName = _T("Microsoft Windows 98 SE"); break; + case 3000: lpzOSName = _T("Microsoft Windows ME"); break; //Even if this is wrong, we have already read it in the registry. + case 1381: lpzOSName = _T("Microsoft Windows NT"); break; //What about service packs? + case 2195: lpzOSName = _T("Microsoft Windows 2000"); break; //What about service packs? + case 2600: lpzOSName = _T("Microsoft Windows XP"); break; + case 3790: + if ( GetSystemMetrics( 89 )) //R2 ? + lpzOSName = _T("Microsoft Windows 2003 R2"); + else + lpzOSName = _T("Microsoft Windows 2003"); + + break; //added windows 2003 info + } + + return TRUE; +} + +bool CVersionInfo::GetHWSettings() { + //Free space on Miranda Partition. + TCHAR szMirandaPath[MAX_PATH] = { 0 }; + { + GetModuleFileName(GetModuleHandle(NULL), szMirandaPath, SIZEOF(szMirandaPath)); + TCHAR* str2 = _tcsrchr(szMirandaPath,'\\'); + if ( str2 != NULL) *str2=0; + } + HMODULE hKernel32; + hKernel32 = LoadLibraryA("kernel32.dll"); + if (hKernel32) { + + MyGetDiskFreeSpaceEx = (BOOL (WINAPI *)(LPCTSTR,PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER))GetProcAddress(hKernel32, "GetDiskFreeSpaceExW"); + + + MyIsWow64Process = (BOOL (WINAPI *) (HANDLE, PBOOL)) GetProcAddress(hKernel32, "IsWow64Process"); + MyGetSystemInfo = (void (WINAPI *) (LPSYSTEM_INFO)) GetProcAddress(hKernel32, "GetNativeSystemInfo"); + MyGlobalMemoryStatusEx = (BOOL (WINAPI *) (LPMEMORYSTATUSEX)) GetProcAddress(hKernel32, "GlobalMemoryStatusEx"); + if ( !MyGetSystemInfo ) + MyGetSystemInfo = GetSystemInfo; + + FreeLibrary(hKernel32); + } + if ( MyGetDiskFreeSpaceEx ) { + ULARGE_INTEGER FreeBytes, a, b; + MyGetDiskFreeSpaceEx(szMirandaPath, &FreeBytes, &a, &b); + //Now we need to convert it. + __int64 aux = FreeBytes.QuadPart; + aux /= (1024*1024); + luiFreeDiskSpace = (unsigned long int)aux; + } + else luiFreeDiskSpace = 0; + + TCHAR szInfo[1024]; + GetWindowsShell(szInfo, SIZEOF(szInfo)); + lpzShell = szInfo; + GetInternetExplorerVersion(szInfo, SIZEOF(szInfo)); + lpzIEVersion = szInfo; + + + lpzAdministratorPrivileges = (IsCurrentUserLocalAdministrator()) ? _T("Yes") : _T("No"); + + bIsWOW64 = 0; + if (MyIsWow64Process) + if (!MyIsWow64Process(GetCurrentProcess(), &bIsWOW64)) + bIsWOW64 = 0; + + SYSTEM_INFO sysInfo = {0}; + GetSystemInfo(&sysInfo); + luiProcessors = sysInfo.dwNumberOfProcessors; + + //Installed RAM + if (MyGlobalMemoryStatusEx) { //windows 2000+ + MEMORYSTATUSEX ms = {0}; + ms.dwLength = sizeof(ms); + MyGlobalMemoryStatusEx(&ms); + luiRAM = (unsigned int) ((ms.ullTotalPhys / (1024 * 1024)) + 1); + } + else { + MEMORYSTATUS ms = {0}; + ms.dwLength = sizeof(ms); + GlobalMemoryStatus(&ms); + luiRAM = (ms.dwTotalPhys/(1024*1024))+1; //Ugly hack!!!! + } + + return TRUE; +} + +bool CVersionInfo::GetProfileSettings() +{ + TCHAR* tszProfileName = Utils_ReplaceVarsT(_T("%miranda_userdata%\\%miranda_profilename%.dat")); + lpzProfilePath = tszProfileName; + + WIN32_FIND_DATA fd; + if ( FindFirstFile(tszProfileName, &fd) != INVALID_HANDLE_VALUE ) { + TCHAR number[40]; + mir_sntprintf( number, SIZEOF(number), _T("%.2f KBytes"), double(fd.nFileSizeLow) / 1024 ); + lpzProfileSize = number; + + FillLocalTime(lpzProfileCreationDate, &fd.ftCreationTime); + } + else { + DWORD error = GetLastError(); + TCHAR tmp[1024]; + wsprintf(tmp, _T("%d"), error); + lpzProfileCreationDate = _T("") + std::tstring(tszProfileName); + lpzProfileSize = _T("") + std::tstring(tszProfileName); + } + + mir_free( tszProfileName ); + return true; +} + +static TCHAR szSystemLocales[4096] = {0}; +static WORD systemLangID; +#define US_LANG_ID 0x00000409 + +BOOL CALLBACK EnumSystemLocalesProc(TCHAR *szLocale) +{ + DWORD locale = _ttoi(szLocale); + TCHAR *name = GetLanguageName(locale); + if ( !_tcsstr(szSystemLocales, name)) { + _tcscat(szSystemLocales, name); + _tcscat(szSystemLocales, _T(", ")); + } + + return TRUE; +} + +BOOL CALLBACK EnumResLangProc(HMODULE hModule, LPCTSTR lpszType, LPCTSTR lpszName, WORD wIDLanguage, LONG_PTR lParam) +{ + if (!lpszName) + return FALSE; + + if (wIDLanguage != US_LANG_ID) + systemLangID = wIDLanguage; + + return TRUE; +} + +bool CVersionInfo::GetOSLanguages() +{ + lpzOSLanguages = _T("(UI | Locale (User/System)) : "); + + LANGID UILang; + + OSVERSIONINFO os = {0}; + os.dwOSVersionInfoSize = sizeof(os); + GetVersionEx(&os); + if (os.dwMajorVersion == 4) { + if (os.dwPlatformId == VER_PLATFORM_WIN32_NT) { //Win NT + HMODULE hLib = LoadLibraryA("ntdll.dll"); + + if (hLib) { + EnumResourceLanguages(hLib, RT_VERSION, MAKEINTRESOURCE(1), EnumResLangProc, NULL); + + FreeLibrary(hLib); + + if (systemLangID == US_LANG_ID) { + UINT uiACP; + + uiACP = GetACP(); + switch (uiACP) + { + case 874: // Thai code page activated, it's a Thai enabled system + systemLangID = MAKELANGID(LANG_THAI, SUBLANG_DEFAULT); + break; + + case 1255: // Hebrew code page activated, it's a Hebrew enabled system + systemLangID = MAKELANGID(LANG_HEBREW, SUBLANG_DEFAULT); + break; + + case 1256: // Arabic code page activated, it's a Arabic enabled system + systemLangID = MAKELANGID(LANG_ARABIC, SUBLANG_ARABIC_SAUDI_ARABIA); + break; + + default: + break; + } + } + } + } + else { //Win 95-Me + HKEY hKey = NULL; + TCHAR szLangID[128] = _T("0x"); + DWORD size = SIZEOF(szLangID) - 2; + TCHAR err[512]; + + if (RegOpenKeyEx(HKEY_CURRENT_USER, _T("Control Panel\\Desktop\\ResourceLocale"), 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) { + if (RegQueryValueEx(hKey, _T(""), 0, NULL, (LPBYTE) &szLangID + 2, &size) == ERROR_SUCCESS) + _tscanf(szLangID, _T("%lx"), &systemLangID); + else { + FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 0, GetLastError(), LANG_SYSTEM_DEFAULT, err, size, NULL); + MessageBox(0, err, _T("Error at RegQueryValueEx()"), MB_OK); + } + RegCloseKey(hKey); + } + else { + FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 0, GetLastError(), LANG_SYSTEM_DEFAULT, err, size, NULL); + MessageBox(0, err, _T("Error at RegOpenKeyEx()"), MB_OK); + } + } + + lpzOSLanguages += GetLanguageName(systemLangID); + } + else { + HMODULE hKernel32 = LoadLibraryA("kernel32.dll"); + if (hKernel32) { + MyGetUserDefaultUILanguage = (LANGID (WINAPI *)()) GetProcAddress(hKernel32, "GetUserDefaultUILanguage"); + MyGetSystemDefaultUILanguage = (LANGID (WINAPI *)()) GetProcAddress(hKernel32, "GetSystemDefaultUILanguage"); + + FreeLibrary(hKernel32); + } + + if ((MyGetUserDefaultUILanguage) && (MyGetSystemDefaultUILanguage)) { + UILang = MyGetUserDefaultUILanguage(); + lpzOSLanguages += GetLanguageName(UILang); + lpzOSLanguages += _T("/"); + UILang = MyGetSystemDefaultUILanguage(); + lpzOSLanguages += GetLanguageName(UILang); + } + else lpzOSLanguages += _T("Missing functions in kernel32.dll (GetUserDefaultUILanguage, GetSystemDefaultUILanguage)"); + } + + lpzOSLanguages += _T(" | "); + lpzOSLanguages += GetLanguageName(LOCALE_USER_DEFAULT); + lpzOSLanguages += _T("/"); + lpzOSLanguages += GetLanguageName(LOCALE_SYSTEM_DEFAULT); + + if (DBGetContactSettingByte(NULL, ModuleName, "ShowInstalledLanguages", 0)) { + szSystemLocales[0] = '\0'; + lpzOSLanguages += _T(" ["); + EnumSystemLocales(EnumSystemLocalesProc, LCID_INSTALLED); + if (_tcslen(szSystemLocales) > 2) + szSystemLocales[ _tcslen(szSystemLocales) - 2] = '\0'; + + lpzOSLanguages += szSystemLocales; + lpzOSLanguages += _T("]"); + } + + return true; +} + +int SaveInfo(const char *data, const char *lwrData, const char *search, TCHAR *dest, int size) +{ + const char *pos = strstr(lwrData, search); + int res = 1; + if (pos == lwrData) { + _tcsncpy(dest, _A2T(&data[strlen(search)]), size); + res = 0; + } + + return res; +} + +bool CVersionInfo::GetLangpackInfo() +{ + TCHAR langpackPath[MAX_PATH] = {0}; + TCHAR search[MAX_PATH] = {0}; + + lpzLangpackModifiedDate = _T(""); + GetModuleFileName(GetModuleHandle(NULL), langpackPath, SIZEOF(langpackPath)); + TCHAR* p = _tcsrchr(langpackPath, '\\'); + if (p) { + WIN32_FIND_DATA data = {0}; + HANDLE hLangpack; + + p[1] = '\0'; + _tcscpy(search, langpackPath); + _tcscat(search, _T("langpack_*.txt")); + hLangpack = FindFirstFile(search, &data); + if (hLangpack != INVALID_HANDLE_VALUE) { + char buffer[1024]; + char temp[1024]; + FillLocalTime(lpzLangpackModifiedDate, &data.ftLastWriteTime); + + TCHAR locale[128] = {0}; + TCHAR language[128] = {0}; + TCHAR version[128] = {0}; + _tcscpy(version, _T("N/A")); + + _tcsncpy(language, data.cFileName, SIZEOF(language)); + p = _tcsrchr(language, '.'); + p[0] = '\0'; + + _tcscat(langpackPath, data.cFileName); + FILE *fin = _tfopen(langpackPath, _T("rt")); + if (fin) { + size_t len; + while (!feof(fin)) { + fgets(buffer, SIZEOF(buffer), fin); + len = strlen(buffer); + if (buffer[len - 1] == '\n') buffer[len - 1] = '\0'; + strncpy(temp, buffer, SIZEOF(temp)); + _strlwr(temp); + if (SaveInfo(buffer, temp, "language: ", language, SIZEOF(language))) { + if (SaveInfo(buffer, temp, "locale: ", locale, SIZEOF(locale))) { + char* p = strstr(buffer, "; FLID: "); + if (p) { + int ok = 1; + int i; + for (i = 0; ((i < 3) && (ok)); i++) { + p = strrchr(temp, '.'); + if (p) + p[0] = '\0'; + else + ok = 0; + } + p = strrchr(temp, ' '); + if ((ok) && (p)) + _tcsncpy(version, _A2T(&buffer[p - temp + 1]), SIZEOF(version)); + else + _tcsncpy(version, _T(""), SIZEOF(version)); + } } } } + + lpzLangpackInfo = std::tstring(language) + _T(" [") + std::tstring(locale) + _T("]"); + if ( version[0] ) + lpzLangpackInfo += _T(" v. ") + std::tstring(version); + + fclose(fin); + } + else { + int err = GetLastError(); + lpzLangpackInfo = _T(" Could not open file " + std::tstring(data.cFileName)); + } + FindClose(hLangpack); + } + else lpzLangpackInfo = _T("No language pack installed"); + } + + return true; +} + +std::tstring GetPluginTimestamp(FILETIME *fileTime) +{ + SYSTEMTIME sysTime; + FileTimeToSystemTime(fileTime, &sysTime); //convert the file tyme to system time + + //char time[256]; + TCHAR date[256]; //lovely + GetDateFormat(EnglishLocale, 0, &sysTime, _T("dd' 'MMM' 'yyyy"), date, SIZEOF(date)); + return date; +} + +bool CVersionInfo::GetPluginLists() +{ + HANDLE hFind; + TCHAR szMirandaPath[MAX_PATH] = { 0 }, szSearchPath[MAX_PATH] = { 0 }; //For search purpose + WIN32_FIND_DATA fd; + TCHAR szMirandaPluginsPath[MAX_PATH] = { 0 }, szPluginPath[MAX_PATH] = { 0 }; //For info reading purpose + BYTE PluginIsEnabled = 0; + HINSTANCE hInstPlugin = NULL; + PLUGININFOEX *(*MirandaPluginInfo)(DWORD); //These two are used to get informations from the plugin. + PLUGININFOEX *pluginInfo = NULL; //Read above. + DWORD mirandaVersion = 0; + BOOL asmCheckOK = FALSE; + DWORD loadError; + // SYSTEMTIME sysTime; //for timestamp + + mirandaVersion=(DWORD)CallService(MS_SYSTEM_GETVERSION,0,0); + { + GetModuleFileName(GetModuleHandle(NULL), szMirandaPath, SIZEOF(szMirandaPath)); + TCHAR* str2 = _tcsrchr(szMirandaPath,'\\'); + if(str2!=NULL) *str2=0; + } + lpzMirandaPath = szMirandaPath; + + //We got Miranda path, now we'll use it for two different purposes. + //1) finding plugins. + //2) Reading plugin infos + lstrcpyn(szSearchPath,szMirandaPath, MAX_PATH); //We got the path, now we copy it into szSearchPath. We'll use szSearchPath as am auxiliary variable, while szMirandaPath will keep a "fixed" value. + lstrcat(szSearchPath, _T("\\Plugins\\*.dll")); + + lstrcpyn(szMirandaPluginsPath, szMirandaPath, MAX_PATH); + lstrcat(szMirandaPluginsPath, _T("\\Plugins\\")); + + hFind=FindFirstFile(szSearchPath,&fd); + if ( hFind != INVALID_HANDLE_VALUE) { + do { + if (verbose) PUShowMessageT(fd.cFileName, SM_NOTIFY); + if (!ValidExtension(fd.cFileName, _T("dll"))) + continue; //do not report plugins that do not have extension .dll + + hInstPlugin = GetModuleHandle(fd.cFileName); //try to get the handle of the module + + if (hInstPlugin) //if we got it then the dll is loaded (enabled) + PluginIsEnabled = 1; + else { + PluginIsEnabled = 0; + lstrcpyn(szPluginPath, szMirandaPluginsPath, MAX_PATH); // szPluginPath becomes "drive:\path\Miranda\Plugins\" + lstrcat(szPluginPath, fd.cFileName); // szPluginPath becomes "drive:\path\Miranda\Plugins\popup.dll" + hInstPlugin = LoadLibrary(szPluginPath); + } + if (!hInstPlugin) { //It wasn't loaded. + loadError = GetLastError(); + int bUnknownError = 1; //assume plugin didn't load because of unknown error + //Some error messages. + //get the dlls the plugin statically links to + if (DBGetContactSettingByte(NULL, ModuleName, "CheckForDependencies", TRUE)) + { + std::tstring linkedModules; + + lstrcpyn(szPluginPath, szMirandaPluginsPath, MAX_PATH); // szPluginPath becomes "drive:\path\Miranda\Plugins\" + lstrcat(szPluginPath, fd.cFileName); // szPluginPath becomes "drive:\path\Miranda\Plugins\popup.dll" + if (GetLinkedModulesInfo(szPluginPath, linkedModules)) { + std::tstring time = GetPluginTimestamp(&fd.ftLastWriteTime); + CPlugin thePlugin(fd.cFileName, _T(""), UUID_NULL, _T(""), 0, time.c_str(), linkedModules.c_str()); + AddPlugin(thePlugin, listUnloadablePlugins); + bUnknownError = 0; //we know why the plugin didn't load + } + } + if (bUnknownError) { //if cause is unknown then report it + std::tstring time = GetPluginTimestamp(&fd.ftLastWriteTime); + TCHAR buffer[4096]; + TCHAR error[2048]; + //DWORD_PTR arguments[2] = {loadError, 0}; + FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ARGUMENT_ARRAY, NULL, loadError, 0, error, SIZEOF(error), NULL); + wsprintf(buffer, _T(" Error %ld - %s"), loadError, error); + CPlugin thePlugin( fd.cFileName, _T(""), UUID_NULL, _T(""), 0, time.c_str(), buffer); + AddPlugin(thePlugin, listUnloadablePlugins); + } + } + else { //It was successfully loaded. + MirandaPluginInfo = (PLUGININFOEX *(*)(DWORD))GetProcAddress(hInstPlugin, "MirandaPluginInfoEx"); + if (!MirandaPluginInfo) + MirandaPluginInfo = (PLUGININFOEX *(*)(DWORD))GetProcAddress(hInstPlugin, "MirandaPluginInfo"); + + if (!MirandaPluginInfo) //There is no function: it's not a valid plugin. Let's move on to the next file. + continue; + + //It's a valid plugin, since we could find MirandaPluginInfo + #if (!defined(WIN64) && !defined(_WIN64)) + asmCheckOK = FALSE; + __asm { + push mirandaVersion + push mirandaVersion + call MirandaPluginInfo + pop eax + pop eax + cmp eax, mirandaVersion + jne a1 + mov asmCheckOK, 0xffffffff + a1: + } + #else + asmCheckOK = TRUE; + #endif + if (asmCheckOK) + pluginInfo = CopyPluginInfo(MirandaPluginInfo(mirandaVersion)); + else { + ZeroMemory(&pluginInfo, sizeof(pluginInfo)); + MessageBox(NULL, fd.cFileName, _T("Invalid plugin"), MB_OK); + } } + + //Let's get the info. + if (MirandaPluginInfo != NULL) {//a valid miranda plugin + if (pluginInfo != NULL) { + //We have loaded the informations into pluginInfo. + std::tstring timedate = GetPluginTimestamp(&fd.ftLastWriteTime); + CPlugin thePlugin(fd.cFileName, _A2T(pluginInfo->shortName), pluginInfo->uuid, (pluginInfo->flags & 1) ? _T("Unicode aware") : _T(""), (DWORD) pluginInfo->version, timedate.c_str(), _T("")); + + if (PluginIsEnabled) + AddPlugin(thePlugin, listActivePlugins); + else { + if ((IsUUIDNull(pluginInfo->uuid)) && (mirandaVersion >= PLUGIN_MAKE_VERSION(0,8,0,9))) { + thePlugin.SetErrorMessage( _T(" Plugin does not have an UUID and will not work with Miranda 0.8.\r\n")); + AddPlugin(thePlugin, listUnloadablePlugins); + } + else AddPlugin(thePlugin, listInactivePlugins); + + FreeLibrary(hInstPlugin); //We don't need it anymore. + } + FreePluginInfo(pluginInfo); + MirandaPluginInfo = NULL; + #ifdef _DEBUG + if (verbose) { + TCHAR szMsg[4096] = { 0 }; + wsprintf(szMsg, _T("Done with: %s"), fd.cFileName); + PUShowMessageT(szMsg, SM_NOTIFY); + } + #endif + } + else { //pluginINFO == NULL + pluginInfo = CopyPluginInfo(MirandaPluginInfo(PLUGIN_MAKE_VERSION(9, 9, 9, 9))); //let's see if the plugin likes this miranda version + char *szShortName = ""; + std::tstring time = GetPluginTimestamp(&fd.ftLastWriteTime); //get the plugin timestamp; + DWORD version = 0; + if (pluginInfo) { + szShortName = pluginInfo->shortName; + version = pluginInfo->version; + } + + CPlugin thePlugin(fd.cFileName, _A2T(szShortName), (pluginInfo) ? pluginInfo->uuid : UUID_NULL, (((pluginInfo) && (pluginInfo->flags & 1)) ? _T("Unicode aware") : _T("")), version, time.c_str(), _T(" Plugin refuses to load. Miranda version too old.")); + + AddPlugin(thePlugin, listUnloadablePlugins); + if (pluginInfo) + FreePluginInfo(pluginInfo); + } } + } + while (FindNextFile(hFind,&fd)); + FindClose(hFind); + } + return TRUE; +} + +bool CVersionInfo::AddPlugin(CPlugin &aPlugin, std::list &aList) { + std::list::iterator pos = aList.begin(); + bool inserted = FALSE; + + if (aList.begin() == aList.end()) { //It's empty + aList.push_back(aPlugin); + return TRUE; + } + else { //It's not empty + while (pos != aList.end()) { + //It can be either < or >, not equal. + if (aPlugin < (*pos)) { + aList.insert(pos, aPlugin); + return TRUE; + } + + //It's greater: we need to insert it. + pos++; + } } + + if (inserted == FALSE) { + aList.push_back(aPlugin); + return TRUE; + } + return TRUE; +}; + +static char *GetStringFromRVA(DWORD RVA, const LOADED_IMAGE *image) +{ + char *moduleName; + moduleName = (char *) ImageRvaToVa(image->FileHeader, image->MappedAddress, RVA, NULL); + return moduleName; +} + +bool CVersionInfo::GetLinkedModulesInfo(TCHAR *moduleName, std::tstring &linkedModules) +{ + LOADED_IMAGE image; + ULONG importTableSize; + IMAGE_IMPORT_DESCRIPTOR *importData; + //HMODULE dllModule; + linkedModules = _T(""); + bool result = false; + TCHAR szError[20]; + char* szModuleName = mir_t2a(moduleName); + if (MapAndLoad(szModuleName, NULL, &image, TRUE, TRUE) == FALSE) { + wsprintf(szError, _T("%d"), GetLastError()); + mir_free( szModuleName ); + linkedModules = _T("\r\n"); + return result; + } + mir_free( szModuleName ); + importData = (IMAGE_IMPORT_DESCRIPTOR *) ImageDirectoryEntryToData(image.MappedAddress, FALSE, IMAGE_DIRECTORY_ENTRY_IMPORT, &importTableSize); + if (!importData) { + wsprintf(szError, _T("%d"), GetLastError()); + linkedModules = _T("\r\n"); + } + else { + while (importData->Name) { + char *moduleName; + moduleName = GetStringFromRVA(importData->Name, &image); + if (!DoesDllExist(moduleName)) { + linkedModules.append( _T(" Plugin statically links to missing dll file: ") + std::tstring(_A2T(moduleName)) + _T("\r\n")); + result = true; + } + + importData++; //go to next record + } } + + // FreeLibrary(dllModule); + UnMapAndLoad(&image); //unload the image + return result; +} + +std::tstring CVersionInfo::GetListAsString(std::list &aList, DWORD flags, int beautify) { + std::list::iterator pos = aList.begin(); + std::tstring out = _T(""); +#ifdef _DEBUG + if (verbose) PUShowMessage("CVersionInfo::GetListAsString, begin.", SM_NOTIFY); +#endif + + TCHAR szHeader[32] = {0}; + TCHAR szFooter[32] = {0}; + if ((((flags & VISF_FORUMSTYLE) == VISF_FORUMSTYLE) || beautify) && (DBGetContactSettingByte(NULL, ModuleName, "BoldVersionNumber", TRUE))) { + GetStringFromDatabase("BoldBegin", _T("[b]"), szHeader, SIZEOF(szHeader)); + GetStringFromDatabase("BoldEnd", _T("[/b]"), szFooter, SIZEOF(szFooter)); + } + + while (pos != aList.end()) { + out.append(std::tstring((*pos).getInformations(flags, szHeader, szFooter))); + pos++; + } + #ifdef _DEBUG + if (verbose) PUShowMessage("CVersionInfo::GetListAsString, end.", SM_NOTIFY); + #endif + return out; +}; + +void CVersionInfo::BeautifyReport(int beautify, LPCTSTR szBeautifyText, LPCTSTR szNonBeautifyText, std::tstring &out) +{ + if (beautify) + out.append(szBeautifyText); + else + out.append(szNonBeautifyText); +} + +void CVersionInfo::AddInfoHeader(int suppressHeader, int forumStyle, int beautify, std::tstring &out) +{ + if (forumStyle) { //forum style + TCHAR szSize[256], szQuote[256]; + + GetStringFromDatabase("SizeBegin", _T("[size=1]"), szSize, SIZEOF(szSize)); + GetStringFromDatabase("QuoteBegin", _T("[quote]"), szQuote, SIZEOF(szQuote)); + out.append(szQuote); + out.append(szSize); + } + else out = _T(""); + + if (!suppressHeader) { + out.append( _T("Miranda IM - VersionInformation plugin by Hrk, modified by Eblis\r\n")); + if (!forumStyle) { + out.append( _T("Miranda's homepage: http://www.miranda-im.org/\r\n")); //changed homepage + out.append( _T("Miranda tools: http://miranda-im.org/download/\r\n\r\n")); //was missing a / before download + } } + + TCHAR buffer[1024]; //for beautification + GetStringFromDatabase("BeautifyHorizLine", _T("
"), buffer, SIZEOF(buffer)); + BeautifyReport(beautify, buffer, _T(""), out); + GetStringFromDatabase("BeautifyBlockStart", _T("
"), buffer, SIZEOF(buffer)); + BeautifyReport(beautify, buffer, _T(""), out); + if (!suppressHeader) { + //Time of report: + TCHAR lpzTime[12]; GetTimeFormat(LOCALE_USER_DEFAULT, 0, NULL, _T("HH':'mm':'ss"), lpzTime, SIZEOF(lpzTime)); + TCHAR lpzDate[32]; GetDateFormat(EnglishLocale, 0, NULL, _T("dd' 'MMMM' 'yyyy"), lpzDate, SIZEOF(lpzDate)); + out.append( _T("Report generated at: ") + std::tstring(lpzTime) + _T(" on ") + std::tstring(lpzDate) + _T("\r\n\r\n")); + } + + //Operating system + out.append(_T("CPU: ") + lpzCPUName + _T(" [") + lpzCPUIdentifier + _T("]")); + if (bDEPEnabled) + out.append(_T(" [DEP enabled]")); + + if (luiProcessors > 1) { + TCHAR noProcs[128]; + wsprintf(noProcs, _T(" [%d CPUs]"), luiProcessors); + out.append(noProcs); + } + out.append( _T("\r\n")); + + //RAM + TCHAR szRAM[64]; wsprintf(szRAM, _T("%d"), luiRAM); + out.append( _T("Installed RAM: ") + std::tstring(szRAM) + _T(" MBytes\r\n")); + + //operating system + out.append( _T("Operating System: ") + lpzOSName + _T(" [version: ") + lpzOSVersion + _T("]\r\n")); + + //shell, IE, administrator + out.append( _T("Shell: ") + lpzShell + _T(", Internet Explorer ") + lpzIEVersion + _T("\r\n")); + out.append( _T("Administrator privileges: ") + lpzAdministratorPrivileges + _T("\r\n")); + + //languages + out.append( _T("OS Languages: ") + lpzOSLanguages + _T("\r\n")); + + //FreeDiskSpace + if (luiFreeDiskSpace) { + TCHAR szDiskSpace[64]; wsprintf(szDiskSpace, _T("%d"), luiFreeDiskSpace); + out.append( _T("Free disk space on Miranda partition: ") + std::tstring(szDiskSpace) + _T(" MBytes\r\n")); + } + + //Miranda + out.append( _T("Miranda path: ") + lpzMirandaPath + _T("\r\n")); + out.append( _T("Miranda IM version: ") + lpzMirandaVersion); + if (bIsWOW64) + out.append( _T(" [running inside WOW64]")); + if (bServiceMode) + out.append( _T(" [service mode]")); + + out.append( _T("\r\nBuild time: ") + lpzBuildTime + _T("\r\n")); + out.append( _T("Profile path: ") + lpzProfilePath + _T("\r\n")); + out.append( _T("Profile size: ") + lpzProfileSize + _T("\r\n")); + out.append( _T("Profile creation date: ") + lpzProfileCreationDate + _T("\r\n")); + out.append( _T("Language pack: ") + lpzLangpackInfo); + out.append((lpzLangpackModifiedDate.size() > 0) ? _T(", modified: ") + lpzLangpackModifiedDate : _T("")); + out.append( _T("\r\n")); + + out.append( _T("Nightly: ") + lpzNightly + _T("\r\n")); + out.append( _T("Unicode core: ") + lpzUnicodeBuild); + + GetStringFromDatabase("BeautifyBlockEnd", _T("
"), buffer, SIZEOF(buffer)); + BeautifyReport(beautify, buffer, _T("\r\n"), out); +} + +void CVersionInfo::AddInfoFooter(int suppressFooter, int forumStyle, int beautify, std::tstring &out) +{ + //End of report + TCHAR buffer[1024]; //for beautification purposes + GetStringFromDatabase("BeautifyHorizLine", _T("
"), buffer, SIZEOF(buffer)); + if (!suppressFooter) { + BeautifyReport(beautify, buffer, _T("\r\n"), out); + out.append( _T("\r\nEnd of report.\r\n")); + } + + if (!forumStyle) { + if (!suppressFooter) + out.append( TranslateT("If you are going to use this report to submit a bug, remember to check the website for questions or help the developers may need.\r\nIf you don't check your bug report and give feedback, it will not be fixed!")); + } + else { + TCHAR szSize[256], szQuote[256]; + GetStringFromDatabase("SizeEnd", _T("[/size]"), szSize, SIZEOF(szSize)); + GetStringFromDatabase("QuoteEnd", _T("[/quote]"), szQuote, SIZEOF(szQuote)); + out.append(szSize); + out.append(szQuote); + } +} + +static void AddSectionAndCount(std::list list, LPCTSTR listText, std::tstring &out) +{ + TCHAR tmp[64]; + wsprintf(tmp, _T(" (%u)"), list.size()); + out.append(listText); + out.append( tmp ); + out.append( _T(":")); +} + +std::tstring CVersionInfo::GetInformationsAsString(int bDisableForumStyle) { + //Begin of report + std::tstring out; + int forumStyle = (bDisableForumStyle) ? 0 : DBGetContactSettingByte(NULL, ModuleName, "ForumStyle", TRUE); + int showUUID = DBGetContactSettingByte(NULL, ModuleName, "ShowUUIDs", FALSE); + int beautify = DBGetContactSettingByte(NULL, ModuleName, "Beautify", 0) & (!forumStyle); + int suppressHeader = DBGetContactSettingByte(NULL, ModuleName, "SuppressHeader", TRUE); + + DWORD flags = (forumStyle) | (showUUID << 1); + + AddInfoHeader(suppressHeader, forumStyle, beautify, out); + TCHAR normalPluginsStart[1024]; //for beautification purposes, for normal plugins text (start) + TCHAR normalPluginsEnd[1024]; //for beautification purposes, for normal plugins text (end) + TCHAR horizLine[1024]; //for beautification purposes + TCHAR buffer[1024]; //for beautification purposes + + TCHAR headerHighlightStart[10] = _T(""); + TCHAR headerHighlightEnd[10] = _T(""); + if (forumStyle) { + TCHAR start[128], end[128]; + GetStringFromDatabase("BoldBegin", _T("[b]"), start, SIZEOF(start)); + GetStringFromDatabase("BoldEnd", _T("[/b]"), end, SIZEOF(end)); + _tcsncpy(headerHighlightStart, start, SIZEOF(headerHighlightStart)); + _tcsncpy(headerHighlightEnd, end, SIZEOF(headerHighlightEnd)); + } + + //Plugins: list of active (enabled) plugins. + GetStringFromDatabase("BeautifyHorizLine", _T("
"), horizLine, SIZEOF(horizLine)); + BeautifyReport(beautify, horizLine, _T("\r\n"), out); + GetStringFromDatabase("BeautifyActiveHeaderBegin", _T(""), buffer, SIZEOF(buffer)); + BeautifyReport(beautify, buffer, headerHighlightStart, out); + AddSectionAndCount(listActivePlugins, _T("Active Plugins"), out); + GetStringFromDatabase("BeautifyActiveHeaderEnd", _T(""), buffer, SIZEOF(buffer)); + BeautifyReport(beautify, buffer, headerHighlightEnd, out); + out.append( _T("\r\n")); + + GetStringFromDatabase("BeautifyPluginsBegin", _T(""), normalPluginsStart, SIZEOF(normalPluginsStart)); + BeautifyReport(beautify, normalPluginsStart, _T(""), out); + out.append(GetListAsString(listActivePlugins, flags, beautify)); + GetStringFromDatabase("BeautifyPluginsEnd", _T(""), normalPluginsEnd, SIZEOF(normalPluginsEnd)); + BeautifyReport(beautify, normalPluginsEnd, _T(""), out); + //Plugins: list of inactive (disabled) plugins. + if ((!forumStyle) && ((DBGetContactSettingByte(NULL, ModuleName, "ShowInactive", TRUE)) || (bServiceMode))) { + BeautifyReport(beautify, horizLine, _T("\r\n"), out); + GetStringFromDatabase("BeautifyInactiveHeaderBegin", _T(""), buffer, SIZEOF(buffer)); + BeautifyReport(beautify, buffer, headerHighlightStart, out); + AddSectionAndCount(listInactivePlugins, _T("Inactive Plugins"), out); + GetStringFromDatabase("BeautifyInactiveHeaderEnd", _T(""), buffer, SIZEOF(buffer)); + BeautifyReport(beautify, buffer, headerHighlightEnd, out); + out.append( _T("\r\n")); + BeautifyReport(beautify, normalPluginsStart, _T(""), out); + out.append(GetListAsString(listInactivePlugins, flags, beautify)); + BeautifyReport(beautify, normalPluginsEnd, _T(""), out); + } + if (listUnloadablePlugins.size() > 0) { + BeautifyReport(beautify, horizLine, _T("\r\n"), out); + GetStringFromDatabase("BeautifyUnloadableHeaderBegin", _T(""), buffer, SIZEOF(buffer)); + BeautifyReport(beautify, buffer, headerHighlightStart, out); + AddSectionAndCount(listUnloadablePlugins, _T("Unloadable Plugins"), out); + GetStringFromDatabase("BeautifyUnloadableHeaderEnd", _T(""), buffer, SIZEOF(buffer)); + BeautifyReport(beautify, buffer, headerHighlightEnd, out); + out.append( _T("\r\n")); + BeautifyReport(beautify, normalPluginsStart, _T(""), out); + out.append(GetListAsString(listUnloadablePlugins, flags, beautify)); + BeautifyReport(beautify, normalPluginsEnd, _T(""), out); + } + AddInfoFooter(suppressHeader, forumStyle, beautify, out); + return out; +} + +//========== Print functions ===== + +void CVersionInfo::PrintInformationsToFile(const TCHAR *info) +{ + TCHAR buffer[MAX_PATH], outputFileName[MAX_PATH]; + if (bFoldersAvailable) { + FoldersGetCustomPathT(hOutputLocation, buffer, SIZEOF(buffer), _T("%miranda_path%")); + _tcscat(buffer, _T("\\VersionInfo.txt")); + } + else GetStringFromDatabase("OutputFile", _T("VersionInfo.txt"), buffer, SIZEOF(buffer)); + + RelativePathToAbsolute(buffer, outputFileName, SIZEOF(buffer)); + + FILE *fp = _tfopen(outputFileName, _T("wb")); + if ( fp != NULL ) { + char* utf = mir_utf8encodeT( info ); + fputs( "\xEF\xBB\xBF", fp); + fputs( utf, fp ); + fclose(fp); + + TCHAR mex[512]; + mir_sntprintf(mex, SIZEOF(mex), TranslateT("Information successfully written to file: \"%s\"."), outputFileName); + Log(mex); + } + else { + TCHAR mex[512]; + mir_sntprintf(mex, SIZEOF(mex), TranslateT("Error during the creation of file \"%s\". Disk may be full or write protected."), outputFileName); + Log(mex); + } +} + +void CVersionInfo::PrintInformationsToFile() +{ + PrintInformationsToFile( GetInformationsAsString().c_str()); +} + +void CVersionInfo::PrintInformationsToMessageBox() +{ + MessageBox(NULL, GetInformationsAsString().c_str(), _T("VersionInfo"), MB_OK); +} + +void CVersionInfo::PrintInformationsToOutputDebugString() +{ + OutputDebugString( GetInformationsAsString().c_str()); +} + + +void CVersionInfo::PrintInformationsToDialogBox() +{ + HWND DialogBox = CreateDialogParam(hInst, + MAKEINTRESOURCE(IDD_DIALOGINFO), + NULL, DialogBoxProc, (LPARAM) this); + + SetDlgItemText(DialogBox, IDC_TEXT, GetInformationsAsString().c_str()); +} + +void CVersionInfo::PrintInformationsToClipboard(bool showLog) +{ + if (GetOpenClipboardWindow()) { + Log( TranslateT("The clipboard is not available, retry.")); + return; + } + + OpenClipboard(NULL); + //Ok, let's begin, then. + EmptyClipboard(); + //Storage data we'll use. + LPTSTR lptstrCopy; + std::tstring aux = GetInformationsAsString(); + size_t length = aux.length() + 1; + HANDLE hData = GlobalAlloc(GMEM_MOVEABLE, length*sizeof(TCHAR) + 5); + //Lock memory, copy it, release it. + lptstrCopy = (LPTSTR)GlobalLock(hData); + lstrcpy(lptstrCopy, aux.c_str()); + lptstrCopy[length] = '\0'; + GlobalUnlock(hData); + //Now set the clipboard data. + + SetClipboardData(CF_UNICODETEXT, hData); + + //Remove the lock on the clipboard. + CloseClipboard(); + if (showLog) + Log( TranslateT("Information successfully copied into clipboard.")); +} diff --git a/plugins/VersionInfo/CVersionInfo.h b/plugins/VersionInfo/CVersionInfo.h new file mode 100644 index 0000000000..eb55b808fc --- /dev/null +++ b/plugins/VersionInfo/CVersionInfo.h @@ -0,0 +1,115 @@ +/* +Version information plugin for Miranda IM + +Copyright © 2002-2006 Luca Santarelli, Cristian Libotean + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#ifndef CVERSIONINFO_H +#define CVERSIONINFO_H + +//#define STRICT +#define WIN32_LEAN_AND_MEAN +//#include "AggressiveOptimize.h" + +#define _CRT_SECURE_NO_DEPRECATE + +#ifndef PF_NX_ENABLED + #define PF_NX_ENABLED 12 +#endif + +#include +#include +//using namespace std; + +#include "CPlugin.h" + +class CVersionInfo +{ + private: + //Informations related to Miranda: main informations. + std::tstring lpzMirandaVersion; + std::tstring lpzMirandaPath; + std::tstring lpzProfilePath; + std::tstring lpzProfileSize; + std::tstring lpzProfileCreationDate; + std::tstring lpzNightly; + std::tstring lpzUnicodeBuild; + std::tstring lpzCPUName; + std::tstring lpzCPUIdentifier; + std::tstring lpzBuildTime; + std::tstring lpzShell; + std::tstring lpzIEVersion; + std::tstring lpzAdministratorPrivileges; + std::tstring lpzOSLanguages; + std::tstring lpzLangpackInfo; + std::tstring lpzLangpackModifiedDate; + //Informations related to plugins + std::list listActivePlugins; + std::list listInactivePlugins; + std::list listUnloadablePlugins; + //OS and hardware informations. + std::tstring lpzOSVersion; + std::tstring lpzOSName; + unsigned int luiProcessors; + unsigned int luiRAM; + unsigned int luiFreeDiskSpace; + int bDEPEnabled; + BOOL bIsWOW64; + //Additional Miranda informations. + unsigned int luiContacts; + unsigned int luiEvents; + unsigned int luiUnreadEvents; + unsigned int luiDBSize; + bool bExpertSettingsOn; + //Configuration + + bool GetLinkedModulesInfo(TCHAR *moduleName, std::tstring &linkedModules); + + public: + //Constructor/Destructor + CVersionInfo(); + ~CVersionInfo(); + void Initialize(); + //Miranda informations + bool GetMirandaVersion(); + bool GetProfileSettings(); + bool GetOSLanguages(); + bool GetLangpackInfo(); + bool GetPluginLists(); + bool GetEventCount(); //TODO + //OSInformations + bool GetOSVersion(); + bool GetHWSettings(); + //Plugins + bool AddPlugin(CPlugin&, std::list&); + //Prints + + void PrintInformationsToFile(); + void PrintInformationsToFile(const TCHAR *info); + void PrintInformationsToDialogBox(); + void PrintInformationsToMessageBox(); + void PrintInformationsToOutputDebugString(); + void PrintInformationsToClipboard(bool); + + std::tstring GetListAsString(std::list&, DWORD flags, int beautify); + std::tstring GetInformationsAsString(int bDisableForumStyle = 0); + void BeautifyReport(int, LPCTSTR, LPCTSTR, std::tstring &); + void AddInfoHeader(int, int, int, std::tstring &); + void AddInfoFooter(int, int, int, std::tstring &); +}; + +#endif \ No newline at end of file diff --git a/plugins/VersionInfo/VersionInfo.html b/plugins/VersionInfo/VersionInfo.html new file mode 100644 index 0000000000..a955874979 --- /dev/null +++ b/plugins/VersionInfo/VersionInfo.html @@ -0,0 +1,11 @@ + + + +
+

Version Information Test Page

+ +

Version Information version 1.4.3.2

+

VersionInfo.zip

+
+ + diff --git a/plugins/VersionInfo/VersionInfo.ico b/plugins/VersionInfo/VersionInfo.ico new file mode 100644 index 0000000000..b026d584c2 Binary files /dev/null and b/plugins/VersionInfo/VersionInfo.ico differ diff --git a/plugins/VersionInfo/VersionInfo_10.vcxproj b/plugins/VersionInfo/VersionInfo_10.vcxproj new file mode 100644 index 0000000000..89490b37fa --- /dev/null +++ b/plugins/VersionInfo/VersionInfo_10.vcxproj @@ -0,0 +1,210 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + Svc_vi + {3CE5572B-B7B0-4D1C-9D10-4622FBA6198E} + + + + DynamicLibrary + Unicode + true + + + DynamicLibrary + Unicode + + + DynamicLibrary + true + Unicode + + + DynamicLibrary + Unicode + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(SolutionDir)$(Configuration)\Plugins\ + $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)\Plugins\ + $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)64\Plugins\ + $(SolutionDir)$(Configuration)64\Plugins\ + $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ + true + + + + Disabled + ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;VERSIONINFO_EXPORTS;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebugDLL + Level3 + EditAndContinue + 4996;%(DisableSpecificWarnings) + Use + common.h + + + _DEBUG;%(PreprocessorDefinitions) + ..\..\include\msapi + + + imagehlp.lib;%(AdditionalDependencies) + true + 0x25040000 + false + $(IntDir)$(TargetName).lib + Windows + $(SolutionDir)\lib + + + + + Full + OnlyExplicitInline + Size + ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;VERSIONINFO_EXPORTS;%(PreprocessorDefinitions) + true + true + Use + Level3 + 4996;%(DisableSpecificWarnings) + common.h + + + NDEBUG;%(PreprocessorDefinitions) + ..\..\include\msapi + + + imagehlp.lib;%(AdditionalDependencies) + true + true + true + 0x25040000 + false + $(IntDir)$(TargetName).lib + Windows + $(SolutionDir)\lib + + + + + ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + EnableFastChecks + MultiThreadedDebugDLL + Disabled + Use + common.h + WIN64;_DEBUG;_WINDOWS;_USRDLL;VERSIONINFO_EXPORTS;%(PreprocessorDefinitions) + Level3 + + + $(IntDir)$(TargetName).lib + imagehlp.lib;%(AdditionalDependencies) + true + Windows + 0x25040000 + false + $(SolutionDir)\lib + + + ..\..\include\msapi + _DEBUG;%(PreprocessorDefinitions) + + + + + ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + Full + OnlyExplicitInline + Size + Use + common.h + WIN64;NDEBUG;_WINDOWS;_USRDLL;VERSIONINFO_EXPORTS;%(PreprocessorDefinitions) + Level3 + true + true + + + $(IntDir)$(TargetName).lib + true + true + imagehlp.lib;%(AdditionalDependencies) + true + Windows + 0x25040000 + false + $(SolutionDir)\lib + + + ..\..\include\msapi + NDEBUG;%(PreprocessorDefinitions) + + + + + + + + + Create + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/plugins/VersionInfo/VersionInfo_10.vcxproj.filters b/plugins/VersionInfo/VersionInfo_10.vcxproj.filters new file mode 100644 index 0000000000..e0c4f5db2e --- /dev/null +++ b/plugins/VersionInfo/VersionInfo_10.vcxproj.filters @@ -0,0 +1,67 @@ + + + + + {0740347a-255e-4fb6-9e9a-14397010e8ad} + cpp;c;cxx;rc;def;r;odl;idl;hpj;bat + + + {691f667c-7c8a-4c3e-8990-a9b456b12230} + h;hpp;hxx;hm;inl + + + {b90941c8-389b-4c91-9298-f201b8740872} + ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Resource Files + + + + + Resource Files + + + \ No newline at end of file diff --git a/plugins/VersionInfo/common.h b/plugins/VersionInfo/common.h new file mode 100644 index 0000000000..3182abc660 --- /dev/null +++ b/plugins/VersionInfo/common.h @@ -0,0 +1,96 @@ +/* +Version information plugin for Miranda IM + +Copyright © 2002-2006 Luca Santarelli, Cristian Libotean + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#ifndef M_VERSIONINFO_COMMON_H +#define M_VERSIONINFO_COMMON_H + +#pragma warning(disable:4005) +#define _CRT_SECURE_NO_DEPRECATE +#pragma warning(default:4005) + +#define VIPF_NONE 0x0000 +#define VIPF_UNCERTAIN 0x0010 + +#define VISF_FORUMSTYLE 0x0001 +#define VISF_SHOWUUID 0x0002 +#define VISF_SHOWFLAGS 0x0004 + +#include +#include + +#include +#include +#include +#include + +#include +//using namespace std; + +#include "version.h" + +#include "m_versioninfo.h" +#include "hooked_events.h" +#include "services.h" +#include "dlgHandlers.h" + +#include "newpluginapi.h" +#include "m_system.h" +#include "m_langpack.h" +#include "m_database.h" +#include "m_skin.h" +#include "m_clist.h" +#include "m_options.h" +#include "m_popup.h" + +#include "m_utils.h" +#include "m_folders.h" +#include "win2k.h" + +#include "utils.h" + +#ifndef MS_DB_GETPROFILEPATH_BASIC //db3xSA +#define MS_DB_GETPROFILEPATH_BASIC "DB/GetProfilePathBasic" +#endif + +//main.cpp +extern HINSTANCE hInst; + +//main.cpp +extern HICON hiVIIcon; + +//main.cpp +extern DWORD EnglishLocale; + +//for folders support +extern BOOL bFoldersAvailable; +extern HANDLE hOutputLocation; + +//services.cpp +extern int bServiceMode; + +//main.cpp +extern char ModuleName[]; +extern BOOL verbose; + +#define DEFAULT_UPLOAD_PORT 51234 + +const MUUID UUID_NULL = {0x00000000, 0x0000, 0x0000, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}; + +#endif \ No newline at end of file diff --git a/plugins/VersionInfo/dlgHandlers.cpp b/plugins/VersionInfo/dlgHandlers.cpp new file mode 100644 index 0000000000..a1a81e6a51 --- /dev/null +++ b/plugins/VersionInfo/dlgHandlers.cpp @@ -0,0 +1,589 @@ +/* +Version information plugin for Miranda IM + +Copyright © 2002-2006 Luca Santarelli, Cristian Libotean + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include "common.h" +#include "dlgHandlers.h" + +const char *szQuoteStrings[] = {"[quote] | [/quote]", "[code] | [/code]", ""}; +const char *szSizeStrings[] = {"[size=1] | [/size]", "[size=1px] | [/size]", "[size=12] | [/size]", "[size=80] | [/size]", ""}; +const char *szBoldStrings[] = {"[b] | [/b]", "[u] | [/u]", "[b][u] | [/u][/b]", " | ", " | ", " | "}; +const int nQuoteCount = SIZEOF(szQuoteStrings); //get the number of quote strings +const int nSizeCount = SIZEOF(szSizeStrings); //get the number of size strings +const int nBoldCount = SIZEOF(szBoldStrings); //get the number of bold strings + +#define MAX_TEXT 4096*4 + +int AddInfoToComboboxes(HWND hWnd, int nQuotesComboBox, int nSizesComboBox, int nBoldComboBox) +{ + int i; + for (i = 0; i < nQuoteCount; i++) + SendDlgItemMessageA(hWnd, nQuotesComboBox, CB_ADDSTRING, 0, (LPARAM) szQuoteStrings[i]); + + for (i = 0; i < nSizeCount; i++) + SendDlgItemMessageA(hWnd, nSizesComboBox, CB_ADDSTRING, 0, (LPARAM) szSizeStrings[i]); + + for (i = 0; i < nBoldCount; i++) + SendDlgItemMessageA(hWnd, nBoldComboBox, CB_ADDSTRING, 0, (LPARAM) szBoldStrings[i]); + + return 0; +} + +void EnableAskComboboxes(HWND hWnd, int bEnable) +{ + EnableWindow(GetDlgItem(hWnd, IDC_ASK_BOLDCOMBOBOX), bEnable); + EnableWindow(GetDlgItem(hWnd, IDC_ASK_QUOTECOMBOBOX), bEnable); + EnableWindow(GetDlgItem(hWnd, IDC_ASK_SIZECOMBOBOX), bEnable); +} + +INT_PTR CALLBACK AskDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + const int MAX_SIZE = 128; + static int oldFSFValue; + static TCHAR oldQuoteBegin[MAX_SIZE], oldQuoteEnd[MAX_SIZE]; + static TCHAR oldSizeBegin[MAX_SIZE], oldSizeEnd[MAX_SIZE]; + static TCHAR oldBoldBegin[MAX_SIZE], oldBoldEnd[MAX_SIZE]; + + switch (msg) { + case WM_INITDIALOG: + SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM) hiVIIcon); + + TranslateDialogDefault(hWnd); + + oldFSFValue = DBGetContactSettingByte(NULL, ModuleName, "ForumStyle", 1); + + AddInfoToComboboxes(hWnd, IDC_ASK_QUOTECOMBOBOX, IDC_ASK_SIZECOMBOBOX, IDC_ASK_BOLDCOMBOBOX); + + CheckDlgButton(hWnd, IDC_ASK_TODIALOGBOX, BST_CHECKED); + + CheckDlgButton(hWnd, IDC_ASK_FORUMSTYLE, (oldFSFValue) ? BST_CHECKED : BST_UNCHECKED); + EnableAskComboboxes(hWnd, oldFSFValue); + { + TCHAR buffer[1024]; + GetStringFromDatabase("QuoteBegin", _T("[quote]"), oldQuoteBegin, MAX_SIZE); + GetStringFromDatabase("QuoteEnd", _T("[/quote]"), oldQuoteEnd, MAX_SIZE); + mir_sntprintf(buffer, SIZEOF(buffer), _T("%s | %s"), oldQuoteBegin, oldQuoteEnd); + SendDlgItemMessage(hWnd, IDC_ASK_QUOTECOMBOBOX, CB_SELECTSTRING, -1, (LPARAM) buffer); + + GetStringFromDatabase("SizeBegin", _T("[size=1]"), oldSizeBegin, MAX_SIZE); + GetStringFromDatabase("SizeEnd", _T("[/size]"), oldSizeEnd, MAX_SIZE); + mir_sntprintf(buffer, SIZEOF(buffer), _T("%s | %s"), oldSizeBegin, oldSizeEnd); + SendDlgItemMessage(hWnd, IDC_ASK_SIZECOMBOBOX, CB_SELECTSTRING, -1, (LPARAM) buffer); + + GetStringFromDatabase("BoldBegin", _T("[b]"), oldBoldBegin, MAX_SIZE); + GetStringFromDatabase("BoldEnd", _T("[/b]"), oldBoldEnd, MAX_SIZE); + mir_sntprintf(buffer, SIZEOF(buffer), _T("%s | %s"), oldBoldBegin, oldBoldEnd); + SendDlgItemMessage(hWnd, IDC_ASK_BOLDCOMBOBOX, CB_SELECTSTRING, -1, (LPARAM) buffer); + } + + return TRUE; + + case WM_CLOSE: + DestroyWindow(hWnd); + break; + + case WM_COMMAND: + switch (LOWORD(wParam)) { + case IDC_ASK_FORUMSTYLE: + EnableAskComboboxes(hWnd, IsDlgButtonChecked(hWnd, IDC_ASK_FORUMSTYLE)); + break; + + case IDC_ASK_CANCEL: + DestroyWindow(hWnd); + break; + + case IDC_ASK_OK: + TCHAR quoteBegin[MAX_SIZE], quoteEnd[MAX_SIZE]; + TCHAR sizeBegin[MAX_SIZE], sizeEnd[MAX_SIZE]; + TCHAR boldBegin[MAX_SIZE], boldEnd[MAX_SIZE]; + TCHAR buffer[1024]; + + SendDlgItemMessage(hWnd, IDC_ASK_QUOTECOMBOBOX, WM_GETTEXT, SIZEOF(buffer), (LPARAM) buffer); + SplitStringInfo(buffer, quoteBegin, quoteEnd); + SendDlgItemMessage(hWnd, IDC_ASK_SIZECOMBOBOX, WM_GETTEXT, SIZEOF(buffer), (LPARAM) buffer); + SplitStringInfo(buffer, sizeBegin, sizeEnd); + SendDlgItemMessage(hWnd, IDC_ASK_BOLDCOMBOBOX, WM_GETTEXT, SIZEOF(buffer), (LPARAM) buffer); + SplitStringInfo(buffer, boldBegin, boldEnd); + + int newFSFValue = IsDlgButtonChecked(hWnd, IDC_ASK_FORUMSTYLE); + if (newFSFValue != oldFSFValue) + DBWriteContactSettingByte(NULL, ModuleName, "ForumStyle", newFSFValue); //temporary store the new value + + if (newFSFValue) { + DBWriteContactSettingTString(NULL, ModuleName, "QuoteBegin", quoteBegin); + DBWriteContactSettingTString(NULL, ModuleName, "QuoteEnd", quoteEnd); + + DBWriteContactSettingTString(NULL, ModuleName, "SizeBegin", sizeBegin); + DBWriteContactSettingTString(NULL, ModuleName, "SizeEnd", sizeEnd); + + DBWriteContactSettingTString(NULL, ModuleName, "BoldBegin", boldBegin); + DBWriteContactSettingTString(NULL, ModuleName, "BoldEnd", boldEnd); + } + + int debugTo = TO_DIALOGBOX; //just to be safe + if (IsDlgButtonChecked(hWnd, IDC_ASK_TOFILE)) + debugTo = TO_FILE; + if (IsDlgButtonChecked(hWnd, IDC_ASK_TOMESSAGEBOX)) + debugTo = TO_MESSAGEBOX; + if (IsDlgButtonChecked(hWnd, IDC_ASK_TODIALOGBOX)) + debugTo = TO_DIALOGBOX; + if (IsDlgButtonChecked(hWnd, IDC_ASK_TOOUTPUTDEBUGSTRING)) + debugTo = TO_DEBUGSTRING; + if (IsDlgButtonChecked(hWnd, IDC_ASK_TOCLIPBOARD)) + debugTo = TO_CLIPBOARD; + if (IsDlgButtonChecked(hWnd, IDC_ASK_TOUPLOAD)) + debugTo = TO_UPLOAD; + + DoDebugTo(debugTo); + + if (newFSFValue != oldFSFValue) + DBWriteContactSettingByte(NULL, ModuleName, "ForumStyle", oldFSFValue); + + if (newFSFValue) { + DBWriteContactSettingTString(NULL, ModuleName, "QuoteBegin", oldQuoteBegin); + DBWriteContactSettingTString(NULL, ModuleName, "QuoteEnd", oldQuoteEnd); + + DBWriteContactSettingTString(NULL, ModuleName, "SizeBegin", oldSizeBegin); + DBWriteContactSettingTString(NULL, ModuleName, "SizeEnd", oldSizeEnd); + + DBWriteContactSettingTString(NULL, ModuleName, "BoldBegin", oldBoldBegin); + DBWriteContactSettingTString(NULL, ModuleName, "BoldEnd", oldBoldEnd); + } + + DestroyWindow(hWnd); + break; + } + break; + } + return 0; +} + +int DoDebugTo(int debugTo) +{ + HWND parent = NULL; + HWND askDialog; + CVersionInfo myInfo;// = CVersionInfo(); + if (verbose) PUShowMessage("I am going to read the information.", SM_NOTIFY); + if (debugTo != TO_ASK) + myInfo.Initialize(); + + if (verbose) PUShowMessage("I have read the information, I will now print them.", SM_NOTIFY); + + switch(debugTo) { + case TO_ASK: + askDialog = CreateDialog(hInst, MAKEINTRESOURCE(IDD_ASKDIALOG), parent, AskDlgProc); + ShowWindow(askDialog, SW_SHOW); + break; + + case TO_FILE: + myInfo.PrintInformationsToFile(); + break; + + case TO_MESSAGEBOX: + myInfo.PrintInformationsToMessageBox(); + break; + + case TO_DIALOGBOX: + myInfo.PrintInformationsToDialogBox(); + break; + + case TO_DEBUGSTRING: + myInfo.PrintInformationsToOutputDebugString(); + break; + + case TO_CLIPBOARD: + myInfo.PrintInformationsToClipboard(true); + break; + + default: + myInfo.PrintInformationsToFile(); + break; + } + + if ((debugTo != TO_CLIPBOARD) && (DBGetContactSettingByte(NULL, ModuleName, "ClipboardAlways", FALSE))) + myInfo.PrintInformationsToClipboard(false); + + if ((bServiceMode) && (debugTo != TO_DIALOGBOX) && (debugTo != TO_ASK)) //close miranda if in service mode and no dialog was shown + PostQuitMessage(0); + + return 0; +} + +void EnableUploadSettings(HWND hWnd, int bEnable) +{ + EnableWindow(GetDlgItem(hWnd, IDC_UPLOAD_SERVER), bEnable); + EnableWindow(GetDlgItem(hWnd, IDC_UPLOAD_PORT), bEnable); + EnableWindow(GetDlgItem(hWnd, IDC_UPLOAD_USERNAME), bEnable); + EnableWindow(GetDlgItem(hWnd, IDC_UPLOAD_PASSWORD), bEnable); +} + +INT_PTR CALLBACK DlgProcOpts(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + static int bOptionsInitializing = 0; + switch(msg) { + case WM_INITDIALOG: + bOptionsInitializing = 1; + TranslateDialogDefault(hWnd); + AddInfoToComboboxes(hWnd, IDC_QUOTECOMBOBOX, IDC_SIZECOMBOBOX, IDC_BOLDCOMBOBOX); + + CheckDlgButton(hWnd, IDC_FORUMSTYLE, (BOOL) DBGetContactSettingByte(NULL, ModuleName, "ForumStyle", TRUE) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hWnd, IDC_DISABLEDTOO, (BOOL) DBGetContactSettingByte(NULL, ModuleName, "ShowInactive", TRUE) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hWnd, IDC_SHOWUUIDS, (BOOL) DBGetContactSettingByte(NULL, ModuleName, "ShowUUIDs", FALSE) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hWnd, IDC_SHOWINSTALLEDLANGUAGES, (BOOL) DBGetContactSettingByte(NULL, ModuleName, "ShowInstalledLanguages", FALSE) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hWnd, IDC_SUPPRESSHEADER, (BOOL) DBGetContactSettingByte(NULL, ModuleName, "SuppressHeader", TRUE) ? BST_CHECKED : BST_UNCHECKED); + + CheckDlgButton(hWnd, IDC_SHOWINTASKBAR, (BOOL) DBGetContactSettingByte(NULL, ModuleName, "ShowInTaskbar", TRUE) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hWnd, IDC_CLIPBOARDALSO, (BOOL) DBGetContactSettingByte(NULL, ModuleName, "ClipboardAlways", FALSE) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hWnd, IDC_BOLDVERSION, (BOOL) DBGetContactSettingByte(NULL, ModuleName, "BoldVersionNumber", TRUE) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hWnd, IDC_CHECKUNLOADABLE, (BOOL) DBGetContactSettingByte(NULL, ModuleName, "CheckForDependencies", TRUE) ? BST_CHECKED : BST_UNCHECKED); + SetFocus(GetDlgItem(hWnd, IDC_FORUMSTYLE)); + { + DBVARIANT dbv = { 0 }; + bOptionsInitializing = 1; + TCHAR buffer[1024]; + TCHAR notFound[1024]; + + if (DBGetContactSettingTString(NULL, ModuleName, "OutputFile", &dbv) == 0) + RelativePathToAbsolute(dbv.ptszVal, notFound, SIZEOF(notFound)); + else + RelativePathToAbsolute( _T("VersionInfo.txt"), notFound, SIZEOF(notFound)); + + if (bFoldersAvailable) + _tcscpy(buffer, TranslateT("Customize using folders plugin")); + else + _tcsncpy(buffer, notFound, SIZEOF(notFound)); + + SetDlgItemText(hWnd, IDC_FILENAME, buffer); + + TCHAR start[256], end[256]; + GetStringFromDatabase("QuoteBegin", _T("[quote]"), start, SIZEOF(start)); + GetStringFromDatabase("QuoteEnd", _T("[/quote]"), end, SIZEOF(end)); + mir_sntprintf(buffer, SIZEOF(buffer), _T("%s | %s"), start, end); + SendDlgItemMessage(hWnd, IDC_QUOTECOMBOBOX, CB_SELECTSTRING, -1, (LPARAM) buffer); + + GetStringFromDatabase("SizeBegin", _T("[size=1]"), start, SIZEOF(start)); + GetStringFromDatabase("SizeEnd", _T("[/size]"), end, SIZEOF(end)); + mir_sntprintf(buffer, SIZEOF(buffer), _T("%s | %s"), start, end); + SendDlgItemMessage(hWnd, IDC_SIZECOMBOBOX, CB_SELECTSTRING, -1, (LPARAM) buffer); + + GetStringFromDatabase("BoldBegin", _T("[b]"), start, SIZEOF(start)); + GetStringFromDatabase("BoldEnd", _T("[/b]"), end, SIZEOF(end)); + mir_sntprintf(buffer, SIZEOF(buffer), _T("%s | %s"), start, end); + SendDlgItemMessage(hWnd, IDC_BOLDCOMBOBOX, CB_SELECTSTRING, -1, (LPARAM) buffer); + //to add stuff + + //upload server settings + GetStringFromDatabase("UploadServer", _T("vi.cass.cz"), buffer, SIZEOF(buffer)); + SetWindowText(GetDlgItem(hWnd, IDC_UPLOAD_SERVER), buffer); + + int port = DBGetContactSettingWord(NULL, ModuleName, "UploadPort", DEFAULT_UPLOAD_PORT); + _itot(port, buffer, 10); + SetWindowText(GetDlgItem(hWnd, IDC_UPLOAD_PORT), buffer); + + GetStringFromDatabase("UploadUser", _T(""), buffer, SIZEOF(buffer)); + SetWindowText(GetDlgItem(hWnd, IDC_UPLOAD_USERNAME), buffer); + + GetStringFromDatabase("UploadPassword", _T(""), buffer, SIZEOF(buffer)); + CallService(MS_DB_CRYPT_DECODESTRING, SIZEOF(buffer), (LPARAM) buffer); + SetWindowText(GetDlgItem(hWnd, IDC_UPLOAD_PASSWORD), buffer); + } + + switch(DBGetContactSettingByte(NULL, ModuleName, "DebugTo", TO_DIALOGBOX)) { + case TO_FILE: + CheckDlgButton(hWnd, IDC_TOFILE, BST_CHECKED); + break; + + case TO_MESSAGEBOX: + CheckDlgButton(hWnd, IDC_TOMESSAGEBOX, BST_CHECKED); + break; + + case TO_DIALOGBOX: + CheckDlgButton(hWnd, IDC_TODIALOGBOX, BST_CHECKED); + break; + + case TO_DEBUGSTRING: + CheckDlgButton(hWnd, IDC_TODEBUGSTRING, BST_CHECKED); + break; + + case TO_CLIPBOARD: + CheckDlgButton(hWnd, IDC_TOCLIPBOARD, BST_CHECKED); + break; + + case TO_UPLOAD: + CheckDlgButton(hWnd, IDC_TOUPLOAD, BST_CHECKED); + break; + + case TO_ASK: + CheckDlgButton(hWnd, IDC_ASKEVERYTIME, BST_CHECKED); + break; + + default: + CheckDlgButton(hWnd, IDC_TODIALOGBOX, BST_CHECKED); + break; + } + + EnableWindow(GetDlgItem(hWnd, IDC_QUOTECOMBOBOX), IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE) ? TRUE : FALSE); //forum style only + EnableWindow(GetDlgItem(hWnd, IDC_SIZECOMBOBOX), IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE) ? TRUE : FALSE); //forum style only + EnableWindow(GetDlgItem(hWnd, IDC_BOLDVERSION), IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE) ? TRUE : FALSE); //forum style only + EnableWindow(GetDlgItem(hWnd, IDC_BOLDCOMBOBOX), (IsDlgButtonChecked(hWnd, IDC_BOLDVERSION) & IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE)) ? TRUE : FALSE);//both forum style and bold version checked + EnableWindow(GetDlgItem(hWnd, IDC_SHOWINTASKBAR), IsDlgButtonChecked(hWnd, IDC_TODIALOGBOX) ? TRUE : FALSE); //only enable for to dialog box + EnableWindow(GetDlgItem(hWnd, IDC_DISABLEDTOO), IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE) ? FALSE : TRUE); //if forum style disable show disabled plugins + EnableWindow(GetDlgItem(hWnd, IDC_CLIPBOARDALSO), IsDlgButtonChecked(hWnd, IDC_TOCLIPBOARD) ? FALSE : TRUE); //don't enable always clipboard if we're printing to clipboard + EnableWindow(GetDlgItem(hWnd, IDC_FILENAME), ((IsDlgButtonChecked(hWnd, IDC_TOFILE)) && (!bFoldersAvailable)) ? TRUE : FALSE); + EnableUploadSettings(hWnd, IsDlgButtonChecked(hWnd, IDC_TOUPLOAD) ? TRUE : FALSE); + { + OSVERSIONINFO osvi = { 0 }; + osvi.dwOSVersionInfoSize = sizeof(osvi); + GetVersionEx(&osvi); + + if (osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) + EnableWindow(GetDlgItem(hWnd, IDC_CHECKUNLOADABLE), FALSE); + } + + CheckDlgButton(hWnd, IDC_DEBUG, (BOOL) verbose == TRUE ? BST_CHECKED : BST_UNCHECKED); + + SetFocus(GetDlgItem(hWnd, IDC_GETINFONOW)); + + bOptionsInitializing = 0; + break; + + case WM_COMMAND: + switch(LOWORD(wParam)) { + case IDC_ASKEVERYTIME: + case IDC_TOFILE: + case IDC_TOMESSAGEBOX: + case IDC_TODIALOGBOX: + case IDC_TODEBUGSTRING: + case IDC_TOCLIPBOARD: + case IDC_TOUPLOAD: + case IDC_FORUMSTYLE: + case IDC_BOLDVERSION: + EnableWindow(GetDlgItem(hWnd, IDC_QUOTECOMBOBOX), IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE) ? TRUE : FALSE); //forum style only + EnableWindow(GetDlgItem(hWnd, IDC_SIZECOMBOBOX), IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE) ? TRUE : FALSE); //forum style only + EnableWindow(GetDlgItem(hWnd, IDC_BOLDVERSION), IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE) ? TRUE : FALSE); //forum style only + EnableWindow(GetDlgItem(hWnd, IDC_BOLDCOMBOBOX), (IsDlgButtonChecked(hWnd, IDC_BOLDVERSION) & IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE)) ? TRUE : FALSE); //both forum style and bold version checked + EnableWindow(GetDlgItem(hWnd, IDC_FILENAME), ((IsDlgButtonChecked(hWnd, IDC_TOFILE)) && (!bFoldersAvailable)) ? TRUE : FALSE); + EnableWindow(GetDlgItem(hWnd, IDC_SHOWINTASKBAR), IsDlgButtonChecked(hWnd, IDC_TODIALOGBOX) ? TRUE : FALSE); //only enable for to dialog box + EnableWindow(GetDlgItem(hWnd, IDC_DISABLEDTOO), IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE) ? FALSE : TRUE); //if forum style disable show disabled plugins + EnableWindow(GetDlgItem(hWnd, IDC_CLIPBOARDALSO), IsDlgButtonChecked(hWnd, IDC_TOCLIPBOARD) ? FALSE : TRUE); //don't enable always clipboard if we're printing to clipboard + EnableUploadSettings(hWnd, IsDlgButtonChecked(hWnd, IDC_TOUPLOAD) ? TRUE : FALSE); + + case IDC_SHOWUUIDS: + if (IsDlgButtonChecked(hWnd, IDC_SHOWUUIDS) && MessageBox(hWnd, + TranslateT("Are you sure you want to enable this option ?\nPlease only enable this option if you really know what you're doing and what the option is for or if someone asked you to do it."), + TranslateT("Show plugin UUIDs ?"), MB_YESNO | MB_ICONWARNING) == IDNO) + { + CheckDlgButton(hWnd, IDC_SHOWUUIDS, FALSE); + + break; + }//else fallthrough + case IDC_DISABLEDTOO: + case IDC_SHOWINTASKBAR: + case IDC_CLIPBOARDALSO: + case IDC_CHECKUNLOADABLE: + case IDC_SUPPRESSHEADER: + case IDC_SHOWINSTALLEDLANGUAGES: + EnableWindow(GetDlgItem(hWnd, IDC_GETINFONOW), FALSE); + + case IDC_QUOTECOMBOBOX: + case IDC_SIZECOMBOBOX: + case IDC_BOLDCOMBOBOX: + if (!bOptionsInitializing) + SendMessage(GetParent(hWnd), PSM_CHANGED,0,0); + break; + + case IDC_FILENAME: + case IDC_UPLOAD_USERNAME: + case IDC_UPLOAD_PASSWORD: + case IDC_UPLOAD_PORT: + case IDC_UPLOAD_SERVER: + if ( HIWORD(wParam) == EN_CHANGE && !bOptionsInitializing) { + SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0); + EnableWindow(GetDlgItem(hWnd, IDC_GETINFONOW), FALSE); + } + break; + + case IDC_GETINFONOW: + //Call the plugin menu command routine. + PluginMenuCommand(0,0); + break; + + case IDC_DEBUG: + verbose = !verbose; + break; + } + + break; + + case WM_NOTIFY: + switch(((LPNMHDR)lParam)->idFrom) { + case 0: + switch (((LPNMHDR)lParam)->code) { + case PSN_APPLY: + { + TCHAR buffer[1024]; + TCHAR start[256], end[256]; + SendDlgItemMessage(hWnd, IDC_QUOTECOMBOBOX, WM_GETTEXT, SIZEOF(buffer), (LPARAM) buffer); + SplitStringInfo(buffer, start, end); + DBWriteContactSettingTString(NULL, ModuleName, "QuoteBegin", start); + DBWriteContactSettingTString(NULL, ModuleName, "QuoteEnd", end); + SendDlgItemMessage(hWnd, IDC_SIZECOMBOBOX, WM_GETTEXT, SIZEOF(buffer), (LPARAM) buffer); + SplitStringInfo(buffer, start, end); + DBWriteContactSettingTString(NULL, ModuleName, "SizeBegin", start); + DBWriteContactSettingTString(NULL, ModuleName, "SizeEnd", end); + SendDlgItemMessage(hWnd, IDC_BOLDCOMBOBOX, WM_GETTEXT, SIZEOF(buffer), (LPARAM) buffer); + SplitStringInfo(buffer, start, end); + DBWriteContactSettingTString(NULL, ModuleName, "BoldBegin", start); + DBWriteContactSettingTString(NULL, ModuleName, "BoldEnd", end); + } + + DBWriteContactSettingByte(NULL, ModuleName, "CheckForDependencies", IsDlgButtonChecked(hWnd, IDC_CHECKUNLOADABLE) ? TRUE : FALSE); + DBWriteContactSettingByte(NULL, ModuleName, "BoldVersionNumber", IsDlgButtonChecked(hWnd, IDC_BOLDVERSION) ? TRUE : FALSE); + DBWriteContactSettingByte(NULL, ModuleName, "ForumStyle", IsDlgButtonChecked(hWnd, IDC_FORUMSTYLE) ? TRUE : FALSE); + DBWriteContactSettingByte(NULL, ModuleName, "ClipboardAlways", IsDlgButtonChecked(hWnd, IDC_CLIPBOARDALSO) ? TRUE : FALSE); + DBWriteContactSettingByte(NULL, ModuleName, "SuppressHeader", IsDlgButtonChecked(hWnd, IDC_SUPPRESSHEADER) ? TRUE : FALSE); + DBWriteContactSettingByte(NULL, ModuleName, "ShowUUIDs", IsDlgButtonChecked(hWnd, IDC_SHOWUUIDS) ? TRUE : FALSE); + DBWriteContactSettingByte(NULL, ModuleName, "ShowInstalledLanguages", IsDlgButtonChecked(hWnd, IDC_SHOWINSTALLEDLANGUAGES) ? TRUE : FALSE); + + if (!bFoldersAvailable) { + TCHAR filePath[MAX_PATH], fileName[MAX_PATH]; + GetDlgItemText(hWnd, IDC_FILENAME, fileName, MAX_PATH); + AbsolutePathToRelative(fileName, filePath, SIZEOF(filePath)); + + DBWriteContactSettingTString(NULL, ModuleName, "OutputFile", filePath); //store relative path + } + DBWriteContactSettingByte(NULL, ModuleName, "ShowInTaskbar", IsDlgButtonChecked(hWnd, IDC_SHOWINTASKBAR) ? TRUE : FALSE); + //Debug to: + if (IsDlgButtonChecked(hWnd, IDC_TOFILE)) + DBWriteContactSettingByte(NULL, ModuleName, "DebugTo", TO_FILE); + else if (IsDlgButtonChecked(hWnd, IDC_TOMESSAGEBOX)) + DBWriteContactSettingByte(NULL, ModuleName, "DebugTo", TO_MESSAGEBOX); + else if (IsDlgButtonChecked(hWnd, IDC_TODIALOGBOX)) + DBWriteContactSettingByte(NULL, ModuleName, "DebugTo", TO_DIALOGBOX); + else if (IsDlgButtonChecked(hWnd, IDC_TODEBUGSTRING)) + DBWriteContactSettingByte(NULL, ModuleName, "DebugTo", TO_DEBUGSTRING); + else if (IsDlgButtonChecked(hWnd, IDC_TOCLIPBOARD)) + DBWriteContactSettingByte(NULL, ModuleName, "DebugTo", TO_CLIPBOARD); + else if (IsDlgButtonChecked(hWnd, IDC_TOUPLOAD)) + DBWriteContactSettingByte(NULL, ModuleName, "DebugTo", TO_UPLOAD); + else if (IsDlgButtonChecked(hWnd, IDC_ASKEVERYTIME)) + DBWriteContactSettingByte(NULL, ModuleName, "DebugTo", TO_ASK); + + EnableWindow(GetDlgItem(hWnd, IDC_GETINFONOW), TRUE); + //Disabled plugins too? + DBWriteContactSettingByte(NULL, ModuleName, "ShowInactive", IsDlgButtonChecked(hWnd, IDC_DISABLEDTOO)?TRUE:FALSE); + + GetStringFromDatabase("UUIDCharMark", _T(DEF_UUID_CHARMARK), PLUGIN_UUID_MARK, cPLUGIN_UUID_MARK); + } } + + break; + } + return 0; +} + +INT_PTR CALLBACK DialogBoxProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + static CVersionInfo *myInfo = NULL; + switch(msg) { + case WM_INITDIALOG: + SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM) hiVIIcon); + + myInfo = (CVersionInfo *) lParam; + if (DBGetContactSettingByte(NULL, ModuleName, "ShowInTaskbar", TRUE)) { + DWORD ws; + ws = GetWindowLongPtr(hWnd, GWL_EXSTYLE); + SetWindowLongPtr(hWnd, GWL_EXSTYLE, ws | WS_EX_APPWINDOW); + //SetWindowLongPtr(hWnd, GWL_STYLE, ws | WS_DLGFRAME | WS_POPUPWINDOW); + } + + TranslateDialogDefault(hWnd); + { + DBVARIANT dbv = { 0 }; + LOGFONT lf = { 0 }; + + dbv.type = DBVT_BLOB; + if (DBGetContactSetting(NULL, "OptionFont", "Font", &dbv) == 0) + lf=*(LOGFONT*)dbv.pbVal; + else { + HFONT hFont = (HFONT)SendDlgItemMessage(hWnd,IDC_CLOSE,WM_GETFONT,0,0); + GetObject(hFont,sizeof(lf),&lf); + } + SendDlgItemMessage(hWnd,IDC_TEXT,WM_SETFONT,(WPARAM)CreateFontIndirect(&lf),0); + } + + return TRUE; + + case WM_CLOSE: + DestroyWindow(hWnd); + break; + + case WM_COMMAND: { + switch(LOWORD(wParam)) { + case IDC_CLOSE: + DestroyWindow(hWnd); + break; + + case IDC_COPYTEXT: + SetLastError(0); + if (GetOpenClipboardWindow()) + Log( TranslateT("The clipboard is not available, retry.")); + else { + OpenClipboard(hWnd); + //Ok, let's begin, then. + EmptyClipboard(); + //Storage data we'll use. + TCHAR text[MAX_TEXT]; + LPTSTR lptstrCopy; + GetDlgItemText(hWnd, IDC_TEXT, text, MAX_TEXT); + int length = lstrlen(text) + 1; + HANDLE hData = GlobalAlloc(GMEM_MOVEABLE, (length + 5)*sizeof( TCHAR )); + //Lock memory, copy it, release it. + lptstrCopy = (LPTSTR)GlobalLock(hData); + lstrcpyn(lptstrCopy, text, length); + lptstrCopy[length] = '\0'; + GlobalUnlock(hData); + //Now set the clipboard data. + + SetClipboardData(CF_UNICODETEXT, hData); + + //Remove the lock on the clipboard. + CloseClipboard(); + } + + break; + + case IDC_SAVETOFILE: + TCHAR text[MAX_TEXT]; + GetDlgItemText(hWnd, IDC_TEXT, text, MAX_TEXT); + myInfo->PrintInformationsToFile(text); + break; + } + + break; + } + case WM_DESTROY: + DeleteObject((HFONT)SendDlgItemMessage(hWnd,IDC_TEXT,WM_GETFONT,0,0)); + myInfo = NULL; + if (bServiceMode) //close miranda if in service mode + PostQuitMessage(0); + + break; + } + return 0; +} diff --git a/plugins/VersionInfo/dlgHandlers.h b/plugins/VersionInfo/dlgHandlers.h new file mode 100644 index 0000000000..bab1876ea2 --- /dev/null +++ b/plugins/VersionInfo/dlgHandlers.h @@ -0,0 +1,43 @@ +/* +Version information plugin for Miranda IM + +Copyright © 2002-2006 Luca Santarelli, Cristian Libotean + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#ifndef M_VERSIONINFO_DLGHEADERS_H +#define M_VERSIONINFO_DLGHEADERS_H + +#include "resource.h" +#include "CVersionInfo.h" + +#define TO_ASK 0 +#define TO_FILE 1 +#define TO_MESSAGEBOX 2 +#define TO_DIALOGBOX 3 +#define TO_DEBUGSTRING 4 +#define TO_CLIPBOARD 5 +#define TO_UPLOAD 6 + +extern INT_PTR PluginMenuCommand(WPARAM, LPARAM); +extern INT_PTR OptionsInitialise(WPARAM, LPARAM); + + +int DoDebugTo(int debugTo); +INT_PTR CALLBACK AskDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); +INT_PTR CALLBACK DlgProcOpts(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); +INT_PTR CALLBACK DialogBoxProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); +#endif \ No newline at end of file diff --git a/plugins/VersionInfo/docs/readme_versioninfo.txt b/plugins/VersionInfo/docs/readme_versioninfo.txt new file mode 100644 index 0000000000..8a7d49fe7a --- /dev/null +++ b/plugins/VersionInfo/docs/readme_versioninfo.txt @@ -0,0 +1,433 @@ +VersionInfo, v.1.4.3.4 + by Luca "Hrk" Santarelli, Cristian Libotean + hrk@users.sf.net, eblis102@yahoo.com + Thanks go to: StormLord, Cyreve, Strickz, Wintime98 + All of them helped me somehow. + +- INFO - + +Hi :-) + +This plugin is born from a feature request on the Open Discussion forum. +Its purpose is to display some informations related to Miranda and to the OS +so that you can copy/paste them in a bug report. + +Remember: submitting a bug report DOES NOT mean that it will be fixed. +You need to check the bug report because developers may need your cooperation, +testing debug builds or making other tests. + +The displayed informations are: +§ Date/Time of report +§ System cpu type +§ OS name and version (major, minor, build, additional data) +§ Installed RAM +§ Miranda version, being it or not a nightly and/or unicode. +§ List of enabled plugins (filename, short name, version and last modified date) +§ List of disabled plugins (filename, short name, version and last modified date). Optional. + + +- USE - + +!!! For bugs and/or suggestions please email me, eblis102@yahoo.com (please don't spam hrk as +he's not working on this anymore). + +Click on the button in the main menu or the one in the options... and you're done. +You can choose where to debug: text file, message box (no copy/paste), dialog +box (copy/paste), OutputDebugString(), Clipboard directly. You can also check to print +to clipboard while printing to any of the other options (except clipboard, of course :) ) + + +- CHANGES - + ++ : new feature +* : changed +! : bufgix +- : feature removed or disabled because of pending bugs + +v. 1.4.3.4 - 2009/11/13 + + x64 support (not tested !!) + +v.1.4.3.3 - 2008/02/15 + ! Plugins that do not have the extension .dll will not be listed anymore + +v.1.4.3.2 - 2008/01/31 + * Report plugins without UUIDs in Miranda 0.8 #9 or later as Unloadable instead of Inactive + +v.1.4.3.1 - 2008/01/30 + * When in service mode enable showing of disabled plugins if 'forum style formatting' is disabled, regardless if the option to show disabled plugins in the options is checked or not. + ! Ignore case when checking dll name. + +v.1.4.3.0 - 2008/01/29 + * Show messages using a popup if a popup plugin is available + + Added service mode functionality - requires miranda 0.8 #9 or later. + WARNING: Please rename the plugin back to svc_vi.dll if you're using Updater to update your plugins. + +v.1.4.2.7 - 2008/01/25 + ! Fixed crash when displaying information for unloadable plugins + +v.1.4.2.6 - 2008/01/24 + * Changed beta versions server. + +v.1.4.2.5 - 2007/10/24 + + Added profile path to VersionInfo report. + +v.1.4.2.4 - 2007/09/26 + * Show warning message when user tries to activate 'Show plugin UUIDs' option. + +v.1.4.2.3 - 2007/07/25 + ! Fixed time zone offset calculation. + ! Fixed negative time zones display. + +v.1.4.2.2 - 2007/07/24 + + Added time zone information for profile creation date and language pack modified date. + +v.1.4.2.1 - 2007/06/22 + * Show menu item is always checked (to disable use the menu editor). + * Enabled unicode flag since plugin is 2in1. + +v.1.4.2.0 - 2007/06/22 + * Show UUIDs checkbox is now visible only when 'show expert options' is checked. + * Added checkbox to enable/disable showing installed languages - visible only when 'show expert options' is checked. + +v.1.4.1.5 - 2007/06/21 + * Removed installed languages info from report (still available using the hidden setting 'ShowInstalledLanguages') + +v 1.4.1.4 - 2007/05/11 + ! Show more than 2g of memory if available. + +v. 1.4.1.3 - 2007/03/27 + * Fix for database plugins returning non standard profile path (dbxSA). + +v. 1.4.1.2 - 2007/03/22 + ! Fix Unicode plugin detection. + +v. 1.4.1.1 - 2007/03/07 + + Added icon to output dialog window. + * Make 'Customize using folders plugin' translatable. + +v. 1.4.1.0 - 2007/03/07 + * Changed plugin UUID ( {2f174488-489c-4fe1-940d-596cf0f35e65} ). + + Added VERSIONINFO interface. + +v. 1.4.0.4 - 2007/03/06 + + Option to show UUID info. + + Added VI UUID. + + Added hidden setting to change the character shown if plugin has a UUID defined (UUIDCharMark). + ! Do not enable Apply when first entering the options. + +v. 1.4.0.3 - 2007/02/12 + + Read plugin Unicode aware flag. Only shown if plugin name doesn't contain 'unicode' or '2in1'. + +v. 1.4.0.2 - 2007/01/31 + * Changed beta URL. + +v. 1.4.0.1 - 2007/01/28 + + Added InternetExplorer version + +v. 1.4.0.0 - 2007/01/28 + + Added Windows shell information. + ! Fix for profile creation date and size on Windows 98 + +v. 1.3.2.2 - 2007/01/07 + + New version resource file. + + Added OS languages info: {User UI language/}System UI language | Current user locale/System locale [available system languages]. User UI language is not available for Windows 95, 98, Me and NT. + + Folders support. + ! Close thread handle. + +v. 1.3.2.1 - 2006/12/07 + * Changed controls tab order. + +v. 1.3.2.0 - 2006/11/26 + * Reorganised the post a bit. + + Added empty blockquote style. + ! Fixed version number highlighting. + + Added dll version info. + +v. 1.3.1.1 - 2006/11/15 + * "Ask every time", not "Ask everytime" :) + + Added administrator privileges information. + + Added "Save to file" button to dialog. + * Disabled the "Upload" button. + +v. 1.3.1.0 - 2006/11/1 + + Added multiple CPUs info. + + Added WOW64 info. + ! Don't get plugin information twice. + * Moved main menu entry near Help. + * Default output location changed to dialog. + +v. 1.3.0.4 - 2006/10/16 + * Made langpack retrieval more robust. + + Show langpack info. + * No more dependency on winsock2 (removed upload feature for now, support isn't available anyway) + +v. 1.3.0.1 - 2006/09/25 + + Updater support (beta versions) + ! Enable the Apply button when combobox items are changed. + + Added quote, size and bold comboboxes to ask dialog. + * Sections now use the same highlighting method as the plugins. + * Changed text displayed when plugins don't want to load with current Miranda version. + +v. 1.3.0.0 - 2006/08/08 + * Use relative paths. The file path in the options will show as absolute but it's saved in the database as relative - uses the services in m_utils.h. + + New versioninfo icon - thanks Faith Healer. + + Option to automatically upload VI post to vi.cass.cz :) - currently there's no support on the site for it + + Show plugins that fail to load for unknown reasons. + * Use mir_snprintf where possible. + + Added checkbox for forum style formatting in ask dialog. + * Changed plugin section to "Services" + +v. 1.2.0.4 - 2006/07/26 + * 'Attempt to find unloadable plugins' is checked by default now and is grayed out on Win 98. + + Added check for Windows 2003 R2. + +v. 1.2.0.3 - 2006/06/01 + + Added a service to get the VersionInfo post as a string. + +v. 1.2.0.2 - 2006/05/20 + ! Fixed a bug when notifing of errors - thanks for the patch Peter (UnregistereD). + +v. 1.2.0.1 - 2006/05/17 + * People reported they don't have PF_NX_ENABLED defined so i created a workaround for those who want to build VI from sources. + ! Destroy services the proper way. + +v. 1.2.0.0 - 2006/05/01 + + Added DEP information. + * Show message if CPU doesn't recognize cpuid extension. + +v. 1.0.1.19 - 2006/03/23 + ! Fixed "Do it now" being disabled when first entering the options window. + +v. 1.0.1.18 - 2006/03/09 + + Added a new size option for phpBB forums. + + Added a new highlight option (bold and underline). + + Added a new option to suppress header and footer information - will make the post a bit smaller. + ! Fixed a bug when information was copied to clipboard. + +v. 1.0.1.17 - 2006/01/01 + + Added check to find out plugin information for plugins that refuse to load. + ! Fixed a new line issue (happened when Unloadable plugins entry was visible). + +v. 1.0.1.16 - 2006/01/31 + * Removed the static edge from the dialog buttons. + + Added check for plugins that refuse to load. + * Updated the translation strings. + +v. 1.0.1.15 - 2005/10/17 + + Added some hidden beautification settings. You need to use dbeditor to add these settings to + VersionInfo. All settings are strings and they should either be bbcodes or html codes. (do a default + output for an example). Check the changes in version 1.0.1.14 to see how you can activate this output. + ~ BeautifyHorizLine - code for a horizontal line + (default:
) + ~ BeautifyBlockStart - code for a blockquote (start code) that separates the hw and miranda settings from the plugins + (default:
) + ~ BeautifyBlockEnd - code for a blockquote (end code) that separates the hw and miranda settings from the plugins + (default:
) + ~ BeautifyActiveHeaderBegin - code for the font and size of the active header text (start code) + (default: ) + ~ BeautifyActiveHeaderEnd - code for the font and size of the active header text (end code) + (default: ) + ~ BeautifyInactiveHeaderBegin - code for the font and size of the inactive header text (start code) + (default: ) + ~ BeautifyInactiveHeaderEnd - code for the font and size of the inactive header text (end code) + (default: ) + ~ BeautifyUnloadableHeaderBegin - code for the font and size of the unloadable header text (start code) + (default: ) + ~ BeautifyUnloadableHeaderEnd - code for the font and size of the unloadable header text (end code) + (default: ) + ~ BeautifyPluginsBegin - code for the font and size of plugins (start code) + (default: ) + ~ BeautifyPluginsEnd - code for the font and size of plugins (end code) + (default: ) + How it works: + $starting info [Miranda IM ... Miranda's homepage ... Miranda tools] + {Horizontal line}{block start}Report generated at: $date + $hardware, os and miranda settings + {block end}{horizontal line}{active header start}Active Plugins (#):{active header end} + {plugins start} + $plugins + {plugins end}{horizontal line}{inactive header start}Inactive Plugins (#):{inactive header end} + {plugins start} + $plugins + {plugins end}{horizontal line}{unloadable header start}Unloadable Plugins (#):{unloadable header end} + {plugins start} + $plugins + {plugins end}{horizontal line} + $end info [End of report ...] + +v. 1.0.1.14 - 2005/10/16 + - Removed the logging functions used when attempting to find an unloadable plugin. + + Added hidden option to beautify the output. You need to use dbeditor and add a new + byte value to VersionInfo called Beautify and set it to 1 for the setting to take effect. + Forum style formatting must be OFF; although forum style is unchecked it will get the + highlighting information from the appropriate checkbox so be sure to set it + accordingly (usually to or . The formatting is hardcoded at the moment + (it's set to html tags), i might add some strings in the database for it later on. + + Added option to select how to highlight version number; currently you can + select from bold or underline. + +v. 1.0.1.13 - 2005/10/14 + + Added option to ask where to print the output. + +v. 1.0.1.12 - 2005/10/06 + * Changed the way versioninfo scans for enabled/disabled plugins. + Now it should be able to detect even plugin that were reported as inactive before (like aim toc2 and clist_nicerW+) + + Added profile size and creation date. + + Added information about missing statically linked dll files. Use with care, might crash miranda on some systems. + This function might not work (correctly) on windows 98 and below. If you check this option a file named + 'versioninfo.log' will appear in miranda's folder; in case of a crash please post this info in the forums + (thread Plugins->Versioninfo format style) using [code][/code] bbcodes. + +v. 1.0.1.11 - 2005/09/24 + + Added option to print version number in bold or not. + + Added [code] bbcode and empty size field (if the forum doesn't strip other bbcodes from inside a [code]) + +v. 1.0.1.10 - 2005/09/25 + ! Fixed issue that prevented the apply button to be enabled when changing the filename. + + Added options to select forum bbcodes. + +v. 1.0.1.9 - 2005/09/22 :) + + Added a new CPU check. Might be unstable and can't detect very old processors (like pentium mmx) + * Changed hidden settings strings to QuoteBegin, QuoteEnd, SizeBegin, SizeEnd. + ! Fixed updater issue - older versions should be detected as well (thanks sje). Plugin should + comply with updater rules from now on. + +v. 1.0.1.8 - 2005/09/22 + * Changed month number to month short name (english locale) + + Added "hidden" settings for 'quote' and 'size' strings (only valid when using forum style formatting). + You need to use dbeditor++ to add these. + "QuoteHeader" - String value containing the starting quote string. + You can use this if you want to change the "[quote]" string to "[code]" for example. + If the setting is not present it reverts to "[quote]" + "SizeHeader" - String value containing the starting size string. + You should use this if the forum software doesn't recognize "[size=1]" and needs + something like "[size=1px]". If the setting is not present it reverts to "[size=1]". + "QuoteFooter" - String value containing the ending quote string. If the setting is not present it reverts to "[/quote]" + "SizeFooter" - String value containing the ending size string. If the setting is not present it reverts to "[/size]" + !If you change the header for one of these don't forget to change the footer as well (and vice versa). + + When using forum style formatting the version number will be bold. + + Added active and inactive plugins count (it can't hurt :) ) + +v. 1.0.1.7 - 2005/09/21 + ! Fixed double enter issue + ! Fixed unicode detection problem + + +1.0.1.6 - 2005/09/11 + * Changed miranda's homepage from 'http://miranda-icq.sourceforge.net/' to 'miranda-im.org' + * Changed miranda tools link. + * Changed some strings (date and time related). + + Added check for unicode core. + + Added miranda path to versioninfo output. + + Added plugin's last modified date to versioninfo output. + + Added plugin's short name to versioninfo output. + + Added os check for windows 2003. + + Added option to show information window in taskbar + + Added option to always copy to clipboard + + Added CPU info + Should still work with amd 64 (unsure) + +1.0.1.5 * Works on AMD64 now. + * Fixed some typos in the text and URLs. + * Changed some default settings. + +1.0.1.4 * Fixed the crashes when a .dll file was found but was not a plugin. + * Filesize somehow increased to 80KB... don't ask me why. + + Added support for MirandaInstaller/Wassup by Tornado. + +1.0.1.3 * No change at all, but it now works for everyone. Don't ask me how. + +1.0.1.2 * Fixed NT detection. + * Fixed click on X button in dialogbox. + +1.0.1.1 * Changed the option page UI to reflect Miranda's one and to have a + more intuitive usage. + * Size has increased, but there's not anymore the need for that + external DLL. :-) + +1.0.1.0 + Added "DialogBox" as output (Cyreve, Stormlord, myself) + + Added "OutputDebugString()" as output + + Added "Clipboard" as output + + Added the missing button in the options + + Added a cool icon + + Added OS name (Wintime98, myself) + + Added Miranda build time (Wintime98) + + Added free disk space on Miranda partition (Stormlord, myself) + * Changed "Debug to:" to "Output to:" because of its meaning + +1.0.0.0 First release. + DialogBox is not yet selectable. + Developers, read the REBASE information. + + +- TRANSLATION - + +The strings you can translate are these: + +for version 1.4.2.4 +;Plugin description: +;[Collects and prints information related to Miranda, the plugins and the OS.] +; +;Option dialog +;[Plugins] +;[Version Information] +;[Output to:] +;[Text file] +;[MessageBox()] +;[DialogBox] +;[Show window in taskbar] +;[OutputDebugString()] +;[Clipboard] +;[Upload to site] +;[Ask every time] +;[Also copy info to clipboard] +;[Forum style formatting] +;[Highlight version number using] +;[Show disabled plugins too] +;[Show plugin UUIDs] +;[Attempt to find unloadable plugins (doesn't work on Windows 98)] +;[Suppress header information] +;[Add a menu item to the main Miranda Menu] +;[You will need to restart Miranda to add/remove the menu item.] +;[Do it now] +;[Upload site settings] +;[Username] +;[Password] +;[Customize using folders plugin] +;[Are you sure you want to enable this option ?\nPlease only enable this option if you really know what you're doing and what the option is for or if someone asked you to do it.] +;[Show plugin UUIDs ?] +; +;Dialog box +;[Upload] +;[Close] +;[Copy text] +; +;Miscellanea +;[If you are going to use this report to submit a bug, remember to check the website for questions or help the developers may need.\r\nIf you don't check your bug report and give feedback, it will not be fixed!] +;[Information successfully written to file: \"%s\".] +;[Error during the creation of file \"%s\". Disk may be full or write protected.] + +;[Ok, something went wrong in the \"%s\" setting. Report back the following values:\nFacility: %X\nError code: %X\nLine number: %d] + +;[The clipboard is not available, retry.] +;[Information successfully copied into clipboard.] +;[Miranda Version Information] + +- DISCLAIMER - + +This plugin works just fine on my machine, it should work just fine on yours +without conflicting with other plugins. Should you have any trouble, write me +at hrk@users.sf.net where "sf" must be changed to "sourceforge". +Anyway, if you are a smart programmer, give a look at the code and tell me +the changes you'd make. If I like them, I'll put them inside. :-) + +This plugin is released under the GPL license, I'm too lazy to copy it, though. +Anyway, if you do have Miranda (and you should, otherwise this plugin is +pretty useless) you already have a file called GPL.txt with tis license. +Being GPLed you are free to modify or change the source code (you can find it +here: http://nortiq.com/miranda/ and look for the source section) but you +cannot sell it. +As I already wrote: if you do modify it, notify me, I don't see a good reason +not to share the improvements with the Miranda community. :-) + +Yes, I have made a quite long disclaimer, I can save the file now. :-) diff --git a/plugins/VersionInfo/docs/rebase_versioninfo.txt b/plugins/VersionInfo/docs/rebase_versioninfo.txt new file mode 100644 index 0000000000..fd71ab0526 --- /dev/null +++ b/plugins/VersionInfo/docs/rebase_versioninfo.txt @@ -0,0 +1,33 @@ +=§= TO PLUGIN DEVELOPERS =§= + +This plugin has its Base Address set to: +0x25040000 + +Please, avoid using this BaseAddress for your plugins: using the same addresses +will slow Miranda. +Read "pluginguidelines.txt" under miranda0100/miranda32/doc/ in the CVS. + +This Base Address is built this way: + +0x25 040000 +^^^^ ^^^^^^ +My radix Incremental value related to my plugins. + +Range for base address is 0x10000000 to 0x50000000, so 0x25040000 fits well there. + +040000 is an incremental value which represents VersionInfo. +[Note: 000000 is used for RePosition, 010000 for NewStatusNotify, 030000 for PicPlugin and so on.] + +Why do I call 0x25 "My radix"? + +HRK = H + R + K +H = 8th letter in the english alphabet. +R = 18th letter in the english alphabet. +K = 11th letter in the english alphabet. + +8 + 18 + 11 = 37. +37(dec) = 25(Hex) + +Base Address can be found/configured: +§ MSVC++ 6.0 + Project->Settings->Link->Output->Base Address \ No newline at end of file diff --git a/plugins/VersionInfo/docs/versioninfo.gif b/plugins/VersionInfo/docs/versioninfo.gif new file mode 100644 index 0000000000..a0e1f8eadb Binary files /dev/null and b/plugins/VersionInfo/docs/versioninfo.gif differ diff --git a/plugins/VersionInfo/hooked_events.cpp b/plugins/VersionInfo/hooked_events.cpp new file mode 100644 index 0000000000..77d72e6a97 --- /dev/null +++ b/plugins/VersionInfo/hooked_events.cpp @@ -0,0 +1,80 @@ +/* +Version information plugin for Miranda IM + +Copyright © 2002-2006 Luca Santarelli, Cristian Libotean + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include "common.h" +#include "hooked_events.h" + +HANDLE hModulesLoaded; +HANDLE hOptionsInitialize; + +#define HOST "http://eblis.tla.ro/projects" + +#define VERSIONINFO_VERSION_URL HOST "/miranda/VersionInfo/updater/VersionInfo.html" +#define VERSIONINFO_UPDATE_URL HOST "/miranda/VersionInfo/updater/VersionInfo.zip" +#define VERSIONINFO_VERSION_PREFIX "Version Information version " + +int HookEvents() +{ + hModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded); + hOptionsInitialize = HookEvent(ME_OPT_INITIALISE, OnOptionsInitialise); + //hPreShutdown = HookEvent(ME_SYSTEM_PRESHUTDOWN, OnPreShutdown); + + return 0; +} + +int UnhookEvents() +{ + UnhookEvent(hModulesLoaded); + UnhookEvent(hOptionsInitialize); + + return 0; +} + +int OnModulesLoaded(WPARAM wParam, LPARAM lParam) +{ + + bFoldersAvailable = ServiceExists(MS_FOLDERS_REGISTER_PATH); + hOutputLocation = FoldersRegisterCustomPathT("VersionInfo", "Output folder", _T("%miranda_path%")); + + GetStringFromDatabase("UUIDCharMark", _T(DEF_UUID_CHARMARK), PLUGIN_UUID_MARK, cPLUGIN_UUID_MARK); + return 0; +} + +static UINT uiExpertOnlyControls[] = { IDC_SHOWUUIDS, IDC_SHOWINSTALLEDLANGUAGES }; + +int OnOptionsInitialise(WPARAM wParam, LPARAM lParam) +{ + OPTIONSDIALOGPAGE odp = { 0 }; + odp.cbSize = sizeof(odp); + odp.position = 100000000; + odp.hInstance = hInst; + odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_VERSIONINFO); + odp.pszTitle = LPGEN("Version Information"); + odp.pszGroup = LPGEN("Services"); + odp.groupPosition = 910000000; + odp.flags = ODPF_BOLDGROUPS; + odp.pfnDlgProc = DlgProcOpts; + odp.expertOnlyControls = uiExpertOnlyControls; + odp.nExpertOnlyControls = SIZEOF(uiExpertOnlyControls); + + Options_AddPage(wParam, &odp); + + return 0; +} \ No newline at end of file diff --git a/plugins/VersionInfo/hooked_events.h b/plugins/VersionInfo/hooked_events.h new file mode 100644 index 0000000000..b75b5e59a8 --- /dev/null +++ b/plugins/VersionInfo/hooked_events.h @@ -0,0 +1,33 @@ +/* +Version information plugin for Miranda IM + +Copyright © 2002-2006 Luca Santarelli, Cristian Libotean + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#ifndef M_VERSIONINFO_HOOKED_EVENTS_H +#define M_VERSIONINFO_HOOKED_EVENTS_H + +extern HANDLE hModulesLoaded; +extern HANDLE hOptionsInitialise; + +int HookEvents(); +int UnhookEvents(); + +int OnModulesLoaded(WPARAM wParam, LPARAM lParam); +int OnOptionsInitialise(WPARAM wParam, LPARAM lParam); + +#endif \ No newline at end of file diff --git a/plugins/VersionInfo/main.cpp b/plugins/VersionInfo/main.cpp new file mode 100644 index 0000000000..c244ba2db6 --- /dev/null +++ b/plugins/VersionInfo/main.cpp @@ -0,0 +1,135 @@ +/* +Version information plugin for Miranda IM + +Copyright © 2002-2006 Luca Santarelli, Cristian Libotean + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#define STRICT +#define WIN32_LEAN_AND_MEAN + +#define _CRT_SECURE_NO_DEPRECATE + +#include "common.h" + +#include "CVersionInfo.h" + +HINSTANCE hInst; + +int hLangpack; + +HICON hiVIIcon; + +DWORD EnglishLocale; + +BOOL bFoldersAvailable = FALSE; +HANDLE hOutputLocation = NULL; //for folders plugin + +void * (* MirandaMalloc)(size_t); +void * (* MirandaRealloc)(void *, size_t); +void (* MirandaFree)(void *); + +char ModuleName[] = "VersionInfo"; + +#ifdef _DEBUG + BOOL verbose = FALSE;//TRUE; +#else + BOOL verbose = FALSE; +#endif + +PLUGININFOEX pluginInfo={ + sizeof(PLUGININFOEX), + __PLUGIN_DISPLAY_NAME, + VERSION, + __DESC, + __AUTHOR, + __AUTHOREMAIL, + __COPYRIGHT, + __AUTHORWEB, + UNICODE_AWARE, + // {2f174488-489c-4fe1-940d-596cf0f35e65} + {0x2f174488, 0x489c, 0x4fe1, {0x94, 0x0d, 0x59, 0x6c, 0xf0, 0xf3, 0x5e, 0x65}} +}; + +extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = {MIID_VERSIONINFO, MIID_SERVICEMODE, MIID_LAST}; + +bool WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved) +{ + hInst=hinstDLL; + if (fdwReason == DLL_PROCESS_ATTACH) DisableThreadLibraryCalls(hinstDLL); + EnglishLocale = MAKELCID(MAKELANGID(0x09, 0x01), SORT_DEFAULT); //create our english locale and use it everywhere it's needed + return TRUE; +} + +extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) +{ + return &pluginInfo; +} + +extern "C" int __declspec(dllexport) Load(void) +{ + + mir_getLP(&pluginInfo); + + InitServices(); + HookEvents(); + + hiVIIcon = LoadIcon(hInst,MAKEINTRESOURCE(IDI_MAIN)); + + //get the name of the dll itself + TCHAR filePath[512] = {0}; + GetModuleFileName(hInst, filePath, SIZEOF(filePath)); + TCHAR *fileName = NULL; + size_t i = _tcslen(filePath) - 1; + _tcslwr(filePath); + + //check that the name begins with svc_ + while ((i > 0) && (filePath[i] != '\\')) { i--; } + if (i > 0) + { + filePath[i] = 0; + fileName = filePath + i + 1; + + if (_tcsstr(fileName, _T("svc_")) != fileName) + { + TCHAR buffer[1024]; + mir_sntprintf(buffer, SIZEOF(buffer), TranslateT("Please rename the plugin '%s' to 'svc_vi.dll' to enable service mode functionality."), fileName); + MessageBox(NULL, buffer, TranslateT("Version Information"), MB_OK | MB_ICONEXCLAMATION); + } + } + + //Menu item + CLISTMENUITEM mi = { 0 }; + mi.cbSize = sizeof(mi); + mi.position = mi.popupPosition = 2000089999; + mi.flags = 0; + mi.hIcon = hiVIIcon; + mi.pszName = Translate("Version Information"); + mi.pszService = MS_VERSIONINFO_MENU_COMMAND; + Menu_AddMainMenuItem(&mi); + + if (LoadLibraryA("RichEd32.dll") == NULL) + MessageBoxA(NULL, "d'oh", "d'oh", MB_OK); + + return 0; +} + +extern "C" int __declspec(dllexport) Unload(void) +{ + UnhookEvents(); + DestroyServices(); + return 0; +} \ No newline at end of file diff --git a/plugins/VersionInfo/resource.h b/plugins/VersionInfo/resource.h new file mode 100644 index 0000000000..b282e8bca6 --- /dev/null +++ b/plugins/VersionInfo/resource.h @@ -0,0 +1,71 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by resource.rc +// +#define IDD_DIALOG1 101 +#define IDD_OPT_VERSIONINFO 102 +#define IDD_DIALOGBOX 103 +#define IDD_DIALOGINFO 103 +#define IDI_ICON1 104 +#define IDI_MAIN 104 +#define IDD_ASKDIALOG 106 +#define IDC_MENUITEM 1000 +#define IDC_TOFILE 1001 +#define IDC_TOMESSAGEBOX 1002 +#define IDC_TODIALOGBOX 1003 +#define IDC_DISABLEDTOO 1004 +#define IDC_FILENAME 1005 +#define IDC_TEXT 1006 +#define IDC_TODEBUGSTRING 1006 +#define IDC_CLOSE 1007 +#define IDC_TOCLIPBOARD 1007 +#define IDC_GETINFONOW 1009 +#define IDC_TOUPLOAD 1010 +#define IDC_GETINFONOW2 1011 +#define IDC_COPYTEXT 1012 +#define IDC_DEBUG 1013 +#define IDC_FORUMSTYLE 1014 +#define IDC_CLIPBOARDALSO 1015 +#define IDC_SHOWINTASKBAR 1016 +#define IDC_QUOTECOMBOBOX 1017 +#define IDC_SIZECOMBOBOX 1018 +#define IDC_BOLDVERSION 1020 +#define IDC_CHECKUNLOADABLE 1021 +#define IDC_ASKEVERYTIME 1022 +#define IDC_ASK_TOFILE 1023 +#define IDC_ASK_TOMESSAGEBOX 1024 +#define IDC_ASK_TODIALOGBOX 1025 +#define IDC_ASK_TOOUTPUTDEBUGSTRING 1026 +#define IDC_ASK_TOCLIPBOARD 1027 +#define IDC_ASK_CANCEL 1028 +#define IDC_ASK_OK 1029 +#define IDC_BOLDCOMBOBOX 1030 +#define IDC_SUPPRESSHEADER 1031 +#define IDC_SHOWHARDWAREINFO 1033 +#define IDC_UPLOAD 1034 +#define IDC_ASK_UPLOAD 1036 +#define IDC_ASK_TOUPLOAD 1036 +#define IDC_UPLOAD_SERVER 1038 +#define IDC_UPLOAD_PORT 1039 +#define IDC_UPLOAD_USERNAME 1040 +#define IDC_UPLOAD_PASSWORD 1041 +#define IDC_TEMPORARY_FORUMSTYLE 1042 +#define IDC_ASK_FORUMSTYLE 1042 +#define IDC_ASK_QUOTECOMBOBOX 1043 +#define IDC_ASK_SIZECOMBOBOX 1044 +#define IDC_ASK_BOLDCOMBOBOX 1045 +#define IDC_SAVETOFILE 1046 +#define IDC_SHOWUUIDS 1048 +#define IDC_CHECK1 1049 +#define IDC_SHOWINSTALLEDLANGUAGES 1049 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 107 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1050 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/plugins/VersionInfo/resource.rc b/plugins/VersionInfo/resource.rc new file mode 100644 index 0000000000..b4a8eb819a --- /dev/null +++ b/plugins/VersionInfo/resource.rc @@ -0,0 +1,225 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_ASKDIALOG DIALOGEX 0, 0, 231, 146 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Output to:" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + DEFPUSHBUTTON "OK",IDC_ASK_OK,63,125,50,14 + PUSHBUTTON "Cancel",IDC_ASK_CANCEL,117,125,50,14 + CONTROL "Text file",IDC_ASK_TOFILE,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,15,17,206,10 + CONTROL "MessageBox()",IDC_ASK_TOMESSAGEBOX,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,15,27,206,10 + CONTROL "DialogBox",IDC_ASK_TODIALOGBOX,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,15,37,206,10 + CONTROL "OutputDebugString()",IDC_ASK_TOOUTPUTDEBUGSTRING,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,15,47,206,10 + CONTROL "Clipboard",IDC_ASK_TOCLIPBOARD,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,15,57,206,10 + GROUPBOX "Select output:",IDC_STATIC,7,7,217,72 + CONTROL "Upload to site",IDC_ASK_TOUPLOAD,"Button",BS_AUTORADIOBUTTON | WS_DISABLED | WS_TABSTOP,15,67,206,10 + CONTROL "Forum style formatting",IDC_ASK_FORUMSTYLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,92,206,9 + GROUPBOX "Aditional options:",IDC_STATIC,7,81,217,39 + COMBOBOX IDC_ASK_QUOTECOMBOBOX,15,104,75,50,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_ASK_SIZECOMBOBOX,93,104,71,48,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_ASK_BOLDCOMBOBOX,167,104,54,47,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_ASKDIALOG, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 224 + VERTGUIDE, 15 + VERTGUIDE, 221 + TOPMARGIN, 7 + BOTTOMMARGIN, 139 + HORZGUIDE, 116 + END +END +#endif // APSTUDIO_INVOKED + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + +///////////////////////////////////////////////////////////////////////////// +// Italian (Italy) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ITA) +#ifdef _WIN32 +LANGUAGE LANG_ITALIAN, SUBLANG_ITALIAN +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_OPT_VERSIONINFO DIALOGEX 0, 0, 315, 222 +STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0, 0x0 +BEGIN + PUSHBUTTON "Do it now",IDC_GETINFONOW,265,4,48,13 + GROUPBOX "Output to:",IDC_STATIC,5,4,197,130 + CONTROL "Text file",IDC_TOFILE,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,16,186,10 + EDITTEXT IDC_FILENAME,24,26,150,14,ES_AUTOHSCROLL + CONTROL "MessageBox()",IDC_TOMESSAGEBOX,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,40,186,10 + CONTROL "DialogBox",IDC_TODIALOGBOX,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,51,186,10 + CONTROL "Show window in taskbar",IDC_SHOWINTASKBAR,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,21,62,177,10 + CONTROL "OutputDebugString()",IDC_TODEBUGSTRING,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,73,186,10 + CONTROL "Clipboard",IDC_TOCLIPBOARD,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,84,186,10 + CONTROL "Upload to site",IDC_TOUPLOAD,"Button",BS_AUTORADIOBUTTON | WS_DISABLED | WS_TABSTOP,12,95,186,10 + CONTROL "Ask every time",IDC_ASKEVERYTIME,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,106,186,10 + CONTROL "Also copy info to clipboard",IDC_CLIPBOARDALSO,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,121,186,10 + GROUPBOX "Upload site settings",IDC_STATIC,205,74,108,60 + EDITTEXT IDC_UPLOAD_SERVER,209,83,71,14,ES_AUTOHSCROLL | WS_DISABLED + EDITTEXT IDC_UPLOAD_PORT,281,83,27,14,ES_AUTOHSCROLL | WS_DISABLED + LTEXT "Username",IDC_STATIC,209,103,42,8 + EDITTEXT IDC_UPLOAD_USERNAME,253,99,55,14,ES_AUTOHSCROLL | WS_DISABLED + LTEXT "Password",IDC_STATIC,209,118,43,8 + EDITTEXT IDC_UPLOAD_PASSWORD,253,115,55,14,ES_PASSWORD | ES_AUTOHSCROLL | WS_DISABLED + CONTROL "Forum style formatting",IDC_FORUMSTYLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,5,139,149,10 + COMBOBOX IDC_QUOTECOMBOBOX,159,137,75,58,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_SIZECOMBOBOX,238,137,75,58,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + CONTROL "Highlight version number using",IDC_BOLDVERSION,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,5,153,216,10 + COMBOBOX IDC_BOLDCOMBOBOX,252,153,61,37,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + CONTROL "Show disabled plugins too",IDC_DISABLEDTOO,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,5,164,232,10 + CONTROL "Attempt to find unloadable plugins (doesn't work on Windows 98)",IDC_CHECKUNLOADABLE, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,5,174,272,10 + CONTROL "Suppress header information",IDC_SUPPRESSHEADER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,5,184,274,10 + CONTROL "Enable debug messages",IDC_DEBUG,"Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_DISABLED | WS_TABSTOP,220,207,93,10 + CONTROL "Show plugin UUIDs",IDC_SHOWUUIDS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,5,195,272,10 + CONTROL "Show installed languages",IDC_SHOWINSTALLEDLANGUAGES, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,5,206,273,10 +END + +IDD_DIALOGINFO DIALOGEX 0, 0, 373, 217 +STYLE DS_LOCALEDIT | DS_SETFONT | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +EXSTYLE WS_EX_TOOLWINDOW | WS_EX_CONTROLPARENT +CAPTION "Miranda Version Information" +FONT 8, "MS Shell Dlg", 0, 0, 0x0 +BEGIN + CONTROL "",IDC_TEXT,"RICHEDIT",TCS_HOTTRACK | TCS_FOCUSONBUTTONDOWN | TCS_MULTISELECT | WS_BORDER | WS_VSCROLL | WS_TABSTOP,7,7,298,203 + PUSHBUTTON "Close",IDC_CLOSE,316,7,50,14 + PUSHBUTTON "&Copy text",IDC_COPYTEXT,316,26,50,14 + PUSHBUTTON "Upload",IDC_UPLOAD,316,196,50,14,WS_DISABLED + PUSHBUTTON "&Save to file",IDC_SAVETOFILE,316,45,50,14 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_OPT_VERSIONINFO, DIALOG + BEGIN + LEFTMARGIN, 5 + RIGHTMARGIN, 313 + VERTGUIDE, 12 + VERTGUIDE, 198 + VERTGUIDE, 202 + VERTGUIDE, 205 + VERTGUIDE, 304 + VERTGUIDE, 308 + TOPMARGIN, 4 + BOTTOMMARGIN, 217 + HORZGUIDE, 149 + END + + IDD_DIALOGINFO, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 366 + TOPMARGIN, 7 + BOTTOMMARGIN, 210 + END +END +#endif // APSTUDIO_INVOKED + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_MAIN ICON "VersionInfo.ico" +#endif // Italian (Italy) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/plugins/VersionInfo/services.cpp b/plugins/VersionInfo/services.cpp new file mode 100644 index 0000000000..4efa482404 --- /dev/null +++ b/plugins/VersionInfo/services.cpp @@ -0,0 +1,76 @@ +/* +Version information plugin for Miranda IM + +Copyright © 2002-2006 Luca Santarelli, Cristian Libotean + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include "common.h" +#include "services.h" + +HANDLE hsMenuCommand; +HANDLE hsGetInfo; +HANDLE hsServiceMode; + +int bServiceMode = 0; //true only if plugin is running in service mode + +int InitServices() +{ + hsMenuCommand = CreateServiceFunction(MS_VERSIONINFO_MENU_COMMAND, PluginMenuCommand); + hsGetInfo = CreateServiceFunction(MS_VERSIONINFO_GETINFO, GetInfoService); + hsServiceMode = CreateServiceFunction(MS_SERVICEMODE_LAUNCH, ServiceModeService); + return 0; +} + +int DestroyServices() +{ + DestroyServiceFunction(hsMenuCommand); + DestroyServiceFunction(hsGetInfo); + DestroyServiceFunction(hsServiceMode); + return 0; +} + +INT_PTR PluginMenuCommand(WPARAM wParam, LPARAM lParam) +{ + int debugTo = DBGetContactSettingByte(NULL, ModuleName, "DebugTo", TO_DIALOGBOX); + DoDebugTo(debugTo); + if (verbose) PUShowMessage("I have printed the information.", SM_NOTIFY); +/* char *data; + CallService(MS_VERSIONINFO_GETINFO, 1, (LPARAM) &data); */ + return 0; +} + +INT_PTR GetInfoService(WPARAM wParam, LPARAM lParam) +{ + int result = 1; //failure + if (lParam != NULL) { + CVersionInfo myInfo; + myInfo.Initialize(); + std::tstring VI = myInfo.GetInformationsAsString(wParam); + char **retData = (char **) lParam; + *retData = mir_utf8encodeT( VI.c_str()); + if (*retData) + result = 0; //success + } + return result; +} + +INT_PTR ServiceModeService(WPARAM wParam, LPARAM lParam) +{ + bServiceMode = 1; + DoDebugTo(TO_ASK); + return 0; +} diff --git a/plugins/VersionInfo/services.h b/plugins/VersionInfo/services.h new file mode 100644 index 0000000000..38acbc7731 --- /dev/null +++ b/plugins/VersionInfo/services.h @@ -0,0 +1,31 @@ +/* +Version information plugin for Miranda IM + +Copyright © 2002-2006 Luca Santarelli, Cristian Libotean + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#ifndef M_VERSIONINFO_SERVICES_H +#define M_VERSIONINFO_SERVICES_H + +int InitServices(); +int DestroyServices(); + +INT_PTR PluginMenuCommand(WPARAM wParam, LPARAM lParam); +INT_PTR GetInfoService(WPARAM wParam, LPARAM lParam); +INT_PTR ServiceModeService(WPARAM wParam, LPARAM lParam); + +#endif //M_VERSIONINFO_SERVICES_H \ No newline at end of file diff --git a/plugins/VersionInfo/svc_vi-translation.txt b/plugins/VersionInfo/svc_vi-translation.txt new file mode 100644 index 0000000000..719f0beb2c --- /dev/null +++ b/plugins/VersionInfo/svc_vi-translation.txt @@ -0,0 +1,56 @@ +; Common strings that belong to many files +;[The clipboard is not available, retry.] +;[Version Information] + +; ../../plugins/Svc_vi/CVersionInfo.cpp +;[Error during the creation of file \"%s\". Disk may be full or write protected.] +;[If you are going to use this report to submit a bug, remember to check the website for questions or help the developers may need.\r\nIf you don't check your bug report and give feedback, it will not be fixed!] +;[Information successfully copied into clipboard.] +;[Information successfully written to file: \"%s\".] + +; ../../plugins/Svc_vi/dlgHandlers.cpp +;[Are you sure you want to enable this option ?\nPlease only enable this option if you really know what you're doing and what the option is for or if someone asked you to do it.] +;[Customize using folders plugin] +;[Show plugin UUIDs ?] + +; ../../plugins/Svc_vi/hooked_events.cpp +;[Services] + +; ../../plugins/Svc_vi/main.cpp +;[Please rename the plugin '%s' to 'svc_vi.dll' to enable service mode functionality.] + +; ../../plugins/Svc_vi/resource.rc +;[&Copy text] +;[&Save to file] +;[Aditional options:] +;[Also copy info to clipboard] +;[Ask every time] +;[Attempt to find unloadable plugins (doesn't work on Windows 98)] +;[Cancel] +;[Clipboard] +;[Close] +;[DialogBox] +;[Do it now] +;[Enable debug messages] +;[Forum style formatting] +;[Highlight version number using] +;[MessageBox()] +;[Miranda Version Information] +;[OK] +;[Output to:] +;[OutputDebugString()] +;[Password] +;[Select output:] +;[Show disabled plugins too] +;[Show installed languages] +;[Show plugin UUIDs] +;[Show window in taskbar] +;[Suppress header information] +;[Text file] +;[Upload] +;[Upload site settings] +;[Upload to site] +;[Username] + +; ../../plugins/Svc_vi/utils.cpp +;[Ok, something went wrong in the \"%s\" setting. Report back the following values:\nFacility: %X\nError code: %X\nLine number: %d] diff --git a/plugins/VersionInfo/utils.cpp b/plugins/VersionInfo/utils.cpp new file mode 100644 index 0000000000..9be552c8cc --- /dev/null +++ b/plugins/VersionInfo/utils.cpp @@ -0,0 +1,526 @@ +/* +Version information plugin for Miranda IM + +Copyright © 2002-2006 Luca Santarelli, Cristian Libotean + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +//#define USE_LOG_FUNCTIONS + +#define STRICT +#define WIN32_LEAN_AND_MEAN + +#include "common.h" +#include "utils.h" + +/* +My usual MessageBoxes :-) +*/ +void MB(const TCHAR* message) +{ + if (verbose) MessageBox(NULL, message, _T("VersionInfo"), MB_OK | MB_ICONEXCLAMATION); +} + +void Log(const TCHAR* message) +{ + if (ServiceExists(MS_POPUP_ADDPOPUPT)) { + POPUPDATAT pu = {0}; + pu.lchIcon = hiVIIcon; + _tcsncpy(pu.lptzContactName, TranslateT("Version Information"), MAX_CONTACTNAME); + _tcsncpy(pu.lptzText, message, MAX_SECONDLINE); + PUAddPopUpT(&pu); + } + else MessageBox(NULL, message, _T("VersionInfo"), MB_OK | MB_ICONINFORMATION); +} + +int SplitStringInfo(const TCHAR *szWholeText, TCHAR *szStartText, TCHAR *szEndText) +{ + const TCHAR *pos = _tcschr(szWholeText, '|'); + if (pos) { + size_t index = pos - szWholeText; + lstrcpyn(szStartText, szWholeText, (int)index); + szStartText[index] = '\0'; + StrTrim(szStartText, _T(" ")); + lstrcpyn(szEndText, pos + 1, (int)_tcslen(pos)); //copies the \0 as well ... :) + StrTrim(szEndText, _T(" ")); + } + else szStartText[0] = szEndText[0] = '\0'; + + return 0; +} + +int GetStringFromDatabase(char *szSettingName, TCHAR *szError, TCHAR *szResult, size_t size) +{ + DBVARIANT dbv = {0}; + int res = 1; + size_t len; + if ( DBGetContactSettingTString(NULL, ModuleName, szSettingName, &dbv) == 0) { + res = 0; + size_t tmp = _tcslen(dbv.ptszVal); + len = (tmp < size - 1) ? tmp : size - 1; + _tcsncpy(szResult, dbv.ptszVal, len); + szResult[len] = '\0'; + mir_free(dbv.ptszVal); + } + else { + res = 1; + size_t tmp = _tcslen(szError); + len = (tmp < size - 1) ? tmp : size - 1; + _tcsncpy(szResult, szError, len); + szResult[len] = '\0'; + } + return res; +} + +TCHAR *RelativePathToAbsolute(TCHAR *szRelative, TCHAR *szAbsolute, size_t size) +{ + if (size < MAX_PATH) { + TCHAR buffer[MAX_PATH]; //new path should be at least MAX_PATH chars + CallService(MS_UTILS_PATHTOABSOLUTET, (WPARAM) szRelative, (LPARAM) buffer); + _tcsncpy(szAbsolute, buffer, size); + } + else CallService(MS_UTILS_PATHTOABSOLUTET, (WPARAM) szRelative, (LPARAM) szAbsolute); + + return szAbsolute; +} + +TCHAR *AbsolutePathToRelative(TCHAR *szAbsolute, TCHAR *szRelative, size_t size) +{ + if (size < MAX_PATH) { + TCHAR buffer[MAX_PATH]; + CallService(MS_UTILS_PATHTORELATIVET, (WPARAM) szAbsolute, (LPARAM) szRelative); + _tcsncpy(szRelative, buffer, size); + } + else CallService(MS_UTILS_PATHTORELATIVET, (WPARAM) szAbsolute, (LPARAM) szRelative); + + return szRelative; +} + +#define GetFacility(dwError) (HIWORD(dwError) && 0x0000111111111111) +#define GetErrorCode(dwError) (LOWORD(dwError)) + +void NotifyError(DWORD dwError, const TCHAR* szSetting, int iLine) +{ + TCHAR str[1024]; + mir_sntprintf(str, SIZEOF(str), TranslateT("Ok, something went wrong in the \"%s\" setting. Report back the following values:\nFacility: %X\nError code: %X\nLine number: %d"), szSetting, GetFacility(dwError), GetErrorCode(dwError), iLine); + Log(str); +} + +TCHAR *StrTrim(TCHAR *szText, const TCHAR *szTrimChars) +{ + size_t i = _tcslen(szText) - 1; + while (i >= 0 && _tcschr(szTrimChars, szText[i])) + szText[i--] = '\0'; + + i = 0; + while (((unsigned int )i < _tcslen(szText)) && _tcschr(szTrimChars, szText[i])) + i++; + + if (i) { + size_t size = _tcslen(szText); + size_t j; + for (j = i; j <= size; j++) //shift the \0 as well + szText[j - i] = szText[j]; + } + return szText; +} + +bool DoesDllExist(char *dllName) +{ + HMODULE dllHandle; + dllHandle = LoadLibraryExA(dllName, NULL, DONT_RESOLVE_DLL_REFERENCES); + if (dllHandle) + { + FreeLibrary(dllHandle); + return true; + } + return false; +} + +//========== From Cyreve ========== +PLUGININFOEX *GetPluginInfo(const TCHAR *filename,HINSTANCE *hPlugin) +{ + TCHAR szMirandaPath[MAX_PATH], szPluginPath[MAX_PATH]; + PLUGININFOEX *(*MirandaPluginInfo)(DWORD); + PLUGININFOEX *pPlugInfo; + HMODULE hLoadedModule; + DWORD mirandaVersion = CallService(MS_SYSTEM_GETVERSION,0,0); + + GetModuleFileName(GetModuleHandle(NULL), szMirandaPath, SIZEOF(szMirandaPath)); + TCHAR* str2 = _tcsrchr(szMirandaPath,'\\'); + if(str2!=NULL) *str2=0; + + hLoadedModule = GetModuleHandle(filename); + if(hLoadedModule!=NULL) { + *hPlugin=NULL; + MirandaPluginInfo=(PLUGININFOEX *(*)(DWORD))GetProcAddress(hLoadedModule,"MirandaPluginInfo"); + return MirandaPluginInfo(mirandaVersion); + } + wsprintf(szPluginPath, _T("%s\\Plugins\\%s"), szMirandaPath, filename); + *hPlugin=LoadLibrary(szPluginPath); + if (*hPlugin==NULL) return NULL; + MirandaPluginInfo=(PLUGININFOEX *(*)(DWORD))GetProcAddress(*hPlugin,"MirandaPluginInfo"); + if(MirandaPluginInfo==NULL) {FreeLibrary(*hPlugin); *hPlugin=NULL; return NULL;} + pPlugInfo=MirandaPluginInfo(mirandaVersion); + if(pPlugInfo==NULL) {FreeLibrary(*hPlugin); *hPlugin=NULL; return NULL;} + if(pPlugInfo->cbSize != sizeof(PLUGININFOEX)) {FreeLibrary(*hPlugin); *hPlugin=NULL; return NULL;} + return pPlugInfo; +} + +//========== from Frank Cheng (wintime98) ========== +// I've changed something to suit VersionInfo :-) +#include + +void TimeStampToSysTime(DWORD Unix,SYSTEMTIME* SysTime) +{ + SYSTEMTIME S; + DWORDLONG FileReal,UnixReal; + S.wYear=1970; + S.wMonth=1; + S.wDay=1; + S.wHour=0; + S.wMinute=0; + S.wSecond=0; + S.wMilliseconds=0; + SystemTimeToFileTime(&S,(FILETIME*)&FileReal); + UnixReal = Unix; + UnixReal*=10000000; + FileReal+=UnixReal; + FileTimeToSystemTime((FILETIME*)&FileReal,SysTime); +} + +void GetModuleTimeStamp(TCHAR* ptszDate, TCHAR* ptszTime) +{ + TCHAR tszModule[MAX_PATH]; + HANDLE mapfile,file; + DWORD timestamp,filesize; + LPVOID mapmem; + SYSTEMTIME systime; + GetModuleFileName(NULL,tszModule,SIZEOF(tszModule)); + file = CreateFile(tszModule,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL); + filesize = GetFileSize(file,NULL); + mapfile = CreateFileMapping(file, NULL, PAGE_READONLY, 0, filesize, NULL); + mapmem = MapViewOfFile(mapfile, FILE_MAP_READ, 0, 0, 0); + timestamp = GetTimestampForLoadedLibrary((HINSTANCE)mapmem); + TimeStampToSysTime(timestamp,&systime); + GetTimeFormat(LOCALE_USER_DEFAULT, 0, &systime, _T("HH':'mm':'ss"), ptszTime, 40 ); + GetDateFormat(EnglishLocale, 0, &systime, _T("dd' 'MMMM' 'yyyy"), ptszDate, 40); + UnmapViewOfFile(mapmem); + CloseHandle(mapfile); + CloseHandle(file); +} + +//From Egodust or Cyreve... I don't really know. +PLUGININFOEX *CopyPluginInfo(PLUGININFOEX *piSrc) +{ + if(piSrc==NULL) + return NULL; + + PLUGININFOEX *pi = (PLUGININFOEX *)malloc(sizeof(PLUGININFOEX)); + *pi = *piSrc; + + if (piSrc->cbSize >= sizeof(PLUGININFOEX)) + pi->uuid = piSrc->uuid; + else + pi->uuid = UUID_NULL; + + if (pi->author) pi->author = _strdup(pi->author); + if (pi->authorEmail) pi->authorEmail = _strdup(pi->authorEmail); + if (pi->copyright) pi->copyright = _strdup(pi->copyright); + if (pi->description) pi->description = _strdup(pi->description); + if (pi->homepage) pi->homepage = _strdup(pi->homepage); + if (pi->shortName) pi->shortName = _strdup(pi->shortName); + return pi; +} + +void FreePluginInfo(PLUGININFOEX *pi) +{ + if (pi->author) free(pi->author); + if (pi->authorEmail) free(pi->authorEmail); + if (pi->copyright) free(pi->copyright); + if (pi->description) free(pi->description); + if (pi->homepage) free(pi->homepage); + if (pi->shortName) free(pi->shortName); + free(pi); +} + +BOOL IsCurrentUserLocalAdministrator(void) +{ + BOOL fReturn = FALSE; + DWORD dwStatus; + DWORD dwAccessMask; + DWORD dwAccessDesired; + DWORD dwACLSize; + DWORD dwStructureSize = sizeof(PRIVILEGE_SET); + PACL pACL = NULL; + PSID psidAdmin = NULL; + + HANDLE hToken = NULL; + HANDLE hImpersonationToken = NULL; + + PRIVILEGE_SET ps; + GENERIC_MAPPING GenericMapping; + + PSECURITY_DESCRIPTOR psdAdmin = NULL; + SID_IDENTIFIER_AUTHORITY SystemSidAuthority = SECURITY_NT_AUTHORITY; + + /* + Determine if the current thread is running as a user that is a member of + the local admins group. To do this, create a security descriptor that + has a DACL which has an ACE that allows only local aministrators access. + Then, call AccessCheck with the current thread's token and the security + descriptor. It will say whether the user could access an object if it + had that security descriptor. Note: you do not need to actually create + the object. Just checking access against the security descriptor alone + will be sufficient. + */ + const DWORD ACCESS_READ = 1; + const DWORD ACCESS_WRITE = 2; + + + __try + { + + /* + AccessCheck() requires an impersonation token. We first get a primary + token and then create a duplicate impersonation token. The + impersonation token is not actually assigned to the thread, but is + used in the call to AccessCheck. Thus, this function itself never + impersonates, but does use the identity of the thread. If the thread + was impersonating already, this function uses that impersonation context. + */ + if (!OpenThreadToken(GetCurrentThread(), TOKEN_DUPLICATE|TOKEN_QUERY, TRUE, &hToken)) + { + if (GetLastError() != ERROR_NO_TOKEN) + __leave; + + if (!OpenProcessToken(GetCurrentProcess(), TOKEN_DUPLICATE|TOKEN_QUERY, &hToken)) + __leave; + } + + if (!DuplicateToken (hToken, SecurityImpersonation, &hImpersonationToken)) + __leave; + + + /* + Create the binary representation of the well-known SID that + represents the local administrators group. Then create the security + descriptor and DACL with an ACE that allows only local admins access. + After that, perform the access check. This will determine whether + the current user is a local admin. + */ + if (!AllocateAndInitializeSid(&SystemSidAuthority, 2, SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &psidAdmin)) + __leave; + + psdAdmin = LocalAlloc(LPTR, SECURITY_DESCRIPTOR_MIN_LENGTH); + if (psdAdmin == NULL) + __leave; + + if (!InitializeSecurityDescriptor(psdAdmin, SECURITY_DESCRIPTOR_REVISION)) + __leave; + + // Compute size needed for the ACL. + dwACLSize = sizeof(ACL) + sizeof(ACCESS_ALLOWED_ACE) + GetLengthSid(psidAdmin) - sizeof(DWORD); + + pACL = (PACL)LocalAlloc(LPTR, dwACLSize); + if (pACL == NULL) + __leave; + + if (!InitializeAcl(pACL, dwACLSize, ACL_REVISION2)) + __leave; + + dwAccessMask= ACCESS_READ | ACCESS_WRITE; + + if (!AddAccessAllowedAce(pACL, ACL_REVISION2, dwAccessMask, psidAdmin)) + __leave; + + if (!SetSecurityDescriptorDacl(psdAdmin, TRUE, pACL, FALSE)) + __leave; + + /* + AccessCheck validates a security descriptor somewhat; set the group + and owner so that enough of the security descriptor is filled out to + make AccessCheck happy. + */ + SetSecurityDescriptorGroup(psdAdmin, psidAdmin, FALSE); + SetSecurityDescriptorOwner(psdAdmin, psidAdmin, FALSE); + + if (!IsValidSecurityDescriptor(psdAdmin)) + __leave; + + dwAccessDesired = ACCESS_READ; + + /* + Initialize GenericMapping structure even though you + do not use generic rights. + */ + GenericMapping.GenericRead = ACCESS_READ; + GenericMapping.GenericWrite = ACCESS_WRITE; + GenericMapping.GenericExecute = 0; + GenericMapping.GenericAll = ACCESS_READ | ACCESS_WRITE; + + if (!AccessCheck(psdAdmin, hImpersonationToken, dwAccessDesired, &GenericMapping, &ps, &dwStructureSize, &dwStatus, &fReturn)) + { + fReturn = FALSE; + __leave; + } + } + __finally + { + // Clean up. + if (pACL) LocalFree(pACL); + if (psdAdmin) LocalFree(psdAdmin); + if (psidAdmin) FreeSid(psidAdmin); + if (hImpersonationToken) CloseHandle (hImpersonationToken); + if (hToken) CloseHandle (hToken); + } + + return fReturn; +} + +BOOL GetWindowsShell(TCHAR *shellPath, size_t shSize) +{ + OSVERSIONINFO vi = {0}; + vi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + GetVersionEx(&vi); + + TCHAR szShell[1024] = {0}; + DWORD size = SIZEOF(szShell); + + if (vi.dwPlatformId == VER_PLATFORM_WIN32_NT) + { + HKEY hKey; + if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\IniFileMapping\\system.ini\\boot"), 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) + { + RegQueryValueEx(hKey, _T("Shell"), NULL, NULL, (LPBYTE) szShell, &size); + _tcslwr(szShell); + HKEY hRootKey = ( _tcsstr(szShell, _T("sys:")) == szShell) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; + RegCloseKey(hKey); + + _tcscpy(szShell, _T("")); + if (RegOpenKeyEx(hRootKey, _T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon"), 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) + { + size = SIZEOF(szShell); + RegQueryValueEx(hKey, _T("Shell"), NULL, NULL, (LPBYTE) szShell, &size); + RegCloseKey(hKey); + } + } + } + else{ + TCHAR szSystemIniPath[2048]; + GetWindowsDirectory(szSystemIniPath, SIZEOF(szSystemIniPath)); + size_t len = lstrlen(szSystemIniPath); + if (len > 0) + { + if (szSystemIniPath[len - 1] == '\\') { szSystemIniPath[--len] = '\0'; } + _tcscat(szSystemIniPath, _T("\\system.ini")); + GetPrivateProfileString( _T("boot"), _T("shell"), _T(""), szShell, size, szSystemIniPath); + } + } + + TCHAR *pos = _tcsrchr(szShell, '\\'); + TCHAR *res = (pos) ? pos + 1 : szShell; + _tcsncpy(shellPath, res, shSize); + + return TRUE; +} + +BOOL GetInternetExplorerVersion(TCHAR *ieVersion, size_t ieSize) +{ + HKEY hKey; + TCHAR ieVer[1024]; + DWORD size = SIZEOF(ieVer); + TCHAR ieBuild[64] = {0}; + + _tcsncpy(ieVer, _T(""), size); + + if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Internet Explorer"), 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) + { + if (RegQueryValueEx(hKey, _T("Version"), NULL, NULL, (LPBYTE) ieVer, &size) == ERROR_SUCCESS) + { + TCHAR *pos = _tcschr(ieVer, '.'); + if (pos) + { + pos = _tcschr(pos + 1, '.'); + if (pos) { *pos = 0; } + _tcsncpy(ieBuild, pos + 1, SIZEOF(ieBuild)); + pos = _tcschr(ieBuild, '.'); + if (pos) { *pos = 0; } + } + } + else{ + size = SIZEOF(ieVer); + if (RegQueryValueEx(hKey, _T("Build"), NULL, NULL, (LPBYTE) ieVer, &size) == ERROR_SUCCESS) + { + TCHAR *pos = ieVer + 1; + _tcsncpy(ieBuild, pos, SIZEOF(ieBuild)); + *pos = 0; + pos = _tcschr(ieBuild, '.'); + if (pos) { *pos = 0; } + } + else{ + _tcsncpy(ieVer, _T(""), size); + } + } + RegCloseKey(hKey); + } + + _tcsncpy(ieVersion, ieVer, ieSize); + if ( ieBuild[0] ) + { + _tcsncat(ieVersion, _T("."), ieSize); + _tcsncat(ieVersion, ieBuild, ieSize); + } + + return TRUE; +} + + +TCHAR *GetLanguageName(LANGID language) +{ + LCID lc = MAKELCID(language, SORT_DEFAULT); + return GetLanguageName(lc); +} + +extern TCHAR *GetLanguageName(LCID locale) +{ + static TCHAR name[1024]; + GetLocaleInfo(locale, LOCALE_SENGLANGUAGE, name, SIZEOF(name)); + return name; +} + +BOOL UUIDToString(MUUID uuid, TCHAR *str, size_t len) +{ + if ( len < sizeof(MUUID) || !str ) + return 0; + + mir_sntprintf(str, len, _T("{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}"), uuid.a, uuid.b, uuid.c, uuid.d[0], uuid.d[1], uuid.d[2], uuid.d[3], uuid.d[4], uuid.d[5], uuid.d[6], uuid.d[7]); + return 1; +} + +BOOL IsUUIDNull(MUUID uuid) +{ + int i; + for (i = 0; i < sizeof(uuid.d); i++) + { + if (uuid.d[i]) + { + return 0; + } + } + + return ((uuid.a == 0) && (uuid.b == 0) && (uuid.c == 0)); +} \ No newline at end of file diff --git a/plugins/VersionInfo/utils.h b/plugins/VersionInfo/utils.h new file mode 100644 index 0000000000..5db4b1a811 --- /dev/null +++ b/plugins/VersionInfo/utils.h @@ -0,0 +1,49 @@ +#ifndef _M_VERSIONINFO_UTILS_H +#define _M_VERSIONINFO_UTILS_H + +#include "common.h" + +//utils.cpp +void MB(const TCHAR*); +void Log(const TCHAR*); +TCHAR *StrTrim(TCHAR *, const TCHAR *); + +//utils.cpp +TCHAR *RelativePathToAbsolute(TCHAR *szRelative, TCHAR *szAbsolute, size_t size); +TCHAR *AbsolutePathToRelative(TCHAR *szAbsolute, TCHAR *szRelative, size_t size); + +//returns a string from the database and uses MirandaFree to deallocate the string, leaving only the local copy +//utils.cpp +int GetStringFromDatabase(char *szSettingName, TCHAR *szError, TCHAR *szResult, size_t size); + +//a string of the form %s(start) | %s(end) is split into the two strings (start and end) +//utils.cpp +int SplitStringInfo(const TCHAR *szWholeText, TCHAR *szStartText, TCHAR *szEndText); + +//utils.cpp +bool DoesDllExist(char *dllName); + +//utils.cpp +void GetModuleTimeStamp(TCHAR*, TCHAR*); +void NotifyError(DWORD, const TCHAR*, int); + +//utils.cpp +PLUGININFOEX *GetPluginInfo(const char *,HINSTANCE *); +PLUGININFOEX *CopyPluginInfo(PLUGININFOEX *); +void FreePluginInfo(PLUGININFOEX *); + +//utils.cpp + +BOOL IsCurrentUserLocalAdministrator(); + +TCHAR *GetLanguageName(LANGID language); +TCHAR *GetLanguageName(LCID locale); + +BOOL GetWindowsShell(TCHAR *shellPath, size_t shSize); +BOOL GetInternetExplorerVersion(TCHAR *ieVersion, size_t ieSize); + +BOOL UUIDToString(MUUID uuid, TCHAR *str, size_t len); + +BOOL IsUUIDNull(MUUID uuid); + +#endif \ No newline at end of file diff --git a/plugins/VersionInfo/version.h b/plugins/VersionInfo/version.h new file mode 100644 index 0000000000..200ac05349 --- /dev/null +++ b/plugins/VersionInfo/version.h @@ -0,0 +1,44 @@ +/* +Version information plugin for Miranda IM + +Copyright © 2002-2005 Luca Santarelli, © 2005-2008 Cristian Libotean + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#ifndef M_VERSIONINFO_VERSION_H +#define M_VERSIONINFO_VERSION_H + +#define __MAJOR_VERSION 1 +#define __MINOR_VERSION 5 +#define __RELEASE_NUM 0 +#define __BUILD_NUM 2 + +#define VERSION PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM) + +#define __PLUGINVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM +#define __PLUGINVERSION_STRING_DOTS __MAJOR_VERSION.__MINOR_VERSION.__RELEASE_NUM.__BUILD_NUM +#define __STRINGIFY_(x) #x +#define __STRINGIFY(x) __STRINGIFY_(x) +#define __VERSION_STRING __STRINGIFY(__PLUGINVERSION_STRING_DOTS) + +#define __DESC "Collects and prints information related to Miranda, the plugins and the OS." +#define __AUTHOR "Luca Santarelli, Cristian Libotean, George Hazan" +#define __AUTHOREMAIL "hrk@users.sourceforge.net, eblis102@yahoo.com, ghazan@miranda.im" +#define __COPYRIGHT "© 2002-2005 Luca Santarelli, © 2005-2009 Cristian Libotean" +#define __AUTHORWEB "http://www.miranda-im.org/" +#define __PLUGIN_DISPLAY_NAME "Version Information" + +#endif //M_VERSIONINFO_VERSION_H diff --git a/plugins/VersionInfo/version.rc b/plugins/VersionInfo/version.rc new file mode 100644 index 0000000000..cd65db2ee3 --- /dev/null +++ b/plugins/VersionInfo/version.rc @@ -0,0 +1,104 @@ +// Microsoft Visual C++ generated resource script. +// +#ifdef APSTUDIO_INVOKED +#error this file is not editable by Microsoft Visual C++ +#endif //APSTUDIO_INVOKED + +#include "resource.h" +#include "version.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource1.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION __PLUGINVERSION_STRING + PRODUCTVERSION __PLUGINVERSION_STRING + FILEFLAGSMASK 0x17L +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "Author", __AUTHOR + VALUE "FileDescription", __DESC + VALUE "FileVersion", __VERSION_STRING + VALUE "InternalName", __PLUGIN_DISPLAY_NAME + VALUE "LegalCopyright", __COPYRIGHT + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + -- cgit v1.2.3