Trcmoe 发表于 2025-10-4 16:24:44

weeds 发表于 2025-10-4 16:17
我问一下,kail Liunx可以制作系统吗?

所以你的大胆本质上就是套壳是吗

weeds 发表于 2025-10-4 16:56:03

Trcmoe 发表于 2025-10-4 16:24
所以你的大胆本质上就是套壳是吗

NO!我只是先基于Liunx制作,然后再有一定经验后制作纯血版的

weeds 发表于 2025-10-4 19:26:31

现在我让DeepSeek编了一个C++语言,并使用NT内核的系统代码(同样只透露第1部分):

内核模块:// SK_Core.h - 核心内核头文件
#ifndef SK_CORE_H
#define SK_CORE_H

#include <ntddk.h> // 借用NT内核的基础定义

namespace SK {
    namespace Core {

      // 1. 进程与线程管理 (融合Linux的轻量级进程概念)
      class ProcessManager {
      public:
            static NTSTATUS CreateProcess(SK_PROCESS* parentProcess, const wchar_t* imagePath, SK_PROCESS** newProcess);
            static NTSTATUS CreateThread(SK_PROCESS* process, SK_THREAD** newThread);
            static void Schedule(); // 调度器,支持多核与低功耗
      };

      // 2. 高级内存管理 (融合Linux的Slab分配器与NT的虚拟内存管理)
      class MemoryManager {
      public:
            static void*AllocateKernelMemory(size_t size, MEMORY_CACHING_TYPE cacheType);
            static void   FreeKernelMemory(void* ptr);
            static NTSTATUS MapUserMemory(SK_PROCESS* process, void* virtualAddress, size_t size, ULONG protection);
            
            // 低内存优化:动态压缩与智能交换
            static void   EnableMemoryCompression(bool enable);
            static size_t GetSystemMemoryUsage();
      };

      // 3. 统一的硬件抽象层 (HAL) - 支持多核与异构计算
      class HardwareAbstractionLayer {
      public:
            static bool Initialize(); // 探测并初始化CPU、内存控制器、中断控制器等
            static void EnableSMP(); // 对称多处理支持
            static void* GetDriverInterface(const char* driverId); // 统一的驱动接口
      };

      // 4. 安全子系统 (融合iOS的沙盒与NT的安全令牌)
      class SecurityManager {
      public:
            static bool MandatoryAccessCheck(SK_PROCESS* process, const char* resource, ACCESS_MASK desiredAccess);
            static NTSTATUS CreateSandbox(const wchar_t* sandboxProfile, SK_SANDBOX** sandbox);
      };
    }
}

// 系统全局状态
extern SK::Core::SystemGlobalState g_SystemState;

#endif // SK_CORE_H
入口点:// SK_Main.cpp - 内核入口
extern "C" NTSTATUS DriverEntry(_In_ PDRIVER_OBJECT DriverObject, _In_ PUNICODE_STRING RegistryPath) {
    UNREFERENCED_PARAMETER(DriverObject);
    UNREFERENCED_PARAMETER(RegistryPath);

    KdPrint((" Kernel Initialization Starting...\n"));

    // 阶段1:基础硬件初始化
    if (!SK::Core::HardwareAbstractionLayer::Initialize()) {
      KdPrint((" HAL Initialization Failed!\n"));
      return STATUS_UNSUCCESSFUL;
    }

    // 阶段2:内存管理器初始化
    SK::Core::MemoryManager::Initialize();
    SK::Core::MemoryManager::EnableMemoryCompression(true); // 默认开启内存压缩

    // 阶段3:启用SMP(对称多处理)
    SK::Core::HardwareAbstractionLayer::EnableSMP();

    // 阶段4:进程与对象管理器初始化
    SK::Core::ProcessManager::Initialize();
    SK::Core::ObjectManager::Initialize();

    // 阶段5:安全子系统初始化
    SK::Core::SecurityManager::Initialize();

    // 阶段6:启动第一个用户态进程 - 系统服务管理器 (System Service Manager, SSM)
    // SSM 将负责启动所有其他用户态服务(如图形服务器、文件服务等)
    SK_PROCESS* ssmProcess;
    NTSTATUS status = SK::Core::ProcessManager::CreateProcess(nullptr, L"\\System\\SSM.exe", &ssmProcess);
    if (!NT_SUCCESS(status)) {
      KdPrint((" Failed to start System Service Manager!\n"));
      return status;
    }

    KdPrint((" Kernel Initialization Complete. System is now live.\n"));

    return STATUS_SUCCESS;
}
内存优化技术:// MemoryManager.cpp - 内存压缩示例(简化概念)
namespace SK {
    namespace Core {
      void MemoryManager::HandleLowMemory() {
            // 当可用内存低于阈值时...
            PageFrame* candidatePages = FindIdlePages();
            for (PageFrame* page : candidatePages) {
                CompressedPage* compressed = CompressPage(page);
                StoreCompressedPage(compressed);
                MarkPageAsCompressed(page); // 更新页表项
                FreePhysicalFrame(page);
            }
      }

      void* MemoryManager::AccessCompressedPage(virtual_address_t va) {
            // 当访问被压缩的页面时,触发页错误...
            // 在页错误处理程序中,我们在这里解压页面
            CompressedPage* compressed = FindCompressedPage(va);
            PageFrame* newFrame = AllocatePhysicalFrame();
            DecompressPage(compressed, newFrame);
            MapVirtualToPhysical(va, newFrame);
            RemoveCompressedPage(compressed);
            return newFrame;
      }
    }
}

nicocat 发表于 2025-10-4 20:42:24

weeds 发表于 2025-10-4 19:26
现在我让DeepSeek编了一个C++语言,并使用NT内核的系统代码(同样只透露第1部分):

内核模块:// SK_Core ...

有点高级了,居然还是CPP😂

weeds 发表于 2025-10-4 21:39:03

我也不知道管理员们又会怎么怼我

weeds 发表于 2025-10-4 21:52:49

nicocat 发表于 2025-10-4 20:42
有点高级了,居然还是CPP😂

高级吗{:0.o:}

Trcmoe 发表于 2025-10-4 21:58:31

weeds 发表于 2025-10-4 19:26
现在我让DeepSeek编了一个C++语言,并使用NT内核的系统代码(同样只透露第1部分):

内核模块:// SK_Core ...

不赖,核心代码全在不存在的头文件里,贴出来的代码全是不存在的函数,评价是感觉AI比你聪明点,因为它知道怎么糊弄你。

weeds 发表于 2025-10-4 22:01:43

Trcmoe 发表于 2025-10-4 21:58
不赖,核心代码全在不存在的头文件里,贴出来的代码全是不存在的函数,评价是感觉AI比你聪明点,因为它知 ...

。。。。。。。。。。

SHEEP_REALMS 发表于 2025-10-4 22:21:05

你现在急转弯跑去搞抽象还能成功起号:https://www.bilibili.com/video/BV1HZEZzeEeH/

weeds 发表于 2025-10-5 10:23:49

SHEEP_REALMS 发表于 2025-10-4 22:21
你现在急转弯跑去搞抽象还能成功起号:https://www.bilibili.com/video/BV1HZEZzeEeH/

要不是你搅屎,我的这个帖子也不会到这个地步!
页: 1 2 3 4 5 [6] 7 8 9 10
查看完整版本: 我又有一个大胆的想法