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

[Req?] Importer with Strings #34

Closed
XenocodeRCE opened this issue Jun 7, 2015 · 6 comments
Closed

[Req?] Importer with Strings #34

XenocodeRCE opened this issue Jun 7, 2015 · 6 comments

Comments

@XenocodeRCE
Copy link

It would be nice to be able to use plain-text strings with Importer :

Importer importer = new Importer(module);
var test = importer.Import("instance void [mscorlib]System.DateTime::.ctor(int64)");

@0xd4d
Copy link
Collaborator

0xd4d commented Jun 7, 2015

Couldn't you just create a few extension methods? One that gets the type, then another that gets the method from the type (if it's not null).

importer.Import("The.Full.Type.Name").ImportMethod("TheMethod")

Import() above can use the normal type parser code. ImportMethod will resolve the type then find the method and finally import it by calling the importer's method and return the imported method reference.

@XenocodeRCE
Copy link
Author

Nop because GetMethod("ctor") will always return null

@0xd4d
Copy link
Collaborator

0xd4d commented Jun 8, 2015

Try GetMethod(".ctor") or: FindConstructors(), FindDefaultConstructor(), FindInstanceConstructors() etc.

@XenocodeRCE
Copy link
Author

I tried them all and it fails everythime

This is what I want to do :

this is my code :

Importer importerz = new Importer(module);
var ctor1 = importerz.Import(typeof(DateTime).GetMethod(".ctor"));

I but a breakpoint on var ctor1, I pass it and it remains null everytime

@0xd4d
Copy link
Collaborator

0xd4d commented Jun 9, 2015

@XenocodeRCE
Copy link
Author

Solved :

Importer importerz = new Importer(module);
Type myType = typeof(DateTime);
Type[] types = new Type[1];
types[0] = typeof(Int64);
var ctor1 = importerz.Import(myType.GetConstructor(types));

Thanks a lot @0xd4d

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