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,121 +24,100 @@
|
||||||
* 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
|
||||||
|
|
||||||
|
LPCWSTR app_name = L"notevil";
|
||||||
|
|
||||||
HANDLE myself;
|
HANDLE myself;
|
||||||
HANDLE ScreenBuffer;
|
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);
|
||||||
|
|
||||||
|
/* Don't bother writing text when erasing */
|
||||||
if (wColor)
|
if (wColor)
|
||||||
WriteConsoleOutputCharacter( ScreenBuffer,
|
{
|
||||||
|
WriteConsoleOutputCharacterW(ScreenBuffer,
|
||||||
lpString,
|
lpString,
|
||||||
wLen,
|
wLen,
|
||||||
xy,
|
xy,
|
||||||
& cWritten
|
&cWritten);
|
||||||
);
|
}
|
||||||
FillConsoleOutputAttribute(
|
|
||||||
ScreenBuffer,
|
FillConsoleOutputAttribute(ScreenBuffer,
|
||||||
wColor,
|
wColor,
|
||||||
wLen,
|
wLen,
|
||||||
xy,
|
xy,
|
||||||
& cWritten
|
&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,
|
||||||
DWORD *Index
|
PDWORD Index)
|
||||||
)
|
|
||||||
{
|
{
|
||||||
if (RES_LAST_INDEX == *Index)
|
if (RES_LAST_INDEX == *Index)
|
||||||
{
|
|
||||||
*Index = RES_FIRST_INDEX;
|
*Index = RES_FIRST_INDEX;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
++*Index;
|
++*Index;
|
||||||
}
|
|
||||||
LoadString(
|
LoadStringW(myself, *Index, Buffer, BufferSize);
|
||||||
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;
|
||||||
|
@ -153,12 +132,13 @@ MainLoop(void)
|
||||||
{
|
{
|
||||||
if (n == RES_DELAY_CHANGE)
|
if (n == RES_DELAY_CHANGE)
|
||||||
{
|
{
|
||||||
n = GetNextString(
|
n = 0;
|
||||||
NameString,
|
|
||||||
|
GetNextString(NameString,
|
||||||
RES_BUFFER_SIZE,
|
RES_BUFFER_SIZE,
|
||||||
& NameIndex
|
&NameIndex);
|
||||||
);
|
NameLength = wcslen(NameString);
|
||||||
NameLength = lstrlen(NameString);
|
|
||||||
wColor++;
|
wColor++;
|
||||||
if ((wColor & 0x000F) == 0)
|
if ((wColor & 0x000F) == 0)
|
||||||
wColor = 1;
|
wColor = 1;
|
||||||
|
@ -186,30 +166,20 @@ MainLoop(void)
|
||||||
dir_y = -1;
|
dir_y = -1;
|
||||||
}
|
}
|
||||||
xy.Y += dir_y;
|
xy.Y += dir_y;
|
||||||
|
|
||||||
#ifdef DISPLAY_COORD
|
#ifdef DISPLAY_COORD
|
||||||
WriteCoord(xy);
|
WriteCoord(xy);
|
||||||
#endif /* def DISPLAY_COORD */
|
#endif /* def DISPLAY_COORD */
|
||||||
|
|
||||||
DisplayTitle();
|
DisplayTitle();
|
||||||
WriteStringAt(
|
WriteStringAt(NameString, xy, wColor);
|
||||||
NameString,
|
|
||||||
xy,
|
|
||||||
wColor
|
|
||||||
);
|
|
||||||
WaitForSingleObject(WaitableTimer, INFINITE);
|
WaitForSingleObject(WaitableTimer, INFINITE);
|
||||||
WriteStringAt(
|
WriteStringAt(NameString, xy, 0);
|
||||||
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;
|
||||||
|
@ -221,23 +191,18 @@ main(
|
||||||
&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)
|
|
||||||
{
|
{
|
||||||
_ftprintf(
|
wprintf(L"%s: could not create a new screen buffer\n", app_name);
|
||||||
stderr,
|
|
||||||
_TEXT("%s: could not create a new screen buffer\n"),
|
|
||||||
app_name
|
|
||||||
);
|
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
// Fill buffer with black background
|
|
||||||
|
/* Fill buffer with black background */
|
||||||
FillConsoleOutputAttribute(ScreenBuffer,
|
FillConsoleOutputAttribute(ScreenBuffer,
|
||||||
0,
|
0,
|
||||||
ScreenBufferInfo.dwSize.X * ScreenBufferInfo.dwSize.Y,
|
ScreenBufferInfo.dwSize.X * ScreenBufferInfo.dwSize.Y,
|
||||||
|
@ -247,13 +212,13 @@ main(
|
||||||
WaitableTimer = CreateWaitableTimer(NULL, FALSE, NULL);
|
WaitableTimer = CreateWaitableTimer(NULL, FALSE, NULL);
|
||||||
if (WaitableTimer == INVALID_HANDLE_VALUE)
|
if (WaitableTimer == INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
printf( "CreateWaitabletimer() failed\n" );
|
wprintf(L"CreateWaitabletimer() failed\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
lint.QuadPart = -2000000;
|
lint.QuadPart = -2000000;
|
||||||
if( SetWaitableTimer( WaitableTimer, &lint, 200, NULL, NULL, FALSE ) == FALSE )
|
if (!SetWaitableTimer(WaitableTimer, &lint, 200, NULL, NULL, FALSE))
|
||||||
{
|
{
|
||||||
printf( "SetWaitableTimer() failed: 0x%lx\n", GetLastError() );
|
wprintf(L"SetWaitableTimer() failed: 0x%lx\n", GetLastError());
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
SetConsoleActiveScreenBuffer(ScreenBuffer);
|
SetConsoleActiveScreenBuffer(ScreenBuffer);
|
||||||
|
@ -262,5 +227,4 @@ main(
|
||||||
return EXIT_SUCCESS;
|
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>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue