CreateEvent from Windows-7 Logon Screen

馋奶兔 提交于 2020-01-14 10:14:17

问题


I'm asking this question because it turns out that there's some difficulty in writing a screensaver app in Delphi that's capable of running from the Logon screen.

See question: Windows 7 logon screensaver in Delphi

I've narrowed down the problem (or at least one problem) to a particular Win API call CreateEvent.

SyncEvent := CreateEvent(nil, True, False, '');
if SyncEvent = 0 then
  RaiseLastOSError;

This code only fails if called from the Logon screen. And GetLastError returns that access is denied. So clearly the security restrictions on the Logon screen prevent CreateEvent(nil, True, False, ''); from creating the event as desired.

(I don't really see how an Event could be an exploitable security risk.)

So, the question is: Is it possible to create an Event from the Logon screen? Presumably via either:

  • Using an appropriate lpEventAttributes
  • Or calling CreatingEventEx instead.

Although the problem was experienced in Delphi, this is more about the Win API. So feel free to answer in your language of choice.


回答1:


Try setting the last parameter of CreateEvent() to nil instead of '' . There is a difference between a nil pointer and a pointer to a zero-length string. The documentation does not say anything about a zero- length string being treated any differently than any other named string. So maybe there is another zero-length-named event that exists somewhere else on your machine that your app does not have access to, thus the Access Denied error when CreateEvent() tries to access the existing event and fails. If you want to create an unnamed event, use nil instead.



来源:https://stackoverflow.com/questions/24726463/createevent-from-windows-7-logon-screen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!