Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4111070
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T22:01:08+00:00 2026-05-20T22:01:08+00:00

I am using Delphi 2010. Is it possible to tell Delphi to not generate

  • 0

I am using Delphi 2010. Is it possible to tell Delphi to not generate a prologue for a function? I’m writing some pure assembly functions like this:

procedure SomeAssembly; stdcall;
begin
    asm
        ...
    end;
end;

and I would like to tell Delphi not to generate a prologue and epilogue for this function, like C++’s __declspec(naked) feature.

And so no one wastes their time, I don’t need help getting these functions to work with the prologue; I can already do that. It’s just a large inconvenience and will make maintenance an huge hassle. I’ll have to manually inspect the prologues generated by the compiler to see their length, and if that changes, my program will crash.

I also know I can write the function as a series of bytes in a byte array, but that would be even worse than having to go find the length of Delphi’s prologue.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T22:01:08+00:00Added an answer on May 20, 2026 at 10:01 pm

    Delphi doesn’t generate prologues or epilogues for functions having no arguments and declared with the register calling convention. If you want functions without prologues, declare them as zero-argument, register-calling-convention functions. Also, skip the begin–end block and go straight into assembly.

    procedure SomeAssembly; // register; (implied)
    asm
      // ...
    end;
    

    Since you’re effectively lying about the nature of the functions, calling them may be tricky. If you’ve implemented a function as though it received parameters and used a different calling convention, then you’ll have to make sure the compiler knows about that at the call site. To do that, declare a function pointer that reflects the “real” type of your function instead of the declared type. For example, if your function is really 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 it points at your function:

    SomeAssemblyProc := TSomeAssemblyProc(@SomeAssembly);
    if SomeAssembly(2, 'foo') then ...
    

    In addition to skipping the prologue and epilogue, the compiler will generate the incorrect RET instruction for this function (because of the different calling convention), so you’ll have to make sure you say ret 8 in your code instead of letting the compiler’s default ret instruction occur.


    Finding the length of Delphi’s prologue is trivial, if you have a working debugger:

    1. Set a breakpoint at the start of the function.
    2. Call the function.
    3. When the debugger stops at the breakpoint, switch to the CPU view.
    4. Look at the instructions that make up the prologue.
    5. Count the bytes displayed beside those instructions.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Delphi 2010, let's say I've got a class declared like this: TMyList =
Using Delphi 2010. I am looking for (possibly) a function or procedure which can
Using Delphi 2010 I would like to copy a PNG image to the clipboard
I'm automating some document creation using Delphi 2010. In the layout I have, I
This is my first time using BalloonHints. I'm using Delphi 2010. I'm not sure
I am using Firebird on Windows (Delphi 2010 developed Application). Is it possible to
Using Delphi 2010 and a patched version of the BDE I run into a
Is there a way (on windows using Delphi 2010) to get the number of
I need to read from and write to Excel spreadsheets using Delphi 2010. Nothing
I have started using of generics in Delphi 2010 but I have a problem

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.