EnumWindows
-> [ GetClassName, GetWindowText ]
CreateToolhelp32Snapshot
Process32First
Process32Next
-> [ PROCESSENTRY32구조체의 szExeFile ]
#include "Windows.h"
#include "tlhelp32.h"
#include "tchar.h"
#include "stdio.h"
BOOL CALLBACK EnumWindowProc(HWND hwnd, LPARAM lParam)
{
TCHAR classname[100] = {0};
TCHAR titlename[100] = {0};
GetClassName (hwnd, (LPTSTR)&classname, 100);
GetWindowText(hwnd, (LPTSTR)&titlename, 256);
if(_tcslen(titlename) != 0 )
_tprintf(_T("%-45s || %s \n"), titlename, classname);
return true;
}
BOOL ProcessList()
{
HANDLE hProcess = NULL;
PROCESSENTRY32 ppe = {0};
hProcess = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
ppe.dwSize = sizeof( PROCESSENTRY32 );
if( Process32First( hProcess, &ppe ) )
{
do
{
_tprintf(_T("%-30s (%d) \n"), ppe.szExeFile, ppe.th32ProcessID);
} while ( Process32Next( hProcess, &ppe ) );
}
CloseHandle (hProcess);
return TRUE;
}
void main()
{
_tprintf(_T("===== [ TITLE || ClassName ] ===== \n"));
EnumWindows(EnumWindowProc, 0);
_tprintf(_T("\n\n===== [ ProcessName (PID) ] ===== \n"));
ProcessList();
}
'Programming > Win_API' 카테고리의 다른 글
| Windows API - 서비스 제어 (0) | 2014.01.21 |
|---|---|
| ANSI, WIDE, TCHAR 함수들 (0) | 2014.01.08 |
| API Hooking - [3] DLL Injection + Trampoline Code Hooking (0) | 2013.12.07 |
| API Hooking - [2] DLL Injection + IAT (1) | 2013.11.24 |
| API Hooking - [1] Debugger Attach + 0xCC (1) | 2013.11.23 |
Pname.exe