1 /***********************************************************************\ 2 * tlhelp32.d * 3 * * 4 * Windows API header module * 5 * * 6 * Translated from MinGW Windows headers * 7 * * 8 * Placed into public domain * 9 \***********************************************************************/ 10 module windows.tlhelp32; 11 nothrow: 12 private import windows.windef; 13 14 enum : uint { 15 HF32_DEFAULT = 1, 16 HF32_SHARED 17 } 18 19 enum : uint { 20 LF32_FIXED = 0x1, 21 LF32_FREE = 0x2, 22 LF32_MOVEABLE = 0x4 23 } 24 25 const MAX_MODULE_NAME32 = 255; 26 27 enum : uint { 28 TH32CS_SNAPHEAPLIST = 0x1, 29 TH32CS_SNAPPROCESS = 0x2, 30 TH32CS_SNAPTHREAD = 0x4, 31 TH32CS_SNAPMODULE = 0x8, 32 TH32CS_SNAPALL = (TH32CS_SNAPHEAPLIST|TH32CS_SNAPPROCESS|TH32CS_SNAPTHREAD|TH32CS_SNAPMODULE), 33 TH32CS_INHERIT = 0x80000000 34 } 35 36 struct HEAPLIST32 { 37 SIZE_T dwSize; 38 DWORD th32ProcessID; 39 ULONG_PTR th32HeapID; 40 DWORD dwFlags; 41 } 42 alias HEAPLIST32* PHEAPLIST32; 43 alias HEAPLIST32* LPHEAPLIST32; 44 45 struct HEAPENTRY32 { 46 SIZE_T dwSize; 47 HANDLE hHandle; 48 ULONG_PTR dwAddress; 49 SIZE_T dwBlockSize; 50 DWORD dwFlags; 51 DWORD dwLockCount; 52 DWORD dwResvd; 53 DWORD th32ProcessID; 54 ULONG_PTR th32HeapID; 55 } 56 alias HEAPENTRY32* PHEAPENTRY32; 57 alias HEAPENTRY32* LPHEAPENTRY32; 58 59 struct PROCESSENTRY32W { 60 DWORD dwSize; 61 DWORD cntUsage; 62 DWORD th32ProcessID; 63 ULONG_PTR th32DefaultHeapID; 64 DWORD th32ModuleID; 65 DWORD cntThreads; 66 DWORD th32ParentProcessID; 67 LONG pcPriClassBase; 68 DWORD dwFlags; 69 WCHAR[MAX_PATH] szExeFile; 70 } 71 alias PROCESSENTRY32W* PPROCESSENTRY32W; 72 alias PROCESSENTRY32W* LPPROCESSENTRY32W; 73 74 struct THREADENTRY32 { 75 DWORD dwSize; 76 DWORD cntUsage; 77 DWORD th32ThreadID; 78 DWORD th32OwnerProcessID; 79 LONG tpBasePri; 80 LONG tpDeltaPri; 81 DWORD dwFlags; 82 } 83 alias THREADENTRY32* PTHREADENTRY32; 84 alias THREADENTRY32* LPTHREADENTRY32; 85 86 struct MODULEENTRY32W { 87 DWORD dwSize; 88 DWORD th32ModuleID; 89 DWORD th32ProcessID; 90 DWORD GlblcntUsage; 91 DWORD ProccntUsage; 92 BYTE *modBaseAddr; 93 DWORD modBaseSize; 94 HMODULE hModule; 95 WCHAR[MAX_MODULE_NAME32 + 1] szModule; 96 WCHAR[MAX_PATH] szExePath; 97 } 98 alias MODULEENTRY32W* PMODULEENTRY32W; 99 alias MODULEENTRY32W* LPMODULEENTRY32W; 100 101 version(Unicode) { 102 alias PROCESSENTRY32W PROCESSENTRY32; 103 alias PPROCESSENTRY32W PPROCESSENTRY32; 104 alias LPPROCESSENTRY32W LPPROCESSENTRY32; 105 106 alias MODULEENTRY32W MODULEENTRY32; 107 alias PMODULEENTRY32W PMODULEENTRY32; 108 alias LPMODULEENTRY32W LPMODULEENTRY32; 109 } else { 110 struct PROCESSENTRY32 { 111 DWORD dwSize; 112 DWORD cntUsage; 113 DWORD th32ProcessID; 114 ULONG_PTR th32DefaultHeapID; 115 DWORD th32ModuleID; 116 DWORD cntThreads; 117 DWORD th32ParentProcessID; 118 LONG pcPriClassBase; 119 DWORD dwFlags; 120 CHAR[MAX_PATH] szExeFile; 121 } 122 alias PROCESSENTRY32* PPROCESSENTRY32; 123 alias PROCESSENTRY32* LPPROCESSENTRY32; 124 125 struct MODULEENTRY32 { 126 DWORD dwSize; 127 DWORD th32ModuleID; 128 DWORD th32ProcessID; 129 DWORD GlblcntUsage; 130 DWORD ProccntUsage; 131 BYTE *modBaseAddr; 132 DWORD modBaseSize; 133 HMODULE hModule; 134 char[MAX_MODULE_NAME32 + 1] szModule; 135 char[MAX_PATH] szExePath; 136 } 137 alias MODULEENTRY32* PMODULEENTRY32; 138 alias MODULEENTRY32* LPMODULEENTRY32; 139 } 140 141 142 extern(Windows) { 143 BOOL Heap32First(LPHEAPENTRY32,DWORD,DWORD); 144 BOOL Heap32ListFirst(HANDLE,LPHEAPLIST32); 145 BOOL Heap32ListNext(HANDLE,LPHEAPLIST32); 146 BOOL Heap32Next(LPHEAPENTRY32); 147 BOOL Thread32First(HANDLE,LPTHREADENTRY32); 148 BOOL Thread32Next(HANDLE,LPTHREADENTRY32); 149 BOOL Toolhelp32ReadProcessMemory(DWORD,LPCVOID,LPVOID,DWORD,LPDWORD); 150 HANDLE CreateToolhelp32Snapshot(DWORD,DWORD); 151 BOOL Module32FirstW(HANDLE,LPMODULEENTRY32W); 152 BOOL Module32NextW(HANDLE,LPMODULEENTRY32W); 153 BOOL Process32FirstW(HANDLE,LPPROCESSENTRY32W); 154 BOOL Process32NextW(HANDLE,LPPROCESSENTRY32W); 155 } 156 157 version(Unicode) { 158 alias Module32FirstW Module32First; 159 alias Module32NextW Module32Next; 160 alias Process32FirstW Process32First; 161 alias Process32NextW Process32Next; 162 } else { 163 extern(Windows) { 164 BOOL Module32First(HANDLE,LPMODULEENTRY32); 165 BOOL Module32Next(HANDLE,LPMODULEENTRY32); 166 BOOL Process32First(HANDLE,LPPROCESSENTRY32); 167 BOOL Process32Next(HANDLE,LPPROCESSENTRY32); 168 } 169 }