LogoLogo
  • Welcome to Cyphor
  • .NET Code Obfuscation
    • Getting Started
    • How to Obfuscate
    • Basic Code Obfuscation
      • Symbol Renaming
      • Body Mutation
      • Control Flow
      • Constant Encryption
      • Call Hiding
      • Debug Protection
      • Integrity Checks
      • Self Healing
    • Advanced Obfuscation
      • Attribute-Based Obfuscation
      • Guide to obfuscation
      • Code Inlining
      • What is RASP?
      • Protections that protect each other
      • Program not working after obfuscation
      • Keeping performance with obfuscation
      • Virtualization
  • Dashboard
    • Files
    • Billing
      • Pay as you go
      • Examples
    • Projects
      • Code Guard Tasks
      • Permissions
        • Roles
      • Files
      • SAML and SSO
  • Code Guard
    • Introduction
    • Implement with your licensing system
      • Setting up a gateway
      • Setting up the SDK
    • Secured values
      • Dynamic values
      • Code Encryption
        • Page 1
    • Preventing analysis
    • Enhanced visibility
      • Disabling tracing on production
      • Logging external methods
      • Optimizing Memory Usage
    • Edge connectivity
    • Preventing modifications
      • Preventing assembly load
      • Allowing partial tampering
      • Enterprise EDRs and XDRs
      • Dynamic Hook protection
      • Thread hijacking
      • Guard Checksums
      • DLL Injection
      • Handling complex RE attacks
        • Custom payload detection
    • Granular Integrity Checks
    • Virtualized Environments
    • Troubleshooting
    • Threat database
    • Real time alerts
      • Alert Insights
  • CLI Tool
    • Introduction
    • Global options
    • Profiles
    • Projects
    • Obfuscator
      • Obfuscation Schemes
      • Task templates
      • Protecting files
        • Global obfuscation flags
        • Using templates to obfuscate files
        • Quick obfuscation
      • Monitoring obfuscation jobs
    • Securing local storage
Powered by GitBook
On this page
  • When to use Inlining on obfuscation?
  • Is it fine to inline everything?

Was this helpful?

  1. .NET Code Obfuscation
  2. Advanced Obfuscation

Code Inlining

PreviousGuide to obfuscationNextWhat is RASP?

Last updated 3 years ago

Was this helpful?

Code Inlining, also known as inline expansion or simply inlining is a compiler technique that is commonly used to optimize the code that you write. This is done by replacing the call to the target method with the code that we were calling.

Before Inlining:

public static void MyMethod(string parameter) {
  var number = Sum(3, 2);
}

public static int Sum(int a, int b) {
  return a + b;
}

After Inlining:

public static void MyMethod(string parameter) {
  var number = 3 + 2;
}

When to use Inlining on obfuscation?

To take the most advantage of code inlining, you need to think of the reason behind why functions exist. They were made to make it easier for us to maintain and understand code, it is a common practice for us developers to divide 1 function into multiple methods to improve readability and maintainability.

By inlining a function, you completely erase its existence and thus makes it stealthy against potential attacks that a hacker could perform on that function.

Simultaneously, the callee method becomes larger, making the code harder to analyze.

Inlining comes with the downside that if used too much, it stops being a performance benefit. Instead, it will slow down your code.

The reason for this decrease in performance is due to the compiler chasing a faster compilation time, by inlining too many functions we make the code harder to analyze for the compiler, and thus disables parts of the optimizations that would be performed in our original application.

Be advised that those are worst-case scenarios, in general terms, you won't have to worry about inlining.

Is it fine to inline everything?

Inlining your code has two potential issues. First, your application will become slightly bigger, depending on how many times the inlined function is referenced, this difference becomes more or less noticeable. Second, when you inline too many methods into one, the runtime compiler (JIT) will have a worse code generation. Refer to if you want to learn more about this subject.

🤔
⚠️
this page