From: Eric Kohl Date: Sat, 1 Dec 2018 16:11:51 +0000 (+0100) Subject: [NET] NET HELPMSG: Add support for network message from netmsg.dll. X-Git-Tag: 0.4.12-dev~54 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=17fa384a25506b68aafbbe8529fcf959ac4cf3f9 [NET] NET HELPMSG: Add support for network message from netmsg.dll. --- diff --git a/base/applications/network/net/cmdHelpMsg.c b/base/applications/network/net/cmdHelpMsg.c index 57b9b7a61ac..cbe1ffe99d8 100644 --- a/base/applications/network/net/cmdHelpMsg.c +++ b/base/applications/network/net/cmdHelpMsg.c @@ -13,11 +13,12 @@ INT cmdHelpMsg(INT argc, WCHAR **argv) { + WCHAR szBuffer[MAX_PATH]; + HMODULE hMsgDll = NULL; INT i; LONG errNum; LPWSTR endptr; - // DWORD dwLength = 0; - LPWSTR lpBuffer; + LPWSTR pBuffer; if (argc < 3) { @@ -46,23 +47,51 @@ INT cmdHelpMsg(INT argc, WCHAR **argv) return 1; } - /* Retrieve the message string without appending extra newlines */ - // dwLength = - FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_MAX_WIDTH_MASK, - NULL, - errNum, - LANG_USER_DEFAULT, - (LPWSTR)&lpBuffer, - 0, NULL); - if (lpBuffer /* && dwLength */) + if (errNum >= MIN_LANMAN_MESSAGE_ID && errNum <= MAX_LANMAN_MESSAGE_ID) { - ConPrintf(StdOut, L"\n%s\n", lpBuffer); - LocalFree(lpBuffer); + /* Load netmsg.dll */ + GetSystemDirectoryW(szBuffer, ARRAYSIZE(szBuffer)); + wcscat(szBuffer, L"\\netmsg.dll"); + + hMsgDll = LoadLibrary(szBuffer); + if (hMsgDll == NULL) + { + ConPrintf(StdOut, L"Failed to load netmsg.dll\n"); + return 0; + } + + FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_HMODULE | + FORMAT_MESSAGE_IGNORE_INSERTS, + hMsgDll, + errNum, + LANG_USER_DEFAULT, + (LPWSTR)&pBuffer, + 0, + NULL); + if (pBuffer) + { + ConPrintf(StdOut, L"\n%s\n", pBuffer); + LocalFree(pBuffer); + } + + FreeLibrary(hMsgDll); } else { - ConPrintf(StdOut, L"Unrecognized error code: %ld\n", errNum); + /* Retrieve the message string without appending extra newlines */ + FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + errNum, + LANG_USER_DEFAULT, + (LPWSTR)&pBuffer, + 0, + NULL); + if (pBuffer) + { + ConPrintf(StdOut, L"\n%s\n", pBuffer); + LocalFree(pBuffer); + } } return 0;