17

I'm trying to compile TrueCrypt. I am using the instructions from https://github.com/syglug/truecrypt.

I set the 3 environment variables (pkcs,ddk,MSVC16_ROOT) and opened the project in msvc2008. This wasn't in the instructions but I needed NASM to be installed so I installed it and put NASM in the PATH. Now when I build I get the below. It juts ends even though the IDE has the cancel build selectable the compiler isn't doing anything and the system idles.

Crypto.lib does exist after this step

1>------ Build started: Project: Crypto, Configuration: Release Win32 ------
2>------ Build started: Project: Boot, Configuration: Release Win32 ------
3>------ Build started: Project: Driver, Configuration: Release Win32 ------
2>Performing Makefile project actions
3>Performing Makefile project actions
1>Performing Custom Build Step
3>------ Building truecrypt.sys: Release x86 ------
1>Aes_hw_cpu.asm 
2>Microsoft (R) C/C++ Optimizing Compiler Version 8.00c    
2>Copyright (c) Microsoft Corp 1984-1993. All rights reserved.
3>The syntax of the command is incorrect.
3>Project : error PRJ0002 : Error result 255 returned from 'C:\Windows\SysWow64\cmd.exe'.
3>Build log was saved at "file://c:\unzipped\tc\Driver\Release\BuildLog.htm"
3>Driver - 1 error(s), 0 warning(s)
1>Performing Custom Build Step
1>Aes_x86.asm 
1>Compiling...
1>Whirlpool.c
1>Twofish.c
1>Sha2.c
1>Sha1.c
1>Serpent.c
1>Rmd160.c
1>Des.c
1>Cast.c
1>Blowfish.c
1>Aestab.c
1>Aeskey.c
1>Generating Code...
1>Creating library...
1>Build log was saved at "file://c:\unzipped\tc\Crypto\Release\BuildLog.htm"
1>Crypto - 0 error(s), 0 warning(s)

It just hangs. It isn't using any CPU the IDE doesn't seem to know it failed or stopped. When running again I get this

1>------ Build started: Project: Boot, Configuration: Release Win32 ------
2>------ Build started: Project: Driver, Configuration: Release Win32 ------
1>Performing Makefile project actions
2>Performing Makefile project actions
2>------ Building truecrypt.sys: Release x86 ------
1>Microsoft (R) C/C++ Optimizing Compiler Version 8.00c    
1>Copyright (c) Microsoft Corp 1984-1993. All rights reserved.
2>The syntax of the command is incorrect.

I have msvc2012 installed so I tried it as well. I get the same problems

1>------ Build started: Project: Crypto, Configuration: Release Win32 ------
2>------ Build started: Project: Boot, Configuration: Release Win32 ------
3>------ Build started: Project: Driver, Configuration: Release Win32 ------
1>  Performing Custom Build Tools
1>  Aes_hw_cpu.asm 
3>  ------ Building truecrypt.sys: Release x86 ------
2>  Microsoft (R) C/C++ Optimizing Compiler Version 8.00c    
2>  Copyright (c) Microsoft Corp 1984-1993. All rights reserved.
2>  
3>  The syntax of the command is incorrect.
3>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.MakeFile.Targets(38,5): error MSB3073: The command "echo ------ Building truecrypt.sys: Release x86 ------
3>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.MakeFile.Targets(38,5): error MSB3073: cmd.exe /c BuildDriver.cmd -build -release -x86 "C:\unzipped\tc\\Common" "C:\unzipped\tc\\Crypto" "C:\unzipped\tc\Driver\"
3>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.MakeFile.Targets(38,5): error MSB3073: if errorlevel 1 exit %errorlevel%
3>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.MakeFile.Targets(38,5): error MSB3073: echo.
3>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.MakeFile.Targets(38,5): error MSB3073: echo ------ Building truecrypt.sys: Release x64 ------
3>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.MakeFile.Targets(38,5): error MSB3073: BuildDriver.cmd -build -release -x64 "C:\unzipped\tc\\Common" "C:\unzipped\tc\\Crypto" "C:\unzipped\tc\Driver\"" exited with code 255.
1>  Performing Custom Build Tools
1>  Aes_x86.asm 
1>  Aeskey.c
1>  Aestab.c
1>  Blowfish.c
1>  Cast.c
1>  Des.c
1>  Rmd160.c
1>  Serpent.c
1>  Sha1.c
1>  Sha2.c
1>  Twofish.c
1>  Whirlpool.c
1>  Generating Code...
1>  Crypto.vcxproj -> C:\unzipped\tc\Crypto\Release\Crypto.lib

When I cancel/build again I get the below

1>------ Build started: Project: Boot, Configuration: Release Win32 ------
2>------ Build started: Project: Driver, Configuration: Release Win32 ------
2>  ------ Building truecrypt.sys: Release x86 ------
2>  The syntax of the command is incorrect.
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.MakeFile.Targets(38,5): error MSB3073: The command "echo ------ Building truecrypt.sys: Release x86 ------
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.MakeFile.Targets(38,5): error MSB3073: cmd.exe /c BuildDriver.cmd -build -release -x86 "C:\unzipped\tc\\Common" "C:\unzipped\tc\\Crypto" "C:\unzipped\tc\Driver\"
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.MakeFile.Targets(38,5): error MSB3073: if errorlevel 1 exit %errorlevel%
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.MakeFile.Targets(38,5): error MSB3073: echo.
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.MakeFile.Targets(38,5): error MSB3073: echo ------ Building truecrypt.sys: Release x64 ------
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.MakeFile.Targets(38,5): error MSB3073: BuildDriver.cmd -build -release -x64 "C:\unzipped\tc\\Common" "C:\unzipped\tc\\Crypto" "C:\unzipped\tc\Driver\"" exited with code 255.
1>  Microsoft (R) C/C++ Optimizing Compiler Version 8.00c    
1>  Copyright (c) Microsoft Corp 1984-1993. All rights reserved.
1>  

What's wrong here? How do I build TrueCrypt? I'm running Windows 7 64bits

user2428118
  • 7,935
  • 4
  • 45
  • 72
  • May I politely ask why the hell you're doing this? – Joel E Salas Nov 14 '12 at 01:56
  • 7
    @JoelESalas: Thats almost like asking why linux people like building from source rather then using `apt-get install` –  Nov 14 '12 at 02:15
  • linux people build/built the source because they "had to", not because they wanted to... – Logman Nov 14 '12 at 02:21
  • 3
    @Logman: Actually they do it either to get the bleeding edge or 'just because'. IIRC gentoo people build their own kernel (or distro, or something, google mentions genkernel). My answer is because I like to build it then look/play around. At the moment i'm just looking at their coding style and the design –  Nov 14 '12 at 02:25
  • can you put the link directly to your instructions? Because I found instructions for windows that sound different from what you posted – Logman Nov 14 '12 at 02:30
  • 16
    @JoelESalas and acidzombie24: You actually build Truecrypt from source to be sure that no backdoor has been installed by the entity who's built the binary. – Anton Kaiser Jul 20 '13 at 20:22

3 Answers3

32

I could successfully build all projects from https://github.com/syglug/truecrypt. I followed mostly the instructions from readme.txt. Because the instruction are not detailed enough I describe below all steps which I did. If you will have some additional questions to some steps I'll include additional details.

I used Visual Studio 2008 installed on Windows 7 X64. If needed I could reproduce the same with Visual Studio 2010 or 2012.

  1. I downloaded from MSDN (I have subscription) Visual C++ 1.52: en_vc152.exe. It's self extracted EXE file. To hold Paths mostly short and have no spaces in the directory names I extracted MSVC15 directly in C:\. So I had for example old binaries of 16-bit VC compiler in C:\MSVC15\BIN.
  2. I placed all files downloaded from ftp://ftp.rsasecurity.com/pub/pkcs/pkcs-11/v2-20 in C:\PKCS-11 directory. The file C:\PKCS-11\pkcs11.h like all dependent files will be in the same directory C:\PKCS-11
  3. I downloaded the current version 2.10.05 of NASM from http://www.nasm.us/pub/nasm/releasebuilds/2.10.05/. I extracted nasm-2.10.05-win32.zip in C:\nasm-2.10.05 directory. So that nasm.exe could be found in C:\nasm-2.10.05.
  4. I downloaded Binaries of Gzip for Windows. I extracted gzip-1.3.12-1-bin.zip to C:\gzip-1.3.12-1-bin. So that C:\gzip-1.3.12-1-bin\bin contains gzip.exe.
  5. I had already installed Windows DDK in directory C:\WinDDK\7600.16385.1 before.
  6. I downloaded truecrypt-master.zip from https://github.com/syglug/truecrypt. I extracted it in C:\truecrypt-master directory. So that Crypto.vcproj can be found in C:\truecrypt-master\Crypto directory.

Because I don't like to modify the global environment variables I created the following batch file:

SET MSVC16_ROOT=C:\MSVC15
SET PKCS11_INC=C:\PKCS-11
PATH=C:\nasm-2.10.05;C:\gzip-1.3.12-1-bin\bin;%PATH%
"C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe"

In the last line of the batch file Visual Studio 2008 will be started (devenv.exe). It inherits all environment variables set in CMD.EXE (the parent process which started Visual Studio 2008).

The solution file 'TrueCrypt.sln' described in the readme is not included in the sources found on github. So I opened every Project file which I found in subdirectories of C:\truecrypt-master and compiled it. It was Crypto.vcproj (from C:\truecrypt-master\Crypto), Boot.vcproj (from C:\truecrypt-master\Boot\Windows), Driver.vcproj (from C:\truecrypt-master\Driver), Format.vcproj (from C:\truecrypt-master\Format) and Mount.vcproj (from C:\truecrypt-master\Mount).

I could successfully compile all the projects. The only small problems were during building of Format.vcproj and Mount.sln. The files Format.tlb and Mount.tlb exists in subdirectories. So I fixed the lines where TLB files are referenced in C:\truecrypt-master\Format\Format.rc and C:\truecrypt-master\Mount\Mount.rc to

IDR_FORMAT_TLB          TYPELIB                 ".\\Format\\Format.tlb"

and

IDR_MOUNT_TLB           TYPELIB                 ".\\Mount\\Mount.tlb"

I'll post later the corresponded fixes to https://github.com/syglug/truecrypt in form of Pull Request.

UPDATED: One have to change in the file BuildDriver.cmd the line

set TC_BUILD_ARCH=x64 WNET

to

set TC_BUILD_ARCH=x64

to be able to build Driver.

Additionally one should build lines uses correct pathes like "$(SolutionDir)..\Crypto" and "$(SolutionDir)..\Common" (see nmake options in Visual Studio). If one use TrueCrypt.sln from C:\TrueCrypt7.1a it's not needed.

UPDATED 2: After you compiled the project you will see in C:\TrueCrypt7.1a\Release\Setup Files or in C:\truecrypt-master\Release\Setup Files the files

enter image description here

The file TrueCrypt Setup.exe exists only in C:\TrueCrypt7.1a (downloaded from the link www.truecrypt.org which you posted in the comment later). As I mentioned in the comment before you need configure Visual Studio 2008 to use Windows SDK 7 instead of default 6.0a to be able successfully to compile Setup project.

The drivers which will be compiled are not digitaly signed with Microsoft signature. So the drivers will be not trusted by Windows 7 by default. So to verify that the driver work you have to press F8 during boot of the computer and disable driver signature:

enter image description here

After that you will be able to execute TrueCrypt.exe (from C:\TrueCrypt7.1a\Release\Setup Files directory for example). You will get warning

enter image description here

but the TrueCrypt.exe will do work and you will see

enter image description here

user2428118
  • 7,935
  • 4
  • 45
  • 72
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • my copy of the source (which has the sln file) came from the official site http://www.truecrypt.org/downloads2 Were you able to run truecrypt.exe and `TrueCrypt Format.exe`? I gave compiling a try when I saw the other answer (i had to do things before i could start tho) and removing quotes + renaming folders to have no spaces solved the errors. But I get the error `6>.\Setup.c(135) : error C2065: 'PKEY_AppUserModel_ID' : undeclared identifier` which is in the setup project. I can see truecrypt in my release folder but when i open it i get these two error messages http://i.imgur.com/IUyGV.png –  Nov 16 '12 at 10:22
  • I tried it with your bat even tho i did setup the vars as globals. I got the error `2>ERROR: This window already has the DDK build environment set. Please open 2> a new window if you want to change or reset your build environment. ` and only 4 of the 6 built. So I started VS w/o the bat and was able to build 5 of the 6 like i was able to when wrote my first comment. So i guess my question is now that i solved the quotes/space problem how do i either open truecrypt so it will run (see pic for error messages) and if you want to answer how do i fix that last error PKEY_AppUserModel_ID? –  Nov 16 '12 at 10:35
  • But i dont really care for setup files so i wouldnt mind ignoring it. When i open truecrypt.exe I get a UAC and it says the publisher is unknown before showing those two errors. Does the publisher being unknown have anything to do with it? How do i compile it so it doesnt care? I'd like to be able to run it after i compile :x –  Nov 16 '12 at 10:43
  • @acidzombie24: I could not full follows you probably because I don't used TrueCrypt before. I don't verified that `Driver` project don't made it's job. It produced "Successful built" but don't produced SYS files (`truecrypt.sys`, `truecrypt-x64.sys`). After some investigations I could do this after I modified `BuildDriver.cmd` so that I replaced `set TC_BUILD_ARCH=x64 WNET` to `set TC_BUILD_ARCH=x64` (removed `WNET` because I am working not on Windows 2003). I still get the error about SYS files are not digitally signed so one probably choose the option during booting of Windows. – Oleg Nov 16 '12 at 12:51
  • @acidzombie24: One more remark: "call "C:\WinDDK\7600.16385.1\bin\setenv.bat" C:\WinDDK\7600.16385.1 fre WXP" must be removed because `BuildDriver.cmd` set it. – Oleg Nov 16 '12 at 12:53
  • Hmm in my Release/ directiory there are two .sys files one being x64. Do I need to install these? Do you have any idea how I might? This could be the driver error i got in my picture? Are you able to run truecrypt after you built it? I don't get any GUI just the two error messages in that picture –  Nov 16 '12 at 13:32
  • @acidzombie24: By the way the error about `PKEY_AppUserModel_ID` exist if you use **old** v6.0A SDK. If you configure Options/"Project and Solutions"/"VC++ Diertories" to use `C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Include` and `C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib` for Win32 build and `C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib\x64` as Lib for x64 build you will be able to build setup. – Oleg Nov 16 '12 at 13:38
  • @acidzombie24: I updated the answer with more details how you can verify that the built driver and TrueCrypt work. – Oleg Nov 16 '12 at 14:14
  • oh wow this is perfect. But I can't do all these steps yet. I will be able to in 10hours or so. So I -need- to have windows SDK 7. I looked at that path and i only see include/lib in v5.0. I probably don't have it installed. I'll get that installed tonight and try again. –  Nov 16 '12 at 14:33
  • @acidzombie24: You need Windows SDK 7 only if you want to build `"TrueCrypt Setup.exe"`. To start "TrueCrypt.exe" you need just boot Windows 7 with spasial option. Nevertheless I would recommend you to use Windows 7 SDK because the official [readme](https://github.com/syglug/truecrypt/blob/master/Readme.txt) mention this: "**Microsoft Windows SDK for Windows 7 (configured for Visual C++)**". – Oleg Nov 16 '12 at 14:37
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/19663/discussion-between-acidzombie24-and-oleg) –  Nov 17 '12 at 01:41
  • oops i didnt mean to go into chat. I'm having absolutely horrible luck. I installed the windows SDK http://www.microsoft.com/en-ca/download/details.aspx?id=8279 which clearly says version 7.1 yet i dont have the includes in the path you mentioned. I'm reinstall it with more options selected –  Nov 17 '12 at 01:46
  • wow I really did have the hardest time. So many things went wrong and none of it is documented. `C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Include` is not where the installer put my headers. It put it `C:\Program Files\Microsoft SDKs\Windows\v7.0A\Include` and yes I do have a 64 bit system/os. –  Nov 17 '12 at 02:58
  • You completely answered the question thanks. I dont know about you but my setup didnt work and i had to run it with /p as the message suggested. When i did it extracted another setup which i used to install truecrypt. It failed so i press F8 and installed with success and used it with success. Then i rebooted and can no longer use it because drivers are not signed. So i'm writing a question for a more permanent solution that isnt pressing F8 everytime. Thanks! +1/Accepted –  Nov 17 '12 at 03:01
  • @acidzombie24: You are welcome! The exact path where SDK will be installed depend on many things I installed SDK as a part of Visual Studio 2012. Separate installation install in another path. Look at [here](http://msdn.microsoft.com/en-us/library/windows/hardware/ff547565(v=vs.85).aspx): you can set `DebugFlags` and use `bcdedit -debug on` for example. In general it's important to read [this](http://msdn.microsoft.com/en-us/library/windows/hardware/ff548231(v=vs.85).aspx) inclusine the links at the bottom of the article. – Oleg Nov 17 '12 at 08:56
  • I end up using doing `bcdedit -set TESTSIGNING ON` and signing the two .sys files with "Driver Signature Enforcement Overrider 1.3b" (dseo13b.exe). It worked like a charm. Then I built the setupfiles and the setup files correctly had the test signatures or whatever it did to get it to work –  Nov 17 '12 at 10:22
  • @acidzombie24: It's good news! I didn't understood your last sentence. Do you have some additional question? If you need to use the drivers inside of your company and you want to use self-signed certificates or certificates from your local certificate server you should be able to do this. You need install the certificite used for signing of drivers in "Trusted Publishers Certificate" Store. I did'n tested this, but it should work (see [here](http://msdn.microsoft.com/en-us/library/windows/hardware/ff553504(v=vs.85).aspx) for example) – Oleg Nov 17 '12 at 10:43
  • ah ha, no, no questions. Thank you for getting all of this to work because there were -many- things that went wrong that nothing talked about (like quotations in my path AND there cant be space dammit). I have everything working 100% the way I want –  Nov 17 '12 at 11:43
2

Looks like you have modified the PATH environment variable and some folder path contains quotation ("") marks. Windows no longer needs quotes to avoid getting confused with spaces. Error PRJ0002 : Error result 255 returned from 'C:\Windows\SysWow64\cmd.exe'" goes away once you fix this.

Varun Bhatia
  • 4,326
  • 32
  • 46
  • I had to rename the default folder name (had space and it reported an error bc of it when i removed quotes). Now i get 5 success and only setup fails with the error `6>.\Setup.c(135) : error C2065: 'PKEY_AppUserModel_ID' : undeclared identifier` –  Nov 16 '12 at 10:13
1

For everyone who gets stuck in this PKEY_AppUserModel_ID problem: it works by defining the following in Setup.c before the first function():

EXTERN_C const PROPERTYKEY DECLSPEC_SELECTANY PKEY_AppUserModel_ID =
{ { 0x9F4C2855, 0x9F79, 0x4B39,
{ 0xA8, 0xD0, 0xE1, 0xD4, 0x2D, 0xE1, 0xD5, 0xF3, } }, 5 };

kind regards

Community
  • 1
  • 1