Author: tfaber
Date: Fri Oct 17 13:21:06 2014
New Revision: 64782
URL:
http://svn.reactos.org/svn/reactos?rev=64782&view=rev
Log:
[PING]
- Remove a broken "optimization"
CORE-7509 #resolve
Modified:
trunk/reactos/base/applications/network/ping/CMakeLists.txt
trunk/reactos/base/applications/network/ping/ping.c
Modified: trunk/reactos/base/applications/network/ping/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/network/…
==============================================================================
--- trunk/reactos/base/applications/network/ping/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/reactos/base/applications/network/ping/CMakeLists.txt [iso-8859-1] Fri Oct 17
13:21:06 2014
@@ -2,7 +2,7 @@
add_definitions(-D__USE_W32_SOCKETS)
add_executable(ping ping.c ping.rc)
set_module_type(ping win32cui UNICODE)
-add_importlibs(ping ws2_32 msvcrt kernel32)
+add_importlibs(ping user32 ws2_32 msvcrt kernel32)
if(MSVC)
add_importlibs(ping ntdll)
endif()
Modified: trunk/reactos/base/applications/network/ping/ping.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/network/…
==============================================================================
--- trunk/reactos/base/applications/network/ping/ping.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/network/ping/ping.c [iso-8859-1] Fri Oct 17 13:21:06
2014
@@ -114,30 +114,6 @@
}
#endif /* !NDEBUG */
-LPWSTR
-MyLoadString(UINT uID)
-{
- HRSRC hres;
- HGLOBAL hResData;
- WCHAR *pwsz;
- UINT string_num, i;
-
- hres = FindResourceW(NULL, MAKEINTRESOURCEW((LOWORD(uID) >> 4) + 1),
RT_STRING);
- if (!hres) return NULL;
-
- hResData = LoadResource(NULL, hres);
- if (!hResData) return NULL;
-
- pwsz = LockResource(hResData);
- if (!pwsz) return NULL;
-
- string_num = uID & 15;
- for (i = 0; i < string_num; i++)
- pwsz += *pwsz + 1;
-
- return pwsz + 1;
-}
-
void FormatOutput(UINT uID, ...)
{
va_list valist;
@@ -146,15 +122,18 @@
CHAR AnsiBuf[1024];
LPWSTR pBuf = Buf;
PCHAR pAnsiBuf = AnsiBuf;
- LPWSTR Format;
+ WCHAR Format[1024];
DWORD written;
UINT DataLength;
int AnsiLength;
va_start(valist, uID);
- Format = MyLoadString(uID);
- if (!Format) return;
+ if (!LoadString(GetModuleHandle(NULL), uID,
+ Format, sizeof(Format) / sizeof(WCHAR)))
+ {
+ return;
+ }
DataLength = FormatMessage(FORMAT_MESSAGE_FROM_STRING, Format, 0, 0, Buf,\
sizeof(Buf) / sizeof(WCHAR), &valist);
@@ -272,7 +251,7 @@
if (i + 1 < argc)
{
DataSize = wcstoul(argv[++i], NULL, 0);
-
+
if (DataSize > ICMP_MAXSIZE - sizeof(ICMP_ECHO_PACKET) -
sizeof(IPv4_HEADER))
{
FormatOutput(IDS_BAD_VALUE_OPTION_L, ICMP_MAXSIZE - \
@@ -484,7 +463,7 @@
}
}
-static VOID TimeToMsString(LPWSTR String, LARGE_INTEGER Time)
+static VOID TimeToMsString(LPWSTR String, ULONG Length, LARGE_INTEGER Time)
{
WCHAR Convstr[40];
LARGE_INTEGER LargeTime;
@@ -494,8 +473,8 @@
_i64tow(LargeTime.QuadPart, Convstr, 10);
wcscpy(String, Convstr);
- ms = MyLoadString(IDS_MS);
- wcscat(String, ms);
+ ms = String + wcslen(String);
+ LoadString(GetModuleHandle(NULL), IDS_MS, ms, Length - (ms - String));
}
/* Locate the ICMP data and print it. Returns TRUE if the packet was good,
@@ -555,16 +534,13 @@
if ((RelativeTime.QuadPart / TicksPerMs.QuadPart) < 1)
{
- LPWSTR ms1;
-
wcscpy(Sign, L"<");
- ms1 = MyLoadString(IDS_1MS);
- wcscpy(Time, ms1);
+ LoadString(GetModuleHandle(NULL), IDS_1MS, Time, sizeof(Time) / sizeof(WCHAR));
}
else
{
wcscpy(Sign, L"=");
- TimeToMsString(Time, RelativeTime);
+ TimeToMsString(Time, sizeof(Time) / sizeof(WCHAR), RelativeTime);
}
@@ -740,9 +716,9 @@
if (!MinRTTSet)
MinRTT = MaxRTT;
- TimeToMsString(MinTime, MinRTT);
- TimeToMsString(MaxTime, MaxRTT);
- TimeToMsString(AvgTime, AvgRTT);
+ TimeToMsString(MinTime, sizeof(MinTime) / sizeof(WCHAR), MinRTT);
+ TimeToMsString(MaxTime, sizeof(MaxTime) / sizeof(WCHAR), MaxRTT);
+ TimeToMsString(AvgTime, sizeof(AvgTime) / sizeof(WCHAR), AvgRTT);
/* Print statistics */
FormatOutput(IDS_PING_STATISTICS, TargetIP);