Binarysharp.MemoryManagement.Assembly.CallingConvention.ThiscallCallingConvention.FormatParameters C# (CSharp) Method

FormatParameters() public method

Formats the given parameters to call a function. The 'this' pointer must be passed in first.
public FormatParameters ( IntPtr parameters ) : string
parameters System.IntPtr An array of parameters.
return string
        public string FormatParameters(IntPtr[] parameters)
        {
            // Declare a var to store the mnemonics
            var ret = new StringBuilder();
            var paramList = new List<IntPtr>(parameters);
            // Store the 'this' pointer in the ECX register
            if (paramList.Count > 0)
            {
                ret.AppendLine("mov ecx, " + paramList[0]);
                paramList.RemoveAt(0);
            }
            // For each parameters (in reverse order)
            paramList.Reverse();
            foreach (var parameter in paramList)
            {
                ret.AppendLine("push " + parameter);
            }
            // Return the mnemonics
            return ret.ToString();
        }