From 39fbd5604255b16da65f60cba7e0a61366f4f444 Mon Sep 17 00:00:00 2001 From: serr Date: Thu, 9 Jan 2025 18:55:43 +0300 Subject: [PATCH] =?UTF-8?q?=D0=97=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=B8?= =?UTF-8?q?=D1=82=D1=8C=20=D1=84=D0=B0=D0=B9=D0=BB=D1=8B=20=D0=B2=20=C2=AB?= =?UTF-8?q?/=C2=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- label_pointer.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 label_pointer.c diff --git a/label_pointer.c b/label_pointer.c new file mode 100644 index 0000000..2fd35d2 --- /dev/null +++ b/label_pointer.c @@ -0,0 +1,36 @@ +#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