NT4源码编译环境

转自:http://yanshurong.spaces.live.com/blog/cns!33C6A79B73579F0!275.entry

2004212号,有人将Microsoft Windows NT 4Microsoft Windows 2000的部分核心源代码泄露出来,并在网上传播。对此,微软公司发言人汤姆·皮拉表示:我们发现Windows 2000NT 4.0的部分源代码非法地出现在互联网上。并警告说,任何第三方传播这些源代码都是非法的行为,微软将对此采取严肃行动。不过相信很多对Windows内核感兴趣的朋友还是在第一时间下载到了这些压缩文件。如果你没有,也不用着急,虽然我不能告诉你直接的下载地址,但即使到今天,你仍然可以尝试通过emule或迅雷等P2P工具搜索到,关键字分别是nt sourcewindows_2000_source_code。请记住,为了不必要的法律纠纷,不要把这些代码用于商业目的,也不要传播这些代码,学习完后应该立刻把这些代码删除,如果由此引起任何法律问题,本人概不负责。

 

在泄露当天我得到了相关代码,至于从哪下的忘掉了,好像是一个国外网站。NT4的代码压缩包大小是229M2000的是203M。通过研究分析,NT4代码相对比较全,可以编译出绝大部分系统核心文件(起码我想编译的大都编译出来了),2000代码基本上只能看,不能编译,因为缺失了太多的头文件。今天突然起了怀旧之心,想来个故地重游,本以为轻车熟路,应该很快就能搞定,不料还是碰到不少问题,虽然凭记忆最终还是得以解决,但还是花了不少时间。其间也借助google尝试查找这方面的信息,但结果并不是很理想,尤其是NTLDR的编译可以说没有任何相关信息,为了方便大家也为了方便自己以后查找,特意把步骤记录下来。发表是最好的记忆。

 

这篇文章主要讨论代码的编译环境搭建,后面有时间的话我会陆续写出编译NTLDRntoskrnl.exehal.dll以及win32k.sys等文件的详细编译步骤。由于我可爱的小黑一直用的是XP,下面就介绍XP系统下编译环境的搭建,在这你需要准备好VC6.0NT4DDK以及NT4的源代码压缩包。NT4DDK可以从下载。(可惜MS对中国还不开放SkyDrive,否则我可以把相应修改后的文件放上去了)

 

1 安装VC6.0

2  由于在XP2003下没办法安装NT4 DDK,只好在另外一台WIN2K的机器(可以是虚拟机)上安装选自定义安装,仅安装库和头文 件。假定安装到c:\ddk

3  把上一步中的c:\ddk目录整个拷到XP系统的d:\下,这样就类似于把NT4 DDK安装到XP系统下的d:\ddk中。

4  nt4源代码解压到d:\nt下,里面应包含privatepublic两个目录。

5  d:\ddk目录下创建buildchk.bat文件,其内容是:

cmd.exe /k D:\DDK\bin\setenv.bat D:\DDK checked

       d:\ddk目录下创建buildfre.bat文件,其内容是:

cmd.exe /k D:\DDK\bin\setenv.bat D:\DDK free

6.  拷贝D:\nt\public\sdk\lib\coffbase.txtD:\DDK\lib\i386\free目录。

7.   点击d:\ddk\buildfre.bat,切换到D:\nt\private\sdktools目录,尽可能多的编译其中的文件,并把编好的文件拷贝到D:\nt\public\tools。其中至少应包括chmode.exe ech.exe gensrv.exe hextract.exe hsplist.exe listmung.exe masm386.exe strcto.exe touch.exe wcshdr.exe ws2hdr.exe。如果在编译过程中碰到类似“link() : error LNK1104: cannot open file "obj\i386\free\structo.exe"”的错误,手动在其i386目录下创建free目录,再重新编译。

8.   d:\nt目录下创建ntos.bat文件,其内容是:

              set CPUTYPE=I386

set USE_PDB=1

set NTDEBUG=ntsd

set NTDEBUGTYPE=windbg

set BASEDIR=\nt

set _NTDRIVE=d:

set _NTROOT=\nt

set NT_UP=1

rem set C_DEFINES=%C_DEFINES% -D_UNICODE -DUNICODE

path d:\nt\public\tools;%PATH%

9  修改d:\ddk\inc下的MAKEFILE.DEF文件,其中原来的92-101行更改为:

#modified by David

SDK_INC_PATH = D:\nt\public\sdk\inc

CRT_INC_PATH = D:\nt\public\sdk\inc\crt

OAK_INC_PATH = D:\nt\public\oak\inc

 

#SDK_LIB_PATH = $(BASEDIR)\lib\*\$(DDKBUILDENV)

#DDK_LIB_PATH = $(BASEDIR)\lib\*\$(DDKBUILDENV)

#CRT_LIB_PATH = $(BASEDIR)\lib\*\$(DDKBUILDENV)

 

#modified by David

SDK_LIB_PATH = D:\nt\public\sdk\lib\*

DDK_LIB_PATH = D:\nt\public\sdk\lib\*

CRT_LIB_PATH = D:\nt\public\sdk\lib\*

USE_PDB=1

#BROWSER_INFO=1

BUILD_OPTIONS=fe

LINKER_FLAGS=$(LINKER_FLAGS) $(SDK_LIB_PATH)\exsup.lib

 

MASTER_VERSION_FILE = $(BASEDIR)\inc\ntverp.h

 

#modified by David

 

#COFFBASE_TXT_FILE = $(BASEDIR)\lib\*\$(DDKBUILDENV)\coffbase.txt

COFFBASE_TXT_FILE = $(BASEDIR)\public\sdk\lib\coffbase.txt

10.   如果你安装NT4DDK的WIN2K系统不是英文环境,修改D:\ddk\bin下的SETENV.BAT文件,其中原来的95行更改为:

              set LANGUAGE=USA

        原来的109行更改为:

              set LANGUAGE=USA

11  修改D:\nt\public\sdk\inc下的ntdbg.h文件,其中原来的213-221行更改为:

//modified by David

/*typedef enum _DBGUI_APINUMBER {

                  DbgUiWaitStateChangeApi,

                  DbgUiContinueApi,

                  DbgUiMaxI

}

CsrGetProcessLuid(

                  HANDLE ProcessHandle,

                  PLUID LuidProcess

                  );*/

 

//added by David

#define PCSR_API_ROUTINE ULONG

#define PCSR_1P_API_ROUTINE ULONG

#define PCSR_SERVER_CONNECT_ROUTINE ULONG

#define PCSR_SERVER_DISCONNECT_ROUTINE ULONG

#define PCSR_SERVER_ADDTHREAD_ROUTINE ULONG

#define PCSR_SERVER_DELETETHREAD_ROUTINE ULONG

#define PCSR_SERVER_INITTHREAD_ROUTINE ULONG

#define PCSR_SERVER_EXCEPTION_ROUTINE ULONG

#define PCSR_SERVER_HARDERROR_ROUTINE ULONG

#define PCSR_SERVER_ADDPROCESS_ROUTINE ULONG

#define PCSR_SERVER_SHUTDOWNPROCESS_ROUTINE ULONG

#define PCSR_API_DISPATCH_ROUTINE ULONG

   原来的262行后插入:

//added by David

#define NTCSRAPI

#define PCSR_THREAD ULONG

   原来的276行后插入:

              //added by David

#define PCSR_NT_SESSION ULONG

   原来的298行后插入:

              //added by David

#define PCSR_PROCESS ULONG

   原来的313行后插入:

              //modified by David

#define PDBGSS_DBGKM_APIMSG_FILTER ULONG

   原来的319-320行更改为:

              OUT PCSR_PROCESS *Process,

              IN ULONG NTCSoutine OPTIONAL,

   原来的337行后插入:

              //added by David

#define PDBGUI_WAIT_STATE_CHANGE ULONG 

Utilities for Windows NT Besides my research work I am responsible for a couple of computers at the physics department of the University of Mainz which are running under Windows NT. Therefore I started developing some utilities which I think are missing in the core operating system. These programs will be free to use for everyone (which does not mean that I will not appreciate any donations if you like them, and if they save your time and money - this hint is directed mainly to users in a commercial environment). Disclaimer: These programs are provided "as is" and come without any warranty of any kind, either expressed or implied, including but not limited to fitness for a particular purpose or a particular system. In no case shall the author be liable for any damage or unwanted behavior of any computer hardware and/or software, including but not limited to data loss or time spent to recover your system. Do not test this program on your production machines without a backup you know you can restore! A new service: You can send an e-mail to ntutils@bibserver.physik.uni-mainz.de to automatically receive information about new versions of some or all of the listed utilities. NEWGINA How to run a script at logoff! How to run a script at system shutdown! How to get rid of CTRL-ALT-DEL prior to logging on! Very new and untested... try at your own risk! It is distributed under the GNU General Public License, and comes with source code and binaries for Intel x86. More information can be found in the README file. Download newgina_pre09.zip (approx. 64k). Important information (a little bug): The user logoff script does not execute if there is no log file set. Set the log file to NUL:. (An old version without the logoff/shutdown script option with binaries for DEC Alpha is still available.) CHOWN Demonstrates that it is possible to assign a new owner to a file, even if Microsoft asserts that this is impossible. Not the first implementation of such a program, but source is included, so you may understand how this works. There are no miracles. V1.1 changes more reliably the owner of files where the Administrator has no access to. It is distributed under the GNU General Public License, and comes with source code and binaries for Intel x86. Type 'chown' on the command line for a short instruction. More information can be found in the README file. Download Version 1.1 of chown.zip (approx. 35k). There is also a GUI frontend written by Suppi. Please contact him for any questions regarding this frontend. More information can be found in the README file. CLOSE Closes a window from the command line based on its title in the title bar by sending a WM_CLOSE message. This allows graceful shutdown of applications as opposed to KILL utilities (e.g. from the Resource Kit), which do not give the application some time to tidy up. It is distributed under the GNU General Public License, and comes with source code and binaries for Intel x86. Type 'close' on the command line for a short information. Usage should be self-explanatory. Download close.zip (approx. 20k). MOVEEX Replaces or moves files currently in use, e.g. system DLLs. This is nothing more than a command line interface to the MoveFileEx() API call with a flag that delays the move until the next reboot. More information can be found in the README file. Binary for x86 only, but source is included. Download moveex.zip (approx. 21k) PUSHKEYS for C This is a straightforward port of Christopher Latta's Pushkeys for Visual Basic to C. It is equivalent to the VB SendKeys statement (unfortunately missing in C), which allows to send keystrokes to open applications, including DOS application. Included is a short demo program, which may be useful on its own (type 'pushkeys' on the command line for usage instructions and a short example), as well as the original VB program which includes the help file (in the /orig directory). It should run under Windows 95 as well. Download pushkeyc.zip (approx. 35k). LOGOFF A tool to log off users from their workstations remotely or unattended. This tool is in a very early (pre-beta) stage and will be part of a service that monitors the valid logon hours and logs of users whose logon hours have expired, but should already be useful as a standalone program. It is distributed under the GNU General Public License, and comes with source code and binaries for Intel x86, but without (much) documentation. Few information can be found in the README file. For more information contact me. Download logoff.zip V0.1 PRE-BETA (approx. 80k). NOLOCKWS Especially for large PC pools in universities or schools it is very annoying when users lock their NT workstations, leave, and forget to come back. Subsequent users have the choice of resetting the PC or calling an administrator who can unlock the workstation. While lots of Windows NT settings can be changed through the registry, disabling the Lock Workstation button in the Windows NT Security (Ctrl-Alt-Del) dialog seems to be forgotten. This program allows administrators to disable or re-enable the Lock Workstation button. Version 0.99 BETA can now handle Novell's IntraNetware Client, which uses its own Gina (with the same lack of configurability), and eases the use with international version of Windows NT. NOLOCKWS is distributed under the GNU General Public License, comes with source code and binaries for DEC Alpha and Intel x86. More information can be found in the README file. Download nolockws.zip V0.99 BETA (approx. 95k). PASSWD This utility allows changing passwords on the command line or from within a batch file (non-interactive) instead of the usual CTRL-ALT-DEL dialog. It is also possible to change the password on remote domains or machines. No special privileges are necessary to issue this command (in contrast to the 'net user' command, which allows password changing as well, but only for users with administrative privileges). Intended for: Users who come from other operating systems like Unix or VMS and think it is unnecessary to do everything with a GUI interface. Users who want to automate tasks like password changing in a batch file or want to force users to change passwords in their logon script. Allow password changing for users who (can) never physically log on to a computer with the CTRL-ALT-DEL dialog, but use this computer for a PPP connection or log on through a Telnet connection. Now with source code and distributed under the GNU General Public License Download passwd.zip (approx. 29k). More useful utilities written by others... I am working on more utilities, including a program that forces users to log off after the logon hours have expired (and not just disconnects network connections to a server). Watch out! (C) by Alexander Frink, July 1997 (back to my homepage).
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值