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