ReactOS 0.4.15-dev-7660-g0086d05
notevil.c
Go to the documentation of this file.
1/*
2 * notevil.c
3 *
4 * --------------------------------------------------------------------
5 *
6 * This software is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
10 *
11 * This software is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Library General Public
17 * License along with this software; see the file COPYING.LIB. If
18 * not, write to the Free Software Foundation, Inc., 675 Mass Ave,
19 * Cambridge, MA 02139, USA.
20 *
21 * --------------------------------------------------------------------
22 * ReactOS Coders Console Parade
23 *
24 * 19990411 EA
25 * 19990515 EA
26 */
27
28#include <windows.h>
29#include <stdio.h>
30#include "resource.h"
31
32// #define DISPLAY_COORD
33
34LPCWSTR app_name = L"notevil";
35
40
41VOID
43 COORD xy,
45{
46 DWORD cWritten = 0;
47 DWORD dwLen;
48
49 if (!lpString || *lpString == 0) return;
50
51 dwLen = (DWORD)wcslen(lpString);
52
53 /* Don't bother writing text when erasing */
54 if (wColor)
55 {
57 lpString,
58 dwLen,
59 xy,
60 &cWritten);
61 }
62
64 wColor,
65 dwLen,
66 xy,
67 &cWritten);
68}
69
70
71#ifdef DISPLAY_COORD
72VOID
73WriteCoord(COORD c)
74{
75 COORD xy = {0,0};
76 WCHAR buf[40];
77
78 wsprintf(buf, L"x=%02d y=%02d", c.X, c.Y);
79
82}
83#endif /* def DISPLAY_COORD */
84
85
86VOID
90{
91 if (RES_LAST_INDEX == *Index)
93 else
94 ++*Index;
95
97}
98
99
100VOID
102{
103 LPWSTR szTitle = L"ReactOS Coders Console Parade";
104 COORD xy;
105
107 xy.Y = ScreenBufferInfo.dwSize.Y / 2;
108
111}
112
113
114#define RES_DELAY_CHANGE 12
115#define RES_BUFFER_SIZE 1024
116VOID
118{
119 WCHAR NameString[RES_BUFFER_SIZE];
120 DWORD NameIndex = 0;
121 INT NameLength = 0;
122 COORD xy;
124 INT dir_y = 1;
125 INT dir_x = 1;
126 WORD wColor = 1;
127
128 xy.X = ScreenBufferInfo.dwSize.X / 2;
129 xy.Y = ScreenBufferInfo.dwSize.Y / 2;
130
131 for ( ; 1; ++n )
132 {
133 if (n == RES_DELAY_CHANGE)
134 {
135 n = 0;
136
137 GetNextString(NameString,
139 &NameIndex);
140 NameLength = wcslen(NameString);
141
142 wColor++;
143 if ((wColor & 0x000F) == 0)
144 wColor = 1;
145 }
146 if (xy.X == 0)
147 {
148 if (dir_x == -1)
149 dir_x = 1;
150 }
151 else if (xy.X >= ScreenBufferInfo.dwSize.X - NameLength - 1)
152 {
153 if (dir_x == 1)
154 dir_x = -1;
155 }
156 xy.X += dir_x;
157
158 if (xy.Y == 0)
159 {
160 if (dir_y == -1)
161 dir_y = 1;
162 }
163 else if (xy.Y >= ScreenBufferInfo.dwSize.Y - 1)
164 {
165 if (dir_y == 1)
166 dir_y = -1;
167 }
168 xy.Y += dir_y;
169
170#ifdef DISPLAY_COORD
171 WriteCoord(xy);
172#endif /* def DISPLAY_COORD */
173
174 DisplayTitle();
175 WriteStringAt(NameString, xy, wColor);
177 WriteStringAt(NameString, xy, 0);
178 }
179}
180
181
182int wmain(int argc, WCHAR* argv[])
183{
185 DWORD Written;
186 COORD Coord = { 0, 0 };
187
189
195 0,
196 NULL,
198 NULL);
200 {
201 wprintf(L"%s: could not create a new screen buffer\n", app_name);
202 return EXIT_FAILURE;
203 }
204
205 /* Fill buffer with black background */
207 0,
209 Coord,
210 &Written);
211
214 {
215 wprintf(L"CreateWaitabletimer() failed\n");
216 return 1;
217 }
218 lint.QuadPart = -2000000;
220 {
221 wprintf(L"SetWaitableTimer() failed: 0x%lx\n", GetLastError());
222 return 2;
223 }
225 MainLoop();
227 return EXIT_SUCCESS;
228}
229
230/* EOF */
static int argc
Definition: ServiceArgs.c:12
#define lint
Definition: hash.c:43
BOOL WINAPI WriteConsoleOutputCharacterW(HANDLE hConsoleOutput, IN LPCWSTR lpCharacter, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfCharsWritten)
Definition: console.c:451
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
Definition: console.c:203
BOOL WINAPI FillConsoleOutputAttribute(IN HANDLE hConsoleOutput, IN WORD wAttribute, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfAttrsWritten)
Definition: console.c:525
BOOL WINAPI GetConsoleScreenBufferInfo(IN HANDLE hConsoleOutput, OUT PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo)
Definition: console.c:595
WORD wColor
#define FOREGROUND_INTENSITY
Definition: blue.h:64
#define BACKGROUND_GREEN
Definition: blue.h:66
#define BACKGROUND_RED
Definition: blue.h:67
#define BACKGROUND_BLUE
Definition: blue.h:65
#define FOREGROUND_GREEN
Definition: blue.h:62
Definition: bufpool.h:45
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define CloseHandle
Definition: compat.h:739
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
HANDLE WINAPI CreateConsoleScreenBuffer(DWORD dwDesiredAccess, DWORD dwShareMode, CONST SECURITY_ATTRIBUTES *lpSecurityAttributes, DWORD dwFlags, LPVOID lpScreenBufferData)
Definition: console.c:2313
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleActiveScreenBuffer(HANDLE hConsoleOutput)
Definition: console.c:1799
#define INFINITE
Definition: serial.h:102
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned short WORD
Definition: ntddk_ex.h:93
GLdouble n
Definition: glext.h:7729
const GLubyte * c
Definition: glext.h:8905
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define EXIT_FAILURE
Definition: jerror.c:33
TCHAR szTitle[MAX_LOADSTRING]
Definition: magnifier.c:35
#define RES_LAST_INDEX
Definition: resource.h:2
#define RES_FIRST_INDEX
Definition: resource.h:1
#define argv
Definition: mplay32.c:18
VOID GetNextString(LPWSTR Buffer, INT BufferSize, PDWORD Index)
Definition: notevil.c:87
LPCWSTR app_name
Definition: notevil.c:34
CONSOLE_SCREEN_BUFFER_INFO ScreenBufferInfo
Definition: notevil.c:38
HANDLE myself
Definition: notevil.c:36
VOID DisplayTitle(VOID)
Definition: notevil.c:101
#define RES_DELAY_CHANGE
Definition: notevil.c:114
VOID WriteStringAt(LPWSTR lpString, COORD xy, WORD wColor)
Definition: notevil.c:42
HANDLE WaitableTimer
Definition: notevil.c:39
#define RES_BUFFER_SIZE
Definition: notevil.c:115
HANDLE ScreenBuffer
Definition: notevil.c:37
VOID MainLoop(VOID)
Definition: notevil.c:117
#define DWORD
Definition: nt_native.h:44
#define GENERIC_WRITE
Definition: nt_native.h:90
#define L(x)
Definition: ntvdm.h:50
DWORD * PDWORD
Definition: pedump.c:68
unsigned short USHORT
Definition: pedump.c:61
int wmain()
#define EXIT_SUCCESS
Definition: rdjpgcom.c:55
Definition: bl.h:1338
ULONG Y
Definition: bl.h:1340
ULONG X
Definition: bl.h:1339
SHORT Y
Definition: blue.h:27
SHORT X
Definition: blue.h:26
SHORT Right
Definition: blue.h:34
SHORT Left
Definition: blue.h:32
SHORT Top
Definition: blue.h:33
SHORT Bottom
Definition: blue.h:35
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
BOOL WINAPI SetWaitableTimer(IN HANDLE hTimer, IN const LARGE_INTEGER *pDueTime, IN LONG lPeriod, IN PTIMERAPCROUTINE pfnCompletionRoutine OPTIONAL, IN OPTIONAL LPVOID lpArgToCompletionRoutine, IN BOOL fResume)
Definition: synch.c:382
int32_t INT
Definition: typedefs.h:58
_In_ WDFCOLLECTION _In_ ULONG Index
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254
#define wprintf(...)
Definition: whoami.c:18
#define STD_OUTPUT_HANDLE
Definition: winbase.h:268
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define GetModuleHandle
Definition: winbase.h:3762
#define CreateWaitableTimer
Definition: winbase.h:3696
#define CONSOLE_TEXTMODE_BUFFER
Definition: wincon.h:62
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define wsprintf
Definition: winuser.h:5864
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185