具体是什么导致 EPrivilege 提高?
我收到一份错误报告,指出我的程序使用的外部 DLL(SDL_Mixer,如果它有帮助)中的某些音乐播放代码中的某些功能正在提高 EPrivilege。该 DLL 是用 C 编写的,因此我无法使用 MadExcept 从中获取有用的堆栈跟踪信息,并且该问题在我这边无法重现。更糟糕的是,我什至不知道 EPrivilege 是什么。
我从来没有在我自己的代码中看到过它,网上关于它的信息很少,而且内容是矛盾的。 (一种解释是,如果您尝试使用有限帐户执行某些需要不可用权限的操作,则操作系统会引发此错误;另一种解释则表示,如果您尝试执行高于您的权限级别的指令,则 CPU 会引发此错误。)
有谁对EPrivilege的原因有权威的解释吗?有谁知道如何在非管理员帐户下的一台 Windows 7 64 位计算机上通过音乐播放代码来引发它,但在我的 Windows 7 上运行相同的代码时却不会引发它64位机器在非管理员帐户下?
I'm getting a bug report that some functionality in some music-playing code in an external DLL (SDL_Mixer, in case it helps) that my program uses is raising EPrivilege. The DLL is written in C, so I can't get useful stack trace information out of it with MadExcept, and the problem is not reproducible on my end. And just to make things worse, I don't even know what EPrivilege is.
I've never seen it come up in my own code, there's very little information about it available online, and what there is is contradictory. (One explanation says it's raised by the OS if you try to do something with a limited account that requires privileges that aren't available, another says that it's raised by the CPU if you try to execute an instruction that's above your privilege level.)
Does anyone have an authoritative explanation for what causes EPrivilege? And does anyone have any idea how it could be raised by music-playing code on one Windows 7 64-bit machine under a non-admin account but not be raised when running the same code on my Windows 7 64-bit machine under a non-admin account?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
当硬件反对您尝试在用户模式下运行特权指令时,会引发
EPrivilege
。这些特权指令仅限于超级用户模式,即 ring 0。硬件引发错误,然后 RTL 捕获它并将其映射到 RTL 异常,就像所有
EExternal
异常一样,例如EAccessViolation
、EStackOverflow
> 等等。管理员权限与此处无关。这是由操作系统软件强制执行的。指令特权在硬件级别进行控制。
如果您尝试执行垃圾(即损坏的函数指针),而这恰好拼写了特权指令,您会看到这样的错误。内存损坏是唯一合理的解释。只有针对内核模式代码的编译器才会发出特权指令。
EPrivilege
is raised when the hardware objects to you trying to run a privileged instruction in user mode. These privileged instructions are restricted to supervisor mode, a.k.a. ring 0.The hardware raises the error and then the RTL catches it and maps it to a RTL exception, just like all the
EExternal
exceptions, e.g.EAccessViolation
,EStackOverflow
etc.Admin rights are not relevant here. That is something that is enforced by the OS software. Instruction privilege is controlled at the hardware level.
You see such an error if you attempt to execute garbage (i.e. corrupted function pointer) which just happens to spell a privileged instruction. Memory corruption is the only sane explanation. Only compilers that target kernel mode code will emit privileged instructions.
我们使用Delphi 进行很多实时硬件控制。这涉及到读取和写入 I/O 端口。如果您没有权限(或内核驱动程序)执行此操作,您将获得
EPrivilege
。例如,这段代码:
在W98下不需要任何东西就可以将一个字节写入I/O地址,例如PC并行端口。在 NT 下及其上将生成
EPrivilege
除非该地址已以某种方式“打开”,例如使用 gwiopm。因此,EPrivilege
可能是“垃圾读/写”(如 David 所建议的)或不完整的设置(读取/写入不正确的设置硬件)的指示符。We do a lot of real-time hardware control using Delphi. This involves reading and writing I/O ports. If you dont have permission (or a kernel driver) to do this, you get
EPrivilege
.For example this bit of code:
under W98 needed nothing to allow it to write a byte to an I/O address, eg the PC parallel port. Under NT and on it will generate
EPrivilege
unless that address has been 'opened' in some way eg using gwiopm. ThusEPrivilege
can be an indicator of a 'garbage read/write' (as David suggests) or of an incomplete setup that read / writes incorrectly setup hardware.就我而言,我只是重新编译了主单元,它就得到了修复。
In my case I just recompiled the main unit and it got fixed.