xref: /reactos/sdk/lib/rossym/zwfile.c (revision c2c66aff)
1*c2c66affSColin Finck /*
2*c2c66affSColin Finck  * COPYRIGHT:       See COPYING in the top level directory
3*c2c66affSColin Finck  * PROJECT:         ReactOS kernel
4*c2c66affSColin Finck  * FILE:            lib/rossym/zwfile.c
5*c2c66affSColin Finck  * PURPOSE:         File I/O using native functions
6*c2c66affSColin Finck  *
7*c2c66affSColin Finck  * PROGRAMMERS:     Ge van Geldorp (gvg@reactos.com)
8*c2c66affSColin Finck  */
9*c2c66affSColin Finck 
10*c2c66affSColin Finck #define NTOSAPI
11*c2c66affSColin Finck #include <wdm.h>
12*c2c66affSColin Finck #include <reactos/rossym.h>
13*c2c66affSColin Finck #include "rossympriv.h"
14*c2c66affSColin Finck 
15*c2c66affSColin Finck BOOLEAN
16*c2c66affSColin Finck RosSymZwReadFile(PVOID FileContext, PVOID Buffer, ULONG Size)
17*c2c66affSColin Finck {
18*c2c66affSColin Finck   NTSTATUS Status;
19*c2c66affSColin Finck   IO_STATUS_BLOCK IoStatusBlock;
20*c2c66affSColin Finck 
21*c2c66affSColin Finck   Status = ZwReadFile(*((HANDLE *) FileContext),
22*c2c66affSColin Finck                       0, 0, 0,
23*c2c66affSColin Finck                       &IoStatusBlock,
24*c2c66affSColin Finck                       Buffer,
25*c2c66affSColin Finck                       Size,
26*c2c66affSColin Finck                       0, 0);
27*c2c66affSColin Finck 
28*c2c66affSColin Finck   return NT_SUCCESS(Status) && IoStatusBlock.Information == Size;
29*c2c66affSColin Finck }
30*c2c66affSColin Finck 
31*c2c66affSColin Finck BOOLEAN
32*c2c66affSColin Finck RosSymZwSeekFile(PVOID FileContext, ULONG_PTR Position)
33*c2c66affSColin Finck {
34*c2c66affSColin Finck   NTSTATUS Status;
35*c2c66affSColin Finck   IO_STATUS_BLOCK IoStatusBlock;
36*c2c66affSColin Finck   FILE_POSITION_INFORMATION NewPosition;
37*c2c66affSColin Finck 
38*c2c66affSColin Finck   NewPosition.CurrentByteOffset.u.HighPart = 0;
39*c2c66affSColin Finck   NewPosition.CurrentByteOffset.u.LowPart = Position;
40*c2c66affSColin Finck   Status = ZwSetInformationFile(*((HANDLE *) FileContext),
41*c2c66affSColin Finck                                 &IoStatusBlock,
42*c2c66affSColin Finck                                 (PVOID) &NewPosition,
43*c2c66affSColin Finck                                 sizeof(FILE_POSITION_INFORMATION),
44*c2c66affSColin Finck                                 FilePositionInformation);
45*c2c66affSColin Finck 
46*c2c66affSColin Finck   return NT_SUCCESS(Status);
47*c2c66affSColin Finck }
48