summaryrefslogtreecommitdiffstats
path: root/private/ntos/fw/alpha/fakebldr.c
blob: 38153d82e77e80fe1f3de16d55f2284f5daaaf60 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#include "fwp.h"
#include "jnsnvdeo.h"
#include "jnvendor.h"

VOID
main(
    int argc,
    char *argv[],
    char *envp[]
    )
{
    ULONG Index;
    UCHAR Character;
    ULONG Count;
    LONG DefaultChoice = 0;
    PCHAR Choices[] = {
        "Print out argc",
        "Print out argv list",
        "Print out envp list",
        "Exit"
    };
#define NUMBER_OF_CHOICES (sizeof(Choices) / sizeof(ULONG))


    while (TRUE) {

        VenSetScreenAttributes( TRUE, FALSE, FALSE);
        VenPrint1("%c2J", ASCII_CSI);
        VenSetPosition( 0, 0);
	VenPrint("Welcome to the Alpha fake osloader!!\r\n");

        for (Index = 0; Index < NUMBER_OF_CHOICES ; Index++ ) {
            VenSetPosition( Index + 2, 5);
            if (Index == DefaultChoice) {
                VenSetScreenAttributes( TRUE, FALSE, TRUE);
                VenPrint(Choices[Index]);
                VenSetScreenAttributes( TRUE, FALSE, FALSE);
            } else {
                VenPrint(Choices[Index]);
            }
        }

        VenSetPosition(NUMBER_OF_CHOICES + 2, 0);

        Character = 0;
        do {
            if (ArcGetReadStatus(ARC_CONSOLE_INPUT) == ESUCCESS) {
                ArcRead(ARC_CONSOLE_INPUT, &Character, 1, &Count);
                switch (Character) {

                case ASCII_ESC:
                    ArcRead(ARC_CONSOLE_INPUT, &Character, 1, &Count);
                    if (Character != '[') {
                        break;
                    }

                case ASCII_CSI:
                    ArcRead(ARC_CONSOLE_INPUT, &Character, 1, &Count);
                    VenSetPosition( DefaultChoice + 2, 5);
                    VenPrint(Choices[DefaultChoice]);
                    switch (Character) {
                    case 'A':
                    case 'D':
                        DefaultChoice--;
                        if (DefaultChoice < 0) {
                            DefaultChoice = NUMBER_OF_CHOICES-1;
                        }
                        break;
                    case 'B':
                    case 'C':
                        DefaultChoice++;
                        if (DefaultChoice == NUMBER_OF_CHOICES) {
                            DefaultChoice = 0;
                        }
                        break;
                    case 'H':
                        DefaultChoice = 0;
                        break;
                    default:
                        break;
                    }
                    VenSetPosition( DefaultChoice + 2, 5);
                    VenSetScreenAttributes( TRUE, FALSE, TRUE);
                    VenPrint(Choices[DefaultChoice]);
                    VenSetScreenAttributes( TRUE, FALSE, FALSE);
                    continue;

                default:
                    break;
                }
            }

        } while ((Character != '\n') && (Character != '\r'));

        switch (DefaultChoice) {

	    //
	    // Print out argc
	    //

        case 0:

	    VenSetPosition( 3, 5);
            VenPrint("\x9BJ");
            VenPrint1("argc is %x (hex).\r\n", argc);

            VenPrint(" Press any key to continue...");
            ArcRead(ARC_CONSOLE_INPUT, &Character, 1, &Count);
	    break;

	    
	    //
	    // Print out argv list
	    //

        case 1:

            VenSetPosition( 3, 5);
            VenPrint("\x9BJ");
            VenPrint("argv list is...\r\n\n");

	    for (Index = 0; Index < argc; Index++) {
		VenPrint2("argv[%d]=%s\r\n",
			  Index,
			  argv[Index]
			  );
	    }

            VenPrint("\r\n Press any key to continue...");
            ArcRead(ARC_CONSOLE_INPUT, &Character, 1, &Count);
	    break;


	    //
	    // Print out envp list
	    //

	case 2:

            VenSetPosition( 3, 5);
            VenPrint("\x9BJ");
            VenPrint("envp list is...\r\n\n");

	    Index = 0;
	    while (envp[Index] != NULL) {
		VenPrint2("envp[%d]=%s\r\n", Index, envp[Index]);
		Index++;
	    }
	    VenPrint1("envp[%d]=NULL\r\n", Index);

            VenPrint("\r\n Press any key to continue...");
            ArcRead(ARC_CONSOLE_INPUT, &Character, 1, &Count);
	    break;



		
	default:
        case 3:
            return;

	}

    }
}