#include #include #include static const wchar_t *glpDllName; static const wchar_t *glpTypeName; static const size_t bufferSize = 1024; using namespace std; void writeHTMLEnd() { wcout << L"" << endl; } void writeHTMLStart(const wchar_t *classNames, const wchar_t *text) { wcout << L"
" << text; } void writeHTMLStartEnd(const wchar_t *classNames, const wchar_t *text, bool indent = true) { writeHTMLStart(classNames, text); writeHTMLEnd(); } BOOL EnumNamesFunc(HMODULE hModule, LPCWSTR lpType, LPWSTR lpName, LONG lParam) { wchar_t nameBuffer[bufferSize]; wchar_t resURIBuffer[bufferSize]; if (IS_INTRESOURCE(lpName)) StringCchPrintfW(nameBuffer, bufferSize, L"/#%d", (int)lpName); else StringCchPrintfW(nameBuffer, bufferSize, L"/%s", lpName); StringCchPrintfW(resURIBuffer, bufferSize, L"%s", glpDllName, glpTypeName, nameBuffer, nameBuffer); writeHTMLStartEnd(L"resource", resURIBuffer); return TRUE; } BOOL EnumTypesFunc(HMODULE hModule, LPWSTR lpType, LONG lParam) { wchar_t typeBuffer[bufferSize]; if (IS_INTRESOURCE(lpType)) StringCchPrintfW(typeBuffer, bufferSize, L"/#%d", (int)lpType); else StringCchPrintfW(typeBuffer, bufferSize, L"/%s", lpType); glpTypeName = typeBuffer; writeHTMLStart(L"type", typeBuffer); EnumResourceNamesW(hModule, lpType, (ENUMRESNAMEPROCW)EnumNamesFunc, 0); writeHTMLEnd(); glpTypeName = NULL; return TRUE; } void listResources(const wchar_t *dllPath) { HMODULE hDll = LoadLibraryExW(dllPath, NULL, LOAD_LIBRARY_AS_DATAFILE | DONT_RESOLVE_DLL_REFERENCES); if (NULL == hDll) { wchar_t buffer[bufferSize]; StringCchPrintfW(buffer, bufferSize, L"%s failed LoadLibrary: 0x%x", dllPath, GetLastError()); writeHTMLStartEnd(L"error library", buffer); } else { glpDllName = dllPath; writeHTMLStart(L"library", dllPath); EnumResourceTypesW(hDll, (ENUMRESTYPEPROCW)EnumTypesFunc, 0); writeHTMLEnd(); FreeLibrary(hDll); glpDllName = NULL; } } void listResources(int dllPathsSize, const wchar_t *dllPaths[]) { wcout << L"" << endl; for (int idx = 0; idx < dllPathsSize; ++idx) listResources(dllPaths[idx]); wcout << L"" << endl; } void wmain(int argc, const wchar_t * argv[]) { if (argc > 1) listResources(argc - 1, argv + 1); else wcout << L"Usage:" << endl << L"\t" << argv[0] << L" dllPath1 [dllPath2 [... [dllPathN]]]" << endl; }