[IPHLPAPI_APITEST] CurrPorts seems to confirm that timestamp is really a timestamp
authorPierre Schweitzer <pierre@reactos.org>
Wed, 28 Nov 2018 07:26:55 +0000 (08:26 +0100)
committerPierre Schweitzer <pierre@reactos.org>
Wed, 28 Nov 2018 07:28:37 +0000 (08:28 +0100)
drivers/network/tcpip/tcpip/ninfo.c
modules/rostests/apitests/iphlpapi/AllocateAndGetTcpExTable2FromStack.c

index 3df5204..8ad01fb 100644 (file)
@@ -204,7 +204,7 @@ TDI_STATUS InfoTdiQueryGetConnectionTcpTable(PADDRESS_FILE AddrFile,
     }
 
     TcpRow.dwOwningPid = (DWORD)AddrFile->ProcessId;
     }
 
     TcpRow.dwOwningPid = (DWORD)AddrFile->ProcessId;
-    TcpRow.liCreateTimestamp = AddrFile->CreationTime; /* FIXME: to check */
+    TcpRow.liCreateTimestamp = AddrFile->CreationTime;
 
     if (AddrFile->Listener != NULL)
     {
 
     if (AddrFile->Listener != NULL)
     {
@@ -291,7 +291,7 @@ TDI_STATUS InfoTdiQueryGetConnectionUdpTable(PADDRESS_FILE AddrFile,
     UdpRow.dwLocalAddr = AddrFile->Address.Address.IPv4Address;
     UdpRow.dwLocalPort = AddrFile->Port;
     UdpRow.dwOwningPid = (DWORD)AddrFile->ProcessId;
     UdpRow.dwLocalAddr = AddrFile->Address.Address.IPv4Address;
     UdpRow.dwLocalPort = AddrFile->Port;
     UdpRow.dwOwningPid = (DWORD)AddrFile->ProcessId;
-    UdpRow.liCreateTimestamp = AddrFile->CreationTime;  /* FIXME: to check */
+    UdpRow.liCreateTimestamp = AddrFile->CreationTime;
     UdpRow.dwFlags = 0; /* FIXME */
     if (Class == TcpUdpClassOwner)
     {
     UdpRow.dwFlags = 0; /* FIXME */
     if (Class == TcpUdpClassOwner)
     {
index 002d7d1..1f49664 100644 (file)
@@ -24,7 +24,8 @@ START_TEST(AllocateAndGetTcpExTable2FromStack)
     DWORD i;
     BOOLEAN Found;
     HINSTANCE hIpHlpApi;
     DWORD i;
     BOOLEAN Found;
     HINSTANCE hIpHlpApi;
-    SYSTEMTIME Creation;
+    FILETIME Creation;
+    LARGE_INTEGER CreationTime;
     DWORD Pid = GetCurrentProcessId();
 
     hIpHlpApi = GetModuleHandleW(L"iphlpapi.dll");
     DWORD Pid = GetCurrentProcessId();
 
     hIpHlpApi = GetModuleHandleW(L"iphlpapi.dll");
@@ -47,7 +48,9 @@ START_TEST(AllocateAndGetTcpExTable2FromStack)
         return;
     }
 
         return;
     }
 
-    GetSystemTime(&Creation);
+    GetSystemTimeAsFileTime(&Creation);
+    CreationTime.LowPart = Creation.dwLowDateTime;
+    CreationTime.HighPart = Creation.dwHighDateTime;
 
     sock = socket(AF_INET, SOCK_STREAM, 0);
     if (sock == INVALID_SOCKET)
 
     sock = socket(AF_INET, SOCK_STREAM, 0);
     if (sock == INVALID_SOCKET)
@@ -258,17 +261,10 @@ START_TEST(AllocateAndGetTcpExTable2FromStack)
         }
         else
         {
         }
         else
         {
-            SYSTEMTIME SockTime;
-
             ok(TcpTableOwnerMod->table[i].dwOwningPid == Pid, "Invalid owner\n");
 
             ok(TcpTableOwnerMod->table[i].dwOwningPid == Pid, "Invalid owner\n");
 
-            CopyMemory(&SockTime, &TcpTableOwnerMod->table[i].liCreateTimestamp, sizeof(SYSTEMTIME));
-            ok(Creation.wYear == SockTime.wYear, "Invalid year\n");
-            ok(Creation.wMonth == SockTime.wMonth, "Invalid month\n");
-            ok(Creation.wDayOfWeek == SockTime.wDayOfWeek, "Invalid day of week\n");
-            ok(Creation.wDay == SockTime.wDay, "Invalid day\n");
-            ok(Creation.wHour == SockTime.wHour, "Invalid hour\n");
-            ok(Creation.wMinute == SockTime.wMinute, "Invalid minute\n");
+            ok(TcpTableOwnerMod->table[i].liCreateTimestamp.QuadPart >= CreationTime.QuadPart, "Invalid time\n");
+            ok(TcpTableOwnerMod->table[i].liCreateTimestamp.QuadPart <= CreationTime.QuadPart + 60000000000LL, "Invalid time\n");
         }
 
         HeapFree(GetProcessHeap(), 0, TcpTableOwnerMod);
         }
 
         HeapFree(GetProcessHeap(), 0, TcpTableOwnerMod);
@@ -324,17 +320,10 @@ START_TEST(AllocateAndGetTcpExTable2FromStack)
         }
         else
         {
         }
         else
         {
-            SYSTEMTIME SockTime;
-
             ok(TcpTableOwnerMod->table[i].dwOwningPid == Pid, "Invalid owner\n");
 
             ok(TcpTableOwnerMod->table[i].dwOwningPid == Pid, "Invalid owner\n");
 
-            CopyMemory(&SockTime, &TcpTableOwnerMod->table[i].liCreateTimestamp, sizeof(SYSTEMTIME));
-            ok(Creation.wYear == SockTime.wYear, "Invalid year\n");
-            ok(Creation.wMonth == SockTime.wMonth, "Invalid month\n");
-            ok(Creation.wDayOfWeek == SockTime.wDayOfWeek, "Invalid day of week\n");
-            ok(Creation.wDay == SockTime.wDay, "Invalid day\n");
-            ok(Creation.wHour == SockTime.wHour, "Invalid hour\n");
-            ok(Creation.wMinute == SockTime.wMinute, "Invalid minute\n");
+            ok(TcpTableOwnerMod->table[i].liCreateTimestamp.QuadPart >= CreationTime.QuadPart, "Invalid time\n");
+            ok(TcpTableOwnerMod->table[i].liCreateTimestamp.QuadPart <= CreationTime.QuadPart + 60000000000LL, "Invalid time\n");
         }
 
         HeapFree(GetProcessHeap(), 0, TcpTableOwnerMod);
         }
 
         HeapFree(GetProcessHeap(), 0, TcpTableOwnerMod);