delphi - Removing the prologue of a function written in pure assembly -


I am using Delphi 2010. Is Delphi possible to not create the preamble for the function? I am writing some pure assembly functions like this:

  process some assembly; Stdcall; Asm start ... end; End;   

And I would not like to make Delphi an introduction and anecdote for this function, such as the __ display of C ++ (naked) feature.

> And so nobody does not waste their time, I do not need help to work these tasks with preface; I can do this already, this is just a big discomfort and will make maintenance a big problem. I have to manually inspect the proposals generated by the compiler to see my length, and if it changes, then my The program will crash.

I also know that I can write the function as a series of bytes byte array, but it will also get worse than going to find the length of delphi prelude.

Delphi does not generate preamble or epils for the work of no logic And declares with the registered calling conference. If you want to work without preamble, then declare them as zero logic, register-calling conference functions. In addition, go directly to the assembly except the start - end block.

  Process Some Espad; // register; (Implied) ASM // ... end;   

Since you are effectively lying about the nature of the function, it can be difficult to call them. If you have implemented a function such that it has received the criteria and used a different calling conference, then you have to ensure that the compiler knows the call site. To do this, declare the function pointer which shows the "actual" type of your function rather than the declared type. For example, if your function is actually a two-argument stdcall function, declare something like this:

  type TSomeAssemblyFunc = function (Arg1: Integer; Arg2: PAnsiChar): Boolean; Stdcall; Var SomeAssemblyProc: TSomeAssemblyProc;   

Now, assign that variable so that it points to your function:

  some assont effect: = TSomeAssemblyProc (@SomeAssembly); If some assembly (2, 'foo') ... ...   

In addition to leaving the preface and posterior, the compiler will generate incorrect RET instructions for this function (Due to different calling conventions), so you have to make sure that you call ret 8 in your code instead of the default ret instruction of the compiler. <

  1. Set the breakpoint at the beginning of the function. Call the Li function.
  2. When the debugger stops at the breakpace, switch to the CPU view.
  3. Look at the instructions that make the preamble.
  4. Calculate the bytes displayed next to those instructions.

Comments

Popular posts from this blog

qt - switch/case statement in C++ with a QString type -

python - sqlite3.OperationalError: near "REFERENCES": syntax error - foreign key creating -

Python's equivalent for Ruby's define_method? -