📄 install.c
字号:
hService = OpenService(hSCManager, _T("PlugPlay"), SERVICE_CHANGE_CONFIG | SERVICE_START);
if (hService == NULL)
goto cleanup;
ret = ChangeServiceConfig(
hService,
SERVICE_NO_CHANGE, SERVICE_AUTO_START, SERVICE_NO_CHANGE,
NULL, NULL, NULL, NULL, NULL, NULL, NULL);
if (!ret)
goto cleanup;
ret = StartService(hService, 0, NULL);
if (!ret)
goto cleanup;
ret = TRUE;
cleanup:
if (hSCManager != NULL)
CloseServiceHandle(hSCManager);
if (hService != NULL)
CloseServiceHandle(hService);
return ret;
}
DWORD STDCALL
InstallLiveCD (HINSTANCE hInstance)
{
LONG rc;
HKEY hKey = NULL;
DWORD dwType;
DWORD requiredSize;
LPTSTR Shell = NULL;
TCHAR CommandLine[MAX_PATH];
STARTUPINFO StartupInfo;
PROCESS_INFORMATION ProcessInformation;
BOOL res;
hSysSetupInf = SetupOpenInfFileW(
L"syssetup.inf",
NULL,
INF_STYLE_WIN4,
NULL);
if (hSysSetupInf == INVALID_HANDLE_VALUE)
{
DebugPrint("SetupOpenInfFileW() failed to open 'syssetup.inf' (Error: %lu)\n", GetLastError());
return 0;
}
if (!ProcessSysSetupInf())
{
DebugPrint("ProcessSysSetupInf() failed!\n");
return 0;
}
SetupCloseInfFile(hSysSetupInf);
if (!EnableUserModePnpManager())
{
DebugPrint("EnableUserModePnpManager() failed!\n");
return 0;
}
/* Load the default shell */
rc = RegOpenKeyEx(
HKEY_LOCAL_MACHINE,
TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon"), /* FIXME: should be REGSTR_PATH_WINLOGON */
0,
KEY_QUERY_VALUE,
&hKey);
if (rc != ERROR_SUCCESS)
goto cleanup;
rc = RegQueryValueEx(
hKey,
TEXT("Shell"),
NULL,
&dwType,
NULL,
&requiredSize);
if (rc != ERROR_SUCCESS)
goto cleanup;
else if (dwType != REG_SZ && dwType != REG_EXPAND_SZ)
goto cleanup;
else if (requiredSize > (MAX_PATH - 1) * sizeof(TCHAR))
goto cleanup;
Shell = HeapAlloc(GetProcessHeap(), 0, requiredSize + sizeof(TCHAR));
if (!Shell)
goto cleanup;
Shell[requiredSize / sizeof(WCHAR)] = '\0';
rc = RegQueryValueEx(
hKey,
TEXT("Shell"),
NULL,
NULL,
(LPBYTE)Shell,
&requiredSize);
if (rc != ERROR_SUCCESS)
goto cleanup;
if (dwType == REG_EXPAND_SZ)
ExpandEnvironmentStrings(Shell, CommandLine, MAX_PATH);
else if (dwType == REG_SZ)
_tcscpy(CommandLine, Shell);
/* Run the shell */
StartupInfo.cb = sizeof(StartupInfo);
StartupInfo.lpReserved = NULL;
StartupInfo.lpDesktop = NULL;
StartupInfo.lpTitle = NULL;
StartupInfo.dwFlags = 0;
StartupInfo.cbReserved2 = 0;
StartupInfo.lpReserved2 = 0;
res = CreateProcess(
CommandLine,
NULL,
NULL,
NULL,
FALSE,
0,
NULL,
NULL,
&StartupInfo,
&ProcessInformation);
if (!res)
goto cleanup;
/* Wait for process termination */
WaitForSingleObject(ProcessInformation.hProcess, INFINITE);
cleanup:
if (hKey != NULL)
RegCloseKey(hKey);
HeapFree(GetProcessHeap(), 0, Shell);
MessageBoxA(
NULL,
"You can shutdown your computer, or press ENTER to reboot",
"ReactOS LiveCD",
MB_OK);
return 0;
}
DWORD STDCALL
InstallReactOS (HINSTANCE hInstance)
{
TCHAR sAccessories[256];
TCHAR sGames[256];
TCHAR szBuffer[MAX_PATH];
# if 0
OutputDebugStringA ("InstallReactOS() called\n");
if (!InitializeSetupActionLog (FALSE))
{
OutputDebugStringA ("InitializeSetupActionLog() failed\n");
}
LogItem (SYSSETUP_SEVERITY_INFORMATION,
L"ReactOS Setup starting");
LogItem (SYSSETUP_SEVERITY_FATAL_ERROR,
L"Buuuuuuaaaah!");
LogItem (SYSSETUP_SEVERITY_INFORMATION,
L"ReactOS Setup finished");
TerminateSetupActionLog ();
#endif
#if 0
UNICODE_STRING SidString;
#endif
ULONG LastError;
if (!InitializeProfiles ())
{
DebugPrint ("InitializeProfiles() failed\n");
return 0;
}
CoInitialize(NULL);
/* create desktop shortcuts */
CreateShortcut(CSIDL_DESKTOP, NULL, _T("Command Prompt.lnk"), _T("cmd.exe"), IDS_CMT_CMD);
/* create program startmenu shortcuts */
CreateShortcut(CSIDL_PROGRAMS, NULL, _T("winefile.lnk"), _T("winefile.exe"), IDS_CMT_WINEFILE);
CreateShortcut(CSIDL_PROGRAMS, NULL, _T("ibrowser.lnk"), _T("ibrowser.exe"), IDS_CMT_IBROWSER);
CreateShortcut(CSIDL_PROGRAMS, NULL, _T("Get Firefox.lnk"), _T("getfirefox.exe"), IDS_CMT_GETFIREFOX);
CreateShortcut(CSIDL_PROGRAMS, NULL, _T("Download !.lnk"), _T("downloader.exe"), IDS_CMT_DOWNLOADER);
/* create administritive tools startmenu shortcuts */
CreateShortcut(CSIDL_ADMINTOOLS, NULL, _T("Services.lnk"), _T("servman.exe"), IDS_CMT_SERVMAN);
/* create and fill Accessories subfolder */
if (CreateShortcutFolder(CSIDL_PROGRAMS, IDS_ACCESSORIES, sAccessories, 256))
{
CreateShortcut(CSIDL_PROGRAMS, sAccessories, _T("Calculator.lnk"), _T("calc.exe"), IDS_CMT_CALC);
CreateShortcut(CSIDL_PROGRAMS, sAccessories, _T("Command Prompt.lnk"), _T("cmd.exe"), IDS_CMT_CMD);
CreateShortcut(CSIDL_PROGRAMS, sAccessories, _T("Notepad.lnk"), _T("notepad.exe"), IDS_CMT_NOTEPAD);
CreateShortcut(CSIDL_PROGRAMS, sAccessories, _T("ReactOS Explorer.lnk"), _T("explorer.exe"), IDS_CMT_EXPLORER);
CreateShortcut(CSIDL_PROGRAMS, sAccessories, _T("Regedit.lnk"), _T("regedit.exe"), IDS_CMT_REGEDIT);
CreateShortcut(CSIDL_PROGRAMS, sAccessories, _T("WordPad.lnk"), _T("wordpad.exe"), IDS_CMT_WORDPAD);
CreateShortcut(CSIDL_PROGRAMS, sAccessories, _T("SnapShot.lnk"), _T("screenshot.exe"), IDS_CMT_SCREENSHOT);
}
/* create Games subfolder and fill if the exe is available */
if (CreateShortcutFolder(CSIDL_PROGRAMS, IDS_GAMES, sGames, 256))
{
CreateShortcut(CSIDL_PROGRAMS, sGames, _T("Solitaire.lnk"), _T("sol.exe"), IDS_CMT_SOLITAIRE);
CreateShortcut(CSIDL_PROGRAMS, sGames, _T("WineMine.lnk"), _T("winemine.exe"), IDS_CMT_WINEMINE);
}
CoUninitialize();
/* Create the semi-random Domain-SID */
CreateRandomSid (&DomainSid);
if (DomainSid == NULL)
{
DebugPrint ("Domain-SID creation failed!\n");
return 0;
}
#if 0
RtlConvertSidToUnicodeString (&SidString, DomainSid, TRUE);
DebugPrint ("Domain-SID: %wZ\n", &SidString);
RtlFreeUnicodeString (&SidString);
#endif
/* Initialize the Security Account Manager (SAM) */
if (!SamInitializeSAM ())
{
DebugPrint ("SamInitializeSAM() failed!\n");
RtlFreeSid (DomainSid);
return 0;
}
/* Set the Domain SID (aka Computer SID) */
if (!SamSetDomainSid (DomainSid))
{
DebugPrint ("SamSetDomainSid() failed!\n");
RtlFreeSid (DomainSid);
return 0;
}
/* Append the Admin-RID */
AppendRidToSid(&AdminSid, DomainSid, DOMAIN_USER_RID_ADMIN);
#if 0
RtlConvertSidToUnicodeString (&SidString, DomainSid, TRUE);
DebugPrint ("Admin-SID: %wZ\n", &SidString);
RtlFreeUnicodeString (&SidString);
#endif
/* Create the Administrator account */
if (!SamCreateUser(L"Administrator", L"", AdminSid))
{
/* Check what the error was.
* If the Admin Account already exists, then it means Setup
* wasn't allowed to finish properly. Instead of rebooting
* and not completing it, let it restart instead
*/
LastError = GetLastError();
if (LastError != ERROR_USER_EXISTS)
{
DebugPrint("SamCreateUser() failed!\n");
RtlFreeSid(AdminSid);
RtlFreeSid(DomainSid);
return 0;
}
}
/* Create the Administrator profile */
if (!CreateUserProfileW(AdminSid, L"Administrator"))
{
DebugPrint("CreateUserProfileW() failed!\n");
RtlFreeSid(AdminSid);
RtlFreeSid(DomainSid);
return 0;
}
RtlFreeSid(AdminSid);
RtlFreeSid(DomainSid);
CreateTempDir(L"TEMP");
CreateTempDir(L"TMP");
if (GetWindowsDirectory(szBuffer, sizeof(szBuffer) / sizeof(TCHAR)))
{
PathAddBackslash(szBuffer);
_tcscat(szBuffer, _T("system"));
CreateDirectory(szBuffer, NULL);
}
hSysSetupInf = SetupOpenInfFileW(L"syssetup.inf",
NULL,
INF_STYLE_WIN4,
NULL);
if (hSysSetupInf == INVALID_HANDLE_VALUE)
{
DebugPrint("SetupOpenInfFileW() failed to open 'syssetup.inf' (Error: %lu)\n", GetLastError());
return 0;
}
if (!ProcessSysSetupInf())
{
DebugPrint("ProcessSysSetupInf() failed!\n");
return 0;
}
if (!EnableUserModePnpManager())
{
DebugPrint("EnableUserModePnpManager() failed!\n");
return 0;
}
if (CMP_WaitNoPendingInstallEvents(INFINITE) != WAIT_OBJECT_0)
{
DebugPrint("CMP_WaitNoPendingInstallEvents() failed!\n");
return 0;
}
InstallWizard();
SetupCloseInfFile(hSysSetupInf);
/// THE FOLLOWING DPRINT IS FOR THE SYSTEM REGRESSION TOOL
/// DO NOT REMOVE!!!
DbgPrint("SYSREG_CHECKPOINT:SYSSETUP_COMPLETE\n");
return 0;
}
/*
* @unimplemented
*/
DWORD STDCALL
SetupChangeFontSize(HANDLE hWnd,
LPCWSTR lpszFontSize)
{
return FALSE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -