Esempio n. 1
0
BOOL CMainToolBar::OnDrop(COleDataObject *pDataObject, DROPEFFECT dropEffect,
                          CPoint point) {
  int cmd_id = HitTestButton(point);
  if (cmd_id == ID_RECYCLEBIN) {
    FileOperation(this, m_DropFiles, FO_DELETE, FOF_ALLOWUNDO, NULL);
    return TRUE;
  }

  if (cmd_id == ID_MYDOCUMENTS) {
    UINT file_oper = FO_COPY;

    switch (dropEffect) {
    case DROPEFFECT_COPY:
      file_oper = FO_COPY;
      break;

    case DROPEFFECT_MOVE:
      file_oper = FO_MOVE;
      break;
    case DROPEFFECT_LINK:
      return CreateShortcuts(m_DropFiles, m_LastDropFolder);

    default:
      TRACE(_T("Invalide file operation %d\n"), dropEffect);
      return false;
    }

    FileOperation(this, m_DropFiles, file_oper, FOF_ALLOWUNDO,
                  m_LastDropFolder);
    return TRUE;
  }

  return false;
}
Esempio n. 2
0
BOOL CInstallPage::StartInstallation(CString strLogFile)
{
    m_InstallationText.SetWindowText(CRString(IDS_LABEL_BEGIN_INSTALL));

    CWizardToolz toolz;

    // If the log file cannot be created, do not expect
    // that the installation can go on. So give a message and exit
    if (!toolz.InternalCreateFile(strLogFile))
    {
        m_InstallationText.SetWindowText(CRString(IDS_FAIL_INSTALL));
        AfxMessageBox(CRString(IDS_LABEL_NORIGHTS));
        return FALSE;
    }

    CStringArray arrLog;

    // The copy proccess
    arrLog.Add(CRString(IDS_START_COPY));
    if (!CopyNecessaryFiles(arrLog))
    {   // In case of an error, write to log and return
        arrLog.Add(CRString(IDS_FAIL_COPY));
        toolz.InternalWriteToFile(strLogFile, arrLog);
        return FALSE;
    }
    else
    {
        arrLog.Add(CRString(IDS_END_COPY));
        toolz.InternalWriteToFile(strLogFile, arrLog);
    }

    // The configuration of ini files process
    arrLog.RemoveAll();
    arrLog.Add(CRString(IDS_START_CONFIGURE));
    if (!ModifyConfigurationFiles(arrLog))
    {   // In case of an error, write to log and return
        arrLog.Add(CRString(IDS_FAIL_CONFIGURE));
        toolz.InternalWriteToFile(strLogFile, arrLog);
        return FALSE;
    }
    else
    {
        arrLog.Add(CRString(IDS_END_CONFIGURE));
        toolz.InternalWriteToFile(strLogFile, arrLog);
    }

    // Run some scripts to set stuff
    arrLog.RemoveAll();
    arrLog.Add(CRString(IDS_START_RUNSCRIPTS));
    if (!RunScripts(arrLog))
    {   // In case of an error, write to log and return
        arrLog.Add(CRString(IDS_FAIL_RUNSCRIPTS));
        toolz.InternalWriteToFile(strLogFile, arrLog);
        return FALSE;
    }
    else
    {
        arrLog.Add(CRString(IDS_END_RUNSCRIPTS));
        toolz.InternalWriteToFile(strLogFile, arrLog);
    }

    // Clean up process
    arrLog.RemoveAll();
    arrLog.Add(CRString(IDS_START_CLEANUP));
    if (!CleanUp(arrLog))
    {   // In case of an error, write to log and return
        arrLog.Add(CRString(IDS_FAIL_CLEANUP));
        toolz.InternalWriteToFile(strLogFile, arrLog);
        return FALSE;
    }
    else
    {
        arrLog.Add(CRString(IDS_END_CLEANUP));
        toolz.InternalWriteToFile(strLogFile, arrLog);
    }

    // create shortcuts
    CreateShortcuts(arrLog);

    // create registry entry
    arrLog.RemoveAll();
    arrLog.Add(CRString(IDS_START_UPDATEREGISTRY));
    UpdateRegistryEnvironment(arrLog);
    arrLog.Add(CRString(IDS_END_UPDATEREGISTRY));
    toolz.InternalWriteToFile(strLogFile, arrLog);

    return TRUE;
}
Esempio n. 3
0
DWORD WINAPI
InstallReactOS(HINSTANCE hInstance)
{
    TCHAR szBuffer[MAX_PATH];
    HANDLE token;
    TOKEN_PRIVILEGES privs;
    HKEY hKey;
    HINF hShortcutsInf;

    InitializeSetupActionLog(FALSE);
    LogItem(SYSSETUP_SEVERITY_INFORMATION, L"Installing ReactOS");

    if (!InitializeProfiles())
    {
        FatalError("InitializeProfiles() failed");
        return 0;
    }

    CreateTempDir(L"TEMP");
    CreateTempDir(L"TMP");

    if (GetWindowsDirectory(szBuffer, sizeof(szBuffer) / sizeof(TCHAR)))
    {
        if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,
                          L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion",
                          0,
                          KEY_WRITE,
                          &hKey) == ERROR_SUCCESS)
        {
            RegSetValueExW(hKey,
                           L"PathName",
                           0,
                           REG_SZ,
                           (LPBYTE)szBuffer,
                           (wcslen(szBuffer) + 1) * sizeof(WCHAR));

            RegSetValueExW(hKey,
                           L"SystemRoot",
                           0,
                           REG_SZ,
                           (LPBYTE)szBuffer,
                           (wcslen(szBuffer) + 1) * sizeof(WCHAR));

            RegCloseKey(hKey);
        }

        PathAddBackslash(szBuffer);
        _tcscat(szBuffer, _T("system"));
        CreateDirectory(szBuffer, NULL);
    }

    if (!CommonInstall())
        return 0;

    InstallWizard();

    InstallSecurity();

    SetAutoAdminLogon();

    hShortcutsInf = SetupOpenInfFileW(L"shortcuts.inf",
                                      NULL,
                                      INF_STYLE_WIN4,
                                      NULL);
    if (hShortcutsInf == INVALID_HANDLE_VALUE) 
    {
        FatalError("Failed to open shortcuts.inf");
        return 0;
    }

    if (!CreateShortcuts(hShortcutsInf, L"ShortcutFolders"))
    {
        FatalError("CreateShortcuts() failed");
        return 0;
    }

    SetupCloseInfFile(hShortcutsInf);

    /* ROS HACK, as long as NtUnloadKey is not implemented */
    {
        NTSTATUS Status = NtUnloadKey(NULL);
        if (Status == STATUS_NOT_IMPLEMENTED)
        {
            /* Create the Administrator profile */
            PROFILEINFOW ProfileInfo;
            HANDLE hToken;
            BOOL ret;

            ret = LogonUserW(AdminInfo.Name,
                             AdminInfo.Domain,
                             AdminInfo.Password,
                             LOGON32_LOGON_INTERACTIVE,
                             LOGON32_PROVIDER_DEFAULT,
                             &hToken);
            if (!ret)
            {
                FatalError("LogonUserW() failed!");
                return 0;
            }
            ZeroMemory(&ProfileInfo, sizeof(PROFILEINFOW));
            ProfileInfo.dwSize = sizeof(PROFILEINFOW);
            ProfileInfo.lpUserName = L"Administrator";
            ProfileInfo.dwFlags = PI_NOUI;
            LoadUserProfileW(hToken, &ProfileInfo);
            CloseHandle(hToken);
        }
        else
        {
            DPRINT1("ROS HACK not needed anymore. Please remove it\n");
        }
    }
    /* END OF ROS HACK */

    SetupCloseInfFile(hSysSetupInf);
    SetSetupType(0);

    LogItem(SYSSETUP_SEVERITY_INFORMATION, L"Installing ReactOS done");
    TerminateSetupActionLog();

    if (AdminInfo.Name != NULL)
        RtlFreeHeap(RtlGetProcessHeap(), 0, AdminInfo.Name);

    if (AdminInfo.Domain != NULL)
        RtlFreeHeap(RtlGetProcessHeap(), 0, AdminInfo.Domain);

    if (AdminInfo.Password != NULL)
        RtlFreeHeap(RtlGetProcessHeap(), 0, AdminInfo.Password);

    /* Get shutdown privilege */
    if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &token))
    {
        FatalError("OpenProcessToken() failed!");
        return 0;
    }
    if (!LookupPrivilegeValue(
        NULL,
        SE_SHUTDOWN_NAME,
        &privs.Privileges[0].Luid))
    {
        FatalError("LookupPrivilegeValue() failed!");
        return 0;
    }
    privs.PrivilegeCount = 1;
    privs.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
    if (AdjustTokenPrivileges(
        token,
        FALSE,
        &privs,
        0,
        (PTOKEN_PRIVILEGES)NULL,
        NULL) == 0)
    {
        FatalError("AdjustTokenPrivileges() failed!");
        return 0;
    }

    ExitWindowsEx(EWX_REBOOT, 0);
    return 0;
}