- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个运行在各种x86-32和x86-64机器上的相当复杂但经过了充分测试的汇编语言x86-32应用程序。这是用于语言编译器的运行时系统,因此它支持执行另一个已编译的二进制程序“目标代码”。
它使用Windows SEH捕获各种陷阱:除以零,非法访问...,并使用Windows提供的上下文信息打印寄存器转储,该信息显示陷阱时机器的状态。 (它还有很多与问题无关的其他东西,例如打印函数回溯或根据需要从零除以恢复)。这使“目标代码”的编写者可以了解其程序出了什么问题。
在我认为是非法内存访问的两个Windows 7-64系统上,它们的行为或多或少是相同的。特定的问题是某个地方的“目标代码”(不是经过充分测试的运行时系统)愚蠢地将0x82加载到EIP中。这是地址空间AFAIK中不存在的页面。我希望通过SEH获得Windows陷阱,并希望通过EIP = 00000082等进行寄存器转储。
在一个系统上,我确切地得到了该寄存器转储。我可以在这里显示它,但不会对我的问题有任何影响。因此,很明显,我的运行时系统中的SEH可以捕获此错误并显示情况。该机器上没有任何MS开发工具。
在另一个(“神秘”)系统上,使用与运行时系统和目标代码完全相同的二进制文件,我得到的只是命令提示符。没有进一步的输出。 FWIW,此计算机上装有MS Visual Studio 2010。该神秘机大量用于其他目的,在正常使用中未显示其他有趣行为。
我认为行为差异是由某处的Windows配置或Visual Studio控制的某物引起的。不是系统菜单的DEP配置。它们都被配置为“标准系统过程的DEP”(原始)。而且我的运行时系统可执行文件已配置为“否(/ NXCOMPAT:NO)”。
这两台机器都是i7,但芯片不同,4核,大量内存,不同的主板。我认为这不相关;当然,这两个CPU都以相同的方式捕获陷阱。
运行时系统在启动时包括以下行:
SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX); //崩溃时停止Windows弹出窗口
最近添加了此选项是为了防止崩溃发生时“神秘”系统显示弹出窗口“xxx.exe已停止工作”。弹出框的行为在第一个系统上没有发生,因此所有这些操作只是将问题推到了“神秘”机器上的另一个角落。
我在哪里寻找配置/控制的任何线索?
我在这里提供我正在使用的SEH代码。已被编辑
删除大量的健全性检查代码
我声称对所看到的外观状态没有影响
在此代码中。
运行时系统的顶层生成一组工作程序
线程(使用CreateThread)并指向执行ASMGrabGranuleAndGo;
每个线程都设置自己的SEH,并分支到窃取工作的调度程序RunReadyGranule。就我所知,SEH并未更改
之后;至少,运行时系统和“目标代码”可以
不这样做,但是我不知道底层是什么(例如,标准“C”)
库可能会做。
接下来,我提供陷阱处理程序TopLevelEHFilter。
是的,套准印刷机本身可能会吹
导致第二个异常。我会尽快尝试进行检查,
但是IIRC我最后一次尝试是在调试器上
机,没有将控制权传递给调试器,只是
让我弹出了窗口。
public ASMGrabGranuleAndGo
ASSUME FS:NOTHING ; cancel any assumptions made for this register
ASMGrabGranuleAndGo:
;Purpose: Entry for threads as workers in PARLANSE runtime system.
; Each thread initializes as necessary, just once,
; It then goes and hunts for work in the GranulesQ
; and start executing a granule whenever one becomes available
; install top level exception handler
; Install handler for hardware exceptions
cmp gCompilerBreakpointSet, 0
jne HardwareEHinstall_end ; if set, do not install handler
push offset TopLevelEHFilter ; push new exception handler on Windows thread stack
mov eax, [TIB_SEH] ; expected to be empty
test eax, eax
BREAKPOINTIF jne
push eax ; save link to old exception handler
mov fs:[TIB_SEH], esp ; tell Windows that our exception handler is active for this thread
HardwareEHinstall_end:
;Initialize FPU to "empty"... all integer grains are configured like this
finit
fldcw RTSFPUStandardMode
lock sub gUnreadyProcessorCount, 1 ; signal that this thread has completed its initialization
@@: push 0 ; sleep for 0 ticks
call MySleep ; give up CPU (lets other threads run if we don't have enuf CPUs)
lea esp, [esp+4] ; pop arguments
mov eax, gUnreadyProcessorCount ; spin until all other threads have completed initialization
test eax, eax
jne @b
mov gThreadIsAlive[ecx], TRUE ; signal to scheduler that this thread now officially exists
jmp RunReadyGranule
ASMGrabGranuleAndGo_end:
;-------------------------------------------------------------------------------
TopLevelEHFilter: ; catch Windows Structured Exception Handling "trap"
; Invocation:
; call TopLevelEHFilter(&ReportRecord,&RegistrationRecord,&ContextRecord,&DispatcherRecord)
; The arguments are passed in the stack at an offset of 8 (<--NUMBER FROM MS DOCUMENT)
; ESP here "in the stack" being used by the code that caused the exception
; May be either grain stack or Windows thread stack
extern exit :proc
extern syscall @RTSC_PrintExceptionName@4:near ; FASTCALL
push ebp ; act as if this is a function entry
mov ebp, esp ; note: Context block is at offset ContextOffset[ebp]
IF_USING_WINDOWS_THREAD_STACK_GOTO unknown_exception, esp ; don't care what it is, we're dead
; *** otherwise, we must be using PARLANSE function grain stack space
; Compiler has ensured there's enough room, if the problem is a floating point trap
; If the problem is illegal memory reference, etc,
; there is no guarantee there is enough room, unless the application is compiled
; with -G ("large stacks to handle exception traps")
; check what kind of exception
mov eax, ExceptionRecordOffset[ebp]
mov eax, ExceptionRecord.ExceptionCode[eax]
cmp eax, _EXCEPTION_INTEGER_DIVIDE_BY_ZERO
je div_by_zero_exception
cmp eax, _EXCEPTION_FLOAT_DIVIDE_BY_ZERO
je float_div_by_zero_exception
jmp near ptr unknown_exception
float_div_by_zero_exception:
mov ebx, ContextOffset[ebp] ; ebx = context record
mov Context.FltStatusWord[ebx], CLEAR_FLOAT_EXCEPTIONS ; clear any floating point exceptions
mov Context.FltTagWord[ebx], -1 ; Marks all registers as empty
div_by_zero_exception: ; since RTS itself doesn't do division (that traps),
; if we get *here*, then we must be running a granule and EBX for granule points to GCB
mov ebx, ContextOffset[ebp] ; ebx = context record
mov ebx, Context.Rebx[ebx] ; grain EBX has to be set for AR Allocation routines
ALLOCATE_2TOK_BYTES 5 ; 5*4=20 bytes needed for the exception structure
mov ExceptionBufferT.cArgs[eax], 0
mov ExceptionBufferT.pException[eax], offset RTSDivideByZeroException ; copy ptr to exception
mov ebx, ContextOffset[ebp] ; ebx = context record
mov edx, Context.Reip[ebx]
mov Context.Redi[ebx], eax ; load exception into thread's edi
GET_GRANULE_TO ecx
; This is Windows SEH (Structured Exception Handler... see use of Context block below!
mov eax, edx
LOOKUP_EH_FROM_TABLE ; protected by DelayAbort
TRUST_JMP_INDIRECT_OK eax
mov Context.Reip[ebx], eax
mov eax, ExceptionContinueExecution ; signal to Windows: "return to caller" (we've revised the PC to go to Exception handler)
leave
ret
TopLevelEHFilter_end:
unknown_exception:
<print registers, etc. here>
最佳答案
“用于标准系统过程的DEP”不会为您提供帮助;这是internally known as "OptIn"。您需要的是在.exe文件的PE header 中设置的IMAGE_DLLCHARACTERISTICS_NX_COMPAT
标志。或在kernel32.dll中调用SetProcessDEPPolicy
函数。SetProcessMitigationPolicy
也可以...但是直到Windows 8才可用。
有一些nice explanation on Ed Maurer's blog,它解释了.NET如何使用DEP(您不会在意)以及系统规则(您会这样做)。
BIOS设置也会影响硬件NX是否可用。
关于windows - 结构化异常处理程序在几乎相同的机器上以不同的方式捕获接近零的EIP陷阱?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25797325/
我被难住了。如果我对文件路径进行硬编码,则此脚本在我的 Windows 机器上的 Eclipse 中运行良好。如果我尝试接受参数并在我的边缘节点(一个 linux 机器)上运行它,它不会抛出任何特定的
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 关闭 8 年前。 这个问题似乎不是关于 a specific programming problem,
我们最近将我们的基础架构从 Solaris(Oracle/Sun Java) 迁移到 AIX(IBM Java)。 我们的客户将使用我们共享的算法(AES)和 key 上传加密文件,一旦加密文件放置在
我想编写一个程序(java),它接受一个文件作为输入,对其进行加密(使用aes128)并通过ftp发送该加密文件,接收者接收它并使用 key 进行解密。我是初学者,有什么帮助可以做到这一点吗?非常感谢
我正在尝试将一些为 1c2 机器 (thumb) 编译的 DLL 导入 WinMobile 6.1 C# 智能设备项目。 然而,当我尝试将它们导入我的 C# 项目时,我得到“无法添加对...的引用”,
我正在寻找 FPGA + 机器。 它应该是入门级定价(例如不超过 200 美元)。 编辑:我想制作一个 ASM 图表并将 FPGA 编程为我在图表中指定的行为 最佳答案 你看过Arduino ? 关于
这是我想完成的: Write a program that stimulates a bean machine Your program should prompt the user to enter
我尝试使用以下命令在 Windows 10 上使用 hyperv 创建一台机器: docker-machine create --driver hyperv default 但它给了我: This m
我有个问题 我的问题是我有一个将 mapred.map.tasks 配置为10的作业(抓取工具),这意味着我的工作将一次创建10个映射器。但是我的集群将 mapred.tasktracker.map.
我正在尝试使用命令重新启动 Docker sudo docker restart a7f8ce75f51f 但我收到以下错误 Error response from daemon: Cannot re
在新机器上引导 Eclipse 是一个非常耗时的过程,您最终会问自己是否真的需要每个插件。但这些都很方便,并且有助于养成一致的习惯。 Eclipse 引导问题包括: 解释/记录需要发生的事情 粘贴正确
我们希望建立一个 Docker 开发节点,我们团队中的任何人都可以将东西部署到其中。 我使用 SSH 创建了一个新的 Docker 机器,如下所示: docker-machine create \
如果可能的话,我想使用 java.util.logging 来做到这一点,有什么想法吗?谢谢。 最佳答案 您可以尝试一下SLF4J . Simple Logging Facade for Java (
当 vagrant up 时,我们的 vagrant box 需要大约 1 小时才能提供第一次运行,在配置过程的最后,我想将盒子打包到本地文件夹中的图像,以便下次需要重建时将其用作基础盒子。我正在使用
我正在为我的图像处理项目构建一个 SVM 线性机,在其中提取正样本和负样本的特征并将其保存到目录中。然后,我使用这些功能训练 SVM,但收到一个无法调试的错误。下面是我用于训练分类器的 train-c
问题描述: 我要将MySQL server 5.7.11 (win32) 安装到Windows server 2012 中。服务器中安装了多个网络接口(interface)卡,我将安装多个绑定(bin
我想安排一台 (AWS) Linux 计算机启动、运行程序,然后自行关闭(以将成本保持在最低水平)。我可以放 mycommand; shutdown 在/etc/rc.local 文件中。但如果我需要
关闭。这个问题需要多问focused 。目前不接受答案。 想要改进此问题吗?更新问题,使其仅关注一个问题 editing this post . 已关闭 4 年前。 Improve this ques
如何将此文件的输出发送到另一台 Linux 计算机的主目录。 显然,我想发送此文件的输出: sed '/^\s*#/d;/^$/d' /etc/httpd/conf/httpd.conf 到 nati
我有一个 Linux 机器,我可以使用 SSH 进行 root 访问。 我想使用GDB来调试系统。 这是一个精简的 Debian 软件包;因此,我里面没有任何编译工具。 uname -a 给出: 2.
我是一名优秀的程序员,十分优秀!