ReactOS  0.4.15-dev-494-g1d8c567
iso.c File Reference
#include <freeldr.h>
#include <debug.h>
Include dependency graph for iso.c:

Go to the source code of this file.

Macros

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

Functions

 DBG_DEFAULT_CHANNEL (FILESYSTEM)
 
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 IsoFileInfoPointer)
 
ARC_STATUS IsoClose (ULONG FileId)
 
ARC_STATUS IsoGetFileInformation (ULONG FileId, FILEINFORMATION *Information)
 
ARC_STATUS IsoOpen (CHAR *Path, OPENMODE OpenMode, ULONG *FileId)
 
ARC_STATUS IsoRead (ULONG FileId, VOID *Buffer, ULONG N, ULONG *Count)
 
ARC_STATUS IsoSeek (ULONG FileId, LARGE_INTEGER *Position, SEEKMODE SeekMode)
 
const DEVVTBLIsoMount (ULONG DeviceId)
 

Variables

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 28 of file iso.c.

◆ TAG_ISO_FILE

#define TAG_ISO_FILE   'FosI'

Definition at line 29 of file iso.c.

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 99 of file iso.c.

101 {
102  PVOID DirectoryBuffer;
105  ULONG Count;
107 
108  TRACE("IsoBufferDirectory() DirectoryStartSector = %d DirectoryLength = %d\n", DirectoryStartSector, DirectoryLength);
109 
110  SectorCount = ROUND_UP(DirectoryLength, SECTORSIZE) / SECTORSIZE;
111  TRACE("Trying to read (DirectoryCount) %d sectors.\n", SectorCount);
112 
113  //
114  // Attempt to allocate memory for directory buffer
115  //
116  TRACE("Trying to allocate (DirectoryLength) %d bytes.\n", DirectoryLength);
117  DirectoryBuffer = FrLdrTempAlloc(DirectoryLength, TAG_ISO_BUFFER);
118  if (!DirectoryBuffer)
119  return ENOMEM;
120 
121  //
122  // Now read directory contents into DirectoryBuffer
123  //
124  Position.HighPart = 0;
125  Position.LowPart = DirectoryStartSector * SECTORSIZE;
126  Status = ArcSeek(DeviceId, &Position, SeekAbsolute);
127  if (Status != ESUCCESS)
128  {
129  FrLdrTempFree(DirectoryBuffer, TAG_ISO_BUFFER);
130  return Status;
131  }
132  Status = ArcRead(DeviceId, DirectoryBuffer, SectorCount * SECTORSIZE, &Count);
133  if (Status != ESUCCESS || Count != SectorCount * SECTORSIZE)
134  {
135  FrLdrTempFree(DirectoryBuffer, TAG_ISO_BUFFER);
136  return EIO;
137  }
138 
139  *pDirectoryBuffer = DirectoryBuffer;
140  return ESUCCESS;
141 }
#define ROUND_UP(n, align)
Definition: eventvwr.h:31
Definition: arc.h:32
static COORD Position
Definition: mouse.c:34
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1173
ULONG ARC_STATUS
Definition: arc.h:4
Definition: arc.h:48
FORCEINLINE PVOID FrLdrTempAlloc(_In_ SIZE_T Size, _In_ ULONG Tag)
Definition: mm.h:177
#define TAG_ISO_BUFFER
Definition: iso.c:28
#define TRACE(s)
Definition: solgame.cpp:4
#define SECTORSIZE
Definition: iso.c:27
ARC_STATUS ArcRead(ULONG FileId, VOID *Buffer, ULONG N, ULONG *Count)
Definition: fs.c:236
ARC_STATUS ArcSeek(ULONG FileId, LARGE_INTEGER *Position, SEEKMODE SeekMode)
Definition: fs.c:243
ULONG SectorCount
Definition: part_xbox.c:31
Status
Definition: gdiplustypes.h:24
Definition: arc.h:40
unsigned int ULONG
Definition: retypes.h:1
FORCEINLINE VOID FrLdrTempFree(PVOID Allocation, ULONG Tag)
Definition: mm.h:186

Referenced by IsoLookupFile().

◆ IsoClose()

ARC_STATUS IsoClose ( ULONG  FileId)

Definition at line 243 of file iso.c.

244 {
247  return ESUCCESS;
248 }
Definition: arc.h:32
VOID * FsGetDeviceSpecific(ULONG FileId)
Definition: fs.c:416
#define TAG_ISO_FILE
Definition: iso.c:29
HANDLE FileHandle
Definition: stats.c:38
FORCEINLINE VOID FrLdrTempFree(PVOID Allocation, ULONG Tag)
Definition: mm.h:186

◆ IsoGetFileInformation()

ARC_STATUS IsoGetFileInformation ( ULONG  FileId,
FILEINFORMATION Information 
)

Definition at line 250 of file iso.c.

251 {
253 
255  Information->EndingAddress.LowPart = FileHandle->FileSize;
256  Information->CurrentAddress.LowPart = FileHandle->FilePointer;
257 
258  TRACE("IsoGetFileInformation(%lu) -> FileSize = %lu, FilePointer = 0x%lx\n",
259  FileId, Information->EndingAddress.LowPart, Information->CurrentAddress.LowPart);
260 
261  return ESUCCESS;
262 }
Definition: arc.h:32
VOID * FsGetDeviceSpecific(ULONG FileId)
Definition: fs.c:416
HANDLE FileHandle
Definition: stats.c:38
#define TRACE(s)
Definition: solgame.cpp:4
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
Iosb Information
Definition: create.c:4353

◆ IsoLookupFile()

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

Definition at line 150 of file iso.c.

151 {
153  PPVD Pvd = (PPVD)Buffer;
154  UINT32 i;
155  ULONG NumberOfPathParts;
156  CHAR PathPart[261];
157  PVOID DirectoryBuffer;
158  ULONG DirectorySector;
159  ULONG DirectoryLength;
160  ISO_FILE_INFO IsoFileInfo;
162  ULONG Count;
164 
165  TRACE("IsoLookupFile() FileName = %s\n", FileName);
166 
167  RtlZeroMemory(IsoFileInfoPointer, sizeof(ISO_FILE_INFO));
168  RtlZeroMemory(&IsoFileInfo, sizeof(ISO_FILE_INFO));
169 
170  //
171  // Read The Primary Volume Descriptor
172  //
173  Position.HighPart = 0;
174  Position.LowPart = 16 * SECTORSIZE;
175  Status = ArcSeek(DeviceId, &Position, SeekAbsolute);
176  if (Status != ESUCCESS)
177  return Status;
178  Status = ArcRead(DeviceId, Pvd, SECTORSIZE, &Count);
179  if (Status != ESUCCESS || Count < sizeof(PVD))
180  return EIO;
181 
182  DirectorySector = Pvd->RootDirRecord.ExtentLocationL;
183  DirectoryLength = Pvd->RootDirRecord.DataLengthL;
184 
185  //
186  // Figure out how many sub-directories we are nested in
187  //
188  NumberOfPathParts = FsGetNumPathParts(FileName);
189 
190  //
191  // Loop once for each part
192  //
193  for (i=0; i<NumberOfPathParts; i++)
194  {
195  //
196  // Get first path part
197  //
198  FsGetFirstNameFromPath(PathPart, FileName);
199 
200  //
201  // Advance to the next part of the path
202  //
203  for (; (*FileName != '\\') && (*FileName != '/') && (*FileName != '\0'); FileName++)
204  {
205  }
206  FileName++;
207 
208  //
209  // Buffer the directory contents
210  //
211  Status = IsoBufferDirectory(DeviceId, DirectorySector, DirectoryLength, &DirectoryBuffer);
212  if (Status != ESUCCESS)
213  return Status;
214 
215  //
216  // Search for file name in directory
217  //
218  if (!IsoSearchDirectoryBufferForFile(DirectoryBuffer, DirectoryLength, PathPart, &IsoFileInfo))
219  {
220  FrLdrTempFree(DirectoryBuffer, TAG_ISO_BUFFER);
221  return ENOENT;
222  }
223 
224  FrLdrTempFree(DirectoryBuffer, TAG_ISO_BUFFER);
225 
226  //
227  // If we have another sub-directory to go then
228  // grab the start sector and file size
229  //
230  if ((i+1) < NumberOfPathParts)
231  {
232  DirectorySector = IsoFileInfo.FileStart;
233  DirectoryLength = IsoFileInfo.FileSize;
234  }
235 
236  }
237 
238  RtlCopyMemory(IsoFileInfoPointer, &IsoFileInfo, sizeof(ISO_FILE_INFO));
239 
240  return ESUCCESS;
241 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
VOID FsGetFirstNameFromPath(PCHAR Buffer, PCSTR Path)
Definition: fs.c:356
Definition: arc.h:32
static COORD Position
Definition: mouse.c:34
char CHAR
Definition: xmlstorage.h:175
DIR_RECORD RootDirRecord
Definition: iso.h:80
ULONG FsGetNumPathParts(PCSTR Path)
Definition: fs.c:328
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1173
ULONG ARC_STATUS
Definition: arc.h:4
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
unsigned int UINT32
Definition: iso.h:59
ULONG FileStart
Definition: iso.h:94
Definition: bufpool.h:45
#define TAG_ISO_BUFFER
Definition: iso.c:28
#define TRACE(s)
Definition: solgame.cpp:4
#define SECTORSIZE
Definition: iso.c:27
ARC_STATUS ArcRead(ULONG FileId, VOID *Buffer, ULONG N, ULONG *Count)
Definition: fs.c:236
unsigned char UCHAR
Definition: xmlstorage.h:181
struct _PVD * PPVD
Definition: iso.h:88
ARC_STATUS ArcSeek(ULONG FileId, LARGE_INTEGER *Position, SEEKMODE SeekMode)
Definition: fs.c:243
static BOOLEAN IsoSearchDirectoryBufferForFile(PVOID DirectoryBuffer, ULONG DirectoryLength, PCHAR FileName, PISO_FILE_INFO IsoFileInfoPointer)
Definition: iso.c:31
Status
Definition: gdiplustypes.h:24
ULONG ExtentLocationL
Definition: iso.h:27
Definition: arc.h:46
Definition: arc.h:40
unsigned int ULONG
Definition: retypes.h:1
ULONG FileSize
Definition: iso.h:95
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
ULONG DataLengthL
Definition: iso.h:29
static ARC_STATUS IsoBufferDirectory(ULONG DeviceId, ULONG DirectoryStartSector, ULONG DirectoryLength, PVOID *pDirectoryBuffer)
Definition: iso.c:99
FORCEINLINE VOID FrLdrTempFree(PVOID Allocation, ULONG Tag)
Definition: mm.h:186

Referenced by IsoOpen().

◆ IsoMount()

const DEVVTBL* IsoMount ( ULONG  DeviceId)

Definition at line 495 of file iso.c.

496 {
498  PPVD Pvd = (PPVD)Buffer;
500  ULONG Count;
502 
503  TRACE("Enter IsoMount(%lu)\n", DeviceId);
504 
505  //
506  // Read The Primary Volume Descriptor
507  //
508  Position.HighPart = 0;
509  Position.LowPart = 16 * SECTORSIZE;
510  Status = ArcSeek(DeviceId, &Position, SeekAbsolute);
511  if (Status != ESUCCESS)
512  return NULL;
513  Status = ArcRead(DeviceId, Pvd, SECTORSIZE, &Count);
514  if (Status != ESUCCESS || Count < sizeof(PVD))
515  return NULL;
516 
517  //
518  // Check if PVD is valid. If yes, return ISO9660 function table
519  //
520  if (Pvd->VdType == 1 && RtlEqualMemory(Pvd->StandardId, "CD001", 5))
521  {
522  TRACE("IsoMount(%lu) success\n", DeviceId);
523  return &Iso9660FuncTable;
524  }
525 
526  return NULL;
527 }
Definition: arc.h:32
static COORD Position
Definition: mouse.c:34
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1173
ULONG ARC_STATUS
Definition: arc.h:4
Definition: iso.h:59
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
CHAR StandardId[5]
Definition: iso.h:62
#define TRACE(s)
Definition: solgame.cpp:4
NTSYSAPI ULONG NTAPI RtlEqualMemory(CONST VOID *Source1, CONST VOID *Source2, ULONG Length)
#define SECTORSIZE
Definition: iso.c:27
ARC_STATUS ArcRead(ULONG FileId, VOID *Buffer, ULONG N, ULONG *Count)
Definition: fs.c:236
unsigned char UCHAR
Definition: xmlstorage.h:181
struct _PVD * PPVD
Definition: iso.h:88
ARC_STATUS ArcSeek(ULONG FileId, LARGE_INTEGER *Position, SEEKMODE SeekMode)
Definition: fs.c:243
Status
Definition: gdiplustypes.h:24
unsigned int ULONG
Definition: retypes.h:1
UCHAR VdType
Definition: iso.h:61
const DEVVTBL Iso9660FuncTable
Definition: iso.c:485

Referenced by ArcOpen().

◆ IsoOpen()

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

Definition at line 264 of file iso.c.

265 {
266  ISO_FILE_INFO TempFileInfo;
268  ULONG DeviceId;
270 
271  if (OpenMode != OpenReadOnly)
272  return EACCES;
273 
274  DeviceId = FsGetDeviceId(*FileId);
275 
276  TRACE("IsoOpen() FileName = %s\n", Path);
277 
278  RtlZeroMemory(&TempFileInfo, sizeof(TempFileInfo));
279  Status = IsoLookupFile(Path, DeviceId, &TempFileInfo);
280  if (Status != ESUCCESS)
281  return ENOENT;
282 
284  if (!FileHandle)
285  return ENOMEM;
286 
287  RtlCopyMemory(FileHandle, &TempFileInfo, sizeof(ISO_FILE_INFO));
288 
290  return ESUCCESS;
291 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
Definition: arc.h:32
static ARC_STATUS IsoLookupFile(PCSTR FileName, ULONG DeviceId, PISO_FILE_INFO IsoFileInfoPointer)
Definition: iso.c:150
ULONG ARC_STATUS
Definition: arc.h:4
#define TAG_ISO_FILE
Definition: iso.c:29
Definition: arc.h:48
HANDLE FileHandle
Definition: stats.c:38
FORCEINLINE PVOID FrLdrTempAlloc(_In_ SIZE_T Size, _In_ ULONG Tag)
Definition: mm.h:177
#define TRACE(s)
Definition: solgame.cpp:4
VOID FsSetDeviceSpecific(ULONG FileId, VOID *Specific)
Definition: fs.c:409
Definition: arc.h:34
Status
Definition: gdiplustypes.h:24
PRTL_UNICODE_STRING_BUFFER Path
Definition: arc.h:46
ULONG FsGetDeviceId(ULONG FileId)
Definition: fs.c:423
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261

◆ IsoRead()

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

Definition at line 293 of file iso.c.

294 {
297  UCHAR SectorBuffer[SECTORSIZE];
299  ULONG DeviceId;
300  ULONG SectorNumber;
301  ULONG OffsetInSector;
302  ULONG LengthInSector;
303  ULONG NumberOfSectors;
305 
306  TRACE("IsoRead() Buffer = %p, N = %lu\n", Buffer, N);
307 
308  DeviceId = FsGetDeviceId(FileId);
309  *Count = 0;
310 
311  //
312  // If the user is trying to read past the end of
313  // the file then return success with Count == 0.
314  //
315  if (FileHandle->FilePointer >= FileHandle->FileSize)
316  {
317  return ESUCCESS;
318  }
319 
320  //
321  // If the user is trying to read more than there is to read
322  // then adjust the amount to read.
323  //
324  if (FileHandle->FilePointer + N > FileHandle->FileSize)
325  {
326  N = FileHandle->FileSize - FileHandle->FilePointer;
327  }
328 
329  //
330  // Ok, now we have to perform at most 3 calculations
331  // I'll draw you a picture (using nifty ASCII art):
332  //
333  // CurrentFilePointer -+
334  // |
335  // +----------------+
336  // |
337  // +-----------+-----------+-----------+-----------+
338  // | Sector 1 | Sector 2 | Sector 3 | Sector 4 |
339  // +-----------+-----------+-----------+-----------+
340  // | |
341  // +---------------+--------------------+
342  // |
343  // N -----------------+
344  //
345  // 1 - The first calculation (and read) will align
346  // the file pointer with the next sector
347  // boundary (if we are supposed to read that much)
348  // 2 - The next calculation (and read) will read
349  // in all the full sectors that the requested
350  // amount of data would cover (in this case
351  // sectors 2 & 3).
352  // 3 - The last calculation (and read) would read
353  // in the remainder of the data requested out of
354  // the last sector.
355  //
356 
357 
358  //
359  // Only do the first read if we
360  // aren't aligned on a cluster boundary
361  //
362  if (FileHandle->FilePointer % SECTORSIZE)
363  {
364  //
365  // Do the math for our first read
366  //
367  SectorNumber = FileHandle->FileStart + (FileHandle->FilePointer / SECTORSIZE);
368  OffsetInSector = FileHandle->FilePointer % SECTORSIZE;
369  LengthInSector = min(N, SECTORSIZE - OffsetInSector);
370 
371  //
372  // Now do the read and update Count, N, FilePointer, & Buffer
373  //
374  Position.HighPart = 0;
375  Position.LowPart = SectorNumber * SECTORSIZE;
376  Status = ArcSeek(DeviceId, &Position, SeekAbsolute);
377  if (Status != ESUCCESS)
378  {
379  return Status;
380  }
381  Status = ArcRead(DeviceId, SectorBuffer, SECTORSIZE, &BytesRead);
382  if (Status != ESUCCESS || BytesRead != SECTORSIZE)
383  {
384  return EIO;
385  }
386  RtlCopyMemory(Buffer, SectorBuffer + OffsetInSector, LengthInSector);
387  *Count += LengthInSector;
388  N -= LengthInSector;
389  FileHandle->FilePointer += LengthInSector;
390  Buffer = (PVOID)((ULONG_PTR)Buffer + LengthInSector);
391  }
392 
393  //
394  // Do the math for our second read (if any data left)
395  //
396  if (N > 0)
397  {
398  //
399  // Determine how many full clusters we need to read
400  //
401  NumberOfSectors = (N / SECTORSIZE);
402 
403  SectorNumber = FileHandle->FileStart + (FileHandle->FilePointer / SECTORSIZE);
404 
405  //
406  // Now do the read and update Count, N, FilePointer, & Buffer
407  //
408  Position.HighPart = 0;
409  Position.LowPart = SectorNumber * SECTORSIZE;
410  Status = ArcSeek(DeviceId, &Position, SeekAbsolute);
411  if (Status != ESUCCESS)
412  {
413  return Status;
414  }
415  Status = ArcRead(DeviceId, Buffer, NumberOfSectors * SECTORSIZE, &BytesRead);
416  if (Status != ESUCCESS || BytesRead != NumberOfSectors * SECTORSIZE)
417  {
418  return EIO;
419  }
420 
421  *Count += NumberOfSectors * SECTORSIZE;
422  N -= NumberOfSectors * SECTORSIZE;
423  FileHandle->FilePointer += NumberOfSectors * SECTORSIZE;
424  Buffer = (PVOID)((ULONG_PTR)Buffer + NumberOfSectors * SECTORSIZE);
425  }
426 
427  //
428  // Do the math for our third read (if any data left)
429  //
430  if (N > 0)
431  {
432  SectorNumber = FileHandle->FileStart + (FileHandle->FilePointer / SECTORSIZE);
433 
434  //
435  // Now do the read and update Count, N, FilePointer, & Buffer
436  //
437  Position.HighPart = 0;
438  Position.LowPart = SectorNumber * SECTORSIZE;
439  Status = ArcSeek(DeviceId, &Position, SeekAbsolute);
440  if (Status != ESUCCESS)
441  {
442  return Status;
443  }
444  Status = ArcRead(DeviceId, SectorBuffer, SECTORSIZE, &BytesRead);
445  if (Status != ESUCCESS || BytesRead != SECTORSIZE)
446  {
447  return EIO;
448  }
449  RtlCopyMemory(Buffer, SectorBuffer, N);
450  *Count += N;
451  FileHandle->FilePointer += N;
452  }
453 
454  TRACE("IsoRead() done\n");
455 
456  return ESUCCESS;
457 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
Definition: arc.h:32
static COORD Position
Definition: mouse.c:34
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1173
ULONG ARC_STATUS
Definition: arc.h:4
VOID * FsGetDeviceSpecific(ULONG FileId)
Definition: fs.c:416
uint32_t ULONG_PTR
Definition: typedefs.h:64
HANDLE FileHandle
Definition: stats.c:38
Definition: bufpool.h:45
void * PVOID
Definition: retypes.h:9
#define TRACE(s)
Definition: solgame.cpp:4
#define SECTORSIZE
Definition: iso.c:27
ARC_STATUS ArcRead(ULONG FileId, VOID *Buffer, ULONG N, ULONG *Count)
Definition: fs.c:236
unsigned char UCHAR
Definition: xmlstorage.h:181
ARC_STATUS ArcSeek(ULONG FileId, LARGE_INTEGER *Position, SEEKMODE SeekMode)
Definition: fs.c:243
Status
Definition: gdiplustypes.h:24
#define min(a, b)
Definition: monoChain.cc:55
Definition: arc.h:40
ULONG FsGetDeviceId(ULONG FileId)
Definition: fs.c:423
unsigned int ULONG
Definition: retypes.h:1
_Must_inspect_result_ _In_ PFILE_OBJECT _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ FLT_IO_OPERATION_FLAGS _Out_opt_ PULONG BytesRead
Definition: fltkernel.h:1255

◆ IsoSearchDirectoryBufferForFile()

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

Definition at line 31 of file iso.c.

32 {
34  ULONG Offset;
35  ULONG i;
36  CHAR Name[32];
37 
38  TRACE("IsoSearchDirectoryBufferForFile() DirectoryBuffer = 0x%x DirectoryLength = %d FileName = %s\n", DirectoryBuffer, DirectoryLength, FileName);
39 
40  RtlZeroMemory(Name, 32 * sizeof(UCHAR));
41 
42  Offset = 0;
43  Record = (PDIR_RECORD)DirectoryBuffer;
44  while (TRUE)
45  {
46  Offset = Offset + Record->RecordLength;
47  Record = (PDIR_RECORD)((ULONG_PTR)DirectoryBuffer + Offset);
48 
49  if (Record->RecordLength == 0)
50  {
52  Record = (PDIR_RECORD)((ULONG_PTR)DirectoryBuffer + Offset);
53  }
54 
55  if (Offset >= DirectoryLength)
56  return FALSE;
57 
58  if (Record->FileIdLength == 1 && Record->FileId[0] == 0)
59  {
60  TRACE("Name '.'\n");
61  }
62  else if (Record->FileIdLength == 1 && Record->FileId[0] == 1)
63  {
64  TRACE("Name '..'\n");
65  }
66  else
67  {
68  for (i = 0; i < Record->FileIdLength && Record->FileId[i] != ';'; i++)
69  Name[i] = Record->FileId[i];
70  Name[i] = 0;
71  TRACE("Name '%s'\n", Name);
72 
73  if (strlen(FileName) == strlen(Name) && _stricmp(FileName, Name) == 0)
74  {
75  IsoFileInfoPointer->FileStart = Record->ExtentLocationL;
76  IsoFileInfoPointer->FileSize = Record->DataLengthL;
77  IsoFileInfoPointer->FilePointer = 0;
78  IsoFileInfoPointer->Directory = !!(Record->FileFlags & 0x02);
79 
80  return TRUE;
81  }
82 
83  }
84 
85  RtlZeroMemory(Name, 32 * sizeof(UCHAR));
86  }
87 
88  return FALSE;
89 }
#define TRUE
Definition: types.h:120
#define ROUND_UP(n, align)
Definition: eventvwr.h:31
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char CHAR
Definition: xmlstorage.h:175
BOOLEAN Directory
Definition: iso.h:97
#define _stricmp
Definition: cat.c:22
uint32_t ULONG_PTR
Definition: typedefs.h:64
_In_ struct _KBUGCHECK_REASON_CALLBACK_RECORD * Record
Definition: ketypes.h:256
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
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
ULONG FileStart
Definition: iso.h:94
struct _DIR_RECORD * PDIR_RECORD
Definition: iso.h:45
#define TRACE(s)
Definition: solgame.cpp:4
#define SECTORSIZE
Definition: iso.c:27
ULONG FilePointer
Definition: iso.h:96
unsigned char UCHAR
Definition: xmlstorage.h:181
unsigned int ULONG
Definition: retypes.h:1
ULONG FileSize
Definition: iso.h:95
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261

Referenced by IsoLookupFile().

◆ IsoSeek()

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

Definition at line 459 of file iso.c.

460 {
462  LARGE_INTEGER NewPosition = *Position;
463 
464  switch (SeekMode)
465  {
466  case SeekAbsolute:
467  break;
468  case SeekRelative:
469  NewPosition.QuadPart += (ULONGLONG)FileHandle->FilePointer;
470  break;
471  default:
472  ASSERT(FALSE);
473  return EINVAL;
474  }
475 
476  if (NewPosition.HighPart != 0)
477  return EINVAL;
478  if (NewPosition.LowPart >= FileHandle->FileSize)
479  return EINVAL;
480 
481  FileHandle->FilePointer = NewPosition.LowPart;
482  return ESUCCESS;
483 }
Definition: arc.h:32
Definition: arc.h:39
static COORD Position
Definition: mouse.c:34
VOID * FsGetDeviceSpecific(ULONG FileId)
Definition: fs.c:416
HANDLE FileHandle
Definition: stats.c:38
uint64_t ULONGLONG
Definition: typedefs.h:66
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
ULONG LowPart
Definition: typedefs.h:105
LONGLONG QuadPart
Definition: typedefs.h:113

Variable Documentation

◆ Iso9660FuncTable

const DEVVTBL Iso9660FuncTable
Initial value:
=
{
L"cdfs",
}
ARC_STATUS IsoSeek(ULONG FileId, LARGE_INTEGER *Position, SEEKMODE SeekMode)
Definition: iso.c:459
ARC_STATUS IsoRead(ULONG FileId, VOID *Buffer, ULONG N, ULONG *Count)
Definition: iso.c:293
ARC_STATUS IsoGetFileInformation(ULONG FileId, FILEINFORMATION *Information)
Definition: iso.c:250
static const WCHAR L[]
Definition: oid.c:1250
ARC_STATUS IsoClose(ULONG FileId)
Definition: iso.c:243
ARC_STATUS IsoOpen(CHAR *Path, OPENMODE OpenMode, ULONG *FileId)
Definition: iso.c:264

Definition at line 485 of file iso.c.

Referenced by IsoMount().