Jump to content
Sign in to follow this  
reoto

Help. How to change the code of dll without dnspy

Recommended Posts

Normally, I fix it with dnspy but it is a waste of time.
It would be better if I patch it for use.

But I don't know how to change it.

namespace JetBrains.Application.License2.Evaluation
{
    public class EvaluationLicenseViewSubmodel : ILicenseViewSubmodel, ILicenseCheckResult
    {
        internal void CheckLicensesAndFire()
        {
            int leftDays = evaluationInfo.GetLeftDays(second);
          
          //I want to remove this
            if (second.FreeTrialPeriod < leftDays || leftDays < 0)
            {
                this.<>4__this.myCheckResult.ReplaceResult(new LicenseCheckInfo(first, Result.FAILED, string.Format("Free trial period of {0} is over.", first.GetShortPresentableName())), this.<>4__this);
            }
          //till here
            else
            {
                string description;
                if (leftDays != 0)
                {
                    if (leftDays != 1)
                    {
                        description = string.Format("Free trial period is running. {0} days left", leftDays);
                        // **I want to change string here**
                        // description = string.Format("Hello, it's me");
                    }
                    else
                    {
                        description = string.Format("Free trial period is running. 1 day left", Array.Empty<object>());
                    }
                }
                else
                {
                    description = string.Format("Free trial period will expire tomorrow", Array.Empty<object>());
                }
            }
        }
    }
}
namespace JetBrains.Application.License2.Evaluation
{
    public static class EvaluationInfoEx
    {

        public static int GetLeftDays([NotNull] this IEvaluationInfo info, [NotNull] ISupportsEvaluation supportsEvaluation)
        {
            int freeTrialPeriod = supportsEvaluation.FreeTrialPeriod;
            // I want to change "supportsEvaluation.FreeTrialPeriod" To 999
            //  int freeTrialPeriod = 999;
            
            int actuallyUsedDays = info.ActuallyUsedDays;
            int num = (DateTime.Today == info.LastUsageDate) ? 1 : 0;
            return freeTrialPeriod - actuallyUsedDays + num;
        }
    }
}
namespace JetBrains.Application.License2.Evaluation
{
    internal class EvaluationInfo : IEvaluationInfo, ILicenseDataItem
    {
        public bool SetUsed(bool addCalendarDays = false)
        {
            DateTime today = DateTime.Today;
            if (this.LastUsageDate > today)
            {
                this.LastUsageDate = today - TimeSpan.FromDays(1.0);
            }
            if (this.LastUsageDate < today)
            {
                int num = 1;
                if (addCalendarDays)
                {
                    num = Math.Max(1, (int)(today - this.LastUsageDate).TotalDays);
                }
                this.LastUsageDate = today;
                this.ActuallyUsedDays += num;
                // I want to change "num" to 0;
                // this.ActuallyUsedDays = 0;
                
                return true;
            }
            return false;
        }
    }
}

 

Edited by reoto

Share this post


Link to post

you can use dnspy if you don't have a good experience with MSIL opcodes

Share this post


Link to post
9 minutes ago, Kurapica said:

you can use dnspy if you don't have a good experience with MSIL opcodes

thank you for answers. but I'm looking for the way to patch with c#
Not long ago. I found dnlib, mono.Cecil and dnpatch. Now I'm studying these libraries.

 

Share this post


Link to post

finally i got it

for a simple

var mod = ModuleDefMD.Load(path);
foreach (var type in mod.GetTypes())
{

   if (type.FullName == "JetBrains.Application.License2.Evaluation.EvaluationInfo")
   {
     foreach (var md in type.Methods)
     {
       var instructions = md.Body.Instructions;
           for (var i = 0; i < instructions.Count - 1; i++)
           {
            if (instructions[i].IsLdarg() &&
                instructions[i].OpCode == xxx)
            {
               instructions[i].OpCode = OpCodes.Nop;
            }
           }
      }
   }
}

 

Edited by reoto
  • Like 1

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...