File size: 169,136 Bytes
07a3434
 
1
2
3
{"repo_name": "OpenSpeedy", "file_name": "/OpenSpeedy/processmonitor.h", "inference_info": {"prefix_code": "class ProcessMonitor {\n    Q_OBJECT\npublic:\nexplicit ProcessMonitor(QSettings*   settings,\n                        QTreeWidget* treeWidget,\n                        QLabel*      treeStatusLabel,\n                        QLabel*      injector32StatusLabel,\n                        QLabel*      injector64StatusLabel,\n\n                        QObject*     parent = nullptr);\n    ~ProcessMonitor() {\n    this->terminalBridge();\n    delete m_bridge32;\n    delete m_bridge64;\n}\n    void setInterval(int msec);\n    void setFilter(QString processName) {\n    m_filter = processName.toLower();\n}\n    void changeSpeed(double factor) {\n    QString cmd = QString(\"change %1\\n\").arg(factor);\n    m_bridge32->write(cmd.toUtf8(), cmd.size());\n    m_bridge32->waitForBytesWritten();\n    m_bridge64->write(cmd.toUtf8(), cmd.size());\n    m_bridge64->waitForBytesWritten();\n}\n  public:\n    void refresh() {\n    healthcheckBridge();\n    QList<ProcessInfo> processList = winutils::getProcessList();\n    if (m_filter == \"\")\n    {\n        update(processList);\n        m_treeStatusLabel->setText(QString(tr(\"搜索到%1个进程, 已过滤展示%2个\"))\n                                   .arg(processList.size())\n                                   .arg(processList.size()));\n    }\n    else\n    {\n        QList<ProcessInfo> filtered;\n        for (ProcessInfo info : processList)\n        {\n            if (info.name.toLower().contains(m_filter))\n                filtered.append(info);\n        }\n        update(filtered);\n        m_treeStatusLabel->setText(QString(tr(\"搜索到%1个进程, 已过滤展示%2个\"))\n                                   .arg(processList.size())\n                                   .arg(filtered.size()));\n    }\n}\n    void start() {\n    m_timer = new QTimer(this);\n    connect(m_timer, &QTimer::timeout, this, &ProcessMonitor::refresh);\n    m_timer->start(1000);\n}\n  private:\n    void onItemChanged(QTreeWidgetItem* item, int column) {\n    if (column == 5 && (item->flags() & Qt::ItemIsUserCheckable))\n    {\n        bool state = m_treeWidget->blockSignals(true);\n\n        Qt::CheckState checkState = item->checkState(column);\n        QString processName = item->text(0);\n        DWORD pid = item->text(1).toLong();\n        bool is64Bit = item->text(3) == \"x64\" ? true : false;\n        if (checkState == Qt::Checked)\n        {\n            m_targetNames.insert(processName);\n            this->injectDll(pid, is64Bit);\n            item->setText(5, tr(\"加速中\"));\n            for (int col = 0; col < item->columnCount(); ++col)\n            {\n                item->setBackground(col, QBrush(QColor(\"#f3e5f5\")));\n                item->setForeground(col, QBrush(QColor(\"#7b1fa2\")));\n            }\n            qDebug() << processName << \"勾选\";\n            dump();\n        }\n        else\n        {\n            m_targetNames.remove(processName);\n            this->unhookDll(pid, is64Bit);\n            item->setText(5, \"\");\n            for (int col = 0; col < item->columnCount(); ++col)\n            {\n                item->setBackground(col, QBrush());\n                item->setForeground(col, QBrush());\n            }\n            qDebug() << processName << \"取消勾选\";\n            dump();\n        }\n\n        m_treeWidget->blockSignals(state);\n    }\n}\n  private:\n    QTreeWidget* m_treeWidget;\n    QLabel* m_treeStatusLabel;\n    QLabel* m_injector32StatusLabel;\n    QLabel* m_injector64StatusLabel;\n    QString m_filter;\n    QTimer* m_timer = nullptr;\n    QString m_dllPath;\n    QProcess* m_bridge32;\n    QProcess* m_bridge64;\n    QSettings* m_settings;\n    QHash<QString, QIcon> m_iconCache;\n    QMap<DWORD, QTreeWidgetItem*> m_processItems;\n    QSet<QString> m_targetNames;\n    void init() {\n    QStringList targetNames =\n        m_settings->value(CONFIG_TARGETNAMES_KEY).toStringList();\n    m_targetNames = QSet<QString>(targetNames.begin(), targetNames.end());\n}\n    void dump() {\n    m_settings->setValue(CONFIG_TARGETNAMES_KEY,\n                         QStringList(m_targetNames.values()));\n}\n    void update(const QList<ProcessInfo>& processList) {\n    // 跟踪现有进程,用于确定哪些已终止\n    QSet<DWORD> currentPids;\n    for (const ProcessInfo& info : processList)\n    {\n        currentPids.insert(info.pid);\n    }\n\n    // 移除已终止的进程\n    QMutableMapIterator<DWORD, QTreeWidgetItem*> i(m_processItems);\n    while (i.hasNext())\n    {\n        i.next();\n        if (!currentPids.contains(i.key()))\n        {\n            QTreeWidgetItem* item = i.value();\n            QTreeWidgetItem* parent = item->parent();\n\n            if (parent)\n            {\n                parent->removeChild(item);\n            }\n            else\n            {\n                auto index = m_treeWidget->indexOfTopLevelItem(item);\n                m_treeWidget->takeTopLevelItem(index);\n            }\n\n            while (item->childCount() > 0)\n            {\n                QTreeWidgetItem* child = item->takeChild(0);\n                if (parent)\n                {\n                    parent->addChild(child);\n                }\n                else\n                {\n                    m_treeWidget->addTopLevelItem(child);\n                }\n            }\n\n            // 删除节点\n            delete item;\n\n            // 从映射中移除\n            i.remove();\n        }\n    }\n\n    // 添加或更新进程信息\n    for (const ProcessInfo& info : processList)\n    {\n        if (m_processItems.contains(info.pid))\n        {\n            // 更新已存在的进程信息\n            QTreeWidgetItem* item = m_processItems[info.pid];\n            item->setText(1, QString::number(info.pid));\n            item->setData(1, Qt::UserRole, (long long)info.pid);\n            item->setText(2,\n                          QString(\"%1 MB\").arg(info.memoryUsage / 1024 / 1024));\n            item->setData(2, Qt::UserRole, (uint)info.memoryUsage);\n\n            QString arch = info.is64Bit ? \"x64\" : \"x86\";\n            item->setText(3, arch);\n            QString priority;\n            switch (info.priorityClass)\n            {\n            case HIGH_PRIORITY_CLASS:\n                priority = tr(\"\");\n                break;\n            case NORMAL_PRIORITY_CLASS:\n                priority = tr(\"\");\n                break;\n            case IDLE_PRIORITY_CLASS:\n                priority = tr(\"\");\n                break;\n            case REALTIME_PRIORITY_CLASS:\n                priority = tr(\"实时\");\n                break;\n            default:\n                priority = tr(\"未知\");\n                break;\n            }\n            item->setText(4, priority);\n            if (m_targetNames.contains(info.name))\n            {\n                if (item->checkState(5) == Qt::Unchecked)\n                {\n                    item->setCheckState(5, Qt::Checked);\n                }\n            }\n            else\n            {\n                if (item->checkState(5) == Qt::Checked)\n                {\n                    item->setCheckState(5, Qt::Unchecked);\n                }\n            }\n        }\n        else\n        {\n            // 添加新进程\n            QTreeWidgetItem* item = new SortTreeWidgetItem();\n\n            item->setText(0, info.name);\n            item->setData(0, Qt::UserRole, info.name.toLower());\n            item->setText(1, QString::number(info.pid));\n            item->setData(1, Qt::UserRole, (long long)info.pid);\n            item->setText(2,\n                          QString(\"%1 MB\").arg(info.memoryUsage / 1024 / 1024));\n            item->setData(2, Qt::UserRole, (uint)info.memoryUsage);\n\n            QString arch = info.is64Bit ? \"x64\" : \"x86\";\n            item->setText(3, arch);\n\n            // 加载进程图标\n            item->setIcon(0, getProcessIconCached(info.pid));\n\n            QString priority;\n            switch (info.priorityClass)\n            {\n            case HIGH_PRIORITY_CLASS:\n                priority = tr(\"\");\n                break;\n            case NORMAL_PRIORITY_CLASS:\n                priority = tr(\"\");\n                break;\n            case IDLE_PRIORITY_CLASS:\n                priority = tr(\"\");\n                break;\n            case REALTIME_PRIORITY_CLASS:\n                priority = tr(\"实时\");\n                break;\n            default:\n                priority = tr(\"未知\");\n                break;\n            }\n            item->setText(4, priority);\n            item->setCheckState(5, Qt::Unchecked);\n            m_treeWidget->addTopLevelItem(item);\n            m_processItems[info.pid] = item;\n        }\n    }\n}\n    void injectDll(DWORD processId, bool is64Bit) {\n    QString cmd = QString(\"inject %1\\n\").arg(processId);\n    if (!is64Bit)\n    {\n        m_bridge32->write(cmd.toUtf8(), cmd.size());\n        m_bridge32->waitForBytesWritten();\n    }\n    else\n    {\n        m_bridge64->write(cmd.toUtf8(), cmd.size());\n        m_bridge64->waitForBytesWritten();\n    }\n}\n    void unhookDll(DWORD processId, bool is64Bit) {\n    QString cmd = QString(\"unhook %1\\n\").arg(processId);\n    if (!is64Bit)\n    {\n        m_bridge32->write(cmd.toUtf8(), cmd.size());\n        m_bridge32->waitForBytesWritten();\n    }\n    else\n    {\n        m_bridge64->write(cmd.toUtf8(), cmd.size());\n        m_bridge64->waitForBytesWritten();\n    }\n}\n    void startBridge32() {\n    m_bridge32 = new QProcess();\n    QStringList params32;\n    m_bridge32->start(BRIDGE32_EXE, params32);\n    if (!m_bridge32->waitForStarted())\n    {\n        qDebug() << \"32位桥接子进程启动失败\";\n    }\n    else\n    {\n        qDebug() << \"32位桥接子进程已启动\";\n    }\n    m_bridge32->setProcessChannelMode(QProcess::MergedChannels);\n    connect(m_bridge32,\n            &QProcess::readyReadStandardOutput,\n            [&]()\n    {\n        QByteArray data = m_bridge32->readAllStandardOutput();\n        qDebug() << \"收到输出:\" << QString(data).trimmed();\n    });\n}\n    void startBridge64() {\n    m_bridge64 = new QProcess();\n    QStringList params64;\n    m_bridge64->start(BRIDGE64_EXE, params64);\n    if (!m_bridge64->waitForStarted())\n    {\n        qDebug() << \"64位桥接子进程启动失败\";\n    }\n    else\n    {\n        qDebug() << \"64位桥接子进程已启动\";\n    }\n    m_bridge64->setProcessChannelMode(QProcess::MergedChannels);\n    connect(m_bridge64,\n            &QProcess::readyReadStandardOutput,\n            [&]()\n    {\n        QByteArray data = m_bridge64->readAllStandardOutput();\n        qDebug() << \"收到输出:\" << QString(data).trimmed();\n    });\n}\n    void healthcheckBridge() {\n    if (this->m_bridge32->state() == QProcess::Running)\n    {\n        m_injector32StatusLabel->setStyleSheet(\"color: green\");\n        m_injector32StatusLabel->setText(tr(\"正常\"));\n    }\n    else\n    {\n        m_injector32StatusLabel->setStyleSheet(\"color: red\");\n        m_injector32StatusLabel->setText(tr(\"异常退出\"));\n    }\n\n    if (this->m_bridge64->state() == QProcess::Running)\n    {\n        m_injector64StatusLabel->setStyleSheet(\"color: green\");\n        m_injector64StatusLabel->setText(tr(\"正常\"));\n    }\n    else\n    {\n        m_injector64StatusLabel->setStyleSheet(\"color:red\");\n        m_injector64StatusLabel->setText(tr(\"异常退出\"));\n    }\n}\n    void terminalBridge() {\n    QString cmd = QString(\"exit\\n\");\n    m_bridge32->write(cmd.toUtf8(), cmd.size());\n    m_bridge32->waitForBytesWritten();\n    m_bridge64->write(cmd.toUtf8(), cmd.size());\n    m_bridge64->waitForBytesWritten();\n}\n    static QIcon getProcessIcon(QString processPath) {\n    int lastSlashPos =\n        std::max(processPath.lastIndexOf('/'), processPath.lastIndexOf('\\\\'));\n    QString processName;\n    if (lastSlashPos == -1)\n    {\n        processName = processPath;\n    }\n    processName = processPath.mid(lastSlashPos + 1);\n\n    if (processPath.isEmpty())\n    {\n        qDebug() << processPath << \"无法获取进程完整路径\";\n        return getDefaultIcon(processName);\n    }\n\n    SHFILEINFO sfi = {};\n    if (SHGetFileInfo(reinterpret_cast<LPCWSTR>(processPath.utf16()),\n                      FILE_ATTRIBUTE_NORMAL,\n                      &sfi,\n                      sizeof(SHFILEINFO),\n                      SHGFI_ICON | SHGFI_LARGEICON | SHGFI_USEFILEATTRIBUTES))\n    {\n        ", "suffix_code": "\n    }\n\n    HICON hIcon =\n        ExtractIconW(nullptr, reinterpret_cast<LPCWSTR>(processPath.utf16()), 0);\n    if (hIcon)\n    {\n        QIcon icon = QtWin::fromHICON(hIcon);\n        DestroyIcon(hIcon);\n        if (!icon.isNull())\n            return icon;\n    }\n\n    QFileInfo fileInfo(processPath);\n    if (fileInfo.exists())\n    {\n        // 使用Qt的QFileIconProvider获取文件图标\n        QFileIconProvider iconProvider;\n        return iconProvider.icon(fileInfo);\n    }\n    qDebug() << processPath << \"无法获取进程图标使用默认图标\";\n\n    return getDefaultIcon(processName);\n}\n    static QIcon getDefaultIcon(const QString& processName) {\n    // 根据进程名称或类型提供更有针对性的默认图标\n    if (processName != \"\")\n    {\n        // 使用SHGetFileInfo获取.exe文件的图标\n        SHFILEINFO sfi = {};\n        QIcon icon;\n        if (SHGetFileInfo(reinterpret_cast<LPCWSTR>(processName.utf16()),\n                          FILE_ATTRIBUTE_NORMAL,\n                          &sfi,\n                          sizeof(SHFILEINFO),\n                          SHGFI_USEFILEATTRIBUTES | SHGFI_ICON |\n                          SHGFI_SMALLICON))\n        {\n            // 将HICON转换为QIcon\n            icon = QtWin::fromHICON(sfi.hIcon);\n\n            // 释放图标资源\n            DestroyIcon(sfi.hIcon);\n        }\n        return icon;\n    }\n    else\n    {\n        // 使用SHGetFileInfo获取.exe文件的图标\n        SHFILEINFO sfi = {};\n        QIcon icon;\n        if (SHGetFileInfo(reinterpret_cast<LPCWSTR>(L\".exe\"),\n                          FILE_ATTRIBUTE_NORMAL,\n                          &sfi,\n                          sizeof(SHFILEINFO),\n                          SHGFI_USEFILEATTRIBUTES | SHGFI_ICON |\n                          SHGFI_SMALLICON))\n        {\n            // 将HICON转换为QIcon\n            icon = QtWin::fromHICON(sfi.hIcon);\n\n            // 释放图标资源\n            DestroyIcon(sfi.hIcon);\n        }\n        return icon;\n    }\n}\n    QIcon getProcessIconCached(DWORD proccessId) {\n    QString processPath = winutils::getProcessPath(processId);\n    if (m_iconCache.contains(processPath))\n    {\n        return m_iconCache[processPath];\n    }\n\n    QIcon icon = getProcessIcon(processPath);\n    m_iconCache.insert(processPath, icon);\n    return icon;\n}\n  public:\n};", "middle_code": "if (sfi.hIcon)\n        {\n            QIcon icon = QtWin::fromHICON(sfi.hIcon);\n            DestroyIcon(sfi.hIcon);\n            if (!icon.isNull())\n            {\n                qDebug() << processPath << \"通过SHGetFileInfo获取图标成功\";\n                return icon;\n            }\n        }", "code_description": null, "fill_type": "BLOCK_TYPE", "language_type": "cpp", "sub_task_type": "if_statement"}, "context_code": [["/OpenSpeedy/winutils.h", "class winutils {\n  public:\n    winutils() {\n}\n  public:\n    static bool injectDll(DWORD processId, const QString& dllPath) {\n    HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, processId);\n    if (!hProcess)\n    {\n        qDebug() << \"Failed to open process:\" << GetLastError();\n        return false;\n    }\n\n    if (checkDllExist(processId, dllPath))\n    {\n        qDebug() << \"Process already have been injected\";\n        return true;\n    }\n    else if (injectDllViaCRTW(processId, dllPath))\n    {\n        return true;\n    }\n    else if (injectDllViaCRTA(processId, dllPath))\n    {\n        return true;\n    }\n\n    injectDllViaAPCW(processId, dllPath);\n    injectDllViaAPCA(processId, dllPath);\n    if (checkDllExist(processId, dllPath))\n    {\n        return true;\n    }\n    else if (injectDllViaWHKW(processId, dllPath))\n    {\n        return true;\n    }\n    else if (injectDllViaWHKA(processId, dllPath))\n    {\n        return true;\n    }\n    else\n    {\n        return false;\n    }\n}\n    static bool injectDllViaCRTA(DWORD processId, const QString& dllPath) {\n    HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, processId);\n    if (!hProcess)\n    {\n        qDebug() << \"Failed to open process:\" << GetLastError();\n        return false;\n    }\n\n    if (checkDllExist(processId, dllPath))\n    {\n        qDebug() << \"Process already have been injected\";\n        return true;\n    }\n    SIZE_T pathSize = (dllPath.size() + 1) * sizeof(char);\n    LPVOID pDllPath =\n        VirtualAllocEx(hProcess,\n                       nullptr,\n                       pathSize,\n                       MEM_COMMIT | MEM_RESERVE,\n                       PAGE_EXECUTE_READWRITE);\n    if (!pDllPath)\n    {\n        qDebug() << \"Failed to allocate memory in target process:\"\n                 << GetLastError();\n        CloseHandle(hProcess);\n        return false;\n    }\n\n    if (!WriteProcessMemory(hProcess,\n                            pDllPath,\n                            dllPath.toStdString().c_str(),\n                            pathSize,\n                            nullptr))\n    {\n        qDebug() << \"Failed to write memory in target process:\"\n                 << GetLastError();\n        VirtualFreeEx(hProcess, pDllPath, 0, MEM_RELEASE);\n        CloseHandle(hProcess);\n        return false;\n    }\n\n    HMODULE hKernel32 = GetModuleHandle(L\"kernel32.dll\");\n    if (!hKernel32)\n    {\n        qDebug() << \"Failed to get handle for kernel32.dll:\" << GetLastError();\n        VirtualFreeEx(hProcess, pDllPath, 0, MEM_RELEASE);\n        CloseHandle(hProcess);\n        return false;\n    }\n\n    FARPROC pLoadLibraryA = GetProcAddress(hKernel32, \"LoadLibraryA\");\n    if (!pLoadLibraryA)\n    {\n        qDebug() << \"Failed to get address of LoadLibraryA:\" << GetLastError();\n        VirtualFreeEx(hProcess, pDllPath, 0, MEM_RELEASE);\n        CloseHandle(hProcess);\n        return false;\n    }\n\n    HANDLE hThread = CreateRemoteThread(hProcess,\n                                        nullptr,\n                                        0,\n                                        (LPTHREAD_START_ROUTINE)pLoadLibraryA,\n                                        pDllPath,\n                                        0,\n                                        nullptr);\n    if (!hThread)\n    {\n        qDebug() << \"Failed to create remote thread:\" << GetLastError();\n        VirtualFreeEx(hProcess, pDllPath, 0, MEM_RELEASE);\n        CloseHandle(hProcess);\n        return false;\n    }\n\n    WaitForSingleObject(hThread, INFINITE);\n\n    // 检查LoadLibrary是否执行成功\n    DWORD exitCode = 0;\n    if (GetExitCodeThread(hThread, &exitCode))\n    {\n        qDebug() << \"Remote thread exit code:\" << exitCode;\n        // LoadLibrary返回的是模块句柄,如果为0则失败\n        if (exitCode == 0)\n        {\n            VirtualFreeEx(hProcess, pDllPath, 0, MEM_RELEASE);\n            CloseHandle(hProcess);\n            CloseHandle(hThread);\n            qDebug() << \"LoadLibrary failed in remote process\";\n            return false;\n        }\n    }\n\n    VirtualFreeEx(hProcess, pDllPath, 0, MEM_RELEASE);\n    CloseHandle(hThread);\n    CloseHandle(hProcess);\n\n    return true;\n}\n    static bool injectDllViaCRTW(DWORD processId, const QString& dllPath) {\n    HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, processId);\n    if (!hProcess)\n    {\n        qDebug() << \"Failed to open process:\" << GetLastError();\n        return false;\n    }\n\n    if (checkDllExist(processId, dllPath))\n    {\n        qDebug() << \"Process already have been injected\";\n        return true;\n    }\n    SIZE_T pathSize = (dllPath.size() + 1) * sizeof(wchar_t);\n    LPVOID pDllPath =\n        VirtualAllocEx(hProcess, nullptr, pathSize, MEM_COMMIT | MEM_RESERVE,\n                       PAGE_EXECUTE_READWRITE);\n    if (!pDllPath)\n    {\n        qDebug() << \"Failed to allocate memory in target process:\"\n                 << GetLastError();\n        CloseHandle(hProcess);\n        return false;\n    }\n\n    if (!WriteProcessMemory(hProcess,\n                            pDllPath,\n                            dllPath.toStdWString().c_str(),\n                            pathSize,\n                            nullptr))\n    {\n        qDebug() << \"Failed to write memory in target process:\"\n                 << GetLastError();\n        VirtualFreeEx(hProcess, pDllPath, 0, MEM_RELEASE);\n        CloseHandle(hProcess);\n        return false;\n    }\n\n    HMODULE hKernel32 = GetModuleHandle(L\"kernel32.dll\");\n    if (!hKernel32)\n    {\n        qDebug() << \"Failed to get handle for kernel32.dll:\" << GetLastError();\n        VirtualFreeEx(hProcess, pDllPath, 0, MEM_RELEASE);\n        CloseHandle(hProcess);\n        return false;\n    }\n\n    FARPROC pLoadLibraryW = GetProcAddress(hKernel32, \"LoadLibraryW\");\n    if (!pLoadLibraryW)\n    {\n        qDebug() << \"Failed to get address of LoadLibraryW:\" << GetLastError();\n        VirtualFreeEx(hProcess, pDllPath, 0, MEM_RELEASE);\n        CloseHandle(hProcess);\n        return false;\n    }\n\n    HANDLE hThread = CreateRemoteThread(hProcess,\n                                        nullptr,\n                                        0,\n                                        (LPTHREAD_START_ROUTINE)pLoadLibraryW,\n                                        pDllPath,\n                                        0,\n                                        nullptr);\n    if (!hThread)\n    {\n        qDebug() << \"Failed to create remote thread:\" << GetLastError();\n        VirtualFreeEx(hProcess, pDllPath, 0, MEM_RELEASE);\n        CloseHandle(hProcess);\n        return false;\n    }\n\n    WaitForSingleObject(hThread, INFINITE);\n\n    // 检查LoadLibrary是否执行成功\n    DWORD exitCode = 0;\n    if (GetExitCodeThread(hThread, &exitCode))\n    {\n        qDebug() << \"Remote thread exit code:\" << exitCode;\n        // LoadLibrary返回的是模块句柄,如果为0则失败\n        if (exitCode == 0)\n        {\n            VirtualFreeEx(hProcess, pDllPath, 0, MEM_RELEASE);\n            CloseHandle(hProcess);\n            CloseHandle(hThread);\n            qDebug() << \"LoadLibrary failed in remote process\";\n            return false;\n        }\n    }\n\n    VirtualFreeEx(hProcess, pDllPath, 0, MEM_RELEASE);\n    CloseHandle(hThread);\n    CloseHandle(hProcess);\n\n    return true;\n}\n    static bool injectDllViaAPCA(DWORD processId, const QString& dllPath) {\n    HANDLE hProcess =\n        OpenProcess(PROCESS_ALL_ACCESS,\n                    FALSE,\n                    processId);\n\n    if (!hProcess)\n    {\n        qDebug() << \"Failed to open process: \" << GetLastError();\n        return false;\n    }\n\n    if (checkDllExist(processId, dllPath))\n    {\n        qDebug() << \"Process already have been injected\";\n        return true;\n    }\n\n    // 在目标进程中分配内存并写入DLL路径\n    SIZE_T pathSize = (dllPath.toStdString().size() + 1) * sizeof(char);\n    LPVOID pDllPath = VirtualAllocEx(hProcess,\n                                     NULL,\n                                     pathSize,\n                                     MEM_COMMIT,\n                                     PAGE_READWRITE);\n\n    if (!pDllPath)\n    {\n        qDebug() << \"Failed to allocate memory: \" << GetLastError();\n        CloseHandle(hProcess);\n        return false;\n    }\n\n    if (!WriteProcessMemory(hProcess, pDllPath, dllPath.toStdString().c_str(),\n                            pathSize, NULL))\n    {\n        qDebug() << \"Failed to write memory: \" << GetLastError();\n        VirtualFreeEx(hProcess, pDllPath, 0, MEM_RELEASE);\n        CloseHandle(hProcess);\n        return false;\n    }\n\n    // 获取LoadLibraryW的地址\n    HMODULE hKernel32 = GetModuleHandle(L\"kernel32.dll\");\n    if (!hKernel32)\n    {\n        qDebug() << \"Failed to get kernel32 handle\";\n        VirtualFreeEx(hProcess, pDllPath, 0, MEM_RELEASE);\n        CloseHandle(hProcess);\n        return false;\n    }\n\n    FARPROC pLoadLibraryA = GetProcAddress(hKernel32, \"LoadLibraryA\");\n    if (!pLoadLibraryA)\n    {\n        qDebug() << \"Failed to get LoadLibraryA address\";\n        VirtualFreeEx(hProcess, pDllPath, 0, MEM_RELEASE);\n        CloseHandle(hProcess);\n        return false;\n    }\n\n    // 获取进程中的所有线程\n    DWORD threadId = getProcessMainThread(processId);\n    if (!threadId)\n    {\n        qDebug() << \"No threads found in the process\";\n        VirtualFreeEx(hProcess, pDllPath, 0, MEM_RELEASE);\n        CloseHandle(hProcess);\n        return false;\n    }\n\n    // 向目标进程的所有线程队列中添加APC调用\n    bool success = false;\n\n    // 打开线程\n    HANDLE hThread = OpenThread(THREAD_SET_CONTEXT, FALSE, threadId);\n    if (hThread)\n    {\n        // 将LoadLibraryA作为APC函数加入队列\n        PostThreadMessageA(threadId, WM_PAINT, 0, 0);\n        DWORD result =\n            QueueUserAPC((PAPCFUNC)pLoadLibraryA, hThread, (ULONG_PTR)pDllPath);\n        PostThreadMessageA(threadId, WM_PAINT, 0, 0);\n        if (result != 0)\n        {\n            success = true;\n            qDebug() << \"APC queued to thread \" << threadId;\n        }\n\n        CloseHandle(hThread);\n    }\n\n    if (!success)\n    {\n        qDebug() << \"Failed to queue APC to any thread\";\n        VirtualFreeEx(hProcess, pDllPath, 0, MEM_RELEASE);\n        CloseHandle(hProcess);\n        return false;\n    }\n\n    // 注意:我们不释放分配的内存,因为APC函数尚未执行\n    // 内存将在DLL加载后释放\n\n    CloseHandle(hProcess);\n    return true;\n}\n    static bool injectDllViaAPCW(DWORD processId, const QString& dllPath) {\n    HANDLE hProcess =\n        OpenProcess(PROCESS_ALL_ACCESS,\n                    FALSE,\n                    processId);\n\n    if (!hProcess)\n    {\n        qDebug() << \"Failed to open process: \" << GetLastError();\n        return false;\n    }\n\n    if (checkDllExist(processId, dllPath))\n    {\n        qDebug() << \"Process already have been injected\";\n        return true;\n    }\n\n    // 在目标进程中分配内存并写入DLL路径\n    SIZE_T pathSize = (dllPath.toStdWString().size() + 1) * sizeof(wchar_t);\n    LPVOID pDllPath = VirtualAllocEx(hProcess,\n                                     NULL,\n                                     pathSize,\n                                     MEM_COMMIT,\n                                     PAGE_READWRITE);\n\n    if (!pDllPath)\n    {\n        qDebug() << \"Failed to allocate memory: \" << GetLastError();\n        CloseHandle(hProcess);\n        return false;\n    }\n\n    if (!WriteProcessMemory(hProcess,\n                            pDllPath,\n                            dllPath.toStdWString().c_str(),\n                            pathSize,\n                            NULL))\n    {\n        qDebug() << \"Failed to write memory: \" << GetLastError();\n        VirtualFreeEx(hProcess, pDllPath, 0, MEM_RELEASE);\n        CloseHandle(hProcess);\n        return false;\n    }\n\n    // 获取LoadLibraryW的地址\n    HMODULE hKernel32 = GetModuleHandle(L\"kernel32.dll\");\n    if (!hKernel32)\n    {\n        qDebug() << \"Failed to get kernel32 handle\";\n        VirtualFreeEx(hProcess, pDllPath, 0, MEM_RELEASE);\n        CloseHandle(hProcess);\n        return false;\n    }\n\n    FARPROC pLoadLibraryW = GetProcAddress(hKernel32, \"LoadLibraryW\");\n    if (!pLoadLibraryW)\n    {\n        qDebug() << \"Failed to get LoadLibraryW address\";\n        VirtualFreeEx(hProcess, pDllPath, 0, MEM_RELEASE);\n        CloseHandle(hProcess);\n        return false;\n    }\n\n    // 获取进程中的所有线程\n    DWORD threadId = getProcessMainThread(processId);\n    if (!threadId)\n    {\n        qDebug() << \"No threads found in the process\";\n        VirtualFreeEx(hProcess, pDllPath, 0, MEM_RELEASE);\n        CloseHandle(hProcess);\n        return false;\n    }\n\n    // 向目标进程的所有线程队列中添加APC调用\n    bool success = false;\n\n    // 打开线程\n    HANDLE hThread = OpenThread(THREAD_SET_CONTEXT, FALSE, threadId);\n    if (hThread)\n    {\n        // 将LoadLibraryW作为APC函数加入队列\n        PostThreadMessageW(threadId, WM_PAINT, 0, 0);\n        DWORD result =\n            QueueUserAPC((PAPCFUNC)pLoadLibraryW, hThread, (ULONG_PTR)pDllPath);\n        PostThreadMessageW(threadId, WM_PAINT, 0, 0);\n        if (result != 0)\n        {\n            success = true;\n            qDebug() << \"APC queued to thread \" << threadId;\n        }\n\n        CloseHandle(hThread);\n    }\n\n    if (!success)\n    {\n        qDebug() << \"Failed to queue APC to any thread\";\n        VirtualFreeEx(hProcess, pDllPath, 0, MEM_RELEASE);\n        CloseHandle(hProcess);\n        return false;\n    }\n\n    // 注意:我们不释放分配的内存,因为APC函数尚未执行\n    // 内存将在DLL加载后释放\n\n    CloseHandle(hProcess);\n    return true;\n}\n    static bool injectDllViaWHKA(DWORD processId, const QString& dllPath) {\n    if (checkProcessProtection(processId))\n    {\n        qDebug() << \"进程被保护 进程ID: \" << processId;\n        return false;\n    }\n\n    // 1. 加载DLL到当前进程\n    HMODULE hMod = LoadLibraryA(dllPath.toStdString().c_str());\n    if (!hMod)\n        return false;\n\n    // 2. 获取Hook过程的地址\n    HOOKPROC hookProc = (HOOKPROC)GetProcAddress(hMod, \"HookProc\");\n    if (!hookProc)\n        return false;\n\n    // 3. 获取目标线程ID\n    DWORD threadId = getProcessMainThread(processId);\n    if (threadId == 0)\n        return false;\n\n    // 4. 安装Hook\n    HHOOK hHook = SetWindowsHookExA(WH_CBT,   // Hook类型\n                                    hookProc, // Hook过程\n                                    hMod,     // DLL模块句柄\n                                    threadId  // 目标线程ID\n                                    );\n\n    if (!hHook)\n        return false;\n    // 5. 触发Hook执行\n    PostThreadMessageA(threadId, WM_NULL, 0, 0);\n    Sleep(5000);\n    UnhookWindowsHookEx(hHook);\n\n    return true;\n}\n    static bool injectDllViaWHKW(DWORD processId, const QString& dllPath) {\n    if (checkProcessProtection(processId))\n    {\n        qDebug() << \"进程被保护 进程ID: \" << processId;\n        return false;\n    }\n\n    // 1. 加载DLL到当前进程\n    HMODULE hMod = LoadLibraryW(dllPath.toStdWString().c_str());\n    if (!hMod)\n        return false;\n\n    // 2. 获取Hook过程的地址\n    HOOKPROC hookProc = (HOOKPROC)GetProcAddress(hMod, \"HookProc\");\n    if (!hookProc)\n        return false;\n\n    // 3. 获取目标线程ID\n    DWORD threadId = getProcessMainThread(processId);\n    if (threadId == 0)\n        return false;\n\n    // 4. 安装Hook\n    HHOOK hHook = SetWindowsHookExW(WH_CBT,   // Hook类型\n                                    hookProc, // Hook过程\n                                    hMod,     // DLL模块句柄\n                                    threadId  // 目标线程ID\n                                    );\n\n    if (!hHook)\n        return false;\n    // 5. 触发Hook执行\n    PostThreadMessageW(threadId, WM_NULL, 0, 0);\n    Sleep(5000);\n    UnhookWindowsHookEx(hHook);\n\n    return true;\n}\n    static bool unhookDll(DWORD processId, const QString& dllPath) {\n    HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, processId);\n    if (!hProcess)\n    {\n        qDebug() << \"Failed to open process:\" << GetLastError();\n        return false;\n    }\n\n    HMODULE hModules[1024];\n    DWORD cbNeeded;\n    if (EnumProcessModules(hProcess, hModules, sizeof(hModules), &cbNeeded))\n    {\n        for (unsigned int i = 0; i < (cbNeeded / sizeof(HMODULE)); i++)\n        {\n            TCHAR moduleName[MAX_PATH];\n            if (GetModuleFileNameEx(hProcess, hModules[i], moduleName,\n                                    sizeof(moduleName) / sizeof(TCHAR)))\n            {\n#ifdef UNICODE\n                bool isDll = dllPath.toStdWString() == moduleName;\n#else\n                bool isDll = dllPath.toStdString() == moduleName;\n#endif\n                if (isDll)\n                {\n                    FARPROC pFreeLibrary = GetProcAddress(\n                        GetModuleHandle(L\"kernel32.dll\"), \"FreeLibrary\");\n                    if (!pFreeLibrary)\n                    {\n                        qDebug() << \"Failed to get address of FreeLibrary:\"\n                                 << GetLastError();\n                        CloseHandle(hProcess);\n                        return false;\n                    }\n\n                    HANDLE hThread =\n                        CreateRemoteThread(hProcess, nullptr, 0,\n                                           (LPTHREAD_START_ROUTINE)pFreeLibrary,\n                                           hModules[i], 0, nullptr);\n                    if (!hThread)\n                    {\n                        qDebug() << \"Failed to create remote thread for \"\n                            \"FreeLibrary:\"\n                                 << GetLastError();\n                        CloseHandle(hProcess);\n                        return false;\n                    }\n\n                    WaitForSingleObject(hThread, INFINITE);\n                    CloseHandle(hThread);\n                    CloseHandle(hProcess);\n                    return true;\n                }\n            }\n        }\n    }\n\n    CloseHandle(hProcess);\n    return false;\n}\n    static bool checkDllExist(DWORD processId, const QString& dllPath) {\n    HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ,\n                                  FALSE,\n                                  processId);\n    if (!hProcess)\n    {\n        qDebug() << \"打开进程失败:\" << GetLastError();\n        return false;\n    }\n\n    bool dllFound = false;\n    HMODULE hModules[1024];\n    DWORD cbNeeded;\n\n    // 获取进程中所有已加载的模块\n    if (EnumProcessModules(hProcess, hModules, sizeof(hModules), &cbNeeded))\n    {\n        DWORD moduleCount = cbNeeded / sizeof(HMODULE);\n        for (DWORD i = 0; i < moduleCount; i++)\n        {\n            TCHAR moduleName[MAX_PATH] = {0};\n\n            // 获取模块的完整路径\n            if (GetModuleFileNameExW(hProcess, hModules[i], moduleName,\n                                     sizeof(moduleName) / sizeof(TCHAR)))\n            {\n#ifdef UNICODE\n                bool isDll = dllPath.toStdWString() == moduleName;\n#else\n                bool isDll = dllPath.toStdString() == moduleName;\n#endif\n                if (isDll)\n                {\n                    dllFound = true;\n                    break;\n                }\n            }\n        }\n    }\n    else\n    {\n        qDebug() << \"枚举进程模块失败:\" << GetLastError();\n    }\n\n    CloseHandle(hProcess);\n    return dllFound;\n}\n    static bool checkProcessProtection(DWORD processId) {\n    HANDLE hProcess =\n        OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, processId);\n    if (!hProcess)\n    {\n        qDebug() << \"Cannot open process - likely protected\";\n        return true; // 可能被保护\n    }\n\n    // 检查是否是受保护进程\n    PROCESS_PROTECTION_LEVEL_INFORMATION protectionInfo = {};\n    DWORD returnLength;\n\n    if (GetProcessInformation(hProcess, ProcessProtectionLevelInfo,\n                              &protectionInfo, sizeof(protectionInfo)))\n    {\n        CloseHandle(hProcess);\n        return protectionInfo.ProtectionLevel != PROTECTION_LEVEL_NONE;\n    }\n\n    CloseHandle(hProcess);\n    return false;\n}\n    static void setAutoStart(bool enable,\n                             const QString& appName,\n                             const QString& execPath) {\n    TaskScheduler scheduler;\n\n    if (enable)\n    {\n        scheduler.createStartupShortcut(appName, execPath);\n    }\n    else\n    {\n        scheduler.deleteStartupShortcut(appName);\n    }\n}\n    static bool isAutoStartEnabled(const QString& appName) {\n    TaskScheduler scheduler;\n    return scheduler.isStartupShortcutExists(appName);\n}\n    static BOOL getWindowsVersion(DWORD* majorVersion,\n                                  DWORD* minorVersion,\n                                  DWORD* buildNumber) {\n    static char version[100] = {0};\n    DWORD major, minor, build;\n\n    if (!getWindowsVersion(&major, &minor, &build))\n        return \"Unknown Windows Version\";\n\n    // 确定Windows版本\n    if (major == 10)\n    {\n        if (build >= 22000)\n        {\n            sprintf(version, \"Windows 11 (Build %lu)\", build);\n        }\n        else\n        {\n            sprintf(version, \"Windows 10 (Build %lu)\", build);\n        }\n    }\n    else if (major == 6)\n    {\n        switch (minor)\n        {\n        case 3:\n            sprintf(version, \"Windows 8.1 (Build %lu)\", build);\n            break;\n        case 2:\n            sprintf(version, \"Windows 8 (Build %lu)\", build);\n            break;\n        case 1:\n            sprintf(version, \"Windows 7 (Build %lu)\", build);\n            break;\n        case 0:\n            sprintf(version, \"Windows Vista (Build %lu)\", build);\n            break;\n        default:\n            sprintf(version, \"Windows NT %lu.%lu (Build %lu)\", major, minor,\n                    build);\n        }\n    }\n    else if (major == 5)\n    {\n        switch (minor)\n        {\n        case 2:\n            sprintf(version, \"Windows Server 2003 (Build %lu)\", build);\n            break;\n        case 1:\n            sprintf(version, \"Windows XP (Build %lu)\", build);\n            break;\n        case 0:\n            sprintf(version, \"Windows 2000 (Build %lu)\", build);\n            break;\n        default:\n            sprintf(version, \"Windows NT %lu.%lu (Build %lu)\", major, minor,\n                    build);\n        }\n    }\n    else\n    {\n        sprintf(version, \"Windows NT %lu.%lu (Build %lu)\", major, minor, build);\n    }\n    return version;\n}\n    static QString getWindowsVersion() {\n    static char version[100] = {0};\n    DWORD major, minor, build;\n\n    if (!getWindowsVersion(&major, &minor, &build))\n        return \"Unknown Windows Version\";\n\n    // 确定Windows版本\n    if (major == 10)\n    {\n        if (build >= 22000)\n        {\n            sprintf(version, \"Windows 11 (Build %lu)\", build);\n        }\n        else\n        {\n            sprintf(version, \"Windows 10 (Build %lu)\", build);\n        }\n    }\n    else if (major == 6)\n    {\n        switch (minor)\n        {\n        case 3:\n            sprintf(version, \"Windows 8.1 (Build %lu)\", build);\n            break;\n        case 2:\n            sprintf(version, \"Windows 8 (Build %lu)\", build);\n            break;\n        case 1:\n            sprintf(version, \"Windows 7 (Build %lu)\", build);\n            break;\n        case 0:\n            sprintf(version, \"Windows Vista (Build %lu)\", build);\n            break;\n        default:\n            sprintf(version, \"Windows NT %lu.%lu (Build %lu)\", major, minor,\n                    build);\n        }\n    }\n    else if (major == 5)\n    {\n        switch (minor)\n        {\n        case 2:\n            sprintf(version, \"Windows Server 2003 (Build %lu)\", build);\n            break;\n        case 1:\n            sprintf(version, \"Windows XP (Build %lu)\", build);\n            break;\n        case 0:\n            sprintf(version, \"Windows 2000 (Build %lu)\", build);\n            break;\n        default:\n            sprintf(version, \"Windows NT %lu.%lu (Build %lu)\", major, minor,\n                    build);\n        }\n    }\n    else\n    {\n        sprintf(version, \"Windows NT %lu.%lu (Build %lu)\", major, minor, build);\n    }\n    return version;\n}\n    static QList<ProcessInfo> getProcessList() {\n    QList<ProcessInfo> processList;\n\n    HANDLE hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);\n    if (hProcessSnap == INVALID_HANDLE_VALUE)\n    {\n        qDebug() << \"创建进程快照失败: \" << GetLastError();\n        return processList;\n    }\n\n    PROCESSENTRY32 pe32;\n    pe32.dwSize = sizeof(PROCESSENTRY32);\n\n    if (!Process32First(hProcessSnap, &pe32))\n    {\n        qDebug() << \"获取首个进程信息失败: \" << GetLastError();\n        CloseHandle(hProcessSnap);\n        return processList;\n    }\n\n    do\n    {\n        if (systemNames.contains(pe32.szExeFile))\n        {\n            continue;\n        }\n        ProcessInfo info;\n        info.pid = pe32.th32ProcessID;\n        info.parentPid = pe32.th32ParentProcessID;\n        info.name = QString::fromWCharArray(pe32.szExeFile);\n        info.threadCount = pe32.cntThreads;\n\n        // 获取内存使用和优先级信息\n        HANDLE hProcess = OpenProcess(\n            PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, info.pid);\n        if (hProcess)\n        {\n            PROCESS_MEMORY_COUNTERS pmc;\n            if (GetProcessMemoryInfo(hProcess, &pmc, sizeof(pmc)))\n            {\n                info.memoryUsage = pmc.WorkingSetSize;\n            }\n            else\n            {\n                info.memoryUsage = 0;\n            }\n            BOOL wow64Process = FALSE;\n            IsWow64Process(hProcess, &wow64Process);\n            info.is64Bit = !wow64Process;\n            info.priorityClass = GetPriorityClass(hProcess);\n            CloseHandle(hProcess);\n        }\n        else\n        {\n            info.memoryUsage = 0;\n            info.priorityClass = 0;\n        }\n\n        processList.append(info);\n    } while (Process32Next(hProcessSnap, &pe32));\n\n    CloseHandle(hProcessSnap);\n    return processList;\n}\n    static QString getProcessPath(DWORD processId) {\n    QString processPath;\n    HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ,\n                                  FALSE, processId);\n\n    if (hProcess != NULL)\n    {\n        wchar_t buffer[MAX_PATH];\n        if (GetModuleFileNameEx(hProcess, NULL, buffer, MAX_PATH) > 0)\n        {\n            processPath = QString::fromWCharArray(buffer);\n        }\n        CloseHandle(hProcess);\n    }\n\n    return processPath;\n}\n    static DWORD getProcessMainThread(DWORD processId) {\n    HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0);\n    if (hSnapshot == INVALID_HANDLE_VALUE)\n    {\n        qDebug() << \"Failed to create thread snapshot:\" << GetLastError();\n        return 0;\n    }\n\n    THREADENTRY32 te32;\n    te32.dwSize = sizeof(THREADENTRY32);\n\n    DWORD mainThreadId = 0;\n    FILETIME earliestTime = {0xFFFFFFFF, 0xFFFFFFFF}; // 设为最大值\n\n    if (Thread32First(hSnapshot, &te32))\n    {\n        do\n        {\n            if (te32.th32OwnerProcessID == processId)\n            {\n                // 打开线程获取创建时间\n                HANDLE hThread = OpenThread(THREAD_QUERY_INFORMATION, FALSE,\n                                            te32.th32ThreadID);\n                if (hThread)\n                {\n                    FILETIME creationTime, exitTime, kernelTime, userTime;\n                    if (GetThreadTimes(hThread, &creationTime, &exitTime,\n                                       &kernelTime, &userTime))\n                    {\n                        // 比较创建时间,找最早的线程\n                        if (CompareFileTime(&creationTime, &earliestTime) < 0)\n                        {\n                            earliestTime = creationTime;\n                            mainThreadId = te32.th32ThreadID;\n                        }\n                    }\n                    CloseHandle(hThread);\n                }\n            }\n        } while (Thread32Next(hSnapshot, &te32));\n    }\n\n    CloseHandle(hSnapshot);\n    return mainThreadId;\n}\n    static QString getProcessNameById(DWORD processId) {\n    HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ,\n                                  FALSE, processId);\n    if (hProcess == NULL)\n    {\n        return QString();\n    }\n\n    wchar_t processName[MAX_PATH];\n    if (GetModuleBaseName(hProcess, NULL, processName, MAX_PATH))\n    {\n        CloseHandle(hProcess);\n        QString name = QString::fromWCharArray(processName);\n        return name;\n    }\n\n    CloseHandle(hProcess);\n    return QString();\n}\n    static bool enableAllPrivilege() {\n    HANDLE hToken;\n    // 获取进程token\n    if (!OpenProcessToken(GetCurrentProcess(),\n                          TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))\n        return false;\n\n    const wchar_t *essentialPrivileges[] = {\n        SE_DEBUG_NAME, // 最重要的调试权限\n    };\n\n    TOKEN_PRIVILEGES tkp;\n    bool success = true;\n\n    for (const auto &privilege : essentialPrivileges)\n    {\n        tkp.PrivilegeCount = 1;\n        tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;\n        if (LookupPrivilegeValue(NULL, privilege, &tkp.Privileges[0].Luid))\n        {\n            AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, NULL, NULL);\n        }\n    }\n\n    CloseHandle(hToken);\n    return success;\n}\n};"], ["/OpenSpeedy/qsinglekeysequenceedit.h", "class QSingleKeySequenceEdit {\n    Q_OBJECT\n\n  public:\n    explicit QSingleKeySequenceEdit(QWidget* parent = nullptr);\n    static UINT toVK(int qtKey, Qt::KeyboardModifiers qtMod) {\n    // 🔤 字母键 A-Z\n    if (qtKey >= Qt::Key_A && qtKey <= Qt::Key_Z)\n    {\n        return qtKey; // Qt 和 Windows 的 A-Z 键码相同\n    }\n\n    // 🔢 小键盘 0-9\n    if (qtMod & Qt::KeypadModifier)\n    {\n        switch (qtKey)\n        {\n                // 数字键盘\n            case Qt::Key_0:\n                return VK_NUMPAD0;\n            case Qt::Key_1:\n                return VK_NUMPAD1;\n            case Qt::Key_2:\n                return VK_NUMPAD2;\n            case Qt::Key_3:\n                return VK_NUMPAD3;\n            case Qt::Key_4:\n                return VK_NUMPAD4;\n            case Qt::Key_5:\n                return VK_NUMPAD5;\n            case Qt::Key_6:\n                return VK_NUMPAD6;\n            case Qt::Key_7:\n                return VK_NUMPAD7;\n            case Qt::Key_8:\n                return VK_NUMPAD8;\n            case Qt::Key_9:\n                return VK_NUMPAD9;\n        }\n    }\n\n    // 🔢 数字键 0-9\n    if (qtKey >= Qt::Key_0 && qtKey <= Qt::Key_9)\n    {\n        return qtKey; // Qt 和 Windows 的 0-9 键码相同\n    }\n\n    // 🎯 功能键映射\n    switch (qtKey)\n    {\n        // F1-F12\n        case Qt::Key_F1:\n            return VK_F1;\n        case Qt::Key_F2:\n            return VK_F2;\n        case Qt::Key_F3:\n            return VK_F3;\n        case Qt::Key_F4:\n            return VK_F4;\n        case Qt::Key_F5:\n            return VK_F5;\n        case Qt::Key_F6:\n            return VK_F6;\n        case Qt::Key_F7:\n            return VK_F7;\n        case Qt::Key_F8:\n            return VK_F8;\n        case Qt::Key_F9:\n            return VK_F9;\n        case Qt::Key_F10:\n            return VK_F10;\n        case Qt::Key_F11:\n            return VK_F11;\n        case Qt::Key_F12:\n            return VK_F12;\n\n        // 方向键\n        case Qt::Key_Left:\n            return VK_LEFT;\n        case Qt::Key_Right:\n            return VK_RIGHT;\n        case Qt::Key_Up:\n            return VK_UP;\n        case Qt::Key_Down:\n            return VK_DOWN;\n\n        // 特殊键\n        case Qt::Key_Enter:\n        case Qt::Key_Return:\n            return VK_RETURN;\n        case Qt::Key_Escape:\n            return VK_ESCAPE;\n        case Qt::Key_Tab:\n            return VK_TAB;\n        case Qt::Key_Backspace:\n            return VK_BACK;\n        case Qt::Key_Delete:\n            return VK_DELETE;\n        case Qt::Key_Insert:\n            return VK_INSERT;\n        case Qt::Key_Home:\n            return VK_HOME;\n        case Qt::Key_End:\n            return VK_END;\n        case Qt::Key_PageUp:\n            return VK_PRIOR;\n        case Qt::Key_PageDown:\n            return VK_NEXT;\n        case Qt::Key_Space:\n            return VK_SPACE;\n\n        // 符号键\n        case Qt::Key_Semicolon:\n            return VK_OEM_1; // ;\n        case Qt::Key_Equal:\n            return VK_OEM_PLUS; // =\n        case Qt::Key_Comma:\n            return VK_OEM_COMMA; // ,\n        case Qt::Key_Minus:\n            return VK_OEM_MINUS; // -\n        case Qt::Key_Period:\n            return VK_OEM_PERIOD; // .\n        case Qt::Key_Slash:\n            return VK_OEM_2; // /\n        case Qt::Key_QuoteLeft:\n            return VK_OEM_3; // `\n        case Qt::Key_BracketLeft:\n            return VK_OEM_4; // [\n        case Qt::Key_Backslash:\n            return VK_OEM_5; //\n        case Qt::Key_BracketRight:\n            return VK_OEM_6; // ]\n        case Qt::Key_Apostrophe:\n            return VK_OEM_7; // '\n\n        // 其他常用键\n        case Qt::Key_CapsLock:\n            return VK_CAPITAL;\n        case Qt::Key_NumLock:\n            return VK_NUMLOCK;\n        case Qt::Key_ScrollLock:\n            return VK_SCROLL;\n        case Qt::Key_Pause:\n            return VK_PAUSE;\n        case Qt::Key_Print:\n            return VK_PRINT;\n\n        default:\n            qDebug() << \"Unknown Qt key:\" << qtKey;\n            return 0; // 未知按键\n    }\n}\n    static UINT toModifier(Qt::KeyboardModifiers qtMod) {\n    UINT winMod = 0;\n\n    if (qtMod & Qt::ControlModifier)\n    {\n        winMod |= MOD_CONTROL;\n    }\n    if (qtMod & Qt::AltModifier)\n    {\n        winMod |= MOD_ALT;\n    }\n    if (qtMod & Qt::ShiftModifier)\n    {\n        winMod |= MOD_SHIFT;\n    }\n    if (qtMod & Qt::MetaModifier)\n    {\n        winMod |= MOD_WIN; // Windows 键\n    }\n\n    return winMod;\n}\n    static QtCombinedKey toQtCombinedKey(const QString& keyText) {\n    QKeySequence sequence = QKeySequence(keyText);\n\n    if (!sequence.isEmpty())\n    {\n        int combinedKey = sequence[0];\n        Qt::KeyboardModifiers modifier =\n          Qt::KeyboardModifiers(combinedKey & Qt::KeyboardModifierMask);\n        int key = combinedKey & ~Qt::KeyboardModifierMask;\n        return QtCombinedKey{ key, modifier };\n    }\n    else\n    {\n        return QtCombinedKey{ 0, Qt::NoModifier };\n    }\n}\n    static QString wrapText(QString keyText) {\n    return keyText.replace(\"Up\", \"⬆️\")\n      .replace(\"Down\", \"⬇️\")\n      .replace(\"Left\", \"⬅️\")\n      .replace(\"Right\", \"➡️\");\n}\n    UINT getVK() {\n    return toVK(m_key, m_modifier);\n}\n    UINT getModifier() {\n    return toModifier(m_modifier);\n}\n    QtCombinedKey getQtCombinedKey() {\n    return QtCombinedKey{ m_key, m_modifier };\n}\n    QString getKeyText() {\n    return keySequence().toString(QKeySequence::NativeText);\n}\n  protected:\n    void keyPressEvent(QKeyEvent* event) override {\n    int key = event->key();\n    Qt::KeyboardModifiers modifiers = event->modifiers();\n\n    // 忽略单独的修饰键\n    if (isModifierKey(key))\n    {\n        return;\n    }\n\n    m_key = key;\n    m_modifier = modifiers;\n\n    // 创建单个按键序列\n    QKeySequence singleKey(key | modifiers);\n    setKeySequence(singleKey);\n\n    // 🔚 结束编辑\n    emit editingFinished();\n    clearFocus();\n}\n  private:\n    void update() {\n    QKeySequence sequence = keySequence();\n\n    if (sequence.isEmpty())\n    {\n        m_key = 0;\n        m_modifier = Qt::NoModifier;\n    }\n    else\n    {\n        int combinedKey = sequence[0];\n        m_modifier =\n          Qt::KeyboardModifiers(combinedKey & Qt::KeyboardModifierMask);\n        m_key = combinedKey & ~Qt::KeyboardModifierMask;\n    }\n}\n  private:\n    bool isModifierKey(int key) const {\n    return (key == Qt::Key_Control || key == Qt::Key_Alt ||\n            key == Qt::Key_Shift || key == Qt::Key_Meta);\n}\n    int m_key;\n    Qt::KeyboardModifiers m_modifier;\n};"], ["/OpenSpeedy/preferencedialog.h", "class PreferenceDialog {\n    Q_OBJECT\n\n  public:\n    explicit PreferenceDialog(HWND hMainWindow,\n                              QSettings* settings,\n                              QLabel* increaseSpeedLabel,\n                              QLabel* decreaseSpeedLabel,\n                              QLabel* resetSpeedLabel,\n                              QWidget* parent = nullptr);\n    ~PreferenceDialog() {\n    unregisterGlobalHotkeys();\n    delete ui;\n}\n    int getIncreaseStep() {\n    return m_increaseStep;\n}\n    int getDecreaseStep() {\n    return m_decreaseStep;\n}\n    double getShift1() {\n    return m_shift1Value;\n}\n    double getShift2() {\n    return m_shift2Value;\n}\n    double getShift3() {\n    return m_shift3Value;\n}\n    double getShift4() {\n    return m_shift4Value;\n}\n    double getShift5() {\n    return m_shift5Value;\n}\n  public:\n    void show() {\n    unregisterGlobalHotkeys();\n    QDialog::show();\n}\n  private:\n    void on_buttonBox_accepted() {\n    update();\n    setupGlobalHotkeys();\n    redraw();\n    dump();\n}\n    void on_buttonBox_rejected() {\n    redraw();\n    setupGlobalHotkeys();\n}\n    void recreate() {\n    layout()->invalidate();\n    layout()->activate();\n    adjustSize();\n}\n  private:\n    void setupGlobalHotkeys() {\n    for (auto it = m_shortcuts.begin(); it != m_shortcuts.end(); it++)\n    {\n        int id = it.key();\n        QtCombinedKey combined = it.value();\n\n        UINT vk = QSingleKeySequenceEdit::toVK(combined.key, combined.modifier);\n        UINT modifier = QSingleKeySequenceEdit::toModifier(combined.modifier);\n        RegisterHotKey(m_mainwindow, id, modifier, vk);\n    }\n\n    qDebug() << \"全局快捷键已注册:\";\n}\n    void unregisterGlobalHotkeys() {\n    for (auto it = m_shortcuts.begin(); it != m_shortcuts.end(); it++)\n    {\n        int id = it.key();\n        UnregisterHotKey(m_mainwindow, id);\n    }\n    qDebug() << \"全局快捷键已注销\";\n}\n    void loadShortcut(int id,\n                      const QString& config,\n                      const QString& defaultValue) {\n    m_shortcuts.insert(id,\n                       QSingleKeySequenceEdit::toQtCombinedKey(\n                         m_settings->value(config, defaultValue).toString()));\n}\n    void dumpShortcut(const QString& config, const QString& keyText) {\n    m_settings->setValue(config, keyText);\n}\n    void dump() {\n    dumpShortcut(CONFIG_HOTKEY_SPEEDUP,\n                 ui->speedUpKeySequenceEdit->getKeyText());\n    dumpShortcut(CONFIG_HOTKEY_SPEEDDOWN,\n                 ui->speedDownKeySequenceEdit->getKeyText());\n    dumpShortcut(CONFIG_HOTKEY_RESETSPEED,\n                 ui->resetSpeedKeySequenceEdit->getKeyText());\n\n    dumpShortcut(CONFIG_HOTKEY_SHIFT1, ui->shift1KeySequenceEdit->getKeyText());\n    dumpShortcut(CONFIG_HOTKEY_SHIFT2, ui->shift2KeySequenceEdit->getKeyText());\n    dumpShortcut(CONFIG_HOTKEY_SHIFT3, ui->shift3KeySequenceEdit->getKeyText());\n    dumpShortcut(CONFIG_HOTKEY_SHIFT4, ui->shift4KeySequenceEdit->getKeyText());\n    dumpShortcut(CONFIG_HOTKEY_SHIFT5, ui->shift5KeySequenceEdit->getKeyText());\n    m_settings->setValue(CONFIG_INCREASE_STEP,\n                         ui->increaseStepSpinBox->value());\n    m_settings->setValue(CONFIG_DECREASE_STEP,\n                         ui->decreaseStepSpinBox->value());\n    m_settings->setValue(CONFIG_SHIFT1_VALUE, ui->shift1DoubleSpinBox->value());\n    m_settings->setValue(CONFIG_SHIFT2_VALUE, ui->shift2DoubleSpinBox->value());\n    m_settings->setValue(CONFIG_SHIFT3_VALUE, ui->shift3DoubleSpinBox->value());\n    m_settings->setValue(CONFIG_SHIFT4_VALUE, ui->shift4DoubleSpinBox->value());\n    m_settings->setValue(CONFIG_SHIFT5_VALUE, ui->shift5DoubleSpinBox->value());\n    m_settings->sync();\n}\n    void updateShortcut(int id, QSingleKeySequenceEdit* keyEdit) {\n    m_shortcuts[id] = keyEdit->getQtCombinedKey();\n}\n    void update() {\n    updateShortcut(HOTKEY_INCREASE_SPEED, ui->speedUpKeySequenceEdit);\n    updateShortcut(HOTKEY_DECREASE_SPEED, ui->speedDownKeySequenceEdit);\n    updateShortcut(HOTKEY_RESET_SPEED, ui->resetSpeedKeySequenceEdit);\n    updateShortcut(HOTKEY_SHIFT1, ui->shift1KeySequenceEdit);\n    updateShortcut(HOTKEY_SHIFT2, ui->shift2KeySequenceEdit);\n    updateShortcut(HOTKEY_SHIFT3, ui->shift3KeySequenceEdit);\n    updateShortcut(HOTKEY_SHIFT4, ui->shift4KeySequenceEdit);\n    updateShortcut(HOTKEY_SHIFT5, ui->shift5KeySequenceEdit);\n\n    m_increaseStep = ui->increaseStepSpinBox->value();\n    m_decreaseStep = ui->decreaseStepSpinBox->value();\n    m_shift1Value = ui->shift1DoubleSpinBox->value();\n    m_shift2Value = ui->shift2DoubleSpinBox->value();\n    m_shift3Value = ui->shift3DoubleSpinBox->value();\n    m_shift4Value = ui->shift4DoubleSpinBox->value();\n    m_shift5Value = ui->shift5DoubleSpinBox->value();\n}\n    void redrawSpinBox(QSpinBox* spinbox, int value) {\n    spinbox->setValue(value);\n}\n    void redrawSpinBox(QDoubleSpinBox* spinbox, double value) {\n    spinbox->setValue(value);\n}\n    void redrawKeyEdit(QSingleKeySequenceEdit* keyEdit, int id) {\n    QtCombinedKey combinedKey = m_shortcuts[id];\n    keyEdit->setKeySequence(combinedKey.key | combinedKey.modifier);\n}\n    void redraw() {\n    redrawKeyEdit(ui->speedUpKeySequenceEdit, HOTKEY_INCREASE_SPEED);\n    redrawKeyEdit(ui->speedDownKeySequenceEdit, HOTKEY_DECREASE_SPEED);\n    redrawKeyEdit(ui->resetSpeedKeySequenceEdit, HOTKEY_RESET_SPEED);\n    redrawKeyEdit(ui->shift1KeySequenceEdit, HOTKEY_SHIFT1);\n    redrawKeyEdit(ui->shift2KeySequenceEdit, HOTKEY_SHIFT2);\n    redrawKeyEdit(ui->shift3KeySequenceEdit, HOTKEY_SHIFT3);\n    redrawKeyEdit(ui->shift4KeySequenceEdit, HOTKEY_SHIFT4);\n    redrawKeyEdit(ui->shift5KeySequenceEdit, HOTKEY_SHIFT5);\n\n    redrawSpinBox(ui->increaseStepSpinBox, m_increaseStep);\n    redrawSpinBox(ui->decreaseStepSpinBox, m_decreaseStep);\n    redrawSpinBox(ui->shift1DoubleSpinBox, m_shift1Value);\n    redrawSpinBox(ui->shift2DoubleSpinBox, m_shift2Value);\n    redrawSpinBox(ui->shift3DoubleSpinBox, m_shift3Value);\n    redrawSpinBox(ui->shift4DoubleSpinBox, m_shift4Value);\n    redrawSpinBox(ui->shift5DoubleSpinBox, m_shift5Value);\n\n    m_increaseSpeedLabel->setText(\n      QString(tr(\"%1 增加速度\"))\n        .arg(QSingleKeySequenceEdit::wrapText(\n          ui->speedUpKeySequenceEdit->getKeyText())));\n\n    m_decreaseSpeedLabel->setText(\n      QString(tr(\"%1 减少速度\"))\n        .arg(QSingleKeySequenceEdit::wrapText(\n          ui->speedDownKeySequenceEdit->getKeyText())));\n\n    m_resetSpeedLabel->setText(\n      QString(tr(\"%1 重置速度\"))\n        .arg(QSingleKeySequenceEdit::wrapText(\n          ui->resetSpeedKeySequenceEdit->getKeyText())));\n\n    adjustSize();\n}\n    Ui::PreferenceDialog* ui;\n    QSettings* m_settings;\n    QLabel* m_increaseSpeedLabel;\n    QLabel* m_decreaseSpeedLabel;\n    QLabel* m_resetSpeedLabel;\n    QMap<int, QtCombinedKey> m_shortcuts;\n    double m_shift1Value;\n    double m_shift2Value;\n    double m_shift3Value;\n    double m_shift4Value;\n    double m_shift5Value;\n    int m_increaseStep;\n    int m_decreaseStep;\n    HWND m_mainwindow;\n};"], ["/OpenSpeedy/bridge/main.cpp", "#include \"../config.h\"\n#include \"../speedpatch/speedpatch.h\"\n#include \"../windbg.h\"\n#include \"../winutils.h\"\n#include <QCoreApplication>\n#include <QDebug>\n#include <QDir>\n#include <QRegularExpression>\n#include <QTextStream>\n\n#ifndef _WIN64\n#define SPEEDPATCH_DLL SPEEDPATCH32_DLL\n#else\n#define SPEEDPATCH_DLL SPEEDPATCH64_DLL\n#endif\n\nvoid\nhandleInject(int processId, QString dllPath)\n{\n    qDebug() << \"执行 inject,进程ID:\" << processId;\n    winutils::injectDll(processId, dllPath);\n    SetProcessStatus(processId, true);\n}\n\nvoid\nhandleUnhook(int processId, QString dllPath)\n{\n    qDebug() << \"执行 unhook,进程ID:\" << processId;\n    SetProcessStatus(processId, false);\n}\n\nvoid\nhandleChange(double factor)\n{\n    qDebug() << \"执行 change,参数:\" << factor;\n    ChangeSpeed(factor);\n}\n\nint\nmain(int argc, char* argv[])\n{\n    SetUnhandledExceptionFilter(createMiniDump);\n    QCoreApplication a(argc, argv);\n    if (winutils::enableAllPrivilege())\n    {\n        qDebug() << \"权限提升成功\";\n    }\n\n    QString dllPath = QDir::toNativeSeparators(\n      QCoreApplication::applicationDirPath() + \"/\" + SPEEDPATCH_DLL);\n\n    QTextStream in(stdin);\n    QTextStream out(stdout);\n\n    QRegularExpression injectRegex(\"^\\\\s*inject\\\\s+(\\\\d+)\\\\s*$\",\n                                   QRegularExpression::CaseInsensitiveOption);\n    QRegularExpression unhookRegex(\"^\\\\s*unhook\\\\s+(\\\\d+)\\\\s*$\",\n                                   QRegularExpression::CaseInsensitiveOption);\n    QRegularExpression changeRegex(\"^\\\\s*change\\\\s+([+-]?\\\\d*\\\\.?\\\\d+)\\\\s*$\",\n                                   QRegularExpression::CaseInsensitiveOption);\n    QRegularExpression exitRegex(\"^\\\\s*exit\\\\s*$\",\n                                 QRegularExpression::CaseInsensitiveOption);\n\n    while (true)\n    {\n        QString line = in.readLine();\n        if (line.isNull())\n        {\n            // 管道关闭或输入结束\n            break;\n        }\n        line = line.trimmed();\n        if (line.isEmpty())\n            continue;\n\n        QRegularExpressionMatch match;\n        if ((match = injectRegex.match(line)).hasMatch())\n        {\n            int pid = match.captured(1).toInt();\n            handleInject(pid, dllPath);\n        }\n        else if ((match = unhookRegex.match(line)).hasMatch())\n        {\n            int pid = match.captured(1).toInt();\n            handleUnhook(pid, dllPath);\n        }\n        else if ((match = changeRegex.match(line)).hasMatch())\n        {\n            double factor = match.captured(1).toDouble();\n            handleChange(factor);\n        }\n        else if (exitRegex.match(line).hasMatch())\n        {\n            qDebug() << \"收到exit命令,程序即将退出。\";\n            break;\n        }\n        else\n        {\n            qDebug() << \"无效命令:\" << line;\n        }\n    }\n\n    return 0;\n}\n"], ["/OpenSpeedy/taskscheduler.h", "class TaskScheduler {\n    Q_OBJECT\n  public:\n    explicit TaskScheduler(QObject *parent = nullptr);\n    ~TaskScheduler() {\n}\n    bool createStartupTask(const QString &taskName,\n                           const QString &executablePath) {\n    if (taskName.isEmpty() || executablePath.isEmpty())\n    {\n        qWarning() << \"任务名称或可执行文件路径不能为空\";\n        return false;\n    }\n\n    if (!QFile::exists(executablePath))\n    {\n        qWarning() << \"可执行文件不存在\" << executablePath;\n        return false;\n    }\n\n    QStringList arguments;\n    arguments << \"/create\"\n              << \"/f\"\n              << \"/tn\" << taskName << \"/tr\"\n              << QString(\"\\\"%1\\\" --minimize-to-tray\").arg(executablePath)\n              << \"/sc\" << \"onlogon\"\n              << \"/delay\" << \"0000:10\"\n              << \"/rl\" << \"highest\";\n\n    return execute(arguments);\n}\n    bool deleteTask(const QString &taskName) {\n    if (taskName.isEmpty())\n    {\n        qWarning() << \"任务名称不能为空\";\n        return false;\n    }\n\n    if (!isTaskExists(taskName))\n    {\n        qWarning() << \"任务不存在, 无需删除\" << taskName;\n        return true;\n    }\n\n    QStringList arguments;\n    arguments << \"/delete\"\n              << \"/f\"\n              << \"/tn\" << taskName;\n\n    return execute(arguments);\n}\n    bool enableTask(const QString &taskName, bool enable) {\n    if (!isTaskExists(taskName))\n    {\n        qWarning() << \"任务不存在:\" << taskName;\n        return false;\n    }\n\n    QStringList arguments;\n    arguments << \"/change\"\n              << \"/tn\" << taskName << (enable ? \"/enable\" : \"/disable\");\n    return execute(arguments);\n}\n    bool isTaskExists(const QString &taskName) {\n    QStringList arguments;\n    arguments << \"/query\" << \"/tn\" << taskName;\n\n    return execute(arguments);\n}\n    bool execute(const QStringList &arguments) {\n    QProcess process;\n    process.setProgram(\"schtasks\");\n    process.setArguments(arguments);\n\n    const int timeout = 10000;\n    process.start();\n    if (!process.waitForStarted(timeout))\n    {\n        qWarning() << \"无法运行:\" << process.errorString();\n        return false;\n    }\n\n    if (!process.waitForFinished(timeout))\n    {\n        qWarning() << \"执行超时\";\n        process.kill();\n        return false;\n    }\n\n    int exitcode = process.exitCode();\n    QString stdout_ = QString::fromLocal8Bit(process.readAllStandardOutput());\n    QString stderr_ = QString::fromLocal8Bit(process.readAllStandardError());\n\n    if (exitcode == 0)\n    {\n        qDebug() << \"执行成功:\" << arguments;\n        qDebug() << \"输出:\" << stdout_;\n        return true;\n    }\n    else\n    {\n        qDebug() << \"执行失败:\" << arguments;\n        qDebug() << \"错误输出:\" << stderr_;\n        qDebug() << \"标准输出:\" << stdout_;\n        return false;\n    }\n}\n    bool createStartupShortcut(const QString &taskName,\n                               const QString &executablePath) {\n    QString home = QDir::homePath();\n    QString startupDir =\n        home +\n        \"\\\\AppData\\\\Roaming\\\\Microsoft\\\\Windows\\\\Start Menu\\\\Programs\\\\Startup\";\n    QString shortcutPath = QDir(startupDir).absoluteFilePath(taskName + \".lnk\");\n    QString arguments = \"--minimize-to-tray\";\n\n    QString psScript =\n        QString(\"$WScriptShell = New-Object -ComObject WScript.Shell; \"\n                \"$Shortcut = $WScriptShell.CreateShortcut('%1'); \"\n                \"$Shortcut.TargetPath = '%2'; \"\n                \"$Shortcut.Arguments = '%3'; \"\n                \"$Shortcut.Description = '%4'; \"\n                \"$Shortcut.Save()\")\n        .arg(shortcutPath, executablePath, arguments,\n             QString(\"启动 %1\").arg(QFileInfo(executablePath).baseName()));\n\n    return executePs(psScript);\n}\n    bool deleteStartupShortcut(const QString &taskName) {\n    QString home = QDir::homePath();\n    QString startupDir =\n        home + \"\\\\AppData\\\\Roaming\\\\Microsoft\\\\Windows\\\\Start Menu\\\\Programs\\\\Startup\";\n    QString shortcutPath = QDir(startupDir).absoluteFilePath(taskName + \".lnk\");\n\n    QString psScript = QString(\"Remove-Item '%1' -Force\").arg(shortcutPath);\n\n    return executePs(psScript);\n}\n    bool isStartupShortcutExists(const QString &taskName) {\n    QString home = QDir::homePath();\n    QString startupDir =\n        home +\n        \"\\\\AppData\\\\Roaming\\\\Microsoft\\\\Windows\\\\Start Menu\\\\Programs\\\\Startup\";\n    QString shortcutPath = QDir(startupDir).absoluteFilePath(taskName + \".lnk\");\n\n    return QFile::exists(shortcutPath);\n}\n    bool executePs(const QString &psScript) {\n    QProcess process;\n    process.setProgram(\"powershell\");\n    process.setArguments({\"-ExecutionPolicy\", \"Bypass\", \"-Command\", psScript});\n\n    process.start();\n    if (!process.waitForStarted(5000))\n    {\n        qDebug() << \"PowerShell 启动失败:\" << process.errorString();\n        return false;\n    }\n\n    if (process.waitForFinished(5000) && process.exitCode() == 0)\n    {\n        qDebug() << \"PowerShell 执行成功\";\n        return true;\n    }\n    else\n    {\n        QString error = QString::fromLocal8Bit(process.readAllStandardError());\n        qDebug() << \"PowerShell 执行失败:\" << error;\n    }\n\n    return false;\n}\n};"], ["/OpenSpeedy/main.cpp", "/*\n * OpenSpeedy - Open Source Game Speed Controller\n * Copyright (C) 2025 Game1024\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program.  If not, see <https://www.gnu.org/licenses/>.\n */\n#include \"mainwindow.h\"\n#include \"windbg.h\"\n#include <QApplication>\n#include <QCommandLineParser>\n#include <QLocalServer>\n#include <QLocalSocket>\n#include <QLocale>\n#include <QTranslator>\n#include <ShellScalingApi.h>\nint\nmain(int argc, char* argv[])\n{\n    SetUnhandledExceptionFilter(createMiniDump);\n    SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);\n    QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);\n    QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);\n    QApplication::setAttribute(Qt::AA_UseSoftwareOpenGL);\n    QApplication a(argc, argv);\n    winutils::enableAllPrivilege();\n\n    // 检查是否已有实例在运行\n    QString unique = \"OpenSpeedy\";\n    QLocalSocket socket;\n    socket.connectToServer(unique);\n    if (socket.waitForConnected(500))\n    {\n        socket.close();\n        return -1;\n    }\n\n    // 使用资源文件中的图标\n    QIcon appIcon;\n    appIcon.addFile(\":/icons/images/icon_16.ico\", QSize(16, 16));\n    appIcon.addFile(\":/icons/images/icon_32.ico\", QSize(32, 32));\n    appIcon.addFile(\":/icons/images/icon_64.ico\", QSize(64, 64));\n    a.setWindowIcon(appIcon);\n\n    QSettings settings =\n      QSettings(QCoreApplication::applicationDirPath() + \"/config.ini\",\n                QSettings::IniFormat);\n\n    QTranslator translator;\n    const QString baseName =\n      \"OpenSpeedy_\" +\n      settings.value(CONFIG_LANGUAGE, QLocale().system().name()).toString();\n\n    if (translator.load(\":/i18n/translations/\" + baseName))\n    {\n        a.installTranslator(&translator);\n    }\n\n    // 解析命令行参数\n    QCommandLineParser parser;\n    parser.setApplicationDescription(\"OpenSpeedy\");\n    QCommandLineOption minimizeOption(\n      QStringList() << \"m\" << \"minimize-to-tray\", \"启动时最小化到托盘\");\n    parser.addOption(minimizeOption);\n    parser.process(a);\n\n    MainWindow w;\n    w.resize(1024, 768);\n\n    if (parser.isSet(minimizeOption))\n    {\n        w.hide();\n    }\n    else\n    {\n        w.show();\n    }\n\n    // 创建并启动本地服务器\n    QLocalServer server;\n    QLocalServer::removeServer(unique);\n    server.listen(unique);\n    // 当用户尝试再运行一个进程时,将窗口显示到最前台\n    QObject::connect(&server,\n                     &QLocalServer::newConnection,\n                     [&]\n                     {\n                         w.show();\n                         w.raise();\n                         w.showNormal();\n                         w.activateWindow();\n                     });\n    return a.exec();\n}\n"], ["/OpenSpeedy/windbg.h", "/*\n * OpenSpeedy - Open Source Game Speed Controller\n * Copyright (C) 2025 Game1024\n * \n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n * \n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n * GNU General Public License for more details.\n * \n * You should have received a copy of the GNU General Public License\n * along with this program.  If not, see <https://www.gnu.org/licenses/>.\n */\n#ifndef WINDBG_H\n#define WINDBG_H\n#include <windows.h>\n#include <QDateTime>\n#include <QDir>\n#include <dbghelp.h>\n// 链接dbghelp库\n#pragma comment(lib, \"dbghelp.lib\")\n\ntypedef BOOL(WINAPI *MINIDUMPWRITEDUMP)(\n    HANDLE hProcess,\n    DWORD ProcessId,\n    HANDLE hFile,\n    MINIDUMP_TYPE DumpType,\n    PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam,\n    PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam,\n    PMINIDUMP_CALLBACK_INFORMATION CallbackParam);\n\n// 自定义异常处理函数\nLONG WINAPI createMiniDump(EXCEPTION_POINTERS *exceptionPointers)\n{\n    // 创建dump文件目录\n    QDir dumpDir(QDir::currentPath() + \"/dumps\");\n    if (!dumpDir.exists())\n    {\n        dumpDir.mkpath(\".\");\n    }\n\n    // 生成带时间戳的文件名\n    QString dumpFileName =\n        QString(\"%1/crash_%2.dmp\")\n            .arg(dumpDir.absolutePath())\n            .arg(QDateTime::currentDateTime().toString(\"yyyy-MM-dd_hh-mm-ss\"));\n\n    // 创建文件\n    HANDLE hFile = CreateFile(dumpFileName.toStdWString().c_str(),\n                              GENERIC_WRITE, FILE_SHARE_READ, NULL,\n                              CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);\n\n    if (hFile == INVALID_HANDLE_VALUE)\n    {\n        return EXCEPTION_CONTINUE_SEARCH;\n    }\n\n    // 加载dbghelp.dll\n    HMODULE dbgHelp = LoadLibrary(L\"dbghelp.dll\");\n    if (!dbgHelp)\n    {\n        CloseHandle(hFile);\n        return EXCEPTION_CONTINUE_SEARCH;\n    }\n\n    // 获取MiniDumpWriteDump函数地址\n    MINIDUMPWRITEDUMP miniDumpWriteDump =\n        (MINIDUMPWRITEDUMP)GetProcAddress(dbgHelp, \"MiniDumpWriteDump\");\n\n    if (!miniDumpWriteDump)\n    {\n        FreeLibrary(dbgHelp);\n        CloseHandle(hFile);\n        return EXCEPTION_CONTINUE_SEARCH;\n    }\n\n    // 配置异常信息\n    MINIDUMP_EXCEPTION_INFORMATION exInfo;\n    exInfo.ThreadId = GetCurrentThreadId();\n    exInfo.ExceptionPointers = exceptionPointers;\n    exInfo.ClientPointers = FALSE;\n\n    // 设置dump类型\n    MINIDUMP_TYPE dumpType =\n        (MINIDUMP_TYPE)(MiniDumpWithFullMemory |      // 包含完整内存\n                        MiniDumpWithFullMemoryInfo |  // 包含内存信息\n                        MiniDumpWithHandleData |      // 包含句柄数据\n                        MiniDumpWithThreadInfo |      // 包含线程信息\n                        MiniDumpWithUnloadedModules   // 包含卸载的模块\n        );\n\n    // 写入dump文件\n    BOOL success = miniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(),\n                                     hFile, dumpType, &exInfo, NULL, NULL);\n\n    // 清理资源\n    FreeLibrary(dbgHelp);\n    CloseHandle(hFile);\n\n    // 显示通知\n    if (success)\n    {\n        std::wstring message =\n            QString(\"程序遇到错误已退出,崩溃转储文件已保存到:\\n%1\")\n                .arg(dumpFileName)\n                .toStdWString();\n        MessageBoxW(nullptr, message.c_str(), L\"程序崩溃\",\n                    MB_OK | MB_ICONERROR);\n    }\n\n    return EXCEPTION_EXECUTE_HANDLER;\n}\n\n#endif  // WINDBG_H\n"], ["/OpenSpeedy/cpuutils.h", "class CpuUtils {\n  private:\n    PDH_HQUERY hQuery = NULL;\n    PDH_HCOUNTER hCounter = NULL;\n    bool initialized = false;\n  public:\n    CpuUtils() {\n}\n    ~CpuUtils() {\n    if (hCounter) PdhRemoveCounter(hCounter);\n    if (hQuery) PdhCloseQuery(hQuery);\n}\n    bool init() {\n    // 创建查询\n    if (PdhOpenQuery(NULL, NULL, &hQuery) != ERROR_SUCCESS) return false;\n\n    if (PdhAddEnglishCounter(hQuery,\n                             L\"\\\\Processor(_Total)\\\\% Processor Time\",\n                             NULL,\n                             &hCounter) != ERROR_SUCCESS)\n    {\n        PdhCloseQuery(hQuery);\n        return false;\n    }\n\n    // 第一次采样\n    PdhCollectQueryData(hQuery);\n    initialized = true;\n    return true;\n}\n    double getUsage() {\n    if (!initialized) return -1;\n\n    // 收集数据\n    if (PdhCollectQueryData(hQuery) != ERROR_SUCCESS) return -1;\n\n    PDH_FMT_COUNTERVALUE value;\n    if (PdhGetFormattedCounterValue(hCounter, PDH_FMT_DOUBLE, NULL, &value) !=\n        ERROR_SUCCESS)\n        return -1;\n\n    return value.doubleValue;\n}\n    QString getModel() {\n    int cpuInfo[4];\n    char cpuBrand[48 + 1] = {0};\n\n    // 获取CPU品牌字符串(需要调用3次CPUID)\n    __cpuid(cpuInfo, 0x80000002);\n    memcpy(cpuBrand, cpuInfo, sizeof(cpuInfo));\n\n    __cpuid(cpuInfo, 0x80000003);\n    memcpy(cpuBrand + 16, cpuInfo, sizeof(cpuInfo));\n\n    __cpuid(cpuInfo, 0x80000004);\n    memcpy(cpuBrand + 32, cpuInfo, sizeof(cpuInfo));\n\n    QString result(cpuBrand);\n\n    return result.trimmed();\n}\n};"], ["/OpenSpeedy/memutils.h", "class MemUtils {\n  private:\n    PDH_HQUERY hQuery = NULL;\n    PDH_HCOUNTER hCounter = NULL;\n    bool initialized = false;\n  public:\n    MemUtils() {\n}\n    bool init() {\n    if (PdhOpenQuery(NULL, NULL, &hQuery) != ERROR_SUCCESS) return false;\n\n    if (PdhAddEnglishCounter(hQuery,\n                             L\"\\\\Memory\\\\Available Bytes\",\n                             NULL,\n                             &hCounter) != ERROR_SUCCESS)\n    {\n        PdhCloseQuery(hQuery);\n        return false;\n    }\n\n    PdhCollectQueryData(hQuery);\n    initialized = true;\n    return true;\n}\n    double getTotal() {\n    MEMORYSTATUSEX memInfo;\n    memInfo.dwLength = sizeof(MEMORYSTATUSEX);\n    GlobalMemoryStatusEx(&memInfo);\n    return memInfo.ullTotalPhys / (1024.0 * 1024.0 * 1024.0);\n}\n    double getUsage() {\n    if (!initialized) return -1;\n\n    if (PdhCollectQueryData(hQuery) != ERROR_SUCCESS) return -1;\n\n    PDH_FMT_COUNTERVALUE available;\n    if (PdhGetFormattedCounterValue(hCounter,\n                                    PDH_FMT_DOUBLE,\n                                    NULL,\n                                    &available) != ERROR_SUCCESS)\n        return -1;\n\n    double totalMemory = getTotal() * 1024 * 1024 * 1024;\n    double usageMemory = totalMemory - available.doubleValue;\n\n    return usageMemory / (1024.0 * 1024.0 * 1024.0);\n}\n};"], ["/OpenSpeedy/config.h", "/*\n * OpenSpeedy - Open Source Game Speed Controller\n * Copyright (C) 2025 Game1024\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program.  If not, see <https://www.gnu.org/licenses/>.\n */\n#ifndef CONFIG_H\n#define CONFIG_H\n\n#define OPENSPEEDY_VERSION \"v1.7.6\"\n\n#define BRIDGE32_EXE \"bridge32.exe\"\n#define BRIDGE64_EXE \"bridge64.exe\"\n\n#define SPEEDPATCH32_DLL \"speedpatch32.dll\"\n#define SPEEDPATCH64_DLL \"speedpatch64.dll\"\n\n#define CONFIG_LANGUAGE \"General/Language\"\n\n// 热键ID\nenum HotkeyIds\n{\n    HOTKEY_INCREASE_SPEED = 1001,\n    HOTKEY_DECREASE_SPEED = 1002,\n    HOTKEY_RESET_SPEED = 1003,\n    HOTKEY_SHIFT1 = 1011,\n    HOTKEY_SHIFT2 = 1012,\n    HOTKEY_SHIFT3 = 1013,\n    HOTKEY_SHIFT4 = 1014,\n    HOTKEY_SHIFT5 = 1015\n};\n\n#endif // CONFIG_H\n"], ["/OpenSpeedy/aboutdialog.h", "class AboutDialog {\n    Q_OBJECT\n\n  public:\n    explicit AboutDialog(QWidget* parent = nullptr);\n    ~AboutDialog() {\n    delete ui;\n}\n  private:\n    void recreate() {\n    layout()->invalidate();\n    layout()->activate();\n    adjustSize();\n}\n  private:\n    Ui::AboutDialog* ui;\n};"], ["/OpenSpeedy/speedpatch/SpeedPatch_global.h", "/*\n * OpenSpeedy - Open Source Game Speed Controller\n * Copyright (C) 2025 Game1024\n * \n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n * \n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n * GNU General Public License for more details.\n * \n * You should have received a copy of the GNU General Public License\n * along with this program.  If not, see <https://www.gnu.org/licenses/>.\n */\n#ifndef SPEEDPATCH_GLOBAL_H\n#define SPEEDPATCH_GLOBAL_H\n\n\n#endif // SPEEDPATCH_GLOBAL_H\n"], ["/OpenSpeedy/mainwindow.h", "class MainWindow {\n};"], ["/OpenSpeedy/speedpatch/speedpatch.h", "class speedpatch {\n};"]], "task_instance_info": {"created_time": "2025-08-20 20:13:07", "created_task_model": "DeepSeek-R1", "code_description": "This code segment functions to: Retrieve graphical icons from system resources using platform-specific handles, convert native icon handles into application-compatible graphical formats, and manage system resource cleanup after successful icon acquisition while validating successful resource conversion."}, "inference_content": {"inference_model": "DeepSeek-R1", "inference_result": "```cpp\n[TASK_BEGIN]\n        QIcon icon = QtWin::fromHICON(sfi.hIcon);\n        DestroyIcon(sfi.hIcon);\n        if (!icon.isNull()) {\n            return icon;\n        }\n[TASK_END]\n```", "inference_time": "2025-08-20 20-13-20"}, "editdistance_info": {"edit_distance": 48.4375, "calculate_time": "2025-08-20 20:13:20", "true_code_clean": "if (sfi.hIcon)\n        {\n            QIcon icon = QtWin::fromHICON(sfi.hIcon);\n            DestroyIcon(sfi.hIcon);\n            if (!icon.isNull())\n            {\n                qDebug() << processPath << \"通过SHGetFileInfo获取图标成功\";\n                return icon;\n            }\n        }", "predict_code_clean": "QIcon icon = QtWin::fromHICON(sfi.hIcon);\n        DestroyIcon(sfi.hIcon);\n        if (!icon.isNull()) {\n            return icon;\n        }"}}
{"repo_name": "OpenSpeedy", "file_name": "/OpenSpeedy/winutils.h", "inference_info": {"prefix_code": "class winutils {\n  public:\n    winutils() {\n}\n  public:\n    static bool injectDll(DWORD processId, const QString& dllPath) {\n    HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, processId);\n    if (!hProcess)\n    {\n        qDebug() << \"Failed to open process:\" << GetLastError();\n        return false;\n    }\n\n    if (checkDllExist(processId, dllPath))\n    {\n        qDebug() << \"Process already have been injected\";\n        return true;\n    }\n    else if (injectDllViaCRTW(processId, dllPath))\n    {\n        return true;\n    }\n    else if (injectDllViaCRTA(processId, dllPath))\n    {\n        return true;\n    }\n\n    injectDllViaAPCW(processId, dllPath);\n    injectDllViaAPCA(processId, dllPath);\n    if (checkDllExist(processId, dllPath))\n    {\n        return true;\n    }\n    else if (injectDllViaWHKW(processId, dllPath))\n    {\n        return true;\n    }\n    else if (injectDllViaWHKA(processId, dllPath))\n    {\n        return true;\n    }\n    else\n    {\n        return false;\n    }\n}\n    static bool injectDllViaCRTA(DWORD processId, const QString& dllPath) {\n    HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, processId);\n    if (!hProcess)\n    {\n        qDebug() << \"Failed to open process:\" << GetLastError();\n        return false;\n    }\n\n    if (checkDllExist(processId, dllPath))\n    {\n        qDebug() << \"Process already have been injected\";\n        return true;\n    }\n    SIZE_T pathSize = (dllPath.size() + 1) * sizeof(char);\n    LPVOID pDllPath =\n        VirtualAllocEx(hProcess,\n                       nullptr,\n                       pathSize,\n                       MEM_COMMIT | MEM_RESERVE,\n                       PAGE_EXECUTE_READWRITE);\n    if (!pDllPath)\n    {\n        qDebug() << \"Failed to allocate memory in target process:\"\n                 << GetLastError();\n        CloseHandle(hProcess);\n        return false;\n    }\n\n    if (!WriteProcessMemory(hProcess,\n                            pDllPath,\n                            dllPath.toStdString().c_str(),\n                            pathSize,\n                            nullptr))\n    {\n        qDebug() << \"Failed to write memory in target process:\"\n                 << GetLastError();\n        VirtualFreeEx(hProcess, pDllPath, 0, MEM_RELEASE);\n        CloseHandle(hProcess);\n        return false;\n    }\n\n    HMODULE hKernel32 = GetModuleHandle(L\"kernel32.dll\");\n    if (!hKernel32)\n    {\n        qDebug() << \"Failed to get handle for kernel32.dll:\" << GetLastError();\n        VirtualFreeEx(hProcess, pDllPath, 0, MEM_RELEASE);\n        CloseHandle(hProcess);\n        return false;\n    }\n\n    FARPROC pLoadLibraryA = GetProcAddress(hKernel32, \"LoadLibraryA\");\n    if (!pLoadLibraryA)\n    {\n        qDebug() << \"Failed to get address of LoadLibraryA:\" << GetLastError();\n        VirtualFreeEx(hProcess, pDllPath, 0, MEM_RELEASE);\n        CloseHandle(hProcess);\n        return false;\n    }\n\n    HANDLE hThread = CreateRemoteThread(hProcess,\n                                        nullptr,\n                                        0,\n                                        (LPTHREAD_START_ROUTINE)pLoadLibraryA,\n                                        pDllPath,\n                                        0,\n                                        nullptr);\n    if (!hThread)\n    {\n        qDebug() << \"Failed to create remote thread:\" << GetLastError();\n        VirtualFreeEx(hProcess, pDllPath, 0, MEM_RELEASE);\n        CloseHandle(hProcess);\n        return false;\n    }\n\n    WaitForSingleObject(hThread, INFINITE);\n\n    // 检查LoadLibrary是否执行成功\n    DWORD exitCode = 0;\n    if (GetExitCodeThread(hThread, &exitCode))\n    {\n        qDebug() << \"Remote thread exit code:\" << exitCode;\n        // LoadLibrary返回的是模块句柄,如果为0则失败\n        if (exitCode == 0)\n        {\n            VirtualFreeEx(hProcess, pDllPath, 0, MEM_RELEASE);\n            CloseHandle(hProcess);\n            CloseHandle(hThread);\n            qDebug() << \"LoadLibrary failed in remote process\";\n            return false;\n        }\n    }\n\n    VirtualFreeEx(hProcess, pDllPath, 0, MEM_RELEASE);\n    CloseHandle(hThread);\n    CloseHandle(hProcess);\n\n    return true;\n}\n    static bool injectDllViaCRTW(DWORD processId, const QString& dllPath) {\n    HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, processId);\n    if (!hProcess)\n    {\n        qDebug() << \"Failed to open process:\" << GetLastError();\n        return false;\n    }\n\n    if (checkDllExist(processId, dllPath))\n    {\n        qDebug() << \"Process already have been injected\";\n        return true;\n    }\n    SIZE_T pathSize = (dllPath.size() + 1) * sizeof(wchar_t);\n    LPVOID pDllPath =\n        VirtualAllocEx(hProcess, nullptr, pathSize, MEM_COMMIT | MEM_RESERVE,\n                       PAGE_EXECUTE_READWRITE);\n    if (!pDllPath)\n    {\n        qDebug() << \"Failed to allocate memory in target process:\"\n                 << GetLastError();\n        CloseHandle(hProcess);\n        return false;\n    }\n\n    if (!WriteProcessMemory(hProcess,\n                            pDllPath,\n                            dllPath.toStdWString().c_str(),\n                            pathSize,\n                            nullptr))\n    {\n        qDebug() << \"Failed to write memory in target process:\"\n                 << GetLastError();\n        VirtualFreeEx(hProcess, pDllPath, 0, MEM_RELEASE);\n        CloseHandle(hProcess);\n        return false;\n    }\n\n    HMODULE hKernel32 = GetModuleHandle(L\"kernel32.dll\");\n    if (!hKernel32)\n    {\n        qDebug() << \"Failed to get handle for kernel32.dll:\" << GetLastError();\n        VirtualFreeEx(hProcess, pDllPath, 0, MEM_RELEASE);\n        CloseHandle(hProcess);\n        return false;\n    }\n\n    FARPROC pLoadLibraryW = GetProcAddress(hKernel32, \"LoadLibraryW\");\n    if (!pLoadLibraryW)\n    {\n        qDebug() << \"Failed to get address of LoadLibraryW:\" << GetLastError();\n        VirtualFreeEx(hProcess, pDllPath, 0, MEM_RELEASE);\n        CloseHandle(hProcess);\n        return false;\n    }\n\n    HANDLE hThread = CreateRemoteThread(hProcess,\n                                        nullptr,\n                                        0,\n                                        (LPTHREAD_START_ROUTINE)pLoadLibraryW,\n                                        pDllPath,\n                                        0,\n                                        nullptr);\n    if (!hThread)\n    {\n        qDebug() << \"Failed to create remote thread:\" << GetLastError();\n        VirtualFreeEx(hProcess, pDllPath, 0, MEM_RELEASE);\n        CloseHandle(hProcess);\n        return false;\n    }\n\n    WaitForSingleObject(hThread, INFINITE);\n\n    // 检查LoadLibrary是否执行成功\n    DWORD exitCode = 0;\n    if (GetExitCodeThread(hThread, &exitCode))\n    {\n        qDebug() << \"Remote thread exit code:\" << exitCode;\n        // LoadLibrary返回的是模块句柄,如果为0则失败\n        if (exitCode == 0)\n        {\n            VirtualFreeEx(hProcess, pDllPath, 0, MEM_RELEASE);\n            CloseHandle(hProcess);\n            CloseHandle(hThread);\n            qDebug() << \"LoadLibrary failed in remote process\";\n            return false;\n        }\n    }\n\n    VirtualFreeEx(hProcess, pDllPath, 0, MEM_RELEASE);\n    CloseHandle(hThread);\n    CloseHandle(hProcess);\n\n    return true;\n}\n    static bool injectDllViaAPCA(DWORD processId, const QString& dllPath) {\n    HANDLE hProcess =\n        OpenProcess(PROCESS_ALL_ACCESS,\n                    FALSE,\n                    processId);\n\n    if (!hProcess)\n    {\n        qDebug() << \"Failed to open process: \" << GetLastError();\n        return false;\n    }\n\n    if (checkDllExist(processId, dllPath))\n    {\n        qDebug() << \"Process already have been injected\";\n        return true;\n    }\n\n    // 在目标进程中分配内存并写入DLL路径\n    SIZE_T pathSize = (dllPath.toStdString().size() + 1) * sizeof(char);\n    LPVOID pDllPath = VirtualAllocEx(hProcess,\n                                     NULL,\n                                     pathSize,\n                                     MEM_COMMIT,\n                                     PAGE_READWRITE);\n\n    if (!pDllPath)\n    {\n        qDebug() << \"Failed to allocate memory: \" << GetLastError();\n        CloseHandle(hProcess);\n        return false;\n    }\n\n    if (!WriteProcessMemory(hProcess, pDllPath, dllPath.toStdString().c_str(),\n                            pathSize, NULL))\n    {\n        qDebug() << \"Failed to write memory: \" << GetLastError();\n        VirtualFreeEx(hProcess, pDllPath, 0, MEM_RELEASE);\n        CloseHandle(hProcess);\n        return false;\n    }\n\n    // 获取LoadLibraryW的地址\n    HMODULE hKernel32 = GetModuleHandle(L\"kernel32.dll\");\n    if (!hKernel32)\n    {\n        qDebug() << \"Failed to get kernel32 handle\";\n        VirtualFreeEx(hProcess, pDllPath, 0, MEM_RELEASE);\n        CloseHandle(hProcess);\n        return false;\n    }\n\n    FARPROC pLoadLibraryA = GetProcAddress(hKernel32, \"LoadLibraryA\");\n    if (!pLoadLibraryA)\n    {\n        qDebug() << \"Failed to get LoadLibraryA address\";\n        VirtualFreeEx(hProcess, pDllPath, 0, MEM_RELEASE);\n        CloseHandle(hProcess);\n        return false;\n    }\n\n    // 获取进程中的所有线程\n    DWORD threadId = getProcessMainThread(processId);\n    if (!threadId)\n    {\n        qDebug() << \"No threads found in the process\";\n        VirtualFreeEx(hProcess, pDllPath, 0, MEM_RELEASE);\n        CloseHandle(hProcess);\n        return false;\n    }\n\n    // 向目标进程的所有线程队列中添加APC调用\n    bool success = false;\n\n    // 打开线程\n    HANDLE hThread = OpenThread(THREAD_SET_CONTEXT, FALSE, threadId);\n    if (hThread)\n    {\n        // 将LoadLibraryA作为APC函数加入队列\n        PostThreadMessageA(threadId, WM_PAINT, 0, 0);\n        DWORD result =\n            QueueUserAPC((PAPCFUNC)pLoadLibraryA, hThread, (ULONG_PTR)pDllPath);\n        PostThreadMessageA(threadId, WM_PAINT, 0, 0);\n        if (result != 0)\n        {\n            success = true;\n            qDebug() << \"APC queued to thread \" << threadId;\n        }\n\n        CloseHandle(hThread);\n    }\n\n    if (!success)\n    {\n        qDebug() << \"Failed to queue APC to any thread\";\n        VirtualFreeEx(hProcess, pDllPath, 0, MEM_RELEASE);\n        CloseHandle(hProcess);\n        return false;\n    }\n\n    // 注意:我们不释放分配的内存,因为APC函数尚未执行\n    // 内存将在DLL加载后释放\n\n    CloseHandle(hProcess);\n    return true;\n}\n    static bool injectDllViaAPCW(DWORD processId, const QString& dllPath) {\n    HANDLE hProcess =\n        OpenProcess(PROCESS_ALL_ACCESS,\n                    FALSE,\n                    processId);\n\n    if (!hProcess)\n    {\n        qDebug() << \"Failed to open process: \" << GetLastError();\n        return false;\n    }\n\n    if (checkDllExist(processId, dllPath))\n    {\n        qDebug() << \"Process already have been injected\";\n        return true;\n    }\n\n    // 在目标进程中分配内存并写入DLL路径\n    SIZE_T pathSize = (dllPath.toStdWString().size() + 1) * sizeof(wchar_t);\n    LPVOID pDllPath = VirtualAllocEx(hProcess,\n                                     NULL,\n                                     pathSize,\n                                     MEM_COMMIT,\n                                     PAGE_READWRITE);\n\n    if (!pDllPath)\n    {\n        qDebug() << \"Failed to allocate memory: \" << GetLastError();\n        CloseHandle(hProcess);\n        return false;\n    }\n\n    if (!WriteProcessMemory(hProcess,\n                            pDllPath,\n                            dllPath.toStdWString().c_str(),\n                            pathSize,\n                            NULL))\n    {\n        qDebug() << \"Failed to write memory: \" << GetLastError();\n        VirtualFreeEx(hProcess, pDllPath, 0, MEM_RELEASE);\n        CloseHandle(hProcess);\n        return false;\n    }\n\n    // 获取LoadLibraryW的地址\n    HMODULE hKernel32 = GetModuleHandle(L\"kernel32.dll\");\n    if (!hKernel32)\n    {\n        qDebug() << \"Failed to get kernel32 handle\";\n        VirtualFreeEx(hProcess, pDllPath, 0, MEM_RELEASE);\n        CloseHandle(hProcess);\n        return false;\n    }\n\n    FARPROC pLoadLibraryW = GetProcAddress(hKernel32, \"LoadLibraryW\");\n    if (!pLoadLibraryW)\n    {\n        qDebug() << \"Failed to get LoadLibraryW address\";\n        VirtualFreeEx(hProcess, pDllPath, 0, MEM_RELEASE);\n        CloseHandle(hProcess);\n        return false;\n    }\n\n    // 获取进程中的所有线程\n    DWORD threadId = getProcessMainThread(processId);\n    if (!threadId)\n    {\n        qDebug() << \"No threads found in the process\";\n        VirtualFreeEx(hProcess, pDllPath, 0, MEM_RELEASE);\n        CloseHandle(hProcess);\n        return false;\n    }\n\n    // 向目标进程的所有线程队列中添加APC调用\n    bool success = false;\n\n    // 打开线程\n    HANDLE hThread = OpenThread(THREAD_SET_CONTEXT, FALSE, threadId);\n    if (hThread)\n    {\n        // 将LoadLibraryW作为APC函数加入队列\n        PostThreadMessageW(threadId, WM_PAINT, 0, 0);\n        DWORD result =\n            QueueUserAPC((PAPCFUNC)pLoadLibraryW, hThread, (ULONG_PTR)pDllPath);\n        PostThreadMessageW(threadId, WM_PAINT, 0, 0);\n        if (result != 0)\n        {\n            success = true;\n            qDebug() << \"APC queued to thread \" << threadId;\n        }\n\n        CloseHandle(hThread);\n    }\n\n    if (!success)\n    {\n        qDebug() << \"Failed to queue APC to any thread\";\n        VirtualFreeEx(hProcess, pDllPath, 0, MEM_RELEASE);\n        CloseHandle(hProcess);\n        return false;\n    }\n\n    // 注意:我们不释放分配的内存,因为APC函数尚未执行\n    // 内存将在DLL加载后释放\n\n    CloseHandle(hProcess);\n    return true;\n}\n    static bool injectDllViaWHKA(DWORD processId, const QString& dllPath) {\n    if (checkProcessProtection(processId))\n    {\n        qDebug() << \"进程被保护 进程ID: \" << processId;\n        return false;\n    }\n\n    // 1. 加载DLL到当前进程\n    HMODULE hMod = LoadLibraryA(dllPath.toStdString().c_str());\n    if (!hMod)\n        return false;\n\n    // 2. 获取Hook过程的地址\n    HOOKPROC hookProc = (HOOKPROC)GetProcAddress(hMod, \"HookProc\");\n    if (!hookProc)\n        return false;\n\n    // 3. 获取目标线程ID\n    DWORD threadId = getProcessMainThread(processId);\n    if (threadId == 0)\n        return false;\n\n    // 4. 安装Hook\n    HHOOK hHook = SetWindowsHookExA(WH_CBT,   // Hook类型\n                                    hookProc, // Hook过程\n                                    hMod,     // DLL模块句柄\n                                    threadId  // 目标线程ID\n                                    );\n\n    if (!hHook)\n        return false;\n    // 5. 触发Hook执行\n    PostThreadMessageA(threadId, WM_NULL, 0, 0);\n    Sleep(5000);\n    UnhookWindowsHookEx(hHook);\n\n    return true;\n}\n    static bool injectDllViaWHKW(DWORD processId, const QString& dllPath) {\n    if (checkProcessProtection(processId))\n    {\n        qDebug() << \"进程被保护 进程ID: \" << processId;\n        return false;\n    }\n\n    // 1. 加载DLL到当前进程\n    HMODULE hMod = LoadLibraryW(dllPath.toStdWString().c_str());\n    if (!hMod)\n        return false;\n\n    // 2. 获取Hook过程的地址\n    HOOKPROC hookProc = (HOOKPROC)GetProcAddress(hMod, \"HookProc\");\n    if (!hookProc)\n        return false;\n\n    // 3. 获取目标线程ID\n    DWORD threadId = getProcessMainThread(processId);\n    if (threadId == 0)\n        return false;\n\n    // 4. 安装Hook\n    HHOOK hHook = SetWindowsHookExW(WH_CBT,   // Hook类型\n                                    hookProc, // Hook过程\n                                    hMod,     // DLL模块句柄\n                                    threadId  // 目标线程ID\n                                    );\n\n    if (!hHook)\n        return false;\n    // 5. 触发Hook执行\n    PostThreadMessageW(threadId, WM_NULL, 0, 0);\n    Sleep(5000);\n    UnhookWindowsHookEx(hHook);\n\n    return true;\n}\n    static bool unhookDll(DWORD processId, const QString& dllPath) {\n    HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, processId);\n    if (!hProcess)\n    {\n        qDebug() << \"Failed to open process:\" << GetLastError();\n        return false;\n    }\n\n    HMODULE hModules[1024];\n    DWORD cbNeeded;\n    if (EnumProcessModules(hProcess, hModules, sizeof(hModules), &cbNeeded))\n    {\n        for (unsigned int i = 0; i < (cbNeeded / sizeof(HMODULE)); i++)\n        {\n            TCHAR moduleName[MAX_PATH];\n            if (GetModuleFileNameEx(hProcess, hModules[i], moduleName,\n                                    sizeof(moduleName) / sizeof(TCHAR)))\n            {\n#ifdef UNICODE\n                bool isDll = dllPath.toStdWString() == moduleName;\n#else\n                bool isDll = dllPath.toStdString() == moduleName;\n#endif\n                if (isDll)\n                {\n                    FARPROC pFreeLibrary = GetProcAddress(\n                        GetModuleHandle(L\"kernel32.dll\"), \"FreeLibrary\");\n                    if (!pFreeLibrary)\n                    {\n                        qDebug() << \"Failed to get address of FreeLibrary:\"\n                                 << GetLastError();\n                        CloseHandle(hProcess);\n                        return false;\n                    }\n\n                    HANDLE hThread =\n                        CreateRemoteThread(hProcess, nullptr, 0,\n                                           (LPTHREAD_START_ROUTINE)pFreeLibrary,\n                                           hModules[i], 0, nullptr);\n                    if (!hThread)\n                    {\n                        qDebug() << \"Failed to create remote thread for \"\n                            \"FreeLibrary:\"\n                                 << GetLastError();\n                        CloseHandle(hProcess);\n                        return false;\n                    }\n\n                    WaitForSingleObject(hThread, INFINITE);\n                    CloseHandle(hThread);\n                    CloseHandle(hProcess);\n                    return true;\n                }\n            }\n        }\n    }\n\n    CloseHandle(hProcess);\n    return false;\n}\n    static bool checkDllExist(DWORD processId, const QString& dllPath) {\n    HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ,\n                                  FALSE,\n                                  processId);\n    if (!hProcess)\n    {\n        qDebug() << \"打开进程失败:\" << GetLastError();\n        return false;\n    }\n\n    bool dllFound = false;\n    HMODULE hModules[1024];\n    DWORD cbNeeded;\n\n    // 获取进程中所有已加载的模块\n    if (EnumProcessModules(hProcess, hModules, sizeof(hModules), &cbNeeded))\n    {\n        DWORD moduleCount = cbNeeded / sizeof(HMODULE);\n        for (DWORD i = 0; i < moduleCount; i++)\n        {\n            TCHAR moduleName[MAX_PATH] = {0};\n\n            // 获取模块的完整路径\n            if (GetModuleFileNameExW(hProcess, hModules[i], moduleName,\n                                     sizeof(moduleName) / sizeof(TCHAR)))\n            {\n#ifdef UNICODE\n                bool isDll = dllPath.toStdWString() == moduleName;\n#else\n                bool isDll = dllPath.toStdString() == moduleName;\n#endif\n                if (isDll)\n                {\n                    dllFound = true;\n                    break;\n                }\n            }\n        }\n    }\n    else\n    {\n        qDebug() << \"枚举进程模块失败:\" << GetLastError();\n    }\n\n    CloseHandle(hProcess);\n    return dllFound;\n}\n    static bool checkProcessProtection(DWORD processId) {\n    HANDLE hProcess =\n        OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, processId);\n    if (!hProcess)\n    {\n        qDebug() << \"Cannot open process - likely protected\";\n        return true; // 可能被保护\n    }\n\n    // 检查是否是受保护进程\n    PROCESS_PROTECTION_LEVEL_INFORMATION protectionInfo = {};\n    DWORD returnLength;\n\n    if (GetProcessInformation(hProcess, ProcessProtectionLevelInfo,\n                              &protectionInfo, sizeof(protectionInfo)))\n    {\n        CloseHandle(hProcess);\n        return protectionInfo.ProtectionLevel != PROTECTION_LEVEL_NONE;\n    }\n\n    CloseHandle(hProcess);\n    return false;\n}\n    static void setAutoStart(bool enable,\n                             const QString& appName,\n                             const QString& execPath) {\n    TaskScheduler scheduler;\n\n    if (enable)\n    {\n        scheduler.createStartupShortcut(appName, execPath);\n    }\n    else\n    {\n        scheduler.deleteStartupShortcut(appName);\n    }\n}\n    static bool isAutoStartEnabled(const QString& appName) {\n    TaskScheduler scheduler;\n    return scheduler.isStartupShortcutExists(appName);\n}\n    static BOOL getWindowsVersion(DWORD* majorVersion,\n                                  DWORD* minorVersion,\n                                  DWORD* buildNumber) {\n    static char version[100] = {0};\n    DWORD major, minor, build;\n\n    if (!getWindowsVersion(&major, &minor, &build))\n        return \"Unknown Windows Version\";\n\n    // 确定Windows版本\n    if (major == 10)\n    {\n        if (build >= 22000)\n        {\n            sprintf(version, \"Windows 11 (Build %lu)\", build);\n        }\n        else\n        {\n            sprintf(version, \"Windows 10 (Build %lu)\", build);\n        }\n    }\n    else if (major == 6)\n    {\n        switch (minor)\n        {\n        case 3:\n            sprintf(version, \"Windows 8.1 (Build %lu)\", build);\n            break;\n        case 2:\n            sprintf(version, \"Windows 8 (Build %lu)\", build);\n            break;\n        case 1:\n            sprintf(version, \"Windows 7 (Build %lu)\", build);\n            break;\n        case 0:\n            sprintf(version, \"Windows Vista (Build %lu)\", build);\n            break;\n        default:\n            sprintf(version, \"Windows NT %lu.%lu (Build %lu)\", major, minor,\n                    build);\n        }\n    }\n    else if (major == 5)\n    {\n        switch (minor)\n        {\n        case 2:\n            sprintf(version, \"Windows Server 2003 (Build %lu)\", build);\n            break;\n        case 1:\n            sprintf(version, \"Windows XP (Build %lu)\", build);\n            break;\n        case 0:\n            sprintf(version, \"Windows 2000 (Build %lu)\", build);\n            break;\n        default:\n            sprintf(version, \"Windows NT %lu.%lu (Build %lu)\", major, minor,\n                    build);\n        }\n    }\n    else\n    {\n        sprintf(version, \"Windows NT %lu.%lu (Build %lu)\", major, minor, build);\n    }\n    return version;\n}\n    static QString getWindowsVersion() {\n    static char version[100] = {0};\n    DWORD major, minor, build;\n\n    if (!getWindowsVersion(&major, &minor, &build))\n        return \"Unknown Windows Version\";\n\n    // 确定Windows版本\n    if (major == 10)\n    {\n        if (build >= 22000)\n        {\n            sprintf(version, \"Windows 11 (Build %lu)\", build);\n        }\n        else\n        {\n            sprintf(version, \"Windows 10 (Build %lu)\", build);\n        }\n    }\n    else if (major == 6)\n    {\n        switch (minor)\n        {\n        case 3:\n            sprintf(version, \"Windows 8.1 (Build %lu)\", build);\n            break;\n        case 2:\n            sprintf(version, \"Windows 8 (Build %lu)\", build);\n            break;\n        case 1:\n            sprintf(version, \"Windows 7 (Build %lu)\", build);\n            break;\n        case 0:\n            sprintf(version, \"Windows Vista (Build %lu)\", build);\n            break;\n        default:\n            sprintf(version, \"Windows NT %lu.%lu (Build %lu)\", major, minor,\n                    build);\n        }\n    }\n    else if (major == 5)\n    {\n        switch (minor)\n        {\n        case 2:\n            sprintf(version, \"Windows Server 2003 (Build %lu)\", build);\n            break;\n        case 1:\n            sprintf(version, \"Windows XP (Build %lu)\", build);\n            break;\n        case 0:\n            sprintf(version, \"Windows 2000 (Build %lu)\", build);\n            break;\n        default:\n            sprintf(version, \"Windows NT %lu.%lu (Build %lu)\", major, minor,\n                    build);\n        }\n    }\n    else\n    {\n        sprintf(version, \"Windows NT %lu.%lu (Build %lu)\", major, minor, build);\n    }\n    return version;\n}\n    static QList<ProcessInfo> getProcessList() {\n    QList<ProcessInfo> processList;\n\n    HANDLE hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);\n    if (hProcessSnap == INVALID_HANDLE_VALUE)\n    {\n        qDebug() << \"创建进程快照失败: \" << GetLastError();\n        return processList;\n    }\n\n    PROCESSENTRY32 pe32;\n    pe32.dwSize = sizeof(PROCESSENTRY32);\n\n    if (!Process32First(hProcessSnap, &pe32))\n    {\n        qDebug() << \"获取首个进程信息失败: \" << GetLastError();\n        CloseHandle(hProcessSnap);\n        return processList;\n    }\n\n    do\n    {\n        if (systemNames.contains(pe32.szExeFile))\n        {\n            continue;\n        }\n        ProcessInfo info;\n        info.pid = pe32.th32ProcessID;\n        info.parentPid = pe32.th32ParentProcessID;\n        info.name = QString::fromWCharArray(pe32.szExeFile);\n        info.threadCount = pe32.cntThreads;\n\n        // 获取内存使用和优先级信息\n        HANDLE hProcess = OpenProcess(\n            PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, info.pid);\n        ", "suffix_code": "\n\n        processList.append(info);\n    } while (Process32Next(hProcessSnap, &pe32));\n\n    CloseHandle(hProcessSnap);\n    return processList;\n}\n    static QString getProcessPath(DWORD processId) {\n    QString processPath;\n    HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ,\n                                  FALSE, processId);\n\n    if (hProcess != NULL)\n    {\n        wchar_t buffer[MAX_PATH];\n        if (GetModuleFileNameEx(hProcess, NULL, buffer, MAX_PATH) > 0)\n        {\n            processPath = QString::fromWCharArray(buffer);\n        }\n        CloseHandle(hProcess);\n    }\n\n    return processPath;\n}\n    static DWORD getProcessMainThread(DWORD processId) {\n    HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0);\n    if (hSnapshot == INVALID_HANDLE_VALUE)\n    {\n        qDebug() << \"Failed to create thread snapshot:\" << GetLastError();\n        return 0;\n    }\n\n    THREADENTRY32 te32;\n    te32.dwSize = sizeof(THREADENTRY32);\n\n    DWORD mainThreadId = 0;\n    FILETIME earliestTime = {0xFFFFFFFF, 0xFFFFFFFF}; // 设为最大值\n\n    if (Thread32First(hSnapshot, &te32))\n    {\n        do\n        {\n            if (te32.th32OwnerProcessID == processId)\n            {\n                // 打开线程获取创建时间\n                HANDLE hThread = OpenThread(THREAD_QUERY_INFORMATION, FALSE,\n                                            te32.th32ThreadID);\n                if (hThread)\n                {\n                    FILETIME creationTime, exitTime, kernelTime, userTime;\n                    if (GetThreadTimes(hThread, &creationTime, &exitTime,\n                                       &kernelTime, &userTime))\n                    {\n                        // 比较创建时间,找最早的线程\n                        if (CompareFileTime(&creationTime, &earliestTime) < 0)\n                        {\n                            earliestTime = creationTime;\n                            mainThreadId = te32.th32ThreadID;\n                        }\n                    }\n                    CloseHandle(hThread);\n                }\n            }\n        } while (Thread32Next(hSnapshot, &te32));\n    }\n\n    CloseHandle(hSnapshot);\n    return mainThreadId;\n}\n    static QString getProcessNameById(DWORD processId) {\n    HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ,\n                                  FALSE, processId);\n    if (hProcess == NULL)\n    {\n        return QString();\n    }\n\n    wchar_t processName[MAX_PATH];\n    if (GetModuleBaseName(hProcess, NULL, processName, MAX_PATH))\n    {\n        CloseHandle(hProcess);\n        QString name = QString::fromWCharArray(processName);\n        return name;\n    }\n\n    CloseHandle(hProcess);\n    return QString();\n}\n    static bool enableAllPrivilege() {\n    HANDLE hToken;\n    // 获取进程token\n    if (!OpenProcessToken(GetCurrentProcess(),\n                          TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))\n        return false;\n\n    const wchar_t *essentialPrivileges[] = {\n        SE_DEBUG_NAME, // 最重要的调试权限\n    };\n\n    TOKEN_PRIVILEGES tkp;\n    bool success = true;\n\n    for (const auto &privilege : essentialPrivileges)\n    {\n        tkp.PrivilegeCount = 1;\n        tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;\n        if (LookupPrivilegeValue(NULL, privilege, &tkp.Privileges[0].Luid))\n        {\n            AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, NULL, NULL);\n        }\n    }\n\n    CloseHandle(hToken);\n    return success;\n}\n};", "middle_code": "if (hProcess)\n        {\n            PROCESS_MEMORY_COUNTERS pmc;\n            if (GetProcessMemoryInfo(hProcess, &pmc, sizeof(pmc)))\n            {\n                info.memoryUsage = pmc.WorkingSetSize;\n            }\n            else\n            {\n                info.memoryUsage = 0;\n            }\n            BOOL wow64Process = FALSE;\n            IsWow64Process(hProcess, &wow64Process);\n            info.is64Bit = !wow64Process;\n            info.priorityClass = GetPriorityClass(hProcess);\n            CloseHandle(hProcess);\n        }\n        else\n        {\n            info.memoryUsage = 0;\n            info.priorityClass = 0;\n        }", "code_description": null, "fill_type": "BLOCK_TYPE", "language_type": "cpp", "sub_task_type": "if_statement"}, "context_code": [["/OpenSpeedy/processmonitor.h", "class ProcessMonitor {\n    Q_OBJECT\npublic:\nexplicit ProcessMonitor(QSettings*   settings,\n                        QTreeWidget* treeWidget,\n                        QLabel*      treeStatusLabel,\n                        QLabel*      injector32StatusLabel,\n                        QLabel*      injector64StatusLabel,\n\n                        QObject*     parent = nullptr);\n    ~ProcessMonitor() {\n    this->terminalBridge();\n    delete m_bridge32;\n    delete m_bridge64;\n}\n    void setInterval(int msec);\n    void setFilter(QString processName) {\n    m_filter = processName.toLower();\n}\n    void changeSpeed(double factor) {\n    QString cmd = QString(\"change %1\\n\").arg(factor);\n    m_bridge32->write(cmd.toUtf8(), cmd.size());\n    m_bridge32->waitForBytesWritten();\n    m_bridge64->write(cmd.toUtf8(), cmd.size());\n    m_bridge64->waitForBytesWritten();\n}\n  public:\n    void refresh() {\n    healthcheckBridge();\n    QList<ProcessInfo> processList = winutils::getProcessList();\n    if (m_filter == \"\")\n    {\n        update(processList);\n        m_treeStatusLabel->setText(QString(tr(\"搜索到%1个进程, 已过滤展示%2个\"))\n                                   .arg(processList.size())\n                                   .arg(processList.size()));\n    }\n    else\n    {\n        QList<ProcessInfo> filtered;\n        for (ProcessInfo info : processList)\n        {\n            if (info.name.toLower().contains(m_filter))\n                filtered.append(info);\n        }\n        update(filtered);\n        m_treeStatusLabel->setText(QString(tr(\"搜索到%1个进程, 已过滤展示%2个\"))\n                                   .arg(processList.size())\n                                   .arg(filtered.size()));\n    }\n}\n    void start() {\n    m_timer = new QTimer(this);\n    connect(m_timer, &QTimer::timeout, this, &ProcessMonitor::refresh);\n    m_timer->start(1000);\n}\n  private:\n    void onItemChanged(QTreeWidgetItem* item, int column) {\n    if (column == 5 && (item->flags() & Qt::ItemIsUserCheckable))\n    {\n        bool state = m_treeWidget->blockSignals(true);\n\n        Qt::CheckState checkState = item->checkState(column);\n        QString processName = item->text(0);\n        DWORD pid = item->text(1).toLong();\n        bool is64Bit = item->text(3) == \"x64\" ? true : false;\n        if (checkState == Qt::Checked)\n        {\n            m_targetNames.insert(processName);\n            this->injectDll(pid, is64Bit);\n            item->setText(5, tr(\"加速中\"));\n            for (int col = 0; col < item->columnCount(); ++col)\n            {\n                item->setBackground(col, QBrush(QColor(\"#f3e5f5\")));\n                item->setForeground(col, QBrush(QColor(\"#7b1fa2\")));\n            }\n            qDebug() << processName << \"勾选\";\n            dump();\n        }\n        else\n        {\n            m_targetNames.remove(processName);\n            this->unhookDll(pid, is64Bit);\n            item->setText(5, \"\");\n            for (int col = 0; col < item->columnCount(); ++col)\n            {\n                item->setBackground(col, QBrush());\n                item->setForeground(col, QBrush());\n            }\n            qDebug() << processName << \"取消勾选\";\n            dump();\n        }\n\n        m_treeWidget->blockSignals(state);\n    }\n}\n  private:\n    QTreeWidget* m_treeWidget;\n    QLabel* m_treeStatusLabel;\n    QLabel* m_injector32StatusLabel;\n    QLabel* m_injector64StatusLabel;\n    QString m_filter;\n    QTimer* m_timer = nullptr;\n    QString m_dllPath;\n    QProcess* m_bridge32;\n    QProcess* m_bridge64;\n    QSettings* m_settings;\n    QHash<QString, QIcon> m_iconCache;\n    QMap<DWORD, QTreeWidgetItem*> m_processItems;\n    QSet<QString> m_targetNames;\n    void init() {\n    QStringList targetNames =\n        m_settings->value(CONFIG_TARGETNAMES_KEY).toStringList();\n    m_targetNames = QSet<QString>(targetNames.begin(), targetNames.end());\n}\n    void dump() {\n    m_settings->setValue(CONFIG_TARGETNAMES_KEY,\n                         QStringList(m_targetNames.values()));\n}\n    void update(const QList<ProcessInfo>& processList) {\n    // 跟踪现有进程,用于确定哪些已终止\n    QSet<DWORD> currentPids;\n    for (const ProcessInfo& info : processList)\n    {\n        currentPids.insert(info.pid);\n    }\n\n    // 移除已终止的进程\n    QMutableMapIterator<DWORD, QTreeWidgetItem*> i(m_processItems);\n    while (i.hasNext())\n    {\n        i.next();\n        if (!currentPids.contains(i.key()))\n        {\n            QTreeWidgetItem* item = i.value();\n            QTreeWidgetItem* parent = item->parent();\n\n            if (parent)\n            {\n                parent->removeChild(item);\n            }\n            else\n            {\n                auto index = m_treeWidget->indexOfTopLevelItem(item);\n                m_treeWidget->takeTopLevelItem(index);\n            }\n\n            while (item->childCount() > 0)\n            {\n                QTreeWidgetItem* child = item->takeChild(0);\n                if (parent)\n                {\n                    parent->addChild(child);\n                }\n                else\n                {\n                    m_treeWidget->addTopLevelItem(child);\n                }\n            }\n\n            // 删除节点\n            delete item;\n\n            // 从映射中移除\n            i.remove();\n        }\n    }\n\n    // 添加或更新进程信息\n    for (const ProcessInfo& info : processList)\n    {\n        if (m_processItems.contains(info.pid))\n        {\n            // 更新已存在的进程信息\n            QTreeWidgetItem* item = m_processItems[info.pid];\n            item->setText(1, QString::number(info.pid));\n            item->setData(1, Qt::UserRole, (long long)info.pid);\n            item->setText(2,\n                          QString(\"%1 MB\").arg(info.memoryUsage / 1024 / 1024));\n            item->setData(2, Qt::UserRole, (uint)info.memoryUsage);\n\n            QString arch = info.is64Bit ? \"x64\" : \"x86\";\n            item->setText(3, arch);\n            QString priority;\n            switch (info.priorityClass)\n            {\n            case HIGH_PRIORITY_CLASS:\n                priority = tr(\"\");\n                break;\n            case NORMAL_PRIORITY_CLASS:\n                priority = tr(\"\");\n                break;\n            case IDLE_PRIORITY_CLASS:\n                priority = tr(\"\");\n                break;\n            case REALTIME_PRIORITY_CLASS:\n                priority = tr(\"实时\");\n                break;\n            default:\n                priority = tr(\"未知\");\n                break;\n            }\n            item->setText(4, priority);\n            if (m_targetNames.contains(info.name))\n            {\n                if (item->checkState(5) == Qt::Unchecked)\n                {\n                    item->setCheckState(5, Qt::Checked);\n                }\n            }\n            else\n            {\n                if (item->checkState(5) == Qt::Checked)\n                {\n                    item->setCheckState(5, Qt::Unchecked);\n                }\n            }\n        }\n        else\n        {\n            // 添加新进程\n            QTreeWidgetItem* item = new SortTreeWidgetItem();\n\n            item->setText(0, info.name);\n            item->setData(0, Qt::UserRole, info.name.toLower());\n            item->setText(1, QString::number(info.pid));\n            item->setData(1, Qt::UserRole, (long long)info.pid);\n            item->setText(2,\n                          QString(\"%1 MB\").arg(info.memoryUsage / 1024 / 1024));\n            item->setData(2, Qt::UserRole, (uint)info.memoryUsage);\n\n            QString arch = info.is64Bit ? \"x64\" : \"x86\";\n            item->setText(3, arch);\n\n            // 加载进程图标\n            item->setIcon(0, getProcessIconCached(info.pid));\n\n            QString priority;\n            switch (info.priorityClass)\n            {\n            case HIGH_PRIORITY_CLASS:\n                priority = tr(\"\");\n                break;\n            case NORMAL_PRIORITY_CLASS:\n                priority = tr(\"\");\n                break;\n            case IDLE_PRIORITY_CLASS:\n                priority = tr(\"\");\n                break;\n            case REALTIME_PRIORITY_CLASS:\n                priority = tr(\"实时\");\n                break;\n            default:\n                priority = tr(\"未知\");\n                break;\n            }\n            item->setText(4, priority);\n            item->setCheckState(5, Qt::Unchecked);\n            m_treeWidget->addTopLevelItem(item);\n            m_processItems[info.pid] = item;\n        }\n    }\n}\n    void injectDll(DWORD processId, bool is64Bit) {\n    QString cmd = QString(\"inject %1\\n\").arg(processId);\n    if (!is64Bit)\n    {\n        m_bridge32->write(cmd.toUtf8(), cmd.size());\n        m_bridge32->waitForBytesWritten();\n    }\n    else\n    {\n        m_bridge64->write(cmd.toUtf8(), cmd.size());\n        m_bridge64->waitForBytesWritten();\n    }\n}\n    void unhookDll(DWORD processId, bool is64Bit) {\n    QString cmd = QString(\"unhook %1\\n\").arg(processId);\n    if (!is64Bit)\n    {\n        m_bridge32->write(cmd.toUtf8(), cmd.size());\n        m_bridge32->waitForBytesWritten();\n    }\n    else\n    {\n        m_bridge64->write(cmd.toUtf8(), cmd.size());\n        m_bridge64->waitForBytesWritten();\n    }\n}\n    void startBridge32() {\n    m_bridge32 = new QProcess();\n    QStringList params32;\n    m_bridge32->start(BRIDGE32_EXE, params32);\n    if (!m_bridge32->waitForStarted())\n    {\n        qDebug() << \"32位桥接子进程启动失败\";\n    }\n    else\n    {\n        qDebug() << \"32位桥接子进程已启动\";\n    }\n    m_bridge32->setProcessChannelMode(QProcess::MergedChannels);\n    connect(m_bridge32,\n            &QProcess::readyReadStandardOutput,\n            [&]()\n    {\n        QByteArray data = m_bridge32->readAllStandardOutput();\n        qDebug() << \"收到输出:\" << QString(data).trimmed();\n    });\n}\n    void startBridge64() {\n    m_bridge64 = new QProcess();\n    QStringList params64;\n    m_bridge64->start(BRIDGE64_EXE, params64);\n    if (!m_bridge64->waitForStarted())\n    {\n        qDebug() << \"64位桥接子进程启动失败\";\n    }\n    else\n    {\n        qDebug() << \"64位桥接子进程已启动\";\n    }\n    m_bridge64->setProcessChannelMode(QProcess::MergedChannels);\n    connect(m_bridge64,\n            &QProcess::readyReadStandardOutput,\n            [&]()\n    {\n        QByteArray data = m_bridge64->readAllStandardOutput();\n        qDebug() << \"收到输出:\" << QString(data).trimmed();\n    });\n}\n    void healthcheckBridge() {\n    if (this->m_bridge32->state() == QProcess::Running)\n    {\n        m_injector32StatusLabel->setStyleSheet(\"color: green\");\n        m_injector32StatusLabel->setText(tr(\"正常\"));\n    }\n    else\n    {\n        m_injector32StatusLabel->setStyleSheet(\"color: red\");\n        m_injector32StatusLabel->setText(tr(\"异常退出\"));\n    }\n\n    if (this->m_bridge64->state() == QProcess::Running)\n    {\n        m_injector64StatusLabel->setStyleSheet(\"color: green\");\n        m_injector64StatusLabel->setText(tr(\"正常\"));\n    }\n    else\n    {\n        m_injector64StatusLabel->setStyleSheet(\"color:red\");\n        m_injector64StatusLabel->setText(tr(\"异常退出\"));\n    }\n}\n    void terminalBridge() {\n    QString cmd = QString(\"exit\\n\");\n    m_bridge32->write(cmd.toUtf8(), cmd.size());\n    m_bridge32->waitForBytesWritten();\n    m_bridge64->write(cmd.toUtf8(), cmd.size());\n    m_bridge64->waitForBytesWritten();\n}\n    static QIcon getProcessIcon(QString processPath) {\n    int lastSlashPos =\n        std::max(processPath.lastIndexOf('/'), processPath.lastIndexOf('\\\\'));\n    QString processName;\n    if (lastSlashPos == -1)\n    {\n        processName = processPath;\n    }\n    processName = processPath.mid(lastSlashPos + 1);\n\n    if (processPath.isEmpty())\n    {\n        qDebug() << processPath << \"无法获取进程完整路径\";\n        return getDefaultIcon(processName);\n    }\n\n    SHFILEINFO sfi = {};\n    if (SHGetFileInfo(reinterpret_cast<LPCWSTR>(processPath.utf16()),\n                      FILE_ATTRIBUTE_NORMAL,\n                      &sfi,\n                      sizeof(SHFILEINFO),\n                      SHGFI_ICON | SHGFI_LARGEICON | SHGFI_USEFILEATTRIBUTES))\n    {\n        if (sfi.hIcon)\n        {\n            QIcon icon = QtWin::fromHICON(sfi.hIcon);\n            DestroyIcon(sfi.hIcon);\n            if (!icon.isNull())\n            {\n                qDebug() << processPath << \"通过SHGetFileInfo获取图标成功\";\n                return icon;\n            }\n        }\n    }\n\n    HICON hIcon =\n        ExtractIconW(nullptr, reinterpret_cast<LPCWSTR>(processPath.utf16()), 0);\n    if (hIcon)\n    {\n        QIcon icon = QtWin::fromHICON(hIcon);\n        DestroyIcon(hIcon);\n        if (!icon.isNull())\n            return icon;\n    }\n\n    QFileInfo fileInfo(processPath);\n    if (fileInfo.exists())\n    {\n        // 使用Qt的QFileIconProvider获取文件图标\n        QFileIconProvider iconProvider;\n        return iconProvider.icon(fileInfo);\n    }\n    qDebug() << processPath << \"无法获取进程图标使用默认图标\";\n\n    return getDefaultIcon(processName);\n}\n    static QIcon getDefaultIcon(const QString& processName) {\n    // 根据进程名称或类型提供更有针对性的默认图标\n    if (processName != \"\")\n    {\n        // 使用SHGetFileInfo获取.exe文件的图标\n        SHFILEINFO sfi = {};\n        QIcon icon;\n        if (SHGetFileInfo(reinterpret_cast<LPCWSTR>(processName.utf16()),\n                          FILE_ATTRIBUTE_NORMAL,\n                          &sfi,\n                          sizeof(SHFILEINFO),\n                          SHGFI_USEFILEATTRIBUTES | SHGFI_ICON |\n                          SHGFI_SMALLICON))\n        {\n            // 将HICON转换为QIcon\n            icon = QtWin::fromHICON(sfi.hIcon);\n\n            // 释放图标资源\n            DestroyIcon(sfi.hIcon);\n        }\n        return icon;\n    }\n    else\n    {\n        // 使用SHGetFileInfo获取.exe文件的图标\n        SHFILEINFO sfi = {};\n        QIcon icon;\n        if (SHGetFileInfo(reinterpret_cast<LPCWSTR>(L\".exe\"),\n                          FILE_ATTRIBUTE_NORMAL,\n                          &sfi,\n                          sizeof(SHFILEINFO),\n                          SHGFI_USEFILEATTRIBUTES | SHGFI_ICON |\n                          SHGFI_SMALLICON))\n        {\n            // 将HICON转换为QIcon\n            icon = QtWin::fromHICON(sfi.hIcon);\n\n            // 释放图标资源\n            DestroyIcon(sfi.hIcon);\n        }\n        return icon;\n    }\n}\n    QIcon getProcessIconCached(DWORD proccessId) {\n    QString processPath = winutils::getProcessPath(processId);\n    if (m_iconCache.contains(processPath))\n    {\n        return m_iconCache[processPath];\n    }\n\n    QIcon icon = getProcessIcon(processPath);\n    m_iconCache.insert(processPath, icon);\n    return icon;\n}\n  public:\n};"], ["/OpenSpeedy/windbg.h", "/*\n * OpenSpeedy - Open Source Game Speed Controller\n * Copyright (C) 2025 Game1024\n * \n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n * \n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n * GNU General Public License for more details.\n * \n * You should have received a copy of the GNU General Public License\n * along with this program.  If not, see <https://www.gnu.org/licenses/>.\n */\n#ifndef WINDBG_H\n#define WINDBG_H\n#include <windows.h>\n#include <QDateTime>\n#include <QDir>\n#include <dbghelp.h>\n// 链接dbghelp库\n#pragma comment(lib, \"dbghelp.lib\")\n\ntypedef BOOL(WINAPI *MINIDUMPWRITEDUMP)(\n    HANDLE hProcess,\n    DWORD ProcessId,\n    HANDLE hFile,\n    MINIDUMP_TYPE DumpType,\n    PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam,\n    PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam,\n    PMINIDUMP_CALLBACK_INFORMATION CallbackParam);\n\n// 自定义异常处理函数\nLONG WINAPI createMiniDump(EXCEPTION_POINTERS *exceptionPointers)\n{\n    // 创建dump文件目录\n    QDir dumpDir(QDir::currentPath() + \"/dumps\");\n    if (!dumpDir.exists())\n    {\n        dumpDir.mkpath(\".\");\n    }\n\n    // 生成带时间戳的文件名\n    QString dumpFileName =\n        QString(\"%1/crash_%2.dmp\")\n            .arg(dumpDir.absolutePath())\n            .arg(QDateTime::currentDateTime().toString(\"yyyy-MM-dd_hh-mm-ss\"));\n\n    // 创建文件\n    HANDLE hFile = CreateFile(dumpFileName.toStdWString().c_str(),\n                              GENERIC_WRITE, FILE_SHARE_READ, NULL,\n                              CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);\n\n    if (hFile == INVALID_HANDLE_VALUE)\n    {\n        return EXCEPTION_CONTINUE_SEARCH;\n    }\n\n    // 加载dbghelp.dll\n    HMODULE dbgHelp = LoadLibrary(L\"dbghelp.dll\");\n    if (!dbgHelp)\n    {\n        CloseHandle(hFile);\n        return EXCEPTION_CONTINUE_SEARCH;\n    }\n\n    // 获取MiniDumpWriteDump函数地址\n    MINIDUMPWRITEDUMP miniDumpWriteDump =\n        (MINIDUMPWRITEDUMP)GetProcAddress(dbgHelp, \"MiniDumpWriteDump\");\n\n    if (!miniDumpWriteDump)\n    {\n        FreeLibrary(dbgHelp);\n        CloseHandle(hFile);\n        return EXCEPTION_CONTINUE_SEARCH;\n    }\n\n    // 配置异常信息\n    MINIDUMP_EXCEPTION_INFORMATION exInfo;\n    exInfo.ThreadId = GetCurrentThreadId();\n    exInfo.ExceptionPointers = exceptionPointers;\n    exInfo.ClientPointers = FALSE;\n\n    // 设置dump类型\n    MINIDUMP_TYPE dumpType =\n        (MINIDUMP_TYPE)(MiniDumpWithFullMemory |      // 包含完整内存\n                        MiniDumpWithFullMemoryInfo |  // 包含内存信息\n                        MiniDumpWithHandleData |      // 包含句柄数据\n                        MiniDumpWithThreadInfo |      // 包含线程信息\n                        MiniDumpWithUnloadedModules   // 包含卸载的模块\n        );\n\n    // 写入dump文件\n    BOOL success = miniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(),\n                                     hFile, dumpType, &exInfo, NULL, NULL);\n\n    // 清理资源\n    FreeLibrary(dbgHelp);\n    CloseHandle(hFile);\n\n    // 显示通知\n    if (success)\n    {\n        std::wstring message =\n            QString(\"程序遇到错误已退出,崩溃转储文件已保存到:\\n%1\")\n                .arg(dumpFileName)\n                .toStdWString();\n        MessageBoxW(nullptr, message.c_str(), L\"程序崩溃\",\n                    MB_OK | MB_ICONERROR);\n    }\n\n    return EXCEPTION_EXECUTE_HANDLER;\n}\n\n#endif  // WINDBG_H\n"], ["/OpenSpeedy/bridge/main.cpp", "#include \"../config.h\"\n#include \"../speedpatch/speedpatch.h\"\n#include \"../windbg.h\"\n#include \"../winutils.h\"\n#include <QCoreApplication>\n#include <QDebug>\n#include <QDir>\n#include <QRegularExpression>\n#include <QTextStream>\n\n#ifndef _WIN64\n#define SPEEDPATCH_DLL SPEEDPATCH32_DLL\n#else\n#define SPEEDPATCH_DLL SPEEDPATCH64_DLL\n#endif\n\nvoid\nhandleInject(int processId, QString dllPath)\n{\n    qDebug() << \"执行 inject,进程ID:\" << processId;\n    winutils::injectDll(processId, dllPath);\n    SetProcessStatus(processId, true);\n}\n\nvoid\nhandleUnhook(int processId, QString dllPath)\n{\n    qDebug() << \"执行 unhook,进程ID:\" << processId;\n    SetProcessStatus(processId, false);\n}\n\nvoid\nhandleChange(double factor)\n{\n    qDebug() << \"执行 change,参数:\" << factor;\n    ChangeSpeed(factor);\n}\n\nint\nmain(int argc, char* argv[])\n{\n    SetUnhandledExceptionFilter(createMiniDump);\n    QCoreApplication a(argc, argv);\n    if (winutils::enableAllPrivilege())\n    {\n        qDebug() << \"权限提升成功\";\n    }\n\n    QString dllPath = QDir::toNativeSeparators(\n      QCoreApplication::applicationDirPath() + \"/\" + SPEEDPATCH_DLL);\n\n    QTextStream in(stdin);\n    QTextStream out(stdout);\n\n    QRegularExpression injectRegex(\"^\\\\s*inject\\\\s+(\\\\d+)\\\\s*$\",\n                                   QRegularExpression::CaseInsensitiveOption);\n    QRegularExpression unhookRegex(\"^\\\\s*unhook\\\\s+(\\\\d+)\\\\s*$\",\n                                   QRegularExpression::CaseInsensitiveOption);\n    QRegularExpression changeRegex(\"^\\\\s*change\\\\s+([+-]?\\\\d*\\\\.?\\\\d+)\\\\s*$\",\n                                   QRegularExpression::CaseInsensitiveOption);\n    QRegularExpression exitRegex(\"^\\\\s*exit\\\\s*$\",\n                                 QRegularExpression::CaseInsensitiveOption);\n\n    while (true)\n    {\n        QString line = in.readLine();\n        if (line.isNull())\n        {\n            // 管道关闭或输入结束\n            break;\n        }\n        line = line.trimmed();\n        if (line.isEmpty())\n            continue;\n\n        QRegularExpressionMatch match;\n        if ((match = injectRegex.match(line)).hasMatch())\n        {\n            int pid = match.captured(1).toInt();\n            handleInject(pid, dllPath);\n        }\n        else if ((match = unhookRegex.match(line)).hasMatch())\n        {\n            int pid = match.captured(1).toInt();\n            handleUnhook(pid, dllPath);\n        }\n        else if ((match = changeRegex.match(line)).hasMatch())\n        {\n            double factor = match.captured(1).toDouble();\n            handleChange(factor);\n        }\n        else if (exitRegex.match(line).hasMatch())\n        {\n            qDebug() << \"收到exit命令,程序即将退出。\";\n            break;\n        }\n        else\n        {\n            qDebug() << \"无效命令:\" << line;\n        }\n    }\n\n    return 0;\n}\n"], ["/OpenSpeedy/taskscheduler.h", "class TaskScheduler {\n    Q_OBJECT\n  public:\n    explicit TaskScheduler(QObject *parent = nullptr);\n    ~TaskScheduler() {\n}\n    bool createStartupTask(const QString &taskName,\n                           const QString &executablePath) {\n    if (taskName.isEmpty() || executablePath.isEmpty())\n    {\n        qWarning() << \"任务名称或可执行文件路径不能为空\";\n        return false;\n    }\n\n    if (!QFile::exists(executablePath))\n    {\n        qWarning() << \"可执行文件不存在\" << executablePath;\n        return false;\n    }\n\n    QStringList arguments;\n    arguments << \"/create\"\n              << \"/f\"\n              << \"/tn\" << taskName << \"/tr\"\n              << QString(\"\\\"%1\\\" --minimize-to-tray\").arg(executablePath)\n              << \"/sc\" << \"onlogon\"\n              << \"/delay\" << \"0000:10\"\n              << \"/rl\" << \"highest\";\n\n    return execute(arguments);\n}\n    bool deleteTask(const QString &taskName) {\n    if (taskName.isEmpty())\n    {\n        qWarning() << \"任务名称不能为空\";\n        return false;\n    }\n\n    if (!isTaskExists(taskName))\n    {\n        qWarning() << \"任务不存在, 无需删除\" << taskName;\n        return true;\n    }\n\n    QStringList arguments;\n    arguments << \"/delete\"\n              << \"/f\"\n              << \"/tn\" << taskName;\n\n    return execute(arguments);\n}\n    bool enableTask(const QString &taskName, bool enable) {\n    if (!isTaskExists(taskName))\n    {\n        qWarning() << \"任务不存在:\" << taskName;\n        return false;\n    }\n\n    QStringList arguments;\n    arguments << \"/change\"\n              << \"/tn\" << taskName << (enable ? \"/enable\" : \"/disable\");\n    return execute(arguments);\n}\n    bool isTaskExists(const QString &taskName) {\n    QStringList arguments;\n    arguments << \"/query\" << \"/tn\" << taskName;\n\n    return execute(arguments);\n}\n    bool execute(const QStringList &arguments) {\n    QProcess process;\n    process.setProgram(\"schtasks\");\n    process.setArguments(arguments);\n\n    const int timeout = 10000;\n    process.start();\n    if (!process.waitForStarted(timeout))\n    {\n        qWarning() << \"无法运行:\" << process.errorString();\n        return false;\n    }\n\n    if (!process.waitForFinished(timeout))\n    {\n        qWarning() << \"执行超时\";\n        process.kill();\n        return false;\n    }\n\n    int exitcode = process.exitCode();\n    QString stdout_ = QString::fromLocal8Bit(process.readAllStandardOutput());\n    QString stderr_ = QString::fromLocal8Bit(process.readAllStandardError());\n\n    if (exitcode == 0)\n    {\n        qDebug() << \"执行成功:\" << arguments;\n        qDebug() << \"输出:\" << stdout_;\n        return true;\n    }\n    else\n    {\n        qDebug() << \"执行失败:\" << arguments;\n        qDebug() << \"错误输出:\" << stderr_;\n        qDebug() << \"标准输出:\" << stdout_;\n        return false;\n    }\n}\n    bool createStartupShortcut(const QString &taskName,\n                               const QString &executablePath) {\n    QString home = QDir::homePath();\n    QString startupDir =\n        home +\n        \"\\\\AppData\\\\Roaming\\\\Microsoft\\\\Windows\\\\Start Menu\\\\Programs\\\\Startup\";\n    QString shortcutPath = QDir(startupDir).absoluteFilePath(taskName + \".lnk\");\n    QString arguments = \"--minimize-to-tray\";\n\n    QString psScript =\n        QString(\"$WScriptShell = New-Object -ComObject WScript.Shell; \"\n                \"$Shortcut = $WScriptShell.CreateShortcut('%1'); \"\n                \"$Shortcut.TargetPath = '%2'; \"\n                \"$Shortcut.Arguments = '%3'; \"\n                \"$Shortcut.Description = '%4'; \"\n                \"$Shortcut.Save()\")\n        .arg(shortcutPath, executablePath, arguments,\n             QString(\"启动 %1\").arg(QFileInfo(executablePath).baseName()));\n\n    return executePs(psScript);\n}\n    bool deleteStartupShortcut(const QString &taskName) {\n    QString home = QDir::homePath();\n    QString startupDir =\n        home + \"\\\\AppData\\\\Roaming\\\\Microsoft\\\\Windows\\\\Start Menu\\\\Programs\\\\Startup\";\n    QString shortcutPath = QDir(startupDir).absoluteFilePath(taskName + \".lnk\");\n\n    QString psScript = QString(\"Remove-Item '%1' -Force\").arg(shortcutPath);\n\n    return executePs(psScript);\n}\n    bool isStartupShortcutExists(const QString &taskName) {\n    QString home = QDir::homePath();\n    QString startupDir =\n        home +\n        \"\\\\AppData\\\\Roaming\\\\Microsoft\\\\Windows\\\\Start Menu\\\\Programs\\\\Startup\";\n    QString shortcutPath = QDir(startupDir).absoluteFilePath(taskName + \".lnk\");\n\n    return QFile::exists(shortcutPath);\n}\n    bool executePs(const QString &psScript) {\n    QProcess process;\n    process.setProgram(\"powershell\");\n    process.setArguments({\"-ExecutionPolicy\", \"Bypass\", \"-Command\", psScript});\n\n    process.start();\n    if (!process.waitForStarted(5000))\n    {\n        qDebug() << \"PowerShell 启动失败:\" << process.errorString();\n        return false;\n    }\n\n    if (process.waitForFinished(5000) && process.exitCode() == 0)\n    {\n        qDebug() << \"PowerShell 执行成功\";\n        return true;\n    }\n    else\n    {\n        QString error = QString::fromLocal8Bit(process.readAllStandardError());\n        qDebug() << \"PowerShell 执行失败:\" << error;\n    }\n\n    return false;\n}\n};"], ["/OpenSpeedy/qsinglekeysequenceedit.h", "class QSingleKeySequenceEdit {\n    Q_OBJECT\n\n  public:\n    explicit QSingleKeySequenceEdit(QWidget* parent = nullptr);\n    static UINT toVK(int qtKey, Qt::KeyboardModifiers qtMod) {\n    // 🔤 字母键 A-Z\n    if (qtKey >= Qt::Key_A && qtKey <= Qt::Key_Z)\n    {\n        return qtKey; // Qt 和 Windows 的 A-Z 键码相同\n    }\n\n    // 🔢 小键盘 0-9\n    if (qtMod & Qt::KeypadModifier)\n    {\n        switch (qtKey)\n        {\n                // 数字键盘\n            case Qt::Key_0:\n                return VK_NUMPAD0;\n            case Qt::Key_1:\n                return VK_NUMPAD1;\n            case Qt::Key_2:\n                return VK_NUMPAD2;\n            case Qt::Key_3:\n                return VK_NUMPAD3;\n            case Qt::Key_4:\n                return VK_NUMPAD4;\n            case Qt::Key_5:\n                return VK_NUMPAD5;\n            case Qt::Key_6:\n                return VK_NUMPAD6;\n            case Qt::Key_7:\n                return VK_NUMPAD7;\n            case Qt::Key_8:\n                return VK_NUMPAD8;\n            case Qt::Key_9:\n                return VK_NUMPAD9;\n        }\n    }\n\n    // 🔢 数字键 0-9\n    if (qtKey >= Qt::Key_0 && qtKey <= Qt::Key_9)\n    {\n        return qtKey; // Qt 和 Windows 的 0-9 键码相同\n    }\n\n    // 🎯 功能键映射\n    switch (qtKey)\n    {\n        // F1-F12\n        case Qt::Key_F1:\n            return VK_F1;\n        case Qt::Key_F2:\n            return VK_F2;\n        case Qt::Key_F3:\n            return VK_F3;\n        case Qt::Key_F4:\n            return VK_F4;\n        case Qt::Key_F5:\n            return VK_F5;\n        case Qt::Key_F6:\n            return VK_F6;\n        case Qt::Key_F7:\n            return VK_F7;\n        case Qt::Key_F8:\n            return VK_F8;\n        case Qt::Key_F9:\n            return VK_F9;\n        case Qt::Key_F10:\n            return VK_F10;\n        case Qt::Key_F11:\n            return VK_F11;\n        case Qt::Key_F12:\n            return VK_F12;\n\n        // 方向键\n        case Qt::Key_Left:\n            return VK_LEFT;\n        case Qt::Key_Right:\n            return VK_RIGHT;\n        case Qt::Key_Up:\n            return VK_UP;\n        case Qt::Key_Down:\n            return VK_DOWN;\n\n        // 特殊键\n        case Qt::Key_Enter:\n        case Qt::Key_Return:\n            return VK_RETURN;\n        case Qt::Key_Escape:\n            return VK_ESCAPE;\n        case Qt::Key_Tab:\n            return VK_TAB;\n        case Qt::Key_Backspace:\n            return VK_BACK;\n        case Qt::Key_Delete:\n            return VK_DELETE;\n        case Qt::Key_Insert:\n            return VK_INSERT;\n        case Qt::Key_Home:\n            return VK_HOME;\n        case Qt::Key_End:\n            return VK_END;\n        case Qt::Key_PageUp:\n            return VK_PRIOR;\n        case Qt::Key_PageDown:\n            return VK_NEXT;\n        case Qt::Key_Space:\n            return VK_SPACE;\n\n        // 符号键\n        case Qt::Key_Semicolon:\n            return VK_OEM_1; // ;\n        case Qt::Key_Equal:\n            return VK_OEM_PLUS; // =\n        case Qt::Key_Comma:\n            return VK_OEM_COMMA; // ,\n        case Qt::Key_Minus:\n            return VK_OEM_MINUS; // -\n        case Qt::Key_Period:\n            return VK_OEM_PERIOD; // .\n        case Qt::Key_Slash:\n            return VK_OEM_2; // /\n        case Qt::Key_QuoteLeft:\n            return VK_OEM_3; // `\n        case Qt::Key_BracketLeft:\n            return VK_OEM_4; // [\n        case Qt::Key_Backslash:\n            return VK_OEM_5; //\n        case Qt::Key_BracketRight:\n            return VK_OEM_6; // ]\n        case Qt::Key_Apostrophe:\n            return VK_OEM_7; // '\n\n        // 其他常用键\n        case Qt::Key_CapsLock:\n            return VK_CAPITAL;\n        case Qt::Key_NumLock:\n            return VK_NUMLOCK;\n        case Qt::Key_ScrollLock:\n            return VK_SCROLL;\n        case Qt::Key_Pause:\n            return VK_PAUSE;\n        case Qt::Key_Print:\n            return VK_PRINT;\n\n        default:\n            qDebug() << \"Unknown Qt key:\" << qtKey;\n            return 0; // 未知按键\n    }\n}\n    static UINT toModifier(Qt::KeyboardModifiers qtMod) {\n    UINT winMod = 0;\n\n    if (qtMod & Qt::ControlModifier)\n    {\n        winMod |= MOD_CONTROL;\n    }\n    if (qtMod & Qt::AltModifier)\n    {\n        winMod |= MOD_ALT;\n    }\n    if (qtMod & Qt::ShiftModifier)\n    {\n        winMod |= MOD_SHIFT;\n    }\n    if (qtMod & Qt::MetaModifier)\n    {\n        winMod |= MOD_WIN; // Windows 键\n    }\n\n    return winMod;\n}\n    static QtCombinedKey toQtCombinedKey(const QString& keyText) {\n    QKeySequence sequence = QKeySequence(keyText);\n\n    if (!sequence.isEmpty())\n    {\n        int combinedKey = sequence[0];\n        Qt::KeyboardModifiers modifier =\n          Qt::KeyboardModifiers(combinedKey & Qt::KeyboardModifierMask);\n        int key = combinedKey & ~Qt::KeyboardModifierMask;\n        return QtCombinedKey{ key, modifier };\n    }\n    else\n    {\n        return QtCombinedKey{ 0, Qt::NoModifier };\n    }\n}\n    static QString wrapText(QString keyText) {\n    return keyText.replace(\"Up\", \"⬆️\")\n      .replace(\"Down\", \"⬇️\")\n      .replace(\"Left\", \"⬅️\")\n      .replace(\"Right\", \"➡️\");\n}\n    UINT getVK() {\n    return toVK(m_key, m_modifier);\n}\n    UINT getModifier() {\n    return toModifier(m_modifier);\n}\n    QtCombinedKey getQtCombinedKey() {\n    return QtCombinedKey{ m_key, m_modifier };\n}\n    QString getKeyText() {\n    return keySequence().toString(QKeySequence::NativeText);\n}\n  protected:\n    void keyPressEvent(QKeyEvent* event) override {\n    int key = event->key();\n    Qt::KeyboardModifiers modifiers = event->modifiers();\n\n    // 忽略单独的修饰键\n    if (isModifierKey(key))\n    {\n        return;\n    }\n\n    m_key = key;\n    m_modifier = modifiers;\n\n    // 创建单个按键序列\n    QKeySequence singleKey(key | modifiers);\n    setKeySequence(singleKey);\n\n    // 🔚 结束编辑\n    emit editingFinished();\n    clearFocus();\n}\n  private:\n    void update() {\n    QKeySequence sequence = keySequence();\n\n    if (sequence.isEmpty())\n    {\n        m_key = 0;\n        m_modifier = Qt::NoModifier;\n    }\n    else\n    {\n        int combinedKey = sequence[0];\n        m_modifier =\n          Qt::KeyboardModifiers(combinedKey & Qt::KeyboardModifierMask);\n        m_key = combinedKey & ~Qt::KeyboardModifierMask;\n    }\n}\n  private:\n    bool isModifierKey(int key) const {\n    return (key == Qt::Key_Control || key == Qt::Key_Alt ||\n            key == Qt::Key_Shift || key == Qt::Key_Meta);\n}\n    int m_key;\n    Qt::KeyboardModifiers m_modifier;\n};"], ["/OpenSpeedy/cpuutils.h", "class CpuUtils {\n  private:\n    PDH_HQUERY hQuery = NULL;\n    PDH_HCOUNTER hCounter = NULL;\n    bool initialized = false;\n  public:\n    CpuUtils() {\n}\n    ~CpuUtils() {\n    if (hCounter) PdhRemoveCounter(hCounter);\n    if (hQuery) PdhCloseQuery(hQuery);\n}\n    bool init() {\n    // 创建查询\n    if (PdhOpenQuery(NULL, NULL, &hQuery) != ERROR_SUCCESS) return false;\n\n    if (PdhAddEnglishCounter(hQuery,\n                             L\"\\\\Processor(_Total)\\\\% Processor Time\",\n                             NULL,\n                             &hCounter) != ERROR_SUCCESS)\n    {\n        PdhCloseQuery(hQuery);\n        return false;\n    }\n\n    // 第一次采样\n    PdhCollectQueryData(hQuery);\n    initialized = true;\n    return true;\n}\n    double getUsage() {\n    if (!initialized) return -1;\n\n    // 收集数据\n    if (PdhCollectQueryData(hQuery) != ERROR_SUCCESS) return -1;\n\n    PDH_FMT_COUNTERVALUE value;\n    if (PdhGetFormattedCounterValue(hCounter, PDH_FMT_DOUBLE, NULL, &value) !=\n        ERROR_SUCCESS)\n        return -1;\n\n    return value.doubleValue;\n}\n    QString getModel() {\n    int cpuInfo[4];\n    char cpuBrand[48 + 1] = {0};\n\n    // 获取CPU品牌字符串(需要调用3次CPUID)\n    __cpuid(cpuInfo, 0x80000002);\n    memcpy(cpuBrand, cpuInfo, sizeof(cpuInfo));\n\n    __cpuid(cpuInfo, 0x80000003);\n    memcpy(cpuBrand + 16, cpuInfo, sizeof(cpuInfo));\n\n    __cpuid(cpuInfo, 0x80000004);\n    memcpy(cpuBrand + 32, cpuInfo, sizeof(cpuInfo));\n\n    QString result(cpuBrand);\n\n    return result.trimmed();\n}\n};"], ["/OpenSpeedy/main.cpp", "/*\n * OpenSpeedy - Open Source Game Speed Controller\n * Copyright (C) 2025 Game1024\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program.  If not, see <https://www.gnu.org/licenses/>.\n */\n#include \"mainwindow.h\"\n#include \"windbg.h\"\n#include <QApplication>\n#include <QCommandLineParser>\n#include <QLocalServer>\n#include <QLocalSocket>\n#include <QLocale>\n#include <QTranslator>\n#include <ShellScalingApi.h>\nint\nmain(int argc, char* argv[])\n{\n    SetUnhandledExceptionFilter(createMiniDump);\n    SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);\n    QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);\n    QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);\n    QApplication::setAttribute(Qt::AA_UseSoftwareOpenGL);\n    QApplication a(argc, argv);\n    winutils::enableAllPrivilege();\n\n    // 检查是否已有实例在运行\n    QString unique = \"OpenSpeedy\";\n    QLocalSocket socket;\n    socket.connectToServer(unique);\n    if (socket.waitForConnected(500))\n    {\n        socket.close();\n        return -1;\n    }\n\n    // 使用资源文件中的图标\n    QIcon appIcon;\n    appIcon.addFile(\":/icons/images/icon_16.ico\", QSize(16, 16));\n    appIcon.addFile(\":/icons/images/icon_32.ico\", QSize(32, 32));\n    appIcon.addFile(\":/icons/images/icon_64.ico\", QSize(64, 64));\n    a.setWindowIcon(appIcon);\n\n    QSettings settings =\n      QSettings(QCoreApplication::applicationDirPath() + \"/config.ini\",\n                QSettings::IniFormat);\n\n    QTranslator translator;\n    const QString baseName =\n      \"OpenSpeedy_\" +\n      settings.value(CONFIG_LANGUAGE, QLocale().system().name()).toString();\n\n    if (translator.load(\":/i18n/translations/\" + baseName))\n    {\n        a.installTranslator(&translator);\n    }\n\n    // 解析命令行参数\n    QCommandLineParser parser;\n    parser.setApplicationDescription(\"OpenSpeedy\");\n    QCommandLineOption minimizeOption(\n      QStringList() << \"m\" << \"minimize-to-tray\", \"启动时最小化到托盘\");\n    parser.addOption(minimizeOption);\n    parser.process(a);\n\n    MainWindow w;\n    w.resize(1024, 768);\n\n    if (parser.isSet(minimizeOption))\n    {\n        w.hide();\n    }\n    else\n    {\n        w.show();\n    }\n\n    // 创建并启动本地服务器\n    QLocalServer server;\n    QLocalServer::removeServer(unique);\n    server.listen(unique);\n    // 当用户尝试再运行一个进程时,将窗口显示到最前台\n    QObject::connect(&server,\n                     &QLocalServer::newConnection,\n                     [&]\n                     {\n                         w.show();\n                         w.raise();\n                         w.showNormal();\n                         w.activateWindow();\n                     });\n    return a.exec();\n}\n"], ["/OpenSpeedy/memutils.h", "class MemUtils {\n  private:\n    PDH_HQUERY hQuery = NULL;\n    PDH_HCOUNTER hCounter = NULL;\n    bool initialized = false;\n  public:\n    MemUtils() {\n}\n    bool init() {\n    if (PdhOpenQuery(NULL, NULL, &hQuery) != ERROR_SUCCESS) return false;\n\n    if (PdhAddEnglishCounter(hQuery,\n                             L\"\\\\Memory\\\\Available Bytes\",\n                             NULL,\n                             &hCounter) != ERROR_SUCCESS)\n    {\n        PdhCloseQuery(hQuery);\n        return false;\n    }\n\n    PdhCollectQueryData(hQuery);\n    initialized = true;\n    return true;\n}\n    double getTotal() {\n    MEMORYSTATUSEX memInfo;\n    memInfo.dwLength = sizeof(MEMORYSTATUSEX);\n    GlobalMemoryStatusEx(&memInfo);\n    return memInfo.ullTotalPhys / (1024.0 * 1024.0 * 1024.0);\n}\n    double getUsage() {\n    if (!initialized) return -1;\n\n    if (PdhCollectQueryData(hQuery) != ERROR_SUCCESS) return -1;\n\n    PDH_FMT_COUNTERVALUE available;\n    if (PdhGetFormattedCounterValue(hCounter,\n                                    PDH_FMT_DOUBLE,\n                                    NULL,\n                                    &available) != ERROR_SUCCESS)\n        return -1;\n\n    double totalMemory = getTotal() * 1024 * 1024 * 1024;\n    double usageMemory = totalMemory - available.doubleValue;\n\n    return usageMemory / (1024.0 * 1024.0 * 1024.0);\n}\n};"], ["/OpenSpeedy/preferencedialog.h", "class PreferenceDialog {\n    Q_OBJECT\n\n  public:\n    explicit PreferenceDialog(HWND hMainWindow,\n                              QSettings* settings,\n                              QLabel* increaseSpeedLabel,\n                              QLabel* decreaseSpeedLabel,\n                              QLabel* resetSpeedLabel,\n                              QWidget* parent = nullptr);\n    ~PreferenceDialog() {\n    unregisterGlobalHotkeys();\n    delete ui;\n}\n    int getIncreaseStep() {\n    return m_increaseStep;\n}\n    int getDecreaseStep() {\n    return m_decreaseStep;\n}\n    double getShift1() {\n    return m_shift1Value;\n}\n    double getShift2() {\n    return m_shift2Value;\n}\n    double getShift3() {\n    return m_shift3Value;\n}\n    double getShift4() {\n    return m_shift4Value;\n}\n    double getShift5() {\n    return m_shift5Value;\n}\n  public:\n    void show() {\n    unregisterGlobalHotkeys();\n    QDialog::show();\n}\n  private:\n    void on_buttonBox_accepted() {\n    update();\n    setupGlobalHotkeys();\n    redraw();\n    dump();\n}\n    void on_buttonBox_rejected() {\n    redraw();\n    setupGlobalHotkeys();\n}\n    void recreate() {\n    layout()->invalidate();\n    layout()->activate();\n    adjustSize();\n}\n  private:\n    void setupGlobalHotkeys() {\n    for (auto it = m_shortcuts.begin(); it != m_shortcuts.end(); it++)\n    {\n        int id = it.key();\n        QtCombinedKey combined = it.value();\n\n        UINT vk = QSingleKeySequenceEdit::toVK(combined.key, combined.modifier);\n        UINT modifier = QSingleKeySequenceEdit::toModifier(combined.modifier);\n        RegisterHotKey(m_mainwindow, id, modifier, vk);\n    }\n\n    qDebug() << \"全局快捷键已注册:\";\n}\n    void unregisterGlobalHotkeys() {\n    for (auto it = m_shortcuts.begin(); it != m_shortcuts.end(); it++)\n    {\n        int id = it.key();\n        UnregisterHotKey(m_mainwindow, id);\n    }\n    qDebug() << \"全局快捷键已注销\";\n}\n    void loadShortcut(int id,\n                      const QString& config,\n                      const QString& defaultValue) {\n    m_shortcuts.insert(id,\n                       QSingleKeySequenceEdit::toQtCombinedKey(\n                         m_settings->value(config, defaultValue).toString()));\n}\n    void dumpShortcut(const QString& config, const QString& keyText) {\n    m_settings->setValue(config, keyText);\n}\n    void dump() {\n    dumpShortcut(CONFIG_HOTKEY_SPEEDUP,\n                 ui->speedUpKeySequenceEdit->getKeyText());\n    dumpShortcut(CONFIG_HOTKEY_SPEEDDOWN,\n                 ui->speedDownKeySequenceEdit->getKeyText());\n    dumpShortcut(CONFIG_HOTKEY_RESETSPEED,\n                 ui->resetSpeedKeySequenceEdit->getKeyText());\n\n    dumpShortcut(CONFIG_HOTKEY_SHIFT1, ui->shift1KeySequenceEdit->getKeyText());\n    dumpShortcut(CONFIG_HOTKEY_SHIFT2, ui->shift2KeySequenceEdit->getKeyText());\n    dumpShortcut(CONFIG_HOTKEY_SHIFT3, ui->shift3KeySequenceEdit->getKeyText());\n    dumpShortcut(CONFIG_HOTKEY_SHIFT4, ui->shift4KeySequenceEdit->getKeyText());\n    dumpShortcut(CONFIG_HOTKEY_SHIFT5, ui->shift5KeySequenceEdit->getKeyText());\n    m_settings->setValue(CONFIG_INCREASE_STEP,\n                         ui->increaseStepSpinBox->value());\n    m_settings->setValue(CONFIG_DECREASE_STEP,\n                         ui->decreaseStepSpinBox->value());\n    m_settings->setValue(CONFIG_SHIFT1_VALUE, ui->shift1DoubleSpinBox->value());\n    m_settings->setValue(CONFIG_SHIFT2_VALUE, ui->shift2DoubleSpinBox->value());\n    m_settings->setValue(CONFIG_SHIFT3_VALUE, ui->shift3DoubleSpinBox->value());\n    m_settings->setValue(CONFIG_SHIFT4_VALUE, ui->shift4DoubleSpinBox->value());\n    m_settings->setValue(CONFIG_SHIFT5_VALUE, ui->shift5DoubleSpinBox->value());\n    m_settings->sync();\n}\n    void updateShortcut(int id, QSingleKeySequenceEdit* keyEdit) {\n    m_shortcuts[id] = keyEdit->getQtCombinedKey();\n}\n    void update() {\n    updateShortcut(HOTKEY_INCREASE_SPEED, ui->speedUpKeySequenceEdit);\n    updateShortcut(HOTKEY_DECREASE_SPEED, ui->speedDownKeySequenceEdit);\n    updateShortcut(HOTKEY_RESET_SPEED, ui->resetSpeedKeySequenceEdit);\n    updateShortcut(HOTKEY_SHIFT1, ui->shift1KeySequenceEdit);\n    updateShortcut(HOTKEY_SHIFT2, ui->shift2KeySequenceEdit);\n    updateShortcut(HOTKEY_SHIFT3, ui->shift3KeySequenceEdit);\n    updateShortcut(HOTKEY_SHIFT4, ui->shift4KeySequenceEdit);\n    updateShortcut(HOTKEY_SHIFT5, ui->shift5KeySequenceEdit);\n\n    m_increaseStep = ui->increaseStepSpinBox->value();\n    m_decreaseStep = ui->decreaseStepSpinBox->value();\n    m_shift1Value = ui->shift1DoubleSpinBox->value();\n    m_shift2Value = ui->shift2DoubleSpinBox->value();\n    m_shift3Value = ui->shift3DoubleSpinBox->value();\n    m_shift4Value = ui->shift4DoubleSpinBox->value();\n    m_shift5Value = ui->shift5DoubleSpinBox->value();\n}\n    void redrawSpinBox(QSpinBox* spinbox, int value) {\n    spinbox->setValue(value);\n}\n    void redrawSpinBox(QDoubleSpinBox* spinbox, double value) {\n    spinbox->setValue(value);\n}\n    void redrawKeyEdit(QSingleKeySequenceEdit* keyEdit, int id) {\n    QtCombinedKey combinedKey = m_shortcuts[id];\n    keyEdit->setKeySequence(combinedKey.key | combinedKey.modifier);\n}\n    void redraw() {\n    redrawKeyEdit(ui->speedUpKeySequenceEdit, HOTKEY_INCREASE_SPEED);\n    redrawKeyEdit(ui->speedDownKeySequenceEdit, HOTKEY_DECREASE_SPEED);\n    redrawKeyEdit(ui->resetSpeedKeySequenceEdit, HOTKEY_RESET_SPEED);\n    redrawKeyEdit(ui->shift1KeySequenceEdit, HOTKEY_SHIFT1);\n    redrawKeyEdit(ui->shift2KeySequenceEdit, HOTKEY_SHIFT2);\n    redrawKeyEdit(ui->shift3KeySequenceEdit, HOTKEY_SHIFT3);\n    redrawKeyEdit(ui->shift4KeySequenceEdit, HOTKEY_SHIFT4);\n    redrawKeyEdit(ui->shift5KeySequenceEdit, HOTKEY_SHIFT5);\n\n    redrawSpinBox(ui->increaseStepSpinBox, m_increaseStep);\n    redrawSpinBox(ui->decreaseStepSpinBox, m_decreaseStep);\n    redrawSpinBox(ui->shift1DoubleSpinBox, m_shift1Value);\n    redrawSpinBox(ui->shift2DoubleSpinBox, m_shift2Value);\n    redrawSpinBox(ui->shift3DoubleSpinBox, m_shift3Value);\n    redrawSpinBox(ui->shift4DoubleSpinBox, m_shift4Value);\n    redrawSpinBox(ui->shift5DoubleSpinBox, m_shift5Value);\n\n    m_increaseSpeedLabel->setText(\n      QString(tr(\"%1 增加速度\"))\n        .arg(QSingleKeySequenceEdit::wrapText(\n          ui->speedUpKeySequenceEdit->getKeyText())));\n\n    m_decreaseSpeedLabel->setText(\n      QString(tr(\"%1 减少速度\"))\n        .arg(QSingleKeySequenceEdit::wrapText(\n          ui->speedDownKeySequenceEdit->getKeyText())));\n\n    m_resetSpeedLabel->setText(\n      QString(tr(\"%1 重置速度\"))\n        .arg(QSingleKeySequenceEdit::wrapText(\n          ui->resetSpeedKeySequenceEdit->getKeyText())));\n\n    adjustSize();\n}\n    Ui::PreferenceDialog* ui;\n    QSettings* m_settings;\n    QLabel* m_increaseSpeedLabel;\n    QLabel* m_decreaseSpeedLabel;\n    QLabel* m_resetSpeedLabel;\n    QMap<int, QtCombinedKey> m_shortcuts;\n    double m_shift1Value;\n    double m_shift2Value;\n    double m_shift3Value;\n    double m_shift4Value;\n    double m_shift5Value;\n    int m_increaseStep;\n    int m_decreaseStep;\n    HWND m_mainwindow;\n};"], ["/OpenSpeedy/config.h", "/*\n * OpenSpeedy - Open Source Game Speed Controller\n * Copyright (C) 2025 Game1024\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program.  If not, see <https://www.gnu.org/licenses/>.\n */\n#ifndef CONFIG_H\n#define CONFIG_H\n\n#define OPENSPEEDY_VERSION \"v1.7.6\"\n\n#define BRIDGE32_EXE \"bridge32.exe\"\n#define BRIDGE64_EXE \"bridge64.exe\"\n\n#define SPEEDPATCH32_DLL \"speedpatch32.dll\"\n#define SPEEDPATCH64_DLL \"speedpatch64.dll\"\n\n#define CONFIG_LANGUAGE \"General/Language\"\n\n// 热键ID\nenum HotkeyIds\n{\n    HOTKEY_INCREASE_SPEED = 1001,\n    HOTKEY_DECREASE_SPEED = 1002,\n    HOTKEY_RESET_SPEED = 1003,\n    HOTKEY_SHIFT1 = 1011,\n    HOTKEY_SHIFT2 = 1012,\n    HOTKEY_SHIFT3 = 1013,\n    HOTKEY_SHIFT4 = 1014,\n    HOTKEY_SHIFT5 = 1015\n};\n\n#endif // CONFIG_H\n"], ["/OpenSpeedy/aboutdialog.h", "class AboutDialog {\n    Q_OBJECT\n\n  public:\n    explicit AboutDialog(QWidget* parent = nullptr);\n    ~AboutDialog() {\n    delete ui;\n}\n  private:\n    void recreate() {\n    layout()->invalidate();\n    layout()->activate();\n    adjustSize();\n}\n  private:\n    Ui::AboutDialog* ui;\n};"], ["/OpenSpeedy/speedpatch/SpeedPatch_global.h", "/*\n * OpenSpeedy - Open Source Game Speed Controller\n * Copyright (C) 2025 Game1024\n * \n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n * \n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n * GNU General Public License for more details.\n * \n * You should have received a copy of the GNU General Public License\n * along with this program.  If not, see <https://www.gnu.org/licenses/>.\n */\n#ifndef SPEEDPATCH_GLOBAL_H\n#define SPEEDPATCH_GLOBAL_H\n\n\n#endif // SPEEDPATCH_GLOBAL_H\n"], ["/OpenSpeedy/mainwindow.h", "class MainWindow {\n};"], ["/OpenSpeedy/speedpatch/speedpatch.h", "class speedpatch {\n};"]], "task_instance_info": {"created_time": "2025-08-20 20:13:07", "created_task_model": "DeepSeek-R1", "code_description": "This code segment functions to: Collect memory utilization metrics and system architecture details from active processes while determining their execution priority levels for comprehensive process monitoring purposes."}, "inference_content": {"inference_model": "DeepSeek-R1", "inference_result": "```cpp\n[TASK_BEGIN]\n        if (hProcess)\n        {\n            PROCESS_MEMORY_COUNTERS pmc;\n            if (GetProcessMemoryInfo(hProcess, &pmc, sizeof(pmc)))\n            {\n                info.memoryUsage = pmc.WorkingSetSize;\n            }\n\n            DWORD priority = GetPriorityClass(hProcess);\n            switch (priority)\n            {\n            case REALTIME_PRIORITY_CLASS:\n                info.priority = \"Realtime\";\n                break;\n            case HIGH_PRIORITY_CLASS:\n                info.priority = \"High\";\n                break;\n            case ABOVE_NORMAL_PRIORITY_CLASS:\n                info.priority = \"Above Normal\";\n                break;\n            case NORMAL_PRIORITY_CLASS:\n                info.priority = \"Normal\";\n                break;\n            case BELOW_NORMAL_PRIORITY_CLASS:\n                info.priority = \"Below Normal\";\n                break;\n            case IDLE_PRIORITY_CLASS:\n                info.priority = \"Idle\";\n                break;\n            default:\n                info.priority = \"Unknown\";\n            }\n            \n            CloseHandle(hProcess);\n        }\n[TASK_END]\n```", "inference_time": "2025-08-20 20-13-24"}, "editdistance_info": {"edit_distance": 37.5661, "calculate_time": "2025-08-20 20:13:24", "true_code_clean": "if (hProcess)\n        {\n            PROCESS_MEMORY_COUNTERS pmc;\n            if (GetProcessMemoryInfo(hProcess, &pmc, sizeof(pmc)))\n            {\n                info.memoryUsage = pmc.WorkingSetSize;\n            }\n            else\n            {\n                info.memoryUsage = 0;\n            }\n            BOOL wow64Process = FALSE;\n            IsWow64Process(hProcess, &wow64Process);\n            info.is64Bit = !wow64Process;\n            info.priorityClass = GetPriorityClass(hProcess);\n            CloseHandle(hProcess);\n        }\n        else\n        {\n            info.memoryUsage = 0;\n            info.priorityClass = 0;\n        }", "predict_code_clean": "if (hProcess)\n        {\n            PROCESS_MEMORY_COUNTERS pmc;\n            if (GetProcessMemoryInfo(hProcess, &pmc, sizeof(pmc)))\n            {\n                info.memoryUsage = pmc.WorkingSetSize;\n            }\n            DWORD priority = GetPriorityClass(hProcess);\n            switch (priority)\n            {\n            case REALTIME_PRIORITY_CLASS:\n                info.priority = \"Realtime\";\n                break;\n            case HIGH_PRIORITY_CLASS:\n                info.priority = \"High\";\n                break;\n            case ABOVE_NORMAL_PRIORITY_CLASS:\n                info.priority = \"Above Normal\";\n                break;\n            case NORMAL_PRIORITY_CLASS:\n                info.priority = \"Normal\";\n                break;\n            case BELOW_NORMAL_PRIORITY_CLASS:\n                info.priority = \"Below Normal\";\n                break;\n            case IDLE_PRIORITY_CLASS:\n                info.priority = \"Idle\";\n                break;\n            default:\n                info.priority = \"Unknown\";\n            }\n            CloseHandle(hProcess);\n        }"}}