[.MSIL Reversing] Damn pointer instructions... - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

[.MSIL Reversing] Damn pointer instructions...

ZarathosZarathos Posts: 1Member
Hi all! Hope it's not a problem if I ask something about IL instructions in a forum about .NET languages, but I really need some help fixing a problem.

I'm trying to reverse those instructions...
[code]ldloc.s texturedRef
conv.i
ldloc.s num11
ldloc.1
mul
ldloc.s num12
add
conv.i
sizeof [Microsoft.DirectX.Direct3D]Microsoft.DirectX.Direct3D.CustomVertex/TransformedColoredTextured
mul
add
conv.u
stloc.s texturedPtr[/code]

My best try is:
[code]CustomVertex.TransformedColoredTextured* texturedPtr = (CustomVertex.TransformedColoredTextured*)((byte)(texturedRef + ((k * num2) + m)));[/code]
Buy I obviously get something like that:
[code]ldloc.s texturedRef
conv.i
ldloc.s num11
ldloc.1
mul
ldloc.s num12
add
conv.i
sizeof [Microsoft.DirectX.Direct3D]Microsoft.DirectX.Direct3D.CustomVertex/TransformedColoredTextured
mul
add
conv.u4 <--------------- Difference
conv.u
stloc.s texturedPtr[/code]

If I compile this line removing the (byte) boxing, like that:
[code]CustomVertex.TransformedColoredTextured* texturedPtr = (CustomVertex.TransformedColoredTextured*)(texturedRef + ((k * num2) + m));[/code]
I get those instructions (without final conv):
[code]ldloc.s texturedRef
conv.i
ldloc.s num11
ldloc.1
mul
ldloc.s num12
add
conv.i
sizeof [Microsoft.DirectX.Direct3D]Microsoft.DirectX.Direct3D.CustomVertex/TransformedColoredTextured
mul
add
stloc.s texturedPtr[/code]

Those differences are making texture rendering process very very slow... with .NET Reflector Reflexil I injected the correct instructions and all is working fine, then I need to find a way to get rid of this megind difference. Well... I can't get a stand alone "conv.u". Any ideas anyone?

Thanks in advance!
Sign In or Register to comment.