none
Disabling the generation of prolog and epilog code

    Question

  • Hey,
    well, I will not describe my situation because it is not part of my question and has nothing directly to do with it and would only lead to false assumptions as it already did...

    My question is whether there is another way - other than __declspec(naked), to disable the generation of prolog and epilog code of a function.
    __declspec(naked) is not allowed on class member functions, which is probably because the this-pointer gets stored on the stack.

    However, in my situation, the stack as well as any general register must not be modified, as I intend to make the function jump (via __asm{ jmp ... } ) somewhere else where it does not return from to execute the epilog code.

    That is why I am looking for an alternative of sorts.
    Is it possible to disable the prolog and epilog generation in class member functions? If so, how?

    Not that I am implying anything, but seeing that the discussion may drift to an entirely different topic directly, please do not return the question of why I am wanting to do this. I do know what I am doing and why I would need this.

    Any help would be greatly appreciated.
    Regards,
    pd
    Saturday, October 04, 2008 11:51 AM

Answers

  • I just found your original thread.

    If I understand correctly:
    you have a DLL that is called by the EXE.
    That DLL exports a class.
    If the EXE calls method MyClass::foo you want to execute another function.

    That function is located where?
    Why does your method have to be naked? Why not simply cast the execution address to a function pointer and execute that function through its function pointer normally?
    • Marked as answer by Yan-Fei Wei Friday, October 10, 2008 7:52 AM
    Monday, October 06, 2008 7:28 AM

All replies

  • well, I will not describe my situation because it is not part of my question and has nothing directly to do with it and would only lead to false assumptions as it already did... 


    How do you know it has nothing to do with it? You obviously have a problem with something.
    If we don't know the context of your question, there is less chance of use being able to help you.

    Not that I am implying anything, but seeing that the discussion may drift to an entirely different topic directly, please do not return the question of why I am wanting to do this. I do know what I am doing and why I would need this.

    And we would like to know so too. Even if it is just out of curiosity.
    Monday, October 06, 2008 6:26 AM
  • I just found your original thread.

    If I understand correctly:
    you have a DLL that is called by the EXE.
    That DLL exports a class.
    If the EXE calls method MyClass::foo you want to execute another function.

    That function is located where?
    Why does your method have to be naked? Why not simply cast the execution address to a function pointer and execute that function through its function pointer normally?
    • Marked as answer by Yan-Fei Wei Friday, October 10, 2008 7:52 AM
    Monday, October 06, 2008 7:28 AM
  •  

    Hello

     

    Re:  Disabling the generation of prolog and epilog code


    I am going to mark this thread as answered since you have not followed up with any further information on your problem as requested - I assume you solved the problem yourself or one of the suggestions in this thread helped you solved the problem. If you have a solution you could post it so others can find it. If you don’t have a solution, then please submit further details and then mark the thread as unanswered.

     

    Thanks!


    Please remember to mark the replies as answers if they help and unmark them if they provide no help. http://forums.msdn.microsoft.com/en-US/vcgeneral/thread/aad4f73b-59e2-4ead-8a11-a19752dfea0a
    Friday, October 10, 2008 7:52 AM