├── .gitignore ├── Cargo.lock ├── Cargo.toml ├── LICENSE ├── README.md ├── examples └── bsod.rs └── src └── lib.rs /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "aho-corasick" 7 | version = "0.7.20" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" 10 | dependencies = [ 11 | "memchr", 12 | ] 13 | 14 | [[package]] 15 | name = "async-broadcast" 16 | version = "0.4.1" 17 | source = "registry+https://github.com/rust-lang/crates.io-index" 18 | checksum = "6d26004fe83b2d1cd3a97609b21e39f9a31535822210fe83205d2ce48866ea61" 19 | dependencies = [ 20 | "event-listener", 21 | "futures-core", 22 | "parking_lot", 23 | ] 24 | 25 | [[package]] 26 | name = "async-channel" 27 | version = "1.7.1" 28 | source = "registry+https://github.com/rust-lang/crates.io-index" 29 | checksum = "e14485364214912d3b19cc3435dde4df66065127f05fa0d75c712f36f12c2f28" 30 | dependencies = [ 31 | "concurrent-queue 1.2.4", 32 | "event-listener", 33 | "futures-core", 34 | ] 35 | 36 | [[package]] 37 | name = "async-executor" 38 | version = "1.5.0" 39 | source = "registry+https://github.com/rust-lang/crates.io-index" 40 | checksum = "17adb73da160dfb475c183343c8cccd80721ea5a605d3eb57125f0a7b7a92d0b" 41 | dependencies = [ 42 | "async-lock", 43 | "async-task", 44 | "concurrent-queue 2.0.0", 45 | "fastrand", 46 | "futures-lite", 47 | "slab", 48 | ] 49 | 50 | [[package]] 51 | name = "async-io" 52 | version = "1.12.0" 53 | source = "registry+https://github.com/rust-lang/crates.io-index" 54 | checksum = "8c374dda1ed3e7d8f0d9ba58715f924862c63eae6849c92d3a18e7fbde9e2794" 55 | dependencies = [ 56 | "async-lock", 57 | "autocfg", 58 | "concurrent-queue 2.0.0", 59 | "futures-lite", 60 | "libc", 61 | "log", 62 | "parking", 63 | "polling", 64 | "slab", 65 | "socket2", 66 | "waker-fn", 67 | "windows-sys", 68 | ] 69 | 70 | [[package]] 71 | name = "async-lock" 72 | version = "2.6.0" 73 | source = "registry+https://github.com/rust-lang/crates.io-index" 74 | checksum = "c8101efe8695a6c17e02911402145357e718ac92d3ff88ae8419e84b1707b685" 75 | dependencies = [ 76 | "event-listener", 77 | "futures-lite", 78 | ] 79 | 80 | [[package]] 81 | name = "async-recursion" 82 | version = "1.0.0" 83 | source = "registry+https://github.com/rust-lang/crates.io-index" 84 | checksum = "2cda8f4bcc10624c4e85bc66b3f452cca98cfa5ca002dc83a16aad2367641bea" 85 | dependencies = [ 86 | "proc-macro2", 87 | "quote", 88 | "syn", 89 | ] 90 | 91 | [[package]] 92 | name = "async-task" 93 | version = "4.3.0" 94 | source = "registry+https://github.com/rust-lang/crates.io-index" 95 | checksum = "7a40729d2133846d9ed0ea60a8b9541bccddab49cd30f0715a1da672fe9a2524" 96 | 97 | [[package]] 98 | name = "async-trait" 99 | version = "0.1.58" 100 | source = "registry+https://github.com/rust-lang/crates.io-index" 101 | checksum = "1e805d94e6b5001b651426cf4cd446b1ab5f319d27bab5c644f61de0a804360c" 102 | dependencies = [ 103 | "proc-macro2", 104 | "quote", 105 | "syn", 106 | ] 107 | 108 | [[package]] 109 | name = "autocfg" 110 | version = "1.1.0" 111 | source = "registry+https://github.com/rust-lang/crates.io-index" 112 | checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" 113 | 114 | [[package]] 115 | name = "bitflags" 116 | version = "1.3.2" 117 | source = "registry+https://github.com/rust-lang/crates.io-index" 118 | checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" 119 | 120 | [[package]] 121 | name = "block-buffer" 122 | version = "0.10.3" 123 | source = "registry+https://github.com/rust-lang/crates.io-index" 124 | checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" 125 | dependencies = [ 126 | "generic-array", 127 | ] 128 | 129 | [[package]] 130 | name = "bsod" 131 | version = "0.1.1" 132 | dependencies = [ 133 | "windows", 134 | "zbus", 135 | ] 136 | 137 | [[package]] 138 | name = "byteorder" 139 | version = "1.4.3" 140 | source = "registry+https://github.com/rust-lang/crates.io-index" 141 | checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" 142 | 143 | [[package]] 144 | name = "cache-padded" 145 | version = "1.2.0" 146 | source = "registry+https://github.com/rust-lang/crates.io-index" 147 | checksum = "c1db59621ec70f09c5e9b597b220c7a2b43611f4710dc03ceb8748637775692c" 148 | 149 | [[package]] 150 | name = "cc" 151 | version = "1.0.77" 152 | source = "registry+https://github.com/rust-lang/crates.io-index" 153 | checksum = "e9f73505338f7d905b19d18738976aae232eb46b8efc15554ffc56deb5d9ebe4" 154 | 155 | [[package]] 156 | name = "cfg-if" 157 | version = "1.0.0" 158 | source = "registry+https://github.com/rust-lang/crates.io-index" 159 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 160 | 161 | [[package]] 162 | name = "concurrent-queue" 163 | version = "1.2.4" 164 | source = "registry+https://github.com/rust-lang/crates.io-index" 165 | checksum = "af4780a44ab5696ea9e28294517f1fffb421a83a25af521333c838635509db9c" 166 | dependencies = [ 167 | "cache-padded", 168 | ] 169 | 170 | [[package]] 171 | name = "concurrent-queue" 172 | version = "2.0.0" 173 | source = "registry+https://github.com/rust-lang/crates.io-index" 174 | checksum = "bd7bef69dc86e3c610e4e7aed41035e2a7ed12e72dd7530f61327a6579a4390b" 175 | dependencies = [ 176 | "crossbeam-utils", 177 | ] 178 | 179 | [[package]] 180 | name = "cpufeatures" 181 | version = "0.2.5" 182 | source = "registry+https://github.com/rust-lang/crates.io-index" 183 | checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" 184 | dependencies = [ 185 | "libc", 186 | ] 187 | 188 | [[package]] 189 | name = "crossbeam-utils" 190 | version = "0.8.14" 191 | source = "registry+https://github.com/rust-lang/crates.io-index" 192 | checksum = "4fb766fa798726286dbbb842f174001dab8abc7b627a1dd86e0b7222a95d929f" 193 | dependencies = [ 194 | "cfg-if", 195 | ] 196 | 197 | [[package]] 198 | name = "crypto-common" 199 | version = "0.1.6" 200 | source = "registry+https://github.com/rust-lang/crates.io-index" 201 | checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" 202 | dependencies = [ 203 | "generic-array", 204 | "typenum", 205 | ] 206 | 207 | [[package]] 208 | name = "derivative" 209 | version = "2.2.0" 210 | source = "registry+https://github.com/rust-lang/crates.io-index" 211 | checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" 212 | dependencies = [ 213 | "proc-macro2", 214 | "quote", 215 | "syn", 216 | ] 217 | 218 | [[package]] 219 | name = "digest" 220 | version = "0.10.6" 221 | source = "registry+https://github.com/rust-lang/crates.io-index" 222 | checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" 223 | dependencies = [ 224 | "block-buffer", 225 | "crypto-common", 226 | ] 227 | 228 | [[package]] 229 | name = "dirs" 230 | version = "4.0.0" 231 | source = "registry+https://github.com/rust-lang/crates.io-index" 232 | checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" 233 | dependencies = [ 234 | "dirs-sys", 235 | ] 236 | 237 | [[package]] 238 | name = "dirs-sys" 239 | version = "0.3.7" 240 | source = "registry+https://github.com/rust-lang/crates.io-index" 241 | checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" 242 | dependencies = [ 243 | "libc", 244 | "redox_users", 245 | "winapi", 246 | ] 247 | 248 | [[package]] 249 | name = "enumflags2" 250 | version = "0.7.5" 251 | source = "registry+https://github.com/rust-lang/crates.io-index" 252 | checksum = "e75d4cd21b95383444831539909fbb14b9dc3fdceb2a6f5d36577329a1f55ccb" 253 | dependencies = [ 254 | "enumflags2_derive", 255 | "serde", 256 | ] 257 | 258 | [[package]] 259 | name = "enumflags2_derive" 260 | version = "0.7.4" 261 | source = "registry+https://github.com/rust-lang/crates.io-index" 262 | checksum = "f58dc3c5e468259f19f2d46304a6b28f1c3d034442e14b322d2b850e36f6d5ae" 263 | dependencies = [ 264 | "proc-macro2", 265 | "quote", 266 | "syn", 267 | ] 268 | 269 | [[package]] 270 | name = "event-listener" 271 | version = "2.5.3" 272 | source = "registry+https://github.com/rust-lang/crates.io-index" 273 | checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" 274 | 275 | [[package]] 276 | name = "fastrand" 277 | version = "1.8.0" 278 | source = "registry+https://github.com/rust-lang/crates.io-index" 279 | checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" 280 | dependencies = [ 281 | "instant", 282 | ] 283 | 284 | [[package]] 285 | name = "futures-core" 286 | version = "0.3.25" 287 | source = "registry+https://github.com/rust-lang/crates.io-index" 288 | checksum = "04909a7a7e4633ae6c4a9ab280aeb86da1236243a77b694a49eacd659a4bd3ac" 289 | 290 | [[package]] 291 | name = "futures-io" 292 | version = "0.3.25" 293 | source = "registry+https://github.com/rust-lang/crates.io-index" 294 | checksum = "00f5fb52a06bdcadeb54e8d3671f8888a39697dcb0b81b23b55174030427f4eb" 295 | 296 | [[package]] 297 | name = "futures-lite" 298 | version = "1.12.0" 299 | source = "registry+https://github.com/rust-lang/crates.io-index" 300 | checksum = "7694489acd39452c77daa48516b894c153f192c3578d5a839b62c58099fcbf48" 301 | dependencies = [ 302 | "fastrand", 303 | "futures-core", 304 | "futures-io", 305 | "memchr", 306 | "parking", 307 | "pin-project-lite", 308 | "waker-fn", 309 | ] 310 | 311 | [[package]] 312 | name = "futures-sink" 313 | version = "0.3.25" 314 | source = "registry+https://github.com/rust-lang/crates.io-index" 315 | checksum = "39c15cf1a4aa79df40f1bb462fb39676d0ad9e366c2a33b590d7c66f4f81fcf9" 316 | 317 | [[package]] 318 | name = "futures-task" 319 | version = "0.3.25" 320 | source = "registry+https://github.com/rust-lang/crates.io-index" 321 | checksum = "2ffb393ac5d9a6eaa9d3fdf37ae2776656b706e200c8e16b1bdb227f5198e6ea" 322 | 323 | [[package]] 324 | name = "futures-util" 325 | version = "0.3.25" 326 | source = "registry+https://github.com/rust-lang/crates.io-index" 327 | checksum = "197676987abd2f9cadff84926f410af1c183608d36641465df73ae8211dc65d6" 328 | dependencies = [ 329 | "futures-core", 330 | "futures-sink", 331 | "futures-task", 332 | "pin-project-lite", 333 | "pin-utils", 334 | "slab", 335 | ] 336 | 337 | [[package]] 338 | name = "generic-array" 339 | version = "0.14.6" 340 | source = "registry+https://github.com/rust-lang/crates.io-index" 341 | checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" 342 | dependencies = [ 343 | "typenum", 344 | "version_check", 345 | ] 346 | 347 | [[package]] 348 | name = "getrandom" 349 | version = "0.2.8" 350 | source = "registry+https://github.com/rust-lang/crates.io-index" 351 | checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" 352 | dependencies = [ 353 | "cfg-if", 354 | "libc", 355 | "wasi", 356 | ] 357 | 358 | [[package]] 359 | name = "hex" 360 | version = "0.4.3" 361 | source = "registry+https://github.com/rust-lang/crates.io-index" 362 | checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" 363 | 364 | [[package]] 365 | name = "instant" 366 | version = "0.1.12" 367 | source = "registry+https://github.com/rust-lang/crates.io-index" 368 | checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" 369 | dependencies = [ 370 | "cfg-if", 371 | ] 372 | 373 | [[package]] 374 | name = "libc" 375 | version = "0.2.137" 376 | source = "registry+https://github.com/rust-lang/crates.io-index" 377 | checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89" 378 | 379 | [[package]] 380 | name = "lock_api" 381 | version = "0.4.9" 382 | source = "registry+https://github.com/rust-lang/crates.io-index" 383 | checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" 384 | dependencies = [ 385 | "autocfg", 386 | "scopeguard", 387 | ] 388 | 389 | [[package]] 390 | name = "log" 391 | version = "0.4.17" 392 | source = "registry+https://github.com/rust-lang/crates.io-index" 393 | checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" 394 | dependencies = [ 395 | "cfg-if", 396 | ] 397 | 398 | [[package]] 399 | name = "memchr" 400 | version = "2.5.0" 401 | source = "registry+https://github.com/rust-lang/crates.io-index" 402 | checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" 403 | 404 | [[package]] 405 | name = "memoffset" 406 | version = "0.6.5" 407 | source = "registry+https://github.com/rust-lang/crates.io-index" 408 | checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" 409 | dependencies = [ 410 | "autocfg", 411 | ] 412 | 413 | [[package]] 414 | name = "nix" 415 | version = "0.25.0" 416 | source = "registry+https://github.com/rust-lang/crates.io-index" 417 | checksum = "e322c04a9e3440c327fca7b6c8a63e6890a32fa2ad689db972425f07e0d22abb" 418 | dependencies = [ 419 | "autocfg", 420 | "bitflags", 421 | "cfg-if", 422 | "libc", 423 | "memoffset", 424 | "pin-utils", 425 | ] 426 | 427 | [[package]] 428 | name = "once_cell" 429 | version = "1.16.0" 430 | source = "registry+https://github.com/rust-lang/crates.io-index" 431 | checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" 432 | 433 | [[package]] 434 | name = "ordered-stream" 435 | version = "0.1.1" 436 | source = "registry+https://github.com/rust-lang/crates.io-index" 437 | checksum = "034ce384018b245e8d8424bbe90577fbd91a533be74107e465e3474eb2285eef" 438 | dependencies = [ 439 | "futures-core", 440 | "pin-project-lite", 441 | ] 442 | 443 | [[package]] 444 | name = "parking" 445 | version = "2.0.0" 446 | source = "registry+https://github.com/rust-lang/crates.io-index" 447 | checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72" 448 | 449 | [[package]] 450 | name = "parking_lot" 451 | version = "0.12.1" 452 | source = "registry+https://github.com/rust-lang/crates.io-index" 453 | checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" 454 | dependencies = [ 455 | "lock_api", 456 | "parking_lot_core", 457 | ] 458 | 459 | [[package]] 460 | name = "parking_lot_core" 461 | version = "0.9.4" 462 | source = "registry+https://github.com/rust-lang/crates.io-index" 463 | checksum = "4dc9e0dc2adc1c69d09143aff38d3d30c5c3f0df0dad82e6d25547af174ebec0" 464 | dependencies = [ 465 | "cfg-if", 466 | "libc", 467 | "redox_syscall", 468 | "smallvec", 469 | "windows-sys", 470 | ] 471 | 472 | [[package]] 473 | name = "pin-project-lite" 474 | version = "0.2.9" 475 | source = "registry+https://github.com/rust-lang/crates.io-index" 476 | checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" 477 | 478 | [[package]] 479 | name = "pin-utils" 480 | version = "0.1.0" 481 | source = "registry+https://github.com/rust-lang/crates.io-index" 482 | checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" 483 | 484 | [[package]] 485 | name = "polling" 486 | version = "2.5.0" 487 | source = "registry+https://github.com/rust-lang/crates.io-index" 488 | checksum = "9f7d73f1eaed1ca1fb37b54dcc9b38e3b17d6c7b8ecb7abfffcac8d0351f17d4" 489 | dependencies = [ 490 | "autocfg", 491 | "cfg-if", 492 | "libc", 493 | "log", 494 | "wepoll-ffi", 495 | "windows-sys", 496 | ] 497 | 498 | [[package]] 499 | name = "ppv-lite86" 500 | version = "0.2.17" 501 | source = "registry+https://github.com/rust-lang/crates.io-index" 502 | checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" 503 | 504 | [[package]] 505 | name = "proc-macro-crate" 506 | version = "1.2.1" 507 | source = "registry+https://github.com/rust-lang/crates.io-index" 508 | checksum = "eda0fc3b0fb7c975631757e14d9049da17374063edb6ebbcbc54d880d4fe94e9" 509 | dependencies = [ 510 | "once_cell", 511 | "thiserror", 512 | "toml", 513 | ] 514 | 515 | [[package]] 516 | name = "proc-macro2" 517 | version = "1.0.47" 518 | source = "registry+https://github.com/rust-lang/crates.io-index" 519 | checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725" 520 | dependencies = [ 521 | "unicode-ident", 522 | ] 523 | 524 | [[package]] 525 | name = "quote" 526 | version = "1.0.21" 527 | source = "registry+https://github.com/rust-lang/crates.io-index" 528 | checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" 529 | dependencies = [ 530 | "proc-macro2", 531 | ] 532 | 533 | [[package]] 534 | name = "rand" 535 | version = "0.8.5" 536 | source = "registry+https://github.com/rust-lang/crates.io-index" 537 | checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" 538 | dependencies = [ 539 | "libc", 540 | "rand_chacha", 541 | "rand_core", 542 | ] 543 | 544 | [[package]] 545 | name = "rand_chacha" 546 | version = "0.3.1" 547 | source = "registry+https://github.com/rust-lang/crates.io-index" 548 | checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" 549 | dependencies = [ 550 | "ppv-lite86", 551 | "rand_core", 552 | ] 553 | 554 | [[package]] 555 | name = "rand_core" 556 | version = "0.6.4" 557 | source = "registry+https://github.com/rust-lang/crates.io-index" 558 | checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" 559 | dependencies = [ 560 | "getrandom", 561 | ] 562 | 563 | [[package]] 564 | name = "redox_syscall" 565 | version = "0.2.16" 566 | source = "registry+https://github.com/rust-lang/crates.io-index" 567 | checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" 568 | dependencies = [ 569 | "bitflags", 570 | ] 571 | 572 | [[package]] 573 | name = "redox_users" 574 | version = "0.4.3" 575 | source = "registry+https://github.com/rust-lang/crates.io-index" 576 | checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" 577 | dependencies = [ 578 | "getrandom", 579 | "redox_syscall", 580 | "thiserror", 581 | ] 582 | 583 | [[package]] 584 | name = "regex" 585 | version = "1.7.0" 586 | source = "registry+https://github.com/rust-lang/crates.io-index" 587 | checksum = "e076559ef8e241f2ae3479e36f97bd5741c0330689e217ad51ce2c76808b868a" 588 | dependencies = [ 589 | "aho-corasick", 590 | "memchr", 591 | "regex-syntax", 592 | ] 593 | 594 | [[package]] 595 | name = "regex-syntax" 596 | version = "0.6.28" 597 | source = "registry+https://github.com/rust-lang/crates.io-index" 598 | checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" 599 | 600 | [[package]] 601 | name = "remove_dir_all" 602 | version = "0.5.3" 603 | source = "registry+https://github.com/rust-lang/crates.io-index" 604 | checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" 605 | dependencies = [ 606 | "winapi", 607 | ] 608 | 609 | [[package]] 610 | name = "scopeguard" 611 | version = "1.1.0" 612 | source = "registry+https://github.com/rust-lang/crates.io-index" 613 | checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" 614 | 615 | [[package]] 616 | name = "serde" 617 | version = "1.0.148" 618 | source = "registry+https://github.com/rust-lang/crates.io-index" 619 | checksum = "e53f64bb4ba0191d6d0676e1b141ca55047d83b74f5607e6d8eb88126c52c2dc" 620 | dependencies = [ 621 | "serde_derive", 622 | ] 623 | 624 | [[package]] 625 | name = "serde_derive" 626 | version = "1.0.148" 627 | source = "registry+https://github.com/rust-lang/crates.io-index" 628 | checksum = "a55492425aa53521babf6137309e7d34c20bbfbbfcfe2c7f3a047fd1f6b92c0c" 629 | dependencies = [ 630 | "proc-macro2", 631 | "quote", 632 | "syn", 633 | ] 634 | 635 | [[package]] 636 | name = "serde_repr" 637 | version = "0.1.9" 638 | source = "registry+https://github.com/rust-lang/crates.io-index" 639 | checksum = "1fe39d9fbb0ebf5eb2c7cb7e2a47e4f462fad1379f1166b8ae49ad9eae89a7ca" 640 | dependencies = [ 641 | "proc-macro2", 642 | "quote", 643 | "syn", 644 | ] 645 | 646 | [[package]] 647 | name = "sha1" 648 | version = "0.10.5" 649 | source = "registry+https://github.com/rust-lang/crates.io-index" 650 | checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" 651 | dependencies = [ 652 | "cfg-if", 653 | "cpufeatures", 654 | "digest", 655 | ] 656 | 657 | [[package]] 658 | name = "slab" 659 | version = "0.4.7" 660 | source = "registry+https://github.com/rust-lang/crates.io-index" 661 | checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" 662 | dependencies = [ 663 | "autocfg", 664 | ] 665 | 666 | [[package]] 667 | name = "smallvec" 668 | version = "1.10.0" 669 | source = "registry+https://github.com/rust-lang/crates.io-index" 670 | checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" 671 | 672 | [[package]] 673 | name = "socket2" 674 | version = "0.4.7" 675 | source = "registry+https://github.com/rust-lang/crates.io-index" 676 | checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd" 677 | dependencies = [ 678 | "libc", 679 | "winapi", 680 | ] 681 | 682 | [[package]] 683 | name = "static_assertions" 684 | version = "1.1.0" 685 | source = "registry+https://github.com/rust-lang/crates.io-index" 686 | checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" 687 | 688 | [[package]] 689 | name = "syn" 690 | version = "1.0.104" 691 | source = "registry+https://github.com/rust-lang/crates.io-index" 692 | checksum = "4ae548ec36cf198c0ef7710d3c230987c2d6d7bd98ad6edc0274462724c585ce" 693 | dependencies = [ 694 | "proc-macro2", 695 | "quote", 696 | "unicode-ident", 697 | ] 698 | 699 | [[package]] 700 | name = "tempfile" 701 | version = "3.3.0" 702 | source = "registry+https://github.com/rust-lang/crates.io-index" 703 | checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" 704 | dependencies = [ 705 | "cfg-if", 706 | "fastrand", 707 | "libc", 708 | "redox_syscall", 709 | "remove_dir_all", 710 | "winapi", 711 | ] 712 | 713 | [[package]] 714 | name = "thiserror" 715 | version = "1.0.37" 716 | source = "registry+https://github.com/rust-lang/crates.io-index" 717 | checksum = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e" 718 | dependencies = [ 719 | "thiserror-impl", 720 | ] 721 | 722 | [[package]] 723 | name = "thiserror-impl" 724 | version = "1.0.37" 725 | source = "registry+https://github.com/rust-lang/crates.io-index" 726 | checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb" 727 | dependencies = [ 728 | "proc-macro2", 729 | "quote", 730 | "syn", 731 | ] 732 | 733 | [[package]] 734 | name = "toml" 735 | version = "0.5.9" 736 | source = "registry+https://github.com/rust-lang/crates.io-index" 737 | checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7" 738 | dependencies = [ 739 | "serde", 740 | ] 741 | 742 | [[package]] 743 | name = "tracing" 744 | version = "0.1.37" 745 | source = "registry+https://github.com/rust-lang/crates.io-index" 746 | checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" 747 | dependencies = [ 748 | "cfg-if", 749 | "pin-project-lite", 750 | "tracing-attributes", 751 | "tracing-core", 752 | ] 753 | 754 | [[package]] 755 | name = "tracing-attributes" 756 | version = "0.1.23" 757 | source = "registry+https://github.com/rust-lang/crates.io-index" 758 | checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a" 759 | dependencies = [ 760 | "proc-macro2", 761 | "quote", 762 | "syn", 763 | ] 764 | 765 | [[package]] 766 | name = "tracing-core" 767 | version = "0.1.30" 768 | source = "registry+https://github.com/rust-lang/crates.io-index" 769 | checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" 770 | dependencies = [ 771 | "once_cell", 772 | ] 773 | 774 | [[package]] 775 | name = "typenum" 776 | version = "1.15.0" 777 | source = "registry+https://github.com/rust-lang/crates.io-index" 778 | checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" 779 | 780 | [[package]] 781 | name = "uds_windows" 782 | version = "1.0.2" 783 | source = "registry+https://github.com/rust-lang/crates.io-index" 784 | checksum = "ce65604324d3cce9b966701489fbd0cf318cb1f7bd9dd07ac9a4ee6fb791930d" 785 | dependencies = [ 786 | "tempfile", 787 | "winapi", 788 | ] 789 | 790 | [[package]] 791 | name = "unicode-ident" 792 | version = "1.0.5" 793 | source = "registry+https://github.com/rust-lang/crates.io-index" 794 | checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3" 795 | 796 | [[package]] 797 | name = "version_check" 798 | version = "0.9.4" 799 | source = "registry+https://github.com/rust-lang/crates.io-index" 800 | checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" 801 | 802 | [[package]] 803 | name = "waker-fn" 804 | version = "1.1.0" 805 | source = "registry+https://github.com/rust-lang/crates.io-index" 806 | checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" 807 | 808 | [[package]] 809 | name = "wasi" 810 | version = "0.11.0+wasi-snapshot-preview1" 811 | source = "registry+https://github.com/rust-lang/crates.io-index" 812 | checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" 813 | 814 | [[package]] 815 | name = "wepoll-ffi" 816 | version = "0.1.2" 817 | source = "registry+https://github.com/rust-lang/crates.io-index" 818 | checksum = "d743fdedc5c64377b5fc2bc036b01c7fd642205a0d96356034ae3404d49eb7fb" 819 | dependencies = [ 820 | "cc", 821 | ] 822 | 823 | [[package]] 824 | name = "winapi" 825 | version = "0.3.9" 826 | source = "registry+https://github.com/rust-lang/crates.io-index" 827 | checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" 828 | dependencies = [ 829 | "winapi-i686-pc-windows-gnu", 830 | "winapi-x86_64-pc-windows-gnu", 831 | ] 832 | 833 | [[package]] 834 | name = "winapi-i686-pc-windows-gnu" 835 | version = "0.4.0" 836 | source = "registry+https://github.com/rust-lang/crates.io-index" 837 | checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 838 | 839 | [[package]] 840 | name = "winapi-x86_64-pc-windows-gnu" 841 | version = "0.4.0" 842 | source = "registry+https://github.com/rust-lang/crates.io-index" 843 | checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 844 | 845 | [[package]] 846 | name = "windows" 847 | version = "0.52.0" 848 | source = "registry+https://github.com/rust-lang/crates.io-index" 849 | checksum = "e48a53791691ab099e5e2ad123536d0fff50652600abaf43bbf952894110d0be" 850 | dependencies = [ 851 | "windows-core", 852 | "windows-targets", 853 | ] 854 | 855 | [[package]] 856 | name = "windows-core" 857 | version = "0.52.0" 858 | source = "registry+https://github.com/rust-lang/crates.io-index" 859 | checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" 860 | dependencies = [ 861 | "windows-targets", 862 | ] 863 | 864 | [[package]] 865 | name = "windows-sys" 866 | version = "0.42.0" 867 | source = "registry+https://github.com/rust-lang/crates.io-index" 868 | checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" 869 | dependencies = [ 870 | "windows_aarch64_gnullvm 0.42.0", 871 | "windows_aarch64_msvc 0.42.0", 872 | "windows_i686_gnu 0.42.0", 873 | "windows_i686_msvc 0.42.0", 874 | "windows_x86_64_gnu 0.42.0", 875 | "windows_x86_64_gnullvm 0.42.0", 876 | "windows_x86_64_msvc 0.42.0", 877 | ] 878 | 879 | [[package]] 880 | name = "windows-targets" 881 | version = "0.52.0" 882 | source = "registry+https://github.com/rust-lang/crates.io-index" 883 | checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" 884 | dependencies = [ 885 | "windows_aarch64_gnullvm 0.52.0", 886 | "windows_aarch64_msvc 0.52.0", 887 | "windows_i686_gnu 0.52.0", 888 | "windows_i686_msvc 0.52.0", 889 | "windows_x86_64_gnu 0.52.0", 890 | "windows_x86_64_gnullvm 0.52.0", 891 | "windows_x86_64_msvc 0.52.0", 892 | ] 893 | 894 | [[package]] 895 | name = "windows_aarch64_gnullvm" 896 | version = "0.42.0" 897 | source = "registry+https://github.com/rust-lang/crates.io-index" 898 | checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e" 899 | 900 | [[package]] 901 | name = "windows_aarch64_gnullvm" 902 | version = "0.52.0" 903 | source = "registry+https://github.com/rust-lang/crates.io-index" 904 | checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" 905 | 906 | [[package]] 907 | name = "windows_aarch64_msvc" 908 | version = "0.42.0" 909 | source = "registry+https://github.com/rust-lang/crates.io-index" 910 | checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4" 911 | 912 | [[package]] 913 | name = "windows_aarch64_msvc" 914 | version = "0.52.0" 915 | source = "registry+https://github.com/rust-lang/crates.io-index" 916 | checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" 917 | 918 | [[package]] 919 | name = "windows_i686_gnu" 920 | version = "0.42.0" 921 | source = "registry+https://github.com/rust-lang/crates.io-index" 922 | checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7" 923 | 924 | [[package]] 925 | name = "windows_i686_gnu" 926 | version = "0.52.0" 927 | source = "registry+https://github.com/rust-lang/crates.io-index" 928 | checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" 929 | 930 | [[package]] 931 | name = "windows_i686_msvc" 932 | version = "0.42.0" 933 | source = "registry+https://github.com/rust-lang/crates.io-index" 934 | checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246" 935 | 936 | [[package]] 937 | name = "windows_i686_msvc" 938 | version = "0.52.0" 939 | source = "registry+https://github.com/rust-lang/crates.io-index" 940 | checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" 941 | 942 | [[package]] 943 | name = "windows_x86_64_gnu" 944 | version = "0.42.0" 945 | source = "registry+https://github.com/rust-lang/crates.io-index" 946 | checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed" 947 | 948 | [[package]] 949 | name = "windows_x86_64_gnu" 950 | version = "0.52.0" 951 | source = "registry+https://github.com/rust-lang/crates.io-index" 952 | checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" 953 | 954 | [[package]] 955 | name = "windows_x86_64_gnullvm" 956 | version = "0.42.0" 957 | source = "registry+https://github.com/rust-lang/crates.io-index" 958 | checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028" 959 | 960 | [[package]] 961 | name = "windows_x86_64_gnullvm" 962 | version = "0.52.0" 963 | source = "registry+https://github.com/rust-lang/crates.io-index" 964 | checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" 965 | 966 | [[package]] 967 | name = "windows_x86_64_msvc" 968 | version = "0.42.0" 969 | source = "registry+https://github.com/rust-lang/crates.io-index" 970 | checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5" 971 | 972 | [[package]] 973 | name = "windows_x86_64_msvc" 974 | version = "0.52.0" 975 | source = "registry+https://github.com/rust-lang/crates.io-index" 976 | checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" 977 | 978 | [[package]] 979 | name = "zbus" 980 | version = "3.5.0" 981 | source = "registry+https://github.com/rust-lang/crates.io-index" 982 | checksum = "a25ae891bd547674b368906552115143031c16c23a0f2f4b2f5f5436ab2e6a9f" 983 | dependencies = [ 984 | "async-broadcast", 985 | "async-channel", 986 | "async-executor", 987 | "async-io", 988 | "async-lock", 989 | "async-recursion", 990 | "async-task", 991 | "async-trait", 992 | "byteorder", 993 | "derivative", 994 | "dirs", 995 | "enumflags2", 996 | "event-listener", 997 | "futures-core", 998 | "futures-sink", 999 | "futures-util", 1000 | "hex", 1001 | "nix", 1002 | "once_cell", 1003 | "ordered-stream", 1004 | "rand", 1005 | "serde", 1006 | "serde_repr", 1007 | "sha1", 1008 | "static_assertions", 1009 | "tracing", 1010 | "uds_windows", 1011 | "winapi", 1012 | "zbus_macros", 1013 | "zbus_names", 1014 | "zvariant", 1015 | ] 1016 | 1017 | [[package]] 1018 | name = "zbus_macros" 1019 | version = "3.5.0" 1020 | source = "registry+https://github.com/rust-lang/crates.io-index" 1021 | checksum = "8aa37701ce7b3a43632d2b0ad9d4aef602b46be6bdd7fba3b7c5007f9f6eb2c2" 1022 | dependencies = [ 1023 | "proc-macro-crate", 1024 | "proc-macro2", 1025 | "quote", 1026 | "regex", 1027 | "syn", 1028 | ] 1029 | 1030 | [[package]] 1031 | name = "zbus_names" 1032 | version = "2.3.0" 1033 | source = "registry+https://github.com/rust-lang/crates.io-index" 1034 | checksum = "d69bb79b44e1901ed8b217e485d0f01991aec574479b68cb03415f142bc7ae67" 1035 | dependencies = [ 1036 | "serde", 1037 | "static_assertions", 1038 | "zvariant", 1039 | ] 1040 | 1041 | [[package]] 1042 | name = "zvariant" 1043 | version = "3.8.0" 1044 | source = "registry+https://github.com/rust-lang/crates.io-index" 1045 | checksum = "5c817f416f05fcbc833902f1e6064b72b1778573978cfeac54731451ccc9e207" 1046 | dependencies = [ 1047 | "byteorder", 1048 | "enumflags2", 1049 | "libc", 1050 | "serde", 1051 | "static_assertions", 1052 | "zvariant_derive", 1053 | ] 1054 | 1055 | [[package]] 1056 | name = "zvariant_derive" 1057 | version = "3.8.0" 1058 | source = "registry+https://github.com/rust-lang/crates.io-index" 1059 | checksum = "fdd24fffd02794a76eb10109de463444064c88f5adb9e9d1a78488adc332bfef" 1060 | dependencies = [ 1061 | "proc-macro-crate", 1062 | "proc-macro2", 1063 | "quote", 1064 | "syn", 1065 | ] 1066 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "bsod" 3 | version = "0.1.1" 4 | edition = "2021" 5 | authors = ["anna "] 6 | repository = "https://github.com/pozm/bsod-rs/" 7 | description = "The safest library on the block. Calling the bsod function will cause a blue screen of death." 8 | license-file = "LICENSE" 9 | 10 | [target.release] 11 | lto = true 12 | opt-level = "z" 13 | panic = "abort" 14 | 15 | [dependencies] 16 | 17 | [target.'cfg(windows)'.dependencies] 18 | windows = { version = "0.52.0", features = [ 19 | "Win32_Foundation", 20 | "Win32_System_LibraryLoader", 21 | ] } 22 | 23 | [target.'cfg(target_os = "linux")'.dependencies] 24 | zbus = "3.5.0" 25 | windows = { version = "0.52.0", features = [ 26 | "Win32_Foundation", 27 | "Win32_System_LibraryLoader", 28 | ] } 29 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # bsod 2 | The safest library on the block. Calling the bsod function will cause a blue screen of death. 3 | ## links 4 | - [`crates.io`](https://crates.io/crates/bsod) 5 | - [`docs.rs`](https://docs.rs/bsod/latest/bsod/) 6 | -------------------------------------------------------------------------------- /examples/bsod.rs: -------------------------------------------------------------------------------- 1 | use bsod::bsod; 2 | 3 | fn main() { 4 | bsod(); 5 | } 6 | -------------------------------------------------------------------------------- /src/lib.rs: -------------------------------------------------------------------------------- 1 | /// # bsod 2 | /// The safest library on the block. Calling the bsod function will cause a blue screen of death. 3 | /// ## links 4 | /// - [`crates.io`](https://crates.io/crates/bsod) 5 | /// - [`docs.rs`](https://docs.rs/bsod/latest/bsod/) 6 | use std::{ 7 | ffi::{c_ulong, c_ulonglong, CString}, 8 | mem::transmute, 9 | }; 10 | 11 | #[cfg(target_os = "linux")] 12 | use std::process::Command; 13 | #[cfg(target_os = "linux")] 14 | use zbus::export::serde::Serialize; 15 | #[cfg(target_os = "linux")] 16 | use zbus::zvariant::DynamicType; 17 | 18 | #[cfg(windows)] 19 | use windows::{ 20 | core::PCSTR, 21 | Win32::{ 22 | Foundation::{NTSTATUS, STATUS_FLOAT_MULTIPLE_FAULTS}, 23 | System::LibraryLoader::{GetProcAddress, LoadLibraryA}, 24 | }, 25 | }; 26 | 27 | #[cfg(windows)] 28 | type RtlAdjustPrivilige = unsafe extern "C" fn( 29 | privilge: c_ulong, 30 | enable: bool, 31 | currentThread: bool, 32 | enabled: *mut bool, 33 | ) -> NTSTATUS; 34 | #[cfg(windows)] 35 | type NtRaiseHardError = unsafe extern "C" fn( 36 | errorStatus: NTSTATUS, 37 | numberOfParams: c_ulong, 38 | unicodeStrParamMask: c_ulong, 39 | params: *const c_ulonglong, 40 | responseOption: c_ulong, 41 | response: *mut c_ulong, 42 | ) -> i64; 43 | 44 | #[cfg(windows)] 45 | macro_rules! make_pcstr { 46 | ($str:expr) => {{ 47 | // considering the program will exit almost immediately i don't care about mem leaks. 48 | let cstr = CString::new($str).unwrap(); 49 | 50 | let pc = PCSTR::from_raw(cstr.as_ptr() as *const u8); 51 | 52 | std::mem::forget(cstr); 53 | 54 | pc 55 | }}; 56 | } 57 | 58 | /// this function will cause a blue screen of death 59 | #[cfg(windows)] 60 | pub fn bsod() { 61 | unsafe { 62 | let hndl = LoadLibraryA(make_pcstr!("ntdll.dll")).expect("ntdll to exist"); 63 | let adjust_priv: RtlAdjustPrivilige = transmute( 64 | GetProcAddress(hndl, make_pcstr!("RtlAdjustPrivilege")) 65 | .expect("RtlAdjustPrivilige to exist"), 66 | ); 67 | let raise_hard_err: NtRaiseHardError = transmute( 68 | GetProcAddress(hndl, make_pcstr!("NtRaiseHardError")) 69 | .expect("NtRaiseHardError to exist"), 70 | ); 71 | 72 | let mut lol: c_ulong = 0; 73 | let mut enabled = false; 74 | adjust_priv(19, true, false, &mut enabled); 75 | raise_hard_err( 76 | STATUS_FLOAT_MULTIPLE_FAULTS, 77 | 0, 78 | 0, 79 | std::mem::zeroed(), 80 | 6, 81 | &mut lol, 82 | ); 83 | } 84 | } 85 | 86 | #[cfg(all(not(windows), not(target_os = "linux")))] 87 | pub fn bsod() {} 88 | 89 | /// this will cause a shutdown on linux 90 | #[cfg(target_os = "linux")] 91 | pub fn bsod() { 92 | dbus( 93 | "org.kde.ksmserver", 94 | "/KSMServer", 95 | "org.kde.KSMServerInterface", 96 | "logout", 97 | &(-1, 2, 2), 98 | ); 99 | dbus( 100 | "org.gnome.SessionManager", 101 | "org/gnome/SessionManager", 102 | "org.gnome.SessionManager", 103 | "Shutdown", 104 | &(), 105 | ); 106 | dbus( 107 | "org.xfce.SessionManager", 108 | "/org/xfce/SessionManager", 109 | "org.xfce.SessionManager", 110 | "Shutdown", 111 | &(true), 112 | ); 113 | dbus( 114 | "org.freedesktop.login1", 115 | "/org/freedesktop/login1", 116 | "org.freedesktop.login1.Manager", 117 | "PowerOff", 118 | &(true), 119 | ); 120 | dbus( 121 | "org.freedesktop.PowerManagement", 122 | "/org/freedesktop/PowerManagement", 123 | "org.freedesktop.PowerManagement", 124 | "Shutdown", 125 | &(), 126 | ); 127 | dbus( 128 | "org.freedesktop.SessionManagement", 129 | "/org/freedesktop/Sessionmanagement", 130 | "org.freedesktop.SessionManagement", 131 | "Shutdown", 132 | &(), 133 | ); 134 | dbus( 135 | "org.freedesktop.ConsoleKit", 136 | "/org/freedesktop/ConsoleKit/Manager", 137 | "org.freedesktop.ConsoleKit.Manager", 138 | "Stop", 139 | &(), 140 | ); 141 | dbus( 142 | "org.freedesktop.Hal", 143 | "/org/freedesktop/Hal/devices/computer", 144 | "org.freedesktop.Hal.Device.SystemPowermanagement", 145 | "Shutdown", 146 | &(), 147 | ); 148 | dbus( 149 | "org.freedesktop.systemd1", 150 | "/org/freedesktop/systemd1", 151 | "org.freedesktop.systemd1.Manager", 152 | "PowerOff", 153 | &(), 154 | ); 155 | // If dbus doesn't work, this is the last resort 156 | Command::new("shutdown").args(&["-h", "now"]).output(); 157 | } 158 | 159 | #[cfg(target_os = "linux")] 160 | fn dbus( 161 | destination: &str, 162 | path: &str, 163 | interface: &str, 164 | method: &str, 165 | body: &T, 166 | ) { 167 | let mut owner: bool = false; 168 | if let Ok(connection) = zbus::blocking::Connection::session() { 169 | let reply = connection.call_method( 170 | Some("org.freedesktop.DBus"), 171 | "/", 172 | Some("org.freedesktop.DBus"), 173 | "NameHasOwner", 174 | &(destination), 175 | ); 176 | owner = reply.and_then(|r| r.body()).unwrap_or(false); 177 | } 178 | if owner { 179 | if let Ok(connection) = zbus::blocking::Connection::session() { 180 | let reply = 181 | connection.call_method(Some(destination), path, Some(interface), method, body); 182 | } 183 | } 184 | } 185 | --------------------------------------------------------------------------------