From 944c4e8f760460ca6a260573d87c454052caad2c Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Fri, 13 Sep 2019 17:19:38 +0200 Subject: [PATCH] ntdll: Use virtual_uninterrupted_read_memory() to read code inside signal handler on i386. Signed-off-by: Alexandre Julliard --- dlls/ntdll/signal_i386.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/dlls/ntdll/signal_i386.c b/dlls/ntdll/signal_i386.c index 35abc288b30..8d1c591504d 100644 --- a/dlls/ntdll/signal_i386.c +++ b/dlls/ntdll/signal_i386.c @@ -1530,13 +1530,13 @@ __ASM_STDCALL_FUNC( NtGetContextThread, 8, */ static inline DWORD is_privileged_instr( CONTEXT *context ) { - const BYTE *instr; - unsigned int prefix_count = 0; + BYTE instr[16]; + unsigned int i, len, prefix_count = 0; if (!wine_ldt_is_system( context->SegCs )) return 0; - instr = (BYTE *)context->Eip; + len = virtual_uninterrupted_read_memory( (BYTE *)context->Eip, instr, sizeof(instr) ); - for (;;) switch(*instr) + for (i = 0; i < len; i++) switch (instr[i]) { /* instruction prefixes */ case 0x2e: /* %cs: */ @@ -1551,11 +1551,11 @@ static inline DWORD is_privileged_instr( CONTEXT *context ) case 0xf2: /* repne */ case 0xf3: /* repe */ if (++prefix_count >= 15) return EXCEPTION_ILLEGAL_INSTRUCTION; - instr++; continue; case 0x0f: /* extended instruction */ - switch(instr[1]) + if (i == len - 1) return 0; + switch(instr[i + 1]) { case 0x20: /* mov crX, reg */ case 0x21: /* mov drX, reg */ @@ -1584,6 +1584,7 @@ static inline DWORD is_privileged_instr( CONTEXT *context ) default: return 0; } + return 0; }