VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/SharedFolders/testcase/eof-1.cpp@ 85675

Last change on this file since 85675 was 82968, checked in by vboxsync, 5 years ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.7 KB
Line 
1/* $Id: eof-1.cpp 82968 2020-02-04 10:35:17Z vboxsync $ */
2/** @file
3 * VirtualBox Windows Guest Shared Folders FSD - Simple Testcase.
4 */
5
6/*
7 * Copyright (C) 2019-2020 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#include <iprt/nt/nt-and-windows.h>
19#include <stdio.h>
20
21int main(int argc, char **argv)
22{
23 for (int i = 1; i < argc; i++)
24 {
25 HANDLE hFile = CreateFileA(argv[i], GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
26 NULL /*pSecAttr*/, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
27 if (hFile != INVALID_HANDLE_VALUE)
28 {
29#if 1
30 DWORD cbFileHi = 0;
31 DWORD cbFileLo = GetFileSize(hFile, &cbFileHi);
32 LONG offFileHi = cbFileHi;
33 if (SetFilePointer(hFile, cbFileLo + 1, &offFileHi, FILE_BEGIN) == INVALID_SET_FILE_POINTER)
34 fprintf(stderr, "%s: error: %s: SetFilePointer() -> %u\n", argv[0], argv[i], GetLastError());
35#else
36 //if (SetFilePointer(hFile, 0, &offWhateverHi, FILE_END) == INVALID_SET_FILE_POINTER)
37 // fprintf(stderr, "%s: error: %s: SetFilePointer() -> %u\n", argv[0], argv[i], GetLastError());
38#endif
39
40
41 uint8_t abBuf[64];
42 IO_STATUS_BLOCK const IosVirgin = RTNT_IO_STATUS_BLOCK_INITIALIZER;
43 IO_STATUS_BLOCK Ios = RTNT_IO_STATUS_BLOCK_INITIALIZER;
44 NTSTATUS rcNt = NtReadFile(hFile, NULL /*hEvent*/, NULL /*ApcRoutine*/, NULL /*ApcContext*/,
45 &Ios, abBuf, (ULONG)sizeof(abBuf), NULL /*poffFile*/, NULL /*Key*/);
46 Sleep(2);
47 if (rcNt == STATUS_END_OF_FILE && Ios.Status == IosVirgin.Status && Ios.Information == IosVirgin.Information)
48 fprintf(stderr, "%s: info: %s: PASSED\n", argv[0], argv[i]);
49 else
50 fprintf(stderr, "%s: info: %s: FAILED - rcNt=%#x (expected %#x) Ios.Status=%#x (expected %#x [untouched]), Info=%p (expected %p)\n",
51 argv[0], argv[i], rcNt, STATUS_END_OF_FILE, Ios.Status, IosVirgin.Status, Ios.Information, IosVirgin.Information);
52
53 CloseHandle(hFile);
54 }
55 else
56 fprintf(stderr, "%s: error: %s: CreateFileA() -> %u\n", argv[0], argv[i], GetLastError());
57 }
58 return 0;
59}
60
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette