bsod 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +15 -4
- data/bin/bsod +40 -4
- data/lib/bsod.rb +28 -2
- data/lib/bsod/linux-sparc.rb +38 -6
- data/lib/bsod/settings.rb +45 -21
- data/lib/bsod/version.rb +1 -1
- data/lib/bsod/windows2000.rb +4 -45
- data/lib/bsod/windowsnt.rb +2 -44
- data/lib/bsod/windowstext.rb +99 -0
- data/lib/bsod/windowsxp.rb +4 -48
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f56d2e58602a897f414aaadab80f80e9f7bca4cd
|
4
|
+
data.tar.gz: 3f0fd0d0bb317de06ba43d8e3e55f6a0ebf67154
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2f7b96d7cb7bdd0645c6f4a54774ce027a533860de20d987d9dbadc6afa16db27962df2e92f2bc4b0f8d69db15874e651b75a6ef355150e6aea84ce27524b32
|
7
|
+
data.tar.gz: 0fe0d86c1419ddedcdbc0ce903d7d423eaba2a477e1571754c7a182ea3131fa97150726c5d0e7e2409f80986401179c19bc0bab0e2ee6d84ad78e4817e5e37f9
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
|
3
3
|

|
4
4
|
|
5
|
-
Simulates [Blue Screens of Death](https://en.wikipedia.org/wiki/Blue_screen_of_death)
|
6
|
-
several systems, primarily Micro$oftWindow$.
|
7
|
-
|
5
|
+
Simulates [Blue Screens of Death](https://en.wikipedia.org/wiki/Blue_screen_of_death)
|
6
|
+
from several systems, primarily Micro$oftWindow$.
|
7
|
+
Shows BSODs both on graphical displays (via SDL) and terminal windows (via Curses).
|
8
8
|
|
9
9
|
As an executable, has optional flag to sleep before BSODing so you can surprise
|
10
10
|
your friends!
|
11
11
|
|
12
|
-
As a library, you can integrate a BSOD on any SDL surface.
|
12
|
+
As a library, you can integrate a BSOD on any SDL surface or Curses window.
|
13
13
|
|
14
14
|
## Usage
|
15
15
|
|
@@ -19,11 +19,14 @@ As a library, you can integrate a BSOD on any SDL surface.
|
|
19
19
|
$ bsod --wait 3.1415 # waits seconds before BSODing
|
20
20
|
$ bsod --style windowsxp # explicitly selects BSOD style
|
21
21
|
$ bsod --list # show supported systems
|
22
|
+
$ bsod --style linux-sparc --curses # show on the terminal
|
22
23
|
|
23
24
|
For more see `bsod --help`.
|
24
25
|
|
25
26
|
### Library
|
26
27
|
|
28
|
+
Over SDL
|
29
|
+
|
27
30
|
require 'bsod'
|
28
31
|
# after initializing sdl properly
|
29
32
|
screen = SDL::Screen.get
|
@@ -31,6 +34,14 @@ For more see `bsod --help`.
|
|
31
34
|
bsod.draw(screen, screen.w, screen.h)
|
32
35
|
BSOD::wait_for_sdl_key # defaults to F8
|
33
36
|
|
37
|
+
Over Curses
|
38
|
+
|
39
|
+
require 'bsod'
|
40
|
+
# after initializing curses properly
|
41
|
+
bsod = BSOD::LinuxSPARC.new
|
42
|
+
bsod.draw_curses(Curses.stdscr, Curses.cols, Curses.lines)
|
43
|
+
BSOD::wait_for_curses_key # defaults to F8
|
44
|
+
|
34
45
|
## Install
|
35
46
|
|
36
47
|
$ gem install bsod
|
data/bin/bsod
CHANGED
@@ -25,7 +25,7 @@ $settings = nil
|
|
25
25
|
# Note: This initializes `SDL` based on the global
|
26
26
|
# `$settings` parsed by `Settings` module.
|
27
27
|
#
|
28
|
-
def
|
28
|
+
def init_sdl
|
29
29
|
SDL::init(SDL::INIT_VIDEO)
|
30
30
|
SDL::TTF.init
|
31
31
|
|
@@ -51,6 +51,26 @@ def self.init_sdl
|
|
51
51
|
return screen
|
52
52
|
end
|
53
53
|
|
54
|
+
# Starts all things related to the `Curses` terminal-handling
|
55
|
+
# thingy, returning the main window.
|
56
|
+
#
|
57
|
+
# Note: This method is only required if you don't do
|
58
|
+
# this manually. For most of your custom projects,
|
59
|
+
# ignore this.
|
60
|
+
def init_curses
|
61
|
+
Curses::init_screen # all hail Curses
|
62
|
+
Curses::curs_set 0 # invisible cursor
|
63
|
+
Curses::start_color # dem colors
|
64
|
+
Curses::stdscr.keypad true # extra keys!
|
65
|
+
Curses::noecho # wont show keys typed by the user
|
66
|
+
|
67
|
+
return Curses::stdscr # main window
|
68
|
+
end
|
69
|
+
|
70
|
+
def exit_curses
|
71
|
+
Curses::close_screen
|
72
|
+
end
|
73
|
+
|
54
74
|
begin
|
55
75
|
$settings = Settings.new
|
56
76
|
$settings.parse ARGV
|
@@ -59,7 +79,11 @@ begin
|
|
59
79
|
time = $settings[:sleep_time]
|
60
80
|
sleep time if time
|
61
81
|
|
62
|
-
|
82
|
+
if not BSOD::ALL.include? $settings[:bsod_type]
|
83
|
+
puts "Unknown BSOD '#{$settings[:bsod_type]}'."
|
84
|
+
puts "Use --list to show all known types."
|
85
|
+
exit 666
|
86
|
+
end
|
63
87
|
|
64
88
|
bsod = nil
|
65
89
|
case $settings[:bsod_type]
|
@@ -69,9 +93,21 @@ begin
|
|
69
93
|
when "linux-sparc" then bsod = BSOD::LinuxSPARC.new
|
70
94
|
end
|
71
95
|
|
72
|
-
|
73
|
-
|
96
|
+
if $settings[:curses]
|
97
|
+
window = init_curses
|
98
|
+
|
99
|
+
bsod.draw_curses(window, Curses.cols, Curses.lines)
|
100
|
+
BSOD::wait_for_curses_key $settings[:exit_key]
|
101
|
+
else
|
102
|
+
screen = init_sdl
|
103
|
+
|
104
|
+
bsod.draw(screen, screen.w, screen.h)
|
105
|
+
BSOD::wait_for_sdl_key $settings[:exit_key]
|
106
|
+
end
|
74
107
|
|
75
108
|
# It automatically ends SDL on exit
|
109
|
+
#
|
110
|
+
# ...but not Curses
|
111
|
+
exit_curses if $settings[:curses]
|
76
112
|
end
|
77
113
|
|
data/lib/bsod.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
1
|
require 'sdl'
|
2
|
+
require 'curses'
|
3
3
|
|
4
4
|
# This is a great container over all Blue Screens
|
5
5
|
# of Death (BSOD).
|
@@ -9,6 +9,11 @@ require 'sdl'
|
|
9
9
|
#
|
10
10
|
module BSOD
|
11
11
|
|
12
|
+
# All currently supported BSODs.
|
13
|
+
ALL = ["windowsnt",
|
14
|
+
"windows2000",
|
15
|
+
"windowsxp",
|
16
|
+
"linux-sparc"]
|
12
17
|
|
13
18
|
# Tells if SDL has been initialized already, both
|
14
19
|
# by us (`init_sdl`) or by the user.
|
@@ -45,8 +50,29 @@ module BSOD
|
|
45
50
|
end
|
46
51
|
end
|
47
52
|
|
48
|
-
|
53
|
+
# TODO Figure out how to actually see if Curses is initialized.
|
54
|
+
def self.curses_inited?
|
55
|
+
return true
|
56
|
+
end
|
49
57
|
|
58
|
+
# Waits for a keypress of `Curses::Key` `key`, ignoring
|
59
|
+
# anything else.
|
60
|
+
#
|
61
|
+
# Defaults to F8.
|
62
|
+
#
|
63
|
+
# TODO Somehow mix this with `wait_for_sdl_key`.
|
64
|
+
def self.wait_for_curses_key(key=Curses::KEY_F8)
|
65
|
+
loop = true
|
66
|
+
while loop
|
67
|
+
|
68
|
+
case Curses::getch
|
69
|
+
when key
|
70
|
+
loop = false
|
71
|
+
end
|
72
|
+
# Sleeping a little to avoid high-CPU rates.
|
73
|
+
sleep 0.05
|
74
|
+
end
|
50
75
|
end
|
76
|
+
|
51
77
|
end
|
52
78
|
|
data/lib/bsod/linux-sparc.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
|
2
1
|
require 'bsod'
|
3
2
|
|
4
3
|
module BSOD
|
5
4
|
|
6
|
-
#
|
5
|
+
# Linux sparc kernel paging fault.
|
7
6
|
#
|
8
|
-
#
|
9
|
-
#
|
7
|
+
# TODO Somehow merge with WindowsText, because it follows the
|
8
|
+
# same drawing rules (except that it's a white over black
|
9
|
+
# text and it's shown on the bottom of the screen).
|
10
10
|
class LinuxSPARC
|
11
11
|
|
12
12
|
BSODTEXT = <<END_OF_TEXT
|
@@ -39,8 +39,7 @@ END_OF_TEXT
|
|
39
39
|
# is acceptable too.
|
40
40
|
def draw(screen, width, height)
|
41
41
|
|
42
|
-
|
43
|
-
BSOD::init_sdl if not BSOD::sdl_inited?
|
42
|
+
return if not BSOD::sdl_inited?
|
44
43
|
|
45
44
|
black = screen.format.map_rgb(0, 0, 0)
|
46
45
|
screen.fill_rect(0, 0, width, height, black)
|
@@ -73,6 +72,39 @@ END_OF_TEXT
|
|
73
72
|
# @note Maybe update only the bounded rectangle?
|
74
73
|
SDL::Screen.get.update_rect(0, 0, 0, 0)
|
75
74
|
end
|
75
|
+
|
76
|
+
# Draws the BSOD on a Curses' `window`, bounded by `width` and
|
77
|
+
# `height`.
|
78
|
+
def draw_curses(window, width, height)
|
79
|
+
|
80
|
+
return if not BSOD::curses_inited?
|
81
|
+
|
82
|
+
# Initializing colors (3 is any number)
|
83
|
+
Curses::init_pair(3, Curses::COLOR_WHITE, Curses::COLOR_BLACK)
|
84
|
+
|
85
|
+
window.attrset(Curses::color_pair(3) | Curses::A_BOLD)
|
86
|
+
|
87
|
+
# Clears the screen with spaces
|
88
|
+
0.upto(height) { window.addstr(" " * width) }
|
89
|
+
|
90
|
+
# need to print at the bottom of the screen
|
91
|
+
lines_ammount = height
|
92
|
+
|
93
|
+
i = (lines_ammount - BSODTEXT.lines.size)
|
94
|
+
BSODTEXT.each_line do |line|
|
95
|
+
# This is a little hack to allow printing empty lines.
|
96
|
+
# First I remove the '\n' at the end to avoid nasty things
|
97
|
+
# and then I append a space, to prevent nil strings.
|
98
|
+
line.chomp!
|
99
|
+
line += " "
|
100
|
+
|
101
|
+
window.setpos(i, 0)
|
102
|
+
window.addstr line
|
103
|
+
|
104
|
+
i += 1
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
76
108
|
end
|
77
109
|
end
|
78
110
|
|
data/lib/bsod/settings.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
1
|
require 'optparse'
|
2
|
+
require 'bsod'
|
3
3
|
require 'bsod/version'
|
4
4
|
|
5
5
|
# Global configurations of the program, along with a commandline
|
@@ -15,13 +15,13 @@ class Settings
|
|
15
15
|
# Makes possible to sleep for a while before BSODing
|
16
16
|
@settings[:sleep_time] = nil
|
17
17
|
|
18
|
-
#
|
19
|
-
@settings[:bsod_type] =
|
18
|
+
# Default BSOD
|
19
|
+
@settings[:bsod_type] = BSOD::ALL.first
|
20
20
|
|
21
21
|
# This doesn't matter because it will go fullscreen anyways.
|
22
22
|
# Just change it if looks ugly
|
23
|
-
@settings[:width]
|
24
|
-
@settings[:height]
|
23
|
+
@settings[:width] = 800
|
24
|
+
@settings[:height] = 600
|
25
25
|
@settings[:fullscreen] = true
|
26
26
|
|
27
27
|
# SDL-specific key to exit BSOD
|
@@ -35,6 +35,11 @@ class Settings
|
|
35
35
|
@settings[:font_filename] = fontname
|
36
36
|
@settings[:font_size] = 14
|
37
37
|
@settings[:font_bold] = false
|
38
|
+
|
39
|
+
# Curses mode for consoles!
|
40
|
+
# Most of the settings above won't make any sense if this
|
41
|
+
# is true
|
42
|
+
@settings[:curses] = false
|
38
43
|
end
|
39
44
|
|
40
45
|
# Sets options based on commandline arguments `args`.
|
@@ -62,18 +67,16 @@ class Settings
|
|
62
67
|
@settings[:fullscreen] = f
|
63
68
|
end
|
64
69
|
|
70
|
+
parser.on("-c", "--[no-]curses", "Runs on the terminal, without a graphical window") do |f|
|
71
|
+
@settings[:curses] = f
|
72
|
+
end
|
73
|
+
|
65
74
|
# parser.on("-r", "--random", "Select a random BSOD") do
|
66
75
|
# DO SOMETHING ABOUT IT
|
67
76
|
# end
|
68
77
|
|
69
78
|
parser.on("-l", "--list", "Show all possible BSODs") do
|
70
|
-
|
71
|
-
puts " where [type] can be:"
|
72
|
-
puts
|
73
|
-
puts "windowsnt [default]"
|
74
|
-
puts "windows2000"
|
75
|
-
puts "windowsxp"
|
76
|
-
puts "linux-sparc"
|
79
|
+
self.show_list
|
77
80
|
exit
|
78
81
|
end
|
79
82
|
|
@@ -84,7 +87,23 @@ class Settings
|
|
84
87
|
end
|
85
88
|
|
86
89
|
parser.on("--version", "Show version and license info") do
|
87
|
-
|
90
|
+
self.show_version
|
91
|
+
exit
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
opts.parse! args
|
96
|
+
|
97
|
+
return @settings
|
98
|
+
end
|
99
|
+
|
100
|
+
# Returns a specific setting previously set.
|
101
|
+
def [] name
|
102
|
+
return @settings[name]
|
103
|
+
end
|
104
|
+
|
105
|
+
def show_version
|
106
|
+
puts <<END_OF_VERSION
|
88
107
|
_ __ _ _
|
89
108
|
|_) (_ / \\ | \\
|
90
109
|
|_) __) \\_/ |_/ #{BSOD::VERSION} (http://alexdantas.net/projects/bsod)
|
@@ -106,18 +125,23 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
106
125
|
|
107
126
|
The Droid Sans font family is licensed under the Apache license.
|
108
127
|
END_OF_VERSION
|
109
|
-
|
128
|
+
end
|
129
|
+
|
130
|
+
def show_list
|
131
|
+
puts "Usage: bsod -t [type]"
|
132
|
+
puts " where [type] can be:"
|
133
|
+
puts
|
134
|
+
|
135
|
+
# Kinda ugly, right?
|
136
|
+
BSOD::ALL.each_with_index do |type, i|
|
137
|
+
if i == 0
|
138
|
+
puts "#{type} [default]"
|
139
|
+
next
|
110
140
|
end
|
111
141
|
|
142
|
+
puts "#{type}"
|
112
143
|
end
|
113
|
-
opts.parse! args
|
114
|
-
|
115
|
-
return @settings
|
116
144
|
end
|
117
145
|
|
118
|
-
# Returns a specific setting previously set.
|
119
|
-
def [] name
|
120
|
-
return @settings[name]
|
121
|
-
end
|
122
146
|
end
|
123
147
|
|
data/lib/bsod/version.rb
CHANGED
data/lib/bsod/windows2000.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
|
2
|
-
require 'bsod'
|
2
|
+
require 'bsod/windowstext'
|
3
3
|
|
4
4
|
module BSOD
|
5
5
|
|
6
6
|
# Remember Window$ 2000?
|
7
7
|
#
|
8
|
-
# This
|
9
|
-
|
10
|
-
class Windows2000
|
8
|
+
# This contains the text, see WindowsText for drawing rules.
|
9
|
+
class Windows2000 < WindowsText
|
11
10
|
|
11
|
+
# The text that will appear over the blue background.
|
12
12
|
BSODTEXT = <<END_OF_TEXT
|
13
13
|
A problem has been detected and windows has been shut down to prevent damage
|
14
14
|
to your computer.
|
@@ -41,47 +41,6 @@ Contact your system administrator or technical support group for further
|
|
41
41
|
assistance.
|
42
42
|
END_OF_TEXT
|
43
43
|
|
44
|
-
# No `def initialize` on purpose
|
45
|
-
|
46
|
-
# Draws the BSOD on a SDL's `screen`, bounded by `width` and
|
47
|
-
# `height`.
|
48
|
-
#
|
49
|
-
# It must be a `SDL::Surface` (consequently, a `SDL::Screen`
|
50
|
-
# is acceptable too.
|
51
|
-
def draw(screen, width, height)
|
52
|
-
|
53
|
-
# Should I break the program's flow here?
|
54
|
-
BSOD::init_sdl if not BSOD::sdl_inited?
|
55
|
-
|
56
|
-
# Filling screen with that sweet, sweet blue tone
|
57
|
-
blue = screen.format.map_rgb(0, 0, 255)
|
58
|
-
screen.fill_rect(0, 0, width, height, blue)
|
59
|
-
|
60
|
-
# Printing that bizarre text
|
61
|
-
font = SDL::TTF.open($settings[:font_filename],
|
62
|
-
$settings[:font_size])
|
63
|
-
|
64
|
-
font.style = SDL::TTF::STYLE_BOLD if $settings[:font_bold]
|
65
|
-
|
66
|
-
i = 0
|
67
|
-
BSODTEXT.each_line do |line|
|
68
|
-
# This is a little hack to allow printing empty lines.
|
69
|
-
# First I remove the '\n' at the end to avoid nasty things
|
70
|
-
# and then I append a space, to prevent nil strings.
|
71
|
-
line.chomp!
|
72
|
-
line += " "
|
73
|
-
|
74
|
-
font.draw_solid_utf8(screen, line,
|
75
|
-
3, (i * font.height),
|
76
|
-
255, 255, 255)
|
77
|
-
i += 1
|
78
|
-
end
|
79
|
-
|
80
|
-
font.close
|
81
|
-
|
82
|
-
# @note Maybe update only the bounded rectangle?
|
83
|
-
SDL::Screen.get.update_rect(0, 0, 0, 0)
|
84
|
-
end
|
85
44
|
end
|
86
45
|
end
|
87
46
|
|
data/lib/bsod/windowsnt.rb
CHANGED
@@ -1,10 +1,9 @@
|
|
1
|
-
|
2
|
-
require 'bsod'
|
1
|
+
require 'bsod/windowstext'
|
3
2
|
|
4
3
|
module BSOD
|
5
4
|
|
6
5
|
# Ye olde Window$ NT.
|
7
|
-
class WindowsNT
|
6
|
+
class WindowsNT < WindowsText
|
8
7
|
|
9
8
|
# The default white text that will appear over the
|
10
9
|
# blue background.
|
@@ -38,47 +37,6 @@ or the /CRASHDEBUG system start option. If this message reappears,
|
|
38
37
|
contact your system administrator or technical support group.
|
39
38
|
END_OF_TEXT
|
40
39
|
|
41
|
-
# No `def initialize` on purpose
|
42
|
-
|
43
|
-
# Draws the BSOD on a SDL's `screen`, bounded by `width` and
|
44
|
-
# `height`.
|
45
|
-
#
|
46
|
-
# It must be a `SDL::Surface` (consequently, a `SDL::Screen`
|
47
|
-
# is acceptable too.
|
48
|
-
def draw(screen, width, height)
|
49
|
-
|
50
|
-
# Should I break the program's flow here?
|
51
|
-
BSOD::init_sdl if not BSOD::sdl_inited?
|
52
|
-
|
53
|
-
# Filling screen with that sweet, sweet blue tone
|
54
|
-
blue = screen.format.map_rgb(0, 0, 255)
|
55
|
-
screen.fill_rect(0, 0, width, height, blue)
|
56
|
-
|
57
|
-
# Printing that bizarre text
|
58
|
-
font = SDL::TTF.open($settings[:font_filename],
|
59
|
-
$settings[:font_size])
|
60
|
-
|
61
|
-
font.style = SDL::TTF::STYLE_BOLD if $settings[:font_bold]
|
62
|
-
|
63
|
-
i = 0
|
64
|
-
BSODTEXT.each_line do |line|
|
65
|
-
# This is a little hack to allow printing empty lines.
|
66
|
-
# First I remove the '\n' at the end to avoid nasty things
|
67
|
-
# and then I append a space, to prevent nil strings.
|
68
|
-
line.chomp!
|
69
|
-
line += " "
|
70
|
-
|
71
|
-
font.draw_solid_utf8(screen, line,
|
72
|
-
3, (i * font.height),
|
73
|
-
255, 255, 255)
|
74
|
-
i += 1
|
75
|
-
end
|
76
|
-
|
77
|
-
font.close
|
78
|
-
|
79
|
-
# @note Maybe update only the bounded rectangle?
|
80
|
-
SDL::Screen.get.update_rect(0, 0, 0, 0)
|
81
|
-
end
|
82
40
|
end
|
83
41
|
end
|
84
42
|
|
@@ -0,0 +1,99 @@
|
|
1
|
+
require 'bsod'
|
2
|
+
|
3
|
+
module BSOD
|
4
|
+
|
5
|
+
# Abstract class that encapsulates common stuff within
|
6
|
+
# some Windows BSODs.
|
7
|
+
#
|
8
|
+
# Some BSODs are simply a blue background with white text, while
|
9
|
+
# others follow more complex rules.
|
10
|
+
# For the simple ones, we inherit from WindowText.
|
11
|
+
#
|
12
|
+
# See WindowsNT, Windows2000 and WindowsXP
|
13
|
+
class WindowsText
|
14
|
+
|
15
|
+
# This is the text to be shown on the screen.
|
16
|
+
# On most subclasses, we simply change this - drawing rules
|
17
|
+
# are common.
|
18
|
+
#
|
19
|
+
# Side-note, referring to `self.class::CONSTANT` makes
|
20
|
+
# possible to override super class constants on subclasses.
|
21
|
+
BSODTEXT = <<END_OF_TEXT
|
22
|
+
END_OF_TEXT
|
23
|
+
|
24
|
+
# Draws the BSOD on a SDL's `screen`, bounded by `width` and
|
25
|
+
# `height`.
|
26
|
+
#
|
27
|
+
# It must be a `SDL::Surface` (consequently, a `SDL::Screen`
|
28
|
+
# is acceptable too.
|
29
|
+
#
|
30
|
+
# It's a white text on a blue background.
|
31
|
+
def draw(screen, width, height)
|
32
|
+
return if not BSOD::sdl_inited?
|
33
|
+
|
34
|
+
# Filling screen with that sweet, sweet blue tone
|
35
|
+
blue = screen.format.map_rgb(0, 0, 255)
|
36
|
+
screen.fill_rect(0, 0, width, height, blue)
|
37
|
+
|
38
|
+
# Printing that bizarre text
|
39
|
+
font = SDL::TTF.open($settings[:font_filename],
|
40
|
+
$settings[:font_size])
|
41
|
+
|
42
|
+
font.style = SDL::TTF::STYLE_BOLD if $settings[:font_bold]
|
43
|
+
|
44
|
+
i = 0
|
45
|
+
self.class::BSODTEXT.each_line do |line|
|
46
|
+
# This is a little hack to allow printing empty lines.
|
47
|
+
# First I remove the '\n' at the end to avoid nasty things
|
48
|
+
# and then I append a space, to prevent nil strings.
|
49
|
+
line.chomp!
|
50
|
+
line += " "
|
51
|
+
|
52
|
+
font.draw_solid_utf8(screen, line,
|
53
|
+
3, (i * font.height),
|
54
|
+
255, 255, 255)
|
55
|
+
i += 1
|
56
|
+
end
|
57
|
+
|
58
|
+
font.close
|
59
|
+
|
60
|
+
# @note Maybe update only the bounded rectangle?
|
61
|
+
SDL::Screen.get.update_rect(0, 0, 0, 0)
|
62
|
+
end
|
63
|
+
|
64
|
+
# Draws the BSOD on a Curses' `window`, bounded by `width` and
|
65
|
+
# `height`.
|
66
|
+
#
|
67
|
+
def draw_curses(window, width, height)
|
68
|
+
return if not BSOD::curses_inited?
|
69
|
+
|
70
|
+
# Initializing colors (3 is an arbitrary number)
|
71
|
+
Curses::init_pair(3, Curses::COLOR_WHITE, Curses::COLOR_BLUE)
|
72
|
+
|
73
|
+
window.attrset(Curses::color_pair(3) | Curses::A_BOLD)
|
74
|
+
|
75
|
+
# Clears the screen with spaces
|
76
|
+
0.upto(height) { window.addstr(" " * width) }
|
77
|
+
|
78
|
+
# need to print at the bottom of the screen
|
79
|
+
lines_ammount = height
|
80
|
+
|
81
|
+
i = (lines_ammount - self.class::BSODTEXT.lines.size)
|
82
|
+
self.class::BSODTEXT.each_line do |line|
|
83
|
+
# This is a little hack to allow printing empty lines.
|
84
|
+
# First I remove the '\n' at the end to avoid nasty things
|
85
|
+
# and then I append a space, to prevent nil strings.
|
86
|
+
line.chomp!
|
87
|
+
line += " "
|
88
|
+
|
89
|
+
window.setpos(i, 0)
|
90
|
+
window.addstr line
|
91
|
+
|
92
|
+
i += 1
|
93
|
+
end
|
94
|
+
window.refresh
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
data/lib/bsod/windowsxp.rb
CHANGED
@@ -1,17 +1,14 @@
|
|
1
1
|
|
2
|
-
require 'bsod'
|
3
|
-
require 'bsod/windowsnt'
|
2
|
+
require 'bsod/windowstext'
|
4
3
|
|
5
4
|
module BSOD
|
6
5
|
|
7
6
|
# As seen on Window$ XP.
|
8
7
|
#
|
9
|
-
# This
|
10
|
-
|
11
|
-
class WindowsXP
|
8
|
+
# This contains the text, see WindowsText for drawing rules.
|
9
|
+
class WindowsXP < WindowsText
|
12
10
|
|
13
|
-
# The
|
14
|
-
# blue background.
|
11
|
+
# The text that will appear over the blue background.
|
15
12
|
BSODTEXT = <<END_OF_TEXT
|
16
13
|
A problem has been detected and windows has been shut down to prvent damage
|
17
14
|
to your computer.
|
@@ -42,47 +39,6 @@ Technical information:
|
|
42
39
|
*** SPCMDCON.SYS - Address FBFE7617 base at FBFE5000, DateStamp 3d6dd67c
|
43
40
|
END_OF_TEXT
|
44
41
|
|
45
|
-
# No `def initialize` on purpose
|
46
|
-
|
47
|
-
# Draws the BSOD on a SDL's `screen`, bounded by `width` and
|
48
|
-
# `height`.
|
49
|
-
#
|
50
|
-
# It must be a `SDL::Surface` (consequently, a `SDL::Screen`
|
51
|
-
# is acceptable too.
|
52
|
-
def draw(screen, width, height)
|
53
|
-
|
54
|
-
# Should I break the program's flow here?
|
55
|
-
BSOD::init_sdl if not BSOD::sdl_inited?
|
56
|
-
|
57
|
-
# Filling screen with that sweet, sweet blue tone
|
58
|
-
blue = screen.format.map_rgb(0, 0, 255)
|
59
|
-
screen.fill_rect(0, 0, width, height, blue)
|
60
|
-
|
61
|
-
# Printing that bizarre text
|
62
|
-
font = SDL::TTF.open($settings[:font_filename],
|
63
|
-
$settings[:font_size])
|
64
|
-
|
65
|
-
font.style = SDL::TTF::STYLE_BOLD if $settings[:font_bold]
|
66
|
-
|
67
|
-
i = 0
|
68
|
-
BSODTEXT.each_line do |line|
|
69
|
-
# This is a little hack to allow printing empty lines.
|
70
|
-
# First I remove the '\n' at the end to avoid nasty things
|
71
|
-
# and then I append a space, to prevent nil strings.
|
72
|
-
line.chomp!
|
73
|
-
line += " "
|
74
|
-
|
75
|
-
font.draw_solid_utf8(screen, line,
|
76
|
-
3, (i * font.height),
|
77
|
-
255, 255, 255)
|
78
|
-
i += 1
|
79
|
-
end
|
80
|
-
|
81
|
-
font.close
|
82
|
-
|
83
|
-
# @note Maybe update only the bounded rectangle?
|
84
|
-
SDL::Screen.get.update_rect(0, 0, 0, 0)
|
85
|
-
end
|
86
42
|
end
|
87
43
|
end
|
88
44
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bsod
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexandre Dantas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-10-
|
11
|
+
date: 2013-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -69,6 +69,7 @@ files:
|
|
69
69
|
- lib/bsod/version.rb
|
70
70
|
- lib/bsod/windows2000.rb
|
71
71
|
- lib/bsod/windowsnt.rb
|
72
|
+
- lib/bsod/windowstext.rb
|
72
73
|
- lib/bsod/windowsxp.rb
|
73
74
|
homepage: http://www.alexdantas.net/projects/bsod
|
74
75
|
licenses:
|