Windows 10源码一览!

Windows 操作系统本身是不开源的,但是微软内核工程师 Axel Rietschin 发表了一篇博客,带大家一窥了Windows 10 内核的魅力。

 

Axel 介绍,Windows 10 与 Windows 8.x、7、Vista、XP、2000 和 NT 的代码库是相同的,其中每一代都在之前的基础上进行重大的重构,并增加大量新功能,改进性能和硬件支持,此外还有安全性的提升,同时保持非常高的后向兼容性。

目前在 GitHub 上其实可以找到 Windows 内核研究的泄露副本,虽然这些代码已经过时且很不完整,但它们还是具有很高的研究价值。

比如 wrk-v1.2/base/ntos/config 源码实现了一个大名鼎鼎的内核组件配置管理器 Registry,也就是注册表,它在内部称被为 Cm。

其实 Axel 这个博客是在回答一个问题:“Windows 10 是由什么语言写就的?”

他介绍,ntoskrnl.exe 内核大部分是使用 C 编写的,在内核模式下运行的大多数内容也是用 C 编定的,包括文件系统、网络与驱动程序等。其中也包含一些 C++ 代码,而越靠近用户模式、越接近新的源码时,C 的使用变得越来越少,反之 C++ 变多。

具体看一下 Windows 10 “DVD” 的源码,作者猜测其中 98% 由 C 和 C++ 写就,而 C 占据大比例。

此外,.NET BCL 与一些相关库和框架通常都是用 C# 编写的,“但它们也只不过是带有几座 C++ 小岛的 C 汪洋大海的一栗”,它们自不同的部门,代码并不属于 Windows 源码树。

作者惊呼:Windows 源码的规模巨大,这是一个真正史诗般的巨型项目。

 

完整的源码树包含所有代码,如上图所示,测试代码与一起构成“Windows 源码”的所有内容加起来有超过 400 万个文件、50 万个文件夹、大小超过 0.5 TB,其中包含了构成 OS 工作站、服务器和所有版本的工具、相关开发工具包的每个组件的代码。

源码的规模有多恐怖呢?作者估计完全查看这些源码的文件名,并试图理解源码具体是用来干什么的,需要花上一生的时间。

他还举了一个例子:有一次,我离开了一个 Git 分支几个星期,当我回来时,已经落在了将近 60 000 次 commit 之后。

博客原文:

 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
[上一页 [下一页] 前言 Windows Driver Model(WDM)的根源可追溯到几年前一种叫做Windows for Workgroups 3.10的操作系统。那时候我们努力地支持无数不同的SCSI控制器,我长期地注意WindowsNT开发组创建的小端口驱动程序类型。不久就认识到重新构造必要的映象加载器(image loader)和小端口驱动程序需要的执行环境比把这些小端口驱动程序重写成某些VXD形式的驱动程序并调试完毕所花费的努力要少得多。 不幸的是,Windows from Workgroups 3.10已经停止发行带有SCSI小端口支持的版本,主要是由于象ASPI(高级SCSI编程接口)这样的外围问题。然而,跨Windowswindows NT操作系统共享同样的驱动程序执行映象的基础是适当的并且可以在win95中见到,它(win95)可以与NT共享SCSI和NDIS小端口驱动程序二进制代码。 共享驱动程序模式的潜在意义是重大的。驱动程序开发人员感兴趣的是支持双平台,共享驱动模式能降低开发和调试的一半开消。对微软来说,共享模式意味着更容易地从win9x迁移到Windows2000或这个平台的未来版本。对最终用户来说,大量不同种类的稳定驱动程序可以在这个家族中的所有成员之间通用。 下一个(逻辑)步骤是 The next logical step, then, was to create a driver model with the ability to share general purpose drivers across both platforms. But what form should it take? Three requirements were immediately obvious: it must be multiprocessor-capable, it must be processor-independent, and it must support Plug and Play (PnP). Fortunately, the Windows NT 4.0 driver model met the first two requirements, and it seemed clear that the next major release of Windows NT would support PnP as well. As a result, WDM can be considered a proper subset of what is now the Windows NT driver model. The potential benefits of a shared driver model can be realized today for many classes of devices, and choosing the WDM driver model will continue to pay dividends in the future. For example, a correctly written WDM driver requires only a recompile before functioning in an NT 64-bit environment prototype. WDM will continue to evolve as new platforms and device classes are supported. Future versions of Windows 9x and Windows 2000 will contain upwardly revised WDM execution environments. Fortunately, WDM is designed to be "backward compatible," meaning that WDM drivers written according to the Windows 2000 DDK and designed to work for the intended environment will continue to work in a subsequent WDM environments. There is a lot to WDM, and in this book Walter does an excellent job in offering an in-depth tour of every aspect as well as the philosophy of the Windows Driver Model. Forrest Foltz 微软公司Windows开发体系结构设计者
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值