Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cWinSnapshot.h
Go to the documentation of this file.
1 //
4 //
5 
6 #ifndef _INC_cWinSnapshot_H
7 #define _INC_cWinSnapshot_H
8 #ifndef NO_PRAGMA_ONCE
9 #pragma once
10 #endif
11 
12 #include "WinTypes.h"
13 #ifdef _WIN32
17 
18 struct _FNFW(tagPROCESSENTRY32);
19 struct _FNFW(tagMODULEENTRY32);
20 struct tagTHREADENTRY32;
21 
22 #if 0
23 #define MAX_MODULE_NAME32 255
24 #define TH32CS_SNAPMODULE 0x00000008
25 #pragma pack( push, 8 )
26 typedef struct CATTR_PACKED _FNFW(tagPROCESSENTRY32)
27 {
28  DWORD dwSize;
29  DWORD cntUsage;
30  DWORD th32ProcessID; // this process
31  ULONG_PTR th32DefaultHeapID;
32  DWORD th32ModuleID; // associated exe
33  DWORD cntThreads;
34  DWORD th32ParentProcessID; // this process's parent process
35  LONG pcPriClassBase; // Base priority of process's threads
36  DWORD dwFlags;
37  CHAR szExeFile[MAX_PATH]; // Path
38 }; // PROCESSENTRY32;
39 typedef struct CATTR_PACKED _FNFW(tagMODULEENTRY32)
40 {
41  DWORD dwSize;
42  DWORD th32ModuleID; // This module
43  DWORD th32ProcessID; // owning process PROCESSID_tfs
44  DWORD GlblcntUsage; // Global usage count on the module
45  DWORD ProccntUsage; // Module usage count in th32ProcessID's context
46  BYTE * modBaseAddr; // Base address of module in th32ProcessID's context
47  DWORD modBaseSize; // Size in bytes of module starting at modBaseAddr
48  HMODULE hModule; // The hModule of this module in th32ProcessID's context
49  char szModule[MAX_MODULE_NAME32 + 1];
50  char szExePath[_MAX_PATH];
51 } // MODULEENTRY32;
52 typedef struct CATTR_PACKED tagTHREADENTRY32
53 {
54  DWORD dwSize;
55  DWORD cntUsage;
56  DWORD th32ThreadID; // this thread
57  DWORD th32OwnerProcessID; // Process this thread is associated with
58  LONG tpBasePri;
59  LONG tpDeltaPri;
60  DWORD dwFlags;
61 } // THREADENTRY32;
62 #pragma pack( pop )
63 #endif
64 
65 namespace GrayLib
66 {
67  class GRAYLIB_LINK cWinSnapshot
68 #ifndef UNDER_CE
69  : public cOSHandle
70 #endif
71  {
77 
78 #ifdef UNDER_CE
79  public:
80  HANDLE m_h;
81  public:
82  void CloseHandle();
83 #endif
84 
85  public:
86  cWinSnapshot();
87  ~cWinSnapshot();
88 
89  HRESULT CreateSnapshot(DWORD dwFlags, PROCESSID_t th32ProcessID);
90  bool GetProcessFirst(struct _FNFW(tagPROCESSENTRY32)* p) const;
91  bool GetProcessNext(struct _FNFW(tagPROCESSENTRY32)* p) const;
92  bool GetModuleFirst(struct _FNFW(tagMODULEENTRY32)* p) const;
93  bool GetModuleNext(struct _FNFW(tagMODULEENTRY32)* p) const;
94  bool GetThreadFirst(struct tagTHREADENTRY32* p) const;
95  bool GetThreadNext(struct tagTHREADENTRY32* p) const;
96  };
97 };
98 #endif
99 #endif
#define _FNFW(c)
_WIN32 name has a W for UNICODE but not UTF8
Definition: FileName.h:25
#define CATTR_PACKED
Definition: GrayCore.h:87
#define GRAYLIB_LINK
Definition: GrayLibBase.h:35
#define _MAX_PATH
Definition: SysTypes.h:423
INT32 HRESULT
_WIN32 style error codes. INT32
Definition: SysTypes.h:465
Definition: cMesh.h:22