proc/native: Mask MS_VC_EXCEPTION [windows]

Some libraries (for example steam_api64.dll) will send this exception
code to set the thread name on Microsoft VisualC.
In theory it should be fine to send the exception back to the target,
which is responsible for setting a handler for it, in practice in some
cases (steam_api64.dll) this will crash the program. So we'll mask it
instead.

Fixes #1383
This commit is contained in:
aarzilli 2018-10-19 09:16:56 +02:00 committed by Derek Parker
parent d0f0a872a7
commit 4db9939845

@ -245,6 +245,8 @@ const (
waitDontHandleExceptions waitDontHandleExceptions
) )
const _MS_VC_EXCEPTION = 0x406D1388 // part of VisualC protocol to set thread names
func (dbp *Process) waitForDebugEvent(flags waitForDebugEventFlags) (threadID, exitCode int, err error) { func (dbp *Process) waitForDebugEvent(flags waitForDebugEventFlags) (threadID, exitCode int, err error) {
var debugEvent _DEBUG_EVENT var debugEvent _DEBUG_EVENT
shouldExit := false shouldExit := false
@ -346,6 +348,10 @@ func (dbp *Process) waitForDebugEvent(flags waitForDebugEventFlags) (threadID, e
case _EXCEPTION_SINGLE_STEP: case _EXCEPTION_SINGLE_STEP:
dbp.os.breakThread = tid dbp.os.breakThread = tid
return tid, 0, nil return tid, 0, nil
case _MS_VC_EXCEPTION:
// This exception is sent to set the thread name in VisualC, we should
// mask it or it might crash the program.
continueStatus = _DBG_CONTINUE
default: default:
continueStatus = _DBG_EXCEPTION_NOT_HANDLED continueStatus = _DBG_EXCEPTION_NOT_HANDLED
} }