32 |
|
|
33 |
#define DLL_EXPORT __declspec(dllexport) |
#define DLL_EXPORT __declspec(dllexport) |
34 |
|
|
35 |
|
#ifdef __GNUC__ |
36 |
|
#define SHARED __attribute__((section ("SHAREDDATA"), shared)) |
37 |
|
#else |
38 |
|
#define SHARED |
39 |
|
#endif |
40 |
|
|
41 |
// Shared DATA |
// Shared DATA |
42 |
#pragma data_seg ( "SHAREDDATA" ) |
#pragma data_seg ( "SHAREDDATA" ) |
43 |
|
|
44 |
// this is the total number of processes this dll is currently attached to |
// this is the total number of processes this dll is currently attached to |
45 |
int g_instance_count = 0; |
int g_instance_count SHARED = 0; |
46 |
|
|
47 |
|
// blocks for locally generated events |
48 |
|
RECT g_block_move SHARED = { 0, 0, 0, 0 }; |
49 |
|
|
50 |
#pragma data_seg () |
#pragma data_seg () |
51 |
|
|
62 |
static void |
static void |
63 |
update_position(HWND hwnd) |
update_position(HWND hwnd) |
64 |
{ |
{ |
65 |
RECT rect; |
RECT rect, blocked; |
66 |
|
|
67 |
if (!GetWindowRect(hwnd, &rect)) |
if (!GetWindowRect(hwnd, &rect)) |
68 |
{ |
{ |
70 |
return; |
return; |
71 |
} |
} |
72 |
|
|
73 |
|
WaitForSingleObject(g_mutex, INFINITE); |
74 |
|
memcpy(&blocked, &g_block_move, sizeof(RECT)); |
75 |
|
ReleaseMutex(g_mutex); |
76 |
|
|
77 |
|
if ((rect.left == blocked.left) && (rect.top == blocked.top) |
78 |
|
&& (rect.right == blocked.right) && (rect.bottom == blocked.bottom)) |
79 |
|
return; |
80 |
|
|
81 |
vchannel_write("POSITION,0x%p,%d,%d,%d,%d,0x%x", |
vchannel_write("POSITION,0x%p,%d,%d,%d,%d,0x%x", |
82 |
hwnd, |
hwnd, |
83 |
rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, 0); |
rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, 0); |
307 |
UnhookWindowsHookEx(g_wndprocret_hook); |
UnhookWindowsHookEx(g_wndprocret_hook); |
308 |
} |
} |
309 |
|
|
310 |
|
DLL_EXPORT void |
311 |
|
SafeMoveWindow(HWND hwnd, int x, int y, int width, int height) |
312 |
|
{ |
313 |
|
WaitForSingleObject(g_mutex, INFINITE); |
314 |
|
g_block_move.left = x; |
315 |
|
g_block_move.top = y; |
316 |
|
g_block_move.right = x + width; |
317 |
|
g_block_move.bottom = y + height; |
318 |
|
ReleaseMutex(g_mutex); |
319 |
|
|
320 |
|
SetWindowPos(hwnd, NULL, x, y, width, height, SWP_NOACTIVATE | SWP_NOZORDER); |
321 |
|
|
322 |
|
WaitForSingleObject(g_mutex, INFINITE); |
323 |
|
memset(&g_block_move, 0, sizeof(RECT)); |
324 |
|
ReleaseMutex(g_mutex); |
325 |
|
} |
326 |
|
|
327 |
DLL_EXPORT int |
DLL_EXPORT int |
328 |
GetInstanceCount() |
GetInstanceCount() |
329 |
{ |
{ |