Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Wrong code in release] PatchHelper / GetInstructions #57

Open
themaoci opened this issue Feb 21, 2021 · 1 comment
Open

[Wrong code in release] PatchHelper / GetInstructions #57

themaoci opened this issue Feb 21, 2021 · 1 comment

Comments

@themaoci
Copy link

Hello i found a bug in PatchHelper.GetInstructions

its suposed to return Instruction[] and anyway no matter how hard i tried it was always returnign me an exception that i cannot cast IList to Instruction[]

so my quick workaround was to edit it from this code below

public Instruction[] GetInstructions(Target target)
{
	TypeDef type = this.FindType(target.Namespace + "." + target.Class, target.NestedClasses);
	MethodDef methodDef = this.FindMethod(type, target.Method, target.Parameters, target.ReturnType);
	return (Instruction[])methodDef.Body.Instructions;
}

into this one

public Instruction[] GetInstructions(Target target)
{
	TypeDef type = this.FindType(target.Namespace + "." + target.Class, target.NestedClasses);
	IEnumerator<Instruction> enumerator = this.FindMethod(type, target.Method, target.Parameters, target.ReturnType).Body.Instructions.GetEnumerator();
	List<Instruction> list = new List<Instruction>();
	while (enumerator.MoveNext())
	{
		Instruction item = enumerator.Current;
		list.Add(item);
	}
	return list.ToArray();
}

if someone of you have some time please apply it to new release THANKS :) it will deffenetly help others
Hope you guys are doing well!!!

@themaoci
Copy link
Author

PS. i was checking dnpatch.zip and dnlib.zip release files as i remember

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant