API for getting IL from byte array - cil

There is a GetILAsByteArray method in MethodBody class which gives body of a method. I am looking for converting this byte array into more understandable IL instructions (into a List or something like that). What resources, open source code or api available are there to help me understand and convert this byte array (or do it for me)?
I found this but it does not work with generics. I am pretty much looking for guidance to convert understand these bytes in all framework versions.
CLI Documentation is also helpful for learning IL instructions but I cannot see how to use it to make these bytes make sense.

I just wrote an extension method to get a more understandable list of instructions using GetILAsByteArray. It's quite simple, the API is like:
public static IList<Instruction> GetInstructions (this MethodBase self);
You can read more about the implementation in my blog post. Or you can go take the implementation and start using it.

Have a look at the Mono.Cecil library.

It is a huge undertaking. I wrote the starts of an IL reader and it had a pretty good amount of opcodes implemented: but you will need to finish it.
http://svn.ensemble-os.org/tags/OldOCJ/CIL/
There is also MONO Cecil, which is feature-complete.

Related

Geo.Lua function GEOMETRYFILTER and Redis

I'm trying to figure out how to actually do a call to GEOMETRYFILTER function in geo.lua since documentation is not very clear to me:
https://github.com/RedisLabs/geo.lua#GEOMETRYFILTER
What exactly do these parameters means and how do I call this function from Redis-cli? I was not able to find any example on google.
geo.lua's author here - IIRC it involves first creating a polyhash to describe the filter and then providing it along with the geoset to the library. Performance is quite horrible as everything is done in Lua.
FYI - that library is no longer maintained.

J8583 project for parsing/creating iso8583 financial messages

I'am currently looking for an api for parsing/creating iso8583. iso8583 is a barbarian iso norm of raw string message.
I have found the j8583 project, http://j8583.sourceforge.net/index.html, but i can't found easy code example to parse a message.
Do you know good examples using this api ? or using another api ?
Thank you for your time
Perhaps my answer is biased because I'm the author, but jPOS can be an alternative. Take a look at http://jpos.org and its documentation (http://jpos.org/doc/proguide-draft.pdf).
Hope it helps.
Perhaps I need to reorganize/improve the docs?
The concept is fairly simple: Create a MessageFactory, configure it (the simplest way is via XML config file) and use that to parse messages with the parseMessage method, which receives a byte array.
The library includes a simple message parser which you can look at to get an idea. The test suite can also be helpful.
Here is the source code for the project that you can clone
https://bitbucket.org/chochos/j8583/src/master/
here is the XML Configuration Guide
http://j8583.sourceforge.net/xmlconf.html
All from the same person and framework

Reading Byte Data through the serial port in C++/CLI

I am trying to make an interface with another program so I have to use C++.
It's been years since I have programmed in C++ and I have been at this problem for about a week so I'm slowly starting to see how everything works.
I want to read byte data coming from a serial port device.
I have verified that I can get text through the serial port using the readline command:
For example:
String^ message = _serialPort->Readline();
Is how the data is read in an example from MSDN that I got to work successfully.
However I have tried to modify it several times and I'm having no luck coming up with something that reads the data as bytes. (I already have conversion of byte data to string so I can actually see the bytes such as the number 15 equaling 0f in bytes.)
Modifying the code to
wchar_t message = _serialPort->Readline();
gives me
error c2440: 'initializing' : cannot convert from System::String ^' to 'wchar_t'.
I'm not familiar with Readline. Is it only for strings? I have verified that it does work with strings and if I use a serial device that sends a string the first set of code does work.
Can someone explain what method I could use to read byte data? Thanks.
If you actually want to use C++ rather than C++/CLI, I recommend using boost.asio. It is well established, relatively easy to understand, and has a specific set of functionality just for working with serial ports.
Update
Pure C++ Win32 API versions:
See the following good references
CodeProject article
MSDN
Is there any specific reason you are doing this in C++/CLI code?
I thought you might not even be aware of that (otherwise, tag your questions, please).
String^, Readline etc are CLR functions (i.e. .NET, think: "you could do this more easily in C#). So, again,
If there is a need for this to be in C++, why don't you look at the native Win32 API
Otherwise, why are you bothering with C++
If you really wanted C++/CLI I suggest not mixing native/managed code when handling the serial IO. You can get an UnmanagedMemoryStream to marshal the data in/out of managed land.
$0.02

how to get knowing more about a class behaviour without looking at its manual?(a fundamental question about how to dive more into OOP)

I'm practicing OOP for 2 years (for real) and I know how to consume objects and packages and I'm developing stuffs mostly using C# .
but I have a problem with consuming unknown objects and packages as an instance :
for now I am working on an enterprise like website and for part of our job we need to consume RSS. I decided to use "System.Xml.Xpath"
and my real problem is:
for using system.xml.xpath I should look at manual and read it carefully and I don't want to do that every time.A plain example of that is like following code :
XPathDocument xp = new XPathDocument(sites[2]);
XPathNavigator nav = xp.CreateNavigator();
XPathNodeIterator it = nav.Select(xpath3);
foreach (XPathNavigator n in it)
{
//get elements here
}
//another way of iterating elements is
while(it.movenext())
{
//it.current.Value;
}
for the "foreeach" part I got it from MSDN manual and I guess I could get this simple fact by looking at class structure.
but I don't know which structure I should look.
I know how to read tooltips and I'm familiar with things like : [] / collection / enum /generic / Ienumerable / Idisposable etc...
but I think there is something about reading class behaviors and I'm missing that part.
for make it more lucid :
I know whenever we have a class that inherited from IEnumerable so we can use foreach statement against that class to iterate it through
my real problem is I think classes are self described enough to not to look at manuals all the time but I don't know how/where to read those descriptions of classes so I need your advice to get more familiar with how to reading classes without looking at manuals.
best regards.
Classes can (and should) be documented with source code comments, and in many languages you can generate API documentation from these comments (in HTML, XML or other format). In Java it is called Javadoc; I don't know the C# term. If this is what you call "manual", then this is your primary source of information. Other than reading the source code comments and the code itself (which you often don't have access to, especially in the MS universe). If you don't find enough information in the API documentation, you can always try googling for more explanation, tutorials or usage examples.
Hope this helps; I am not entirely sure I understood your question though. If this is not the answer you are looking for, please clarify.

Weird function names in Quartz Core: what gives?

Out of curiosity, what may the rationale behind these function names (found in Apple's Quartz Core framework) be?
ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv()
ZNK2CA6Render9Animation9next_timeEdRd()
ZN2CA11GenericRectIiE5insetEii()
Do you think the developers somehow encoded argument types in function names? How do you find yourself putting "EP19" in there in the course of day-to-day coding? In what circumstances do such barely readable function names actually help you read code and otherwise be more productive?
Thanks in advance for any hints, and Merry Christmas!
These 'mangled' names are automatically generated by the C++ compiler and indeed encode type information.