コミットメタ情報

リビジョンaa92c5f7ee4e371d6b130533640018889e6479c1 (tree)
日時2014-09-11 22:22:28
作者Kazuhiro Fujieda <fujieda@user...>
コミッターKazuhiro Fujieda

ログメッセージ

Fix a bug where the icon doesn't reflect the hook state on Internet Explorer

Each window on Internet Explorer runs on a separate process at a low
integrity level. These processes can't write the named pipe to notify
the hook state. This fix allow them to do it.

変更サマリ

差分

--- a/xkeymacs/mainfrm.cpp
+++ b/xkeymacs/mainfrm.cpp
@@ -6,6 +6,8 @@
66 #include "profile.h"
77 #include "../xkeymacsdll/xkeymacsdll.h"
88 #include "../xkeymacsdll/Utils.h"
9+#include <Sddl.h>
10+#include <AclAPI.h>
911
1012 #ifdef _DEBUG
1113 #define new DEBUG_NEW
@@ -196,14 +198,9 @@ bool SendAck(HANDLE pipe)
196198
197199 DWORD WINAPI CMainFrame::PollMessage(LPVOID)
198200 {
199- HANDLE pipe = CreateNamedPipe(PipeName(PIPENAME_IPC32).GetName(), PIPE_ACCESS_DUPLEX, PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE, 1,
200- sizeof(DWORD), sizeof(IPC32Message), 0, NULL);
201- if (pipe == INVALID_HANDLE_VALUE) {
202-#ifdef DEBUG_IPC
203- CUtils::Log(_T("PollMessage: CreateNamedPipe failed. (%d)"), GetLastError());
204-#endif
201+ HANDLE pipe = CreateNamedPipeWithLowIntegrityAccess();
202+ if (pipe == INVALID_HANDLE_VALUE)
205203 return 1;
206- }
207204 for (; ;) {
208205 if (ConnectNamedPipe(pipe, NULL) ? FALSE : (GetLastError() != ERROR_PIPE_CONNECTED)) {
209206 #ifdef DEBUG_IPC
@@ -246,6 +243,31 @@ exit:
246243 return 0;
247244 }
248245
246+HANDLE CMainFrame::CreateNamedPipeWithLowIntegrityAccess()
247+{
248+ LPCTSTR LOW_INTEGRITY_SDDL_SACL = _T("S:(ML;;NW;;;LW)");
249+ PSECURITY_DESCRIPTOR sd;
250+ if (!ConvertStringSecurityDescriptorToSecurityDescriptor(LOW_INTEGRITY_SDDL_SACL, SDDL_REVISION_1, &sd, nullptr)) {
251+#ifdef DEBUG_IPC
252+ CUtils::Log(_T("ConvertStringSecurityDescriptorToSecurityDescriptor failed. (%d)"), GetLastError());
253+#endif
254+ return INVALID_HANDLE_VALUE;
255+ }
256+ SECURITY_ATTRIBUTES sa;
257+ sa.nLength = sizeof(SECURITY_ATTRIBUTES);
258+ sa.lpSecurityDescriptor = sd;
259+ sa.bInheritHandle = false;
260+ HANDLE pipe = CreateNamedPipe(PipeName(PIPENAME_IPC32).GetName(), PIPE_ACCESS_DUPLEX, PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE, 1,
261+ sizeof(DWORD), sizeof(IPC32Message), 0, &sa);
262+ if (pipe == INVALID_HANDLE_VALUE) {
263+#ifdef DEBUG_IPC
264+ CUtils::Log(_T("CreateNamedPipeWithLowIntegrityAccess failed. (%d)"), GetLastError());
265+#endif
266+ }
267+ LocalFree(sd);
268+ return pipe;
269+}
270+
249271 void CMainFrame::SetIconData(ICON_TYPE icon, int tip, int on, int off, int reg)
250272 {
251273 m_hIcon[icon][ON_ICON] = AfxGetApp()->LoadIcon(on);
--- a/xkeymacs/mainfrm.h
+++ b/xkeymacs/mainfrm.h
@@ -105,6 +105,7 @@ private:
105105 void StartPollThread();
106106 void TerminatePollThread();
107107 static DWORD WINAPI PollMessage(LPVOID lpParam);
108+ static HANDLE CreateNamedPipeWithLowIntegrityAccess();
108109 public:
109110 void EnableShell_NotifyIcon(ICON_TYPE icon, BOOL bEnable);
110111 };
旧リポジトリブラウザで表示