1 | /* $Id: tstDump.c 2376 2010-01-13 01:45:49Z bird $ */
|
---|
2 | /** @file
|
---|
3 | * tstDump - dump inherited file handle information on Windows.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (c) 2010 knut st. osmundsen <[email protected]>
|
---|
8 | *
|
---|
9 | *
|
---|
10 | * This file is part of kBuild.
|
---|
11 | *
|
---|
12 | * kBuild is free software; you can redistribute it and/or modify
|
---|
13 | * it under the terms of the GNU General Public License as published by
|
---|
14 | * the Free Software Foundation; either version 2 of the License, or
|
---|
15 | * (at your option) any later version.
|
---|
16 | *
|
---|
17 | * kBuild is distributed in the hope that it will be useful,
|
---|
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
20 | * GNU General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with kBuild; if not, write to the Free Software
|
---|
24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
25 | *
|
---|
26 | */
|
---|
27 |
|
---|
28 | /*******************************************************************************
|
---|
29 | * Header Files *
|
---|
30 | *******************************************************************************/
|
---|
31 | #include <Windows.h>
|
---|
32 | #include <stdio.h>
|
---|
33 |
|
---|
34 |
|
---|
35 | int main()
|
---|
36 | {
|
---|
37 | STARTUPINFO Info;
|
---|
38 | GetStartupInfo(&Info);
|
---|
39 |
|
---|
40 | printf("tst: hStdInput =%p / %p\n", Info.hStdInput, GetStdHandle(STD_INPUT_HANDLE));
|
---|
41 | printf("tst: hStdOutput=%p / %p\n", Info.hStdOutput, GetStdHandle(STD_OUTPUT_HANDLE));
|
---|
42 | printf("tst: hStdError =%p / %p\n", Info.hStdError, GetStdHandle(STD_ERROR_HANDLE));
|
---|
43 | printf("tst: cbReserved2=%d (%#x) lpReserved2=%p\n",
|
---|
44 | Info.cbReserved2, Info.cbReserved2, Info.lpReserved2);
|
---|
45 |
|
---|
46 | if (Info.cbReserved2 > sizeof(int) && Info.lpReserved2)
|
---|
47 | {
|
---|
48 | int count = *(int *)Info.lpReserved2;
|
---|
49 | unsigned char *paf = (unsigned char *)Info.lpReserved2 + sizeof(int);
|
---|
50 | HANDLE *pah = (HANDLE *)(paf + count);
|
---|
51 | int i;
|
---|
52 |
|
---|
53 | printf("tst: count=%d\n", count);
|
---|
54 | for (i = 0; i < count; i++)
|
---|
55 | {
|
---|
56 | if (paf[i] == 0 && pah[i] == INVALID_HANDLE_VALUE)
|
---|
57 | continue;
|
---|
58 |
|
---|
59 | printf("tst: #%02d: native=%#p flags=%#x", i, pah[i], paf[i]);
|
---|
60 | if (paf[i] & 0x01) printf(" FOPEN");
|
---|
61 | if (paf[i] & 0x02) printf(" FEOFLAG");
|
---|
62 | if (paf[i] & 0x02) printf(" FEOFLAG");
|
---|
63 | if (paf[i] & 0x04) printf(" FCRLF");
|
---|
64 | if (paf[i] & 0x08) printf(" FPIPE");
|
---|
65 | if (paf[i] & 0x10) printf(" FNOINHERIT");
|
---|
66 | if (paf[i] & 0x20) printf(" FAPPEND");
|
---|
67 | if (paf[i] & 0x40) printf(" FDEV");
|
---|
68 | if (paf[i] & 0x80) printf(" FTEXT");
|
---|
69 | printf("\n");
|
---|
70 | }
|
---|
71 | }
|
---|
72 |
|
---|
73 | return 0;
|
---|
74 | }
|
---|
75 |
|
---|