Changeset 2764
- Timestamp:
- Aug 13, 2006, 10:58:34 PM (19 years ago)
- Location:
- trunk/synergy
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/synergy/Makefile.kmk
r2763 r2764 187 187 188 188 PROGRAMS = \ 189 synergys \ 190 synergyc\189 synergyc 190 # synergys \ 191 191 192 192 synergyc_SOURCES = \ -
trunk/synergy/lib/platform/CPMScreen.cpp
r2763 r2764 691 691 } 692 692 693 HMODULE 694 CPMScreen::openHookLibrary(const char* name) 695 { 696 // load the hook library - try with qualified name first. 697 HMODULE hmod = NULLHANDLE; 698 APIRET rc = ERROR_FILE_NOT_FOUND; 699 char szFullName[CCHMAXPATH + 10]; 700 if (!_execname(szFullName, CCHMAXPATH)) { 701 char *psz = strrchr(szFullName, '\\'); 693 /** 694 * Gets the path to the directory with the executable. 695 * Has trailing slash. 696 * 697 * @returns pszBuf. 698 * @returns NULL on buffer overflow. 699 * @param pszBuf Where to store the path. 700 * @param cchBuf The buffer size. 701 */ 702 static char * 703 getExecDir(char *pszBuf, size_t cchBuf) 704 { 705 char *psz = NULL; 706 if (!_execname(pszBuf,cchBuf)) { 707 char *psz = strrchr(pszBuf, '\\'); 702 708 if (!psz || strrchr(psz, '/')) { 703 709 psz = strrchr(psz, '/'); 704 710 } 705 711 if (psz) { 706 strcat(strcpy(psz + 1, name), ".DLL"); 712 psz[1] = '\0'; 713 return pszBuf; 707 714 } 708 rc = DosLoadModule(NULL, 0, (PCSZ)szFullName, &hmod);709 715 } 710 711 // if that failed, try with the bare name. 712 if (rc != NO_ERROR) { 713 rc = DosLoadModule(NULL, 0, (PCSZ)name, &hmod); 714 } else { 715 name = szFullName; 716 return NULL; 717 } 718 719 HMODULE 720 CPMScreen::openHookLibrary(const char* name) 721 { 722 // 723 // Load the hook dll as a global DLL. 724 // 725 // The kernel/PM will fuck up if it's loaded with a path (i.e. non global). 726 // What happend was that the DLL wasn't actually loaded into the other 727 // processes for some stupid reason, leading to nasty crashes and even 728 // weirder behaviour. 729 // 730 char szPath[CCHMAXPATH + 10]; 731 char szCwd[CCHMAXPATH]; 732 if ( getcwd(szCwd, sizeof(szCwd)) == NULL 733 || getExecDir(szPath, sizeof(szPath)) == NULL 734 || chdir(szPath) != 0) { 735 LOG((CLOG_ERR "can't get cwd or exec dir or failed to change path to the exec dir!")); 736 throw XScreenOpenFailure(); 716 737 } 738 HMODULE hmod; 739 APIRET rc = DosLoadModule(NULL, 0, (PCSZ)name, &hmod); 740 chdir(szCwd); 717 741 if (rc != NO_ERROR) { 718 742 LOG((CLOG_ERR "Failed to load hook library (%s), rc=%d ", name, rc)); … … 720 744 } 721 745 722 // look upfunctions746 // resolve the functions 723 747 if ( (rc = DosQueryProcAddr(hmod, 0, (PCSZ)"_fakeMsg", (PPFN)&m_fakeMsg )) != NO_ERROR 724 748 || (rc = DosQueryProcAddr(hmod, 0, (PCSZ)"_setSides", (PPFN)&m_setSides)) != NO_ERROR -
trunk/synergy/lib/platform/CPMSynergyHook.cpp
r2763 r2764 92 92 /** Error description. */ 93 93 const char *g_pszErrorMsg; 94 /** Set if the dummy hook is installed. */95 bool g_fDummyHook;96 94 /** @} */ 97 95 … … 288 286 289 287 290 #define NO_DUMMY_HOOK 1291 #ifndef NO_DUMMY_HOOK292 /**293 * Dummy hook.294 */295 static VOID EXPENTRY SendMsgHook(HAB hab, PSMHSTRUCT psmh, BOOL fInterTask)296 {297 /* nop */298 }299 #endif300 301 302 303 288 // 304 289 // external functions … … 382 367 } 383 368 384 #ifndef NO_DUMMY_HOOK385 /*386 * Install the fake hook.387 */388 if (g_fDummyHook)389 WinReleaseHook(WinQueryAnchorBlock(HWND_DESKTOP), NULLHANDLE, HK_SENDMSG, (PFN)SendMsgHook, g_hmod);390 g_fDummyHook = WinSetHook(WinQueryAnchorBlock(HWND_DESKTOP), NULLHANDLE, HK_SENDMSG, (PFN)SendMsgHook, g_hmod);391 if (!g_fDummyHook) {392 return false;393 }394 #endif395 396 369 g_fSynergyInitialized = true; 397 370 return true; … … 420 393 /* parnaoia */ 421 394 uninstall(hab); 422 423 #ifndef NO_DUMMY_HOOK424 // release the dummy hook.425 if (WinReleaseHook(hab, NULLHANDLE, HK_SENDMSG, (PFN)SendMsgHook, g_hmod))426 g_fDummyHook = false;427 #endif428 395 429 396 g_hmqSynergy = NULLHANDLE; … … 564 531 565 532 533 // 534 // Message faking. 535 // 536 566 537 /** 567 538 * Hook callback used to insert message into the system queue. … … 579 550 static BOOL EXPENTRY MsgInputHook(HAB hab, PQMSG pqmsg, BOOL fSkip, PBOOL pfNoRecord) 580 551 { 581 /*582 * FUCKING HELL!583 *584 * For whatever fucking reason, PM fails to load the hook dll into585 * a bunch of processes. We still get here for some peculiar reasons,586 * and thus we can try deal with it...587 */588 BOOL fUnload = FALSE;589 HMODULE hmod;590 ULONG offObj, iObj;591 APIRET rc = DosQueryModFromEIP(&hmod, &iObj, 0, NULL, &offObj, (ULONG)&MsgInputHook);592 if (rc != NO_ERROR) {593 if (DosLoadModule(NULL, 0, (PCSZ)"d:/coding/libc/trunk/out/os2.x86/debug/dist/bin/synrgyhk.dll", &hmod)) {594 return FALSE;595 }596 fUnload = TRUE;597 }598 599 552 /* 600 553 * We've only got one message, so everything is dead simple. … … 616 569 } 617 570 618 /*619 * If we loaded the dll we must unload it.620 * Don't wanna have any DLLs stuck in foreign processes.621 */622 if (fUnload)623 DosFreeModule(hmod);624 571 return TRUE; 625 572 }
Note:
See TracChangeset
for help on using the changeset viewer.