1. 최초 커밋

This commit is contained in:
2021-05-02 15:31:55 +09:00
commit eddba8f209
44 changed files with 4131 additions and 0 deletions
+47
View File
@@ -0,0 +1,47 @@
#include "stdafx.h"
#include "HookProcedure.h"
extern HHOOK g_hHook;
//----------------------------------------------------------------------
//
//----------------------------------------------------------------------
LRESULT CALLBACK KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
{
char szPath[MAX_PATH] = {0,};
char *p = NULL;
//------------------------------
//
//------------------------------
TCHAR szCaptureWindowName[] = "MFC_PIDINFO_Training";
HWND hWindowToFind = NULL;
HWND hCurrTopWindowHandle = NULL;
TCHAR szMessage[ 128 ] = { 0, };
if( ( wParam == VK_F12 ) && !( lParam & FLAG_KEYDOWN ) )
{
hWindowToFind = FindWindow( NULL, szCaptureWindowName );
if( hWindowToFind != NULL )
{
// 해당 프로세스에게 메시지를 날린다
SendMessage( hWindowToFind, WM_USER + 10000, (WPARAM)0, (LPARAM)0 );
#if defined( _DEBUG_MODE_ )
MessageBox( NULL, "Send Message","", MB_OK );
#endif
}
else
{
#if defined( _DEBUG_MODE_ )
MessageBox( NULL, "No Found!","", MB_OK );
#endif //
}
}
return CallNextHookEx(g_hHook, nCode, wParam, lParam);
}
+8
View File
@@ -0,0 +1,8 @@
#pragma once
LRESULT CALLBACK KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam);
LRESULT CALLBACK TempKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam);
LRESULT CALLBACK KeyboardProcSendCurrProcessId(int nCode, WPARAM wParam, LPARAM lParam);
+50
View File
@@ -0,0 +1,50 @@
// KeyHookForCapture.cpp : DLL 응용 프로그램에 대한 진입점을 정의합니다.
//
#include "stdafx.h"
#include "HookProcedure.h"
#include "Utility.h"
// 전역 객체
HINSTANCE g_hInstance = NULL; //
HHOOK g_hHook = NULL; //
// 메인 함수
BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpvReserved )
{
switch( dwReason )
{
case DLL_PROCESS_ATTACH:
g_hInstance = hinstDLL;
break;
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
//----------------------------------
// 훅 시작
//----------------------------------
DELARE_EXPORT_FUNCTION void HookStart()
{
g_hHook = SetWindowsHookEx(WH_KEYBOARD, KeyboardProc, g_hInstance, 0);
}
//----------------------------------
// 훅 끝
//----------------------------------
DELARE_EXPORT_FUNCTION void HookEnd()
{
if( g_hHook )
{
UnhookWindowsHookEx(g_hHook);
g_hHook = NULL;
}
}
+245
View File
@@ -0,0 +1,245 @@
<?xml version="1.0" encoding="ks_c_5601-1987"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="KeyHookForCapture"
ProjectGUID="{CBAE52E4-75F6-4E3A-AC60-028649CF136A}"
RootNamespace="KeyHookForCapture"
Keyword="Win32Proj"
TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
UseOfMFC="0"
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;KEYHOOKFORCAPTURE_EXPORTS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="2"
WarningLevel="3"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)\$(ProjectName)_D.dll"
LinkIncremental="2"
GenerateDebugInformation="true"
ProgramDatabaseFile="$(OutDir)/KeyHookForCapture.pdb"
SubSystem="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
ImportLibrary="$(OutDir)/KeyHookForCapture.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="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(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"
/>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;KEYHOOKFORCAPTURE_EXPORTS"
RuntimeLibrary="0"
UsePrecompiledHeader="2"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
ImportLibrary="$(OutDir)/KeyHookForCapture.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>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="소스 파일"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\HookProcedure.cpp"
>
</File>
<File
RelativePath=".\KeyHookForCapture.cpp"
>
</File>
<File
RelativePath=".\stdafx.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\Utility.cpp"
>
</File>
</Filter>
<Filter
Name="헤더 파일"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\HookProcedure.h"
>
</File>
<File
RelativePath=".\stdafx.h"
>
</File>
<File
RelativePath=".\Utility.h"
>
</File>
</Filter>
<Filter
Name="리소스 파일"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
<File
RelativePath=".\ReadMe.txt"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
+40
View File
@@ -0,0 +1,40 @@
========================================================================
동적 연결 라이브러리 : KeyHookForCapture 프로젝트 개요
========================================================================
응용 프로그램 마법사에서 이 KeyHookForCapture DLL을 만들었습니다.
이 파일에는 KeyHookForCapture 응용 프로그램을 구성하는 각각의 파일에
들어 있는 요약 설명이 포함되어 있습니다.
KeyHookForCapture.vcproj
응용 프로그램 마법사를 사용하여 생성한 VC++ 프로젝트의 기본 프로젝트 파일입니다.
해당 파일을 생성한 Visual C++의 버전 정보를 비롯하여
응용 프로그램 마법사에서 선택한 플랫폼, 구성 및
프로젝트 기능에 대한 정보가 들어 있습니다.
KeyHookForCapture.cpp
기본 DLL 소스 파일입니다.
이 DLL은 만들어질 때 기호를 내보내지 않으므로,
빌드될 때 .lib 파일이 생성되지 않습니다.
이 프로젝트가 다른 프로젝트에 종속되게 하려면
해당 DLL에서 기호를 내보내도록 하는 코드를 추가하여
내보내기 라이브러리가 생성되게 하거나,
[프로젝트 속성 페이지] 대화 상자에 있는 [링커] 폴더의 [일반] 속성 페이지에서
[가져오기 라이브러리 무시] 속성을 [예]로 설정합니다.
/////////////////////////////////////////////////////////////////////////////
기타 표준 파일:
StdAfx.h 및 StdAfx.cpp는
KeyHookForCapture.pch라는 이름의 PCH(미리 컴파일된 헤더) 파일과
StdAfx.obj라는 이름의 미리 컴파일된 형식 파일을 빌드하는 데 사용됩니다.
/////////////////////////////////////////////////////////////////////////////
기타 참고:
응용 프로그램 마법사에서 사용하는 "TODO:" 주석은 사용자가 추가하거나 사용자 지정해야 하는
소스 코드 부분을 나타냅니다.
/////////////////////////////////////////////////////////////////////////////
+32
View File
@@ -0,0 +1,32 @@
#include "stdafx.h"
#include "Utility.h"
//------------------------------------------
// 인자로 전달된 이름의 프로세스를 찾는다
//------------------------------------------
DWORD FindProcessID( LPCTSTR szProcessName )
{
DWORD dwPID = 0xFFFFFFFF;
HANDLE hSnapShot = INVALID_HANDLE_VALUE;
PROCESSENTRY32 pe;
// Get the snapshot of the system
pe.dwSize = sizeof( PROCESSENTRY32 );
hSnapShot = CreateToolhelp32Snapshot( TH32CS_SNAPALL, NULL );
// find process
Process32First(hSnapShot, &pe);
do
{
if(!_stricmp(szProcessName, pe.szExeFile))
{
dwPID = pe.th32ProcessID;
break;
}
}
while( Process32Next(hSnapShot, &pe ) );
CloseHandle(hSnapShot);
return dwPID;
}
+7
View File
@@ -0,0 +1,7 @@
#pragma once
//------------------------------------------
// 인자로 전달된 이름의 프로세스를 찾는다
//------------------------------------------
DWORD FindProcessID( LPCTSTR szProcessName );
+8
View File
@@ -0,0 +1,8 @@
// stdafx.cpp : 표준 포함 파일만 들어 있는 소스 파일입니다.
// KeyHookForCapture.pch는 미리 컴파일된 헤더가 됩니다.
// stdafx.obj에는 미리 컴파일된 형식 정보가 포함됩니다.
#include "stdafx.h"
// TODO: 필요한 추가 헤더는
// 이 파일이 아닌 STDAFX.H에서 참조합니다.
+24
View File
@@ -0,0 +1,24 @@
// stdafx.h : 자주 사용하지만 자주 변경되지는 않는
// 표준 시스템 포함 파일 및 프로젝트 관련 포함 파일이
// 들어 있는 포함 파일입니다.
//
#pragma once
#define WIN32_LEAN_AND_MEAN // 거의 사용되지 않는 내용은 Windows 헤더에서 제외합니다.
// Windows 헤더 파일입니다.
#include <windows.h>
// TODO: 프로그램에 필요한 추가 헤더는 여기에서 참조합니다.
#include "tlhelp32.h"
//==========================================
// 상수
//==========================================
#define DELARE_EXPORT_FUNCTION extern "C" __declspec(dllexport)
// 키가 눌렸는지 판단하는 부분의 비트 마스크
#define FLAG_KEYDOWN 0x80000000
//#define _DEBUG_MODE_