Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
aff67aa
Initial plan
Copilot May 1, 2026
8556073
Apply all open UDFS PRs: #62, #108, #193, #216, #218, #269, #277, #28…
Copilot May 1, 2026
7cffc5c
Apply PR #312: no-op macro cleanup, word-at-a-time bitmap check, Sear…
Copilot May 1, 2026
c13c99c
Fix C typedef forward-declaration errors from C++ to C conversion (PR…
Copilot May 1, 2026
6d1a809
Fix remaining C build errors: remove C++ default params and fix DbgPr…
Copilot May 1, 2026
54da39b
Fix mount.c build errors: add missing typedefs and fix comma-expressi…
Copilot May 1, 2026
47acc64
Fix extent.c C4028: correct PSHORT_AD and PEXT_AD types in udf_info.h…
Copilot May 1, 2026
25d50be
Fix phys_lib.c: swap NULL/0 for UDFPhSendIOCTL, add missing Flags arg…
Copilot May 1, 2026
5f862ae
Fix udf_info.c: replace NULL with STATUS_INVALID_PARAMETER in UDFRead…
Copilot May 1, 2026
8189121
Fix cleanup.c build errors: UDFNotifyFullReportChange, forward decl, …
Copilot May 1, 2026
f05fa12
fscntrl.c: replace C++ 'auto RealDevice' with explicit PDEVICE_OBJECT…
Copilot May 1, 2026
27bd821
[UDFS] Replace lowercase false/true with FALSE/TRUE
Copilot May 1, 2026
66ab02a
Fix C++ syntax in strucsup.c: FILE_ID FileId{} -> FileId = {0}, RTL_C…
Copilot May 1, 2026
0b67b5f
Fix PFN_LIST_CORRUPT: skip MmUnlockPages on MDL_SOURCE_IS_NONPAGED_PO…
Copilot May 1, 2026
cd3213f
Apply PR #344: fix access denied on SetRenameInformation for director…
Copilot May 1, 2026
23631ce
UDFS: Add FileAttributeTagInformation support to fix SteamCMD downloa…
Copilot May 1, 2026
64f7e88
UDFS: Skip locality window when allocation exceeds window capacity
Copilot May 1, 2026
8eb4291
plan: remove locality window entirely, always use full partition search
Copilot May 1, 2026
7fa228d
udfs: check incremental free space needed for SetAllocationInformation
Copilot May 1, 2026
a20ec26
udfs: expand locality window to fit requested allocation size in UDFR…
Copilot May 1, 2026
9f5e0bd
Revert "plan: remove locality window entirely, always use full partit…
Copilot May 1, 2026
d12cafc
Apply PR #346: replace locality window with BitmapSearchHint roving p…
Copilot May 2, 2026
7a345e8
alloc.c: clamp EffectiveSearchStart to SearchLim to prevent out-of-ra…
Copilot May 2, 2026
ac796d5
udfs: fix Lcb->Reference never decremented on file close causing rena…
Copilot May 2, 2026
d3a4718
udfs: remove incorrect FcbReference assertions in UDFCloseFileInfoChain
Copilot May 2, 2026
39b87be
udfs: guard CcFlushCache with SharedCacheMap != NULL to fix BUGCHECK …
Copilot May 2, 2026
acb857c
udfs/cleanup: Guard CcSetFileSizes with CcIsFileCached to fix BSOD 0x18
Copilot May 2, 2026
34ce6df
udfs: fix assertion failures and type corruption in extent/alloc-desc…
Copilot May 2, 2026
677791b
udfs: Fix duplicate CcbListResource initialization in UDFCreateFcbNon…
Copilot May 2, 2026
c25c319
udfs: fix assertion failure in UDFCommonCreate error path when Curren…
Copilot May 3, 2026
613258a
Apply PR #193 new commits: Start=4 and devaction.c FS driver bypass
Copilot May 4, 2026
f850953
Replace PR #193 with PR #358: Group=Boot File System, Start=0x3, remo…
Copilot May 12, 2026
df1f304
[FS_REC] Fix UDF recognition for 512-byte sector devices + add AVDP f…
Copilot May 12, 2026
40b7fe2
udfs: fix UDFGetFreeSpace reporting full partition as free on read-on…
Copilot May 12, 2026
219cfd7
udfs: fix SectorSize=0 crash in UDFGetBlockSize during volume verify
Copilot May 12, 2026
6daacbf
udfs: pass no input buffer to CDROM_GET_DRIVE_GEOMETRY_EX
Copilot May 12, 2026
163275a
UDFS: derive HDD LastLBA from partition length
Copilot May 12, 2026
3acc3e4
UDFS: revert broken HDD LastLBA change, keep underflow guard
Copilot May 12, 2026
72e209f
Initialize IRP operation flags in UDFS physical I/O paths
Copilot May 13, 2026
2ebd474
Align UDFS IRP local naming in write path
Copilot May 13, 2026
b564a9a
Fix IRP debug print naming in UDFS write path
Copilot May 13, 2026
aaac78c
Update remaining IRP debug label casing
Copilot May 13, 2026
9313fcd
Add verbose UDFS physical I/O and IOCTL tracing
Copilot May 13, 2026
443823d
Add broader UDFS mount and device-control diagnostics
Copilot May 13, 2026
a261606
Normalize UDFS debug print format specifiers
Copilot May 13, 2026
31d9e9e
Move unreferenced parameter markers in completion routine
Copilot May 13, 2026
89d8617
Use pointer-safe format specifiers in new UDFS traces
Copilot May 13, 2026
efaea67
Address review nits in verbose UDFS diagnostics
Copilot May 13, 2026
49b920f
Harden completion diagnostics against invalid stack access
Copilot May 13, 2026
23008e4
Add NULL guards in verbose completion logging
Copilot May 13, 2026
aab970d
Fail fast on unexpected NULL IRP in debug completions
Copilot May 13, 2026
3d2741c
Use completion-safe return values in NULL-IRP guards
Copilot May 13, 2026
13cdcce
Align verbose diagnostic naming and IOCTL format specifiers
Copilot May 13, 2026
17cea6b
Add verbose ATAPI diagnostic prints for CHS overflow and IDE_STATUS_E…
Copilot May 13, 2026
a304bbc
Fix UDFGetBlockSize to use PartitionLength instead of DiskSize for La…
Copilot May 13, 2026
a9c2179
Lower verbose per-I/O prints to level 2; keep overflow warning and er…
Copilot May 13, 2026
c47c837
Revert "Lower verbose per-I/O prints to level 2; keep overflow warnin…
Copilot May 14, 2026
98444b2
Revert "Fix UDFGetBlockSize to use PartitionLength instead of DiskSiz…
Copilot May 14, 2026
5b8d79f
Revert "Add verbose ATAPI diagnostic prints for CHS overflow and IDE_…
Copilot May 14, 2026
43aa3d8
Revert "Align verbose diagnostic naming and IOCTL format specifiers"
Copilot May 14, 2026
c31d79f
Revert "Use completion-safe return values in NULL-IRP guards"
Copilot May 14, 2026
9c21520
Revert "Fail fast on unexpected NULL IRP in debug completions"
Copilot May 14, 2026
afcf6a2
Revert "Add NULL guards in verbose completion logging"
Copilot May 14, 2026
40d8ce0
Revert "Harden completion diagnostics against invalid stack access"
Copilot May 14, 2026
e084b30
Revert "Address review nits in verbose UDFS diagnostics"
Copilot May 14, 2026
3c481e8
Revert "Use pointer-safe format specifiers in new UDFS traces"
Copilot May 14, 2026
ad31fa0
Revert "Move unreferenced parameter markers in completion routine"
Copilot May 14, 2026
09f7b3a
Revert "Normalize UDFS debug print format specifiers"
Copilot May 14, 2026
f2f5d33
Revert "Add broader UDFS mount and device-control diagnostics"
Copilot May 14, 2026
dcb5fa4
Revert "Add verbose UDFS physical I/O and IOCTL tracing"
Copilot May 14, 2026
5470e01
Revert "Update remaining IRP debug label casing"
Copilot May 14, 2026
dee3ef7
Revert "Fix IRP debug print naming in UDFS write path"
Copilot May 14, 2026
37f638c
Revert "Align UDFS IRP local naming in write path"
Copilot May 14, 2026
4e39b41
Revert "Initialize IRP operation flags in UDFS physical I/O paths"
Copilot May 14, 2026
cdaa9bc
[UDFS] avoid CDROM geometry EX query during mount size detection
Copilot May 14, 2026
c943f4f
[UDFS] Fix HDD mount drive-size query to use plain geometry IOCTL
Copilot May 14, 2026
ada2c1d
Use DiskGeometry for UDFS LastLBA on disk path
Copilot May 14, 2026
582e882
Guard DiskGeometry LastLBA conversion overflow
Copilot May 14, 2026
2c5c025
Refine LastLBA bounds check logic
Copilot May 14, 2026
47d60ea
Clarify 64-bit geometry multiplication and bounds
Copilot May 14, 2026
e8103e7
UDFS: restore HDD LastLBA disk-geometry block style
Copilot May 14, 2026
1ca061f
UDFS: keep prior LastLBA style with minimal geometry safety
Copilot May 14, 2026
8f703cf
UDFS: restore old-style HDD LastLBA expression using DiskGeometry
Copilot May 14, 2026
fe55561
UDFS: restore distinct HDD LastLBA DiskGeometry path
Copilot May 14, 2026
91c46c9
Reverted latest phys_lib.c changes
Zero3K20 May 15, 2026
b3e2a85
Change DiskGeometryEx and related IOCTL to the older variant
Zero3K20 May 15, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions drivers/filesystems/fs_rec/fs_rec.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ typedef struct BIOS_PARAMETER_BLOCK
USHORT BackupBootSector;
} BIOS_PARAMETER_BLOCK, *PBIOS_PARAMETER_BLOCK;

/* UDFS Tag Identifier for Anchor Volume Descriptor Pointer (ECMA-167 7.2) */
#define UDFS_TAG_ID_AVDP 0x0002

/* UDFS Structures */
#include <pshpack1.h>
typedef struct _TAG
Expand Down
37 changes: 36 additions & 1 deletion drivers/filesystems/fs_rec/udfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ FsRecIsUdfsVolume(IN PDEVICE_OBJECT DeviceObject,
int i;
PAGED_CODE();

Offset.QuadPart = 16 * SectorSize;
/* Per ECMA-167 section 8.4.1, the Volume Recognition Sequence starts at
* a fixed byte offset of 32768, regardless of the physical sector size.
* Using 16 * SectorSize is only correct for 2048-byte sectors (CD-ROM);
* for 512-byte sector devices (e.g. VHDs) it gives 8192 instead of 32768,
* causing the VRS to be missed entirely. */
Offset.QuadPart = UDFS_VRS_START_OFFSET;
for (i = 0; i < 16; i++)
{
if (!FsRecReadBlock(DeviceObject,
Expand All @@ -55,6 +60,7 @@ FsRecIsUdfsVolume(IN PDEVICE_OBJECT DeviceObject,
{
DPRINT("NSR03 found\n");
ret = TRUE;
break;
}

if (!strncmp((const char*)VolumeStructDesc->Ident,
Expand All @@ -63,6 +69,7 @@ FsRecIsUdfsVolume(IN PDEVICE_OBJECT DeviceObject,
{
DPRINT("NSR02 found\n");
ret = TRUE;
break;
}

if (!strncmp((const char*)VolumeStructDesc->Ident,
Expand Down Expand Up @@ -98,6 +105,34 @@ FsRecIsUdfsVolume(IN PDEVICE_OBJECT DeviceObject,

if (VolumeStructDesc)
ExFreePool(VolumeStructDesc);

/* If the VRS scan did not find an NSR descriptor, fall back to checking
* for the Anchor Volume Descriptor Pointer at sector 256. This covers
* disks where the VRS is absent or could not be read, and mirrors the
* detection approach used by the UDFS driver itself. */
if (!ret)
{
PAVDP AnchorVDP = NULL;

Offset.QuadPart = (LONGLONG)UDFS_AVDP_SECTOR * SectorSize;
if (FsRecReadBlock(DeviceObject,
&Offset,
sizeof(AVDP),
SectorSize,
(PVOID *)&AnchorVDP,
NULL))
{
/* Tag identifier 2 = Anchor Volume Descriptor Pointer (ECMA-167 7.2) */
if (AnchorVDP->DescriptorTag.Identifier == UDFS_TAG_ID_AVDP &&
AnchorVDP->DescriptorTag.Location == UDFS_AVDP_SECTOR)
{
DPRINT("AVDP found at sector 256\n");
ret = TRUE;
}
ExFreePool(AnchorVDP);
}
}

return ret;
}

Expand Down
74 changes: 37 additions & 37 deletions drivers/filesystems/udfs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,43 @@
include_directories(Include)

list(APPEND SOURCE
udf_info/alloc.cpp
udf_info/dirtree.cpp
udf_info/extent.cpp
udf_info/mount.cpp
udf_info/phys_eject.cpp
udf_info/physical.cpp
udf_info/remap.cpp
udf_info/udf_info.cpp
cleanup.cpp
close.cpp
create.cpp
devcntrl.cpp
dircntrl.cpp
env_spec.cpp
fastio.cpp
fileinfo.cpp
flush.cpp
fscntrl.cpp
lockctrl.cpp
mem.cpp
misc.cpp
namesup.cpp
prefxsup.cpp
pnp.cpp
read.cpp
secursup.cpp
shutdown.cpp
sys_spec.cpp
udf_dbg.cpp
udfinit.cpp
unload.cpp
verfysup.cpp
volinfo.cpp
write.cpp
strucsup.cpp
filobsup.cpp
udfdata.cpp
udf_info/alloc.c
udf_info/dirtree.c
udf_info/extent.c
udf_info/mount.c
udf_info/phys_eject.c
udf_info/physical.c
udf_info/remap.c
udf_info/udf_info.c
cleanup.c
close.c
create.c
devcntrl.c
dircntrl.c
env_spec.c
fastio.c
fileinfo.c
flush.c
fscntrl.c
lockctrl.c
mem.c
misc.c
namesup.c
prefxsup.c
pnp.c
read.c
secursup.c
shutdown.c
sys_spec.c
udf_dbg.c
udfinit.c
unload.c
verfysup.c
volinfo.c
write.c
strucsup.c
filobsup.c
udfdata.c
udffs.h)

add_library(udfs MODULE ${SOURCE} udffs.rc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,10 @@ UDFAttributesToUDF(
IN ULONG NTAttr
)
{
PULONG attr; //permissions
PUSHORT Flags;
PUCHAR Type;
PUCHAR FCharact;
PULONG attr = NULL; //permissions
PUSHORT Flags = NULL;
PUCHAR Type = NULL;
PUCHAR FCharact = NULL;

NTAttr &= UDF_VALID_FILE_ATTRIBUTES;

Expand Down Expand Up @@ -240,7 +240,7 @@ UDFFileDirInfoToNT(
PEXTENDED_FILE_ENTRY ExFileEntry;
USHORT Ident;
BOOLEAN ReadSizes = FALSE;
NTSTATUS status;
NTSTATUS status = STATUS_SUCCESS;
PFCB Fcb;

UDFPrint(("@=%#x, FileDirNdx %x\n", &Vcb, FileDirNdx));
Expand Down Expand Up @@ -575,7 +575,7 @@ UDFDoesOSAllowFileToBeTargetForRename__(
IN PUDF_FILE_INFO FileInfo
)
{
NTSTATUS RC;
NTSTATUS RC = STATUS_SUCCESS;

if (UDFIsADirectory(FileInfo))
return STATUS_ACCESS_DENIED;
Expand Down
2 changes: 1 addition & 1 deletion drivers/filesystems/udfs/Include/Sys_spec_lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ __inline LARGE_INTEGER UDFMakeLargeInteger(LONGLONG value) {

#define UDFGetNTFileId(Vcb, fi) \
UDFMakeLargeInteger((((fi)->Dloc->FELoc.Mapping[0].extLocation - UDFPartStart(Vcb, -2)) + \
((LONGLONG)Vcb<<32)))
((LONGLONG)(ULONG_PTR)Vcb<<32)))

#define UnicodeIsPrint(a) RtlIsValidOemCharacter(&(a))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,12 @@

#ifdef MY_USE_INTERNAL_MEMMANAGER

#ifdef _X86_

__inline VOID DbgTouch(IN PVOID addr)
{
__asm {
mov eax,addr
mov al,[byte ptr eax]
}
volatile UCHAR a = ((volatile UCHAR*)addr)[0];
(void)a;
}

#else // NO X86 optimization , use generic C/C++

__inline VOID DbgTouch(IN PVOID addr)
{
UCHAR a = ((PUCHAR)addr)[0];
}

#endif // _X86_

//MEM_ALLOC_DESC Allocs[MY_HEAP_MAX_BLOCKS];

MEM_FRAME_ALLOC_DESC FrameList[MY_HEAP_MAX_FRAMES];
Expand All @@ -39,23 +26,23 @@ InitLockMemoryManager() {
KeInitializeSpinLock(&FrameLock);
return STATUS_SUCCESS;
}
#define DeinitLockMemoryManager() {NOTHING;}
#define DeinitLockMemoryManager() ((void)0)
#else //MEM_LOCK_BY_SPINLOCK
ERESOURCE FrameLock;
#define LockMemoryManager() ExAcquireResourceExclusiveLite(&FrameLock, TRUE)
#define UnlockMemoryManager() ExReleaseResourceForThreadLite(&FrameLock, ExGetCurrentResourceThread())
#define InitLockMemoryManager() ExInitializeResourceLite(&FrameLock)
#define DeinitLockMemoryManager() ExDeleteResourceLite(&FrameLock)
#endif //MEM_LOCK_BY_SPINLOCK
ULONG FrameCount;
ULONG LastFrame;
ULONG FrameCount = 0;
ULONG LastFrame = 0;
BOOLEAN MyMemInitialized = FALSE;

#define MyAllocIsFrameFree(FrameList, i) \
(!(FrameList[i].LastUsed || FrameList[i].FirstFree))

#ifdef UDF_DBG
ULONG MemTotalAllocated;
ULONG MemTotalAllocated = 0;
PCHAR BreakAddr;

VOID
Expand All @@ -64,7 +51,7 @@ MyAllocDumpDescr(
ULONG i
)
{
BOOLEAN Used;
BOOLEAN Used = FALSE;

Used = (Allocs[i].Len & MY_HEAP_FLAG_USED) ? TRUE : FALSE;
UDFPrint(("block %x \t%s addr %x len %x \t", i, Used ? "used" : "free", Allocs[i].Addr, (Allocs[i].Len) & MY_HEAP_FLAG_LEN_MASK));
Expand Down Expand Up @@ -93,11 +80,11 @@ MyAllocDumpFrame(
ULONG Frame
)
{
ULONG i;
ULONG i = 0;
PMEM_ALLOC_DESC Allocs;
Allocs = FrameList[Frame].Frame;
ULONG k=0;
BOOLEAN Used;
BOOLEAN Used = FALSE;
#ifdef DUMP_MEM_FRAMES
if (!MyDumpMem)
#endif //DUMP_MEM_FRAMES
Expand Down Expand Up @@ -132,7 +119,7 @@ MyAllocDumpFrames(
VOID
)
{
ULONG i;
ULONG i = 0;

for(i=0;i<MY_HEAP_MAX_FRAMES; i++) {
if (FrameList[i].Frame) {
Expand Down Expand Up @@ -184,9 +171,9 @@ MyAllocCheck(
//#endif //CHECK_ALLOC_FRAMES
#else

#define MyAllocDumpFrame(a) {}
#define MyAllocCheck(a) {}
#define MyAllocDumpFrames() {}
#define MyAllocDumpFrame(a) ((void)0)
#define MyAllocCheck(a) ((void)0)
#define MyAllocDumpFrames() ((void)0)

#endif // UDF_DBG

Expand All @@ -206,14 +193,14 @@ MyAllocatePoolInFrame(
#endif //MY_HEAP_TRACK_REF
)
{
ULONG addr;
ULONG i;
ULONG min_len;
ULONG best_i;
ULONG addr = 0;
ULONG i = 0;
ULONG min_len = 0;
ULONG best_i = 0;
PMEM_ALLOC_DESC Allocs;
PMEM_ALLOC_DESC Allocs0;
ULONG LastUsed, FirstFree;
ULONG l;
ULONG LastUsed = 0, FirstFree = 0;
ULONG l = 0;

#ifdef CHECK_ALLOC_FRAMES
MyAllocCheck(Frame);
Expand Down Expand Up @@ -313,9 +300,9 @@ MyFindMemDescByAddr(
PCHAR addr
)
{
ULONG i;
ULONG left;
ULONG right;
ULONG i = 0;
ULONG left = 0;
ULONG right = 0;
PMEM_ALLOC_DESC Allocs;

Allocs = FrameList[Frame].Frame;
Expand Down Expand Up @@ -356,8 +343,8 @@ MyFreePoolInFrame(
)
{
LONG i, j;
ULONG pc;
ULONG len, len2;
ULONG pc = 0;
ULONG len = 0, len2 = 0;
PMEM_ALLOC_DESC Allocs;

Allocs = FrameList[Frame].Frame;
Expand Down Expand Up @@ -622,8 +609,8 @@ MyAllocatePool(
#endif //MY_HEAP_TRACK_REF
)
{
ULONG i;
ULONG addr;
ULONG i = 0;
ULONG addr = 0;

// UDFPrint(("MemFrames: %x\n",FrameCount));

Expand Down Expand Up @@ -708,7 +695,7 @@ MyFindFrameByAddr(
PCHAR addr
)
{
ULONG i;
ULONG i = 0;
// ULONG j;
PMEM_ALLOC_DESC Allocs;

Expand Down Expand Up @@ -780,7 +767,7 @@ MyReallocPool(
#endif
)
{
ULONG i;
ULONG i = 0;
PCHAR new_buff;
#ifdef MY_HEAP_TRACK_REF
PCHAR Tag;
Expand Down Expand Up @@ -855,12 +842,12 @@ MyFindMemDescByRangeInFrame(
PCHAR addr
)
{
ULONG i;
ULONG left;
ULONG right;
ULONG i = 0;
ULONG left = 0;
ULONG right = 0;
PMEM_ALLOC_DESC Allocs;
ULONG curaddr;
ULONG curlen;
ULONG curaddr = 0;
ULONG curlen = 0;

Allocs = FrameList[Frame].Frame;
// i = FrameList[Frame].LastUsed >> 1;
Expand Down Expand Up @@ -933,7 +920,7 @@ MyAllocInit(VOID)
VOID
MyAllocRelease(VOID)
{
ULONG i;
ULONG i = 0;
PMEM_ALLOC_DESC Allocs;

if (!MyMemInitialized)
Expand Down
Loading