From a70f59b0dd525b4d601a2b40ed4797843fc81254 Mon Sep 17 00:00:00 2001 From: Ivan Georgiev Date: Sat, 14 Mar 2026 12:29:02 +0200 Subject: [PATCH] [DRIVERS] Replace obsolete RtlConvert*ToLargeInteger calls with inline equivalents (#8721) RtlConvertUlongToLargeInteger and RtlConvertLongToLargeInteger are obsolete NT routines that assign a 32-bit integer to LARGE_INTEGER.QuadPart. Replace all driver/DLL usages with inline .QuadPart assignments or standard C/C++ casts. This removes unnecessary function calls. CORE-19438 --- dll/win32/msafd/misc/dllmain.c | 4 ++-- drivers/network/ndis/include/ndissys.h | 2 ++ drivers/network/ndis/ndis/io.c | 7 +++---- drivers/network/ndis/ndis/memory.c | 5 +++-- drivers/wdm/audio/backpln/portcls/port_wavertstream.cpp | 8 ++++---- hal/halx86/generic/usage.c | 4 ++-- 6 files changed, 16 insertions(+), 14 deletions(-) diff --git a/dll/win32/msafd/misc/dllmain.c b/dll/win32/msafd/misc/dllmain.c index a63efd9abe0..504e691d1dd 100644 --- a/dll/win32/msafd/misc/dllmain.c +++ b/dll/win32/msafd/misc/dllmain.c @@ -768,7 +768,7 @@ WSPCloseSocket(IN SOCKET Handle, { if (LingerWait <= 0) { - DisconnectInfo.Timeout = RtlConvertLongToLargeInteger(0); + DisconnectInfo.Timeout.QuadPart = 0LL; DisconnectInfo.DisconnectType = LingerWait < 0 ? AFD_DISCONNECT_SEND : AFD_DISCONNECT_ABORT; if (((DisconnectInfo.DisconnectType & AFD_DISCONNECT_SEND) && (!Socket->SharedData->SendShutdown)) || @@ -2326,7 +2326,7 @@ WSPShutdown(SOCKET Handle, break; } - DisconnectInfo.Timeout = RtlConvertLongToLargeInteger(-1000000); + DisconnectInfo.Timeout.QuadPart = -1000000LL; /* Send IOCTL */ Status = NtDeviceIoControlFile((HANDLE)Handle, diff --git a/drivers/network/ndis/include/ndissys.h b/drivers/network/ndis/include/ndissys.h index f9d99263edb..3b32803d45b 100644 --- a/drivers/network/ndis/include/ndissys.h +++ b/drivers/network/ndis/include/ndissys.h @@ -34,6 +34,8 @@ #define MAX(value1, value2) \ ((value1 > value2)? value1 : value2) +#define RTL_CONSTANT_LARGE_INTEGER(quad_part) {{(quad_part), (quad_part) >> 32}} + #define ExInterlockedRemoveEntryList(_List,_Lock) \ { KIRQL OldIrql; \ KeAcquireSpinLock(_Lock, &OldIrql); \ diff --git a/drivers/network/ndis/ndis/io.c b/drivers/network/ndis/ndis/io.c index 3aab42d8aa0..f356d77abc0 100644 --- a/drivers/network/ndis/ndis/io.c +++ b/drivers/network/ndis/ndis/io.c @@ -1039,16 +1039,15 @@ NdisMRegisterIoPortRange( NDIS_DbgPrint(MAX_TRACE, ("Called - InitialPort 0x%x, NumberOfPorts 0x%x\n", InitialPort, NumberOfPorts)); - memset(&PortAddress, 0, sizeof(PortAddress)); - /* * FIXME: NDIS 5+ completely ignores the InitialPort parameter, but * we don't have a way to get the I/O base address yet (see * NDIS_MINIPORT_BLOCK->AllocatedResources and * NDIS_MINIPORT_BLOCK->AllocatedResourcesTranslated). */ + PortAddress.QuadPart = 0ULL; if(InitialPort) - PortAddress = RtlConvertUlongToLargeInteger(InitialPort); + PortAddress.QuadPart = (ULONGLONG)InitialPort; else ASSERT(FALSE); @@ -1104,7 +1103,7 @@ NdisMDeregisterIoPortRange(IN NDIS_HANDLE MiniportAdapterHandle, */ { PLOGICAL_ADAPTER Adapter = (PLOGICAL_ADAPTER)MiniportAdapterHandle; - PHYSICAL_ADDRESS PortAddress = RtlConvertUlongToLargeInteger(InitialPort); + PHYSICAL_ADDRESS PortAddress = RTL_CONSTANT_LARGE_INTEGER((ULONGLONG)InitialPort); PHYSICAL_ADDRESS TranslatedAddress; ULONG AddressSpace = 1; diff --git a/drivers/network/ndis/ndis/memory.c b/drivers/network/ndis/ndis/memory.c index 6aa05e4fb48..de5fbe0cf52 100644 --- a/drivers/network/ndis/ndis/memory.c +++ b/drivers/network/ndis/ndis/memory.c @@ -77,10 +77,11 @@ NdisAllocateMemory( if (MemoryFlags & NDIS_MEMORY_CONTIGUOUS) { /* Allocate contiguous memory (possibly noncached) */ + const PHYSICAL_ADDRESS ZeroAddress = RTL_CONSTANT_LARGE_INTEGER(0LL); *VirtualAddress = MmAllocateContiguousMemorySpecifyCache(Length, - RtlConvertUlongToLargeInteger(0), + ZeroAddress, HighestAcceptableAddress, - RtlConvertUlongToLargeInteger(0), + ZeroAddress, (MemoryFlags & NDIS_MEMORY_NONCACHED) ? MmNonCached : MmCached); } else if (MemoryFlags & NDIS_MEMORY_NONCACHED) diff --git a/drivers/wdm/audio/backpln/portcls/port_wavertstream.cpp b/drivers/wdm/audio/backpln/portcls/port_wavertstream.cpp index 7f01f35bcb9..b017010d657 100644 --- a/drivers/wdm/audio/backpln/portcls/port_wavertstream.cpp +++ b/drivers/wdm/audio/backpln/portcls/port_wavertstream.cpp @@ -47,7 +47,7 @@ CPortWaveRTStreamInit::AllocatePagesForMdl( IN PHYSICAL_ADDRESS HighAddress, IN SIZE_T TotalBytes) { - return MmAllocatePagesForMdl(RtlConvertUlongToLargeInteger(0), HighAddress, RtlConvertUlongToLargeInteger(0), TotalBytes); + return MmAllocatePagesForMdl(PHYSICAL_ADDRESS{0LL}, HighAddress, PHYSICAL_ADDRESS{0LL}, TotalBytes); } PMDL @@ -61,7 +61,7 @@ CPortWaveRTStreamInit::AllocateContiguousPagesForMdl( PVOID Buffer; PHYSICAL_ADDRESS Address; - Buffer = MmAllocateContiguousMemorySpecifyCache(TotalBytes, LowAddress, HighAddress, RtlConvertUlongToLargeInteger(0), MmNonCached); + Buffer = MmAllocateContiguousMemorySpecifyCache(TotalBytes, LowAddress, HighAddress, PHYSICAL_ADDRESS{0LL}, MmNonCached); if (!Buffer) { DPRINT("MmAllocateContiguousMemorySpecifyCache failed\n"); @@ -72,7 +72,7 @@ CPortWaveRTStreamInit::AllocateContiguousPagesForMdl( MmFreeContiguousMemorySpecifyCache(Buffer, TotalBytes, MmNonCached); - Mdl = MmAllocatePagesForMdl(Address, HighAddress, RtlConvertUlongToLargeInteger(0), TotalBytes); + Mdl = MmAllocatePagesForMdl(Address, HighAddress, PHYSICAL_ADDRESS{0LL}, TotalBytes); if (!Mdl) { DPRINT("MmAllocatePagesForMdl failed\n"); @@ -141,7 +141,7 @@ CPortWaveRTStreamInit::GetPhysicalPageAddress( if (Pages <= Index) { DPRINT("OutOfBounds: Pages %u Index %u\n", Pages, Index); - return RtlConvertUlongToLargeInteger(0); + return PHYSICAL_ADDRESS{0LL}; } Buffer = (PUCHAR)MmGetSystemAddressForMdlSafe(MemoryDescriptorList, LowPagePriority) + (Index * PAGE_SIZE); diff --git a/hal/halx86/generic/usage.c b/hal/halx86/generic/usage.c index 14af02a37fc..08669ebda1e 100644 --- a/hal/halx86/generic/usage.c +++ b/hal/halx86/generic/usage.c @@ -130,7 +130,7 @@ HalpGetResourceSortValue(IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor, /* Interrupt goes by level */ *Scale = 0; - *Value = RtlConvertUlongToLargeInteger(Descriptor->u.Interrupt.Level); + Value->QuadPart = (LONGLONG)Descriptor->u.Interrupt.Level; break; case CmResourceTypePort: @@ -151,7 +151,7 @@ HalpGetResourceSortValue(IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor, /* Anything else */ *Scale = 4; - *Value = RtlConvertUlongToLargeInteger(0); + Value->QuadPart = 0LL; break; } }