ReactOS 0.4.16-dev-965-gf669426
iso.c File Reference
#include <freeldr.h>
#include <debug.h>
Include dependency graph for iso.c:

Go to the source code of this file.

Classes

struct  _ISO_VOLUME_INFO
 

Macros

#define SECTORSIZE   2048
 
#define TAG_ISO_VOLUME   'VosI'
 
#define TAG_ISO_BUFFER   'BosI'
 
#define TAG_ISO_FILE   'FosI'
 

Typedefs

typedef struct _ISO_VOLUME_INFO ISO_VOLUME_INFO
 
typedef struct _ISO_VOLUME_INFOPISO_VOLUME_INFO
 

Functions

 DBG_DEFAULT_CHANNEL (FILESYSTEM)
 
static PCSTR IsoLastPathSeparator (_In_ PCSTR Path)
 
static BOOLEAN IsoSearchDirectoryBufferForFile (PVOID DirectoryBuffer, ULONG DirectoryLength, PCHAR FileName, PISO_FILE_INFO IsoFileInfoPointer)
 
static ARC_STATUS IsoBufferDirectory (ULONG DeviceId, ULONG DirectoryStartSector, ULONG DirectoryLength, PVOID *pDirectoryBuffer)
 
static ARC_STATUS IsoLookupFile (PCSTR FileName, ULONG DeviceId, PISO_FILE_INFO IsoFileInfo)
 
static ARC_STATUS IsoClose (ULONG FileId)
 
static ARC_STATUS IsoGetFileInformation (ULONG FileId, FILEINFORMATION *Information)
 
static ARC_STATUS IsoOpen (CHAR *Path, OPENMODE OpenMode, ULONG *FileId)
 
static ARC_STATUS IsoRead (ULONG FileId, VOID *Buffer, ULONG N, ULONG *Count)
 
static ARC_STATUS IsoSeek (ULONG FileId, LARGE_INTEGER *Position, SEEKMODE SeekMode)
 
const DEVVTBLIsoMount (ULONG DeviceId)
 

Variables

static PISO_VOLUME_INFO IsoVolumes [MAX_FDS]
 
static const DEVVTBL Iso9660FuncTable
 

Macro Definition Documentation

◆ SECTORSIZE

#define SECTORSIZE   2048

Definition at line 27 of file iso.c.

◆ TAG_ISO_BUFFER

#define TAG_ISO_BUFFER   'BosI'

Definition at line 29 of file iso.c.

◆ TAG_ISO_FILE

#define TAG_ISO_FILE   'FosI'

Definition at line 30 of file iso.c.

◆ TAG_ISO_VOLUME

#define TAG_ISO_VOLUME   'VosI'

Definition at line 28 of file iso.c.

Typedef Documentation

◆ ISO_VOLUME_INFO

◆ PISO_VOLUME_INFO

Function Documentation

◆ DBG_DEFAULT_CHANNEL()

DBG_DEFAULT_CHANNEL ( FILESYSTEM  )

◆ IsoBufferDirectory()

static ARC_STATUS IsoBufferDirectory ( ULONG  DeviceId,
ULONG  DirectoryStartSector,
ULONG  DirectoryLength,
PVOID pDirectoryBuffer 
)
static

Definition at line 128 of file iso.c.

130{
131 PVOID DirectoryBuffer;
134 ULONG Count;
136
137 TRACE("IsoBufferDirectory() DirectoryStartSector = %d DirectoryLength = %d\n", DirectoryStartSector, DirectoryLength);
138
139 SectorCount = ROUND_UP(DirectoryLength, SECTORSIZE) / SECTORSIZE;
140 TRACE("Trying to read (DirectoryCount) %d sectors.\n", SectorCount);
141
142 //
143 // Attempt to allocate memory for directory buffer
144 //
145 TRACE("Trying to allocate (DirectoryLength) %d bytes.\n", DirectoryLength);
146 DirectoryBuffer = FrLdrTempAlloc(DirectoryLength, TAG_ISO_BUFFER);
147 if (!DirectoryBuffer)
148 return ENOMEM;
149
150 //
151 // Now read directory contents into DirectoryBuffer
152 //
153 Position.HighPart = 0;
154 Position.LowPart = DirectoryStartSector * SECTORSIZE;
155 Status = ArcSeek(DeviceId, &Position, SeekAbsolute);
156 if (Status != ESUCCESS)
157 {
158 FrLdrTempFree(DirectoryBuffer, TAG_ISO_BUFFER);
159 return Status;
160 }
161 Status = ArcRead(DeviceId, DirectoryBuffer, SectorCount * SECTORSIZE, &Count);
163 {
164 FrLdrTempFree(DirectoryBuffer, TAG_ISO_BUFFER);
165 return EIO;
166 }
167
168 *pDirectoryBuffer = DirectoryBuffer;
169 return ESUCCESS;
170}
#define ENOMEM
Definition: acclib.h:84
#define EIO
Definition: acclib.h:81
ARC_STATUS ArcSeek(ULONG FileId, LARGE_INTEGER *Position, SEEKMODE SeekMode)
Definition: fs.c:455
ARC_STATUS ArcRead(ULONG FileId, VOID *Buffer, ULONG N, ULONG *Count)
Definition: fs.c:448
VOID FrLdrTempFree(PVOID Allocation, ULONG Tag)
Definition: heap.c:553
PVOID FrLdrTempAlloc(_In_ SIZE_T Size, _In_ ULONG Tag)
Definition: heap.c:545
#define TAG_ISO_BUFFER
Definition: iso.c:29
#define SECTORSIZE
Definition: iso.c:27
#define ROUND_UP(n, align)
Definition: eventvwr.h:34
Status
Definition: gdiplustypes.h:25
int Count
Definition: noreturn.cpp:7
ULONG SectorCount
Definition: part_xbox.c:31
@ ESUCCESS
Definition: arc.h:32
ULONG ARC_STATUS
Definition: arc.h:4
@ SeekAbsolute
Definition: arc.h:59
#define TRACE(s)
Definition: solgame.cpp:4
static COORD Position
Definition: mouse.c:34
uint32_t ULONG
Definition: typedefs.h:59

Referenced by IsoLookupFile().

◆ IsoClose()

static ARC_STATUS IsoClose ( ULONG  FileId)
static

Definition at line 305 of file iso.c.

306{
309 return ESUCCESS;
310}
PVOID FsGetDeviceSpecific(ULONG FileId)
Definition: fs.c:632
#define TAG_ISO_FILE
Definition: iso.c:30
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
Definition: fltkernel.h:1231

◆ IsoGetFileInformation()

static ARC_STATUS IsoGetFileInformation ( ULONG  FileId,
FILEINFORMATION Information 
)
static

Definition at line 313 of file iso.c.

314{
316
318 Information->EndingAddress.LowPart = FileHandle->FileSize;
319 Information->CurrentAddress.LowPart = FileHandle->FilePointer;
320
321 TRACE("IsoGetFileInformation(%lu) -> FileSize = %lu, FilePointer = 0x%lx\n",
322 FileId, Information->EndingAddress.LowPart, Information->CurrentAddress.LowPart);
323
324 return ESUCCESS;
325}
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
_In_ WDFREQUEST _In_ NTSTATUS _In_ ULONG_PTR Information
Definition: wdfrequest.h:1049

◆ IsoLastPathSeparator()

static PCSTR IsoLastPathSeparator ( _In_ PCSTR  Path)
static

Definition at line 46 of file iso.c.

48{
49 PCSTR Last = NULL;
50
51 ASSERT(Path != NULL);
52
53 while (*Path != ANSI_NULL)
54 {
55 if (*Path == '\\' || *Path == '/')
56 Last = Path;
57
58 ++Path;
59 }
60
61 return Last;
62}
PRTL_UNICODE_STRING_BUFFER Path
#define NULL
Definition: types.h:112
#define ASSERT(a)
Definition: mode.c:44
#define ANSI_NULL
const char * PCSTR
Definition: typedefs.h:52

Referenced by IsoLookupFile().

◆ IsoLookupFile()

static ARC_STATUS IsoLookupFile ( PCSTR  FileName,
ULONG  DeviceId,
PISO_FILE_INFO  IsoFileInfo 
)
static

Definition at line 178 of file iso.c.

179{
180 PCSTR FullPath = FileName;
182 PCSTR FileNameStr;
183 ULONG i, DirectoryPathLength, DirectorySector, DirectoryLength;
184 PVOID DirectoryBuffer;
185 ULONG NumberOfPathParts;
186 CHAR PathBuffer[261];
187 CHAR* PathPart;
189 BOOLEAN DoFullLookup;
190
191 TRACE("IsoLookupFile() FileName = %s\n", FileName);
192
193 Volume = IsoVolumes[DeviceId];
194
195 /*
196 * Extract the file name
197 * '\test.ini' --> 'test.ini'
198 * '\folder\app.exe' --> 'app.exe'
199 */
200 FileNameStr = IsoLastPathSeparator(FileName) + 1;
201
202 /*
203 * Extract the directory path, including trailing slash
204 * '\test.ini' --> '\'
205 * '\folder\app.exe' --> '\folder\'
206 */
207 DirectoryPathLength = FileNameStr - FileName;
208
209 /* See if this directory has been buffered before */
210 DoFullLookup = (DirectoryPathLength != Volume->DirectoryPathLength) ||
211 !RtlEqualMemory(FileName, Volume->DirectoryPath, DirectoryPathLength);
212 if (!DoFullLookup)
213 {
214 PathPart = (CHAR*)FileNameStr;
215 DirectoryBuffer = Volume->DirectoryBuffer;
216 DirectoryLength = Volume->DirectoryLength;
217
218 NumberOfPathParts = 1;
219 }
220 else
221 {
222 PathPart = PathBuffer;
223 DirectorySector = Volume->PvdDirectorySector;
224 DirectoryLength = Volume->PvdDirectoryLength;
225
226 /* Skip leading path separator, if any */
227 if (*FileName == '\\' || *FileName == '/')
228 ++FileName;
229
230 /* Figure out how many sub-directories we are nested in */
231 NumberOfPathParts = FsGetNumPathParts(FileName);
232 }
233
234 //
235 // Loop once for each part
236 //
237 for (i=0; i<NumberOfPathParts; i++)
238 {
239 if (DoFullLookup)
240 {
241 /* Get first path part */
243
244 /* Advance to the next part of the path */
245 while ((*FileName != ANSI_NULL) && (*FileName != '\\') && (*FileName != '/'))
246 {
247 FileName++;
248 }
249 FileName++;
250
251 /* Buffer the directory contents */
252 Status = IsoBufferDirectory(DeviceId,
253 DirectorySector,
254 DirectoryLength,
255 &DirectoryBuffer);
256 if (Status != ESUCCESS)
257 return Status;
258
259 /* Save the directory buffer */
260 if ((i + 1) >= NumberOfPathParts)
261 {
262 if (Volume->DirectoryBuffer)
263 FrLdrTempFree(Volume->DirectoryBuffer, TAG_ISO_BUFFER);
264
265 Volume->DirectoryPathLength = DirectoryPathLength;
266 Volume->DirectoryBuffer = DirectoryBuffer;
267 Volume->DirectoryLength = DirectoryLength;
268
269 RtlCopyMemory(Volume->DirectoryPath, FullPath, DirectoryPathLength);
270 }
271 }
272
273 /* Search for file name in directory */
274 if (!IsoSearchDirectoryBufferForFile(DirectoryBuffer,
275 DirectoryLength,
276 PathPart,
277 IsoFileInfo))
278 {
279 /* Free the directory buffer that wasn't cached */
280 if ((i + 1) < NumberOfPathParts)
281 {
282 ASSERT(DirectoryBuffer != Volume->DirectoryBuffer);
283 FrLdrTempFree(DirectoryBuffer, TAG_ISO_BUFFER);
284 }
285 return ENOENT;
286 }
287
288 //
289 // If we have another sub-directory to go then
290 // grab the start sector and file size
291 //
292 if ((i+1) < NumberOfPathParts)
293 {
294 FrLdrTempFree(DirectoryBuffer, TAG_ISO_BUFFER);
295
296 DirectorySector = IsoFileInfo->FileStart;
297 DirectoryLength = IsoFileInfo->FileSize;
298 }
299 }
300
301 return ESUCCESS;
302}
unsigned char BOOLEAN
#define ENOENT
Definition: acclib.h:79
ULONG FsGetNumPathParts(PCSTR Path)
Definition: fs.c:540
VOID FsGetFirstNameFromPath(PCHAR Buffer, PCSTR Path)
Definition: fs.c:568
static PCSTR IsoLastPathSeparator(_In_ PCSTR Path)
Definition: iso.c:46
static PISO_VOLUME_INFO IsoVolumes[MAX_FDS]
Definition: iso.c:42
static ARC_STATUS IsoBufferDirectory(ULONG DeviceId, ULONG DirectoryStartSector, ULONG DirectoryLength, PVOID *pDirectoryBuffer)
Definition: iso.c:128
static BOOLEAN IsoSearchDirectoryBufferForFile(PVOID DirectoryBuffer, ULONG DirectoryLength, PCHAR FileName, PISO_FILE_INFO IsoFileInfoPointer)
Definition: iso.c:64
struct _FileName FileName
Definition: fatprocs.h:897
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define RtlEqualMemory(dst, src, len)
Definition: kdvm.h:18
UNICODE_STRING Volume
Definition: fltkernel.h:1172
ULONG FileStart
Definition: iso.h:95
ULONG FileSize
Definition: iso.h:96
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
char CHAR
Definition: xmlstorage.h:175

Referenced by IsoOpen().

◆ IsoMount()

const DEVVTBL * IsoMount ( ULONG  DeviceId)

Definition at line 560 of file iso.c.

561{
563 PPVD Pvd = (PPVD)Buffer;
565 ULONG Count;
568
569 TRACE("Enter IsoMount(%lu)\n", DeviceId);
570
571 /*
572 * Read the Primary Volume Descriptor
573 */
574 Position.HighPart = 0;
575 Position.LowPart = 16 * SECTORSIZE;
576 Status = ArcSeek(DeviceId, &Position, SeekAbsolute);
577 if (Status != ESUCCESS)
578 return NULL;
579 Status = ArcRead(DeviceId, Pvd, SECTORSIZE, &Count);
580 if (Status != ESUCCESS || Count < sizeof(PVD))
581 return NULL;
582
583 /* Check if the PVD is valid */
584 if (!(Pvd->VdType == 1 && RtlEqualMemory(Pvd->StandardId, "CD001", 5) && Pvd->VdVersion == 1))
585 {
586 WARN("Unrecognized CDROM format\n");
587 return NULL;
588 }
589 if (Pvd->LogicalBlockSizeL != SECTORSIZE)
590 {
591 ERR("Unsupported LogicalBlockSize %u\n", Pvd->LogicalBlockSizeL);
592 return NULL;
593 }
594
595 Count = (ULONG)((ULONGLONG)Pvd->VolumeSpaceSizeL * SECTORSIZE / 1024 / 1024);
596 TRACE("Recognized ISO9660 drive, size %lu MB (%lu sectors)\n",
597 Count, Pvd->VolumeSpaceSizeL);
598
600 if (!Volume)
601 return NULL;
602 RtlZeroMemory(Volume, sizeof(*Volume));
603
604 /* Cache the PVD information */
605 Volume->PvdDirectorySector = Pvd->RootDirRecord.ExtentLocationL;
606 Volume->PvdDirectoryLength = Pvd->RootDirRecord.DataLengthL;
607
608 IsoVolumes[DeviceId] = Volume;
609
610 /* Everything OK, return the ISO9660 function table */
611 return &Iso9660FuncTable;
612}
#define WARN(fmt,...)
Definition: precomp.h:61
#define ERR(fmt,...)
Definition: precomp.h:57
#define TAG_ISO_VOLUME
Definition: iso.c:28
static const DEVVTBL Iso9660FuncTable
Definition: iso.c:550
Definition: bufpool.h:45
struct _PVD * PPVD
ULONG ExtentLocationL
Definition: iso.h:27
ULONG DataLengthL
Definition: iso.h:29
Definition: iso.h:61
DIR_RECORD RootDirRecord
Definition: iso.h:84
USHORT LogicalBlockSizeL
Definition: iso.h:76
ULONG VolumeSpaceSizeL
Definition: iso.h:69
UCHAR StandardId[5]
Definition: iso.h:63
UCHAR VdType
Definition: iso.h:62
UCHAR VdVersion
Definition: iso.h:64
uint64_t ULONGLONG
Definition: typedefs.h:67
unsigned char UCHAR
Definition: xmlstorage.h:181

◆ IsoOpen()

static ARC_STATUS IsoOpen ( CHAR Path,
OPENMODE  OpenMode,
ULONG FileId 
)
static

Definition at line 328 of file iso.c.

329{
331 ULONG DeviceId;
333
334 if (OpenMode != OpenReadOnly)
335 return EACCES;
336
337 DeviceId = FsGetDeviceId(*FileId);
338
339 TRACE("IsoOpen() FileName = %s\n", Path);
340
342 if (!FileHandle)
343 return ENOMEM;
344
345 Status = IsoLookupFile(Path, DeviceId, FileHandle);
346 if (Status != ESUCCESS)
347 {
349 return ENOENT;
350 }
351
353 return ESUCCESS;
354}
#define EACCES
Definition: acclib.h:85
VOID FsSetDeviceSpecific(ULONG FileId, PVOID Specific)
Definition: fs.c:625
ULONG FsGetDeviceId(ULONG FileId)
Definition: fs.c:639
static ARC_STATUS IsoLookupFile(PCSTR FileName, ULONG DeviceId, PISO_FILE_INFO IsoFileInfo)
Definition: iso.c:178
@ OpenReadOnly
Definition: arc.h:65

◆ IsoRead()

static ARC_STATUS IsoRead ( ULONG  FileId,
VOID Buffer,
ULONG  N,
ULONG Count 
)
static

Definition at line 357 of file iso.c.

358{
361 UCHAR SectorBuffer[SECTORSIZE];
363 ULONG DeviceId;
364 ULONG SectorNumber;
365 ULONG OffsetInSector;
366 ULONG LengthInSector;
367 ULONG NumberOfSectors;
369
370 TRACE("IsoRead() Buffer = %p, N = %lu\n", Buffer, N);
371
372 DeviceId = FsGetDeviceId(FileId);
373 *Count = 0;
374
375 //
376 // If the user is trying to read past the end of
377 // the file then return success with Count == 0.
378 //
379 if (FileHandle->FilePointer >= FileHandle->FileSize)
380 {
381 return ESUCCESS;
382 }
383
384 //
385 // If the user is trying to read more than there is to read
386 // then adjust the amount to read.
387 //
388 if (FileHandle->FilePointer + N > FileHandle->FileSize)
389 {
390 N = FileHandle->FileSize - FileHandle->FilePointer;
391 }
392
393 //
394 // Ok, now we have to perform at most 3 calculations
395 // I'll draw you a picture (using nifty ASCII art):
396 //
397 // CurrentFilePointer -+
398 // |
399 // +----------------+
400 // |
401 // +-----------+-----------+-----------+-----------+
402 // | Sector 1 | Sector 2 | Sector 3 | Sector 4 |
403 // +-----------+-----------+-----------+-----------+
404 // | |
405 // +---------------+--------------------+
406 // |
407 // N -----------------+
408 //
409 // 1 - The first calculation (and read) will align
410 // the file pointer with the next sector
411 // boundary (if we are supposed to read that much)
412 // 2 - The next calculation (and read) will read
413 // in all the full sectors that the requested
414 // amount of data would cover (in this case
415 // sectors 2 & 3).
416 // 3 - The last calculation (and read) would read
417 // in the remainder of the data requested out of
418 // the last sector.
419 //
420
421
422 //
423 // Only do the first read if we
424 // aren't aligned on a cluster boundary
425 //
426 if (FileHandle->FilePointer % SECTORSIZE)
427 {
428 //
429 // Do the math for our first read
430 //
431 SectorNumber = FileHandle->FileStart + (FileHandle->FilePointer / SECTORSIZE);
432 OffsetInSector = FileHandle->FilePointer % SECTORSIZE;
433 LengthInSector = min(N, SECTORSIZE - OffsetInSector);
434
435 //
436 // Now do the read and update Count, N, FilePointer, & Buffer
437 //
438 Position.HighPart = 0;
439 Position.LowPart = SectorNumber * SECTORSIZE;
440 Status = ArcSeek(DeviceId, &Position, SeekAbsolute);
441 if (Status != ESUCCESS)
442 {
443 return Status;
444 }
445 Status = ArcRead(DeviceId, SectorBuffer, SECTORSIZE, &BytesRead);
446 if (Status != ESUCCESS || BytesRead != SECTORSIZE)
447 {
448 return EIO;
449 }
450 RtlCopyMemory(Buffer, SectorBuffer + OffsetInSector, LengthInSector);
451 *Count += LengthInSector;
452 N -= LengthInSector;
453 FileHandle->FilePointer += LengthInSector;
454 Buffer = (PVOID)((ULONG_PTR)Buffer + LengthInSector);
455 }
456
457 //
458 // Do the math for our second read (if any data left)
459 //
460 if (N > 0)
461 {
462 //
463 // Determine how many full clusters we need to read
464 //
465 NumberOfSectors = (N / SECTORSIZE);
466
467 SectorNumber = FileHandle->FileStart + (FileHandle->FilePointer / SECTORSIZE);
468
469 //
470 // Now do the read and update Count, N, FilePointer, & Buffer
471 //
472 Position.HighPart = 0;
473 Position.LowPart = SectorNumber * SECTORSIZE;
474 Status = ArcSeek(DeviceId, &Position, SeekAbsolute);
475 if (Status != ESUCCESS)
476 {
477 return Status;
478 }
479 Status = ArcRead(DeviceId, Buffer, NumberOfSectors * SECTORSIZE, &BytesRead);
480 if (Status != ESUCCESS || BytesRead != NumberOfSectors * SECTORSIZE)
481 {
482 return EIO;
483 }
484
485 *Count += NumberOfSectors * SECTORSIZE;
486 N -= NumberOfSectors * SECTORSIZE;
487 FileHandle->FilePointer += NumberOfSectors * SECTORSIZE;
488 Buffer = (PVOID)((ULONG_PTR)Buffer + NumberOfSectors * SECTORSIZE);
489 }
490
491 //
492 // Do the math for our third read (if any data left)
493 //
494 if (N > 0)
495 {
496 SectorNumber = FileHandle->FileStart + (FileHandle->FilePointer / SECTORSIZE);
497
498 //
499 // Now do the read and update Count, N, FilePointer, & Buffer
500 //
501 Position.HighPart = 0;
502 Position.LowPart = SectorNumber * SECTORSIZE;
503 Status = ArcSeek(DeviceId, &Position, SeekAbsolute);
504 if (Status != ESUCCESS)
505 {
506 return Status;
507 }
508 Status = ArcRead(DeviceId, SectorBuffer, SECTORSIZE, &BytesRead);
509 if (Status != ESUCCESS || BytesRead != SECTORSIZE)
510 {
511 return EIO;
512 }
513 RtlCopyMemory(Buffer, SectorBuffer, N);
514 *Count += N;
515 FileHandle->FilePointer += N;
516 }
517
518 TRACE("IsoRead() done\n");
519
520 return ESUCCESS;
521}
#define N
Definition: crc32.c:57
#define min(a, b)
Definition: monoChain.cc:55
void * PVOID
Definition: typedefs.h:50
uint32_t ULONG_PTR
Definition: typedefs.h:65
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesRead
Definition: wdfiotarget.h:870

◆ IsoSearchDirectoryBufferForFile()

static BOOLEAN IsoSearchDirectoryBufferForFile ( PVOID  DirectoryBuffer,
ULONG  DirectoryLength,
PCHAR  FileName,
PISO_FILE_INFO  IsoFileInfoPointer 
)
static

Definition at line 64 of file iso.c.

65{
68 ULONG i;
69 CHAR Name[32];
70
71 TRACE("IsoSearchDirectoryBufferForFile() DirectoryBuffer = 0x%x DirectoryLength = %d FileName = %s\n", DirectoryBuffer, DirectoryLength, FileName);
72
73 Offset = 0;
74 Record = (PDIR_RECORD)DirectoryBuffer;
75 while (TRUE)
76 {
77 Offset = Offset + Record->RecordLength;
78 Record = (PDIR_RECORD)((ULONG_PTR)DirectoryBuffer + Offset);
79
80 if (Record->RecordLength == 0)
81 {
83 Record = (PDIR_RECORD)((ULONG_PTR)DirectoryBuffer + Offset);
84 }
85
86 if (Offset >= DirectoryLength)
87 return FALSE;
88
89 if (Record->FileIdLength == 1 && Record->FileId[0] == 0)
90 {
91 TRACE("Name '.'\n");
92 }
93 else if (Record->FileIdLength == 1 && Record->FileId[0] == 1)
94 {
95 TRACE("Name '..'\n");
96 }
97 else
98 {
99 for (i = 0; i < Record->FileIdLength && Record->FileId[i] != ';'; i++)
100 Name[i] = Record->FileId[i];
101 Name[i] = ANSI_NULL;
102 TRACE("Name '%s'\n", Name);
103
104 if (strlen(FileName) == strlen(Name) && _stricmp(FileName, Name) == 0)
105 {
106 IsoFileInfoPointer->FileStart = Record->ExtentLocationL;
107 IsoFileInfoPointer->FileSize = Record->DataLengthL;
108 IsoFileInfoPointer->FilePointer = 0;
109 IsoFileInfoPointer->Directory = !!(Record->FileFlags & 0x02);
110
111 return TRUE;
112 }
113
114 }
115 }
116
117 return FALSE;
118}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define _stricmp
Definition: cat.c:22
LPWSTR Name
Definition: desk.c:124
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
struct _DIR_RECORD * PDIR_RECORD
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
ULONG FilePointer
Definition: iso.h:97
BOOLEAN Directory
Definition: iso.h:98
_In_ struct _KBUGCHECK_REASON_CALLBACK_RECORD * Record
Definition: ketypes.h:268

Referenced by IsoLookupFile().

◆ IsoSeek()

static ARC_STATUS IsoSeek ( ULONG  FileId,
LARGE_INTEGER Position,
SEEKMODE  SeekMode 
)
static

Definition at line 524 of file iso.c.

525{
527 LARGE_INTEGER NewPosition = *Position;
528
529 switch (SeekMode)
530 {
531 case SeekAbsolute:
532 break;
533 case SeekRelative:
534 NewPosition.QuadPart += (ULONGLONG)FileHandle->FilePointer;
535 break;
536 default:
537 ASSERT(FALSE);
538 return EINVAL;
539 }
540
541 if (NewPosition.HighPart != 0)
542 return EINVAL;
543 if (NewPosition.LowPart >= FileHandle->FileSize)
544 return EINVAL;
545
546 FileHandle->FilePointer = NewPosition.LowPart;
547 return ESUCCESS;
548}
#define EINVAL
Definition: acclib.h:90
@ SeekRelative
Definition: arc.h:60
LONGLONG QuadPart
Definition: typedefs.h:114
ULONG LowPart
Definition: typedefs.h:106

Variable Documentation

◆ Iso9660FuncTable

const DEVVTBL Iso9660FuncTable
static
Initial value:
=
{
L"cdfs",
}
static ARC_STATUS IsoSeek(ULONG FileId, LARGE_INTEGER *Position, SEEKMODE SeekMode)
Definition: iso.c:524
static ARC_STATUS IsoGetFileInformation(ULONG FileId, FILEINFORMATION *Information)
Definition: iso.c:313
static ARC_STATUS IsoRead(ULONG FileId, VOID *Buffer, ULONG N, ULONG *Count)
Definition: iso.c:357
static ARC_STATUS IsoOpen(CHAR *Path, OPENMODE OpenMode, ULONG *FileId)
Definition: iso.c:328
static ARC_STATUS IsoClose(ULONG FileId)
Definition: iso.c:305
#define L(x)
Definition: ntvdm.h:50

Definition at line 550 of file iso.c.

Referenced by IsoMount().

◆ IsoVolumes

PISO_VOLUME_INFO IsoVolumes[MAX_FDS]
static

Definition at line 42 of file iso.c.

Referenced by IsoLookupFile(), and IsoMount().