BOOL DbgInitDebugChannels() { WCHAR valBuffer[100]; UNICODE_STRING Value; UNICODE_STRING Name = RTL_CONSTANT_STRING(L"DEBUGCHANNEL"); NTSTATUS Status; PPROCESSINFO ppi; BOOL ret; /* Initialize all channels to ERROR */ ppi = PsGetCurrentProcessWin32Process(); RtlFillMemory( ppi->DbgChannelLevel, sizeof(ppi->DbgChannelLevel), ERR_LEVEL); /* Find DEBUGCHANNEL env var */ Value.Buffer = valBuffer; Value.Length = 0; Value.MaximumLength = sizeof(valBuffer); Status = QueryEnvironmentVariable(&Name, &Value); /* It does not exist */ if(Status == STATUS_VARIABLE_NOT_FOUND) { /* There is nothing more to do */ return TRUE; } /* If the buffer in the stack is not enough allocate it */ if(Status == STATUS_BUFFER_TOO_SMALL) { Value.Buffer = ExAllocatePool(PagedPool, Value.MaximumLength); if(Value.Buffer == NULL) { return FALSE; } /* Get the env var again */ Status = QueryEnvironmentVariable(&Name, &Value); } /* Check for error */ if(!NT_SUCCESS(Status)) { if(Value.Buffer != valBuffer) { ExFreePool(Value.Buffer); } return FALSE; } /* Parse the variable */ ret = DbgParseDebugChannels(ppi, &Value); /* Clean up*/ if(Value.Buffer != valBuffer) { ExFreePool(Value.Buffer); } return ret; }
VOID DoOptionsMenu(VOID) { ULONG SelectedMenuItem; CHAR DebugChannelString[100]; if (!UiDisplayMenu("Select an option:", "", TRUE, OptionsMenuList, OptionsMenuItemCount, 11, // Use "Start ReactOS normally" as default; see the switch below. -1, &SelectedMenuItem, TRUE, NULL)) { /* The user pressed ESC */ return; } /* Clear the backdrop */ UiDrawBackdrop(); switch (SelectedMenuItem) { case 0: // Safe Mode BootOptionChoice = SAFE_MODE; BootLogging = TRUE; break; case 1: // Safe Mode with Networking BootOptionChoice = SAFE_MODE_WITH_NETWORKING; BootLogging = TRUE; break; case 2: // Safe Mode with Command Prompt BootOptionChoice = SAFE_MODE_WITH_COMMAND_PROMPT; BootLogging = TRUE; break; // case 3: // Separator // break; case 4: // Enable Boot Logging BootLogging = TRUE; break; case 5: // Enable VGA Mode VgaMode = TRUE; break; case 6: // Last Known Good Configuration BootOptionChoice = LAST_KNOWN_GOOD_CONFIGURATION; break; case 7: // Directory Services Restore Mode BootOptionChoice = DIRECTORY_SERVICES_RESTORE_MODE; break; case 8: // Debugging Mode DebuggingMode = TRUE; break; case 9: // FreeLdr debugging DebugChannelString[0] = 0; if (UiEditBox(FrldrDbgMsg, DebugChannelString, sizeof(DebugChannelString) / sizeof(DebugChannelString[0]))) { DbgParseDebugChannels(DebugChannelString); } break; // case 10: // Separator // break; case 11: // Start ReactOS normally // Reset all the parameters to their default values. BootOptionChoice = NO_OPTION; BootLogging = FALSE; VgaMode = FALSE; DebuggingMode = FALSE; break; #ifdef HAS_OPTION_MENU_CUSTOM_BOOT case 12: // Custom Boot OptionMenuCustomBoot(); break; #endif #ifdef HAS_OPTION_MENU_REBOOT case 13: // Reboot OptionMenuReboot(); break; #endif } }