• Event(事件)


    1、ZC:之前一直没怎么用过 OpenEvent(...),这次试用居然老是报错...

      弄了一下,貌似是 OpenEvent(...)的第一个参数设置成0了...

    FhEvent_CommunicatorServer = CreateEvent(NULL, false, false, EVENT_COMMUNICATOR_SERVER);
    FhEvent_CommunicatorServer = OpenEvent(EVENT_ALL_ACCESS, false, EVENT_COMMUNICATOR_SERVER);

      ZC:(20180418) CreateEvent(...) 和 OpenEvent(...) 可能返回的 HANDLE的值 居然是可以不同的,但是 它们操作的是同一个 事件对象。我还以为 OpenEvent(...) 出错了...

    2、

    关于命名CreateEvent权限的问题

      (http://blog.csdn.net/collin1211/article/details/3322411

      在服务程序中CreateEvent,当LPSECURITY_ATTRIBUTES这个参数传NULL的时候,将使用默认访问控制。           
      服务程序中的默认控制就是不允许桌面程序访问这些对象,所以服务中打开的Event,桌面无法打开,GetLastError()的值为5(ERROR_ACCESS_DENIED) 返回访问拒绝。
      服务中创建的内核对象要想在普通应用程序中使用,必须指定安全描述符。

    SECURITY_DESCRIPTOR SecurityDescriptor = { 0 };
    ::InitializeSecurityDescriptor(&SecurityDescriptor, 1);
    ::SetSecurityDescriptorDacl(&SecurityDescriptor, TRUE, NULL, FALSE);
    SECURITY_ATTRIBUTES SecurityAttribute = { 0 };
    SecurityAttribute.nLength               = sizeof(SecurityAttribute);
    SecurityAttribute.lpSecurityDescriptor  = &SecurityDescriptor;
    SecurityAttribute.bInheritHandle        = TRUE;
    m_hEventForStop = ::CreateEvent(&SecurityAttribute, TRUE, FALSE, _defStopEventName);

      OpenEvent就按一般的写法即可,例:

    HANDLE hStopEvent = ::OpenEvent(EVENT_MODIFY_STATE, FALSE, _defStopEventName);
    if (hStopEvent)
    {
            ::SetEvent(hStopEvent);
        ::CloseHandle(hStopEvent);
    }

    3、

    4、

    5、

  • 相关阅读:
    P1396 营救
    [BUUCTF]REVERSE——xor
    [BUUCTF]REVERSE——helloword
    [BUUCTF]REVERSE——[BJDCTF 2nd]guessgame
    [BUUCTF]REVERSE——新年快乐
    [BUUCTF]PWN——jarvisoj_level3
    [BUUCTF]PWN——[BJDCTF 2nd]test
    [BUUCTF]PWN——ciscn_2019_es_2
    [BUUCTF]PWN——[Black Watch 入群题]PWN
    [BUUCTF]PWN——others_shellcode
  • 原文地址:https://www.cnblogs.com/cppskill/p/8252396.html
Copyright © 2020-2023  润新知