none
zweigs schwangerschaft nochmal wieder RRS feed

  • Question

  • how to get address of any procedure from my project

    i use delegates, Func<> or Action<> but all of them fail to give me uint address pointer to my procedure in c#

    in assembly it would be mov eax,addr myProc

    but in c#

    void myProc(){}

    int pointer=&myProc; //fails

    why?? how to get address??

    Sunday, May 19, 2019 10:50 AM

Answers

  • Is this what you are interested in ?

    https://stackoverflow.com/questions/25464493/how-to-print-address-of-a-method-in-c

    static void foo()
    {
    }
    
    static void Main(string[] args)
    {
        Delegate fooDelegate = new Action(foo);
    
        IntPtr p = Marshal.GetFunctionPointerForDelegate(fooDelegate);
    
        Console.WriteLine(p);
    }


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Sunday, May 19, 2019 11:21 AM
    Moderator
  • Hi okardak onur,

    Thank you for posting here.

    Based on my search, the link below would be helpful.

    https://stackoverflow.com/questions/7911841/how-to-get-address-in-c-sharp-function-from-delegate

    https://limbioliong.wordpress.com/2011/06/19/delegates-as-callbacks-part-2/

    Best Regards,

    Wendy

    Note: This response contains a reference to a third-party World Wide Web site. Microsoft is providing this information as a convenience to you. 
    Microsoft does not control these sites and has not tested any software or information found on these sites; Therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there.
    There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet. 


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, May 20, 2019 5:26 AM
    Moderator

All replies

  • Is this what you are interested in ?

    https://stackoverflow.com/questions/25464493/how-to-print-address-of-a-method-in-c

    static void foo()
    {
    }
    
    static void Main(string[] args)
    {
        Delegate fooDelegate = new Action(foo);
    
        IntPtr p = Marshal.GetFunctionPointerForDelegate(fooDelegate);
    
        Console.WriteLine(p);
    }


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Sunday, May 19, 2019 11:21 AM
    Moderator
  • Hi okardak onur,

    Thank you for posting here.

    Based on my search, the link below would be helpful.

    https://stackoverflow.com/questions/7911841/how-to-get-address-in-c-sharp-function-from-delegate

    https://limbioliong.wordpress.com/2011/06/19/delegates-as-callbacks-part-2/

    Best Regards,

    Wendy

    Note: This response contains a reference to a third-party World Wide Web site. Microsoft is providing this information as a convenience to you. 
    Microsoft does not control these sites and has not tested any software or information found on these sites; Therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there.
    There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet. 


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, May 20, 2019 5:26 AM
    Moderator