/* W I N D O W S 9 5 */ /* Windows source code */ VOID main() { MemSegment ThisSegement; long i = 1; ConsoleIO(O, "Starting Windows 9%d...\n", CURRENT_MINOR_VER); iShowStartupLogo(); ThisSegment = iLoadKernel(LAST_MEM_SEGMENT) while( ! MemoryExauhsted() && ThisSegment != FRIST_MEM_SEGMENT || ! FeelLikeAFool() ) { iUnloadKernel(ThisSegment); ThisSegement = iLoadKernel(LAST_MEM_SEGMENT - i); ++i; if (lUserHitEscKey()) { iHideStatrupLogo(); DontDisplayAnyInfo(); } } iInitializeMemorySystem(WITH_CRASH_EMBEDED); /* WITH_CRASH_FORCED, * WITH_CRASH_NATURAL */ if (lCanCrashNow() && lMachineNotStable() ) { if (lBlueScreenSystemInitialized() ) GiveHimABlueScreenOfDeathTM(BLUE_FOREVER); /* BLUE_ONCE, * BLUE_FOR_A_WHILE */ else KernelCrash(CRASH_IMMIDIATELY, NO_DATA_BE_SAVED, ANNOY_USER_FOR_A_WHILE); } FillMemoryWithDrivers(MEMORY_SIZE / 2, LAST_MEM_SEGMENT); DriverDetectPnPDevices(&Devices, IGNORE_SOME); ThisFS = InitializeLameFileSystem(HardDiskDevices, WASTE_HALF_SPACE, TORTURE_HARD_DISK); SetFSOption(&ThisFS, &HardDiskDevices[BOOT_DEVICE], ENABLE_BAD_CLUSTERS, LOSE_DIR_ENTRY, CORRUPT_BOOT_SECTOR_AFTER_A_YEAR_OR_SO); /* So it become not bootable */ RetVal = InitializeBlueScreenOfDeathSystem(); if (RetVal == FALSE) /* Can't do it */ CrashCurrentTask(); /* This module */ InitializeKernelAPI(); SetKernelAPIOption(GlobalMemAlloc, CRASH_ONCE_A_SESSTION); SetKernelAPIOption(GlobalMemFree, IGNORE_API); SetKernelAPIOption(GlobalMemLock, LOCK_FORVER); ConsoleDev = InitializeGraphics(WITH_MOUSE); DesktopObj = DrawDesktopWithNiceInterface(&ConsoleDev, INTERFACE_PHONY); EnableGrphicsMisBehaviuor(DesktopObj); while (FOREVER) { if (CurrentTask->RanTooMuch && ! CurrentTask->idle) /* Don't crash idle tasks */ CrashCurrentTask(); if (CurrentTask->WndSys->GotFocus) { SetPriorty(&CurrentTask, PRIO_FULL); SendOtherTasksToSleep(CurrentTask); } if (CurrentTask->User->AskForHelp) { ExecProgram(WIN_DIR, "Tour.exe"); } if (CurrentTask->User->RequestSystemFunction) { CheckSystemIntegrity(); /* See below */ SystemRespond(CurrentTask->User); /* See below */ } if (CurrentTask->DemandMemory) { again: start = KernelGetArbitraryMem(CurrentTask->MemSizeNeeded) if (start > KERNEL_SEG_START || start < KERNEL_SEG_END) goto again; /* Oh-uh we're in trouble, this will kill the kernel */ CurrentTask->Mem->MemSegmentStart = start; CurrentTask->Mem->MemSegmentEnd = NULL; } WaitOnTaskToLoseFocus(CurrentTask); if (UserTryToUninstallInternetExplorer(CurrentTask->user) ) KernelPanic("Operation no supported..."); repeat: CurrentTask = ReschduleTask(THE_ONE_WHO_GOT_FOCUS); if (CurrentTask == NULL) goto repeat; } /* NOT REACHED */ } VOID CheckSystemIntegrity() { if (SystemIsRunningMoreThan(ONE_DAY) ) HangMachine(); if (! InternetExplorerInstalled() ) { if (InternetConnectionIsUp() ) DownloadAndInstallIE(); else KernelPanic("Windows is now completely installed..." "Please reinstall Windows") } if (InternetExplorerIsNotRunning() ) ExecProgram(WIN_DIR, "iexplor.exe"); if (NetscapeIsRunning) { CrashTaskByName("Netscape"); Complain("Operation not supported."); } if (JavaVendorID() == SUN_MICROSYSTEMS) { UninstallProgramByName("JDK-%d.%d", SUN_MAJ_VER, SUN_MIN_VER); Complain("Windows recommends running Visual J++ as your default " "JVM \n\n Windows is not responsible for any damage JDK" " can cause.\n"); PlaySexyAdAboutVisualJPP(); } } VOID SystemRespond(USER_STRUCT CurrentUser) { if (CurrentUser->Request == CLIPBOARD_IO && CurrentUser->Task == NotePad) Complain("Not enough memory"); if (CurrentUser->Request == NEW_PROGRAM && NumOfRunningTasks > 20) Complain("Memory exhaused."); } BOOL lMachineNotStable() { return TRUE; } VOID KernalPanic(char* panic) /* aka Hang machine */ { if (CurrentTask->WndSys != NULL) KernelAPI(MessageBox, "Kernel Panic", panic, MB_NO_BUTTONS) else ConsoleIO(O, "Kernel Panic: %s\n", panic); while( TRUE ) { if (KbdUserHitAnyKey() ) { IgnoreUser(); SayBeep(); } if (MouseMoved() ) { PlayStupidVoiceOccassionally(); } if (Alt_Ctl_Del() ) continue; /* Ignore ALT CTL DEL */ } } BOOL lCanCrashNow() { if (UserHasUnsavedData() ) return TRUE; if (UserDoALotOFWork() ) return TRUE; if (UserPlaysDoom() ) return TRUE; if (UserRunNetscape() ) return TRUE; if (WindowsFeelsLikeCrash() ) return TRUE; if (NonOfTheAbove() ) return TRUE; return TRUE; } MemSegment iLoadKernel(long lOffset) { short sKernelNotLoaded; MemSegment ThisSegement; LockMachine(); while(sKernelNotLoaded) { ThisSegement = LoadDLL("krnl32.dll", lOffset, &sKernelNotLoaded); } UnlockMachine(); return ThisSegement; } /* tsemba at menanet dot net */ /* $Id: win-src.txt,v 1.2 2002/11/21 14:33:12 te Exp $ */