ReactOS  0.4.14-dev-52-g6116262
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 
106  xy.X = (ScreenBufferInfo.dwSize.X - wcslen(szTitle)) / 2;
107  xy.Y = ScreenBufferInfo.dwSize.Y / 2;
108 
111 }
CONSOLE_SCREEN_BUFFER_INFO ScreenBufferInfo
Definition: notevil.c:38
ULONG X
Definition: bl.h:1340
TCHAR szTitle[MAX_LOADSTRING]
Definition: magnifier.c:35
static const WCHAR L[]
Definition: oid.c:1250
Definition: bl.h:1338
#define FOREGROUND_GREEN
Definition: wincon.h:40
VOID WriteStringAt(LPWSTR lpString, COORD xy, WORD wColor)
Definition: notevil.c:42
#define FOREGROUND_INTENSITY
Definition: wincon.h:42
WCHAR * LPWSTR
Definition: xmlstorage.h:184
ULONG Y
Definition: bl.h:1341
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

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 }
#define RES_FIRST_INDEX
Definition: resource.h:1
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
Definition: bufpool.h:45
static const UCHAR Index[8]
Definition: usbohci.c:18
#define BufferSize
Definition: classpnp.h:419
#define RES_LAST_INDEX
Definition: resource.h:2
HANDLE myself
Definition: notevil.c:36

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 }
HANDLE WaitableTimer
Definition: notevil.c:39
CONSOLE_SCREEN_BUFFER_INFO ScreenBufferInfo
Definition: notevil.c:38
#define RES_DELAY_CHANGE
Definition: notevil.c:114
GLdouble n
Definition: glext.h:7729
VOID GetNextString(LPWSTR Buffer, INT BufferSize, PDWORD Index)
Definition: notevil.c:87
int32_t INT
Definition: typedefs.h:56
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define RES_BUFFER_SIZE
Definition: notevil.c:115
ULONG X
Definition: bl.h:1340
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
WORD wColor
Definition: bl.h:1338
VOID WriteStringAt(LPWSTR lpString, COORD xy, WORD wColor)
Definition: notevil.c:42
#define INFINITE
Definition: serial.h:102
ULONG Y
Definition: bl.h:1341
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
VOID DisplayTitle(VOID)
Definition: notevil.c:101

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 }
HANDLE WaitableTimer
Definition: notevil.c:39
#define CloseHandle
Definition: compat.h:398
BOOL WINAPI FillConsoleOutputAttribute(IN HANDLE hConsoleOutput, IN WORD wAttribute, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfAttrsWritten)
Definition: console.c:474
CONSOLE_SCREEN_BUFFER_INFO ScreenBufferInfo
Definition: notevil.c:38
LPCWSTR app_name
Definition: notevil.c:34
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleActiveScreenBuffer(HANDLE hConsoleOutput)
Definition: console.c:1801
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
Definition: console.c:152
#define wprintf(...)
Definition: whoami.c:18
#define EXIT_SUCCESS
Definition: rdjpgcom.c:55
#define GENERIC_WRITE
Definition: nt_native.h:90
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI GetConsoleScreenBufferInfo(IN HANDLE hConsoleOutput, OUT PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo)
Definition: console.c:544
SHORT Left
Definition: blue.h:25
ULONG X
Definition: bl.h:1340
SHORT Bottom
Definition: blue.h:28
unsigned long DWORD
Definition: ntddk_ex.h:95
#define EXIT_FAILURE
Definition: jerror.c:33
SHORT Top
Definition: blue.h:26
static const WCHAR L[]
Definition: oid.c:1250
#define STD_OUTPUT_HANDLE
Definition: winbase.h:265
Definition: bl.h:1338
HANDLE myself
Definition: notevil.c:36
#define GetModuleHandle
Definition: winbase.h:3644
#define CONSOLE_TEXTMODE_BUFFER
Definition: wincon.h:59
HANDLE ScreenBuffer
Definition: notevil.c:37
#define lint
Definition: hash.c:43
#define CreateWaitableTimer
Definition: winbase.h:3578
SHORT Right
Definition: blue.h:27
VOID MainLoop(VOID)
Definition: notevil.c:117
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
ULONG Y
Definition: bl.h:1341
HANDLE WINAPI CreateConsoleScreenBuffer(DWORD dwDesiredAccess, DWORD dwShareMode, CONST SECURITY_ATTRIBUTES *lpSecurityAttributes, DWORD dwFlags, LPVOID lpScreenBufferData)
Definition: console.c:2315

◆ WriteStringAt()

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

Definition at line 42 of file notevil.c.

45 {
46  DWORD cWritten = 0;
47  WORD wLen;
48 
49  if (!lpString || *lpString == 0) return;
50 
51  wLen = wcslen(lpString);
52 
53  /* Don't bother writing text when erasing */
54  if (wColor)
55  {
57  lpString,
58  wLen,
59  xy,
60  &cWritten);
61  }
62 
64  wColor,
65  wLen,
66  xy,
67  &cWritten);
68 }
BOOL WINAPI FillConsoleOutputAttribute(IN HANDLE hConsoleOutput, IN WORD wAttribute, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfAttrsWritten)
Definition: console.c:474
BOOL WINAPI WriteConsoleOutputCharacterW(HANDLE hConsoleOutput, IN LPCWSTR lpCharacter, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfCharsWritten)
Definition: console.c:400
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
WORD wColor
HANDLE ScreenBuffer
Definition: notevil.c:37
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

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