[NTVDM] Move the def file out of the source files list. Rename some variables and...
[reactos.git] / subsystems / mvdm / ntvdm / dos / dos32krnl / dosfiles.h
1 /*
2 * COPYRIGHT: GPL - See COPYING in the top level directory
3 * PROJECT: ReactOS Virtual DOS Machine
4 * FILE: subsystems/mvdm/ntvdm/dos/dos32krnl/dosfiles.h
5 * PURPOSE: DOS32 Files Support
6 * PROGRAMMERS: Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
7 */
8
9 #pragma once
10
11 /* DEFINES ********************************************************************/
12
13 #define FILE_INFO_STDIN (1 << 0)
14 #define FILE_INFO_STDOUT (1 << 1)
15 #define FILE_INFO_BINARY (1 << 5)
16 #define FILE_INFO_DEVICE (1 << 7)
17
18 #pragma pack(push, 1)
19
20 #if 0 // Real DOS-5 SFT entry, for reference only
21 typedef struct _DOS_FILE_DESCRIPTOR_DOS5
22 {
23 WORD RefCount; // 0x00
24 WORD OpenMode; // 0x02
25 BYTE Attributes; // 0x04
26 WORD DeviceInfo; // 0x05
27 DWORD DevicePointer; // 0x07
28 WORD StartCluster; // 0x0b
29 WORD Time; // 0x0d
30 WORD Date; // 0x0f
31 DWORD Size; // 0x11
32 DWORD Position; // 0x15
33 BYTE Reserved0[7]; // 0x19
34 CHAR FileName[11]; // 0x20
35 BYTE Reserved1[6]; // 0x2b
36 WORD OwnerPsp; // 0x31
37 BYTE Reserved2[8]; // 0x33
38 } DOS_FILE_DESCRIPTOR_DOS5, *PDOS_FILE_DESCRIPTOR_DOS5;
39
40 C_ASSERT(sizeof(DOS_FILE_DESCRIPTOR_DOS5) == 0x3B);
41 #endif
42
43 // Modified DOS SFT entry, compatible for NTVDM only
44 typedef struct _DOS_FILE_DESCRIPTOR
45 {
46 WORD RefCount;
47 WORD OpenMode;
48 BYTE Attributes;
49 WORD DeviceInfo;
50 DWORD DevicePointer;
51 WORD Time;
52 WORD Date;
53 DWORD Size;
54 DWORD Position;
55 DWORD Reserved;
56 WORD OwnerPsp;
57 HANDLE Win32Handle;
58 CHAR FileName[11];
59 BYTE Padding[0x13 - sizeof(HANDLE)];
60 } DOS_FILE_DESCRIPTOR, *PDOS_FILE_DESCRIPTOR;
61
62 C_ASSERT(sizeof(DOS_FILE_DESCRIPTOR) == 0x3B);
63
64 typedef struct _DOS_SFT
65 {
66 DWORD Link;
67 WORD NumDescriptors;
68 DOS_FILE_DESCRIPTOR FileDescriptors[ANYSIZE_ARRAY];
69 } DOS_SFT, *PDOS_SFT;
70
71 /* FUNCTIONS ******************************************************************/
72
73 BYTE DosFindFreeDescriptor(VOID);
74 BYTE DosFindWin32Descriptor(HANDLE Win32Handle);
75 BYTE DosFindDeviceDescriptor(DWORD DevicePointer);
76 PDOS_FILE_DESCRIPTOR DosGetFileDescriptor(BYTE Id);
77 PDOS_FILE_DESCRIPTOR DosGetHandleFileDescriptor(WORD DosHandle);
78
79 WORD DosCreateFileEx
80 (
81 LPWORD Handle,
82 LPWORD CreationStatus,
83 LPCSTR FilePath,
84 BYTE AccessShareModes,
85 WORD CreateActionFlags,
86 WORD Attributes
87 );
88
89 WORD DosCreateFile
90 (
91 LPWORD Handle,
92 LPCSTR FilePath,
93 DWORD CreationDisposition,
94 WORD Attributes
95 );
96
97 WORD DosOpenFile
98 (
99 LPWORD Handle,
100 LPCSTR FilePath,
101 BYTE AccessShareModes
102 );
103
104 WORD DosReadFile
105 (
106 WORD FileHandle,
107 DWORD Buffer,
108 WORD Count,
109 LPWORD BytesRead
110 );
111
112 WORD DosWriteFile
113 (
114 WORD FileHandle,
115 DWORD Buffer,
116 WORD Count,
117 LPWORD BytesWritten
118 );
119
120 WORD DosSeekFile
121 (
122 WORD FileHandle,
123 LONG Offset,
124 BYTE Origin,
125 LPDWORD NewOffset
126 );
127
128 BYTE DosReadLineBuffered(WORD FileHandle, DWORD Buffer, BYTE MaxSize);
129 BOOL DosFlushFileBuffers(WORD FileHandle);
130 BOOLEAN DosLockFile(WORD DosHandle, DWORD Offset, DWORD Size);
131 BOOLEAN DosUnlockFile(WORD DosHandle, DWORD Offset, DWORD Size);
132
133 BOOLEAN DosDeviceIoControl
134 (
135 WORD FileHandle,
136 BYTE ControlCode,
137 DWORD Buffer,
138 PWORD Length
139 );
140
141 #pragma pack(pop)