[笔记]TrueCrypt7.0a代码编译流程 (已更新 TrueCrypt 7.2代码在Win8.1 64位下编译流程)

早期版本的TrueCrypt若要编译成功,的确需要做多项微调,但是对于7.0a版本的代码,只需按照如下流程,即可在WinXP 32位系统下成功编译。

代码的ReadMe.txt是这么写的:

I. Windows
==========

Requirements for Building TrueCrypt for Windows:
------------------------------------------------

- Microsoft Visual C++ 2008 SP1 (Professional Edition or compatible)
- Microsoft Visual C++ 1.52 (available from MSDN Subscriber Downloads)
- Microsoft Windows SDK for Windows 7 (configured for Visual C++)
- Microsoft Windows Driver Kit 7.1.0 (build 7600.16385.1)
- RSA Security Inc. PKCS #11 Cryptographic Token Interface (Cryptoki) 2.20
  header files (available at ftp://ftp.rsasecurity.com/pub/pkcs/pkcs-11/v2-20)
- NASM assembler 2.08 or compatible
- gzip compressor

IMPORTANT:

The 64-bit editions of Windows Vista and later versions of Windows, and in
some cases (e.g. playback of HD DVD content) also the 32-bit editions, do not
allow the TrueCrypt driver to run without an appropriate digital signature.
Therefore, all .sys files in official TrueCrypt binary packages are digitally
signed with the digital certificate of the TrueCrypt Foundation, which was
issued by a certification authority. At the end of each official .exe and
.sys file, there are embedded digital signatures and all related certificates
(i.e. all certificates in the relevant certification chain, such as the
certification authority certificates, CA-MS cross-certificate, and the
TrueCrypt Foundation certificate). Keep this in mind if you compile TrueCrypt
and compare your binaries with the official binaries. If your binaries are
unsigned, the sizes of the official binaries will usually be approximately
10 KB greater than sizes of your binaries (there may be further differences
if you use a different version of the compiler, or if you install a different
or no service pack for Visual Studio, or different hotfixes for it, or if you
use different versions of the required SDKs).

Instructions for Building TrueCrypt for Windows:
------------------------------------------------

1) Create an environment variable 'MSVC16_ROOT' pointing to the installation
   directory of MS Visual C++ 1.52.

2) If you have installed the Windows Driver Development Kit in another
   directory than '%SYSTEMDRIVE%\WinDDK', create an environment variable
   'WINDDK_ROOT' pointing to the DDK installation directory.

3) Copy the PKCS #11 header files to a standard include path or create an
   environment variable 'PKCS11_INC' pointing to the directory where
   the PKCS #11 header files are installed.

4) Open the 'TrueCrypt.sln' solution in Microsoft Visual Studio 2008.

5) Select 'All' as the active solution configuration.

6) Build the solution.

7) If successful, there should be newly built TrueCrypt binaries in the
   'Release' folder.

按照流程,环境配置如下:

  1. Visual Studio 2008,我的版本是官方的90天评估版。
  2. nasm,我用的版本是 nasm-2.09.08,我的微盘下载地址在这里。将 nasm.exe 文件解压出来, 放到 system32 目录里
  3. gzip,我用的版本是 1.2.4,我的微盘下载地址在这里。将 gzip.exe 文件解压出来, 放到 system32 目录里
  4. VC1.5,我的微盘下载地址在这里。创建一个环境变量 MSVC16_ROOT 指向其解压的目录
  5. Windows Driver Kit Version 7.1.0,官方下载地址 GRMWDK_EN_7600_1.ISO (619.0 MB) ,安装时注意不要选择安装Device Simulation Framework(DSF)。创建环境变量 WINDDK_ROOT 指向WDK目录,如我的WDK目录是C:\WinDDK\7600.16385.1
  6. 下载PKCS#11的头文件,为了省事,可将这里的目录全部下载到本地一个目录,然后创建环境变量 PKCS11_INC 指向该目录

代码编译也需要微调:

代码放置目录不要有中文或空格。

使用 VS2008 打开 TrueCrypt.sln,配置选择ALL,开始生成解决方案吧。

不出意外的话,会报一个错如下:

6>.\Setup.c(135) : error C2065: “PKEY_AppUserModel_ID”: 未声明的标识符

解决方案是在Setup.h中加入如下代码

#include "wtypes.h"

  const PROPERTYKEY PKEY_AppUserModel_ID = {
    {
      (unsigned long)2009,/*unsigned long Data1;*/
        (unsigned short)12,/*unsigned short Data2;*/
        (unsigned short)23,/*unsigned short Data3;*/
        0x44,0x55,0x55,0x55,0x55,0x55,0x55,0x55
    },/* GUID */
    (DWORD)PID_FIRST_USABLE /* pid */
  };

再次生成,就OK了,东西都在 \Release\Setup Files\下。

参考:

  1. TrueCrypt 源码 相关资料
    http://www.cnblogs.com/jecray/archive/2011/01/25/1944968.html
  2. 如何编译TrueCrypt源码
    http://www.cnblogs.com/jecray/archive/2011/01/25/1944971.html
  3. Instructions for Building TrueCrypt 6.3a in Windows XP
    http://www.cnblogs.com/jeffreyli/archive/2010/05/18/1738014.html
  4. 工作笔记:TrueCrypt编译记录
    http://blog.csdn.net/skyremember/article/details/4562090
Technorati 标签: TrueCrypt
 
 

[2014_11_17 更新] TrueCrypt 7.2代码在Win8.1 64位下编译流程
 
 

除了上述配置之外,可能编译时会遇到 nasm 无法识别的问题,解决方案是将其拷入 "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin" 目录下,这样就一切OK了。


 

[2014_12_04 更新] 参考文献
 
 
posted @ 2011-08-08 22:52  ET民工[源自火星]  阅读(2561)  评论(5编辑  收藏  举报