diff --git a/label_pointer.c b/label_pointer.c index 2fd35d2..82f8d99 100644 --- a/label_pointer.c +++ b/label_pointer.c @@ -1,36 +1,37 @@ -#include -#include - -#pragma intrinsic(_ReturnAddress) - -char* next_instruction_address(void) { return (char*)_ReturnAddress(); } - -int test( - char* (*_next_instruction_address) (void) -) { - char* p_begin = _next_instruction_address() + 13; -begin:; - int a = 2; - int b = 2; - char* p_end = _next_instruction_address() + 13; -end:; - - char* save_p_end = p_end; - char* save_p_begin = p_begin; - __asm { - lea eax, begin - mov p_begin, eax - lea eax, end - mov p_end, eax - } - printf("%lu=%lu\n%lu=%lu\n", - (size_t)save_p_end, (size_t)p_end, - (size_t)save_p_begin, (size_t)p_begin); - - return a + b; -} - -int main(void) { - test(next_instruction_address); - return 0; +#include +#include + +#pragma intrinsic(_ReturnAddress) + +char* next_instruction_address(void) { return (char*)_ReturnAddress(); } + +int test( + char* (*_next_instruction_address) (void) +) { + char* p_begin = _next_instruction_address() + 13; +begin:; + int a = 2; + int b = 2; + char* p_end = _next_instruction_address() + 13; +end:; + + char* save_p_end = p_end; + char* save_p_begin = p_begin; + __asm { + lea eax, begin + mov p_begin, eax + lea eax, end + mov p_end, eax + } + // Сравнение адресов, полученных без вставки и с ней + printf("%lu=%lu\n%lu=%lu\n", + (size_t)save_p_end, (size_t)p_end, + (size_t)save_p_begin, (size_t)p_begin); + + return a + b; +} + +int main(void) { + test(next_instruction_address); + return 0; } \ No newline at end of file