nerd space
Contents:
  1. Compiling 7-Zip in Windows For Vuln Research
    1. Steps
    2. Additonal, Debugging Command for WinDbg
      1. Resources & References
8 December 2025

Compiling 7-Zip in Windows For Vuln Research

This is the second time I am working on 7-Zip and each time I want to debug it, I have a hard time compiling it. Hence documenting this here since the online docs are abit vague and not straight forward.

Steps

  1. Retrieve the source of the version interested.
  2. Make sure you have installed Windows SDK tools.
  3. Make the following edits or changes in the CPP\Build.mak file
[Truncated]

- CFLAGS = $(CFLAGS) -nologo -c -Fo$O/ $(CFLAGS_WARN_LEVEL) -WX -EHsc -Gy -GR- -GF
+ CFLAGS = $(CFLAGS) -nologo -c -Fo$O/ $(CFLAGS_WARN_LEVEL) -WX -EHsc -Gy -GR- -GF -Zi

[Truncated]

!IF "$(PLATFORM)" == "x64"
- CFLAGS_O1 = $(CFLAGS) -O1
+ CFLAGS_O1 = $(CFLAGS) -Od
!ELSE
- CFLAGS_O1 = $(CFLAGS) -O1
+ CFLAGS_O1 = $(CFLAGS) -Od
!ENDIF
- CFLAGS_O2 = $(CFLAGS) -O2
+ CFLAGS_O2 = $(CFLAGS) -Od

- LFLAGS = $(LFLAGS) -nologo -OPT:REF -OPT:ICF -INCREMENTAL:NO
+ LFLAGS = $(LFLAGS) -nologo -OPT:REF -OPT:ICF -INCREMENTAL:NO -DEBUG

[Truncated]
  1. Start Tools Command Prompt for VS 20xx and verify the compiler is x64 version.
> where cl
C:\...\bin\Hostx64\x64\cl.exe
  1. Next Build the code with the following command after navigating to the CPP\7zip folder.
# command to build
> nmake NEW_COMPILER=1 MY_STATIC_LINK=1

# Command to clean the build
> cd Bundles\Format7z && nmake clean && cd ..\Alone && nmake clean && cd ..\..\UI\FileManager && nmake clean && cd ..\GUI && nmake clean && cd ..\..\

Done!!

Additonal, Debugging Command for WinDbg

Debugging command with the new WinDbg from Microsoft store.

> "C:\Users\<USER>\AppData\Local\Microsoft\WindowsApps\WinDbgX.exe" -c "!gflag -htc -hfc -hpc" "D:\
Shared\Targets\7-Zip\7z2409-vulnerable-src\CPP\7zip\UI\Console\x64\7z.exe" x demo2.zip

Now, you are ready to debug 7-Zip with source code available.

Resources & References