Wednesday 21 July 2004

Changes to Win32 API in Longhorn - Windows Base APIs

From WinBase.h:

  • New system exception type EXCEPTION_POSSIBLE_DEADLOCK. Is the OS detecting deadlocks for us?
  • New CreateFile flags: FILE_FLAG_MUI_REDIRECT, FILE_FLAG_MUI_FALLBACK, FILE_FLAG_COPY_TEMPLATE_METADATA - used by the loader?
  • CopyFileEx flag COPY_FILE_COPY_LINK. Symbolic links in the filesystem at last? Yes: CreateSymbolicLinkW.
  • GetQueuedCompletionStatusEx function and new structure OVERLAPPED_ENTRY. Apparently able to remove multiple requests from a completion port in one call.
  • CreateIoCompletionPortEx, takes an additional ObjectFlags DWORD over CreateIoCompletionPort.
  • New I/O completion/asynchronous APIs SetFileCompletionNotificationModes and SetFileIoOverlappedRange.
  • Kernel-level reader-writer locks and condition variables, more like POSIX threads. The relative weakness of the Event has been a long-held criticism of the Windows threading model.
  • Encode/Decode{System}Pointer APIs. I could have sworn I'd seen this documented somewhere, but Google can't find it now. I think the idea is to protect an in-memory pointer to a sensitive structure until required, as a security measure.
  • NUMA support for virtual memory allocation with VirtualAllocExNuma - allocate memory with affinity to one or more nodes. New flag NUMA_NO_PREFERRED_NODE. You can also create file mappings on specific nodes using CreateFileMappingNuma, MapViewOfFileExNuma.
  • INHERIT_CALLER_PRIORITY flag (CreateProcess?)
  • JIT_DEBUG_INFO structure (with 32- and 64-bit variants) which may go along with a new IDebugSymbols3 interface declared in DbgEng.h.
  • New OpenFile flags? OF_MUI_REDIRECT, OF_MUI_FALLBACK. OF_ flags are also used by LZOpenFile and AVIFileOpen.
  • Acquire and Release (memory fence) versions of InterlockedIncrement, Decrement, Exchange, CompareExchange.
  • 32-bit versions of InterlockedAnd, Or, Xor. More Interlocked bitwise operations.
  • Ability to push a whole list onto an interlocked singly-linked list (InterlockedPushListSList).
  • Guaranteed thread stack sizes: new API SetThreadStackGuarantee.
  • Ability to explicitly set thread priority: SetThreadActualPriority. Can query with GetThreadActualPriority.
  • GetThreadStartInformation - find out where any thread started executing, and what the lpParameter parameter passed to CreateThread was.
  • 64-bit tick counter: GetTickCount64. Either higher resolution or greater range (or both?)
  • SetEndOfFileEx. Now you can just say how long the file is, you don't need to SetFilePointer first (and you can also keep your place...)
  • Walk and delete file-system trees: WalkTreeW and DeleteTreeW.
  • Transactional file-system backup semantics: BACKUP_TXFS_DATA used with BackupRead/BackupWrite.
  • Enhanced mutexes: CreateMutexEx{A/W}. You can now use some object flags and specify what access you want to the mutex (perhaps you only need to know it exists, rather than being able to SYNCHRONIZE?) Ditto CreateEventEx, CreateSemaphoreEx, CreateWaitableTimerEx.
  • New Reserve object. Some kind of kernel object (like a job??) to which you can join threads and associate processes, then later 'disjoin' and disassociate them. You can set the bandwidth for the reserve... this must be the resource reservation API, to provide guaranteed QoS to threads and applications. No more choppy Media Player?
  • NeedCurrentDirectoryForExePath API. Takes a string parameter called ExeName and returns a BOOL. A get-out clause for the post- XP SP1 LoadLibrary behaviour?
  • EnumResourceTypesEx - look for resources in MUI DLLs with specific languages? Also EnumResourceNamesEx and EnumResourceLanguagesEx. Updating resources also extended: BeginUpdate/Update/EndUpdateResourceEx.
  • 64-bit systems Windows-on-Win64 file system redirection using Wow64EnableWow64FsRedirection.
  • GetFileAttributesEx new flag GetFileExInfoNoReparse - prevent walking through symlinks?
  • 'Fast' search for FindFirstFileEx: new flag FindExInfoFast.
  • Enhanced I/O cancellation: cancel synchronous I/O occurring on another thread with CancelSynchronousIo, and possibly find out how much data was already transferred on an asynchronous I/O using CancelIoEx, which takes a pointer to an OVERLAPPED structure.
  • Explicit thread pooling: CreateThreadpool, SetThreadpoolThreadMinimum/Maximum, Pause, Resume, CreateThreadpoolGang(?), Timers, Waits.
  • A bit of diagnostics: GetOSProductName.
  • Transactions (transactional file data support?): SetCurrentTransaction, GetCurrentTransaction.

That's a lot of new capabilities right there.

1 comment:

Anonymous said...

Mike, would you be interested in writing an article or two on this topic for the MSDN Longhorn Developer Center web site [1]? If so, mailto:csells@microsoft.com.

Chris Sells
[1] http://msdn.com/longhorn/