This code forces me to turn-off my PC.
You ( Tim Roberts ) told John Keenan:
??? Are you saying that you did this in a user-mode application and it
generated a blue screen? That's not supposed to be possible. ???.
About 2 weeks ago, my code blue-screened my WinXP box,
other times it spontaneously rebooted.
I even crashed the VC++ 8.0 compiler ( yet again ),
the report was sent to MicroSoft.
I was really tired at the time so I didn't try to reproduce it.
This code forces me to turn-off my PC:
#pragma warning( disable: 4100 4127 4189 4430 4508 4706 )
#define _WIN32_WINNT 0x0501
#define UNICODE
#include <Windows.H>
#define Quote_It( It ) #It
#define DD_Path( __X ) Quote_It( \
C:\\Program Files\\Microsoft DirectX SDK (December 2005)\\__X )
#include DD_Path( Include\\DDraw.H )
#pragma comment( lib , DD_Path( Lib\\x86\\DDraw.LIB ) )
#pragma comment( lib , DD_Path( Lib\\x86\\DXguid.LIB ) )
#include DD_Path( Include\\Dxerr8.H )
#pragma comment( lib , DD_Path( Lib\\x86\\Dxerr8.LIB ) )
#define CW CreateWindow
#define _SurT LPDIRECTDRAWSURFACE7
#define SetPtr SelectObject
#define Loop( N ) int J = - 1 , LLL = N ; while ( ++ J < LLL )
typedef unsigned int uint; typedef wchar_t * LnP ;
LPDIRECTDRAW _Direct_Draw; LPDIRECTDRAW7 Direct_Draw;
DDSURFACEDESC2 Z = { sizeof Z, DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH };
HWND Win ;
long __stdcall WinProc ( HWND Wnd, uint _WM, uint C, long C2 ) {
return 1 ; }
#define Okay ( \
rv >= 0 || rv == DDERR_WASSTILLDRAWING || rv == DDERR_SURFACELOST )
int Chk( int rv ) { if ( Okay ) return rv ;
LnP Err = LnP( DXGetErrorString8( rv ) );
return rv ; }
int W = 32000, H = 20, rv, CacheW, CacheH, X ; HDC DC ; HFONT Fnt ;
BlueScreen() { _SurT Oops ; Z.dwWidth = W , Z.dwHeight = H ;
Chk( Direct_Draw->CreateSurface( & Z, & Oops, 0 ) );
if ( Oops && ! ( rv = Oops->GetDC( & DC ) ) ) {
SetPtr( DC, Fnt );
Loop( W / CacheW + 3 ) TextOut( DC, X += CacheW, 0, L"X", 1 ); }
if ( Oops && ! rv ) BlueScreen(); }
__stdcall WinMain( HINSTANCE PID, HINSTANCE, char*, int ) {
DirectDrawCreate( 0, & _Direct_Draw, 0 );
_Direct_Draw->QueryInterface( IID_IDirectDraw7, (VOID**) & Direct_Draw );
if ( ! _Direct_Draw ) return ;
WNDCLASS Class = { 0, WinProc , 0,0, PID, 0, 0, 0, 0, L"WinProc" };
RegisterClass( & Class );
Win = CW(L"WinProc", 0, 0, 0, 0, 1, 1, 0, 0, PID, 0 );
Direct_Draw->SetCooperativeLevel( Win, DDSCL_NORMAL );
Z.ddsCaps.dwCaps = DDSCAPS_TEXTURE ; // DDSCAPS_VIDEOMEMORY
Fnt = CreateFont( CacheH = 64, 0,0,0,0,0,0,0,0,0,0,0,0, L"MS Mincho");
CacheW = CacheH * 128 / 256 ;
BlueScreen(); }