Home Understanding the Importance of File Paths in Portable Executables (PE)
Post
Cancel

Understanding the Importance of File Paths in Portable Executables (PE)

The Idea

PE (Portable Executable) stores file paths as part of its metadata to ensure that the file can be loaded and executed properly. The file path information is used by the operating system to locate the file on the file system, and it also helps in resolving any dependencies that the file might have on other files or resources. Additionally, it allows the executable file to be portable, as it can be moved to different locations on the file system without breaking the links to its dependencies.

Reproduce

  1. Install the file, I’ll use AsmResolver 5.0.0, download AsmResolver_v5.0.0_Binaries.zip
  2. Extract ZIP, and then open-up extracted_asmresolver_zip_path\netstandard2.0
  3. Open-up the AsmResolver.dll in dnSpy or Hex Editor (Highly recommend you HxD)
  4. If you’re using the dnSpy, press on file, and then press hotkey CLTR + X, or right click on mouse Open Hex Editor.
  5. Search in Hex something seems to the File Path.

dnSpy Hex file path dnSpy Hex file path

1
C:\projects\asmresolver\src\AsmResolver\obj\Release\netstandard2.0\AsmResolver.pdb

How to Protect Yourself from that?

You can do the same through the IDE options, in this case simply I’ll change the .csproj. Open your .csproj of your IDE project, and edit it.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<Project Sdk="Microsoft.NET.Sdk">
  <!-- Not important to add, just as example -->
  <PropertyGroup>
    <TargetFrameworks>netstandard2.0;net462</TargetFrameworks>
    <LangVersion>10.0</LangVersion>
  </PropertyGroup>

  <!-- Add this for Release, to remove the debug symbols -->
  <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
    <DebugSymbols>false</DebugSymbols>
    <DebugType>none</DebugType>
  </PropertyGroup>

  <!-- Add this for Debug, to remove the debug symbols -->
  <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
    <DebugSymbols>false</DebugSymbols>
    <DebugType>none</DebugType>
  </PropertyGroup>
</Project>

Done, check the magic now! =)

This post is licensed under CC BY 4.0 by the author.

Billions of Nops - Well for Anti Decompiler?

C# Code Optimization Tricks