Skip to content

Commit f0c2911

Browse files
committed
Added MIT licence
1 parent 29ccdbe commit f0c2911

File tree

2 files changed

+63
-1
lines changed

2 files changed

+63
-1
lines changed

LICENCE.TXT

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (C) 2012 James Brown
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in
11+
all copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.

src/DisplayProcessInfo.c

+44-1
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,57 @@
1414

1515
#include <windows.h>
1616
#include <tchar.h>
17+
#include <psapi.h>
1718

1819
#include "WinSpy.h"
1920
#include "resource.h"
2021

22+
#include <tlhelp32.h>
23+
24+
2125
typedef BOOL (WINAPI * EnumProcessModulesProc )(HANDLE, HMODULE *, DWORD, LPDWORD);
2226
typedef DWORD (WINAPI * GetModuleBaseNameProc )(HANDLE, HMODULE, LPTSTR, DWORD);
2327
typedef DWORD (WINAPI * GetModuleFileNameExProc)(HANDLE, HMODULE, LPTSTR, DWORD);
2428

29+
BOOL GetProcessNameByPid(DWORD dwProcessId, TCHAR szName[], DWORD nNameSize, TCHAR szPath[], DWORD nPathSize)
30+
{
31+
HANDLE h = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
32+
PROCESSENTRY32 pe = { sizeof(pe) };
33+
BOOL fFound = FALSE;
34+
35+
szPath[0] = '\0';
36+
szName[0] = '\0';
37+
38+
if(Process32First(h, &pe))
39+
{
40+
do
41+
{
42+
if(pe.th32ProcessID == dwProcessId)
43+
{
44+
if(szName)
45+
{
46+
lstrcpyn(szName, pe.szExeFile, nNameSize);
47+
}
48+
49+
if(szPath)
50+
{
51+
//OpenProcess(
52+
lstrcpyn(szPath, pe.szExeFile, nPathSize);
53+
}
54+
55+
fFound = TRUE;
56+
break;
57+
}
58+
}
59+
while(Process32Next(h, &pe));
60+
}
61+
62+
CloseHandle(h);
63+
64+
return fFound;
65+
}
66+
67+
2568
//
2669
// This uses PSAPI.DLL, which is only available under NT/2000/XP I think,
2770
// so we dynamically load this library, so that we can still run under 9x.
@@ -32,7 +75,7 @@ typedef DWORD (WINAPI * GetModuleFileNameExProc)(HANDLE, HMODULE, LPTSTR, DWORD)
3275
// szPath [out]
3376
// nPathSize [in]
3477
//
35-
BOOL GetProcessNameByPid(DWORD dwProcessId, TCHAR szName[], DWORD nNameSize, TCHAR szPath[], DWORD nPathSize)
78+
BOOL GetProcessNameByPid0(DWORD dwProcessId, TCHAR szName[], DWORD nNameSize, TCHAR szPath[], DWORD nPathSize)
3679
{
3780
HMODULE hPSAPI;
3881
HANDLE hProcess;

0 commit comments

Comments
 (0)