How to get the length of a function in bytes?

后端 未结 11 1121
醉酒成梦
醉酒成梦 2020-11-28 11:16

I want to know the length of C function (written by me) at runtime. Any method to get it? It seems sizeof doesn\'t work here.

11条回答
  •  广开言路
    2020-11-28 11:44

    I have just came up with a solution for the exact same problem but the code i have written is platform depended.

    The idea behind, putting known opcodes at the end of the function and searching for them from start while counting bytes we have skipped. Here is the medium link which i have explained with some code https://medium.com/@gurhanpolat/calculate-c-function-size-x64-x86-c1f49921aa1a

提交回复
热议问题