TomSmartBishop / facile-api

The Facile API is capable of reading (decompiling) .Net assemblies. Covering the metadata tables, the embedded types and methods, including their bodies as CIL (bytecode).
http://tomsmartbishop.github.io/facile-api/
10 stars 3 forks source link

Fixed #6 #7

Closed yhs0602 closed 4 years ago

yhs0602 commented 5 years ago

I made a workaround for the issue #6. MethodBody.toString() now creates a temporary LanguageRenderer with null FacileReflector.

yhs0602 commented 5 years ago

@TomSmartBishop

TomSmartBishop commented 4 years ago

Thanks for your work @KYHSGeekCode !!! It would be great however, if we don't need to pull the ILAsmRenderer into the toString method. The toString method should be independent of that.

I think we could just use this line to the toString method: String.format("\nIL_%04x: %s", programCounter, i.toString());

(maybe also check if there is any CilInstuction that does something different than toString in it's render method)

yhs0602 commented 4 years ago

It would be great however, if we don't need to pull the ILAsmRenderer into the toString method. The toString method should be independent of that.

Perfectly agree with that.

TomSmartBishop commented 4 years ago

Just curious: Are you using the toString method instead of the ILAsmRender to get a string representation of the method body?

yhs0602 commented 4 years ago

Just curious: Are you using the toString method instead of the ILAsmRender to get a string representation of the method body?

I think I used to. (1)

(2)

TomSmartBishop commented 4 years ago

Could you keep an IlAsmRenderer instance and just do a String str = instance.render(methodBody, null); instead?

yhs0602 commented 4 years ago

Could you keep an IlAsmRenderer instance and just do a String str = instance.render(methodBody, null); instead?

Oh I didn't know that that method existed. However, isn't that method private?

TomSmartBishop commented 4 years ago

It uses CilInstruction.toString now

Ok, great I saw ther migt be some minor differences - eg. when resolving token names, so maybe the best thing is to make the render method in ILAamRenderer for the methodBOdy public so that you can use it in your app

TomSmartBishop commented 4 years ago

OK, PR looks good, now, but let's revert the white-space change. Again I'm happy to apply some white-space rules if we can agree on some standard (but in a separate commit)

yhs0602 commented 4 years ago

Okay, I'll do when I'm back home.

yhs0602 commented 4 years ago

Just curious, did you(r team) write such a large and long switch-cases manually to develop a decompiler? Or are there any strategies for writing disassemblers like this project?

TomSmartBishop commented 4 years ago

Good question indeed…I just applied theory from building compilers.