[NETSH] Implement MakeString and FreeString

Used by the 'winsock show catalog' command.
This commit is contained in:
Eric Kohl
2025-11-22 16:53:33 +01:00
parent b18a46e315
commit 0135440d50
3 changed files with 61 additions and 2 deletions

View File

@@ -273,6 +273,15 @@ FreeQuotedString(
HeapFree(GetProcessHeap(), 0, pszQuotedString);
}
VOID
WINAPI
FreeString(
_In_ LPWSTR pszString)
{
DPRINT("FreeString(%S)\n", pszString);
LocalFree(pszString);
}
LPWSTR
WINAPI
MakeQuotedString(
@@ -291,6 +300,44 @@ MakeQuotedString(
return pszQuotedString;
}
LPWSTR
CDECL
MakeString(
_In_ HANDLE hModule,
_In_ DWORD dwMsgId,
...)
{
LPWSTR pszInBuffer, pszOutBuffer = NULL;
DWORD dwLength;
va_list ap;
DPRINT("MakeString(%p %lu ...)\n", hModule, dwMsgId);
va_start(ap, dwMsgId);
pszInBuffer = HeapAlloc(GetProcessHeap(), 0, HUGE_BUFFER_SIZE * sizeof(WCHAR));
if (pszInBuffer == NULL)
return NULL;
dwLength = LoadStringW(hModule, dwMsgId, pszInBuffer, HUGE_BUFFER_SIZE);
if (dwLength > 0)
goto done;
FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_STRING,
pszInBuffer,
0,
0,
(LPWSTR)&pszOutBuffer,
0,
&ap);
done:
if (pszInBuffer)
HeapFree(GetProcessHeap(), 0, pszInBuffer);
return pszOutBuffer;
}
DWORD
WINAPI
MatchEnumTag(

View File

@@ -3,13 +3,13 @@
@ stub DisplayMessageM
@ stub DisplayMessageToConsole
@ stdcall FreeQuotedString(wstr)
@ stub FreeString
@ stdcall FreeString(wstr)
@ stub GenericMonitor
@ stub GetEnumString
@ stub GetHostMachineInfo
@ stub InitializeConsole
@ stdcall MakeQuotedString(wstr)
@ stub MakeString
@ varargs MakeString(ptr long)
@ stub MatchCmdLine
@ stdcall MatchEnumTag(ptr wstr long ptr ptr)
@ stub MatchTagsInCmdLine

View File

@@ -6,11 +6,23 @@ WINAPI
FreeQuotedString(
_In_ LPWSTR pszQuotedString);
VOID
WINAPI
FreeString(
_In_ LPWSTR pszString);
LPWSTR
WINAPI
MakeQuotedString(
_In_ LPWSTR pszString);
LPWSTR
CDECL
MakeString(
_In_ HANDLE hModule,
_In_ DWORD dwMsgId,
...);
DWORD
WINAPI
NsGetFriendlyNameFromIfName(