ReactOS 0.4.16-dev-338-g34e76ad
notevil.c File Reference
#include <windows.h>
#include <stdio.h>
#include "resource.h"
Include dependency graph for notevil.c:

Go to the source code of this file.

Macros

#define RES_DELAY_CHANGE   12
 
#define RES_BUFFER_SIZE   1024
 

Functions

VOID WriteStringAt (LPWSTR lpString, COORD xy, WORD wColor)
 
VOID GetNextString (LPWSTR Buffer, INT BufferSize, PDWORD Index)
 
VOID DisplayTitle (VOID)
 
VOID MainLoop (VOID)
 
int wmain (int argc, WCHAR *argv[])
 

Variables

LPCWSTR app_name = L"notevil"
 
HANDLE myself
 
HANDLE ScreenBuffer
 
CONSOLE_SCREEN_BUFFER_INFO ScreenBufferInfo
 
HANDLE WaitableTimer
 

Macro Definition Documentation

◆ RES_BUFFER_SIZE

#define RES_BUFFER_SIZE   1024

Definition at line 115 of file notevil.c.

◆ RES_DELAY_CHANGE

#define RES_DELAY_CHANGE   12

Definition at line 114 of file notevil.c.

Function Documentation

◆ DisplayTitle()

VOID DisplayTitle ( VOID  )

Definition at line 101 of file notevil.c.

102{
103 LPWSTR szTitle = L"ReactOS Coders Console Parade";
104 COORD xy;
105
107 xy.Y = ScreenBufferInfo.dwSize.Y / 2;
108
111}
#define FOREGROUND_INTENSITY
Definition: blue.h:64
#define FOREGROUND_GREEN
Definition: blue.h:62
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
TCHAR szTitle[MAX_LOADSTRING]
Definition: magnifier.c:35
CONSOLE_SCREEN_BUFFER_INFO ScreenBufferInfo
Definition: notevil.c:38
VOID WriteStringAt(LPWSTR lpString, COORD xy, WORD wColor)
Definition: notevil.c:42
#define L(x)
Definition: ntvdm.h:50
unsigned short USHORT
Definition: pedump.c:61
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
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by MainLoop().

◆ GetNextString()

VOID GetNextString ( LPWSTR  Buffer,
INT  BufferSize,
PDWORD  Index 
)

Definition at line 87 of file notevil.c.

90{
91 if (RES_LAST_INDEX == *Index)
93 else
94 ++*Index;
95
97}
Definition: bufpool.h:45
#define RES_LAST_INDEX
Definition: resource.h:2
#define RES_FIRST_INDEX
Definition: resource.h:1
HANDLE myself
Definition: notevil.c:36
_In_ WDFCOLLECTION _In_ ULONG Index
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)

Referenced by MainLoop().

◆ MainLoop()

VOID MainLoop ( VOID  )

Definition at line 117 of file notevil.c.

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}
WORD wColor
#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
VOID GetNextString(LPWSTR Buffer, INT BufferSize, PDWORD Index)
Definition: notevil.c:87
VOID DisplayTitle(VOID)
Definition: notevil.c:101
#define RES_DELAY_CHANGE
Definition: notevil.c:114
HANDLE WaitableTimer
Definition: notevil.c:39
#define RES_BUFFER_SIZE
Definition: notevil.c:115
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
int32_t INT
Definition: typedefs.h:58
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by wmain().

◆ wmain()

int wmain ( int  argc,
WCHAR argv[] 
)

Definition at line 182 of file notevil.c.

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}
#define lint
Definition: hash.c:43
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
#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 EXIT_FAILURE
Definition: jerror.c:33
LPCWSTR app_name
Definition: notevil.c:34
HANDLE ScreenBuffer
Definition: notevil.c:37
VOID MainLoop(VOID)
Definition: notevil.c:117
#define GENERIC_WRITE
Definition: nt_native.h:90
#define EXIT_SUCCESS
Definition: rdjpgcom.c:55
SHORT Right
Definition: blue.h:34
SHORT Left
Definition: blue.h:32
SHORT Top
Definition: blue.h:33
SHORT Bottom
Definition: blue.h:35
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
#define wprintf(...)
Definition: whoami.c:18
#define STD_OUTPUT_HANDLE
Definition: winbase.h:294
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define GetModuleHandle
Definition: winbase.h:3852
#define CreateWaitableTimer
Definition: winbase.h:3786
#define CONSOLE_TEXTMODE_BUFFER
Definition: wincon.h:62

◆ WriteStringAt()

VOID WriteStringAt ( LPWSTR  lpString,
COORD  xy,
WORD  wColor 
)

Definition at line 42 of file notevil.c.

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}
BOOL WINAPI WriteConsoleOutputCharacterW(HANDLE hConsoleOutput, IN LPCWSTR lpCharacter, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfCharsWritten)
Definition: console.c:451
#define DWORD
Definition: nt_native.h:44

Referenced by DisplayTitle(), and MainLoop().

Variable Documentation

◆ app_name

LPCWSTR app_name = L"notevil"

Definition at line 34 of file notevil.c.

Referenced by wmain().

◆ myself

HANDLE myself

Definition at line 36 of file notevil.c.

Referenced by GetNextString(), and wmain().

◆ ScreenBuffer

◆ ScreenBufferInfo

◆ WaitableTimer

HANDLE WaitableTimer