2

I am having problems with a dll, it is called CalibrationL6.dll, I have been able to see the code inside, and the function that interests me is this:

public static int CalculateCoefficients(
          int[] coefficients,
          out int negCoeffs,
          int numPoints,
          int selCoeffs,
          int CalType,
          double[] bridgeRaw,
          double[] bridgeDesired,
          double[] tempRaw,
          double[] tempDesired)
        {
            CalData data = new CalData();
            Vector<CalPoint> calPoints = (Vector<CalPoint>)data.calPoints;
            LMCallbacks callbacks = new LMCallbacks();
            lm_control_type control = new lm_control_type();
            int index1 = 0;
            negCoeffs = 0;
            if (0 < numPoints)
            {
                do
                {
                    bridgeRaw[index1] = (double)Program.TwosComplementToDecimal((int)bridgeRaw[index1]);
                    tempRaw[index1] = (double)Program.TwosComplementToDecimal((int)tempRaw[index1]);
                    ++index1;
                }
                while (index1 < numPoints);
            }
            int index2 = 0;
            if (0 < numPoints)
            {
                do
                {
                    if (tempRaw != null && tempDesired != null)
                    {
                        CalPoint calPoint;
                        calPoint.rawB = bridgeRaw[index2];
                        calPoint.bridge = bridgeDesired[index2];
                        calPoint.temp = tempDesired[index2];
                        calPoint.rawT = tempRaw[index2];
                        calPoints.Add(calPoint);
                    }
                    else
                    {
                        CalPoint calPoint;
                        calPoint.rawB = bridgeRaw[index2];
                        calPoint.bridge = bridgeDesired[index2];
                        calPoint.temp = 2000.0;
                        calPoint.rawT = 2000.0;
                        calPoints.Add(calPoint);
                    }
                    ++index2;
                }
                while (index2 < numPoints);
            }
            data.CalType = CalType;
            data.CO_CAL = selCoeffs;
            Map<double, double> map = new Map<double, double>();
            List<CalPoint>.Enumerator enumerator1 = calPoints.GetEnumerator();
            if (enumerator1.MoveNext())
            {
                do
                {
                    CalPoint current = enumerator1.Current;
                    double key = Math.Truncate(current.temp * 10.0) / 10.0;
                    Dictionary<double, double>.Enumerator enumerator2 = map.GetEnumerator();
                    if (enumerator2.MoveNext())
                    {
                        while (Math.Abs(Map<double, double>.Key((ValueType)enumerator2.Current) - key) >= 0.1)
                        {
                            if (!enumerator2.MoveNext())
                                goto label_11;
                        }
                        goto label_12;
                    }
                label_11:
                    map[key] = current.rawT;
                label_12:;
                }
                while (enumerator1.MoveNext());
            }
            if (map.Size < 3)
                data.CO_CAL &= -561;
            if (map.Size < 2)
                data.CO_CAL &= -269;
            double[] par = new double[10];
            par[0] = 0.0;
            data.cos[0] = 0.0;
            data.cos[1] = 65536.0;
            data.cos[2] = 0.0;
            data.cos[3] = 0.0;
            data.cos[4] = 0.0;
            data.cos[5] = 0.0;
            data.cos[6] = 0.0;
            data.cos[7] = 0.0;
            data.cos[8] = 32768.0;
            data.cos[9] = 0.0;
            data.zero_point = 8388608.0;
            int[] numArray = new int[4] { 2, 4, 6, 7 };
            int num = 0;
            do
            {
                data.CalType = CalType;
                int index3 = 0;
                do
                {
                    int n_par = 0;
                    int index4 = 0;
                    if (0 < numArray[index3])
                    {
                        do
                        {
                            if ((data.CO_CAL >> index4 & 1) != 0)
                            {
                                par[n_par] = data.cos[index4];
                                ++n_par;
                            }
                            else
                                data.cos[index4] = (double)coefficients[index4];
                            ++index4;
                        }
                        while (index4 < numArray[index3]);
                    }
                    data.calcTo = numArray[index3];
                    control.Initialize();
                    //< Module >.lm_minimize(((Vector<CalPoint>)calPoints).Size, n_par, par, (ILMCallbacks)callbacks, (lm_data_type)data, control);
                    int index5 = 0;
                    int index6 = 0;
                    if (0 < numArray[index3])
                    {
                        do
                        {
                            if ((data.CO_CAL >> index6 & 1) != 0)
                            {
                                data.cos[index6] = par[index5];
                                ++index5;
                            }
                            ++index6;
                        }
                        while (index6 < numArray[index3]);
                    }
                    ++index3;
                }
                while (index3 < 4);
                data.CalType = 2;
                int n_par1 = 0;
                int index7 = 7;
                do
                {
                    if ((data.CO_CAL >> index7 & 1) != 0)
                    {
                        par[n_par1] = data.cos[index7];
                        ++n_par1;
                    }
                    else
                        data.cos[index7] = (double)coefficients[index7];
                    ++index7;
                }
                while (index7 <= 9);
                control.Initialize();
                //< Module >.lm_minimize(((Vector<CalPoint>)calPoints).Size, n_par1, par, (ILMCallbacks)callbacks, (lm_data_type)data, control);
                int index8 = 0;
                int index9 = 7;
                do
                {
                    if ((data.CO_CAL >> index9 & 1) != 0)
                    {
                        data.cos[index9] = par[index8];
                        ++index8;
                    }
                    ++index9;
                }
                while (index9 <= 9);
                int index10 = 0;
                do
                {
                    coefficients[index10] = (int)data.cos[index10];
                    ++index10;
                }
                while (index10 < 10);
                int coefficient = coefficients[6];
                if (coefficient < 0)
                {
                    if (coefficient < -8388607)
                    {
                        coefficients[6] = -8388607;
                        data.CO_CAL &= -65;
                        data.cos[6] = 0.0;
                    }
                    else
                        break;
                }
                else if (coefficient > 536870911)
                {
                    coefficients[6] = 33554431;
                    data.CO_CAL &= -65;
                }
                else
                    break;
                ++num;
            }
            while (num < 2);
            if (coefficients[0] < 0)
                negCoeffs |= 64;
            if (coefficients[7] < 0)
                negCoeffs |= 128;
            if (coefficients[9] < 0)
                negCoeffs |= 8;
            if (coefficients[4] < 0)
                negCoeffs |= 2;
            if (coefficients[5] < 0)
                negCoeffs |= 4;
            if (coefficients[3] < 0)
                negCoeffs |= 16;
            if (coefficients[2] < 0)
                negCoeffs |= 32;
            return 0;

        }

But I have problems with a function and a class that is:

< Module >.lm_minimize(((Vector<CalPoint>)calPoints).Size, n_par1, par, (ILMCallbacks)callbacks, (lm_data_type)data, control);

I can't find the class and I don't know what it refers to... it would be very useful if you can help me find a solution...

Thanks

2
  • Which decompiler are you using? I'd guess worst case you can do an export-all-sources and grep them for lm_minimize. I'd think most tools would let you double-click on lm_minimize and it'll take you to the definition though.
    – Rup
    Feb 20 at 1:58
  • Yes i can check lm_minimize function but it has unreadable code (hexadecimal, binary, etc.) i used two decompilers.. JetBrains dotPeek and Telerik JustDecompile
    – raulelerma
    Feb 23 at 21:02

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.