mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +00:00
[NOTEVIL]
- Convert our goode olde ReactOS Easter Egg "notevil" app to unicode. - Remove .rbuild file. - Code formatting. svn path=/trunk/; revision=62550
This commit is contained in:
parent
eab1b449bb
commit
b67dc560e6
4 changed files with 209 additions and 250 deletions
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
add_executable(notevil notevil.c notevil.rc)
|
add_executable(notevil notevil.c notevil.rc)
|
||||||
set_module_type(notevil win32cui)
|
set_module_type(notevil win32cui UNICODE)
|
||||||
add_importlibs(notevil user32 msvcrt kernel32)
|
add_importlibs(notevil user32 msvcrt kernel32)
|
||||||
add_cd_file(TARGET notevil DESTINATION reactos/system32 FOR all)
|
add_cd_file(TARGET notevil DESTINATION reactos/system32 FOR all)
|
||||||
|
|
|
@ -24,243 +24,207 @@
|
||||||
* 19990411 EA
|
* 19990411 EA
|
||||||
* 19990515 EA
|
* 19990515 EA
|
||||||
*/
|
*/
|
||||||
//#define UNICODE
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <tchar.h>
|
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
|
|
||||||
LPCTSTR app_name = _TEXT("notevil");
|
// #define DISPLAY_COORD
|
||||||
|
|
||||||
HANDLE myself;
|
LPCWSTR app_name = L"notevil";
|
||||||
HANDLE ScreenBuffer;
|
|
||||||
|
HANDLE myself;
|
||||||
|
HANDLE ScreenBuffer;
|
||||||
CONSOLE_SCREEN_BUFFER_INFO ScreenBufferInfo;
|
CONSOLE_SCREEN_BUFFER_INFO ScreenBufferInfo;
|
||||||
HANDLE WaitableTimer;
|
HANDLE WaitableTimer;
|
||||||
|
|
||||||
void
|
VOID
|
||||||
WriteStringAt(
|
WriteStringAt(LPWSTR lpString,
|
||||||
LPTSTR lpString,
|
COORD xy,
|
||||||
COORD xy,
|
WORD wColor)
|
||||||
WORD wColor
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
DWORD cWritten = 0;
|
DWORD cWritten = 0;
|
||||||
WORD wLen = lstrlen(lpString);
|
WORD wLen;
|
||||||
|
|
||||||
if (0 == wLen)
|
if (!lpString || *lpString == 0) return;
|
||||||
return;
|
|
||||||
// don't bother writing text when erasing
|
wLen = wcslen(lpString);
|
||||||
if( wColor )
|
|
||||||
WriteConsoleOutputCharacter( ScreenBuffer,
|
/* Don't bother writing text when erasing */
|
||||||
lpString,
|
if (wColor)
|
||||||
wLen,
|
{
|
||||||
xy,
|
WriteConsoleOutputCharacterW(ScreenBuffer,
|
||||||
& cWritten
|
lpString,
|
||||||
);
|
wLen,
|
||||||
FillConsoleOutputAttribute(
|
xy,
|
||||||
ScreenBuffer,
|
&cWritten);
|
||||||
wColor,
|
}
|
||||||
wLen,
|
|
||||||
xy,
|
FillConsoleOutputAttribute(ScreenBuffer,
|
||||||
& cWritten
|
wColor,
|
||||||
);
|
wLen,
|
||||||
|
xy,
|
||||||
|
&cWritten);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef DISPLAY_COORD
|
#ifdef DISPLAY_COORD
|
||||||
void
|
VOID
|
||||||
WriteCoord(COORD c)
|
WriteCoord(COORD c)
|
||||||
{
|
{
|
||||||
COORD xy = {0,0};
|
COORD xy = {0,0};
|
||||||
TCHAR buf [40];
|
WCHAR buf[40];
|
||||||
|
|
||||||
wsprintf(
|
wsprintf(buf, L"x=%02d y=%02d", c.X, c.Y);
|
||||||
buf,
|
|
||||||
_TEXT("x=%02d y=%02d"),
|
WriteStringAt(buf, xy,
|
||||||
c.X,
|
BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE);
|
||||||
c.Y
|
|
||||||
);
|
|
||||||
WriteStringAt(
|
|
||||||
buf,
|
|
||||||
xy,
|
|
||||||
(BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
#endif /* def DISPLAY_COORD */
|
#endif /* def DISPLAY_COORD */
|
||||||
|
|
||||||
|
|
||||||
INT
|
VOID
|
||||||
GetNextString(
|
GetNextString(LPWSTR Buffer,
|
||||||
LPTSTR Buffer,
|
INT BufferSize,
|
||||||
INT BufferSize,
|
PDWORD Index)
|
||||||
DWORD *Index
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
if (RES_LAST_INDEX == *Index)
|
if (RES_LAST_INDEX == *Index)
|
||||||
{
|
*Index = RES_FIRST_INDEX;
|
||||||
*Index = RES_FIRST_INDEX;
|
else
|
||||||
}
|
++*Index;
|
||||||
else
|
|
||||||
{
|
LoadStringW(myself, *Index, Buffer, BufferSize);
|
||||||
++*Index;
|
|
||||||
}
|
|
||||||
LoadString(
|
|
||||||
myself,
|
|
||||||
*Index,
|
|
||||||
Buffer,
|
|
||||||
BufferSize
|
|
||||||
);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
DisplayTitle(VOID)
|
DisplayTitle(VOID)
|
||||||
{
|
{
|
||||||
LPTSTR szTitle = _TEXT("ReactOS Coders Console Parade");
|
LPWSTR szTitle = L"ReactOS Coders Console Parade";
|
||||||
COORD xy;
|
COORD xy;
|
||||||
|
|
||||||
xy.X = (ScreenBufferInfo.dwSize.X - lstrlen(szTitle)) / 2;
|
xy.X = (ScreenBufferInfo.dwSize.X - wcslen(szTitle)) / 2;
|
||||||
xy.Y = ScreenBufferInfo.dwSize.Y / 2;
|
xy.Y = ScreenBufferInfo.dwSize.Y / 2;
|
||||||
|
|
||||||
WriteStringAt(
|
WriteStringAt(szTitle, xy,
|
||||||
szTitle,
|
FOREGROUND_GREEN | FOREGROUND_INTENSITY);
|
||||||
xy,
|
|
||||||
(FOREGROUND_GREEN | FOREGROUND_INTENSITY)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#define RES_DELAY_CHANGE 12
|
#define RES_DELAY_CHANGE 12
|
||||||
#define RES_BUFFER_SIZE 1024
|
#define RES_BUFFER_SIZE 1024
|
||||||
void
|
VOID
|
||||||
MainLoop(void)
|
MainLoop(VOID)
|
||||||
{
|
{
|
||||||
TCHAR NameString [RES_BUFFER_SIZE];
|
WCHAR NameString[RES_BUFFER_SIZE];
|
||||||
DWORD NameIndex = 1;
|
DWORD NameIndex = 0;
|
||||||
INT NameLength = 0;
|
INT NameLength = 0;
|
||||||
COORD xy;
|
COORD xy;
|
||||||
INT n = RES_DELAY_CHANGE;
|
INT n = RES_DELAY_CHANGE;
|
||||||
INT dir_y = 1;
|
INT dir_y = 1;
|
||||||
INT dir_x = 1;
|
INT dir_x = 1;
|
||||||
WORD wColor = 1;
|
WORD wColor = 1;
|
||||||
|
|
||||||
xy.X = ScreenBufferInfo.dwSize.X / 2;
|
xy.X = ScreenBufferInfo.dwSize.X / 2;
|
||||||
xy.Y = ScreenBufferInfo.dwSize.Y / 2;
|
xy.Y = ScreenBufferInfo.dwSize.Y / 2;
|
||||||
|
|
||||||
for ( ; 1; ++n )
|
for ( ; 1; ++n )
|
||||||
{
|
{
|
||||||
if (n == RES_DELAY_CHANGE)
|
if (n == RES_DELAY_CHANGE)
|
||||||
{
|
{
|
||||||
n = GetNextString(
|
n = 0;
|
||||||
NameString,
|
|
||||||
RES_BUFFER_SIZE,
|
GetNextString(NameString,
|
||||||
& NameIndex
|
RES_BUFFER_SIZE,
|
||||||
);
|
&NameIndex);
|
||||||
NameLength = lstrlen(NameString);
|
NameLength = wcslen(NameString);
|
||||||
wColor++;
|
|
||||||
if ((wColor & 0x000F) == 0)
|
wColor++;
|
||||||
wColor = 1;
|
if ((wColor & 0x000F) == 0)
|
||||||
}
|
wColor = 1;
|
||||||
if (xy.X == 0)
|
}
|
||||||
{
|
if (xy.X == 0)
|
||||||
if (dir_x == -1)
|
{
|
||||||
dir_x = 1;
|
if (dir_x == -1)
|
||||||
}
|
dir_x = 1;
|
||||||
else if (xy.X >= ScreenBufferInfo.dwSize.X - NameLength - 1)
|
}
|
||||||
{
|
else if (xy.X >= ScreenBufferInfo.dwSize.X - NameLength - 1)
|
||||||
if (dir_x == 1)
|
{
|
||||||
dir_x = -1;
|
if (dir_x == 1)
|
||||||
}
|
dir_x = -1;
|
||||||
xy.X += dir_x;
|
}
|
||||||
|
xy.X += dir_x;
|
||||||
|
|
||||||
|
if (xy.Y == 0)
|
||||||
|
{
|
||||||
|
if (dir_y == -1)
|
||||||
|
dir_y = 1;
|
||||||
|
}
|
||||||
|
else if (xy.Y >= ScreenBufferInfo.dwSize.Y - 1)
|
||||||
|
{
|
||||||
|
if (dir_y == 1)
|
||||||
|
dir_y = -1;
|
||||||
|
}
|
||||||
|
xy.Y += dir_y;
|
||||||
|
|
||||||
if (xy.Y == 0)
|
|
||||||
{
|
|
||||||
if (dir_y == -1)
|
|
||||||
dir_y = 1;
|
|
||||||
}
|
|
||||||
else if (xy.Y >= ScreenBufferInfo.dwSize.Y - 1)
|
|
||||||
{
|
|
||||||
if (dir_y == 1)
|
|
||||||
dir_y = -1;
|
|
||||||
}
|
|
||||||
xy.Y += dir_y;
|
|
||||||
#ifdef DISPLAY_COORD
|
#ifdef DISPLAY_COORD
|
||||||
WriteCoord(xy);
|
WriteCoord(xy);
|
||||||
#endif /* def DISPLAY_COORD */
|
#endif /* def DISPLAY_COORD */
|
||||||
DisplayTitle();
|
|
||||||
WriteStringAt(
|
DisplayTitle();
|
||||||
NameString,
|
WriteStringAt(NameString, xy, wColor);
|
||||||
xy,
|
WaitForSingleObject(WaitableTimer, INFINITE);
|
||||||
wColor
|
WriteStringAt(NameString, xy, 0);
|
||||||
);
|
}
|
||||||
WaitForSingleObject( WaitableTimer, INFINITE );
|
|
||||||
WriteStringAt(
|
|
||||||
NameString,
|
|
||||||
xy,
|
|
||||||
0
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int wmain(int argc, WCHAR* argv[])
|
||||||
main(
|
|
||||||
int argc,
|
|
||||||
char *argv []
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
LARGE_INTEGER lint;
|
LARGE_INTEGER lint;
|
||||||
DWORD Written;
|
DWORD Written;
|
||||||
COORD Coord = { 0, 0 };
|
COORD Coord = { 0, 0 };
|
||||||
|
|
||||||
myself = GetModuleHandle(NULL);
|
myself = GetModuleHandle(NULL);
|
||||||
|
|
||||||
GetConsoleScreenBufferInfo (GetStdHandle(STD_OUTPUT_HANDLE),
|
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE),
|
||||||
&ScreenBufferInfo);
|
&ScreenBufferInfo);
|
||||||
ScreenBufferInfo.dwSize.X = ScreenBufferInfo.srWindow.Right - ScreenBufferInfo.srWindow.Left + 1;
|
ScreenBufferInfo.dwSize.X = ScreenBufferInfo.srWindow.Right - ScreenBufferInfo.srWindow.Left + 1;
|
||||||
ScreenBufferInfo.dwSize.Y = ScreenBufferInfo.srWindow.Bottom - ScreenBufferInfo.srWindow.Top + 1;
|
ScreenBufferInfo.dwSize.Y = ScreenBufferInfo.srWindow.Bottom - ScreenBufferInfo.srWindow.Top + 1;
|
||||||
ScreenBuffer = CreateConsoleScreenBuffer(
|
ScreenBuffer = CreateConsoleScreenBuffer(GENERIC_WRITE,
|
||||||
GENERIC_WRITE,
|
0,
|
||||||
0,
|
NULL,
|
||||||
NULL,
|
CONSOLE_TEXTMODE_BUFFER,
|
||||||
CONSOLE_TEXTMODE_BUFFER,
|
NULL);
|
||||||
NULL
|
if (ScreenBuffer == INVALID_HANDLE_VALUE)
|
||||||
);
|
{
|
||||||
if (INVALID_HANDLE_VALUE == ScreenBuffer)
|
wprintf(L"%s: could not create a new screen buffer\n", app_name);
|
||||||
{
|
return EXIT_FAILURE;
|
||||||
_ftprintf(
|
}
|
||||||
stderr,
|
|
||||||
_TEXT("%s: could not create a new screen buffer\n"),
|
|
||||||
app_name
|
|
||||||
);
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
// Fill buffer with black background
|
|
||||||
FillConsoleOutputAttribute( ScreenBuffer,
|
|
||||||
0,
|
|
||||||
ScreenBufferInfo.dwSize.X * ScreenBufferInfo.dwSize.Y,
|
|
||||||
Coord,
|
|
||||||
&Written );
|
|
||||||
|
|
||||||
WaitableTimer = CreateWaitableTimer( NULL, FALSE, NULL );
|
/* Fill buffer with black background */
|
||||||
if( WaitableTimer == INVALID_HANDLE_VALUE )
|
FillConsoleOutputAttribute(ScreenBuffer,
|
||||||
{
|
0,
|
||||||
printf( "CreateWaitabletimer() failed\n" );
|
ScreenBufferInfo.dwSize.X * ScreenBufferInfo.dwSize.Y,
|
||||||
return 1;
|
Coord,
|
||||||
}
|
&Written);
|
||||||
lint.QuadPart = -2000000;
|
|
||||||
if( SetWaitableTimer( WaitableTimer, &lint, 200, NULL, NULL, FALSE ) == FALSE )
|
WaitableTimer = CreateWaitableTimer(NULL, FALSE, NULL);
|
||||||
{
|
if (WaitableTimer == INVALID_HANDLE_VALUE)
|
||||||
printf( "SetWaitableTimer() failed: 0x%lx\n", GetLastError() );
|
{
|
||||||
return 2;
|
wprintf(L"CreateWaitabletimer() failed\n");
|
||||||
}
|
return 1;
|
||||||
SetConsoleActiveScreenBuffer(ScreenBuffer);
|
}
|
||||||
MainLoop();
|
lint.QuadPart = -2000000;
|
||||||
CloseHandle(ScreenBuffer);
|
if (!SetWaitableTimer(WaitableTimer, &lint, 200, NULL, NULL, FALSE))
|
||||||
return EXIT_SUCCESS;
|
{
|
||||||
|
wprintf(L"SetWaitableTimer() failed: 0x%lx\n", GetLastError());
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
SetConsoleActiveScreenBuffer(ScreenBuffer);
|
||||||
|
MainLoop();
|
||||||
|
CloseHandle(ScreenBuffer);
|
||||||
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
<module name="notevil" type="win32cui" installbase="system32" installname="notevil.exe">
|
|
||||||
<include base="notevil">.</include>
|
|
||||||
<library>user32</library>
|
|
||||||
<file>notevil.c</file>
|
|
||||||
<file>notevil.rc</file>
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
#define REACTOS_STR_FILE_DESCRIPTION "ReactOS Coders Console Parade\0"
|
#define REACTOS_STR_FILE_DESCRIPTION "ReactOS Coders Console Parade"
|
||||||
#define REACTOS_STR_INTERNAL_NAME "notevil\0"
|
#define REACTOS_STR_INTERNAL_NAME "notevil"
|
||||||
#define REACTOS_STR_ORIGINAL_FILENAME "notevil.exe\0"
|
#define REACTOS_STR_ORIGINAL_FILENAME "notevil.exe"
|
||||||
#include <reactos/version.rc>
|
#include <reactos/version.rc>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -20,69 +20,69 @@
|
||||||
|
|
||||||
STRINGTABLE MOVEABLE
|
STRINGTABLE MOVEABLE
|
||||||
BEGIN
|
BEGIN
|
||||||
1, "Boudewijn Dekker (Ariadne)"
|
1, "Boudewijn Dekker (Ariadne)"
|
||||||
2, "Robert Bergkvist (FragDance Galore)"
|
2, "Robert Bergkvist (FragDance Galore)"
|
||||||
3, "Arindam Das"
|
3, "Arindam Das"
|
||||||
4, "Boudewijn Dekker"
|
4, "Boudewijn Dekker"
|
||||||
5, "Jason Eager"
|
5, "Jason Eager"
|
||||||
6, "Jason Filby"
|
6, "Jason Filby"
|
||||||
7, "Rex Jolliff"
|
7, "Rex Jolliff"
|
||||||
8, "Eric Kohl"
|
8, "Eric Kohl"
|
||||||
9, "Hans Kremer"
|
9, "Hans Kremer"
|
||||||
10, "Frederik Leemans"
|
10, "Frederik Leemans"
|
||||||
11, "Jean Michault"
|
11, "Jean Michault"
|
||||||
12, "Jim Noeth"
|
12, "Jim Noeth"
|
||||||
13, "Brian Palmer"
|
13, "Brian Palmer"
|
||||||
14, "Matt Pyne"
|
14, "Matt Pyne"
|
||||||
15, "Jason Weiler"
|
15, "Jason Weiler"
|
||||||
END
|
END
|
||||||
|
|
||||||
STRINGTABLE MOVEABLE
|
STRINGTABLE MOVEABLE
|
||||||
BEGIN
|
BEGIN
|
||||||
16, "David Welch"
|
16, "David Welch"
|
||||||
17, "Emanuele Aliberti"
|
17, "Emanuele Aliberti"
|
||||||
18, "Phillip Susi"
|
18, "Phillip Susi"
|
||||||
19, "Paolo Pantaleo"
|
19, "Paolo Pantaleo"
|
||||||
20, "Hernan Ochoa"
|
20, "Hernan Ochoa"
|
||||||
21, "Casper Hornstrup"
|
21, "Casper Hornstrup"
|
||||||
22, "Steven Edwards"
|
22, "Steven Edwards"
|
||||||
23, "KJK::Hyperion"
|
23, "KJK::Hyperion"
|
||||||
24, "Robert Dickenson"
|
24, "Robert Dickenson"
|
||||||
25, "Eugene Ingerman"
|
25, "Eugene Ingerman"
|
||||||
26, "Guido de Jong"
|
26, "Guido de Jong"
|
||||||
27, "Jurgen van Gael"
|
27, "Jurgen van Gael"
|
||||||
28, "Marty Dill"
|
28, "Marty Dill"
|
||||||
29, "Ge van Geldorp"
|
29, "Ge van Geldorp"
|
||||||
30, "Richard Campbell"
|
30, "Richard Campbell"
|
||||||
END
|
END
|
||||||
|
|
||||||
STRINGTABLE MOVEABLE
|
STRINGTABLE MOVEABLE
|
||||||
BEGIN
|
BEGIN
|
||||||
31, "Gunnar Andre' Dalsnes"
|
31, "Gunnar Andre' Dalsnes"
|
||||||
32, "Aleksey Bragin"
|
32, "Aleksey Bragin"
|
||||||
33, "Royce Mitchell III"
|
33, "Royce Mitchell III"
|
||||||
34, "Mark Tempel"
|
34, "Mark Tempel"
|
||||||
35, "Art Yerkes"
|
35, "Art Yerkes"
|
||||||
36, "Martin Fuchs"
|
36, "Martin Fuchs"
|
||||||
37, "Vizzini"
|
37, "Vizzini"
|
||||||
38, "Filip Navara"
|
38, "Filip Navara"
|
||||||
39, "Andrew Greenwood"
|
39, "Andrew Greenwood"
|
||||||
40, "Thomas Weidenmueller"
|
40, "Thomas Weidenmueller"
|
||||||
41, "Jonathan Wilson"
|
41, "Jonathan Wilson"
|
||||||
42, "Alex Ionescu"
|
42, "Alex Ionescu"
|
||||||
43, "Jim Tabor"
|
43, "Jim Tabor"
|
||||||
44, "Magnus Olsen"
|
44, "Magnus Olsen"
|
||||||
45, "Herve Poussineau"
|
45, "Herve Poussineau"
|
||||||
END
|
END
|
||||||
|
|
||||||
STRINGTABLE MOVEABLE
|
STRINGTABLE MOVEABLE
|
||||||
BEGIN
|
BEGIN
|
||||||
46, "Christoph von Wittich"
|
46, "Christoph von Wittich"
|
||||||
47, "Brandon Turner"
|
47, "Brandon Turner"
|
||||||
48, "Ged Murphy"
|
48, "Ged Murphy"
|
||||||
49, "Klemens R. Friedl"
|
49, "Klemens R. Friedl"
|
||||||
50, "Maarten Bosma"
|
50, "Maarten Bosma"
|
||||||
51, "Saveliy Tretiakov"
|
51, "Saveliy Tretiakov"
|
||||||
END
|
END
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
Loading…
Reference in a new issue