OSDN Git Service

first commit
authortnishi <sgm00353@nifty.ne.jp>
Thu, 27 Oct 2016 14:00:32 +0000 (23:00 +0900)
committertnishi <sgm00353@nifty.ne.jp>
Thu, 27 Oct 2016 14:00:32 +0000 (23:00 +0900)
144 files changed:
DCHook/DCHook.6.0.sln [new file with mode: 0644]
DCHook/DCHook.7.1.vcproj [new file with mode: 0644]
DCHook/DCHook.cpp [new file with mode: 0644]
DCHook/DCHook.def [new file with mode: 0644]
DCHook/DCHook.h [new file with mode: 0644]
DCHook/DCHook.mak [new file with mode: 0644]
DCHook/DCHook.sln [new file with mode: 0644]
DCHook/DCHook.vcproj [new file with mode: 0644]
DCHook/DCHook.vcxproj [new file with mode: 0644]
DCHook/DCHook.vcxproj.filters [new file with mode: 0644]
DCHook/MonitorScale.cpp [new file with mode: 0644]
DCHook/MonitorScale.h [new file with mode: 0644]
DCHook/VS2003/DCHook.sln [new file with mode: 0644]
DCHook/VS2003/DCHook.vcproj [new file with mode: 0644]
DCHook/VS2008/DCHook.sln [new file with mode: 0644]
DCHook/VS2008/DCHook.vcproj [new file with mode: 0644]
DCHook/VS2015/DCHook.sln [new file with mode: 0644]
DCHook/VS2015/DCHook.vcxproj [new file with mode: 0644]
DCHook/VS2015/DCHook.vcxproj.filters [new file with mode: 0644]
DCHook/dchook.rc [new file with mode: 0644]
DCHook64/DCHook64.h [new file with mode: 0644]
DCHook64/dchk64/ReadMe.txt [new file with mode: 0644]
DCHook64/dchk64/Resource.h [new file with mode: 0644]
DCHook64/dchk64/dchk64.cpp [new file with mode: 0644]
DCHook64/dchk64/dchk64.h [new file with mode: 0644]
DCHook64/dchk64/dchk64.ico [new file with mode: 0644]
DCHook64/dchk64/dchk64.rc [new file with mode: 0644]
DCHook64/dchk64/dchk64.sln [new file with mode: 0644]
DCHook64/dchk64/dchk64.suo [new file with mode: 0644]
DCHook64/dchk64/dchk64.vcxproj [new file with mode: 0644]
DCHook64/dchk64/dchk64.vcxproj.filters [new file with mode: 0644]
DCHook64/dchk64/small.ico [new file with mode: 0644]
DCHook64/dchk64/stdafx.cpp [new file with mode: 0644]
DCHook64/dchk64/stdafx.h [new file with mode: 0644]
DCHook64/dchk64/targetver.h [new file with mode: 0644]
DCHookTest/DCHookLoader.cpp [new file with mode: 0644]
DCHookTest/DCHookLoader.h [new file with mode: 0644]
DCHookTest/DCHookMain.cpp [new file with mode: 0644]
DCHookTest/DCHookMain.dfm [new file with mode: 0644]
DCHookTest/DCHookMain.h [new file with mode: 0644]
DCHookTest/DCHookTest.bpr [new file with mode: 0644]
DCHookTest/DCHookTest.cpp [new file with mode: 0644]
DCHookTest/DCHookTest.dfm [new file with mode: 0644]
DCHookTest/DCHookTest.h [new file with mode: 0644]
DCHookTest/DCHookTest.mak [new file with mode: 0644]
DCHookTest/DCHookTest.rc [new file with mode: 0644]
DCHookTest/DCHookTest.res [new file with mode: 0644]
DCHookTest/DKPU.txt [new file with mode: 0644]
DCHookTest/HookDLl.cpp [new file with mode: 0644]
DCHookTest/HookDLl.h [new file with mode: 0644]
DCHookTest/HookLoader.cpp [new file with mode: 0644]
DCHookTest/HookLoader.h [new file with mode: 0644]
DCHookTest/MODINotifyDlg.cpp [new file with mode: 0644]
DCHookTest/MODINotifyDlg.dfm [new file with mode: 0644]
DCHookTest/MODINotifyDlg.h [new file with mode: 0644]
DCHookTest/Notify.cpp [new file with mode: 0644]
DCHookTest/Notify.dfm [new file with mode: 0644]
DCHookTest/Notify.h [new file with mode: 0644]
DCHookTest/OCRTextFrm.cpp [new file with mode: 0644]
DCHookTest/OCRTextFrm.dfm [new file with mode: 0644]
DCHookTest/OCRTextFrm.h [new file with mode: 0644]
DCHookTest/PopupConfig.cpp [new file with mode: 0644]
DCHookTest/PopupConfig.dfm [new file with mode: 0644]
DCHookTest/PopupConfig.h [new file with mode: 0644]
DCHookTest/StringLib.cpp [new file with mode: 0644]
DCHookTest/StringLib.h [new file with mode: 0644]
DCHookTest/Util.cpp [new file with mode: 0644]
DCHookTest/Util.h [new file with mode: 0644]
DCHookTest/cpd.bat [new file with mode: 0644]
DCHookTest/dkpp.bmp [new file with mode: 0644]
DCHookTest/dkpp.ico [new file with mode: 0644]
DCHookTest/dkpp0.ico [new file with mode: 0644]
DCHookTest/dkpp2.bmp [new file with mode: 0644]
DCHookTest/dkpp3.bmp [new file with mode: 0644]
DCHookTest/dkpp4.bmp [new file with mode: 0644]
DCHookTest/dkpps.ico [new file with mode: 0644]
DCHookTest/dkpps0.ico [new file with mode: 0644]
DCHookTest/icon.rc [new file with mode: 0644]
DCHookTest/icon.res [new file with mode: 0644]
DCHookTest/mustr.cpp [new file with mode: 0644]
DCHookTest/mustr.h [new file with mode: 0644]
DCHookTest/obj/icon.res [new file with mode: 0644]
DCHookTest/popdisable.bmp [new file with mode: 0644]
DCHookTest/popdisable.h [new file with mode: 0644]
DCHookTest/popenable.bmp [new file with mode: 0644]
DCHookTest/popenable.h [new file with mode: 0644]
DCHookTest/prgconfig.cpp [new file with mode: 0644]
DCHookTest/prgconfig.h [new file with mode: 0644]
DCHookTest/prgprof.cpp [new file with mode: 0644]
DCHookTest/prgprof.h [new file with mode: 0644]
DCHookTest/stdafx.h [new file with mode: 0644]
DKPP.TXT [new file with mode: 0644]
DKPPu.TXT [new file with mode: 0644]
DKPU.TXT [new file with mode: 0644]
DKPUu.TXT [new file with mode: 0644]
Diary.txt [new file with mode: 0644]
ExMODIst/ExMODIst.bpf [new file with mode: 0644]
ExMODIst/ExMODIst.bpr [new file with mode: 0644]
ExMODIst/ExMODIst.cpp [new file with mode: 0644]
ExMODIst/ExMODIst.h [new file with mode: 0644]
ExMODIst/ExMODIst.rc [new file with mode: 0644]
ExMODIst/ExMODIst.sln [new file with mode: 0644]
ExMODIst/ExMODIst.vcproj [new file with mode: 0644]
ExMODIst/ExMODIst.vcxproj [new file with mode: 0644]
ExMODIst/ExMODIst.vcxproj.filters [new file with mode: 0644]
ExMODIst/ReadMe.txt [new file with mode: 0644]
ExMODIst/Resource.h [new file with mode: 0644]
ExMODIst/main.cpp [new file with mode: 0644]
ExMODIst/stdafx.cpp [new file with mode: 0644]
ExMODIst/stdafx.h [new file with mode: 0644]
ExMODIst/targetver.h [new file with mode: 0644]
ExMODIstBCC/ExMODIst.bpf [new file with mode: 0644]
ExMODIstBCC/ExMODIst.bpr [new file with mode: 0644]
ExMODIstBCC/main.cpp [new file with mode: 0644]
MK.BAT [new file with mode: 0644]
MKU.BAT [new file with mode: 0644]
Makefile [new file with mode: 0644]
README.TXT [new file with mode: 0644]
VxD/hk95c.c [new file with mode: 0644]
VxD/hk95d.asm [new file with mode: 0644]
VxD/hk95d.def [new file with mode: 0644]
VxD/hk95d.h [new file with mode: 0644]
VxD/makefile [new file with mode: 0644]
amodi/amodi.sln [new file with mode: 0644]
amodi/amodi/MainForm.Designer.cs [new file with mode: 0644]
amodi/amodi/MainForm.cs [new file with mode: 0644]
amodi/amodi/MainForm.resx [new file with mode: 0644]
amodi/amodi/Program.cs [new file with mode: 0644]
amodi/amodi/Properties/AssemblyInfo.cs [new file with mode: 0644]
amodi/amodi/Properties/Resources.Designer.cs [new file with mode: 0644]
amodi/amodi/Properties/Resources.resx [new file with mode: 0644]
amodi/amodi/Properties/Settings.Designer.cs [new file with mode: 0644]
amodi/amodi/Properties/Settings.settings [new file with mode: 0644]
amodi/amodi/amodi.csproj [new file with mode: 0644]
amodi/amodi/app.config [new file with mode: 0644]
amodi/readme.txt [new file with mode: 0644]
change_iss.pl [new file with mode: 0644]
cpr.bat [new file with mode: 0644]
dchook.ind [new file with mode: 0644]
dchook.tpl [new file with mode: 0644]
dchooku.ind [new file with mode: 0644]
dchooku.tpl [new file with mode: 0644]
mktpl.bat [new file with mode: 0644]
mktplu.bat [new file with mode: 0644]

diff --git a/DCHook/DCHook.6.0.sln b/DCHook/DCHook.6.0.sln
new file mode 100644 (file)
index 0000000..22d6daf
--- /dev/null
@@ -0,0 +1,25 @@
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual Studio 2008
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DCHook", "DCHook.vcproj", "{8C65CE15-64F8-43E6-968D-DBBB96858BB2}"
+EndProject
+Global
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution
+               Debug|Win32 = Debug|Win32
+               Debug|x64 = Debug|x64
+               Release|Win32 = Release|Win32
+               Release|x64 = Release|x64
+       EndGlobalSection
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution
+               {8C65CE15-64F8-43E6-968D-DBBB96858BB2}.Debug|Win32.ActiveCfg = Debug|Win32
+               {8C65CE15-64F8-43E6-968D-DBBB96858BB2}.Debug|Win32.Build.0 = Debug|Win32
+               {8C65CE15-64F8-43E6-968D-DBBB96858BB2}.Debug|x64.ActiveCfg = Debug|x64
+               {8C65CE15-64F8-43E6-968D-DBBB96858BB2}.Debug|x64.Build.0 = Debug|x64
+               {8C65CE15-64F8-43E6-968D-DBBB96858BB2}.Release|Win32.ActiveCfg = Release|Win32
+               {8C65CE15-64F8-43E6-968D-DBBB96858BB2}.Release|Win32.Build.0 = Release|Win32
+               {8C65CE15-64F8-43E6-968D-DBBB96858BB2}.Release|x64.ActiveCfg = Release|x64
+               {8C65CE15-64F8-43E6-968D-DBBB96858BB2}.Release|x64.Build.0 = Release|x64
+       EndGlobalSection
+       GlobalSection(SolutionProperties) = preSolution
+               HideSolutionNode = FALSE
+       EndGlobalSection
+EndGlobal
diff --git a/DCHook/DCHook.7.1.vcproj b/DCHook/DCHook.7.1.vcproj
new file mode 100644 (file)
index 0000000..c6c4c8c
--- /dev/null
@@ -0,0 +1,142 @@
+<?xml version="1.0" encoding="shift_jis"?>
+<VisualStudioProject
+       ProjectType="Visual C++"
+       Version="7.10"
+       Name="DCHook"
+       ProjectGUID="{8C65CE15-64F8-43E6-968D-DBBB96858BB2}"
+       Keyword="Win32Proj">
+       <Platforms>
+               <Platform
+                       Name="Win32"/>
+       </Platforms>
+       <Configurations>
+               <Configuration
+                       Name="Debug|Win32"
+                       OutputDirectory="Debug"
+                       IntermediateDirectory="Debug"
+                       ConfigurationType="2"
+                       CharacterSet="2">
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               Optimization="0"
+                               PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;DCHOOK_EXPORTS"
+                               MinimalRebuild="TRUE"
+                               BasicRuntimeChecks="3"
+                               RuntimeLibrary="1"
+                               UsePrecompiledHeader="2"
+                               WarningLevel="3"
+                               Detect64BitPortabilityProblems="FALSE"
+                               DebugInformationFormat="4"/>
+                       <Tool
+                               Name="VCCustomBuildTool"/>
+                       <Tool
+                               Name="VCLinkerTool"
+                               OutputFile="$(OutDir)/DCHook.dll"
+                               LinkIncremental="2"
+                               ModuleDefinitionFile="DCHook.def"
+                               GenerateDebugInformation="TRUE"
+                               ProgramDatabaseFile="$(OutDir)/DCHook.pdb"
+                               SubSystem="2"
+                               ImportLibrary="$(OutDir)/DCHook.lib"
+                               TargetMachine="1"/>
+                       <Tool
+                               Name="VCMIDLTool"/>
+                       <Tool
+                               Name="VCPostBuildEventTool"/>
+                       <Tool
+                               Name="VCPreBuildEventTool"/>
+                       <Tool
+                               Name="VCPreLinkEventTool"/>
+                       <Tool
+                               Name="VCResourceCompilerTool"/>
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"/>
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"/>
+                       <Tool
+                               Name="VCWebDeploymentTool"/>
+                       <Tool
+                               Name="VCManagedWrapperGeneratorTool"/>
+                       <Tool
+                               Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+               </Configuration>
+               <Configuration
+                       Name="Release|Win32"
+                       OutputDirectory="Release"
+                       IntermediateDirectory="Release"
+                       ConfigurationType="2"
+                       CharacterSet="2">
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;DCHOOK_EXPORTS"
+                               RuntimeLibrary="0"
+                               UsePrecompiledHeader="2"
+                               WarningLevel="3"
+                               Detect64BitPortabilityProblems="FALSE"
+                               DebugInformationFormat="3"/>
+                       <Tool
+                               Name="VCCustomBuildTool"/>
+                       <Tool
+                               Name="VCLinkerTool"
+                               OutputFile="$(OutDir)/DCHook.dll"
+                               LinkIncremental="1"
+                               ModuleDefinitionFile="DCHook.def"
+                               GenerateDebugInformation="TRUE"
+                               SubSystem="2"
+                               OptimizeReferences="2"
+                               EnableCOMDATFolding="2"
+                               ImportLibrary="$(OutDir)/DCHook.lib"
+                               TargetMachine="1"/>
+                       <Tool
+                               Name="VCMIDLTool"/>
+                       <Tool
+                               Name="VCPostBuildEventTool"/>
+                       <Tool
+                               Name="VCPreBuildEventTool"/>
+                       <Tool
+                               Name="VCPreLinkEventTool"/>
+                       <Tool
+                               Name="VCResourceCompilerTool"/>
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"/>
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"/>
+                       <Tool
+                               Name="VCWebDeploymentTool"/>
+                       <Tool
+                               Name="VCManagedWrapperGeneratorTool"/>
+                       <Tool
+                               Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+               </Configuration>
+       </Configurations>
+       <References>
+       </References>
+       <Files>
+               <Filter
+                       Name="\83\\81[\83\83t\83@\83C\83\8b"
+                       Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+                       UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
+                       <File
+                               RelativePath=".\DCHook.cpp">
+                       </File>
+                       <File
+                               RelativePath=".\DCHook.def">
+                       </File>
+               </Filter>
+               <Filter
+                       Name="\83w\83b\83_\81\83t\83@\83C\83\8b"
+                       Filter="h;hpp;hxx;hm;inl;inc;xsd"
+                       UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
+               </Filter>
+               <Filter
+                       Name="\83\8a\83\\81[\83\83t\83@\83C\83\8b"
+                       Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
+                       UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
+                       <File
+                               RelativePath=".\dchook.rc">
+                       </File>
+               </Filter>
+       </Files>
+       <Globals>
+       </Globals>
+</VisualStudioProject>
diff --git a/DCHook/DCHook.cpp b/DCHook/DCHook.cpp
new file mode 100644 (file)
index 0000000..03bd3c8
--- /dev/null
@@ -0,0 +1,3069 @@
+//---------------------------------------------------------------------------
+//
+// \96â\91è\93_\81F
+// Ver0.50
+//
+// \8dÅ\93K\89»\82Ì\89Û\91è\81F
+// standard library\82ð\8eg\82í\82È\82¢\82æ\82¤\82É\82·\82é
+// \8b¤\97L\97Ì\88æ\82ð\91\9d\82â\82·
+//
+// Tips:
+// \93Ë\91RDetach\82³\82ê\82é\8c»\8fÛ
+// --> Hook Function\82Å\97á\8aO\82ª\94­\90\82µ\82Ä\82¢\82é\89Â\94\\90«\82ª\8d\82\82¢
+//     \82à\82µ\82­\82Í\81A\83A\83v\83\8a\83P\81[\83V\83\87\83\93\82Å\97á\8aO\94­\90\82µ\82Ä\82¢\82é
+// \8b¤\97L\83\81\83\82\83\8a\82É\82Â\82¢\82Ä
+// \95¨\97\9d\83\81\83\82\83\8a\82ª\93¯\88ê\82¾\82¯\82Å\82 \82Á\82Ä\81A\98_\97\9d\83A\83h\83\8c\83X\82Í\93¯\88ê\82Æ\82Í\8cÀ\82ç\82È\82¢\81I\81I
+// \8f]\82Á\82Ä\81A\8b¤\97L\83\81\83\82\83\8a\8fã\82Épointer\82ð\94z\92u\82·\82é\82±\82Æ\82Í\8aî\96{\93I\82É\8aë\8c¯\81I\81I
+#define STRICT
+#include <windows.h>
+#include <tchar.h>
+#pragma hdrstop
+#ifndef GWL_WNDPROC
+#define GWL_WNDPROC         (-4)       // \82±\82Ì\92è\8b`\82ª\82È\82¢\82Æerror\82É\82È\82Á\82½ 2014.11.19
+#endif
+#include <tlhelp32.h>
+#include <imagehlp.h>
+#pragma comment(lib, "ImageHlp")
+#include "DCHook.h"
+#ifndef UNICODE
+#include "..\VxD\hk95d.h"
+#endif
+#include "MonitorScale.h"
+
+// Compiler //
+#pragma        warning( disable : 4710 )       // \82Ç\82¤\82µ\82Ä\82±\82¤\82¢\82¤warning\82ª\8fo\82Ä\82­\82é\82Ì\82©\81H
+
+// Configuration //
+#define        USE_SCALING             1       // Uses DPI scaling
+
+#define        USE_DBW                 1       // DBW\82ð\8eg\97p\82·\82é
+#define        USE_SHARE0              1       // share\82µ\82Ä\82à\96â\91è\82È\82¢\95Ï\90\94
+
+#define        METAEXTTEXTOUT  1       // MetaMethod\82ÅExtTextOutx\82ðhook\82·\82é
+#define        HOOK_GETDC              0       // GetDC(),ReleaseDC()\82ðhook\82·\82é
+#define        HOOK_TEXT               0       // DrawText(Ex),TextOut,TabbedTextOut\82Ìhooking
+#define        USE_REDRAW              1
+#define        HOOK_BITBLT             0       // 2016.1.15 \8aO\82µ\82Ä\82Ý\82½
+#define        HOOK_PAINT              0
+#define        GUARD                   0       // \8b¤\97L\83\81\83\82\83\8a\82ðVirtualProtect\82Åguard\82·\82é
+                                                       // \97L\8cø\82É\82·\82é\82ÆApplication\8fI\97¹\8e\9e\82É\88Ù\8fí\8fI\97¹\82ª\94­\90\82·\82é
+                            // Application close ->
+                            // \8c´\88ö\81FDettach\82·\82é\91O\82É\81AOS or Application\82ª
+                            // Protected code\97Ì\88æ\82É\8f\91\82«\8d\9e\82Ý\82ð\8ds\82Á\82Ä\82¢\82é\82æ\82¤\82¾
+
+#define        USE_INVALIDATE          0       // \95`\89æ\91O\82ÉInvalidate\82ð\91\97\82é(IE5@Win98\82Í\95K\97v)
+#define        INVALIDATE_TRUE         0       // InvalidateRect\82Årepaint\82ð\8ds\82¤
+#define        ORG_OFFSET                      1       // ViewPort\82Ìorg offset\8f\88\97\9d\82ð\8ds\82¤
+
+#define        USE_OPTIMALINVALID      1       // \8dÄ\95`\89æ\97Ì\88æ\82ð\82È\82é\82×\82­\8f¬\82³\82­\82·\82é
+#define        USE_VXD                         0       // no longer support (Win9x)
+#define        EXC_WOW64                       0       // do not attach on WOW64
+
+#define        MAX_KEYS                        8       // \83L\81[\83t\83\89\83O\82Ì\8dÅ\91å\92è\8b`\90\94
+
+#define        DEBUG_HITTEXT           0       // for debug hit text
+
+// ExtTextOut hooking\82ÅMetafile\82à\8eg\97p\82·\82é
+// \92P\93Æ\82Å\8ds\82¤\8fê\8d\87\82Í\81ARETRYMETA
+#if HOOK_PAINT || HOOK_GETDC || !USE_REDRAW
+#define        USE_META        1
+#else
+#define        USE_META        0
+#endif
+
+#define        RETRYMETA       1
+
+#if USE_DBW
+#include <stdio.h>
+#else  // !USE_DBW
+#undef DEBUG_HITTEXT
+#define        DEBUG_HITTEXT   0
+#endif // !USE_DBW
+
+#define        MOVESEND_POST   1
+
+// Type Definitions //
+
+// Macros //
+#if GUARD
+#define        PROTECT_SHARE()         ShareProtect( true )
+#define        UNPROTECT_SHARE()       ShareProtect( false )
+#else
+#define        PROTECT_SHARE()
+#define        UNPROTECT_SHARE()
+#endif
+
+#if USE_DBW
+#define        DBW             dbw
+#else
+#define        DBW             (void)
+#endif
+void dbw(const char *format, ...);
+
+#define        WM_AMODI                                (WM_APP+0x400)  // app communication message with AMODI
+#define        WM_MOVESEND                             (WM_APP+0x208)  // DCH_MOVESEND\82Ì\91ã\82í\82è\82ÉPostMessage\82Å\91\97\82é
+#define        AMODI_CMD_QUERY                 0
+#define        AMODI_CMD_PAGE_CAPTURE  1
+
+#define        tsizeof(type)   sizeof(type)
+#define        int_bool(v)             ((v)!=0)
+
+#pragma warning (disable : 4996)
+
+//==============================================//
+// TString template class                                              //
+//==============================================//
+template <class T>
+class TString {
+protected:
+       T *Buffer;
+       int Size;       // Buffer size in character
+       int Length;     // String length in character
+public:
+       TString();
+       ~TString();
+       void Clear()
+               { Buffer[0] = '\0'; Length = 0; }
+       void Set( const T *str, int len );
+       void Set( TString *obj )
+               { Set( obj->c_str(), obj->Length ); }
+       void Cat( const T *str, int len );
+       operator const T *() const
+               { return Buffer; }
+       T operator [] ( int index )
+               { return Buffer[index]; }
+       const T *c_str()
+               { return Buffer; }
+       int GetLength() const { return Length; }
+       int GetByte() const { return Length * sizeof(T); }
+//     int GetSize() const { return Size; }
+};
+template <class T>
+TString<T>::TString()
+{
+       Size = 256;             // initial size
+       Buffer = new T[ Size + 1 ];
+       if (!Buffer)
+               Size = 0;
+       Length = 0;
+}
+template <class T>
+TString<T>::~TString()
+{
+       if (Buffer)
+               delete[] Buffer;
+}
+template <class T>
+void TString<T>::Set( const T *str, int len )
+{
+       if (Buffer){
+               if ( Size < len ){
+                       // not enough space to store
+                       delete[] Buffer;
+               } else goto j1;
+       }
+       Buffer = new T[ len + 1 ];
+       Size = len;
+       if (Buffer){
+j1:;
+               CopyMemory( Buffer, str, len*sizeof(T) );
+               Buffer[len] = '\0';
+               Length = len;
+       } else {
+               Size = 0;
+               Length = 0;
+       }
+}
+template <class T>
+void TString<T>::Cat( const T *str, int len )
+{
+       if (!Buffer){
+               Set( str, len );
+               return;
+       }
+       int newlen = Length + len;
+       if (Size < newlen){
+               T *p = new T[ newlen + 1 ];
+               if (p)
+                       CopyMemory( p, Buffer, newlen*sizeof(T) );
+               delete[] Buffer;
+               Buffer = p;
+               Size = newlen;
+       }
+       if (Buffer){
+               CopyMemory( Buffer+Length, str, len * sizeof(T) );
+               Buffer[newlen] = '\0';
+               Length = newlen;
+       } else {
+               Size = 0;
+               Length = 0;
+               Set( str, len );
+       }
+}
+
+int GetTextFromPoint( HDC hdc, const char *text, int len, int pos, int pos_y, const int *dx=NULL );
+int GetTextFromPoint( HDC hdc, const wchar_t *text, int len, int pos, int pos_y, const int *dx=NULL );
+
+bool CaptureImage(HWND hwnd, bool movesend, bool non_block);
+bool WaitAndGetResult(const TCHAR *text_path, unsigned waittime);
+HANDLE WaitForResult(const TCHAR *text_path, unsigned waittime);
+HWND FindAMODI();
+int SendAMODI(int cmd, const char *data, int len);
+void CheckAMODIAlive();
+void SendMoveMessage();
+void SendCancelMove();
+DWORD WINAPI SendMoveThread(LPVOID vdParam);
+void CheckWOW64();
+
+extern "C" {
+//==============================================//
+// Prototypes                                                                  //
+//==============================================//
+typedef HDC (WINAPI *FNBeginPaint)( HWND, LPPAINTSTRUCT );
+typedef BOOL (WINAPI *FNEndPaint)( HWND, CONST PAINTSTRUCT * );
+typedef HDC (WINAPI *FNGetDC)( HWND );
+typedef int (WINAPI *FNReleaseDC)( HWND, HDC );
+typedef BOOL (WINAPI *FNExtTextOutW)(HDC hdc, int x, int y, UINT option, CONST RECT *rc, LPCWSTR str, UINT count, CONST INT *dx );
+typedef BOOL (WINAPI *FNExtTextOutA)(HDC hdc, int x, int y, UINT option, CONST RECT *rc, LPCSTR str, UINT count, CONST INT *dx );
+typedef BOOL (WINAPI *FNBitBlt)(HDC hdcdest, int xdest, int ydest, int width, int height, HDC hdcsrc, int xsrc, int ysrc, DWORD rop );
+
+typedef LONG (WINAPI *FNTabbedTextOutA)( HDC hdc, int x, int y, LPCSTR str, int count, int ntabs, LPINT tabs, int origin );
+typedef LONG (WINAPI *FNTabbedTextOutW)( HDC hdc, int x, int y, LPCWSTR str, int count, int ntabs, LPINT tabs, int origin );
+typedef BOOL (WINAPI *FNTextOutA)( HDC hdc, int x, int y, LPCSTR str, int count );
+typedef BOOL (WINAPI *FNTextOutW)( HDC hdc, int x, int y, LPCWSTR str, int count );
+typedef int (WINAPI *FNDrawTextA)( HDC hdc, LPCSTR str, int count, LPRECT rc, UINT format );
+typedef int (WINAPI *FNDrawTextW)( HDC hdc, LPCWSTR str, int count, LPRECT rc, UINT format );
+typedef int (WINAPI *FNDrawTextExA)( HDC hdc, LPCSTR str, int count, LPRECT rc, UINT format, LPDRAWTEXTPARAMS params );
+typedef int (WINAPI *FNDrawTextExW)( HDC hdc, LPCWSTR str, int count, LPRECT rc, UINT format, LPDRAWTEXTPARAMS params );
+
+typedef BOOL (WINAPI *FNMoveToEx)(HDC hdc, int x, int y, LPPOINT pt );
+
+
+HDC WINAPI _BeginPaint( HWND hwnd, LPPAINTSTRUCT ps );
+BOOL WINAPI _EndPaint( HWND hwnd, CONST PAINTSTRUCT *ps );
+HDC WINAPI _GetDC( HWND hwnd );
+int WINAPI _ReleaseDC( HWND hwnd, HDC hdc );
+BOOL  WINAPI _ExtTextOutA(HDC hdc, int x, int y, UINT option, CONST RECT *rc, LPCSTR str, UINT count, CONST INT *dx );
+BOOL  WINAPI _ExtTextOutW(HDC hdc, int x, int y, UINT option, CONST RECT *rc, LPCWSTR str, UINT count, CONST INT *dx );
+BOOL WINAPI _BitBlt(HDC hdcdest, int xdest, int ydest, int width, int height, HDC hdcsrc, int xsrc, int ysrc, DWORD rop );
+
+LONG WINAPI _TabbedTextOutA( HDC hdc, int x, int y, LPCSTR str, int count, int ntabs, LPINT tabs, int origin );
+LONG WINAPI _TabbedTextOutW( HDC hdc, int x, int y, LPCWSTR str, int count, int ntabs, LPINT tabs, int origin );
+BOOL WINAPI _TextOutA( HDC hdc, int x, int y, LPCSTR str, int count );
+BOOL WINAPI _TextOutW( HDC hdc, int x, int y, LPCWSTR str, int count );
+int WINAPI _DrawTextA( HDC hdc, LPCSTR str, int count, LPRECT rc, UINT format );
+int WINAPI _DrawTextW( HDC hdc, LPCWSTR str, int count, LPRECT rc, UINT format );
+int WINAPI _DrawTextExA( HDC hdc, LPCSTR str, int count, LPRECT rc, UINT format, LPDRAWTEXTPARAMS params );
+int WINAPI _DrawTextExW( HDC hdc, LPCWSTR str, int count, LPRECT rc, UINT format, LPDRAWTEXTPARAMS params );
+
+BOOL WINAPI _MoveToEx( HDC hdc, int x, int y, LPPOINT pt );
+
+void ShareProtect( bool f );
+DWORD SetWriteProtect( LPVOID addr, bool f );
+bool ChangeMemory( void *dst, const void *src, unsigned size );
+bool LoadVxD();
+void UnloadVxD();
+
+static HMODULE ModuleFromAddress(PVOID pv);
+
+// Prototypes for PSAPI.DLL //
+typedef BOOL (WINAPI *FNEnumProcessModules)( HANDLE hProcess, HMODULE *lphModule, DWORD cb, LPDWORD lpcbNeeded );
+typedef DWORD (WINAPI *FNGetModuleFileNameExA)( HANDLE hProcess, HMODULE hModule, LPSTR lpFilename, DWORD nSize );
+typedef HANDLE (WINAPI *FNCreateToolhelp32Snapshot)( DWORD dwFlags, DWORD th32ProcessID );
+typedef BOOL (WINAPI *FNModule32First)( HANDLE hSnapshot, LPMODULEENTRY32 lpme );
+typedef BOOL (WINAPI *FNModule32Next)( HANDLE hSnapshot, LPMODULEENTRY32 lpme );
+
+
+LRESULT CALLBACK MouseProc( int code, WPARAM wParam, LPARAM lParam );
+LRESULT CALLBACK KeyboardProc( int code, WPARAM wParam, LPARAM lParam );
+bool CaptureText( HWND hwnd, bool movesend );
+bool DoCapture(HWND hwnd, POINT pt, bool movesend, bool image_only=false, bool runOnLaunchedProc=false, bool nonBlock=false);
+void DokoPopMenu( HWND hwnd );
+void ToggleClick( HWND hwnd );
+int CALLBACK EnumMetaFileProc( HDC hdc, HANDLETABLE *, CONST ENHMETARECORD *mfr, int nobj, LPARAM user );
+
+//__declspec(dllexport)
+BOOL  WINAPI _ExtTextOutA(HDC hdc, int x, int y, UINT option, CONST RECT *rc, LPCSTR str, UINT count, CONST INT *dx );
+
+#if METAEXTTEXTOUT
+void ExtTextOutHit();
+#endif
+
+void DoScale(HDC hdc, POINT *pts, int num);
+
+// Prototypes for High DPI //
+typedef enum _PROCESS_DPI_AWARENESS { 
+  Process_DPI_Unaware            = 0,
+  Process_System_DPI_Aware       = 1,
+  Process_Per_Monitor_DPI_Aware  = 2
+} PROCESS_DPI_AWARENESS;
+
+typedef HRESULT (WINAPI *FNGetProcessDPIAwareness)(HANDLE hprocess, PROCESS_DPI_AWARENESS *value);
+typedef HRESULT (WINAPI *FNSetProcessDPIAwareness)(PROCESS_DPI_AWARENESS value);
+
+//==============================================//
+// Shared Section                                                              //
+//==============================================//
+#pragma data_seg(".sdata")
+#pragma bss_seg( ".sbss" )
+HWND hwndCallback = NULL;
+#if USE_VXD
+char VxDpathName[256]; // HK95.vxd path
+#endif
+DWORD siPageSize = 0;
+HWND hwndOrg = NULL;
+HWND hwndAMODI = NULL;
+bool OnlyAMODI = false;
+bool tryAMODI = false;
+bool MoveSend = false;
+#if USE_DBW
+int attach = 0;
+#endif
+#if USE_VXD
+bool WindowsNT;
+#else
+const bool WindowsNT = true;
+#endif
+bool Initialized = false;      // Whether this module initialized or not
+DWORD idDokopopProcess;                // DKPP.EXE process ID
+HHOOK hMouseHook;      // Windows Hook Handle for mouse
+bool ClickOnlyEnabled = false;
+
+struct TKeyConfig {
+       unsigned char Action;
+       int Flag;
+};
+
+TKeyConfig KeyConfig[MAX_KEYS] = {
+       { KA_POPUP, KF_CONTROL },                       // Ctrl+click
+       { KA_POPUP_NC, KF_CLICKONLY },                  // click\82¾\82¯\82Åpopup(DO NOT CHANGE)
+//     { KA_MENU, KF_CONTROL | KF_MENU },      // dokopop menu
+//     { KA_MENU, KF_CONTROL | KF_MENU | KF_CLICKONLY },       // dokopop menu
+       { KA_TOGGLE, KF_CONTROL | KF_MENU },    // dokopop menu
+       { 0, 0 }
+};
+
+bool fWow64 = false;
+
+POINT CursorPoint;     // Client area coordinate //
+POINT ScreenPoint;     // Screen coordinate //
+POINT PrevCursorPoint;
+HWND hwndLast = NULL;
+DWORD PrevMoveTime = 0;
+bool MoveSent = true;
+bool OnlyImage = false;
+
+bool MouseMoving;
+
+RECT rcClient;
+RECT rcInvalid;
+RECT rcOrgInvalid;     // \8dÄ\95`\89æ\91O\82Éinvalid\82¾\82Á\82½\97Ì\88æ
+bool HitFound;
+bool RButtonUpCancel = false;  // \8e\9f\82ÌRButtonUp\82Í\94j\8aü\82·\82é
+bool LButtonUpCancel = false;  // \8e\9f\82ÌLButtonUp\82Í\94j\8aü\82·\82é
+bool MButtonUpCancel = false;  // \8e\9f\82ÌMButtonUp\82Í\94j\8aü\82·\82é
+bool LButtonDown = false;
+bool MButtonDown = false;
+
+HINSTANCE hPSAPI;              // handle of PSAPI.DLL(NT only)
+FNEnumProcessModules fnEnumProcessModules;
+FNGetModuleFileNameExA fnGetModuleFileNameExA;
+FNCreateToolhelp32Snapshot fnCreateToolhelp32Snapshot;
+FNModule32First fnModule32First;
+FNModule32Next fnModule32Next;
+
+#if USE_META || RETRYMETA
+HDC OrgHDC;
+HDC hdcMeta;
+#endif
+HDC hdcExtTextOut;
+#if HOOK_GETDC
+HDC OrgGetDC;
+#endif
+
+int BitBltCount;               // \8c»\8dÝ\82ÌBitBlt\89ñ\90\94
+int ExtTextOutCount;   // \8c»\8dÝ\82ÌBand\93à\82ÌExtTextOut\89ñ\90\94(A/W\82Æ\82à)
+int TargetBitBltCount; // \8c\9f\8d¸\91Î\8fÛ\82ÌBitBlt(\8f\89\89ñ\95`\89æ\8cã\82É\94»\92è) 
+POINT TargetOffset;            // \8c\9f\8d¸\91Î\8fÛ\82ÌBitBlt\82Ì\95`\89æ\83I\83t\83Z\83b\83g(\8f\89\89ñ\95`\89æ\8cã\82É\94»\92è)
+bool RetryPhase;
+
+#if METAEXTTEXTOUT
+// hit text information
+TString<char> *FoundTextA;
+TString<wchar_t> *FoundTextW;
+int FoundLocA;
+int FoundLocW;
+
+// \8dÅ\8cã\82É\95`\89æ\82µ\82½\83e\83L\83X\83g\82Ì\8fî\95ñ
+// for text merge
+int LastX;     // \8dÅ\8cã\82É\95`\89æ\82µ\82½\83e\83L\83X\83g\82Ì\89E\8fã\8dÀ\95W
+int LastY;
+TString<char> *LastTextA;
+TString<wchar_t> *LastTextW;
+#endif // METAEXTTEXTOUT
+
+bool MoveSendMode;
+
+TCHAR AMODIPath[256];
+bool ExtAMODI = false;
+int ScaleX = 0;        // 96\82ð1\82Æ\82µ\82½\89æ\96Ê\82Ì\8ag\91å\97¦
+int ScaleY = 0;
+int generation = 0;
+
+TCHAR ImageTextPath[256+40];   // OCR\97pimage filename or text filename
+DWORD SaveImageTime;
+bool CaptureImageBlocking = false;
+
+const char STR_USER32[] = "user32.dll";
+const char STR_GDI32[] = "gdi32.dll";
+const char STR_KERNEL32[] = "kernel32.dll";
+const TCHAR STR_PSAPI[] = _T("psapi.dll");
+
+// KERNEL32.DLL //
+const char STR_CreateToolhelp32Snapshot[] = "CreateToolhelp32Snapshot";
+const char STR_Module32First[] = "Module32First";
+const char STR_Module32Next[] = "Module32Next";
+
+// PSAPI.DLL //
+const char STR_EnumProcessModules[] = "EnumProcessModules";
+const char STR_GetModuleFileNameExA[] = "GetModuleFileNameExA";
+
+const char STR_BeginPaint[] = "BeginPaint";
+const char STR_EndPaint[] = "EndPaint";
+const char STR_BitBlt[] = "BitBlt";
+const char STR_GetDC[] = "GetDC";
+const char STR_ReleaseDC[] = "ReleaseDC";
+
+const char STR_ExtTextOutA[] = "ExtTextOutA";
+const char STR_ExtTextOutW[] = "ExtTextOutW";
+const char STR_TabbedTextOutA[] = "TabbedTextOutA";
+const char STR_TabbedTextOutW[] = "TabbedTextOutW";
+const char STR_TextOutA[] = "TextOutA";
+const char STR_TextOutW[] = "TextOutW";
+const char STR_DrawTextA[] = "DrawTextA";
+const char STR_DrawTextW[] = "DrawTextW";
+const char STR_DrawTextExA[] = "DrawTextExA";
+const char STR_DrawTextExW[] = "DrawTextExW";
+
+#if USE_SHARE0
+#pragma data_seg()
+#pragma bss_seg()
+#endif
+
+//==============================================//
+// Module depend values                                                        //
+//==============================================//
+HINSTANCE hInstance;   // attached instance
+DWORD idProcess;               // attached process
+HANDLE hProcess;       // Hook\8e\9eGetCurrentProcess()\82Í\8eg\82¦\82È\82¢
+                                       // Hook\8e\9e\82Ìcurrent process\82ª\8f\91\82«\8a·\82¦\82½\82¢thunk\82Ìprocess\82Æ\88ê\92v\82·\82é\82Æ\82Í\8cÀ\82ç\82È\82¢\82½\82ß
+                                       // \82»\82Ì\82½\82ß\81ADLL\82Ìattach\8e\9e\82ÉWriteProcessMemory()\97p\82Éprocess handle\82ð\8eæ\93¾\82·\82é
+DWORD curProcess;      // hooking process
+#if USE_VXD
+HANDLE vxd_Handle = INVALID_HANDLE_VALUE;      // Not shared
+#endif
+
+#if !MOVESEND_POST
+HANDLE SendMoveEvent = NULL;
+DWORD SendMoveThreadId;
+#endif
+
+HINSTANCE hInstSHCore = NULL;
+FNGetProcessDPIAwareness GetProcessDPIAwareness = NULL;
+
+//==============================================//
+// APIHOOK                                                                             //
+//==============================================//
+class APIHOOK {
+public:
+       const char *ModName;
+       const char *FuncName;
+protected:
+       bool ExcludeMe;
+       bool Hooked;
+public:
+       PROC OrgFunc;   // not shared@NT
+protected:
+       PROC HookFunc;  // not shared
+       // Process dedicated values //
+public:
+       static void *MaxAppAddr;        // Maximum private memory address
+protected:
+       static APIHOOK *LinkTop;        // top of APIHOOK link
+       APIHOOK *LinkNext;                      // next pointer of API HOOK link
+public:
+       APIHOOK( const char *modname, const char *name, void *hookfunc, bool excme = true );
+       ~APIHOOK();
+       bool GetProcOrgFunc( HINSTANCE hInst );
+       bool GetProcOrgFunc();
+       bool HookAgain();
+       void Finish();
+protected:
+       bool StoreCode( );
+       void RestoreCode( );
+protected:
+       static void ReplaceIATEntryInAllMods( APIHOOK *obj, PROC pfnCurrent, PROC pfnNew );
+       static bool ReplaceIATEntryInOneMod( APIHOOK *obj, PROC pfnCurrent, PROC pfnNew, HMODULE hmodCaller);
+};
+
+const BYTE cPushOpCode = 0x68;   // The PUSH opcode on x86 platforms
+APIHOOK* APIHOOK::LinkTop = NULL;
+PVOID APIHOOK::MaxAppAddr = NULL;
+
+APIHOOK::APIHOOK( const char *modname, const char *funcname, void *hookfunc, bool excme )
+{
+//     DBW("APIHOOK constructor:%08X %s %s",this, modname, funcname);
+       Hooked = false;
+       ModName = modname;
+       FuncName = funcname;
+       HookFunc = (PROC)hookfunc;
+       ExcludeMe = excme;
+       LinkNext  = LinkTop;
+       LinkTop = this;
+       if (!MaxAppAddr){
+               // Functions with address above lpMaximumApplicationAddress require
+               // special processing (Windows 98 only)
+               SYSTEM_INFO si;
+               GetSystemInfo(&si);
+               MaxAppAddr = si.lpMaximumApplicationAddress;
+       }
+}
+
+APIHOOK::~APIHOOK()
+{
+       Finish();
+       // Remove this object from the linked list
+       APIHOOK* p = LinkTop;
+       if (p == this) {     // Removing the head node
+               LinkTop = p->LinkNext;
+       } else {
+               // Walk list from head and fix pointers
+               for (; p->LinkNext; p = p->LinkNext){
+                       if (p->LinkNext == this) {
+                               // Make the node that points to us point to the our next node
+                               p->LinkNext = p->LinkNext->LinkNext;
+                               break;
+                       }
+               }
+       }
+}
+bool APIHOOK::GetProcOrgFunc()
+{
+       return GetProcOrgFunc( GetModuleHandleA( ModName ) );
+}
+bool APIHOOK::GetProcOrgFunc( HINSTANCE hInst )
+{
+       if (Hooked) return true;
+
+       // Save information about this hooked function
+       OrgFunc = ::GetProcAddress( hInst, FuncName);
+       if (!OrgFunc){
+               DBW("Function doesn't exist =%s:%s", ModName, FuncName);
+               return false;
+       }
+
+       if (OrgFunc > MaxAppAddr) {
+//             DBW("The address is in a shared DLL; the address needs fixing up");
+               PBYTE pb = (PBYTE)OrgFunc;
+               if (pb[0] == cPushOpCode){
+                       // Skip over the PUSH op code and grab the real address
+                       PVOID pv = * (PVOID*) &pb[1];
+                       OrgFunc = (PROC) pv;
+               }
+       }
+
+       // Set assembler code for hooking at the org entry
+       if ( !StoreCode() ){
+               DBW("Cannot write process memory");
+               return false;
+       }
+
+       Hooked = true;
+       return true;
+}
+bool APIHOOK::StoreCode( )
+{
+       DBW("StoreCode:%s %s", ModName, FuncName);
+       // Hook this function in all currently loaded modules
+       ReplaceIATEntryInAllMods( this, OrgFunc, HookFunc );
+       return true;
+}
+void APIHOOK::RestoreCode()
+{
+       DBW("RestoreCode:%s %s", ModName, FuncName);
+       ReplaceIATEntryInAllMods( this, HookFunc, OrgFunc );
+}
+void APIHOOK::ReplaceIATEntryInAllMods( APIHOOK *obj, PROC pfnCurrent, PROC pfnNew )
+{
+       HMODULE hmodThisMod = obj->ExcludeMe
+               ? ModuleFromAddress(ReplaceIATEntryInAllMods) : NULL;
+
+       DWORD cbNeeded;
+       HMODULE hMods[1024];
+       unsigned i;
+       if (fnCreateToolhelp32Snapshot){
+               // Toolhelp\82ª\8eg\97p\82Å\82«\82é\8fê\8d\87\82Í\8eg\97p\82·\82é
+               // Get the list of modules in this process
+               HANDLE hSnapshot = fnCreateToolhelp32Snapshot(TH32CS_SNAPMODULE, idProcess);
+
+               MODULEENTRY32 me = { sizeof(me) };
+               for (BOOL fOk = fnModule32First(hSnapshot,&me); fOk; fOk = fnModule32Next(hSnapshot,&me)){
+                       // NOTE: We don't hook functions in our own module
+                       if (me.hModule != hmodThisMod){
+       //                      DBW("Module : %s %s", me.szModule,FuncName);
+                               // Hook this function in this module
+                               ReplaceIATEntryInOneMod( obj, pfnCurrent, pfnNew, me.hModule);
+                       }
+               }
+               CloseHandle( hSnapshot );
+       } else {
+               if( fnEnumProcessModules(hProcess, hMods, sizeof(hMods), &cbNeeded))
+               {
+                       for ( i = 0; i < (cbNeeded / sizeof(HMODULE)); i++ )
+                       {
+                               if (hMods[i] != hmodThisMod){
+                                       char szModName[MAX_PATH];
+                                       // Get the full path to the module's file.
+                                       if ( fnGetModuleFileNameExA( hProcess, hMods[i], szModName,
+                                                                               sizeof(szModName))){
+       //                                      DBW("Module : %s %s", szModName, FuncName );
+                                               ReplaceIATEntryInOneMod( obj, pfnCurrent, pfnNew, hMods[i]);
+                                       }
+                               }
+                       }
+               }
+#if USE_DBW
+               else DBW("EnumProcessModules failed");
+#endif
+       }
+}
+
+// This functions is almost taken from Jeffrey Richter's sample, thank you.
+bool APIHOOK::ReplaceIATEntryInOneMod( APIHOOK *obj, PROC pfnCurrent, PROC pfnNew, HMODULE hmodCaller)
+{
+       if (!hProcess) return false;
+
+       // Get the address of the module's import section
+       ULONG ulSize;
+       PIMAGE_IMPORT_DESCRIPTOR pImportDesc = (PIMAGE_IMPORT_DESCRIPTOR)
+               ImageDirectoryEntryToData(hmodCaller, TRUE,
+                       IMAGE_DIRECTORY_ENTRY_IMPORT, &ulSize);
+
+       if (!pImportDesc){
+//             DBW("No import section : %s", obj->ModName);
+               return false;
+       }
+
+       // Find the import descriptor containing references to callee's functions
+       for (; pImportDesc->Name; pImportDesc++){
+               PSTR pszModName = (PSTR) ((PBYTE) hmodCaller + pImportDesc->Name);
+               if (lstrcmpiA(pszModName, obj->ModName) == 0) 
+                       break;   // Found
+       }
+
+       if (pImportDesc->Name == 0){
+//             DBW("This module doesn't import any functions from this callee");
+               return false;  // This module doesn't import any functions from this callee
+       }
+
+   // Get caller's import address table (IAT) for the callee's functions
+       PIMAGE_THUNK_DATA pThunk = (PIMAGE_THUNK_DATA) 
+               ((PBYTE) hmodCaller + pImportDesc->FirstThunk);
+
+       // Replace current function address with new function address
+       for (; pThunk->u1.Function; pThunk++){
+               // Get the address of the function address
+               PROC* ppfn = (PROC*) &pThunk->u1.Function;
+               // Is this the function we're looking for?
+               BOOL fFound = (*ppfn == pfnCurrent);
+               if (!fFound && (*ppfn > MaxAppAddr)){
+                       // If this is not the function and the address is in a shared DLL, 
+                       // then maybe we're running under a debugger on Windows 98. In this 
+                       // case, this address points to an instruction that may have the 
+                       // correct address.
+                       PBYTE pbInFunc = (PBYTE) *ppfn;
+                       if (pbInFunc[0] == cPushOpCode){
+                               // We see the PUSH instruction, the real function address follows
+                               ppfn = (PROC*) &pbInFunc[1];
+
+                               // Is this the function we're looking for?
+                               fFound = (*ppfn == pfnCurrent);
+                       }
+               }
+
+               if (fFound){
+                       // The addresses match, change the import section address
+                       if (!WriteProcessMemory(hProcess, ppfn, &pfnNew, sizeof(pfnNew), NULL)){
+                               if (SetWriteProtect( (LPVOID)ppfn, false )==~0){        // write protection release
+                                       DBW("SetWriteProtect failed: %08X %s %s", ppfn, obj->ModName, obj->FuncName);
+                                       return false;
+                               }
+#if USE_VXD
+                               if (!WindowsNT && IsBadWritePtr(ppfn,sizeof(pfnNew))){
+                                       // Windows9x shared DLL section
+                                       // change memory attribte using VxD
+                                       if (!ChangeMemory( ppfn, &pfnNew, sizeof(pfnNew) )){
+                                               DBW("ChangeMemory failed");
+                                       }
+                               } else
+#endif
+                               {
+                                       if (!WriteProcessMemory(hProcess, ppfn, &pfnNew, sizeof(pfnNew), NULL)){
+                                               //SetWriteProtect( ppfn, true );        // restore protection
+                                               DBW("%08X %08X %08X %08X %s %s", hProcess, ppfn, &pfnNew, sizeof(pfnNew), obj->ModName, obj->FuncName );
+                                               DBW("WriteProcessMemory failed : %d",GetLastError());
+                                               return false;
+                                       }
+                               }
+                       }
+                       return true;  // We did it, get out
+               }
+       }
+
+       //DBW("Not found");
+
+       // If we get to here, the function is not in the caller's import section
+       return false;
+}
+bool APIHOOK::HookAgain()
+{
+       if ( Hooked ) return true;
+
+       // Set assembler code for hooking at the org entry
+       if ( !StoreCode() ){
+               DBW("Cannot write process memory@rehook");
+               return false;
+       }
+
+       Hooked = true;
+       return true;
+}
+void APIHOOK::Finish()
+{
+       if ( !Hooked ) return;
+       RestoreCode();
+       Hooked = false;
+}
+// Returns the HMODULE that contains the specified memory address
+static HMODULE ModuleFromAddress(PVOID pv)
+{
+       MEMORY_BASIC_INFORMATION mbi;
+       return((VirtualQuery(pv, &mbi, sizeof(mbi)) != 0) 
+               ? (HMODULE) mbi.AllocationBase : NULL);
+}
+
+#if HOOK_PAINT || RETRYMETA
+APIHOOK BeginPaintHook( STR_USER32, STR_BeginPaint, _BeginPaint );
+APIHOOK EndPaintHook( STR_USER32, STR_EndPaint, _EndPaint );
+#endif
+
+#if HOOK_BITBLT
+APIHOOK BitBltHook( STR_GDI32, STR_BitBlt, _BitBlt );
+#endif
+
+#if HOOK_GETDC
+APIHOOK GetDCHook( STR_USER32, STR_GetDC, _GetDC );
+APIHOOK ReleaseDCHook( STR_USER32, STR_ReleaseDC, _ReleaseDC );
+#endif
+
+#if METAEXTTEXTOUT
+APIHOOK ExtTextOutAHook( STR_GDI32, STR_ExtTextOutA, _ExtTextOutA );
+APIHOOK ExtTextOutWHook( STR_GDI32, STR_ExtTextOutW, _ExtTextOutW );
+#if HOOK_TEXT
+APIHOOK TabbedTextOutAHook( STR_USER32, STR_TabbedTextOutA, _TabbedTextOutA );
+APIHOOK TabbedTextOutWHook( STR_USER32, STR_TabbedTextOutW, _TabbedTextOutW );
+APIHOOK TextOutAHook( STR_GDI32, STR_TextOutA, _TextOutA );
+APIHOOK TextOutWHook( STR_GDI32, STR_TextOutW, _TextOutW );
+APIHOOK DrawTextAHook( STR_USER32, STR_DrawTextA, _DrawTextA );
+APIHOOK DrawTextWHook( STR_USER32, STR_DrawTextW, _DrawTextW );
+APIHOOK DrawTextExAHook( STR_USER32, STR_DrawTextExA, _DrawTextExA );
+APIHOOK DrawTextExWHook( STR_USER32, STR_DrawTextExW, _DrawTextExW );
+#endif
+#endif // METAEXTTEXTOUT
+
+__declspec(dllexport)
+bool WINAPI Init( HWND _hwnd, const char * /*module_name*/, bool windowsnt, const char *vxd_path )
+{
+       DBW("Init:%08X %d", _hwnd, windowsnt);
+       hwndCallback = _hwnd;
+       if ( Initialized ){
+               return true;
+       }
+#if USE_VXD
+       WindowsNT = windowsnt;
+       if (vxd_path){
+//             DBW("vxd_path=%s",vxd_path);
+               lstrcpy( VxDpathName, "\\\\.\\" );
+               lstrcat( VxDpathName, vxd_path );
+               if (!LoadVxD()){
+                       DBW("Cannot open VxD:%s:%d", VxDpathName,GetLastError() );
+                       return false;
+               }
+       }
+#endif
+
+//     HINSTANCE hDll = GetModuleHandle( module_name );
+       hMouseHook = SetWindowsHookEx( WH_MOUSE, (HOOKPROC)MouseProc, hInstance, NULL );
+       if (!hMouseHook){
+               DBW("SetWindowsHookEx error: %d", GetLastError());
+               return false;
+       }
+
+//     hKeyHook = SetWindowsHookEx( WH_KEYBOARD, (HOOKPROC)KeyboardProc, hDll, NULL );
+
+       Initialized = true;
+
+#if GUARD
+       PROTECT_SHARE();
+       DBW("%08X(%08X) Protected", (((INT_PTR)&ExtTextOutAHook) / siPageSize) * siPageSize,&ExtTextOutAHook);
+#endif
+
+       idDokopopProcess = GetCurrentProcessId();
+
+       // get AMODI infomation.
+       if (!tryAMODI){
+               tryAMODI = true;
+               hwndAMODI = FindAMODI();
+#if 0
+               if (hwndAMODI){
+                       DWORD procId;
+                       if (GetWindowThreadProcessId(hwnd, &procId)){
+                               HANDLE hProc = OpenProcess(PROCESS_QUERY_INFORMATION|PROCESS_VM_READ, FALSE, procId);
+                               if (hProc){
+                                       memset(AMODIPath, 0, sizeof(AMODIPath));
+                                       if (GetModuleFileNameEx(hProc, NULL, AMODIPath, sizeof(AMODIPath))>0){
+                                               // OK
+                                       }
+                                       CloseHandle(hProc);
+                               }
+                       }
+               }
+#endif
+       }
+
+       return true;
+}
+
+__declspec(dllexport)
+void WINAPI Uninit()
+{
+       UNPROTECT_SHARE();
+       if ( !Initialized ) return;
+
+       DBW("Uninit");
+       UnhookWindowsHookEx( hMouseHook );
+
+//     UnhookWindowsHookEx( hKeyHook );
+
+#if USE_VXD
+       UnloadVxD();
+#endif
+
+       Initialized = false;
+}
+__declspec(dllexport)
+int WINAPI Config( int clickonly, int keyaction, int keyflag )
+{
+       DBW("Config:%d %d %d", clickonly, keyaction, keyflag);
+       if (clickonly!=-1)
+               ClickOnlyEnabled = int_bool(clickonly);
+       if ( keyflag != 0 ){
+               for ( int i=0;KeyConfig[i].Action;i++ ){
+                       if (KeyConfig[i].Action == keyaction){
+                               KeyConfig[i].Flag = keyflag;
+                               break;
+                       }
+               }
+       }
+       return 0;
+}
+__declspec(dllexport)
+int WINAPI Config2( const struct TDCHConfig *cfg )
+{
+       DBW("Config2: %d %d", cfg->ScaleX, cfg->ScaleY);
+
+       MoveSend = cfg->MoveSend ? true : false;
+       MoveSent = false;
+       OnlyImage = cfg->OnlyImage;
+       ScaleX = cfg->ScaleX;
+       ScaleY = cfg->ScaleY;
+
+       if (cfg->UseAMODI){
+               if (!ExtAMODI){
+                       if (!hwndAMODI)
+                               hwndAMODI = FindAMODI();
+               }
+       } else {
+               hwndAMODI = NULL;
+               ExtAMODI = false;
+               return 0;
+       }
+
+       OnlyAMODI = int_bool(cfg->OnlyAMODI);
+       AMODIPath[0] = '\0';
+       ExtAMODI = false;
+       if (cfg->AMODIPath[0]){
+               size_t len = strlen(cfg->AMODIPath);
+               if (len<sizeof(AMODIPath)-2){
+                       memcpy(AMODIPath, cfg->AMODIPath, len);
+                       if (AMODIPath[len-1]!='\\'){
+                               AMODIPath[len] = '\\';
+                               len++;
+                       }
+                       AMODIPath[len] = '\0';
+                       ExtAMODI = true;
+               }
+       }
+       dbw("Config2[%d]: %d %d %s", ++generation, cfg->ScaleX, cfg->ScaleY, AMODIPath);
+       return 0;
+}
+//Note:
+//     non_block = true\82Ì\8fê\8d\87
+//             \81Ewait\8fó\91Ô\82É\82 \82é\82©\82Ç\82¤\82©\82Í\81AWaitForCaptureResult( false, 0 ) < 0 \82Å\82í\82©\82é\81B
+//             \81E\95K\82¸\8dÅ\8cã\82É\82ÍWaitForCaptureResult(1,...)\82ð\8cÄ\82Ñ\8fo\82·\82±\82Æ\81B
+__declspec(dllexport)
+int WINAPI Capture( HWND hwnd, POINT *ppt, bool movesend, bool non_block )
+{
+       DBW("Capture:%08X %d,%d %d %d", hwnd, ppt ? ppt->x : 0, ppt ? ppt->y : 0, movesend, non_block);
+       if (!hwnd)
+               hwnd = hwndLast;
+       POINT pt;
+       if (ppt)
+               pt = *ppt;
+       else
+               pt = PrevCursorPoint;
+       const bool image_only = true;
+       const bool runOnLaunchedProc = false;
+       return int_bool(DoCapture(hwnd, pt, movesend, image_only, runOnLaunchedProc, non_block));
+}
+//Note:
+// waittime\82ÍCapture()\8aJ\8en\82µ\82Ä\82©\82ç\82Ì\8co\89ß\8e\9e\8aÔ
+// polling\82·\82é\8fê\8d\87\82Íwaittime\82ð\8f­\82µ\82¸\82Â\91\9d\82â\82·\95K\97v\82 \82è(\82»\82Ì\8fê\8d\87\82Ísend_text=0)
+// CaptureImage\82ð\8ds\82Á\82½\8fê\8d\87\82Í\81A\81u\95K\82¸\81vWaitForCaptureResult( 1, ... )\82ð\8cÄ\82Ñ\8fo\82·\95K\97v\82ª\82 \82é\81B
+// \82»\82¤\82µ\82È\82¢\82Æ\81ACaptureImageBlocking\82ª true \82É\82È\82Á\82½\82Ü\82Ü\81B
+//
+// return:
+//     0 : wait\92\86\82Ì\82à\82Ì\82Í\82È\82µ
+//     1 : OK(text ready)
+//     -1: timeout
+__declspec(dllexport)
+int WINAPI WaitForCaptureResult( bool send_text, unsigned waittime )
+{
+       DBW("WaitForCaptureResult: %d %d %d", send_text, waittime, CaptureImageBlocking);
+       if (!CaptureImageBlocking) return 0;
+
+       if (send_text){
+               if (WaitAndGetResult(ImageTextPath, waittime)){
+                       return 1;
+               }
+       } else {
+               HANDLE hf = WaitForResult(ImageTextPath, waittime);
+               if (hf){
+                       CloseHandle(hf);
+                       return 1;
+               }
+       }
+       return -1;
+}
+#if GUARD
+void ShareProtect( bool f )
+{
+       LPVOID BaseAddress = (LPVOID)((((INT_PTR)&ExtTextOutAHook) / siPageSize) * siPageSize);
+
+       DWORD OldProtect;
+       if ( !VirtualProtect( BaseAddress, siPageSize, f ? PAGE_READONLY : PAGE_READWRITE, &OldProtect ) ){
+               DBW("Cannot change protect:%08X@rehook",BaseAddress);
+       }
+}
+#endif
+DWORD SetWriteProtect( LPVOID addr, bool f )
+{
+       LPVOID BaseAddress = (LPVOID)((((INT_PTR)addr) / siPageSize) * siPageSize);
+
+       DWORD OldProtect;
+       if ( !VirtualProtect( BaseAddress, siPageSize, f ? PAGE_READONLY : PAGE_READWRITE, &OldProtect ) ){
+               DBW("Cannot change protect:%08X-%08X@rehook %d", (INT_PTR)BaseAddress>>32, BaseAddress, GetLastError());
+               return ~0;
+       }
+       return OldProtect;
+}
+#if USE_VXD
+// change write protected memory for Windows9x
+bool ChangeMemory( void *dst, const void *src, unsigned size )
+{
+       DWORD DIOC_count;
+       if ( vxd_Handle == INVALID_HANDLE_VALUE ){
+               if (!LoadVxD())
+                       return false;
+       }
+
+       bool r = int_bool(DeviceIoControl( vxd_Handle, DIOC_CHANGE_MEMORY, (void*)src, size, dst, 0, &DIOC_count, NULL));
+#if USE_DBW
+       if ( !r ){
+               DBW("DeviceIoControl failed");
+       }
+#endif
+       return r;
+}
+bool LoadVxD()
+{
+       if (vxd_Handle!=INVALID_HANDLE_VALUE){
+               DBW("Already loaded VxD");
+               return true;
+       }
+       vxd_Handle=CreateFile(&VxDpathName[0],0,0,NULL,0,FILE_FLAG_DELETE_ON_CLOSE,NULL);
+       return vxd_Handle != INVALID_HANDLE_VALUE;
+}
+void UnloadVxD()
+{
+       if (vxd_Handle == INVALID_HANDLE_VALUE)
+               return;
+       CloseHandle(vxd_Handle);
+       vxd_Handle = INVALID_HANDLE_VALUE;
+}
+#endif
+int GetKeyFlag( )
+{
+       int r = 0;
+       if ( GetKeyState( VK_SHIFT ) & 0x8000 ) r |= KF_SHIFT;
+       if ( GetKeyState( VK_CONTROL ) & 0x8000 ) r |= KF_CONTROL;
+       if ( GetKeyState( VK_MENU ) & 0x8000 ) r |= KF_MENU;
+       if ( GetKeyState( VK_LWIN ) & 0x8000 ) r |= KF_LWIN;
+       if ( GetKeyState( VK_RWIN ) & 0x8000 ) r |= KF_RWIN;
+       if ( ClickOnlyEnabled && r == 0 ) r = KF_CLICKONLY;
+//     if ( GetKeyState( VK_APPS ) & 0x8000 ) r |= KF_APPS;
+       return r;
+}
+LRESULT CALLBACK MouseProc( int code, WPARAM wParam, LPARAM lParam )
+{
+       if ( code < 0 || code != HC_ACTION )
+               return CallNextHookEx( hMouseHook, code, wParam, lParam );
+
+       MOUSEHOOKSTRUCT *mhs;
+       HWND hwnd;
+       int kf;
+       int i;
+
+#if 0
+       if (wParam!=0x200 && wParam!=0xA0)
+               dbw("WParam:%08X", wParam);
+#endif
+
+       curProcess = GetCurrentProcessId();
+       bool runOnLaunchedProc = false;
+
+       switch ( wParam ){
+               case WM_LBUTTONDOWN:
+               // case WM_NCLBUTTONDOWN:
+                       LButtonDown = true;
+                       LButtonUpCancel = false;
+//                     if (LButtonUpCancel)
+//                             goto j_end;
+                       kf = KF_LEFTCLICK;
+                       goto j_rbuttondown;
+               case WM_MBUTTONDOWN:
+               // case WM_NCMBUTTONDOWN:
+                       MButtonDown = true;
+                       MButtonUpCancel = false;
+//                     if (MButtonUpCancel)
+//                             goto j_end;
+                       kf = KF_MIDCLICK;
+                       goto j_rbuttondown;
+               case WM_RBUTTONDOWN:
+               //  case WM_NCRBUTTONDOWN:
+                       DBW("RButtonDown");
+                       RButtonUpCancel = false;
+//                     if (RButtonUpCancel)
+//                             goto j_end;
+                       kf = 0;
+                       if (LButtonDown){
+                               kf = KF_LRCLICK;
+                       }
+       j_rbuttondown:;
+                       mhs = (MOUSEHOOKSTRUCT*)lParam;
+                       hwnd = WindowFromPoint( mhs->pt );
+                       //hwnd = mhs->hwnd;
+#if 0
+                       HWND h = GetParent( hwnd );
+                       if ( h )
+                               hwnd = h;
+#endif
+                       kf |= GetKeyFlag();
+
+#if 0
+                       dbw("kf=%02X", kf);
+#endif
+
+                       if (curProcess == idDokopopProcess){
+                               // runs on launched process -> ignored.
+                               DBW("Runs on launched proc(%d)", curProcess);
+                               runOnLaunchedProc = true;
+                       }
+
+                       for ( i=0;KeyConfig[i].Action;i++ ){
+                               //DBW("%d:%d %x", i, KeyConfig[i].Action, KeyConfig[i].Flag);
+                               if ( kf == KeyConfig[i].Flag ){
+                                       switch ( KeyConfig[i].Action ){
+                                               case KA_POPUP:
+                                               case KA_POPUP_NC:
+                                                       {
+                                                       const bool move_send = false;
+                                                       if (DoCapture(hwnd, mhs->pt, move_send, OnlyImage, runOnLaunchedProc)){
+j_discard:
+                                                               if (wParam == WM_LBUTTONDOWN)
+                                                                       LButtonUpCancel = true;
+                                                               if (wParam == WM_MBUTTONDOWN)
+                                                                       MButtonUpCancel = true;
+                                                               else
+                                                                       RButtonUpCancel = true;
+                                                               return 1;       // discard this message
+                                                       }
+                                                       }
+                                                       break;
+                                               case KA_MENU:
+                                                       DokoPopMenu( hwnd );
+                                                       goto j_discard;
+                                               case KA_TOGGLE:
+                                                       DBW("KA_TOGGLE");
+                                                       ToggleClick( hwnd );
+                                                       goto j_discard;
+                                       }
+                               }
+                       }
+                       break;
+               case WM_RBUTTONUP:
+                       DBW("WM_RBUTTONUP:%d",RButtonUpCancel);
+                       if ( RButtonUpCancel ){
+                               RButtonUpCancel = false;
+                               return 1;       // no longer process the message
+                       }
+                       break;
+               case WM_LBUTTONUP:
+                       LButtonDown = false;
+                       if ( LButtonUpCancel ){
+                               LButtonUpCancel = false;
+                               return 1;       // no longer process the message
+                       }
+                       break;
+               case WM_MBUTTONUP:
+                       MButtonDown = false;
+                       if ( MButtonUpCancel ){
+                               MButtonUpCancel = false;
+                               return 1;       // no longer process the message
+                       }
+                       break;
+               case WM_MOUSEMOVE:
+                       if (MoveSend){
+                               mhs = (MOUSEHOOKSTRUCT*)lParam;
+                               hwnd = WindowFromPoint( mhs->pt );
+                               if (PrevCursorPoint.x!=mhs->pt.x || PrevCursorPoint.y!=mhs->pt.y){
+                                       PrevMoveTime = GetTickCount();
+                                       MoveSent = false;
+                                       PrevCursorPoint = mhs->pt;
+                                       hwndLast = hwnd;
+                                       //DBW("Moving:%d %d", mhs->pt.x, mhs->pt.y);
+                                       SendMoveMessage();
+#if 0
+                                       //TODO: 5pixel\96¢\96\9e\82Å\82 \82ê\82ÎDoCapture\82·\82é
+#endif
+                               } else {
+                                       if (!MoveSent){
+#if 0  // 2014.11.18 inc.srch\82Å\97\8e\82¿\82é\82Ì\82Å\82Æ\82è\82 \82¦\82¸comment out
+                                               const int MOVE_SEND_INTERVAL = 50;      // msec
+                                               if (GetTickCount()-PrevMoveTime > MOVE_SEND_INTERVAL){
+                                                       MoveSent = true;
+                                                       if (DoCapture(hwndLast, PrevCursorPoint, true)){
+                                                               // stop the capture from the main.
+                                                               SendCancelMove();
+                                                       }
+                                               }
+#endif
+                                       }
+                               }
+                       }
+                       break;
+       }
+
+//j_end:;
+       return CallNextHookEx( hMouseHook, code, wParam, lParam );
+}
+
+bool DoCapture(HWND hwnd, POINT pt, bool movesend, bool image_only, bool runOnLaunchedProc, bool non_block)
+{
+       CursorPoint = ScreenPoint = pt;
+       ScreenToClient( hwnd, &CursorPoint );
+
+       if (!image_only && !runOnLaunchedProc){
+               //DBW("hwnd:%08X %d %d", (int)hwnd, CursorPoint.x, CursorPoint.y);
+               if ((!hwndAMODI && !ExtAMODI) || !OnlyAMODI){
+                       // Redraw Metafile //
+                       UNPROTECT_SHARE();
+                       DBW("Target : %08X %d", hwnd, curProcess);
+                       bool r = CaptureText( hwnd, movesend );
+                       PROTECT_SHARE();
+                       if (r){
+                               return true;    // discard this message
+                       }
+               }
+       }
+       if (image_only || hwndAMODI || ExtAMODI){
+               if (CaptureImage(hwnd, movesend, non_block))
+                       return true;
+       }
+       return false;
+}
+
+void CallbackMain(int msg, const void *data, int len, HWND wparam=0)
+{
+       COPYDATASTRUCT cds;
+       cds.dwData = msg;
+       cds.cbData = len;
+       cds.lpData = (LPSTR)data;
+       SendMessage( hwndCallback, WM_COPYDATA, (WPARAM)wparam, (LPARAM)&cds );
+}
+
+void DokoPopMenu( HWND hwnd )
+{
+       CallbackMain(DCH_MENU, NULL, 0, hwnd);
+}
+void ToggleClick( HWND hwnd )
+{
+       CallbackMain(DCH_TOGGLE, NULL, 0, hwnd);
+}
+#if 0
+LRESULT CALLBACK KeyboardProc( int code, WPARAM wParam, LPARAM lParam )
+{
+       if ( code < 0 || code != HC_ACTION )
+               return CallNextHookEx( hKeyHook, code, wParam, lParam );
+
+       if ( wParam == VK_CONTROL ){
+               if ( lParam & (KF_UP<<16) ){
+                       // control key up
+                       // -> hold on time
+                       goto j1;
+               } else
+               if ( !(lParam & (KF_REPEAT<<16)) ){
+                       // control key down and not repeat
+//                     DBW("wparam=%08X lparam=%08X",wParam,lParam);
+                       long nowt = GetTickCount();
+                       if ( nowt - LastTypeTime < GetDoubleClickTime() ){
+//                             DBW("On/off!");
+                               ClickOnlyEnabled = !ClickOnlyEnabled;
+                               MessageBeep( MB_OK );
+                               // -> cancel time
+                       } else {
+                               // -> hold on time
+                               LastTypeTime = nowt;
+                               goto j1;
+                       }
+               } else {
+                       // control key down and repeat
+                       // -> cancel time
+               }
+       }
+       LastTypeTime -= 10000;
+j1:;
+       return CallNextHookEx( hMouseHook, code, wParam, lParam );
+}
+#endif
+
+//__declspec(dllexport)
+#if HOOK_PAINT || RETRYMETA
+HDC WINAPI _BeginPaint( HWND hwnd, LPPAINTSTRUCT ps )
+{
+//     DBW("BeginPaint");
+       HDC hdc = ((FNBeginPaint)BeginPaintHook.OrgFunc)( hwnd, ps );
+       OrgHDC = hdc;
+       ps->hdc = hdcMeta;
+#if 1
+       ps->rcPaint.left = 0;
+       ps->rcPaint.top = 0;
+       ps->rcPaint.right = rcInvalid.right;
+       ps->rcPaint.bottom = rcInvalid.bottom;
+#endif
+       return hdcMeta;
+}
+//__declspec(dllexport)
+BOOL WINAPI _EndPaint( HWND hwnd, CONST PAINTSTRUCT *ps )
+{
+       ((PAINTSTRUCT*)ps)->hdc = OrgHDC;
+       return ((FNEndPaint)EndPaintHook.OrgFunc)( hwnd, ps );
+}
+#endif
+#if HOOK_GETDC
+HDC WINAPI _GetDC( HWND hwnd )
+{
+       DBW("GetDC");
+       HDC hdc = ((FNGetDC)GetDCHook.OrgFunc)( hwnd );
+       OrgHDC = hdc;
+       if ( hwnd == hwndOrg ){
+               return hdcMeta;
+       } else {
+               return OrgHDC;
+       }
+}
+int WINAPI _ReleaseDC( HWND hwnd, HDC hdc )
+{
+       DBW("ReleaseDC");
+       if ( hdc == hdcMeta ){
+               hdc = OrgHDC;
+       }
+       int r = ((FNReleaseDC)ReleaseDCHook.OrgFunc)( hwnd, hdc );
+       return r;
+}
+#endif
+
+#if METAEXTTEXTOUT
+//__declspec(dllexport)
+BOOL  WINAPI _ExtTextOutA(HDC hdc, int x, int y, UINT option, CONST RECT *rc, LPCSTR str, UINT count, CONST INT *dx )
+{
+       DBW("_ExtTextOutA");
+       POINT pt;
+       GetCurrentPositionEx(hdc,&pt);
+
+       BOOL r = ((FNExtTextOutA)ExtTextOutAHook.OrgFunc)( hdc, x, y, option, rc, str, count, dx );
+
+       hdcExtTextOut = hdc;
+
+       if ( r
+#if USE_META
+               && hdcMeta != hdc
+#endif
+               && count > 0 ){
+               RECT _rc;
+               if ( rc ){
+                       _rc.right = rc->right;
+                       _rc.bottom = rc->bottom;
+               } else {
+                       _rc.right = rcClient.right;
+                       _rc.bottom = rcClient.bottom;
+               }
+               if ( GetTextAlign( hdc ) & TA_UPDATECP ){
+                       _rc.left = pt.x;
+                       _rc.top = pt.y;
+               } else {
+                       _rc.left = x;
+                       _rc.top = y;
+               }
+               if ( RetryPhase ){
+                       if ( TargetBitBltCount == BitBltCount ){
+                               _rc.right += CursorPoint.x;     //*+++ bug \82±\82¤\82µ\82È\82¢\82Æ\95\9d\82ª\82¹\82Ü\82­\82Ähit\82µ\82È\82¢
+                               OffsetRect( &_rc, TargetOffset.x, TargetOffset.y );
+                       } else {
+                               return r;
+                       }
+               } else {
+                       ExtTextOutCount++;
+               }
+#if ORG_OFFSET /* fixed 2001.1.14 for IE@win2k */
+               POINT vpt;
+               POINT wpt;
+               GetViewportOrgEx( hdc, &vpt );
+               GetWindowOrgEx( hdc, &wpt );
+               OffsetRect( &_rc, vpt.x-wpt.x, vpt.y-wpt.y);
+#else
+#if USE_DBW
+               POINT vpt;
+               POINT wpt;
+               GetViewportOrgEx( hdc, &vpt );
+               GetWindowOrgEx( hdc, &wpt );
+               if (vpt.x != wpt.x || vpt.y != wpt.y)
+                       DBW("!!!Org DIFF=%d %d",vpt.x-wpt.x, vpt.y-wpt.y);
+#endif
+#endif
+
+               // \98A\91±\82µ\82½\83e\83L\83X\83g\82Ì\8fê\8d\87\82Í
+               // \98A\8c\8b\82·\82é
+               if (LastY == _rc.top && LastX == _rc.left ){
+                       // \98A\91±\82µ\82½\83e\83L\83X\83g\95`\89æ\81¨\98A\8c\8b
+                       LastTextA->Cat( str, count );
+               } else {
+                       LastTextA->Set( str, count );
+               }
+               LastX = _rc.left;
+               LastY = _rc.top;
+
+               if ( PtInRect( &_rc, CursorPoint ) )
+               {
+#if DEBUG_HITTEXT
+                       char *buf = new char[ count + 1 ];
+                       CopyMemory( buf, str, count );
+                       buf[count] = '\0';
+                       DBW("CheckA -- %d %d %d %d (%d,%d)", _rc.left, _rc.top, _rc.right, _rc.bottom, CursorPoint.x, CursorPoint.y, count);
+                       DBW("%s", buf);
+                       delete[] buf;
+#endif
+                       int loc = GetTextFromPoint( hdc, str, count, CursorPoint.x - _rc.left, CursorPoint.y - _rc.top, dx );
+                       if ( loc != -1 ){
+                               FoundLocA = loc + LastTextA->GetLength() - count;
+                               FoundTextA->Set( LastTextA );
+#if DEBUG_HITTEXT
+                               DBW("HitA loc=%d Len=%d Text=%ws", FoundLocA, FoundTextA->GetLength(), FoundTextA->c_str());
+#endif
+                       }
+               }
+       }
+
+       return r;
+}
+//__declspec(dllexport)
+BOOL  WINAPI _ExtTextOutW(HDC hdc, int x, int y, UINT option, CONST RECT *rc, LPCWSTR str, UINT count, CONST INT *dx )
+{
+//     DBW("_ExtTextOutW");
+       POINT pt;
+       GetCurrentPositionEx(hdc,&pt);
+
+       BOOL r = ((FNExtTextOutW)ExtTextOutWHook.OrgFunc)( hdc, x, y, option, rc, str, count, dx );
+
+       hdcExtTextOut = hdc;
+
+       if ( r
+#if USE_META
+               && hdcMeta != hdc
+#endif
+               && count > 0 ){
+               RECT _rc;
+               if ( rc ){
+                       _rc.right = rc->right;
+                       _rc.bottom = rc->bottom;
+               } else {
+                       _rc.right = rcClient.right;
+                       _rc.bottom = rcClient.bottom;
+               }
+               if ( GetTextAlign( hdc ) & TA_UPDATECP ){
+                       _rc.left = pt.x;
+                       _rc.top = pt.y;
+               } else {
+                       _rc.left = x;
+                       _rc.top = y;
+               }
+               if ( RetryPhase ){
+                       if ( TargetBitBltCount == BitBltCount ){
+                               _rc.right += CursorPoint.x;     //*+++ bug \82±\82¤\82µ\82È\82¢\82Æ\95\9d\82ª\82¹\82Ü\82­\82Ähit\82µ\82È\82¢
+                               OffsetRect( &_rc, TargetOffset.x, TargetOffset.y );
+                       } else {
+                               return r;
+                       }
+               } else {
+                       ExtTextOutCount++;
+               }
+#if ORG_OFFSET /* fixed 2001.1.14 for IE@win2k */
+               POINT vpt;
+               POINT wpt;
+               GetViewportOrgEx( hdc, &vpt );
+               GetWindowOrgEx( hdc, &wpt );
+               OffsetRect( &_rc, vpt.x-wpt.x, vpt.y-wpt.y);
+#else  // !ORG_OFFSET
+#if USE_DBW
+               POINT vpt;
+               POINT wpt;
+               GetViewportOrgEx( hdc, &vpt );
+               GetWindowOrgEx( hdc, &wpt );
+               if (vpt.x != wpt.x || vpt.y != wpt.y)
+                       DBW("!!!Org DIFF=%d %d",vpt.x-wpt.x, vpt.y-wpt.y);
+#endif // USE_DBW
+#endif // !ORG_OFFSET
+
+               // \98A\91±\82µ\82½\83e\83L\83X\83g\82Ì\8fê\8d\87\82Í\98A\8c\8b\82·\82é
+               if (LastY == _rc.top && LastX == _rc.left ){
+                       // \98A\91±\82µ\82½\83e\83L\83X\83g\95`\89æ\81¨\98A\8c\8b
+                       LastTextW->Cat( str, count );
+               } else {
+                       LastTextW->Set( str, count );
+               }
+               LastX = _rc.left;
+               LastY = _rc.top;
+
+               if ( PtInRect( &_rc, CursorPoint ) )
+               {
+                       DBW("%04X %04X %04X %04X",
+                               str[0],
+                               str[1],
+                               str[2],
+                               str[3]);
+#if DEBUG_HITTEXT
+                       wchar_t *buf = new wchar_t[ count + 1 ];
+                       CopyMemory( buf, str, count*sizeof(wchar_t) );
+                       buf[count] = '\0';
+                       DBW("CheckW -- %d %d %d %d (%d,%d)", _rc.left, _rc.top, _rc.right, _rc.bottom, CursorPoint.x, CursorPoint.y, count);
+                       DBW("%ws", buf);
+                       delete[] buf;
+#endif
+                       int loc = GetTextFromPoint( hdc, str, count, CursorPoint.x - _rc.left, CursorPoint.y - _rc.top, dx );
+                       if ( loc != -1 ){
+                               FoundLocW = loc + LastTextW->GetLength() - count;
+                               FoundTextW->Set( LastTextW );
+#if DEBUG_HITTEXT
+                               DBW("HitW loc=%d Len=%d Text=%ws", FoundLocW, FoundTextW->GetLength(), FoundTextW->c_str());
+#endif
+                       }
+               }
+       }
+
+       return r;
+}
+#endif // !METAEXTTEXTOUT
+
+#if HOOK_BITBLT
+BOOL WINAPI _BitBlt(HDC hdcdest, int xdest, int ydest, int width, int height, HDC hdcsrc, int xsrc, int ysrc, DWORD rop )
+{
+       DBW("BitBlt:%08X %d %d %d %d <- %08X %d %d", hdcdest, xdest, ydest, width, height, hdcsrc, xsrc, ysrc );
+       BOOL r = ((FNBitBlt)BitBltHook.OrgFunc)(hdcdest, xdest, ydest, width, height, hdcsrc, xsrc, ysrc, rop );
+//     DBW("BitBlt:%08X %d %d %d %d <- %08X %d %d", hdcdest, xdest, ydest, width, height, hdcsrc, xsrc, ysrc );
+       if ( r && hdcExtTextOut == hdcsrc ){
+               if ( !RetryPhase ){
+                       // \8d¡\89ñ\82ÌBitBlt\8e\9e\82ÉExtTextOut\82ª\82 \82Á\82½\82©\81H
+                       if ( ExtTextOutCount > 0 ){
+                               // CursorPoint\82ª\8aÜ\82Ü\82ê\82é\82©\81H
+                               DBW("ExtTextOutCount=%d",ExtTextOutCount);
+                               if ( (xdest <= CursorPoint.x)
+                                       && (xdest+width > CursorPoint.x)
+                                       && (ydest <= CursorPoint.y)
+                                       && (ydest+height > CursorPoint.y)
+                               ){
+                                       TargetBitBltCount = BitBltCount;
+                                       TargetOffset.x = xdest - xsrc;
+                                       TargetOffset.y = ydest - ysrc;
+                                       DBW("TargetOffset %d %d (%d,%d %dx%d)<-(%d,%d)",
+                                               TargetOffset.x, TargetOffset.y,xdest,ydest,width,height,xsrc,ysrc);
+#if USE_DBW
+                                       {
+                                       POINT vpt;
+                                       POINT wpt;
+                                       GetViewportOrgEx( hdcdest, &vpt );
+                                       GetWindowOrgEx( hdcdest, &wpt );
+                                       DBW("BitBlt OrgDIFF=%d %d",vpt.x-wpt.x, vpt.y-wpt.y);
+                                       SIZE sz1;
+                                       SIZE sz2;
+                                       GetViewportExtEx( hdcdest, &sz1 );
+                                       GetWindowExtEx( hdcdest, &sz2 );
+                                       DBW("BitBlt Ext %d (%d,%d) (%d,%d)", GetMapMode(hdcdest), sz1.cx, sz1.cy, sz2.cx, sz2.cy );
+#if 1
+                                       XFORM xform;
+                                       GetWorldTransform( hdcdest, &xform );
+                                       {
+                                       char buf[100];
+                                       sprintf(buf,"== [%d] %g %g %g %g %g %g", GetGraphicsMode(hdcdest), xform.eM11, xform.eM12, xform.eM21, xform.eM22, xform.eDx, xform.eDy);
+                                       DBW(buf);
+                                       }
+#endif
+                                       }
+#endif
+                               }
+#if METAEXTTEXTOUT
+                               if ( TargetBitBltCount != -1 ){
+                                       // \82·\82Å\82É\82Ù\82©\82Ìband\82Åhit\82µ\82Ä\82¢\82é\8fê\8d\87\81A
+                                       // Cancel ExtTextOut
+                                       FoundLocA = -1;
+                                       FoundLocW = -1;
+                               }
+#endif
+                       }
+               }
+               BitBltCount++;
+               DBW("BitBltCount=%d",BitBltCount);
+               ExtTextOutCount = 0;
+               return r;
+       } else {
+//             DBW("Unknown destination BitBlt %08X(%d,%d %dx%d)<-%08X(%d,%d)",hdcdest,xdest,ydest,width,height,hdcsrc,xsrc,ysrc);
+       }
+       return r;
+}
+#endif
+
+#if HOOK_TEXT
+#define        HK1( name, ret_type, args ) \
+       ret_type r = ((FN##name)name##Hook.OrgFunc) args; \
+       return r
+LONG WINAPI _TabbedTextOutA( HDC hdc, int x, int y, LPCSTR str, int count, int ntabs, LPINT tabs, int origin )
+{
+       DBW("_TabbedTextOutA");
+       HK1( TabbedTextOutA, LONG, ( hdc, x, y, str, count, ntabs, tabs, origin ) );
+}
+LONG WINAPI _TabbedTextOutW( HDC hdc, int x, int y, LPCWSTR str, int count, int ntabs, LPINT tabs, int origin )
+{
+       DBW("TabbedTextOutW");
+       HK1( TabbedTextOutW, LONG, ( hdc, x, y, str, count, ntabs, tabs, origin ) );
+}
+BOOL WINAPI _TextOutA( HDC hdc, int x, int y, LPCSTR str, int count )
+{
+       DBW("_TextOutA");
+       HK1( TextOutA, BOOL, ( hdc, x, y, str, count ) );
+}
+BOOL WINAPI _TextOutW( HDC hdc, int x, int y, LPCWSTR str, int count )
+{
+       DBW("_TextOutW");
+       HK1( TextOutW, BOOL, ( hdc, x, y, str, count ) );
+}
+int WINAPI _DrawTextA( HDC hdc, LPCSTR str, int count, LPRECT rc, UINT format )
+{
+       DBW("s5");
+       HK1( DrawTextA, int, ( hdc, str, count, rc, format ) );
+}
+int WINAPI _DrawTextW( HDC hdc, LPCWSTR str, int count, LPRECT rc, UINT format )
+{
+       DBW("s6");
+       HK1( DrawTextW, int, ( hdc, str, count, rc, format ) );
+}
+int WINAPI _DrawTextExA( HDC hdc, LPCSTR str, int count, LPRECT rc, UINT format, LPDRAWTEXTPARAMS params )
+{
+       DBW("s7");
+       HK1( DrawTextExA, int, ( hdc, str, count, rc, format, params ) );
+}
+int WINAPI _DrawTextExW( HDC hdc, LPCWSTR str, int count, LPRECT rc, UINT format, LPDRAWTEXTPARAMS params )
+{
+       DBW("s8");
+       HK1( DrawTextExW, int, ( hdc, str, count, rc, format, params ) );
+}
+#endif // HOOK_TEXT
+
+bool CaptureText( HWND hwnd, bool movesend )
+{
+       if ( !hwnd ){
+               return false;
+       }
+
+       MoveSendMode = movesend;
+
+       //DoScale(NULL, &CursorPoint, 1);
+
+#if METAEXTTEXTOUT
+       FoundLocA = -1;
+       FoundLocW = -1;
+       FoundTextA = new TString<char>;
+       FoundTextW = new TString<wchar_t>;
+       LastTextA = new TString<char>;
+       LastTextW = new TString<wchar_t>;
+#endif
+
+#if !USE_REDRAW
+       HRGN hRgn;
+#endif
+
+       GetClientRect( hwnd, &rcClient );
+       GetUpdateRect( hwnd, &rcOrgInvalid, FALSE );
+
+#if USE_OPTIMALINVALID
+       SetRect( &rcInvalid, 0, max(CursorPoint.y - 64,0), rcClient.right, max(CursorPoint.y + 64,0) );
+#else
+       rcInvalid = rcClient;
+#endif
+
+#if !USE_REDRAW
+       hRgn = CreateRectRgn( rcInvalid.left, rcInvalid.top, rcInvalid.right, rcInvalid.bottom );
+
+#if USE_INVALIDATE
+       InvalidateRect( hwnd, &rcInvalid, INVALIDATE_TRUE );
+#endif
+
+       SendMessage( hwnd, WM_PAINT, 0, 0 );
+       SendMessage( hwnd, WM_NCPAINT, (WPARAM)hRgn, 0 );
+#endif
+
+       hwndOrg = hwnd;
+
+#if USE_META
+       HDC hdc;
+#endif
+
+       HINSTANCE hPSAPI = NULL;
+       HMODULE hInst;
+       HMODULE hInstGdi;
+
+       hInst = GetModuleHandleA( STR_KERNEL32 );
+       fnCreateToolhelp32Snapshot = (FNCreateToolhelp32Snapshot)GetProcAddress( hInst, STR_CreateToolhelp32Snapshot );
+       if (fnCreateToolhelp32Snapshot){
+               // Toolhelp\82É\82æ\82émodule enumration\82ª\8eg\97p\89Â\94\
+               fnModule32First = (FNModule32First)GetProcAddress( hInst, STR_Module32First );
+               fnModule32Next = (FNModule32Next)GetProcAddress( hInst, STR_Module32Next );
+       } else {
+               // Toolhelp\82ª\91\8dÝ\82µ\82È\82¢\8fê\8d\87
+               hPSAPI = LoadLibrary( STR_PSAPI );
+               DBW("LoadLibrary : %08X",hPSAPI);
+               if (!hPSAPI){
+                       DBW("Cannot load PSAPI.DLL!!");
+                       return false;
+               }
+               fnEnumProcessModules = (FNEnumProcessModules)GetProcAddress( hPSAPI, STR_EnumProcessModules );
+               fnGetModuleFileNameExA = (FNGetModuleFileNameExA)GetProcAddress( hPSAPI, STR_GetModuleFileNameExA );
+       }
+
+       hInst = GetModuleHandleA( STR_USER32 );
+#if USE_DBW
+       if ( !hInst ){
+               DBW("Cannot load USER32.DLL");
+               return false;
+       }
+#endif
+       hInstGdi = GetModuleHandleA( STR_GDI32 );
+#if USE_DBW
+       if ( !hInstGdi ){
+               DBW("Cannot load GDI32.DLL");
+               goto err9;
+       }
+#endif
+
+#if METAEXTTEXTOUT
+       if ( !ExtTextOutAHook.GetProcOrgFunc( hInstGdi ) ){
+               DBW("Cannot find ExtTextOutA");
+               goto err8;
+       }
+       if ( !ExtTextOutWHook.GetProcOrgFunc( hInstGdi ) ){
+               DBW("Cannot find ExtTextOutW");
+               goto err7;
+       }
+#endif
+
+#if HOOK_BITBLT
+       if ( !BitBltHook.GetProcOrgFunc( hInstGdi ) ){
+               DBW("Cannot find BitBlt");
+               goto err71;
+       }
+#endif
+       RetryPhase = false;
+       TargetBitBltCount = -1;
+       BitBltCount = 0;
+       ExtTextOutCount = 0;
+
+#if HOOK_PAINT
+       if ( !BeginPaintHook.GetProcOrgFunc( hInst ) ){
+               DBW("Cannot hook BeginPaint");
+               goto err73;
+       }
+       if ( !EndPaintHook.GetProcOrgFunc( hInst ) ){
+               DBW("Cannot hook EndPaint");
+               goto err6;
+       }
+#endif
+
+#if HOOK_TEXT
+       TabbedTextOutAHook.GetProcOrgFunc( hInst );
+       TabbedTextOutWHook.GetProcOrgFunc( hInst );
+       TextOutAHook.GetProcOrgFunc( hInstGdi );
+       TextOutWHook.GetProcOrgFunc( hInstGdi );
+       DrawTextAHook.GetProcOrgFunc( hInst );
+       DrawTextWHook.GetProcOrgFunc( hInst );
+       DrawTextExAHook.GetProcOrgFunc( hInst );
+       DrawTextExWHook.GetProcOrgFunc( hInst );
+#endif
+
+#if USE_META
+       hdc = GetDC( hwnd );
+       if ( !hdc ){
+               DBW("Cannot get DC");
+               goto err5;
+       }
+#endif
+
+#if HOOK_GETDC
+       if ( !GetDCHook.GetProcOrgFunc( hInst ) ){
+               DBW("Cannot hook GetDC");
+               goto err4;
+       }
+       if ( !ReleaseDCHook.GetProcOrgFunc( hInst ) ){
+               DBW("Cannot hook ReleaseDC");
+               goto err3;
+       }
+#endif
+
+       {
+       DBW("Hooked successfully");
+//             rect.right = 9999;
+//             rect.bottom = 9999;
+#if 0
+               int iWidthMM = GetDeviceCaps(hdc, HORZSIZE);
+               int iHeightMM = GetDeviceCaps(hdc, VERTSIZE);
+               int iWidthPels = GetDeviceCaps(hdc, HORZRES);
+               int iHeightPels = GetDeviceCaps(hdc, VERTRES);
+
+               // Use iWidthMM, iWidthPels, iHeightMM, and iHeightPels to determine the
+               // number of .01-millimeter units per pixel in the x and y directions.
+
+               int iMMPerPelX = (iWidthMM * 100)/iWidthPels;
+               int iMMPerPelY = (iHeightMM * 100)/iHeightPels;
+               DBW("-%d %d-",iMMPerPelX, iMMPerPelY);
+
+               // Convert client coordinates to .01-mm units.
+
+               rcClient.left = rcClient.left * iMMPerPelX;
+               rcClient.top = rcClient.top * iMMPerPelY;
+               rcClient.right = rcClient.right * iMMPerPelX;
+               rcClient.bottom = rcClient.bottom * iMMPerPelY;
+#endif
+
+#if USE_META
+               hdcMeta = CreateEnhMetaFile(hdc,
+                                 NULL,
+                                 &rcClient, "DCHook\0EnhMetaFile\0");
+               if ( !hdcMeta ){
+                       DBW("Cannot create Meta file");
+                       goto err3;
+               }
+
+               DBW("hdcMeta=%08X", hdcMeta);
+#endif
+
+#if USE_REDRAW
+               RedrawWindow( hwnd, &rcInvalid, NULL, RDW_UPDATENOW | RDW_NOERASE | RDW_NOFRAME | RDW_INVALIDATE );
+#else
+               WNDPROC PaintWndProc = (WNDPROC)GetWindowLong( hwnd, GWL_WNDPROC );
+               SendMessage( hwnd, WM_PAINT, (WPARAM)hdcMeta, 0 );
+#endif
+#if HOOK_GETDC
+               ReleaseDCHook.Finish();
+               GetDCHook.Finish();
+#endif
+
+#if HOOK_TEXT
+               TabbedTextOutAHook.Finish( );
+               TabbedTextOutWHook.Finish( );
+               TextOutAHook.Finish( );
+               TextOutWHook.Finish( );
+               DrawTextAHook.Finish( );
+               DrawTextWHook.Finish( );
+               DrawTextExAHook.Finish( );
+               DrawTextExWHook.Finish( );
+#endif
+
+#if HOOK_PAINT
+               EndPaintHook.Finish();
+               BeginPaintHook.Finish();
+#endif
+
+#if HOOK_BITBLT
+               BitBltHook.Finish();
+#endif
+
+#if METAEXTTEXTOUT
+               ExtTextOutAHook.Finish();
+               ExtTextOutWHook.Finish();
+#endif
+
+               // Notify start enumrate meta-file
+               CallbackMain(DCH_START, &CursorPoint, sizeof(CursorPoint), hwnd);
+
+               HitFound = false;
+
+#if USE_META
+               HENHMETAFILE emf = CloseEnhMetaFile( hdcMeta );
+
+               if ( emf )
+#endif
+               {
+#if METAEXTTEXTOUT
+                       if ( FoundLocA != -1 || FoundLocW != -1 ){
+//                             DBW("Hit ExtText:%d %d",FoundLocA,FoundLocW);
+                               // ExtTextOutx hook\82Ì\82Ù\82¤\82ð\97D\90æ\82·\82é
+                               ExtTextOutHit( );
+                               HitFound = true;
+                       } else
+#endif
+                       {
+#if USE_META
+                               // Create compatible device-context for enumration
+                               HDC _hdc = CreateCompatibleDC( hdc );
+                               HBITMAP hbitmap = CreateCompatibleBitmap( hdc, rcClient.right, rcClient.bottom );
+                               HGDIOBJ gdiobj = SelectObject( _hdc, hbitmap );
+
+                               DBW("Start meta");
+                               // Enumerate meta-file
+                               EnumEnhMetaFile( _hdc, emf, EnumMetaFileProc, NULL, &rcClient );
+                               DBW("End meta");
+
+                               // Delete compatible device-context
+                               SelectObject( _hdc, gdiobj );
+                               DeleteObject( hbitmap );
+                               DeleteDC( _hdc );
+#endif
+                       }
+#if USE_META
+                       DeleteEnhMetaFile( emf );
+#endif
+               }
+#if USE_META
+               else {
+                       DBW("emf is NULL");
+               }
+#endif
+
+#if METAEXTTEXTOUT
+               if ( !HitFound && TargetBitBltCount != -1 ){
+                       DBW("Search from band:%d",TargetBitBltCount);
+#if USE_META
+                       // Band\82©\82ç\8c\9f\8dõ
+                       hdcMeta = CreateCompatibleDC( hdc );
+                       if ( !hdcMeta ){
+                               DBW("Cannot create HDC in retry");
+                       } else
+#endif
+                       {
+#if USE_META
+                               HBITMAP hbitmap = CreateCompatibleBitmap( hdc, rcClient.right, rcClient.bottom );
+                               HGDIOBJ gdiobj = SelectObject( hdcMeta, hbitmap );
+                               DBW("hdcMeata=%08X", hdcMeta);
+#endif
+
+                               BitBltCount = 0;
+                               RetryPhase = true;
+#if METAEXTTEXOUT
+                               FoundLocA = -1;
+                               FoundLocW = -1;
+#endif
+
+#if METAEXTTEXTOUT
+                               ExtTextOutAHook.HookAgain();
+                               ExtTextOutWHook.HookAgain();
+#endif
+#if HOOK_BITBLT
+                               BitBltHook.HookAgain();
+#endif
+#if HOOK_PAINT
+                               BeginPaintHook.HookAgain();
+                               EndPaintHook.HookAgain();
+#endif
+
+//                             DBW("t1:%d %d %d %d",rcClient.left, rcClient.top,rcClient.right,rcClient.bottom);
+
+#if USE_INVALIDATE
+                               InvalidateRect( hwnd, &rcInvalid, INVALIDATE_TRUE );
+#endif
+
+#if USE_REDRAW
+                               RedrawWindow( hwnd, &rcInvalid, NULL, RDW_UPDATENOW | RDW_NOERASE | RDW_NOFRAME | RDW_INVALIDATE );
+#else
+                               CallWindowProc( (WNDPROC)PaintWndProc, hwnd, WM_PAINT, (WPARAM)hdcMeta, 0 );
+#endif
+
+#if HOOK_PAINT
+                               EndPaintHook.Finish();
+                               BeginPaintHook.Finish();
+#endif
+#if HOOK_BITBLT
+                               BitBltHook.Finish();
+#endif
+
+#if METAEXTTEXTOUT
+                               ExtTextOutAHook.Finish();
+                               ExtTextOutWHook.Finish();
+#endif
+#if USE_META
+                               SelectObject( hdcMeta, gdiobj );
+                               DeleteObject( hbitmap );
+                               DeleteDC( hdcMeta );
+#endif
+                               if ( FoundLocA != -1 || FoundLocW != -1 ){
+                                       DBW("Found in BitBlt ExtText:%d %d",FoundLocA,FoundLocW);
+                                       ExtTextOutHit( );
+                                       HitFound = true;
+                               }
+                       }
+               }
+#endif // METAEXTTEXTOUT
+
+#if RETRYMETA
+               if ( !HitFound ){
+                       HENHMETAFILE emf;
+#if !USE_META
+                       HDC hdc = GetDC( hwnd );
+                       if ( !hdc ){
+                               DBW("Cannot get DC");
+                               goto err01;
+                       }
+#endif
+#if HOOK_PAINT
+                       if ( !BeginPaintHook.HookAgain( ) ){
+                               DBW("Cannot hook BeginPaint");
+                               goto err02;
+                       }
+                       if ( !EndPaintHook.HookAgain( ) ){
+                               DBW("Cannot hook EndPaint");
+                               goto err03;
+                       }
+#else
+                       if ( !BeginPaintHook.GetProcOrgFunc( hInst ) ){
+                               DBW("Cannot hook BeginPaint");
+                               goto err02;
+                       }
+                       if ( !EndPaintHook.GetProcOrgFunc( hInst ) ){
+                               DBW("Cannot hook EndPaint");
+                               goto err03;
+                       }
+#endif
+
+                       hdcMeta = CreateEnhMetaFile(hdc,
+                                         NULL,
+                                         &rcClient, _T("DCHook\0EnhMetaFile\0"));
+                       if ( !hdcMeta ){
+                               DBW("Cannot create Meta file");
+                               goto err04;
+                       }
+                       DBW("hdcMeta=%08X", hdcMeta);
+//                     InvalidateRect( hwnd, &rcInvalid, INVALIDATE_TRUE );
+#if 1          // 2000.7.15 NT\82Å\82à\82È\82º\82±\82Á\82¿\82É\82µ\82Ä\82¢\82È\82©\82Á\82½\82Ì\82©\82í\82©\82ç\82È\82¢\82ª\81E\81E\81E
+                       SendMessage( hwnd, WM_PAINT, (WPARAM)hdcMeta, 0 );
+#else
+                       // Notepad\82Å\82Í\88Ù\8fí\8fI\97¹\82·\82é\82½\82ß\8bp\89º
+                       // \89½\82à\82È\82¢\82Æ\82±\82ë\82ÅCtrl+\89E\83N\83\8a\83b\83N
+                       WNDPROC PaintWndProc = (WNDPROC)GetWindowLong( hwnd, GWL_WNDPROC );
+                       if ( PaintWndProc ){
+                               PaintWndProc( hwnd, WM_PAINT, (WPARAM)hdcMeta, 0 );
+                       }
+#endif
+                       EndPaintHook.Finish();
+                       BeginPaintHook.Finish();
+
+                       emf = CloseEnhMetaFile( hdcMeta );
+
+                       if ( emf ){
+                               HDC _hdc = CreateCompatibleDC( hdc );
+                               HBITMAP hbitmap = CreateCompatibleBitmap( hdc, rcClient.right, rcClient.bottom );
+                               HGDIOBJ gdiobj = SelectObject( _hdc, hbitmap );
+
+                               DBW("Start meta-retry");
+                               // Enumerate meta-file
+                               EnumEnhMetaFile( _hdc, emf, EnumMetaFileProc, NULL, &rcClient );
+                               DBW("End meta-retry");
+
+                               // Delete compatible device-context
+                               SelectObject( _hdc, gdiobj );
+                               DeleteObject( hbitmap );
+                               DeleteDC( _hdc );
+                               DeleteEnhMetaFile( emf );
+                       }
+               err04:
+                       EndPaintHook.Finish();
+               err03:
+                       BeginPaintHook.Finish();
+               err02:
+#if !USE_META
+                       ReleaseDC( hwnd, hdc );
+#endif
+               err01:;
+               }
+#endif
+               
+               // Notify end enumrate meta-file
+               CallbackMain(DCH_END | (MoveSendMode ? DCH_MOVESEND : 0), NULL, 0, hwnd);
+       }
+
+#if USE_META
+       ReleaseDC( hwnd, hdc );
+#endif
+
+       if ( rcOrgInvalid.right != 0 ){
+               DBW("Update OrgInvalid--------");
+               InvalidateRect( hwnd, NULL, INVALIDATE_TRUE );
+       }
+
+       goto jreturn;
+
+#if HOOK_GETDC || USE_META
+err3:;
+#endif
+#if HOOK_GETDC
+       GetDCHook.Finish();
+err4:;
+#if USE_META
+       ReleaseDC( hwnd, hdc );
+#endif
+#endif
+#if USE_META
+err5:;
+#endif
+#if HOOK_PAINT
+       EndPaintHook.Finish();
+err6:;
+       BeginPaintHook.Finish();
+err73:;
+#endif
+#if HOOK_BITBLT
+       BitBltHook.Finish();
+#endif
+#if HOOK_BITBLT
+err71:;
+#endif
+#if METAEXTTEXTOUT
+       ExtTextOutWHook.Finish();
+err7:;
+       ExtTextOutAHook.Finish();
+err8:
+#endif
+       if (hPSAPI)
+               FreeLibrary( hPSAPI );
+#if USE_DBW
+err9:
+#endif
+       HitFound = false;
+jreturn:;
+#if USE_VXD
+       if (vxd_Handle!=INVALID_HANDLE_VALUE)
+               UnloadVxD();
+#endif
+#if METAEXTTEXTOUT
+       delete FoundTextA;
+       delete FoundTextW;
+       delete LastTextA;
+       delete LastTextW;
+#endif
+
+       return HitFound;
+}
+#if METAEXTTEXTOUT
+void ExtTextOutHit()
+{
+       if ( FoundLocA != -1 ){
+               // Hit on ANSI
+               DBW("Hit on ANSI@ExtTextOut");
+               CallbackMain(DCH_HITTEXT1, FoundTextA->c_str(), FoundTextA->GetByte(), (HWND)FoundLocA);
+       } else {
+               // Hit on UNICODE
+               DBW("Hit on UNICODE@ExtTextOut");
+               CallbackMain(DCH_HITTEXT2, FoundTextW->c_str(), FoundTextW->GetByte(), (HWND)FoundLocW);
+       }
+}
+#endif // METAEXTTEXTOUT
+
+void DoScale(HDC hdc, POINT *pts, int num)
+{
+       //TODO: hInst, proc\82Íglobal\82É\82µ\82½\82Ù\82¤\82ª\82¢\82¢\82Ì\82Å\82Í\81H
+
+       int scale = 0;
+       if (ScaleX && ScaleY){
+               scale = ScaleX; // \8ew\92è\82µ\82½scaling parameter
+       } else {
+               scale = GetMonitorScale();
+               if (scale == 96) return;
+       }
+
+#if 1
+#if 1
+       PROCESS_DPI_AWARENESS value = Process_DPI_Unaware;
+       if (hInstSHCore){
+               if (!GetProcessDPIAwareness){
+                       GetProcessDPIAwareness = (FNGetProcessDPIAwareness)GetProcAddress(hInstSHCore, "GetProcessDpiAwareness");
+               }
+               if (GetProcessDPIAwareness){
+                       GetProcessDPIAwareness(hProcess, &value);
+                       DBW("DPIAware: value=%d", value);
+               }
+       }
+       if (value != Process_System_DPI_Aware){
+               int dpi_x = scale;
+               int dpi_y = scale;
+               DBW("dpi: %d,%d", dpi_x, dpi_y);
+               for (int i=0;i<num;i++){
+                       pts[i].x = MulDiv(pts[i].x, dpi_x, 96);
+                       pts[i].y = MulDiv(pts[i].y, dpi_y, 96);
+               }
+       }
+#else
+       HINSTANCE hInst = NULL;
+       FNGetProcessDPIAwareness GetProcessDPIAwareness = NULL;
+       //FNSetProcessDPIAwareness SetProcessDPIAwareness = NULL;
+       //if (!GetProcessDPIAwareness)
+       {
+               hInst = LoadLibrary("shcore.dll");
+               if (hInst){
+                       GetProcessDPIAwareness = (FNGetProcessDPIAwareness)GetProcAddress(hInst, "GetProcessDpiAwareness");
+                       //SetProcessDPIAwareness = (FNSetProcessDPIAwareness)GetProcAddress(hInst, "SetProcessDpiAwareness");
+                       //DBW("DPI API:%08X %08X", GetProcessDPIAwareness, SetProcessDPIAwareness);
+                       DBW("DPI API:%08X", GetProcessDPIAwareness);
+               }
+       }
+       if (GetProcessDPIAwareness || (ScaleX && ScaleY)){
+               int dpi_x, dpi_y;
+               PROCESS_DPI_AWARENESS value;
+               if (GetProcessDPIAwareness && hdc){
+                       HRESULT hRes = GetProcessDPIAwareness(hProcess, &value);
+                       DBW("DPIAware: value=%d", value);
+                       //SetProcessDPIAwareness(Process_System_DPI_Aware);
+                       dpi_x = GetDeviceCaps(hdc, LOGPIXELSX);
+                       dpi_y = GetDeviceCaps(hdc, LOGPIXELSY);
+                       DBW("dpi: %d, %d", dpi_x, dpi_y);
+               } else {
+                       dpi_x = ScaleX;
+                       dpi_y = ScaleY;
+               }
+               for (int i=0;i<num;i++){
+                       pts[i].x = MulDiv(pts[i].x, dpi_x, 96);
+                       pts[i].y = MulDiv(pts[i].y, dpi_y, 96);
+               }
+#if 0
+               if (SetProcessDPIAwareness){
+                       SetProcessDPIAwareness(value);
+               }
+#endif
+       }
+       if (hInst){
+               FreeLibrary(hInst);
+       }
+#endif
+#else  // \8b\8c\83R\81[\83h
+       HINSTANCE hInst = NULL;
+       if (!GetProcessDPIAwareness){
+               hInst = LoadLibrary("shcore.dll");
+               DBW("shcore=%08X", hInst);
+               if (hInst){
+                       GetProcessDPIAwareness = (FNGetProcessDPIAwareness)GetProcAddress(hInst, "GetProcessDPIAwareness");
+                       SetProcessDPIAwareness = (FNSetProcessDPIAwareness)GetProcAddress(hInst, "SetProcessDPIAwareness");
+                       DBW("DPI API:%08X %08X", GetProcessDPIAwareness, SetProcessDPIAwareness);
+               }
+       }
+       if (GetProcessDPIAwareness || (ScaleX && ScaleY)){
+               int dpi_x, dpi_y;
+               PROCESS_DPI_AWARENESS value;
+               if (GetProcessDPIAwareness && hdc){
+                       HRESULT hRes = GetProcessDPIAwareness(hProcess, &value);
+                       SetProcessDPIAwareness(Process_System_DPI_Aware);
+                       dpi_x = GetDeviceCaps(hdc, LOGPIXELSX);
+                       dpi_y = GetDeviceCaps(hdc, LOGPIXELSY);
+               } else {
+                       dpi_x = ScaleX;
+                       dpi_y = ScaleY;
+               }
+               for (int i=0;i<num;i++){
+                       pts[i].x = MulDiv(pts[i].x, dpi_x, 96);
+                       pts[i].y = MulDiv(pts[i].y, dpi_y, 96);
+               }
+               if (SetProcessDPIAwareness){
+                       SetProcessDPIAwareness(value);
+               }
+               if (hInst){
+                       FreeLibrary(hInst);
+               }
+       }
+#endif
+}
+
+int CALLBACK EnumMetaFileProc( HDC hdc, HANDLETABLE *ht, CONST ENHMETARECORD *mfr, int nobj, LPARAM /* user */ )
+{
+       PlayEnhMetaFileRecord( hdc, ht, mfr, nobj );
+
+       //DBW("iType=%d",mfr->iType);
+
+       switch ( mfr->iType ){
+               case EMR_EXTTEXTOUTA:
+               case EMR_EXTTEXTOUTW:
+               {
+                       EMREXTTEXTOUTW *emr = (EMREXTTEXTOUTW*)mfr;
+
+                       //DBW("(%d,%d) <%d=%d=%d=%d>", CursorPoint.x, CursorPoint.y, emr->rclBounds.left, emr->rclBounds.top,emr->rclBounds.right, emr->rclBounds.bottom);
+#if 1
+                       if ( PtInRect( (RECT*)&emr->rclBounds, CursorPoint ) ){
+                               DBW("(%d,%d) <%d=%d>", CursorPoint.x, CursorPoint.y, emr->rclBounds.left, emr->emrtext.ptlReference.x);
+#if 0
+                               {
+                               SIZE sz1, sz2;
+                               GetWindowExtEx( hdc, &sz1 );
+                               GetViewportExtEx( hdc, &sz2 );
+                               DBW("%d-%d %d-%d", sz1.cx, sz1.cy, sz2.cx, sz2.cy);
+                               }
+#endif
+                               int loc;
+                               if ( mfr->iType == EMR_EXTTEXTOUTW ){
+                                       //DBW("offString=%d nChars=%d left=%d top=%d offDx=%d", emr->emrtext.offString, emr->emrtext.nChars, emr->rclBounds.left, emr->rclBounds.top, emr->emrtext.offDx);
+                                       //DBW("text=%ws", (wchar_t*) ( ((char*)emr) + emr->emrtext.offString ));
+                                       loc = GetTextFromPoint( hdc, (wchar_t*) ( ((char*)emr) + emr->emrtext.offString ),
+                                               emr->emrtext.nChars,
+                                               CursorPoint.x - emr->rclBounds.left /* + emr->emrtext.ptlReference.x */,
+                                               CursorPoint.y - emr->rclBounds.top  /* + emr->emrtext.ptlReference.y */,
+                                               ((int*)(((char*)emr) + emr->emrtext.offDx)) );
+                               } else {
+                                       loc = GetTextFromPoint( hdc, ((char*)emr) + emr->emrtext.offString,
+                                               emr->emrtext.nChars,
+                                               CursorPoint.x - emr->rclBounds.left /* + emr->emrtext.ptlReference.x */,
+                                               CursorPoint.y - emr->rclBounds.top  /* + emr->emrtext.ptlReference.y */,
+                                               ((int*)(((char*)emr) + emr->emrtext.offDx)) );
+                               }
+                               if ( loc != -1 ){
+//                                     char *buf = NULL;
+                                       const char *text = ((char*)emr) + emr->emrtext.offString;
+                                       int len = emr->emrtext.nChars;
+                                       if ( mfr->iType == EMR_EXTTEXTOUTW ){
+                                               // WIDE
+                                               //DBW("len=%d loc=%d text=%ws", len, loc, text);
+                                               CallbackMain(DCH_HITTEXT2, text, len * sizeof(wchar_t), (HWND)loc);
+#if 0
+                                               // UNICODE->ANSI
+                                               // ANSI\8fã\82Å\82Ìloc\82ð\8b\81\82ß\82é\82½\82ß\81A\91O\94¼\82Æ\8cã\94¼\82ð\95ª\82¯\82Ä\95Ï\8a·
+                                               wchar_t *wp = (wchar_t*) ( ((char*)emr) + emr->emrtext.offString );
+                                               buf = new char[ emr->emrtext.nChars * 2 ];
+                                               memset( buf, 0, emr->emrtext.nChars*2 );
+                                               // \91O\94¼\95\94\95ª
+                                               len = 0;
+                                               if ( loc > 0 ){
+                                                       len = WideCharToMultiByte( CP_ACP, 0, wp, loc,
+                                                               buf, emr->emrtext.nChars * 2, NULL, NULL );
+                                               }
+                                               int newloc = len;
+                                               // \8cã\94¼\95\94\95ª
+                                               if ( emr->emrtext.nChars > (unsigned int)loc ){
+                                                       len += WideCharToMultiByte( CP_ACP, 0, wp+loc, emr->emrtext.nChars - loc,
+                                                               buf+len, emr->emrtext.nChars * 2 - len, NULL, NULL );
+                                               }
+                                               loc = newloc;
+                                               text = buf;
+#endif
+
+                                       } else {
+                                               // ANSI
+                                               CallbackMain(DCH_HITTEXT1, text, len, (HWND)loc);
+                                       }
+
+                                       DBW("Found@Enum");
+#if 0
+                                       CallbackMain(DCH_HITTEXT1, text, len, (HWND)loc);
+                                       if ( buf )
+                                               delete buf;
+#endif
+#if 0
+                                       {
+                                       char b[100];
+                                       sprintf(b,"exScale=%f eyScale=%f ptlReference=(%d,%d)",emr->exScale, emr->eyScale, emr->emrtext.ptlReference.x, emr->emrtext.ptlReference.y );
+                                       DBW(b);
+                                       DBW("iGraphicsMode=%d", emr->iGraphicsMode);
+                                       }
+#endif
+#if 0
+                                       {
+                                               for ( int i=0;i<(int)emr->emrtext.nChars;i++ ){
+                                                       DBW(">%d", ((int*)(((char*)emr) + emr->emrtext.offDx))[i] );
+                                               }
+                                       }
+#endif
+//                                     DBW("[%d %d][%d %d]text=(%s)", emr->rclBounds.left, emr->rclBounds.top, CursorPoint.x, CursorPoint.y, text);
+//                                     result = false; // stop enumration      // \8d\82\91¬\89»\82Ì\82½\82ß\93r\92\86\82Å\8fI\82í\82è\82É\82µ\82½\82¢\82ª\81E\81E\81E\82Ç\82¤\82µ\82æ\82¤\81H
+#if METAEXTTEXTOUT
+                                       // prevent to get from ExtTextOut hook
+                                       FoundLocA = -1;
+                                       FoundLocW = -1;
+#endif
+                                       HitFound = true;
+                               }
+                       }
+#else  // for debug
+                       if ( mfr->iType == EMR_EXTTEXTOUTW ){
+                               CallbackMain(DCH_EXTTEXTOUTW, emr, sizeof(EMREXTTEXTOUTW) + emr->emrtext.nChars * sizeof(wchar_t), (HWND)hdc);
+                       } else {
+                               CallbackMain(DCH_EXTTEXTOUTA, emr, sizeof(EMREXTTEXTOUTA) + emr->emrtext.nChars, (HWND)hdc);
+                       }
+#endif
+               }
+                       break;
+       }
+       return true;
+}
+
+}      // extern "C"
+
+// text\82Ì\90æ\93ª\82ð(0,0)\82Æ\82µ\82½\8dÀ\95W\82Å\81Apos\82Ì\88Ê\92u\82É\82 \82étext\82Ì\95\8e\9a\88Ê\92u\82ð\95Ô\82·
+int GetTextFromPoint( HDC hdc, const char *text, int len, int pos_x, int pos_y, const int *dx )
+{
+       if ( pos_x < 0 || pos_y < 0 ) return -1;
+
+       int count = 0;
+       SIZE sz;
+       int *rdx = NULL;
+       if ( dx ){
+               rdx = new int[len];
+               memset( rdx, 0, len*sizeof(int) );
+       }
+       if ( !GetTextExtentExPointA( hdc, text, len, pos_x, &count, rdx, &sz ) ){
+               DBW("GetTextExtentExPointA Failure!!");
+               if ( rdx )
+                       delete rdx;
+               return -1;
+       }
+#if METAEXTTEXTOUT
+       LastX += sz.cx; // update
+#endif
+       // size over check
+       if ( pos_y > sz.cy
+               || pos_x > sz.cx
+               ){
+               if ( rdx ) delete rdx;
+               return -1;
+       }
+       DBW("A:len=%d pos_x=%d sz.cx=%d", len, pos_x, sz.cx);
+       if ( dx && count > 0 ){
+               // ex.
+               // Win98,Notepad\82Ì\93ú\96{\8cê\8fã\82Å
+               //  dx = 0, 8, 0, 8, 0, 8, ...
+               // rdx = 9,10, 9,10, 9,10, ...
+#if 0
+               {
+                       int i;
+                       for ( i=0;i<len;i++ ){
+                               DBW(" dx[%2d]=%d",i,dx[i]);
+                       }
+                       for ( i=0;i<count;i++ ){
+                               DBW("rdx[%2d]=%d",i,rdx[i+1]-rdx[i]);
+                       }
+               }
+#endif
+               // spacing\82Ì\8cë\8d·\82ð\8cv\8eZ
+               // Times New Roman\82È\82Ç\82Å\92²\82×\82é\82Æ\82©\82È\82è\82Ì\8cë\8d·\82ª\82 \82é\81B\82È\82º\81H
+
+               int i = 0;
+               int j = 0;
+               int sumdx = 0;
+//             DBW("rd(x)[0]=%d,%d",dx[0],rdx[0]);
+               if ( rdx[0] ){
+                       if ( dx[0] ){
+                               sumdx = dx[0] - rdx[0];
+                       } else {
+                               sumdx = dx[1] - rdx[0];
+                       }
+                       i++;
+                       j++;
+               }
+               for ( ;i<count;i++,j++ ){
+#if 0
+                       if ( rdx[i] == rdx[i-1] ){ j--; continue;}      // for multi-bytes font
+                                                                                                               //*++ \82 \82Æ\82Å ExtTextOut API manual\82ð\8eQ\8fÆ
+                       sumdx += dx[j] - (rdx[i]-rdx[i-1]);
+//                     DBW("%3d <> %3d", dx[j], rdx[i]-rdx[i-1]);
+#else  // Win98\82Å\82Í\81Amulti-byte\82Å\82à\95ª\8eU\82³\82¹\82Ä\82¢\82é\8fê\8d\87\82ª\82 \82é\82½\82ß\81Adx\82Å\94»\92f
+                       sumdx += (dx[j]?dx[j]:dx[j+1]) - (rdx[i]-rdx[i-1]);
+#endif
+               }
+//             DBW("sumdx=%d",sumdx);
+               if ( !GetTextExtentExPointA( hdc, text, len, pos_x - sumdx, &count, rdx, &sz ) ){
+                       if ( rdx )
+                               delete rdx;
+                       return -1;
+               }
+       }
+       if ( rdx )
+               delete rdx;
+       return count;
+}
+int GetTextFromPoint( HDC hdc, const wchar_t *text, int len, int pos_x, int pos_y, const int *dx )
+{
+#if USE_VXD
+       if (WindowsNT)
+#endif
+       {
+               if ( pos_x < 0 || pos_y < 0 ) return -1;
+
+               int count = 0;
+               SIZE sz;
+               int *rdx = NULL;
+               if ( dx ){
+                       rdx = new int[ len ];
+                       memset( rdx, 0, len );
+               }
+               if ( !GetTextExtentExPointW( hdc, text, len, pos_x, &count, rdx, &sz ) )
+               {
+                       DBW("GetTextExtentExPointW Failure!!");
+                       if ( rdx )
+                               delete[] rdx;
+                       return -1;
+               }
+#if METAEXTTEXTOUT
+               LastX += sz.cx;
+#endif
+               // size over check
+               if ( pos_y > sz.cy
+                       || pos_x > sz.cx
+                       ){
+                       if ( rdx ) delete[] rdx;
+                       return -1;
+               }
+               DBW("W:len=%d pos_x=%d sz.cx=%d", len, pos_x, sz.cx);
+               if ( dx && count > 0 ){
+                       // spacing\82Ì\8cë\8d·\82ð\8cv\8eZ
+                       // Times New Roman\82È\82Ç\82Å\92²\82×\82é\82Æ\82©\82È\82è\82Ì\8cë\8d·\82ª\82 \82é\81B\82È\82º\81H
+                       int i = 0;
+                       int j = 0;
+                       int sumdx = 0;
+       //              DBW("rd(x)[0]=%d,%d",dx[0],rdx[0]);
+                       if ( rdx[0] ){
+                               sumdx = dx[0] - rdx[0];
+                               i++;
+                               j++;
+                       }
+                       for ( ;i<count-1;i++,j++ ){
+#if 0
+                               if ( rdx[i] == rdx[i-1] ){ j--; continue;}      // for multi-bytes font
+                                                                                                               //*++ \82 \82Æ\82Å ExtTextOut API manual\82ð\8eQ\8fÆ
+                               sumdx += dx[j] - (rdx[i]-rdx[i-1]);
+       //                      DBW("%3d <> %3d", dx[j], rdx[i]-rdx[i-1]);
+#else
+                               sumdx += (dx[j]?dx[j]:dx[j+1]) - (rdx[i]-rdx[i-1]);
+#endif
+                       }
+       //              DBW("sumdx=%d",sumdx);
+                       if ( !GetTextExtentExPointW( hdc, text, len, pos_x - sumdx, &count, rdx, &sz ) ){
+                               if ( rdx )
+                                       delete rdx;
+                               return -1;
+                       }
+               }
+               if ( rdx )
+                       delete rdx;
+               return (count == len && sz.cx < pos_x) ? -1 : count;
+       }
+#if USE_VXD
+       else {
+               char *buf = new char[ len * sizeof(wchar_t) ];
+               memset( buf, 0, len * sizeof(wchar_t) );
+               int ansilen = WideCharToMultiByte( CP_ACP, 0, text, len, buf, len*sizeof(wchar_t), NULL, NULL );
+               int r = GetTextFromPoint( hdc, buf, ansilen, pos_x, pos_y, dx );
+               delete buf;
+               return r;
+       }
+#endif
+}
+
+#define        WMCD_EXISTCHECK         0x4000
+#define        WMCD_SETPOINT           0x4001
+
+class TDC {
+       HDC hdc;
+       HWND hwnd;
+public:
+       TDC()
+       :hwnd(NULL)
+       {
+               hdc = GetDC(NULL);
+       }
+       TDC(HWND _hwnd)
+       :hwnd(_hwnd)
+       {
+               hdc = GetWindowDC(hwnd);
+       }
+       ~TDC()
+       {
+               reset();
+       }
+       void reset()
+       {
+               if (hdc){
+                       ReleaseDC(hwnd, hdc);
+                       hdc = NULL;
+               }
+       }
+       operator HDC() { return hdc; }
+       bool operator !() { return hdc==NULL; }
+};
+
+bool CaptureImage(HWND hwnd, bool movesend, bool non_block)
+{
+       MoveSendMode = movesend;
+       CaptureImageBlocking = false;
+
+       bool capture_page = false;
+       if (hwndAMODI){
+               capture_page = SendMessage(hwndAMODI, WM_AMODI, AMODI_CMD_PAGE_CAPTURE, 0) ? true : false;
+       }
+
+       // Get the rect of the target window.
+       RECT rcTarget;
+       if (!GetWindowRect(hwnd, &rcTarget)){
+               // window died?
+               return false;
+       }
+       if (!ExtAMODI){
+               if (!IsWindowEnabled(hwndAMODI)){
+                       // AMODI died?
+                       hwndAMODI = FindAMODI();
+                       if (!hwndAMODI)
+                               return false;
+               }
+       }
+       int w = rcTarget.right - rcTarget.left;
+       int h = rcTarget.bottom - rcTarget.top;
+       if (w==0 || h==0){
+               return false;   // no area in the target.
+       }
+
+       POINT ptCursor; // \89æ\91\9c\8fã\82Ì\83J\81[\83\\83\8b\88Ê\92u
+       int x, y;
+       if (capture_page){
+               x = rcTarget.left;
+               y = rcTarget.top;
+               ptCursor.x = ScreenPoint.x - rcTarget.left;
+               ptCursor.y = ScreenPoint.y - rcTarget.top;
+       } else {
+               // x\95û\8cü : target rect\82Ì\8d\92[\82©\82ç
+               // y\95û\8cü : cursor point\82Ì\8fã\89º100 pixel
+               x = rcTarget.left;
+               int offs = 100;
+               if (ScreenPoint.y - rcTarget.top < offs){
+                       if (ScreenPoint.y < rcTarget.top) return false; // click on out of rect?
+                       y = rcTarget.top;
+                       h = ScreenPoint.y - rcTarget.top + offs;
+               } else {
+                       y = ScreenPoint.y - offs;
+                       h = offs * 2;
+               }
+               if (y+h>rcTarget.bottom){
+                       h = rcTarget.bottom - y;
+               }
+               ptCursor.x = ScreenPoint.x - rcTarget.left;
+               ptCursor.y = ScreenPoint.y - y;
+       }
+
+       if (0){
+               HWND hwnd = GetDesktopWindow();
+               RECT rc;
+               GetWindowRect(hwnd, &rc);
+               x = 0;
+               y = 0;
+               w = rc.right - rc.left;
+               h = rc.bottom - rc.top;
+       }
+
+       if (!capture_page){
+               // Notify start enumrate
+               CallbackMain(DCH_START, &CursorPoint, sizeof(CursorPoint), hwnd);
+       }
+
+       bool ok = false;
+
+       TDC hdc;
+
+       if (!hdc){
+               goto jend;
+       }
+
+#if USE_SCALING
+       POINT pts[3];
+       pts[0].x = x;
+       pts[0].y = y;
+       pts[1].x = w;
+       pts[1].y = h;
+       pts[2].x = ptCursor.x;
+       pts[2].y = ptCursor.y;
+       DoScale(hdc, pts, 3);
+       //DBW("%d,%d %d,%d,%d,%d -> %d,%d %d,%d,%d,%d", ptCursor.x, ptCursor.y, x, y, w, h, pts[2].x, pts[2].y, pts[0].x, pts[0].y, pts[1].x, pts[1].y);
+       x = pts[0].x;
+       y = pts[0].y;
+       w = pts[1].x;
+       h = pts[1].y;
+       ptCursor.x = pts[2].x;
+       ptCursor.y = pts[2].y;
+#endif
+
+       // capture image
+
+       int wlen = (w*3+3)&~3;
+
+       /* \8f\91\82«\8d\9e\82Ý\97p\83o\83b\83t\83@\82Ì\83T\83C\83Y\8cv\8eZ */
+       DWORD dwFSize = sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER) + wlen * h;
+
+       /* \83o\83b\83t\83@\8am\95Û\82Æ\83|\83C\83\93\83^\90Ý\92è */
+       LPBYTE lpBuf = (LPBYTE)new char[dwFSize];
+       if (!lpBuf){
+               goto jend;
+       }
+
+       LPBITMAPFILEHEADER lpHead = (LPBITMAPFILEHEADER)lpBuf;
+       LPBITMAPINFOHEADER lpInfo = (LPBITMAPINFOHEADER)(lpBuf+sizeof(BITMAPFILEHEADER));
+       LPBYTE lpPixel = lpBuf+sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER);
+
+       /* 24\83r\83b\83gBMP\83t\83@\83C\83\8b\82Ì\83w\83b\83_\8dì\90¬ */
+       lpHead->bfType = ('M'<<8) +'B';
+       lpHead->bfSize = dwFSize;
+       lpHead->bfOffBits = sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER);
+       lpInfo->biSize = sizeof(BITMAPINFOHEADER);
+       lpInfo->biWidth = w;
+       lpInfo->biHeight = h;
+       lpInfo->biPlanes = 1;
+       lpInfo->biBitCount = 24;
+
+       HBITMAP hBmp = CreateCompatibleBitmap(hdc, w, h);
+       if (hBmp){
+               HDC hdcMem = CreateCompatibleDC(hdc);
+               if (hdcMem){
+                       HDC hOld = (HDC)SelectObject(hdcMem, hBmp);
+                       if (hOld!=(HDC)GDI_ERROR){
+                               BOOL r = BitBlt(hdcMem, 0, 0, w, h, hdc, x, y, SRCCOPY);
+                               SelectObject(hdcMem, hOld);
+                               if (r){
+//                                     int lines = GetDIBits(hdc, hBmp, 0, h, NULL, (LPBITMAPINFO)lpInfo, DIB_RGB_COLORS);
+                                       int lines = GetDIBits(hdc, hBmp, 0, h, lpPixel, (LPBITMAPINFO)lpInfo, DIB_RGB_COLORS);
+                                       if (lines!=0){
+                                               ok = true;
+                                       } else {
+                                               dbw("GetDIBits error??? %d h=%d w=%d bfSize=%d", GetLastError(), h, w, dwFSize);
+                                       }
+                               } else {
+//                                             dbw("BitBlt error??? %d", GetLastError());
+                               }
+                       }
+                       DeleteObject(hdcMem);
+               }
+               DeleteObject(hBmp);
+       }
+
+       hdc.reset();
+
+       if (ok){
+               ok = false;
+
+               //TCHAR path[sizeof(AMODIPath)+40];
+               TCHAR *path = ImageTextPath;
+               size_t path_size = sizeof(ImageTextPath);
+               size_t len;
+               if (ExtAMODI){
+                       len = _tcslen(AMODIPath);
+                       _tcscpy(path, AMODIPath);
+               } else {
+                       memset(path, 0, path_size);
+                       len = GetTempPath((DWORD)path_size, path);
+               }
+               if (len>0){
+                       // send image to AMODI
+                       SYSTEMTIME t;
+                       GetLocalTime(&t);
+                       if (ExtAMODI){
+                               wsprintf(path+len, /*path_size-len,*/ _T("\\%04d-%02d-%02d-%02d%02d%02d-(%d,%d).bmp"),
+                                       t.wYear, t.wMonth, t.wDay, t.wHour, t.wMinute, t.wSecond, ptCursor.x, ptCursor.y);
+                       } else {
+                               wsprintf(path+len, /*path_size-len,*/ _T("\\amodi\\%04d-%02d-%02d-%02d%02d%02d.bmp"),
+                                       t.wYear, t.wMonth, t.wDay, t.wHour, t.wMinute, t.wSecond);
+                               SendAMODI(WMCD_SETPOINT, (char*)&ptCursor, sizeof(ptCursor));
+                       }
+                       HANDLE fh = CreateFile(path,  GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
+                       if (fh!=INVALID_HANDLE_VALUE){
+                               DWORD dwSize;
+                               WriteFile(fh, lpBuf, dwFSize, &dwSize, NULL);
+                               CloseHandle(fh);
+                               SaveImageTime = GetTickCount();
+
+                               if (capture_page){
+                                       ok = true;
+                               } else {
+                                       len = (int)_tcslen(path);
+                                       _tcsncat(path+len, _T(".txt"), path_size-len);
+                                       if (non_block){
+                                               CaptureImageBlocking = true;
+                                       } else {
+                                               if (WaitAndGetResult(path, 3000))
+                                                       ok = true;
+                                       }
+                               }
+                       }
+               }
+       }
+       delete[] lpBuf;
+
+jend:
+       if (!CaptureImageBlocking){
+               if (!capture_page){
+                       CallbackMain(DCH_END | (MoveSendMode ? DCH_MOVESEND : 0), NULL, 0, hwnd );
+               }
+       }
+
+       return ok;
+}
+
+bool WaitAndGetResult(const TCHAR *path, unsigned waittime)
+{
+       bool ok = false;
+
+       // wait and get text from AMODI
+
+       HANDLE fh = WaitForResult(path, waittime);
+
+       CaptureImageBlocking = false;
+
+       if (fh==INVALID_HANDLE_VALUE){
+               DBW("file open timeout");
+               CheckAMODIAlive();
+       } else {
+               DWORD size = GetFileSize(fh, NULL);
+               if (size>0){
+                       unsigned bufsize = size+sizeof(wchar_t);
+                       char *text = new char[bufsize];
+                       if (text){
+                               DWORD rbyte;
+                               if (ReadFile(fh, text, size, &rbyte, NULL)){
+                                       if (rbyte==size){
+                                               *(wchar_t*)&text[size] = '\0';
+                                               // text\82Ì\82P\8ds\96Ú\82Í\89ð\90Í\8fî\95ñ
+                                               // format
+                                               // (\83}\83E\83X\83J\81[\83\\83\8b\82Ì\82 \82é\83e\83L\83X\83g\88Ê\92u[\95\8e\9a\96Ú zero-index])
+                                               int loc = 0;
+                                               int col = 0;
+                                               wchar_t *p = (wchar_t*)text;
+                                               while (*p){
+                                                       wchar_t c = *p++;
+                                                       if (c=='\n'){
+                                                               break;
+                                                       }
+                                                       if (col==0){
+                                                               loc = _wtoi(p);
+                                                               col++;
+                                                       }
+                                               }
+
+                                               DBW("%d:%ws", loc, p);
+                                               CallbackMain(DCH_HITTEXT2, p, bufsize - (int)((char*)p-text), (HWND)loc);
+
+                                               ok = true;
+                                       }
+                               }
+                               delete[] text;
+                       }
+               }
+               CloseHandle(fh);
+               DeleteFile(path);
+       }
+       CallbackMain(DCH_END | (MoveSendMode ? DCH_MOVESEND : 0), NULL, 0, NULL );
+       return ok;
+}
+
+HANDLE WaitForResult(const TCHAR *path, unsigned waittime)
+{
+       HANDLE fh = INVALID_HANDLE_VALUE;
+
+       while (1){
+               fh = CreateFile(path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+               if (fh!=INVALID_HANDLE_VALUE)
+                       break;
+
+               DWORD now = GetTickCount();
+               if (now-SaveImageTime > waittime)
+                       break;
+
+               Sleep(10);
+       }
+
+       return fh;
+}
+
+#define        APPNAME _T("Auto MODI")
+
+static HWND hwndFind;
+static BOOL CALLBACK EnumWindowsProc( HWND hwnd, LPARAM lParam )
+{
+       TCHAR wndname[80];
+       if (GetWindowText(hwnd, wndname, tsizeof(wndname))<0){
+               return TRUE;
+       }
+       if (_tcscmp(wndname, APPNAME)){ return TRUE; }
+
+       COPYDATASTRUCT cd;
+       cd.dwData = WMCD_EXISTCHECK;
+       cd.lpData = (void*)APPNAME;
+       cd.cbData = (DWORD)(_tcslen(APPNAME)+1)*sizeof(TCHAR);
+       if ( SendMessage( hwnd, WM_COPYDATA, 0, (LPARAM)&cd ) )
+       {
+               // found
+               hwndFind = hwnd;
+               return FALSE;
+       }
+       return TRUE;
+}
+
+HWND FindAMODI()
+{
+       hwndFind = NULL;
+       EnumWindows(EnumWindowsProc, 0);
+       return hwndFind;
+}
+
+int SendAMODI(int cmd, const char *data, int len)
+{
+       COPYDATASTRUCT cd;
+       cd.dwData = cmd;
+       cd.lpData = (void*)data;
+       cd.cbData = len;
+       return (int)SendMessage(hwndAMODI, WM_COPYDATA, 0, (LPARAM)&cd);
+}
+
+void CheckAMODIAlive()
+{
+       CallbackMain(DCH_LAUNCH_AMODI, NULL, 0, 0);
+}
+
+void SendMoveMessage()
+{
+#if MOVESEND_POST
+       PostMessage(hwndCallback, WM_MOVESEND, MouseMoving ? 0 : -1, 0);
+#else
+//     CallbackMain(DCH_MOVESEND, pt, sizeof(*pt), 0);
+       MouseMoving = true;
+       if (SendMoveEvent) SetEvent(SendMoveEvent);
+#endif
+}
+void SendCancelMove()
+{
+#if MOVESEND_POST
+       PostMessage(hwndCallback, WM_MOVESEND, MouseMoving ? 0 : -1, 0);
+#else
+//     CallbackMain(DCH_MOVESEND, NULL, 0, (HWND)-1);
+       MouseMoving = false;
+       if (SendMoveEvent) SetEvent(SendMoveEvent);
+#endif
+}
+
+#if !MOVESEND_POST
+// main program\82ÌWindows message\8f\88\97\9d\82ª\8fd\82¢\82Æ\81ACalblackMain\82à\8fd\82­\82È\82é\82½\82ß\81A
+// mouse move\82Í\95Êthread\82Å\8f\88\97\9d
+DWORD WINAPI SendMoveThread(LPVOID vdParam)
+{
+       while(1){
+               if (WaitForSingleObject(SendMoveEvent, INFINITE) != WAIT_OBJECT_0){
+                       break;
+               }
+               CallbackMain(DCH_MOVESEND, NULL, 0, (HWND)(MouseMoving ? 0 : -1));
+       }
+       return 0;
+}
+#endif
+
+#if EXC_WOW64 && defined(_M_X64)
+void CheckWOW64()
+{
+       typedef BOOL (WINAPI *FNIsWow64Process)(HANDLE hProcess, PBOOL Wow64Process);
+
+       FNIsWow64Process _IsWow64Process = (FNIsWow64Process)GetProcAddress(GetModuleHandle("kernel32"),"IsWow64Process");
+       if (_IsWow64Process){
+               BOOL flag = FALSE;
+               if (_IsWow64Process(hProcess, &flag)){
+                       fWow64 = int_bool(flag);
+               }
+       }
+}
+#endif
+
+bool EnablePrivilege(LPTSTR lpszPrivilege, bool bEnable)
+{
+       BOOL             bResult;
+       LUID             luid;
+       HANDLE           hToken;
+       TOKEN_PRIVILEGES tokenPrivileges;
+
+       if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
+               return false;
+       
+       if (!LookupPrivilegeValue(NULL, lpszPrivilege, &luid)) {
+               CloseHandle(hToken);
+               return false;
+       }
+
+       tokenPrivileges.PrivilegeCount           = 1;
+       tokenPrivileges.Privileges[0].Luid       = luid;
+       tokenPrivileges.Privileges[0].Attributes = bEnable ? SE_PRIVILEGE_ENABLED : 0;
+       
+       bResult = AdjustTokenPrivileges(hToken, FALSE, &tokenPrivileges, sizeof(TOKEN_PRIVILEGES), NULL, NULL);
+       
+       CloseHandle(hToken);
+
+       return bResult && GetLastError() == ERROR_SUCCESS;
+}
+
+/*======================================================================//
+//     DllMain
+//----------------------------------------------------------------------//
+// Description:
+//
+// Arguments:
+//
+// Return Value:
+//
+//======================================================================*/
+#ifdef _MSC_VER
+BOOL WINAPI DllMain(HINSTANCE hInst, DWORD reason, LPVOID )
+#else
+int WINAPI DllEntryPoint(HINSTANCE hInst, DWORD reason, LPVOID)
+#endif
+{
+       switch ( reason ){
+               case DLL_PROCESS_ATTACH:
+                       hInstance = hInst;
+                       idProcess = GetCurrentProcessId();
+                       for (int i=0;i<2;i++){
+                               hProcess = OpenProcess( PROCESS_ALL_ACCESS|PROCESS_VM_WRITE|PROCESS_VM_OPERATION, TRUE, idProcess );
+                               if ( hProcess ){
+#if USE_DBW
+                                       DBW("Attach %d(%08X)-%d : %08X", idProcess, hProcess, attach++,_ExtTextOutA);
+#endif
+                                       break;
+                               } else {
+                                       DBW("OpenProcess Error: %08X %d", idProcess, GetLastError());
+                                       if (i==0){
+                                               if (!EnablePrivilege(SE_DEBUG_NAME, true)) {
+                                                       break;  // failed
+                                               }
+                                       }
+                               }
+                       }
+#if EXC_WOW64 && defined(_M_X64)
+                       CheckWOW64();
+#ifdef _WIN64
+                       if (fWow64){
+                               DBW("WOW64 true");
+                               return FALSE;
+                       }
+#else
+                       if (!fWow64){
+                               DBW("WOW64 false");
+                               return FALSE;
+                       }
+#endif
+                       DBW("fWow64=%d", fWow64);
+#endif
+                       if (siPageSize==0){
+                               SYSTEM_INFO si;
+                               GetSystemInfo( &si );
+                               siPageSize = si.dwPageSize;
+                       }
+                       hInstSHCore = LoadLibrary(_T("shcore.dll"));
+#if !MOVESEND_POST
+                       SendMoveEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
+                       CreateThread(NULL , 0 , SendMoveThread , NULL , 0 , &SendMoveThreadId);
+#endif
+                       break;
+               case DLL_PROCESS_DETACH:
+//                     UNPROTECT_SHARE();
+#if !MOVESEND_POST
+                       if (SendMoveEvent){
+                               CloseHandle(SendMoveEvent);
+                               SendMoveEvent = NULL;
+                       }
+#endif
+                       if (hInstSHCore){
+                               FreeLibrary(hInstSHCore);
+                               hInstSHCore = NULL;
+                       }
+#if USE_DBW
+                       DBW("Detach %d-%d", GetCurrentProcessId(),--attach);
+#endif
+                       if ( hProcess ){
+                               CloseHandle( hProcess );
+                       }
+                       break;
+       }
+       return TRUE;
+}
+//---------------------------------------------------------------------------
+static HWND hWin = NULL;
+static const char *clsname = "TDbgMsgForm";
+static const char *winname = "Debug Messenger";
+void dbw( const char *format, ... )
+{
+       if ( !hWin ){
+               hWin = FindWindowA( clsname, winname );
+               if ( !hWin ) return;
+       }
+       va_list ap;
+       va_start( ap, format );
+       char buf[ 2048 ];
+#ifdef _WIN64
+       strcpy(buf, "x64:");
+       wvsprintfA( buf+4, format, ap );
+#else
+       wvsprintfA( buf, format, ap );
+#endif
+       COPYDATASTRUCT cds;
+       cds.dwData = 1; // Indicate String
+       cds.cbData = (DWORD)strlen(buf);
+       cds.lpData = buf;
+       SendMessage( hWin, WM_COPYDATA, NULL, (LPARAM)&cds );
+       va_end( ap );
+}
diff --git a/DCHook/DCHook.def b/DCHook/DCHook.def
new file mode 100644 (file)
index 0000000..85ca43d
--- /dev/null
@@ -0,0 +1,16 @@
+LIBRARY         DCHOOK
+DESCRIPTION     'DC hook for event hot keys'
+
+SECTIONS
+       .sdata          READ WRITE SHARED
+       .sbss           READ WRITE SHARED
+       .stext          READ SHARED
+
+EXPORTS
+       Config  @1
+       Init    @2
+       Uninit  @3
+       Config2 @4
+       Capture @5
+       WaitForCaptureResult @6
+
diff --git a/DCHook/DCHook.h b/DCHook/DCHook.h
new file mode 100644 (file)
index 0000000..d19877b
--- /dev/null
@@ -0,0 +1,67 @@
+#ifndef __DCHOOK_H
+#define        __DCHOOK_H
+
+struct TDCHConfig {
+       int UseAMODI : 1;
+       int OnlyAMODI : 1;
+       int MoveSend : 1;
+       int OnlyImage : 1;
+       int ScaleX;
+       int ScaleY;
+       char AMODIPath[_MAX_PATH];
+};
+
+extern "C" {
+
+__declspec(dllexport) bool WINAPI Init( HWND, const char *module_name, bool windowsnt, const char *vxd_path );
+__declspec(dllexport) void WINAPI Uninit();
+__declspec(dllexport) unsigned int WINAPI Debug();
+
+typedef bool (WINAPI *FNDCHInit)( HWND, const char *module_name, bool windowsnt, const char *vxd_path );
+typedef void (WINAPI *FNDCHUninit)();
+typedef int (WINAPI *FNDCHConfig)( int clickonly, int keyaction, int keyflag );
+typedef int (WINAPI *FNDCHConfig2)( struct TDCHConfig *cfg );
+typedef int (WINAPI *FNDCHCapture)( HWND hwnd, POINT *pt, bool movesend, bool non_block );
+typedef int (WINAPI *FNDCHWaitForCaptureResult)( bool send_text, unsigned waittime );
+typedef unsigned int (WINAPI *FNDebug)();
+
+}
+
+/* WM_COPYSTRUCT message */
+#define        DCH_START               0x1000
+#define        DCH_END                 0x1001
+#define        DCH_EXTTEXTOUTA 0x1002
+#define        DCH_EXTTEXTOUTW 0x1003
+#define        DCH_HITTEXT1    0x1010
+#define        DCH_HITTEXT2    0x1011  // UNICODE\82Ì\82Ý(DCH_HITTEXT2\82Ì\82 \82Æ\81ADCH_HITTEXT3\82ª\82­\82é)
+#define        DCH_HITTEXT3    0x1012  // ANSI\82Ì\82Ý
+// UNICODE\82Å\88µ\82¢\82½\82¢\8fê\8d\87\82Í\81ADCH_HITTEXT2\82ÆDCH_HITTEXT3\82ð\8eg\97p\82·\82é
+// UNICODE\82Å\88µ\82¢\82½\82­\82È\82¢\8fê\8d\87(UNICODE->ANSI\95Ï\8a·\82ð\95K\97v\82Æ\82·\82é\8fê\8d\87)\82Í\81ADCH_HITTEXT1\82Ì\82Ý\82ð\8eg\97p\82·\82é
+#define        DCH_MOVESEND    0x0200  // DCH_END\82Æ\82Ì\91g\82Ý\8d\87\82í\82¹ or \92P\91Ì
+
+#define        DCH_MENU                0x1100  // DokoPop Menu
+#define        DCH_TOGGLE              0x1101  // Toggle Click Only
+#define        DCH_LAUNCH_AMODI 0x1102 // Launch AMODI if not alive
+
+/* Do not use 0x12xx!! */
+
+/* Key Definitions */
+#define        KA_POPUP                1
+#define        KA_MENU                 2
+#define        KA_TOGGLE               3
+#define        KA_POPUP_NC             0x10
+
+#define        KF_SHIFT                0x01
+#define        KF_CONTROL              0x02
+#define        KF_MENU                 0x04
+#define        KF_LWIN                 0x08
+#define        KF_RWIN                 0x10
+#define        KF_APPS                 0x20
+#define        KF_LEFTCLICK    0x40
+#define        KF_CLICKONLY    0x80
+#define        KF_LRCLICK              0x100
+#define        KF_MIDCLICK             0x200
+
+
+#endif // __DCHOOK_H
+
diff --git a/DCHook/DCHook.mak b/DCHook/DCHook.mak
new file mode 100644 (file)
index 0000000..72f5799
--- /dev/null
@@ -0,0 +1,100 @@
+# Microsoft Developer Studio Generated NMAKE File, Based on DCHook.dsp
+
+!IF "$(OS)" == "Windows_NT"
+NULL=
+!ELSE 
+NULL=nul
+!ENDIF 
+
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+OUTDIR=.
+INTDIR=.
+# Begin Custom Macros
+OutDir=.\.
+# End Custom Macros
+
+
+ALL : "$(OUTDIR)\DCHook.dll"
+
+
+
+CLEAN :
+       -@erase "$(INTDIR)\dchook.res"
+       -@erase "$(INTDIR)\dchook.obj"
+       -@erase "$(INTDIR)\dchook.sbr"
+       -@erase "$(OUTDIR)\DCHook.dll"
+       -@erase "$(OUTDIR)\DCHook.exp"
+       -@erase "$(OUTDIR)\DCHook.lib"
+       -@erase "$(OUTDIR)\DCHook.map"
+
+"$(OUTDIR)" :
+    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
+
+CPP_PROJ=/nologo /ML /W4 /GX /G4 /GA /O1 /I "$(MSAADEV)\inc32" /D "WIN32" /D "NDEBUG"\
+ /D "_WINDOWS" /FR"$(INTDIR)\\" /Fp"$(INTDIR)\DCHook.pch" /YX /Fo"$(INTDIR)\\"\
+ /Fd"$(INTDIR)\\" /FD /c 
+CPP_OBJS=./
+CPP_SBRS=./
+MTL_PROJ=/nologo /I "$(MSAADEV)\inc32" /D "NDEBUG" /mktyplib203 /win32 
+RSC_PROJ=/l 0x409 /fo"$(INTDIR)\dchook.res" /i "$(MSAADEV)\inc32" /d "NDEBUG" 
+
+LINK32=link.exe
+LINK32_FLAGS=user32.lib kernel32.lib gdi32.lib advapi32.lib \
+ /nologo /subsystem:windows /dll /incremental:no\
+ /pdb:"$(OUTDIR)\DCHook.pdb" /map:"$(INTDIR)\DCHook.map" /machine:I386\
+ /def:".\dchook.def" /out:"$(OUTDIR)\DCHook.dll"\
+ /implib:"$(OUTDIR)\DCHook.lib" /libpath:"$(MSAADEV)\lib" 
+DEF_FILE= \
+       ".\dchook.def"
+LINK32_OBJS= \
+       "$(INTDIR)\dchook.res" \
+       "$(INTDIR)\dchook.obj"
+
+"$(OUTDIR)\DCHook.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
+    $(LINK32) @<<
+  $(LINK32_FLAGS) $(LINK32_OBJS)
+<<
+
+.c{$(CPP_OBJS)}.obj::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+.cpp{$(CPP_OBJS)}.obj::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+.cxx{$(CPP_OBJS)}.obj::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+.c{$(CPP_SBRS)}.sbr::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+.cpp{$(CPP_SBRS)}.sbr::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+.cxx{$(CPP_SBRS)}.sbr::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+SOURCE=.\dchook.rc
+
+"$(INTDIR)\dchook.res" : $(SOURCE) "$(INTDIR)"
+       $(RSC) $(RSC_PROJ) $(SOURCE)
+
+SOURCE=.\dchook.cpp
+DEP_CPP_KEYS_= "DCHook.h"
+
+"$(INTDIR)\dchook.obj" : $(SOURCE) $(DEP_CPP_KEYS_) "$(INTDIR)"
+
diff --git a/DCHook/DCHook.sln b/DCHook/DCHook.sln
new file mode 100644 (file)
index 0000000..e8518fa
--- /dev/null
@@ -0,0 +1,25 @@
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DCHook", "DCHook.vcxproj", "{8C65CE15-64F8-43E6-968D-DBBB96858BB2}"
+EndProject
+Global
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution
+               Debug|Win32 = Debug|Win32
+               Debug|x64 = Debug|x64
+               Release|Win32 = Release|Win32
+               Release|x64 = Release|x64
+       EndGlobalSection
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution
+               {8C65CE15-64F8-43E6-968D-DBBB96858BB2}.Debug|Win32.ActiveCfg = Debug|Win32
+               {8C65CE15-64F8-43E6-968D-DBBB96858BB2}.Debug|Win32.Build.0 = Debug|Win32
+               {8C65CE15-64F8-43E6-968D-DBBB96858BB2}.Debug|x64.ActiveCfg = Debug|x64
+               {8C65CE15-64F8-43E6-968D-DBBB96858BB2}.Debug|x64.Build.0 = Debug|x64
+               {8C65CE15-64F8-43E6-968D-DBBB96858BB2}.Release|Win32.ActiveCfg = Release|Win32
+               {8C65CE15-64F8-43E6-968D-DBBB96858BB2}.Release|Win32.Build.0 = Release|Win32
+               {8C65CE15-64F8-43E6-968D-DBBB96858BB2}.Release|x64.ActiveCfg = Release|x64
+               {8C65CE15-64F8-43E6-968D-DBBB96858BB2}.Release|x64.Build.0 = Release|x64
+       EndGlobalSection
+       GlobalSection(SolutionProperties) = preSolution
+               HideSolutionNode = FALSE
+       EndGlobalSection
+EndGlobal
diff --git a/DCHook/DCHook.vcproj b/DCHook/DCHook.vcproj
new file mode 100644 (file)
index 0000000..2023513
--- /dev/null
@@ -0,0 +1,376 @@
+<?xml version="1.0" encoding="shift_jis"?>
+<VisualStudioProject
+       ProjectType="Visual C++"
+       Version="9.00"
+       Name="DCHook"
+       ProjectGUID="{8C65CE15-64F8-43E6-968D-DBBB96858BB2}"
+       Keyword="Win32Proj"
+       TargetFrameworkVersion="131072"
+       >
+       <Platforms>
+               <Platform
+                       Name="Win32"
+               />
+               <Platform
+                       Name="x64"
+               />
+       </Platforms>
+       <ToolFiles>
+       </ToolFiles>
+       <Configurations>
+               <Configuration
+                       Name="Debug|Win32"
+                       OutputDirectory="Debug"
+                       IntermediateDirectory="Debug"
+                       ConfigurationType="2"
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+                       CharacterSet="2"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               Optimization="0"
+                               PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;DCHOOK_EXPORTS"
+                               MinimalRebuild="true"
+                               BasicRuntimeChecks="3"
+                               RuntimeLibrary="1"
+                               UsePrecompiledHeader="0"
+                               WarningLevel="3"
+                               Detect64BitPortabilityProblems="false"
+                               DebugInformationFormat="4"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               OutputFile="$(OutDir)/DCHook.dll"
+                               LinkIncremental="2"
+                               ModuleDefinitionFile="DCHook.def"
+                               GenerateDebugInformation="true"
+                               ProgramDatabaseFile="$(OutDir)/DCHook.pdb"
+                               SubSystem="2"
+                               RandomizedBaseAddress="1"
+                               DataExecutionPrevention="0"
+                               ImportLibrary="$(OutDir)/DCHook.lib"
+                               TargetMachine="1"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCManifestTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCAppVerifierTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+               <Configuration
+                       Name="Release|Win32"
+                       OutputDirectory="Release"
+                       IntermediateDirectory="Release"
+                       ConfigurationType="2"
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+                       CharacterSet="2"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;DCHOOK_EXPORTS"
+                               RuntimeLibrary="0"
+                               UsePrecompiledHeader="0"
+                               WarningLevel="3"
+                               Detect64BitPortabilityProblems="false"
+                               DebugInformationFormat="3"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               OutputFile="$(OutDir)/DCHook.dll"
+                               LinkIncremental="1"
+                               ModuleDefinitionFile="DCHook.def"
+                               GenerateDebugInformation="true"
+                               SubSystem="2"
+                               OptimizeReferences="2"
+                               EnableCOMDATFolding="2"
+                               RandomizedBaseAddress="1"
+                               DataExecutionPrevention="0"
+                               ImportLibrary="$(OutDir)/DCHook.lib"
+                               TargetMachine="1"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCManifestTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCAppVerifierTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+               <Configuration
+                       Name="Debug|x64"
+                       OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
+                       IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
+                       ConfigurationType="2"
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+                       CharacterSet="2"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                               TargetEnvironment="3"
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               Optimization="0"
+                               PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;DCHOOK_EXPORTS"
+                               MinimalRebuild="true"
+                               BasicRuntimeChecks="3"
+                               RuntimeLibrary="1"
+                               UsePrecompiledHeader="0"
+                               WarningLevel="3"
+                               Detect64BitPortabilityProblems="false"
+                               DebugInformationFormat="4"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               OutputFile="$(OutDir)/DCHook.dll"
+                               LinkIncremental="2"
+                               ModuleDefinitionFile="DCHook.def"
+                               GenerateDebugInformation="true"
+                               ProgramDatabaseFile="$(OutDir)/DCHook.pdb"
+                               SubSystem="2"
+                               RandomizedBaseAddress="1"
+                               DataExecutionPrevention="0"
+                               ImportLibrary="$(OutDir)/DCHook.lib"
+                               TargetMachine="17"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCManifestTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCAppVerifierTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+               <Configuration
+                       Name="Release|x64"
+                       OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
+                       IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
+                       ConfigurationType="2"
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+                       CharacterSet="2"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                               TargetEnvironment="3"
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;DCHOOK_EXPORTS"
+                               RuntimeLibrary="0"
+                               UsePrecompiledHeader="0"
+                               WarningLevel="3"
+                               Detect64BitPortabilityProblems="false"
+                               DebugInformationFormat="3"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               OutputFile="$(OutDir)/DCHook.dll"
+                               LinkIncremental="1"
+                               ModuleDefinitionFile="DCHook.def"
+                               GenerateDebugInformation="true"
+                               SubSystem="2"
+                               OptimizeReferences="2"
+                               EnableCOMDATFolding="2"
+                               RandomizedBaseAddress="1"
+                               DataExecutionPrevention="0"
+                               ImportLibrary="$(OutDir)/DCHook.lib"
+                               TargetMachine="17"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCManifestTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCAppVerifierTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+       </Configurations>
+       <References>
+       </References>
+       <Files>
+               <Filter
+                       Name="\83\\81[\83\83t\83@\83C\83\8b"
+                       Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+                       UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+                       >
+                       <File
+                               RelativePath=".\DCHook.cpp"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\DCHook.def"
+                               >
+                       </File>
+                       <File
+                               RelativePath=".\MonitorScale.cpp"
+                               >
+                       </File>
+               </Filter>
+               <Filter
+                       Name="\83w\83b\83_\81\83t\83@\83C\83\8b"
+                       Filter="h;hpp;hxx;hm;inl;inc;xsd"
+                       UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+                       >
+               </Filter>
+               <Filter
+                       Name="\83\8a\83\\81[\83\83t\83@\83C\83\8b"
+                       Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
+                       UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+                       >
+                       <File
+                               RelativePath=".\dchook.rc"
+                               >
+                       </File>
+               </Filter>
+       </Files>
+       <Globals>
+       </Globals>
+</VisualStudioProject>
diff --git a/DCHook/DCHook.vcxproj b/DCHook/DCHook.vcxproj
new file mode 100644 (file)
index 0000000..0cba8e7
--- /dev/null
@@ -0,0 +1,167 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup Label="ProjectConfigurations">
+    <ProjectConfiguration Include="Debug|Win32">
+      <Configuration>Debug</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Debug|x64">
+      <Configuration>Debug</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|Win32">
+      <Configuration>Release</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|x64">
+      <Configuration>Release</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+  </ItemGroup>
+  <PropertyGroup Label="Globals">
+    <ProjectGuid>{8C65CE15-64F8-43E6-968D-DBBB96858BB2}</ProjectGuid>
+    <Keyword>Win32Proj</Keyword>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
+    <CharacterSet>MultiByte</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
+    <CharacterSet>MultiByte</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
+    <CharacterSet>MultiByte</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
+    <CharacterSet>MultiByte</CharacterSet>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+  <ImportGroup Label="ExtensionSettings">
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <PropertyGroup Label="UserMacros" />
+  <PropertyGroup>
+    <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
+    <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Platform)\$(Configuration)</OutDir>
+    <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Platform)\$(Configuration)</OutDir>
+    <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Debug\</IntDir>
+    <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Debug\</IntDir>
+    <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
+    <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
+    <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Platform)\$(Configuration)</OutDir>
+    <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Platform)\$(Configuration)</OutDir>
+    <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Release\</IntDir>
+    <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Release\</IntDir>
+    <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
+    <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
+  </PropertyGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <ClCompile>
+      <Optimization>Disabled</Optimization>
+      <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;DCHOOK_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <MinimalRebuild>true</MinimalRebuild>
+      <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+      <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
+    </ClCompile>
+    <Link>
+      <OutputFile>$(OutDir)DCHook.dll</OutputFile>
+      <ModuleDefinitionFile>DCHook.def</ModuleDefinitionFile>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <ProgramDatabaseFile>$(OutDir)DCHook.pdb</ProgramDatabaseFile>
+      <SubSystem>Windows</SubSystem>
+      <ImportLibrary>$(OutDir)DCHook.lib</ImportLibrary>
+      <TargetMachine>MachineX86</TargetMachine>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <ClCompile>
+      <Optimization>Disabled</Optimization>
+      <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;DCHOOK_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+      <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+    </ClCompile>
+    <Link>
+      <OutputFile>$(OutDir)DCHook.dll</OutputFile>
+      <ModuleDefinitionFile>DCHook.def</ModuleDefinitionFile>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <ProgramDatabaseFile>$(OutDir)DCHook.pdb</ProgramDatabaseFile>
+      <SubSystem>Windows</SubSystem>
+      <ImportLibrary>$(OutDir)DCHook.lib</ImportLibrary>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <ClCompile>
+      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;DCHOOK_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+    </ClCompile>
+    <Link>
+      <OutputFile>$(OutDir)DCHook.dll</OutputFile>
+      <ModuleDefinitionFile>DCHook.def</ModuleDefinitionFile>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <SubSystem>Windows</SubSystem>
+      <OptimizeReferences>true</OptimizeReferences>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <ImportLibrary>$(OutDir)DCHook.lib</ImportLibrary>
+      <TargetMachine>MachineX86</TargetMachine>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <ClCompile>
+      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;DCHOOK_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+    </ClCompile>
+    <Link>
+      <OutputFile>$(OutDir)DCHook.dll</OutputFile>
+      <ModuleDefinitionFile>DCHook.def</ModuleDefinitionFile>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <SubSystem>Windows</SubSystem>
+      <OptimizeReferences>true</OptimizeReferences>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <ImportLibrary>$(OutDir)DCHook.lib</ImportLibrary>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemGroup>
+    <ClCompile Include="DCHook.cpp" />
+    <ClCompile Include="MonitorScale.cpp" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="DCHook.def" />
+  </ItemGroup>
+  <ItemGroup>
+    <ResourceCompile Include="dchook.rc" />
+  </ItemGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+  <ImportGroup Label="ExtensionTargets">
+  </ImportGroup>
+</Project>
\ No newline at end of file
diff --git a/DCHook/DCHook.vcxproj.filters b/DCHook/DCHook.vcxproj.filters
new file mode 100644 (file)
index 0000000..245a5fc
--- /dev/null
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup>
+    <Filter Include="ソース ファイル">
+      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+      <Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+    </Filter>
+    <Filter Include="ヘッダー ファイル">
+      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
+    </Filter>
+    <Filter Include="リソース ファイル">
+      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
+      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx</Extensions>
+    </Filter>
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="DCHook.cpp">
+      <Filter>ソース ファイル</Filter>
+    </ClCompile>
+    <ClCompile Include="MonitorScale.cpp">
+      <Filter>ソース ファイル</Filter>
+    </ClCompile>
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="DCHook.def">
+      <Filter>ソース ファイル</Filter>
+    </None>
+  </ItemGroup>
+  <ItemGroup>
+    <ResourceCompile Include="dchook.rc">
+      <Filter>リソース ファイル</Filter>
+    </ResourceCompile>
+  </ItemGroup>
+</Project>
\ No newline at end of file
diff --git a/DCHook/MonitorScale.cpp b/DCHook/MonitorScale.cpp
new file mode 100644 (file)
index 0000000..5de8714
--- /dev/null
@@ -0,0 +1,270 @@
+#include <windows.h>
+#include <tchar.h>
+
+#if WINVER<0x0601
+#define QDC_ALL_PATHS                   0x00000001
+#define QDC_ONLY_ACTIVE_PATHS           0x00000002
+#define QDC_DATABASE_CURRENT            0x00000004
+typedef enum
+{
+    DISPLAYCONFIG_OUTPUT_TECHNOLOGY_OTHER                   = -1,
+    DISPLAYCONFIG_OUTPUT_TECHNOLOGY_HD15                    =  0,
+    DISPLAYCONFIG_OUTPUT_TECHNOLOGY_SVIDEO                  =  1,
+    DISPLAYCONFIG_OUTPUT_TECHNOLOGY_COMPOSITE_VIDEO         =  2,
+    DISPLAYCONFIG_OUTPUT_TECHNOLOGY_COMPONENT_VIDEO         =  3,
+    DISPLAYCONFIG_OUTPUT_TECHNOLOGY_DVI                     =  4,
+    DISPLAYCONFIG_OUTPUT_TECHNOLOGY_HDMI                    =  5,
+    DISPLAYCONFIG_OUTPUT_TECHNOLOGY_LVDS                    =  6,
+    DISPLAYCONFIG_OUTPUT_TECHNOLOGY_D_JPN                   =  8,
+    DISPLAYCONFIG_OUTPUT_TECHNOLOGY_SDI                     =  9,
+    DISPLAYCONFIG_OUTPUT_TECHNOLOGY_DISPLAYPORT_EXTERNAL    = 10,
+    DISPLAYCONFIG_OUTPUT_TECHNOLOGY_DISPLAYPORT_EMBEDDED    = 11,
+    DISPLAYCONFIG_OUTPUT_TECHNOLOGY_UDI_EXTERNAL            = 12,
+    DISPLAYCONFIG_OUTPUT_TECHNOLOGY_UDI_EMBEDDED            = 13,
+    DISPLAYCONFIG_OUTPUT_TECHNOLOGY_SDTVDONGLE              = 14,
+    DISPLAYCONFIG_OUTPUT_TECHNOLOGY_INTERNAL                = 0x80000000,
+    DISPLAYCONFIG_OUTPUT_TECHNOLOGY_FORCE_UINT32            = 0xFFFFFFFF
+} DISPLAYCONFIG_VIDEO_OUTPUT_TECHNOLOGY;
+typedef enum
+{
+    DISPLAYCONFIG_ROTATION_IDENTITY     = 1,
+    DISPLAYCONFIG_ROTATION_ROTATE90     = 2,
+    DISPLAYCONFIG_ROTATION_ROTATE180    = 3,
+    DISPLAYCONFIG_ROTATION_ROTATE270    = 4,
+    DISPLAYCONFIG_ROTATION_FORCE_UINT32 = 0xFFFFFFFF
+} DISPLAYCONFIG_ROTATION;
+typedef enum
+{
+    DISPLAYCONFIG_SCALING_IDENTITY                  = 1,
+    DISPLAYCONFIG_SCALING_CENTERED                  = 2,
+    DISPLAYCONFIG_SCALING_STRETCHED                 = 3,
+    DISPLAYCONFIG_SCALING_ASPECTRATIOCENTEREDMAX    = 4,
+    DISPLAYCONFIG_SCALING_CUSTOM                    = 5,
+    DISPLAYCONFIG_SCALING_PREFERRED                 = 128,
+    DISPLAYCONFIG_SCALING_FORCE_UINT32              = 0xFFFFFFFF
+} DISPLAYCONFIG_SCALING;
+typedef struct DISPLAYCONFIG_RATIONAL
+{
+    UINT32    Numerator;
+    UINT32    Denominator;
+} DISPLAYCONFIG_RATIONAL;
+typedef enum
+{
+       DISPLAYCONFIG_SCANLINE_ORDERING_UNSPECIFIED                 = 0,
+       DISPLAYCONFIG_SCANLINE_ORDERING_PROGRESSIVE                 = 1,
+       DISPLAYCONFIG_SCANLINE_ORDERING_INTERLACED                  = 2,
+       DISPLAYCONFIG_SCANLINE_ORDERING_INTERLACED_UPPERFIELDFIRST  = DISPLAYCONFIG_SCANLINE_ORDERING_INTERLACED,
+       DISPLAYCONFIG_SCANLINE_ORDERING_INTERLACED_LOWERFIELDFIRST  = 3,
+       DISPLAYCONFIG_SCANLINE_ORDERING_FORCE_UINT32                = 0xFFFFFFFF
+} DISPLAYCONFIG_SCANLINE_ORDERING;
+typedef enum
+{
+    DISPLAYCONFIG_MODE_INFO_TYPE_SOURCE = 1,
+    DISPLAYCONFIG_MODE_INFO_TYPE_TARGET = 2,
+    DISPLAYCONFIG_MODE_INFO_TYPE_FORCE_UINT32 = 0xFFFFFFFF
+} DISPLAYCONFIG_MODE_INFO_TYPE;
+typedef struct DISPLAYCONFIG_2DREGION
+{
+    UINT32 cx;
+    UINT32 cy;
+} DISPLAYCONFIG_2DREGION;
+typedef struct DISPLAYCONFIG_VIDEO_SIGNAL_INFO
+{
+       UINT64                          pixelRate;
+       DISPLAYCONFIG_RATIONAL          hSyncFreq;
+       DISPLAYCONFIG_RATIONAL          vSyncFreq;
+       DISPLAYCONFIG_2DREGION          activeSize;
+       DISPLAYCONFIG_2DREGION          totalSize;
+       UINT32                          videoStandard;
+       DISPLAYCONFIG_SCANLINE_ORDERING scanLineOrdering;
+} DISPLAYCONFIG_VIDEO_SIGNAL_INFO;
+typedef enum
+{
+    DISPLAYCONFIG_PIXELFORMAT_8BPP          = 1,
+    DISPLAYCONFIG_PIXELFORMAT_16BPP         = 2,
+    DISPLAYCONFIG_PIXELFORMAT_24BPP         = 3,
+    DISPLAYCONFIG_PIXELFORMAT_32BPP         = 4,
+    DISPLAYCONFIG_PIXELFORMAT_NONGDI        = 5,
+    DISPLAYCONFIG_PIXELFORMAT_FORCE_UINT32  = 0xffffffff
+} DISPLAYCONFIG_PIXELFORMAT;
+typedef enum
+{
+      DISPLAYCONFIG_TOPOLOGY_INTERNAL       = 0x00000001,
+      DISPLAYCONFIG_TOPOLOGY_CLONE          = 0x00000002,
+      DISPLAYCONFIG_TOPOLOGY_EXTEND         = 0x00000004,
+      DISPLAYCONFIG_TOPOLOGY_EXTERNAL       = 0x00000008,
+      DISPLAYCONFIG_TOPOLOGY_FORCE_UINT32   = 0xFFFFFFFF
+} DISPLAYCONFIG_TOPOLOGY_ID;
+typedef enum
+{
+      DISPLAYCONFIG_DEVICE_INFO_GET_SOURCE_NAME             = 1,
+      DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_NAME             = 2,
+      DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_PREFERRED_MODE   = 3,
+      DISPLAYCONFIG_DEVICE_INFO_GET_ADAPTER_NAME            = 4,
+      DISPLAYCONFIG_DEVICE_INFO_SET_TARGET_PERSISTENCE      = 5,
+      DISPLAYCONFIG_DEVICE_INFO_FORCE_UINT32                = 0xFFFFFFFF
+} DISPLAYCONFIG_DEVICE_INFO_TYPE;
+
+typedef struct DISPLAYCONFIG_PATH_SOURCE_INFO
+{
+       LUID    adapterId;
+       UINT32  id;
+       UINT32  modeInfoIdx;
+       UINT32  statusFlags;
+} DISPLAYCONFIG_PATH_SOURCE_INFO;
+typedef struct DISPLAYCONFIG_PATH_TARGET_INFO
+{
+       LUID                                    adapterId;
+       UINT32                                  id;
+       UINT32                                  modeInfoIdx;
+       DISPLAYCONFIG_VIDEO_OUTPUT_TECHNOLOGY   outputTechnology;
+       DISPLAYCONFIG_ROTATION                  rotation;
+       DISPLAYCONFIG_SCALING                   scaling;
+       DISPLAYCONFIG_RATIONAL                  refreshRate;
+       DISPLAYCONFIG_SCANLINE_ORDERING         scanLineOrdering;
+       BOOL                                    targetAvailable;
+       UINT32                                  statusFlags;
+} DISPLAYCONFIG_PATH_TARGET_INFO;
+typedef struct DISPLAYCONFIG_PATH_INFO
+{
+       DISPLAYCONFIG_PATH_SOURCE_INFO  sourceInfo;
+       DISPLAYCONFIG_PATH_TARGET_INFO  targetInfo;
+       UINT32                          flags;
+} DISPLAYCONFIG_PATH_INFO;
+typedef struct DISPLAYCONFIG_TARGET_MODE
+{
+    DISPLAYCONFIG_VIDEO_SIGNAL_INFO   targetVideoSignalInfo;
+} DISPLAYCONFIG_TARGET_MODE;
+typedef struct DISPLAYCONFIG_SOURCE_MODE
+{
+    UINT32                      width;
+    UINT32                      height;
+    DISPLAYCONFIG_PIXELFORMAT   pixelFormat;
+    POINTL                      position;
+} DISPLAYCONFIG_SOURCE_MODE;
+typedef struct DISPLAYCONFIG_MODE_INFO
+{
+       DISPLAYCONFIG_MODE_INFO_TYPE    infoType;
+       UINT32                          id;
+       LUID                            adapterId;
+       union
+       {
+               DISPLAYCONFIG_TARGET_MODE   targetMode;
+               DISPLAYCONFIG_SOURCE_MODE   sourceMode;
+       };
+} DISPLAYCONFIG_MODE_INFO;
+typedef struct DISPLAYCONFIG_DEVICE_INFO_HEADER
+{
+       DISPLAYCONFIG_DEVICE_INFO_TYPE  type;
+       UINT32                          size;
+       LUID                            adapterId;
+       UINT32                          id;
+} DISPLAYCONFIG_DEVICE_INFO_HEADER;
+
+#endif
+
+typedef WINUSERAPI LONG (WINAPI *FNGetDisplayConfigBufferSizes)(UINT32 flags, UINT32* numPathArrayElements, UINT32* numModeInfoArrayElements);
+typedef WINUSERAPI LONG (WINAPI *FNSetDisplayConfig)(UINT32 numPathArrayElements, DISPLAYCONFIG_PATH_INFO* pathArray, UINT32 numModeInfoArrayElements, DISPLAYCONFIG_MODE_INFO* modeInfoArray, UINT32 flags);
+typedef WINUSERAPI LONG (WINAPI *FNQueryDisplayConfig)(UINT32 flags, UINT32* numPathArrayElements, DISPLAYCONFIG_PATH_INFO* pathArray, UINT32* numModeInfoArrayElements, DISPLAYCONFIG_MODE_INFO* modeInfoArray, DISPLAYCONFIG_TOPOLOGY_ID* currentTopologyId);
+typedef WINUSERAPI LONG (WINAPI *FNDisplayConfigGetDeviceInfo)(DISPLAYCONFIG_DEVICE_INFO_HEADER* requestPacket);
+
+class TDllHandle {
+protected:
+       HINSTANCE hInst;
+public:
+       TDllHandle(HINSTANCE _hInst)
+               :hInst(_hInst)
+       {
+       }
+       ~TDllHandle(){
+               if (hInst) FreeLibrary(hInst);
+       }
+       HINSTANCE inst(){ return hInst; }
+       operator HINSTANCE (){ return hInst; }
+       FARPROC GetProcAddress(LPCSTR name)
+               { return ::GetProcAddress(hInst, name); }
+};
+
+static TDllHandle *dllHandle = NULL;
+static FNGetDisplayConfigBufferSizes _GetDisplayConfigBufferSizes;
+static FNQueryDisplayConfig _QueryDisplayConfig;
+static bool called = false;
+static HMONITOR hPrevMonitor = NULL;
+static int prevDpi = 0;
+class TDestructor {
+public:
+       ~TDestructor(){ if (dllHandle){ delete dllHandle; dllHandle = NULL; } }
+} destructor;
+
+int GetMonitorScale()
+{
+       int dpi = 96;
+
+       if (!called){
+               called = true;
+               HINSTANCE hDll = LoadLibrary( _T("user32") );
+               if (!hDll)
+                       return dpi;
+
+               TDllHandle hInst(hDll);
+               dllHandle = new TDllHandle(hDll);
+
+               _GetDisplayConfigBufferSizes = (FNGetDisplayConfigBufferSizes)dllHandle->GetProcAddress("GetDisplayConfigBufferSizes");
+               if (!_GetDisplayConfigBufferSizes) return dpi;
+               _QueryDisplayConfig = (FNQueryDisplayConfig)dllHandle->GetProcAddress("QueryDisplayConfig");
+               if (!_QueryDisplayConfig) return dpi;
+       }
+
+       if (!dllHandle) return dpi;
+
+       POINT pt;
+       GetCursorPos( &pt );
+       HMONITOR hMonitor = MonitorFromPoint( pt, MONITOR_DEFAULTTONULL );
+       if (!hMonitor) return dpi;
+
+       if (hMonitor == hPrevMonitor){
+               return prevDpi;
+       }
+       hPrevMonitor = hMonitor;
+
+       MONITORINFOEX LogicalMonitorInfo;
+       LogicalMonitorInfo.cbSize = sizeof(MONITORINFOEX);
+       GetMonitorInfo(hMonitor, &LogicalMonitorInfo);
+       int LogicalMonitorWidth = LogicalMonitorInfo.rcMonitor.right - LogicalMonitorInfo.rcMonitor.left;
+
+       int LogicalDesktopWidth = GetSystemMetrics(SM_CXVIRTUALSCREEN);
+
+       UINT32 numofpath;
+       UINT32 numofmode;
+       _GetDisplayConfigBufferSizes(QDC_DATABASE_CURRENT, &numofpath, &numofmode);
+
+       DISPLAYCONFIG_PATH_INFO *dpis = new DISPLAYCONFIG_PATH_INFO[numofpath];
+       DISPLAYCONFIG_MODE_INFO *pModeInfoArray = new DISPLAYCONFIG_MODE_INFO[numofmode];
+       DISPLAYCONFIG_TOPOLOGY_ID tid;
+       _QueryDisplayConfig(QDC_DATABASE_CURRENT, &numofpath, dpis, &numofmode, pModeInfoArray, &tid);  //TODO: Windows7 or later
+
+       int PhysicalDesktopWidth = LogicalDesktopWidth;
+       int PhysicalMonitorWidth = LogicalMonitorWidth;
+       
+       for (int i=0;i<(int)numofmode;i++){
+               if (pModeInfoArray[i].infoType == DISPLAYCONFIG_MODE_INFO_TYPE_SOURCE){
+                       //DBW("%d: %d", i, pModeInfoArray[i].sourceMode.width);
+                       PhysicalDesktopWidth = pModeInfoArray[i].sourceMode.width;
+                       //int PhysicalDesktopWidth = 
+                       //int ScaleFactor = (LogicalMonitorWidth/LogicalDesktopWidth) / (PhysicalMonitorWidth/PhysicalDesktopWidth)
+                       //return 96 * 1;
+               } else
+               if (pModeInfoArray[i].infoType == DISPLAYCONFIG_MODE_INFO_TYPE_TARGET){
+                       PhysicalMonitorWidth = pModeInfoArray[i].targetMode.targetVideoSignalInfo.activeSize.cx;
+                       //DBW("%d: %d", i, PhysicalMonitorWidth);
+               }
+       }
+
+       //int PhysicalMonitorWidth = pModeInfoArray[i].sourceMode.width;
+       //int ScaleFactor = (LogicalMonitorWidth/LogicalDesktopWidth) / (PhysicalMonitorWidth/PhysicalDesktopWidth)
+
+       delete[] dpis;
+       delete[] pModeInfoArray;
+
+       return prevDpi = dpi * PhysicalDesktopWidth / LogicalDesktopWidth;
+}
diff --git a/DCHook/MonitorScale.h b/DCHook/MonitorScale.h
new file mode 100644 (file)
index 0000000..c900b8e
--- /dev/null
@@ -0,0 +1,6 @@
+#ifndef __MonitorScale_h
+#define        __MonitorScale_h
+
+int GetMonitorScale();
+
+#endif
diff --git a/DCHook/VS2003/DCHook.sln b/DCHook/VS2003/DCHook.sln
new file mode 100644 (file)
index 0000000..9b639fc
--- /dev/null
@@ -0,0 +1,21 @@
+Microsoft Visual Studio Solution File, Format Version 8.00
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DCHook", "DCHook.vcproj", "{8C65CE15-64F8-43E6-968D-DBBB96858BB2}"
+       ProjectSection(ProjectDependencies) = postProject
+       EndProjectSection
+EndProject
+Global
+       GlobalSection(SolutionConfiguration) = preSolution
+               Debug = Debug
+               Release = Release
+       EndGlobalSection
+       GlobalSection(ProjectConfiguration) = postSolution
+               {8C65CE15-64F8-43E6-968D-DBBB96858BB2}.Debug.ActiveCfg = Debug|Win32
+               {8C65CE15-64F8-43E6-968D-DBBB96858BB2}.Debug.Build.0 = Debug|Win32
+               {8C65CE15-64F8-43E6-968D-DBBB96858BB2}.Release.ActiveCfg = Release|Win32
+               {8C65CE15-64F8-43E6-968D-DBBB96858BB2}.Release.Build.0 = Release|Win32
+       EndGlobalSection
+       GlobalSection(ExtensibilityGlobals) = postSolution
+       EndGlobalSection
+       GlobalSection(ExtensibilityAddIns) = postSolution
+       EndGlobalSection
+EndGlobal
diff --git a/DCHook/VS2003/DCHook.vcproj b/DCHook/VS2003/DCHook.vcproj
new file mode 100644 (file)
index 0000000..c7274d2
--- /dev/null
@@ -0,0 +1,145 @@
+<?xml version="1.0" encoding="shift_jis"?>
+<VisualStudioProject
+       ProjectType="Visual C++"
+       Version="7.10"
+       Name="DCHook"
+       ProjectGUID="{8C65CE15-64F8-43E6-968D-DBBB96858BB2}"
+       Keyword="Win32Proj">
+       <Platforms>
+               <Platform
+                       Name="Win32"/>
+       </Platforms>
+       <Configurations>
+               <Configuration
+                       Name="Debug|Win32"
+                       OutputDirectory="Debug"
+                       IntermediateDirectory="Debug"
+                       ConfigurationType="2"
+                       CharacterSet="2">
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               Optimization="0"
+                               PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;DCHOOK_EXPORTS"
+                               MinimalRebuild="TRUE"
+                               BasicRuntimeChecks="3"
+                               RuntimeLibrary="1"
+                               UsePrecompiledHeader="2"
+                               WarningLevel="3"
+                               Detect64BitPortabilityProblems="TRUE"
+                               DebugInformationFormat="4"/>
+                       <Tool
+                               Name="VCCustomBuildTool"/>
+                       <Tool
+                               Name="VCLinkerTool"
+                               OutputFile="$(OutDir)/DCHook.dll"
+                               LinkIncremental="2"
+                               ModuleDefinitionFile="DCHook.def"
+                               GenerateDebugInformation="TRUE"
+                               ProgramDatabaseFile="$(OutDir)/DCHook.pdb"
+                               SubSystem="2"
+                               ImportLibrary="$(OutDir)/DCHook.lib"
+                               TargetMachine="1"/>
+                       <Tool
+                               Name="VCMIDLTool"/>
+                       <Tool
+                               Name="VCPostBuildEventTool"/>
+                       <Tool
+                               Name="VCPreBuildEventTool"/>
+                       <Tool
+                               Name="VCPreLinkEventTool"/>
+                       <Tool
+                               Name="VCResourceCompilerTool"/>
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"/>
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"/>
+                       <Tool
+                               Name="VCWebDeploymentTool"/>
+                       <Tool
+                               Name="VCManagedWrapperGeneratorTool"/>
+                       <Tool
+                               Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+               </Configuration>
+               <Configuration
+                       Name="Release|Win32"
+                       OutputDirectory="Release"
+                       IntermediateDirectory="Release"
+                       ConfigurationType="2"
+                       CharacterSet="2">
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;DCHOOK_EXPORTS"
+                               RuntimeLibrary="0"
+                               UsePrecompiledHeader="2"
+                               WarningLevel="3"
+                               Detect64BitPortabilityProblems="TRUE"
+                               DebugInformationFormat="3"/>
+                       <Tool
+                               Name="VCCustomBuildTool"/>
+                       <Tool
+                               Name="VCLinkerTool"
+                               OutputFile="$(OutDir)/DCHook.dll"
+                               LinkIncremental="1"
+                               ModuleDefinitionFile="DCHook.def"
+                               GenerateDebugInformation="TRUE"
+                               SubSystem="2"
+                               OptimizeReferences="2"
+                               EnableCOMDATFolding="2"
+                               ImportLibrary="$(OutDir)/DCHook.lib"
+                               TargetMachine="1"/>
+                       <Tool
+                               Name="VCMIDLTool"/>
+                       <Tool
+                               Name="VCPostBuildEventTool"/>
+                       <Tool
+                               Name="VCPreBuildEventTool"/>
+                       <Tool
+                               Name="VCPreLinkEventTool"/>
+                       <Tool
+                               Name="VCResourceCompilerTool"/>
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"/>
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"/>
+                       <Tool
+                               Name="VCWebDeploymentTool"/>
+                       <Tool
+                               Name="VCManagedWrapperGeneratorTool"/>
+                       <Tool
+                               Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+               </Configuration>
+       </Configurations>
+       <References>
+       </References>
+       <Files>
+               <Filter
+                       Name="\83\\81[\83\83t\83@\83C\83\8b"
+                       Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+                       UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
+                       <File
+                               RelativePath="..\DCHook.cpp">
+                       </File>
+                       <File
+                               RelativePath="..\DCHook.def">
+                       </File>
+                       <File
+                               RelativePath="..\MonitorScale.cpp">
+                       </File>
+               </Filter>
+               <Filter
+                       Name="\83w\83b\83_\81\83t\83@\83C\83\8b"
+                       Filter="h;hpp;hxx;hm;inl;inc;xsd"
+                       UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
+               </Filter>
+               <Filter
+                       Name="\83\8a\83\\81[\83\83t\83@\83C\83\8b"
+                       Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
+                       UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
+                       <File
+                               RelativePath="..\dchook.rc">
+                       </File>
+               </Filter>
+       </Files>
+       <Globals>
+       </Globals>
+</VisualStudioProject>
diff --git a/DCHook/VS2008/DCHook.sln b/DCHook/VS2008/DCHook.sln
new file mode 100644 (file)
index 0000000..a89cf9d
--- /dev/null
@@ -0,0 +1,26 @@
+
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual Studio 2008
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DCHook", "DCHook.vcproj", "{B8C9A2E3-2767-45C7-91B5-1B717C3653F3}"
+EndProject
+Global
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution
+               Debug|Win32 = Debug|Win32
+               Debug|x64 = Debug|x64
+               Release|Win32 = Release|Win32
+               Release|x64 = Release|x64
+       EndGlobalSection
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution
+               {B8C9A2E3-2767-45C7-91B5-1B717C3653F3}.Debug|Win32.ActiveCfg = Debug|Win32
+               {B8C9A2E3-2767-45C7-91B5-1B717C3653F3}.Debug|Win32.Build.0 = Debug|Win32
+               {B8C9A2E3-2767-45C7-91B5-1B717C3653F3}.Debug|x64.ActiveCfg = Debug|x64
+               {B8C9A2E3-2767-45C7-91B5-1B717C3653F3}.Debug|x64.Build.0 = Debug|x64
+               {B8C9A2E3-2767-45C7-91B5-1B717C3653F3}.Release|Win32.ActiveCfg = Release|Win32
+               {B8C9A2E3-2767-45C7-91B5-1B717C3653F3}.Release|Win32.Build.0 = Release|Win32
+               {B8C9A2E3-2767-45C7-91B5-1B717C3653F3}.Release|x64.ActiveCfg = Release|x64
+               {B8C9A2E3-2767-45C7-91B5-1B717C3653F3}.Release|x64.Build.0 = Release|x64
+       EndGlobalSection
+       GlobalSection(SolutionProperties) = preSolution
+               HideSolutionNode = FALSE
+       EndGlobalSection
+EndGlobal
diff --git a/DCHook/VS2008/DCHook.vcproj b/DCHook/VS2008/DCHook.vcproj
new file mode 100644 (file)
index 0000000..c356754
--- /dev/null
@@ -0,0 +1,359 @@
+<?xml version="1.0" encoding="shift_jis"?>
+<VisualStudioProject
+       ProjectType="Visual C++"
+       Version="9.00"
+       Name="DCHook"
+       ProjectGUID="{B8C9A2E3-2767-45C7-91B5-1B717C3653F3}"
+       RootNamespace="DCHook"
+       Keyword="Win32Proj"
+       TargetFrameworkVersion="196613"
+       >
+       <Platforms>
+               <Platform
+                       Name="Win32"
+               />
+               <Platform
+                       Name="x64"
+               />
+       </Platforms>
+       <ToolFiles>
+       </ToolFiles>
+       <Configurations>
+               <Configuration
+                       Name="Debug|Win32"
+                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+                       IntermediateDirectory="$(ConfigurationName)"
+                       ConfigurationType="2"
+                       CharacterSet="2"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               Optimization="0"
+                               PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;DCHOOK_EXPORTS"
+                               MinimalRebuild="true"
+                               BasicRuntimeChecks="3"
+                               RuntimeLibrary="3"
+                               UsePrecompiledHeader="0"
+                               WarningLevel="3"
+                               DebugInformationFormat="4"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               LinkIncremental="2"
+                               ModuleDefinitionFile="DCHook.def"
+                               GenerateDebugInformation="true"
+                               SubSystem="2"
+                               TargetMachine="1"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCManifestTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCAppVerifierTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+               <Configuration
+                       Name="Release|Win32"
+                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+                       IntermediateDirectory="$(ConfigurationName)"
+                       ConfigurationType="2"
+                       CharacterSet="2"
+                       WholeProgramOptimization="1"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               Optimization="2"
+                               EnableIntrinsicFunctions="true"
+                               PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;DCHOOK_EXPORTS"
+                               RuntimeLibrary="2"
+                               EnableFunctionLevelLinking="true"
+                               UsePrecompiledHeader="0"
+                               WarningLevel="3"
+                               DebugInformationFormat="3"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               LinkIncremental="1"
+                               ModuleDefinitionFile="DCHook.def"
+                               GenerateDebugInformation="true"
+                               SubSystem="2"
+                               OptimizeReferences="2"
+                               EnableCOMDATFolding="2"
+                               TargetMachine="1"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCManifestTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCAppVerifierTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+               <Configuration
+                       Name="Debug|x64"
+                       OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
+                       IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
+                       ConfigurationType="2"
+                       CharacterSet="2"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                               TargetEnvironment="3"
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               Optimization="0"
+                               PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;DCHOOK_EXPORTS"
+                               MinimalRebuild="true"
+                               BasicRuntimeChecks="3"
+                               RuntimeLibrary="3"
+                               UsePrecompiledHeader="0"
+                               WarningLevel="3"
+                               DebugInformationFormat="3"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               LinkIncremental="2"
+                               ModuleDefinitionFile="DCHook.def"
+                               GenerateDebugInformation="true"
+                               SubSystem="2"
+                               TargetMachine="17"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCManifestTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCAppVerifierTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+               <Configuration
+                       Name="Release|x64"
+                       OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
+                       IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
+                       ConfigurationType="2"
+                       CharacterSet="2"
+                       WholeProgramOptimization="1"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                               TargetEnvironment="3"
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               Optimization="2"
+                               EnableIntrinsicFunctions="true"
+                               PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;DCHOOK_EXPORTS"
+                               RuntimeLibrary="2"
+                               EnableFunctionLevelLinking="true"
+                               UsePrecompiledHeader="0"
+                               WarningLevel="3"
+                               DebugInformationFormat="3"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               LinkIncremental="1"
+                               ModuleDefinitionFile="DCHook.def"
+                               GenerateDebugInformation="true"
+                               SubSystem="2"
+                               OptimizeReferences="2"
+                               EnableCOMDATFolding="2"
+                               TargetMachine="17"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCManifestTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCAppVerifierTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+       </Configurations>
+       <References>
+       </References>
+       <Files>
+               <Filter
+                       Name="\83\\81[\83\83t\83@\83C\83\8b"
+                       Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+                       UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+                       >
+                       <File
+                               RelativePath="..\DCHook.cpp"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\DCHook.def"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\MonitorScale.cpp"
+                               >
+                       </File>
+               </Filter>
+               <Filter
+                       Name="\83w\83b\83_\81\83t\83@\83C\83\8b"
+                       Filter="h;hpp;hxx;hm;inl;inc;xsd"
+                       UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+                       >
+               </Filter>
+               <Filter
+                       Name="\83\8a\83\\81[\83\83t\83@\83C\83\8b"
+                       Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+                       UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+                       >
+                       <File
+                               RelativePath="..\dchook.rc"
+                               >
+                       </File>
+               </Filter>
+       </Files>
+       <Globals>
+       </Globals>
+</VisualStudioProject>
diff --git a/DCHook/VS2015/DCHook.sln b/DCHook/VS2015/DCHook.sln
new file mode 100644 (file)
index 0000000..05c95f6
--- /dev/null
@@ -0,0 +1,28 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 14
+VisualStudioVersion = 14.0.23107.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DCHook", "DCHook.vcxproj", "{16E6F306-BD26-4E7E-9A8E-96A5231AD6A3}"
+EndProject
+Global
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution
+               Debug|x64 = Debug|x64
+               Debug|x86 = Debug|x86
+               Release|x64 = Release|x64
+               Release|x86 = Release|x86
+       EndGlobalSection
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution
+               {16E6F306-BD26-4E7E-9A8E-96A5231AD6A3}.Debug|x64.ActiveCfg = Debug|x64
+               {16E6F306-BD26-4E7E-9A8E-96A5231AD6A3}.Debug|x64.Build.0 = Debug|x64
+               {16E6F306-BD26-4E7E-9A8E-96A5231AD6A3}.Debug|x86.ActiveCfg = Debug|Win32
+               {16E6F306-BD26-4E7E-9A8E-96A5231AD6A3}.Debug|x86.Build.0 = Debug|Win32
+               {16E6F306-BD26-4E7E-9A8E-96A5231AD6A3}.Release|x64.ActiveCfg = Release|x64
+               {16E6F306-BD26-4E7E-9A8E-96A5231AD6A3}.Release|x64.Build.0 = Release|x64
+               {16E6F306-BD26-4E7E-9A8E-96A5231AD6A3}.Release|x86.ActiveCfg = Release|Win32
+               {16E6F306-BD26-4E7E-9A8E-96A5231AD6A3}.Release|x86.Build.0 = Release|Win32
+       EndGlobalSection
+       GlobalSection(SolutionProperties) = preSolution
+               HideSolutionNode = FALSE
+       EndGlobalSection
+EndGlobal
diff --git a/DCHook/VS2015/DCHook.vcxproj b/DCHook/VS2015/DCHook.vcxproj
new file mode 100644 (file)
index 0000000..e66c96d
--- /dev/null
@@ -0,0 +1,158 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup Label="ProjectConfigurations">
+    <ProjectConfiguration Include="Debug|Win32">
+      <Configuration>Debug</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|Win32">
+      <Configuration>Release</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Debug|x64">
+      <Configuration>Debug</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|x64">
+      <Configuration>Release</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+  </ItemGroup>
+  <PropertyGroup Label="Globals">
+    <ProjectGuid>{16E6F306-BD26-4E7E-9A8E-96A5231AD6A3}</ProjectGuid>
+    <Keyword>Win32Proj</Keyword>
+    <RootNamespace>DCHook</RootNamespace>
+    <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
+    <UseDebugLibraries>true</UseDebugLibraries>
+    <PlatformToolset>v140</PlatformToolset>
+    <CharacterSet>Unicode</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <PlatformToolset>v140</PlatformToolset>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <CharacterSet>Unicode</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
+    <UseDebugLibraries>true</UseDebugLibraries>
+    <PlatformToolset>v140</PlatformToolset>
+    <CharacterSet>Unicode</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+    <ConfigurationType>DynamicLibrary</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <PlatformToolset>v140</PlatformToolset>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <CharacterSet>Unicode</CharacterSet>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+  <ImportGroup Label="ExtensionSettings">
+  </ImportGroup>
+  <ImportGroup Label="Shared">
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <PropertyGroup Label="UserMacros" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <LinkIncremental>true</LinkIncremental>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <LinkIncremental>true</LinkIncremental>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <LinkIncremental>false</LinkIncremental>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <LinkIncremental>false</LinkIncremental>
+  </PropertyGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <ClCompile>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>Disabled</Optimization>
+      <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;DCHOOK_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <SDLCheck>true</SDLCheck>
+    </ClCompile>
+    <Link>
+      <SubSystem>Windows</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <ClCompile>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>Disabled</Optimization>
+      <PreprocessorDefinitions>_DEBUG;_WINDOWS;_USRDLL;DCHOOK_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <SDLCheck>true</SDLCheck>
+    </ClCompile>
+    <Link>
+      <SubSystem>Windows</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <Optimization>MaxSpeed</Optimization>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;DCHOOK_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <SDLCheck>true</SDLCheck>
+    </ClCompile>
+    <Link>
+      <SubSystem>Windows</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <Optimization>MaxSpeed</Optimization>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <PreprocessorDefinitions>NDEBUG;_WINDOWS;_USRDLL;DCHOOK_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <SDLCheck>true</SDLCheck>
+    </ClCompile>
+    <Link>
+      <SubSystem>Windows</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemGroup>
+    <ClCompile Include="..\DCHook.cpp" />
+    <ClCompile Include="..\MonitorScale.cpp" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="..\DCHook.def" />
+  </ItemGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+  <ImportGroup Label="ExtensionTargets">
+  </ImportGroup>
+</Project>
\ No newline at end of file
diff --git a/DCHook/VS2015/DCHook.vcxproj.filters b/DCHook/VS2015/DCHook.vcxproj.filters
new file mode 100644 (file)
index 0000000..883d488
--- /dev/null
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup>
+    <Filter Include="ソース ファイル">
+      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+    </Filter>
+    <Filter Include="ヘッダー ファイル">
+      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+      <Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
+    </Filter>
+    <Filter Include="リソース ファイル">
+      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
+      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
+    </Filter>
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="..\DCHook.cpp">
+      <Filter>ソース ファイル</Filter>
+    </ClCompile>
+    <ClCompile Include="..\MonitorScale.cpp">
+      <Filter>ソース ファイル</Filter>
+    </ClCompile>
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="..\DCHook.def">
+      <Filter>ソース ファイル</Filter>
+    </None>
+  </ItemGroup>
+</Project>
\ No newline at end of file
diff --git a/DCHook/dchook.rc b/DCHook/dchook.rc
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/DCHook64/DCHook64.h b/DCHook64/DCHook64.h
new file mode 100644 (file)
index 0000000..6029090
--- /dev/null
@@ -0,0 +1,38 @@
+#ifndef __DCHook64_h
+#define __DCHook64_h
+
+// App -> dchk64.exe
+
+enum eHookDllCmd {
+       HDC_Load = WM_APP+0x100,
+       HDC_Unload,
+       HDC_Init,
+       HDC_Uninit,
+       HDC_Config,
+       HDC_Config2,
+       HDC_Capture,
+       HDC_CaptureAsync,
+       HDC_CaptureAsyncWait,
+       HDC_Debug,
+};
+
+struct HDCInitParam {
+       HWND hwnd;
+       //char module_name[];
+       //bool windowsnt;
+       //const char *vxd_path;
+};
+
+struct HDCConfigParam {
+       int clickonly;
+       int keyaction;
+       int keyflag;
+};
+
+// dchk64.exe -> App
+#define        UM_SHORTCUT                     (WM_APP+33)
+
+// WPARAM value
+#define        SCINX_NOTIFY64  (0x1000)        // notify from 64bit HookDll
+
+#endif
diff --git a/DCHook64/dchk64/ReadMe.txt b/DCHook64/dchk64/ReadMe.txt
new file mode 100644 (file)
index 0000000..9a4113d
--- /dev/null
@@ -0,0 +1,69 @@
+========================================================================
+    Win32 アプリケーション: dchk64 プロジェクトの概要
+========================================================================
+
+この dchk64 アプリケーションは、AppWizard により作成されました。
+
+このファイルには、dchk64 
+アプリケーションを構成する各ファイルの内容の概要が含まれています。
+
+
+dchk64.vcxproj
+    これは、アプリケーション ウィザードを使用して生成された VC++ 
+    プロジェクトのメイン プロジェクト ファイルです。
+    ファイルを生成した Visual C++ のバージョンに関する情報と、アプリケーション 
+    ウィザードで選択されたプラットフォーム、
+    構成、およびプロジェクト機能に関する情報が含まれています。
+
+dchk64.vcxproj.filters
+    これは、アプリケーション ウィザードで生成された VC++ プロジェクトのフィルター 
+    ファイルです。 
+    このファイルには、プロジェクト内のファイルとフィルターとの間の関連付けに関する
+    情報が含まれています。 この関連付けは、特定のノー
+    ドで同様の拡張子を持つファイルのグループ化を
+    示すために IDE で使用されます (たとえば、".cpp" ファイルは "ソース ファイル" 
+    フィルターに関連付けられています)。
+
+dchk64.cpp
+    これは、メインのアプリケーション ソース ファイルです。
+
+/////////////////////////////////////////////////////////////////////////////
+AppWizard によって、次のリソースが作成されました。
+
+dchk64.rc
+    これは、プログラムが使用するすべての Microsoft Windows リソースの一覧です。RES 
+    サブディレクトリに格納されるアイコン、ビットマップ、
+    およびカーソルをインクルードしています。  このファイルは、Microsoft Visual C++ 
+    で直接編集できます。
+
+Resource.h
+    これは、新しいリソース ID を定義する標準のヘッダー ファイルです。
+    このファイルの読み込みおよび更新は、Microsoft Visual C++ で行います。
+
+dchk64.ico
+    これは、アプリケーションのアイコン (32x32) として使用されるアイコン 
+    ファイルです。
+    このアイコンは、メイン リソース ファイル dchk64.rc 
+    にインクルードされます。
+
+small.ico
+    これは、アプリケーションのアイコンの小さいバージョン (16x16) を含むアイコン 
+    ファイルです。 このアイコンは、メイン リソース ファイル dchk64.rc 
+    にインクルードされます。
+
+/////////////////////////////////////////////////////////////////////////////
+その他の標準ファイル :
+
+StdAfx.h、StdAfx.cpp
+    これらのファイルは、dchk64.pch 
+    という名前のプリコンパイル済みヘッダー (PCH) ファイルと、StdAfx.obj 
+    という名前のプリコンパイル済みの型ファイルを構築するために使用されます。
+
+/////////////////////////////////////////////////////////////////////////////
+その他のメモ :
+
+AppWizard では "TODO:" 
+コメントを使用して、ユーザーが追加またはカスタマイズする必要のあるソース 
+コードを示します。
+
+/////////////////////////////////////////////////////////////////////////////
diff --git a/DCHook64/dchk64/Resource.h b/DCHook64/dchk64/Resource.h
new file mode 100644 (file)
index 0000000..87a7c48
--- /dev/null
@@ -0,0 +1,31 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ generated include file.
+// Used by dchk64.rc
+//
+
+#define IDS_APP_TITLE                  103
+
+#define IDR_MAINFRAME                  128
+#define IDD_DCHK64_DIALOG      102
+#define IDD_ABOUTBOX                   103
+#define IDM_ABOUT                              104
+#define IDM_EXIT                               105
+#define IDI_DCHK64                     107
+#define IDI_SMALL                              108
+#define IDC_DCHK64                     109
+#define IDC_MYICON                             2
+#ifndef IDC_STATIC
+#define IDC_STATIC                             -1
+#endif
+// \90V\82µ\82¢\83I\83u\83W\83F\83N\83g\82Ì\8e\9f\82Ì\8aù\92è\92l
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+
+#define _APS_NO_MFC                                    130
+#define _APS_NEXT_RESOURCE_VALUE       129
+#define _APS_NEXT_COMMAND_VALUE                32771
+#define _APS_NEXT_CONTROL_VALUE                1000
+#define _APS_NEXT_SYMED_VALUE          110
+#endif
+#endif
diff --git a/DCHook64/dchk64/dchk64.cpp b/DCHook64/dchk64/dchk64.cpp
new file mode 100644 (file)
index 0000000..8812dd7
--- /dev/null
@@ -0,0 +1,336 @@
+// dchk64.cpp : \83A\83v\83\8a\83P\81[\83V\83\87\83\93\82Ì\83G\83\93\83g\83\8a \83|\83C\83\93\83g\82ð\92è\8b`\82µ\82Ü\82·\81B
+//
+
+#include "stdafx.h"
+#include "dchk64.h"
+#include "../../DCHookTest/HookLoader.h"
+#include "../DCHook64.h"
+
+#define MAX_LOADSTRING 100
+
+// \83O\83\8d\81[\83o\83\8b\95Ï\90\94:
+HINSTANCE hInst;                                                               // \8c»\8dÝ\82Ì\83C\83\93\83^\81[\83t\83F\83C\83X
+TCHAR szTitle[MAX_LOADSTRING];                                 // \83^\83C\83g\83\8b \83o\81[\82Ì\83e\83L\83X\83g
+TCHAR szWindowClass[MAX_LOADSTRING];                   // \83\81\83C\83\93 \83E\83B\83\93\83h\83\83N\83\89\83X\96¼
+
+const char *StrDCHOOKDLL = "DKPUHK64.dll";
+THookLoader HookDll(StrDCHOOKDLL);
+
+HWND hWnd = NULL;
+HWND hwndParent = NULL;
+HANDLE hMutex = NULL;
+bool WindowsNT = true;
+
+#ifdef _DEBUG
+#define        DBW     dbw
+#else
+#define        DBW
+#endif
+void dbw( const char *format, ... );
+
+// \82±\82Ì\83R\81[\83\83\82\83W\83\85\81[\83\8b\82É\8aÜ\82Ü\82ê\82é\8aÖ\90\94\82Ì\90é\8c¾\82ð\93]\91\97\82µ\82Ü\82·:
+ATOM MyRegisterClass(HINSTANCE hInstance);
+BOOL InitInstance(HINSTANCE, LPTSTR lpCmdLine, int);
+void Cleanup();
+LRESULT CALLBACK       WndProc(HWND, UINT, WPARAM, LPARAM);
+
+int atox( const TCHAR *str, TCHAR **next );
+
+int APIENTRY _tWinMain(HINSTANCE hInstance,
+                     HINSTANCE hPrevInstance,
+                     LPTSTR    lpCmdLine,
+                     int       nCmdShow)
+{
+       UNREFERENCED_PARAMETER(hPrevInstance);
+       //UNREFERENCED_PARAMETER(lpCmdLine);
+
+       MSG msg;
+       HACCEL hAccelTable;
+
+       // \83O\83\8d\81[\83o\83\8b\95\8e\9a\97ñ\82ð\8f\89\8aú\89»\82µ\82Ä\82¢\82Ü\82·\81B
+       LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
+       LoadString(hInstance, IDC_DCHK64, szWindowClass, MAX_LOADSTRING);
+       MyRegisterClass(hInstance);
+
+       // \83A\83v\83\8a\83P\81[\83V\83\87\83\93\82Ì\8f\89\8aú\89»\82ð\8eÀ\8ds\82µ\82Ü\82·:
+       if (!InitInstance (hInstance, lpCmdLine, nCmdShow))
+       {
+               return FALSE;
+       }
+
+       hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_DCHK64));
+
+       // \83\81\83C\83\93 \83\81\83b\83Z\81[\83\83\8b\81[\83v:
+       while (GetMessage(&msg, NULL, 0, 0))
+       {
+               if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
+               {
+                       TranslateMessage(&msg);
+                       DispatchMessage(&msg);
+               }
+       }
+
+       Cleanup();
+
+       return (int) msg.wParam;
+}
+
+
+
+//
+//  \8aÖ\90\94: MyRegisterClass()
+//
+//  \96Ú\93I: \83E\83B\83\93\83h\83\83N\83\89\83X\82ð\93o\98^\82µ\82Ü\82·\81B
+//
+//  \83R\83\81\83\93\83g:
+//
+//    \82±\82Ì\8aÖ\90\94\82¨\82æ\82Ñ\8eg\82¢\95û\82Í\81A'RegisterClassEx' \8aÖ\90\94\82ª\92Ç\89Á\82³\82ê\82½
+//    Windows 95 \82æ\82è\91O\82Ì Win32 \83V\83X\83e\83\80\82Æ\8cÝ\8a·\82³\82¹\82é\8fê\8d\87\82É\82Ì\82Ý\95K\97v\82Å\82·\81B
+//    \83A\83v\83\8a\83P\81[\83V\83\87\83\93\82ª\81A\8aÖ\98A\95t\82¯\82ç\82ê\82½
+//    \90³\82µ\82¢\8c`\8e®\82Ì\8f¬\82³\82¢\83A\83C\83R\83\93\82ð\8eæ\93¾\82Å\82«\82é\82æ\82¤\82É\82·\82é\82É\82Í\81A
+//    \82±\82Ì\8aÖ\90\94\82ð\8cÄ\82Ñ\8fo\82µ\82Ä\82­\82¾\82³\82¢\81B
+//
+ATOM MyRegisterClass(HINSTANCE hInstance)
+{
+       WNDCLASSEX wcex;
+
+       wcex.cbSize = sizeof(WNDCLASSEX);
+
+       wcex.style                      = CS_HREDRAW | CS_VREDRAW;
+       wcex.lpfnWndProc        = WndProc;
+       wcex.cbClsExtra         = 0;
+       wcex.cbWndExtra         = 0;
+       wcex.hInstance          = hInstance;
+       wcex.hIcon                      = NULL; //LoadIcon(hInstance, MAKEINTRESOURCE(IDI_PDHK64));
+#ifdef _DEBUG
+       wcex.hCursor            = LoadCursor(NULL, IDC_ARROW);
+       wcex.hbrBackground      = (HBRUSH)(COLOR_WINDOW+1);
+#else
+       wcex.hCursor            = NULL; //LoadCursor(NULL, IDC_ARROW);
+       wcex.hbrBackground      = NULL; //(HBRUSH)(COLOR_WINDOW+1);
+#endif
+       wcex.lpszMenuName       = NULL; //MAKEINTRESOURCE(IDC_PDHK64);
+       wcex.lpszClassName      = szWindowClass;
+       wcex.hIconSm            = NULL; //LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
+
+       return RegisterClassEx(&wcex);
+}
+
+//
+//   \8aÖ\90\94: InitInstance(HINSTANCE, LPTSTR, int)
+//
+//   \96Ú\93I: \83C\83\93\83X\83^\83\93\83\83n\83\93\83h\83\8b\82ð\95Û\91\82µ\82Ä\81A\83\81\83C\83\93 \83E\83B\83\93\83h\83E\82ð\8dì\90¬\82µ\82Ü\82·\81B
+//
+//   \83R\83\81\83\93\83g:
+//
+//        \82±\82Ì\8aÖ\90\94\82Å\81A\83O\83\8d\81[\83o\83\8b\95Ï\90\94\82Å\83C\83\93\83X\83^\83\93\83\83n\83\93\83h\83\8b\82ð\95Û\91\82µ\81A
+//        \83\81\83C\83\93 \83v\83\8d\83O\83\89\83\80 \83E\83B\83\93\83h\83E\82ð\8dì\90¬\82¨\82æ\82Ñ\95\\8e¦\82µ\82Ü\82·\81B
+//
+BOOL InitInstance(HINSTANCE hInstance, LPTSTR lpCmdLine, int nCmdShow)
+{
+   hInst = hInstance; // \83O\83\8d\81[\83o\83\8b\95Ï\90\94\82É\83C\83\93\83X\83^\83\93\83X\8f\88\97\9d\82ð\8ai\94[\82µ\82Ü\82·\81B
+
+       TCHAR ModuleName[_MAX_PATH];
+       GetModuleFileName(NULL, ModuleName, sizeof(ModuleName)/sizeof(TCHAR));
+       hMutex = CreateMutex(NULL, FALSE, ModuleName);
+       if (GetLastError()==ERROR_ALREADY_EXISTS){
+               return FALSE;   // dup launched
+       }
+
+#ifdef _DEBUG
+       const int width = 800;
+       const int height = 400;
+#else
+       const int width = 0;
+       const int height = 0;
+#endif
+
+   hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
+      CW_USEDEFAULT, CW_USEDEFAULT, width, height, NULL, NULL, hInstance, NULL);
+
+   if (!hWnd)
+   {
+      return FALSE;
+   }
+
+       hwndParent = (HWND)(LONG_PTR)atox(lpCmdLine, NULL);
+       //DBW("hwndParent=%d", (int)(LONG_PTR)hwndParent);
+       if (hwndParent){
+               PostMessage(hwndParent, UM_SHORTCUT, SCINX_NOTIFY64, (LPARAM)hWnd);
+               //DBW("Posted");
+       }
+
+#ifdef _DEBUG
+   ShowWindow(hWnd, nCmdShow);
+   UpdateWindow(hWnd);
+#endif
+
+   return TRUE;
+}
+
+void Cleanup()
+{
+       if (hMutex){
+               CloseHandle(hMutex);
+               hMutex = NULL;
+       }
+}
+
+//
+//  \8aÖ\90\94: WndProc(HWND, UINT, WPARAM, LPARAM)
+//
+//  \96Ú\93I:  \83\81\83C\83\93 \83E\83B\83\93\83h\83E\82Ì\83\81\83b\83Z\81[\83W\82ð\8f\88\97\9d\82µ\82Ü\82·\81B
+//
+//  WM_COMMAND - \83A\83v\83\8a\83P\81[\83V\83\87\83\93 \83\81\83j\83\85\81[\82Ì\8f\88\97\9d
+//  WM_PAINT   - \83\81\83C\83\93 \83E\83B\83\93\83h\83E\82Ì\95`\89æ
+//  WM_DESTROY - \92\86\8e~\83\81\83b\83Z\81[\83W\82ð\95\\8e¦\82µ\82Ä\96ß\82é
+//
+//
+LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+       //int wmId, wmEvent;
+       PAINTSTRUCT ps;
+       HDC hdc;
+
+       switch (message)
+       {
+       case WM_CREATE:
+               HookDll.Load(hWnd);
+#ifdef _DEBUG
+               {
+               if (!HookDll.Init(hWnd)){
+                       DBW("Hook.Init error");
+               }
+#if 0
+               HookDll.Config(-1, KA_POPUP, KF_CONTROL);
+               TDCHConfig cfg;
+               memset(&cfg, 0, sizeof(cfg));
+               cfg.UseAMODI = 0;
+               cfg.MoveSend = 0;
+               cfg.ScaleX = 0;
+               cfg.ScaleY = 0;
+               HookDll.Config2(&cfg);
+#endif
+               }
+#endif
+               break;
+#if 0
+       case WM_COMMAND:
+               wmId    = LOWORD(wParam);
+               wmEvent = HIWORD(wParam);
+               // \91I\91ð\82³\82ê\82½\83\81\83j\83\85\81[\82Ì\89ð\90Í:
+               switch (wmId)
+               {
+               case IDM_ABOUT:
+                       DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
+                       break;
+               case IDM_EXIT:
+                       DestroyWindow(hWnd);
+                       break;
+               default:
+                       return DefWindowProc(hWnd, message, wParam, lParam);
+               }
+               break;
+#endif
+       case WM_PAINT:
+               hdc = BeginPaint(hWnd, &ps);
+               EndPaint(hWnd, &ps);
+               break;
+       case WM_DESTROY:
+               PostQuitMessage(0);
+               break;
+
+       case WM_COPYDATA:
+               {
+               COPYDATASTRUCT *cds = (COPYDATASTRUCT*)lParam;
+               if ( !cds ) break;
+               switch (cds->dwData){
+                       case HDC_Init:
+                               {
+                               HDCInitParam &p = *(HDCInitParam*)cds->lpData;
+                               return HookDll.Init(p.hwnd);
+                               }
+                       case HDC_Uninit:
+                               HookDll.Uninit();
+                               break;
+                       case HDC_Config:
+                               {
+                               HDCConfigParam &p = *(HDCConfigParam*)cds->lpData;
+                               return HookDll.Config(p.clickonly, p.keyaction, p.keyflag);
+                               }
+                       case HDC_Config2:
+                               return HookDll.Config2((TDCHConfig*)cds->lpData);
+                       case HDC_Capture:
+                               return HookDll.Capture();
+                       case HDC_CaptureAsync:
+                               return HookDll.CaptureAsync();
+                       case HDC_CaptureAsyncWait:
+                               return HookDll.CaptureAsyncWait();
+                       case HDC_Debug:
+                               return HookDll.Debug();
+               }
+               }
+               break;
+       default:
+               return DefWindowProc(hWnd, message, wParam, lParam);
+       }
+       return 0;
+}
+
+int atox( const TCHAR *str, TCHAR **next )
+{
+       unsigned val = 0;
+       while ( 1 )
+       {
+               TCHAR c = *str;
+               if ( c >= '0' && c <= '9' ){
+                       val = (val<<4) + (c - '0');
+               } else if ( c >= 'A' && c <= 'F' ){
+                       val = (val<<4) + ( c - 'A' + 10 );
+               } else if ( c >= 'a' && c <= 'f' ){
+                       val = (val<<4) + ( c - 'a' + 10 );
+               } else {
+                       break;
+               }
+               str++;
+       }
+       if ( next ) *next = (TCHAR*)str;
+       return val;
+}
+
+static HWND hWin = NULL;
+static const TCHAR *clsnameW = _T("TDbgMsgForm");
+static const TCHAR *winnameW = _T("Debug Messenger");
+
+void dbw( const char *format, ... )
+{
+       if ( !hWin ){
+               hWin = FindWindow( clsnameW, winnameW );
+               if ( !hWin ) return;
+       }
+       va_list ap;
+       va_start( ap, format );
+       char buf[ 2048 ];
+       wvsprintfA( buf, format, ap );
+       COPYDATASTRUCT cds;
+       cds.dwData = 1; // Indicate String
+       cds.cbData = (DWORD)strlen(buf)+1;
+       cds.lpData = buf;
+       SendMessageA( hWin, WM_COPYDATA, NULL, (LPARAM)&cds );
+       va_end( ap );
+}
+
+static const char *MyWinTitle = "<Processing...>";
+HANDLE WinExecEx( const char *cmd, int show, const char *dir, const char *title )
+{
+       STARTUPINFO sui;
+       memset( &sui, 0, sizeof(STARTUPINFO) );
+       sui.cb = sizeof(STARTUPINFO);
+       sui.dwFlags = STARTF_USESHOWWINDOW;
+       sui.wShowWindow = (WORD)show;
+       sui.lpTitle = (LPTSTR)(title ? title : MyWinTitle);
+       PROCESS_INFORMATION pi;
+       if ( !CreateProcess( NULL, (LPTSTR)cmd, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, dir, &sui, &pi ) )
+               return NULL;
+       return pi.hProcess;
+}
diff --git a/DCHook64/dchk64/dchk64.h b/DCHook64/dchk64/dchk64.h
new file mode 100644 (file)
index 0000000..d00d47e
--- /dev/null
@@ -0,0 +1,3 @@
+#pragma once
+
+#include "resource.h"
diff --git a/DCHook64/dchk64/dchk64.ico b/DCHook64/dchk64/dchk64.ico
new file mode 100644 (file)
index 0000000..d551aa3
Binary files /dev/null and b/DCHook64/dchk64/dchk64.ico differ
diff --git a/DCHook64/dchk64/dchk64.rc b/DCHook64/dchk64/dchk64.rc
new file mode 100644 (file)
index 0000000..11dfb49
Binary files /dev/null and b/DCHook64/dchk64/dchk64.rc differ
diff --git a/DCHook64/dchk64/dchk64.sln b/DCHook64/dchk64/dchk64.sln
new file mode 100644 (file)
index 0000000..4f667e0
--- /dev/null
@@ -0,0 +1,26 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dchk64", "dchk64.vcxproj", "{5CBB6025-CCD7-40F7-8279-2B633DFA63CA}"
+EndProject
+Global
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution
+               Debug|Win32 = Debug|Win32
+               Debug|x64 = Debug|x64
+               Release|Win32 = Release|Win32
+               Release|x64 = Release|x64
+       EndGlobalSection
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution
+               {5CBB6025-CCD7-40F7-8279-2B633DFA63CA}.Debug|Win32.ActiveCfg = Debug|Win32
+               {5CBB6025-CCD7-40F7-8279-2B633DFA63CA}.Debug|Win32.Build.0 = Debug|Win32
+               {5CBB6025-CCD7-40F7-8279-2B633DFA63CA}.Debug|x64.ActiveCfg = Debug|x64
+               {5CBB6025-CCD7-40F7-8279-2B633DFA63CA}.Debug|x64.Build.0 = Debug|x64
+               {5CBB6025-CCD7-40F7-8279-2B633DFA63CA}.Release|Win32.ActiveCfg = Release|x64
+               {5CBB6025-CCD7-40F7-8279-2B633DFA63CA}.Release|Win32.Build.0 = Release|x64
+               {5CBB6025-CCD7-40F7-8279-2B633DFA63CA}.Release|x64.ActiveCfg = Release|x64
+               {5CBB6025-CCD7-40F7-8279-2B633DFA63CA}.Release|x64.Build.0 = Release|x64
+       EndGlobalSection
+       GlobalSection(SolutionProperties) = preSolution
+               HideSolutionNode = FALSE
+       EndGlobalSection
+EndGlobal
diff --git a/DCHook64/dchk64/dchk64.suo b/DCHook64/dchk64/dchk64.suo
new file mode 100644 (file)
index 0000000..e43c8d0
Binary files /dev/null and b/DCHook64/dchk64/dchk64.suo differ
diff --git a/DCHook64/dchk64/dchk64.vcxproj b/DCHook64/dchk64/dchk64.vcxproj
new file mode 100644 (file)
index 0000000..2d169ec
--- /dev/null
@@ -0,0 +1,162 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup Label="ProjectConfigurations">
+    <ProjectConfiguration Include="Debug|Win32">
+      <Configuration>Debug</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Debug|x64">
+      <Configuration>Debug</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|Win32">
+      <Configuration>Release</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|x64">
+      <Configuration>Release</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+  </ItemGroup>
+  <PropertyGroup Label="Globals">
+    <ProjectGuid>{5CBB6025-CCD7-40F7-8279-2B633DFA63CA}</ProjectGuid>
+    <Keyword>Win32Proj</Keyword>
+    <RootNamespace>dchk64</RootNamespace>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>true</UseDebugLibraries>
+    <CharacterSet>MultiByte</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>true</UseDebugLibraries>
+    <CharacterSet>MultiByte</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <CharacterSet>MultiByte</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <CharacterSet>MultiByte</CharacterSet>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+  <ImportGroup Label="ExtensionSettings">
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <PropertyGroup Label="UserMacros" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <LinkIncremental>true</LinkIncremental>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <LinkIncremental>true</LinkIncremental>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <LinkIncremental>false</LinkIncremental>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <LinkIncremental>false</LinkIncremental>
+  </PropertyGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <ClCompile>
+      <PrecompiledHeader>Use</PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>Disabled</Optimization>
+      <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);USE_UNICODE</PreprocessorDefinitions>
+    </ClCompile>
+    <Link>
+      <SubSystem>Windows</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <ClCompile>
+      <PrecompiledHeader>Use</PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>Disabled</Optimization>
+      <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);USE_UNICODE</PreprocessorDefinitions>
+      <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+    </ClCompile>
+    <Link>
+      <SubSystem>Windows</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <PrecompiledHeader>Use</PrecompiledHeader>
+      <Optimization>MaxSpeed</Optimization>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);USE_UNICODE</PreprocessorDefinitions>
+    </ClCompile>
+    <Link>
+      <SubSystem>Windows</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <PrecompiledHeader>Use</PrecompiledHeader>
+      <Optimization>MaxSpeed</Optimization>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);USE_UNICODE</PreprocessorDefinitions>
+      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+    </ClCompile>
+    <Link>
+      <SubSystem>Windows</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemGroup>
+    <None Include="dchk64.ico" />
+    <None Include="ReadMe.txt" />
+    <None Include="small.ico" />
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="dchk64.h" />
+    <ClInclude Include="Resource.h" />
+    <ClInclude Include="stdafx.h" />
+    <ClInclude Include="targetver.h" />
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="..\..\DCHookTest\HookLoader.cpp" />
+    <ClCompile Include="dchk64.cpp" />
+    <ClCompile Include="stdafx.cpp">
+      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
+      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
+      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
+      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
+    </ClCompile>
+  </ItemGroup>
+  <ItemGroup>
+    <ResourceCompile Include="dchk64.rc" />
+  </ItemGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+  <ImportGroup Label="ExtensionTargets">
+  </ImportGroup>
+</Project>
\ No newline at end of file
diff --git a/DCHook64/dchk64/dchk64.vcxproj.filters b/DCHook64/dchk64/dchk64.vcxproj.filters
new file mode 100644 (file)
index 0000000..25f1275
--- /dev/null
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup>
+    <Filter Include="ソース ファイル">
+      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+    </Filter>
+    <Filter Include="ヘッダー ファイル">
+      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
+    </Filter>
+    <Filter Include="リソース ファイル">
+      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
+      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
+    </Filter>
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="ReadMe.txt" />
+    <None Include="small.ico">
+      <Filter>リソース ファイル</Filter>
+    </None>
+    <None Include="dchk64.ico">
+      <Filter>リソース ファイル</Filter>
+    </None>
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="stdafx.h">
+      <Filter>ヘッダー ファイル</Filter>
+    </ClInclude>
+    <ClInclude Include="targetver.h">
+      <Filter>ヘッダー ファイル</Filter>
+    </ClInclude>
+    <ClInclude Include="Resource.h">
+      <Filter>ヘッダー ファイル</Filter>
+    </ClInclude>
+    <ClInclude Include="dchk64.h">
+      <Filter>ヘッダー ファイル</Filter>
+    </ClInclude>
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="stdafx.cpp">
+      <Filter>ソース ファイル</Filter>
+    </ClCompile>
+    <ClCompile Include="dchk64.cpp">
+      <Filter>ソース ファイル</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\DCHookTest\HookLoader.cpp">
+      <Filter>ソース ファイル</Filter>
+    </ClCompile>
+  </ItemGroup>
+  <ItemGroup>
+    <ResourceCompile Include="dchk64.rc">
+      <Filter>リソース ファイル</Filter>
+    </ResourceCompile>
+  </ItemGroup>
+</Project>
\ No newline at end of file
diff --git a/DCHook64/dchk64/small.ico b/DCHook64/dchk64/small.ico
new file mode 100644 (file)
index 0000000..d551aa3
Binary files /dev/null and b/DCHook64/dchk64/small.ico differ
diff --git a/DCHook64/dchk64/stdafx.cpp b/DCHook64/dchk64/stdafx.cpp
new file mode 100644 (file)
index 0000000..392ff0d
--- /dev/null
@@ -0,0 +1,8 @@
+// stdafx.cpp : \95W\8f\80\83C\83\93\83N\83\8b\81[\83h dchk64.pch \82Ì\82Ý\82ð
+// \8aÜ\82Þ\83\\81[\83\83t\83@\83C\83\8b\82Í\81A\83v\83\8a\83R\83\93\83p\83C\83\8b\8dÏ\82Ý\83w\83b\83_\81[\82É\82È\82è\82Ü\82·\81B
+// stdafx.obj \82É\82Í\83v\83\8a\83R\83\93\83p\83C\83\8b\8dÏ\82Ý\8c^\8fî\95ñ\82ª\8aÜ\82Ü\82ê\82Ü\82·\81B
+
+#include "stdafx.h"
+
+// TODO: \82±\82Ì\83t\83@\83C\83\8b\82Å\82Í\82È\82­\81ASTDAFX.H \82Å\95K\97v\82È
+// \92Ç\89Á\83w\83b\83_\81[\82ð\8eQ\8fÆ\82µ\82Ä\82­\82¾\82³\82¢\81B
diff --git a/DCHook64/dchk64/stdafx.h b/DCHook64/dchk64/stdafx.h
new file mode 100644 (file)
index 0000000..b5cf71f
--- /dev/null
@@ -0,0 +1,21 @@
+// stdafx.h : \95W\8f\80\82Ì\83V\83X\83e\83\80 \83C\83\93\83N\83\8b\81[\83\83t\83@\83C\83\8b\82Ì\83C\83\93\83N\83\8b\81[\83\83t\83@\83C\83\8b\81A\82Ü\82½\82Í
+// \8eQ\8fÆ\89ñ\90\94\82ª\91½\82­\81A\82©\82Â\82 \82Ü\82è\95Ï\8dX\82³\82ê\82È\82¢\81A\83v\83\8d\83W\83F\83N\83g\90ê\97p\82Ì\83C\83\93\83N\83\8b\81[\83\83t\83@\83C\83\8b
+// \82ð\8bL\8fq\82µ\82Ü\82·\81B
+//
+
+#pragma once
+
+#include "targetver.h"
+
+#define WIN32_LEAN_AND_MEAN             // Windows \83w\83b\83_\81[\82©\82ç\8eg\97p\82³\82ê\82Ä\82¢\82È\82¢\95\94\95ª\82ð\8f\9c\8aO\82µ\82Ü\82·\81B
+// Windows \83w\83b\83_\81\83t\83@\83C\83\8b:
+#include <windows.h>
+
+// C \83\89\83\93\83^\83C\83\80 \83w\83b\83_\81\83t\83@\83C\83\8b
+#include <stdlib.h>
+#include <malloc.h>
+#include <memory.h>
+#include <tchar.h>
+
+
+// TODO: \83v\83\8d\83O\83\89\83\80\82É\95K\97v\82È\92Ç\89Á\83w\83b\83_\81[\82ð\82±\82±\82Å\8eQ\8fÆ\82µ\82Ä\82­\82¾\82³\82¢\81B
diff --git a/DCHook64/dchk64/targetver.h b/DCHook64/dchk64/targetver.h
new file mode 100644 (file)
index 0000000..10b7ccd
--- /dev/null
@@ -0,0 +1,8 @@
+#pragma once
+
+// SDKDDKVer.h \82ð\83C\83\93\83N\83\8b\81[\83h\82·\82é\82Æ\81A\97\98\97p\82Å\82«\82é\8dÅ\82à\8fã\88Ê\82Ì Windows \83v\83\89\83b\83g\83t\83H\81[\83\80\82ª\92è\8b`\82³\82ê\82Ü\82·\81B
+
+// \88È\91O\82Ì Windows \83v\83\89\83b\83g\83t\83H\81[\83\80\97p\82É\83A\83v\83\8a\83P\81[\83V\83\87\83\93\82ð\83r\83\8b\83h\82·\82é\8fê\8d\87\82Í\81AWinSDKVer.h \82ð\83C\83\93\83N\83\8b\81[\83h\82µ\81A
+// SDKDDKVer.h \82ð\83C\83\93\83N\83\8b\81[\83h\82·\82é\91O\82É\81A\83T\83|\81[\83g\91Î\8fÛ\82Æ\82·\82é\83v\83\89\83b\83g\83t\83H\81[\83\80\82ð\8e¦\82·\82æ\82¤\82É _WIN32_WINNT \83}\83N\83\8d\82ð\90Ý\92è\82µ\82Ü\82·\81B
+
+#include <SDKDDKVer.h>
diff --git a/DCHookTest/DCHookLoader.cpp b/DCHookTest/DCHookLoader.cpp
new file mode 100644 (file)
index 0000000..dbf85b0
--- /dev/null
@@ -0,0 +1,292 @@
+#include <windows.h>
+#pragma        hdrstop
+#include <tchar.h>
+#include <System.hpp>
+#include "StringLib.h"
+#include "DCHookLoader.h"
+#include "HookLoader.h"
+#include "Util.h"
+
+// LoadHook()\82Íapplication\97§\82¿\8fã\82ª\82è\8e\9e\81A\82Ü\82½\82ÍConfiguration\8e\9e\82É\82P\89ñ\82¾\82¯\8cÄ\82Î\82ê\82é
+// UnloadHook()\82ÍLoadHook()\82Æ\95K\82¸\91Î\82Å\8eg\97p\82·\82é
+
+#define        USE_HOOK64              1
+
+#if USE_HOOK64
+#define        IsWow64()       (fWow64)
+#else
+#define        IsWow64()       (false)
+#endif
+
+/// THookArray ///
+THookArray::~THookArray()
+{
+       clear();
+}
+
+bool THookArray::Load(HWND hwnd)
+{
+       bool ret = true;
+       foreach(Hooks, it, hook_vec){
+               if (!(*it)->Load(hwnd)){
+                       ret = false;
+                       break;
+               }
+       }
+       return ret;
+}
+void THookArray::Unload()
+{
+       foreach(Hooks, it, hook_vec){
+               (*it)->Unload();
+       }
+}
+void THookArray::Uninit()
+{
+       foreach(Hooks, it, hook_vec){
+               (*it)->Uninit();
+       }
+}
+bool THookArray::Init(HWND hwnd)
+{
+       DBW("HookArray::Init");
+       bool ret = true;
+#if 0  // debug code
+       DBW("Init1"); Hooks[1]->Init(hwnd);     // 64bit
+       DBW("Init0"); Hooks[0]->Init(hwnd);     // 32bit
+#else
+       foreach(Hooks, it, hook_vec){
+               if (!(*it)->Init(hwnd)){
+                       ret = false;
+               }
+       }
+#endif
+       return ret;
+}
+void THookArray::Init32(HWND hwnd)
+{
+       Hooks[0]->Init(hwnd);
+}
+int THookArray::Config( int clickonly, int keyaction, int keyflag )
+{
+       foreach(Hooks, it, hook_vec){
+               (*it)->Config(clickonly, keyaction, keyflag);
+       }
+       return 0;
+}
+int THookArray::Config2( struct TDCHConfig *cfg )
+{
+       foreach(Hooks, it, hook_vec){
+               (*it)->Config2(cfg);
+       }
+       return 0;
+}
+int THookArray::Capture()
+{
+       int ret = 0;
+       foreach(Hooks, it, hook_vec){
+               if ((*it)->Capture())
+                       ret = 1;
+       }
+       return ret;
+}
+int THookArray::CaptureAsync()
+{
+       int ret = 0;
+       foreach(Hooks, it, hook_vec){
+               if ((*it)->CaptureAsync())
+                       ret = 1;
+       }
+       return ret;
+}
+int THookArray::CaptureAsyncWait()
+{
+       int ret = 0;
+       foreach(Hooks, it, hook_vec){
+               int r = (*it)->CaptureAsyncWait();
+               if (r!=0){
+                       ret = r;
+                       break;
+               }
+       }
+       return ret;
+}
+int THookArray::Debug()
+{
+       int ret = 0;
+       foreach(Hooks, it, hook_vec){
+               int r = (*it)->Debug();
+               if (r)
+                       ret = r;
+       }
+       return ret;
+}
+
+void THookArray::clear()
+{
+       Uninit();
+       foreach(Hooks, it, hook_vec){
+               delete *it;
+       }
+       Hooks.clear();
+}
+
+bool THookArray::IsLoaded()
+{
+       if (Hooks.size()==0)
+               return false;
+       return Hooks[0]->IsLoaded();
+}
+
+/// TDCHookLoader ///
+TDCHookLoader::TDCHookLoader(bool use64)
+       :Use64(use64)
+{
+       EnableSendAllKeys = false;
+       Hook64 = NULL;
+       Hook32 = NULL;
+       LoadPending = false;
+}
+#if !defined(DSKSVR) && !defined(DCHOOK)
+void TDCHookLoader::SaveProfile(const tchar *param_string)
+{
+       prof.WriteString(PFS_SHORTCUT, StrParams, param_string);
+}
+
+tnstr TDCHookLoader::LoadProfile()
+{
+       return prof.ReadString(PFS_SHORTCUT, StrParams, _T(""));
+}
+#endif
+
+bool TDCHookLoader::LoadHook( HWND hwndParent )
+{
+       if (Hooks.IsLoaded() || LoadPending) return true;
+