获取进程加载的dll
获取进程加载的dll
1 编译为64位程序
2 字符集(使用多字节字符集)
3 管理员运行
1 #include <WINDOWS.H> 2 #include <TLHELP32.H> 3 #include <ctype.h> 4 5 #include <iostream> 6 #include <algorithm> 7 #include <string> 8 #include <list> 9 using namespace std; 10 11 12 int main(int argc, char* argv[]) 13 { 14 list<std::string> moudleList; 15 16 int processId = 14112; 17 MODULEENTRY32 moudle; 18 19 HANDLE handle = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE | TH32CS_SNAPMODULE32, processId); 20 if (handle != INVALID_HANDLE_VALUE) 21 { 22 moudle.dwSize = sizeof(MODULEENTRY32); 23 if (Module32First(handle, &moudle)) 24 { 25 do 26 { 27 std::string str(moudle.szExePath); 28 std::transform(str.begin(), str.end(), str.begin(), tolower); 29 moudleList.push_back(str); 30 } while (Module32Next(handle, &moudle)); 31 } 32 33 CloseHandle(handle); 34 } 35 36 moudleList.sort(); 37 for (auto item : moudleList) { 38 std::cout << item << std::endl; 39 } 40 41 return 0; 42 }