Skip to content

Commit ac1f08a

Browse files
committed
bug fix
1 parent d770087 commit ac1f08a

File tree

3 files changed

+23
-16
lines changed

3 files changed

+23
-16
lines changed

Sources/SmartTaskbar.Win10.Hook/InjectionEntryPoint.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,11 @@ public class InjectionEntryPoint : IEntryPoint
1111

1212
public InjectionEntryPoint(RemoteHooking.IContext context,
1313
string channelName)
14-
{
15-
_server = RemoteHooking.IpcConnectClient<ServerInterface>(channelName);
16-
_server.Ping();
17-
}
14+
=> _server = RemoteHooking.IpcConnectClient<ServerInterface>(channelName);
1815

1916
public void Run(RemoteHooking.IContext context,
2017
string channelName)
2118
{
22-
_server.Ping();
2319
var postMessageHook = LocalHook.Create(
2420
LocalHook.GetProcAddress("user32.dll", "PostMessageW"),
2521
new PostMessageDelegate(PostMessageHook),

Sources/SmartTaskbar.Win10/Helpers/HookHelper.cs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Diagnostics;
23
using System.IO;
34
using System.Reflection;
45
using System.Runtime.Remoting;
@@ -41,13 +42,23 @@ public static void SetHook()
4142
if (_targetPid == 0)
4243
return;
4344

44-
_channel = RemoteHooking.IpcCreateServer<ServerInterface>(ref _channelName, WellKnownObjectMode.Singleton);
45+
try
46+
{
47+
_channel = RemoteHooking.IpcCreateServer<ServerInterface>(
48+
ref _channelName,
49+
WellKnownObjectMode.Singleton);
4550

46-
RemoteHooking.Inject(
47-
_targetPid,
48-
InjectionLibrary,
49-
InjectionLibrary,
50-
_channelName);
51+
RemoteHooking.Inject(
52+
_targetPid,
53+
InjectionLibrary,
54+
InjectionLibrary,
55+
_channelName);
56+
}
57+
catch (Exception e)
58+
{
59+
ReleaseHook();
60+
Debug.WriteLine(e.Message);
61+
}
5162
}
5263
}
5364
}

Sources/SmartTaskbar.Win10/Worker/TaskbarHelper.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -371,15 +371,15 @@ private static IntPtr GetWindowIntPtr(in TaskbarInfo taskbar)
371371
switch (taskbar.Position)
372372
{
373373
case TaskbarPosition.Bottom:
374-
return WindowFromPoint(new TagPoint {x = taskbar.Rect.left, y = taskbar.Rect.top});
374+
return WindowFromPoint(new TagPoint {x = taskbar.Rect.left + 4, y = taskbar.Rect.top});
375375
case TaskbarPosition.Left:
376-
return WindowFromPoint(new TagPoint {x = taskbar.Rect.right, y = taskbar.Rect.top});
376+
return WindowFromPoint(new TagPoint {x = taskbar.Rect.right, y = taskbar.Rect.top + 4});
377377
case TaskbarPosition.Right:
378-
return WindowFromPoint(new TagPoint {x = taskbar.Rect.left, y = taskbar.Rect.top});
378+
return WindowFromPoint(new TagPoint {x = taskbar.Rect.left, y = taskbar.Rect.top + 4});
379379
case TaskbarPosition.Top:
380-
return WindowFromPoint(new TagPoint {x = taskbar.Rect.left, y = taskbar.Rect.bottom});
380+
return WindowFromPoint(new TagPoint {x = taskbar.Rect.left + 4, y = taskbar.Rect.bottom});
381381
default:
382-
return WindowFromPoint(new TagPoint {x = taskbar.Rect.left, y = taskbar.Rect.top});
382+
return WindowFromPoint(new TagPoint {x = taskbar.Rect.left + 4, y = taskbar.Rect.top});
383383
}
384384
}
385385

0 commit comments

Comments
 (0)