Why a function in IDA PRO has two entry points? - ida

I am using IDA pro to disassemble a large binary. I find out that in some functions, it has more than one basic block, which has no(zero) in-degree. Therefore, those basic block can be regard as one of the entry points of this function. May I know why there are more than one entry point for a particular function? And is there any way to fix the number of entry point to be one in IDA pro?

Related

Transpose Coordinates to UTM84-17N Projection

In Swift, is there a way to input Lat/Long coordinates from MapKit, and translate those coordinates to a specified Projection, such as UTM84-17N (e.g. AutoCAD format)?
Well, I never did figure out how to do this using iOS/Swift, but I did discover a lisp code in both AutoCAD Map (two or three lines of code) and even better, in BricsCAD using the Spatial Manager extension (One single line of code).
For both, they involve three parameters: the source coordinates (in my case are in lat/long) the source projection code and the destination projection code.
The projection codes lists are provided in 'help.'
Actually, the company who owns Spatial Manager actually wrote the routine to fit into lisp for me when I posed the question to them; amazing!
So, there might be a manageable method that can be written for any platform.., who knows.
If anyone is interested in those lines of code to work in CAD, I'll look them up and post them.
By the way, a plug for BricsCAD: AutoCAD MAP from Autodesk, is now like almost $10,000 Canadian; BricsCAD is far less than $1000 for their best Pro option. NO BRAINER. AND, I find after being a guru in AutoCAD scripting for years, that BricsCAD is way better! AutoCAD is now so full of bloatware trinkets and useless stuff (similar to Windows' verification window pop ups) that it takes about 30 seconds just to load on a fast rig. And they have made things so much more difficult for old school users. Not to mention, the folks at BricsCAD are so incredibly helpful you feel like family with them!
...only one tiny flaw so far in going with them tho. They don't have a proper lisp editor (that I can find anyway), that lets you test the code line by line real time - like AutoCAD does...

Can online quantum random number generators be used in Matlab?

I want to avoid repetitions as much as possible. I've run the same Matlab program that uses "random" numbers multiple times and gotten exactly the same results. I learned that I should put the command shuffle at the beginning, and then the program will replace the default seed with a new one, based on the time on the clock. But the sequence of outputs from the pseudo-random number generator will
still contain a pattern.
I recently learned about a quantum box random number generator (this or something like it), and in the process of looking it up online I found a couple web servers that deliver random numbers that are continuously generated by quantum mechanical means: ANU Photonics and ANU QRNG.
To buy a quantum box looks pretty hard to afford, so how might I integrate one of the online servers into Matlab?
On http://qrng.anu.edu.au, click the "download" link in the text, and it takes you to a FAQ page where it tells what to download to use the random number generator in different ways. The last on the list is Matlab, for which it gives a link to directly download some code to access the random numbers and a link to Matlab Central to download the JSON Parser which is necessary for it to work.
The code is very simple, and as a script only displays the values it fetches, but can easily be turned into a function. I unzipped the contents of parse_json.zip into C:/Program Files/MATLAB/[version]/toolbox/JSONparser, a new folder in the Toolboxes, navigated to the Toolboxes in the Current Folder in Matlab, right clicked JSONparser, and clicked Add to Path.
Read the comments on the Matlab Central page for JSON Parser to get an idea of the limits of how many random numbers you can pull down at a time.
The random numbers are 16-bit non-negative integers; to create a random integer with more bits, say, 32 bits, I'd recommend taking two of these integers, multiplying one by 2^16, and adding them. If you want a number between 0 and 1, divide the sum by 2^32.

How to vectorize signal and parameter?

I created a subsystem in Simulink with mask underneath. There are all sorts of control and calculation inside this subsystem. Now I have to duplicate this subsystem for one hundred thousand times because I need to connect one hundred thousands of this block in series.
What I have tried, I used the commands “add_block” and “add_line” where I can just type it in the Matlab command and the blocks and lines are added automatically.
What I wish to do now is,
I want to have 100 signals in a single subsystem, so instead of using one hundred thousand subsystem, I will only need one thousand of this subsystem, I understand that this can be done by vectorization.
I have a very limited knowledge on using vectorization feature in Matlab/Simulink. I appreciate if anyone of you could provide me a great reference on how to do this?
What I found here is something like this which I could not link it to my issue above: http://www.mathworks.co.uk/help/matlab/matlab_prog/vectorization.html
The other thing I found is by "using vectorization for most components. Most components are vectorized if they have a vectorized input signal or if one of their parameter is specified as a vector."
However, I could not find any further information/details, appreciate if anyone of you could give opinion on this? Thanks!

Using MATLAB's plotting features as an interactive part of a Fortran program

Although many of you will have a decent idea of what I'm aiming at, just from reading the title -- allow me a simple introduction still.
I have a Fortran program - it consists of a program, some internal subroutines, 7 modules with its own procedures, and ... uhmm, that's it.
Without going into much detail, for I don't think it's necessary at this point, what would be the easiest way to use MATLAB's plotting features (mainly plot(x,y) with some customizations) as an interactive part of my program ? For now I'm using some of my own custom plotting routines (based on HPGL and Calcomp's routines), but just as part of an exercise on my part, I'd like to see where this could go and how would it work (is it even possible what I'm suggesting?). Also, how much effort would it take on my part ?
I know this subject has been rather extensively described in many "tutorials" on the net, but for some reason I have trouble finding the really simple yet illustrative introductory ones. So if anyone can post an example or two, simple ones, I'd be really grateful. Or just take me by the hand and guide me through one working example.
platform: IVF 11.something :) on Win XP SP2, Matlab 2008b
The easiest way would be to have your Fortran program write to file, and have your Matlab program read those files for the information you want to plot. I do most of my number-crunching on Linux, so I'm not entirely sure how Windows handles one process writing a file and another reading it at the same time.
That's a bit of a kludge though, so you might want to think about using Matlab to call the Fortran program (or parts of it) and get data directly for plotting. In this case you'll want to investigate Creating Fortran MEX Files in the Matlab documentation. This is relatively straightforward to do and would serve your needs if you were happy to use Matlab to drive the process and Fortran to act as a compute service. I'd look in the examples distributed with Matlab for simple Fortran MEX files.
Finally, you could call Matlab from your Fortran program, search the documentation for Calling the Matlab Engine. It's a little more difficult for me to see how this might fit your needs, and it's not something I'm terribly familiar with.
If you post again with more detail I may be able to provide more specific tips, but you should probably start rolling your sleeves up and diving in to MEX files.
Continuing the discussion of DISLIN as a solution, with an answer that won't fit into a comment...
#M. S. B. - hello. I apologize for writing in your answer, but these comments are much too short, and answering a question in the form of an answer with an answer is ... anyway ...
There is the Quick Plot feature of DISLIN -- routine QPLOT needs only three arguments to plot a curve: X array, Y array and number N. See Chapter 16 of the manual. Plus only several additional calls to select output device and label the axes. I haven't used this, so I don't know how good the auto-scaling is.
Yes, I know of Quickplot, and it's related routines, but it is too fixed for my needs (cannot change anything), and yes, it's autoscaling is somewhat quircky. Also, too big margins inside the graf.
Or if you want to use the power of GRAF to setup your graph box, there is subroutine GAXPAR to automatically generate recommended values. -2 as the first argument to LABDIG automatically determines the number of digits in tick-mark labels.
Have you tried the routines?
Sorry, I cannot find the GAXPAR routine you're reffering to in dislin's index. Are you sure it is called exactly like that ?
Reply by M.S.B.: Yes, I am sure about the spelling of GAXPAR. It is the last routine in Chapter 4 of the DISLIN 9.5 PDF manual. Perhaps it is a new routine? Also there is another path to automatic scaling: SETSCL -- see Chapter 6.
So far, what I've been doing (apart from some "duck tape" solutions) is
use dislin; implicit none
real, dimension(5) :: &
x = [.5, 2., 3., 4., 5.], &
y = [10., 22., 34., 43., 15.]
real :: xa, xe, xor, xstp, &
ya, ye, yor, ystp
call setpag('da4p'); call metafl('xwin');
call disini(); call winkey('return');
call setscl(x,size(x),'x');
call setscl(y,size(y),'y')
call axslen(1680,2376) !(8/10)*2100 and 2970, respectively
call setgrf('name','name','line','line')
call incmrk(1); call hsymbl(3);
call graf(xa, xe, xor, xstp, ya, ye, yor, ystp); call curve(x,y,size(x))
call disfin()
end
which will put the extreme values right on the axis. Do you know perhaps how could I go to have one "major tick margin" on the outside, as to put some area between the curve and the axis (while still keeping setscl's effects) ?
Even if you don't like the built-in auto-scaling, if you are already using DISLIN, rolling your own auto-scaling will be easier than calling Fortran from MATLAB. You can use the Fortran intrinsic functions minval and maxval to find the smallest and largest values in the data, than write a subroutine to round outwards to "nice" round values. Similarly, a subroutine to decide on the tick-mark spacing.
This is actually not so easy to accomplish (and ideas to prove me wrong will be gladly appreciated). Or should I say, it is easy if you know the rough range in which your values will lie. But if you don't, and you don't know
whether your values will lie in the range of 13-34 or in the 1330-3440, then ...
... if I'm on the wrong track completely here, please, explain if you ment something different. My english is somewhat lacking, so I can only hope the above is understandable.
Inside a subroutine to determine round graph start/end values, you could scale the actual min/max values to always be between 1 and 10, then have a table to pick nice round values, then unscale back to the correct range.
--
Dump Matlab because its proprietary, expensive, bloated/slow and codes are not easy to parallelize.
What you should do is use something on the lines of DISLIN, PLplot, GINO, gnuplotfortran etc.

Graph/tree representation and recursion

I'm currently writing an optimization algorithm in MATLAB, at which I completely suck, therefore I could really use your help. I'm really struggling to find a good way of representing a graph (or well more like a tree with several roots) which would look more or less like this:
alt text http://img100.imageshack.us/img100/3232/graphe.png
Basically 11/12/13 are our roots (stage 0), 2x is stage1, 3x stage2 and 4x stage3. As you can see nodes from stageX are only connected to several nodes from stage(X+1) (so they don't have to be connected to all of them).
Important: each node has to hold several values (at least 3-4), one will be it's number and at least two other variables (which will be used to optimize the decisions).
I do have a simple representation using matrices but it's really hard to maintain, so I was wondering is there a good way to do it?
Second question: when I'm done with that representation I need to calculate how good each route (from roots to the end) is (like let's say I need to compare is 11-21-31-41 the best or is 11-21-31-42 better) to do that I will be using the variables that each node holds. But the values will have to be calculated recursively, let's say we start at 11 but to calcultate how good 11-21-31-41 is we first need to go to 41, do some calculations, go to 31, do some calculations, go to 21 do some calculations and then we can calculate 11 using all the previous calculations. Same with 11-21-31-42 (we start with 42 then 31->21->11). I need to check all the possible routes that way. And here's the question, how to do it? Maybe a BFS/DFS? But I'm not quite sure how to store all the results.
Those are some lengthy questions, but I hope I'm not asking you for doing my homework (as I got all the algorithms, it's just that I'm not really good at matlab and my teacher wouldn't let me to do it in java).
Granted, it may not be the most efficient solution, but if you have access to Matlab 2008+, you can define a node class to represent your graph.
The Matlab documentation has a nice example on linked lists, which you can use as a template.
Basically, a node would have a property 'linksTo', which points to the index of the node it links to, and a method to calculate the cost of each of the links (possibly with some additional property that describe each link). Then, all you need is a function that moves down each link, and brings the cost(s) with it when it moves back up.