HB_BOOL hb_isWSeB( void ) { static int s_iWSeB = -1; if( s_iWSeB < 0 ) { APIRET ret; HMODULE hModule; /* what is the suggested form? [druzus] */ #if 1 ret = DosQueryModuleHandle( ( PCSZ ) "DOSCALLS", &hModule ); #else ret = DosLoadModule( NULL, 0, ( PCSZ ) "DOSCALL1", &hModule ); #endif if( ret == NO_ERROR ) ret = DosQueryProcAddr( hModule, 981, NULL, ( PFN * ) &s_DosOpenL ); if( ret == NO_ERROR ) ret = DosQueryProcAddr( hModule, 986, NULL, ( PFN * ) &s_DosSetFileLocksL ); if( ret == NO_ERROR ) ret = DosQueryProcAddr( hModule, 988, NULL, ( PFN * ) &s_DosSetFilePtrL ); if( ret == NO_ERROR ) ret = DosQueryProcAddr( hModule, 989, NULL, ( PFN * ) &s_DosSetFileSizeL ); s_iWSeB = ret == NO_ERROR; } return s_iWSeB; }
BOOL EXPENTRY installHook( HAB habAB, PHOOKDATA phd ) { if( DosQueryModuleHandle( DLL_NAME, &hm ) != 0 ) return FALSE; IM32Init(); hab = habAB; WinSetHook( hab, NULLHANDLE, HK_INPUT, ( PFN )inputHook, hm ); WinSetHook( hab, NULLHANDLE, HK_ACCEL, ( PFN )accelHook, hm ); WinSetHook( hab, NULLHANDLE, HK_SENDMSG, ( PFN )sendMsgHook, hm ); WinSetHook( hab, NULLHANDLE, HK_DESTROYWINDOW, (PFN)destroyWindowHook, hm ); hwndKime = phd->hwndKime; hwndHIA = phd->hwndHIA; hwndIB = phd->hwndIB; hwndKHS = phd->hwndKHS; hwndCurrentInput = NULLHANDLE; oldKimeWndProc = WinSubclassWindow( hwndKime, newKimeWndProc ); WinSendMsg( hwndHIA, HIAM_SETHANJAKEYCHECKPROC, MPFROMP( isHanjaKey ), 0 ); WinSendMsg( hwndHIA, HIAM_SETSPECIALCHARKEYCHECKPROC, MPFROMP( isSpecialCharKey ), 0 ); return TRUE; }
SOM_Scope HMODULE SOMLINK srcM_clsQueryModuleHandle(M_SrcTransient *somSelf) { PSZ pszPathName; APIRET rc; /* M_SrcTransientData *somThis = M_SrcTransientGetData(somSelf); */ M_SrcTransientMethodDebug("M_SrcTransient","srcM_clsQueryModuleHandle"); if (hmod == NULLHANDLE) { /* * Retrieve registered pathname of our module (DLL) and query the * module handle. */ pszPathName = (SOMClassMgrObject->somLocateClassFile( SOM_IdFromString("SrcTransient"), 0, 0)); rc = DosQueryModuleHandle( pszPathName, &hmod); if (rc) { return 0L; } } /* end if (hmod == NULLHANDLE) */ return (hmod); }
/* * Initialize 64bit file access: dynamic load of WSeB API */ File64bit :: File64bit() { HMODULE hDoscalls; if (DosQueryModuleHandle("DOSCALLS", &hDoscalls) != NO_ERROR) return; if (DosQueryProcAddr(hDoscalls, 981, NULL, (PFN *)&_DosOpenL) != NO_ERROR) return; if (DosQueryProcAddr(hDoscalls, 988, NULL, (PFN *)&_DosSetFilePtrL) != NO_ERROR) { _DosOpenL = NULL; return; } if (DosQueryProcAddr(hDoscalls, 986, NULL, (PFN *)&_DosSetFileLocksL) != NO_ERROR) { _DosOpenL = NULL; _DosSetFilePtrL = NULL; return; } /* notify success */ #ifdef MYSQL_SERVER printf( "WSeB 64bit file API loaded.\n"); #endif }
BOOL EXPENTRY installHook( HAB habAB ) { if( DosQueryModuleHandle( DLL_NAME, &hm ) != 0 ) return FALSE; hab = habAB; WinSetHook( hab, NULLHANDLE, HK_SENDMSG, ( PFN)sendMsgHook, hm ); return TRUE; }
/* * This function returns the module handle of our class-dll */ HMODULE QueryModuleHandle(string class_name) { static HMODULE hmod=0; if(!hmod) { PSZ pathname=_somLocateClassFile(SOMClassMgrObject, somIdFromString(class_name),1,2); DosQueryModuleHandle(pathname,&hmod); //Query module handle } return hmod; }
/* This function returns the module handle of our class-dll */ HMODULE queryModuleHandle(void) { static HMODULE hmod=0; if(!hmod) { PSZ pathname= //Query Pathname of class file _wpModuleForClass(SOMClassMgrObject,"CandyFolder"); DosQueryModuleHandle(pathname,&hmod); } return hmod; }
bool XIOfile64::supported() { if (!checked64) { HMODULE hmod; if ( DosQueryModuleHandle("DOSCALLS", &hmod) == NO_ERROR && DosQueryProcAddr(hmod, 981, NULL, (PFN*)&pOpen) == NO_ERROR && DosQueryProcAddr(hmod, 988, NULL, (PFN*)&pSetFilePtr) == NO_ERROR && DosQueryProcAddr(hmod, 989, NULL, (PFN*)&pSetFileSize) == NO_ERROR ) support64 = true; checked64 = true; } return support64; }
BOOL EXPENTRY HookInit(void) { if (!loaded) { /* find desktop anchor */ mainhab = WinQueryAnchorBlock(HWND_DESKTOP); /* setting hook */ if(DosQueryModuleHandle("numcomma", &hmDll)) return FALSE; return WinSetHook(mainhab, NULLHANDLE, HK_INPUT, (PFN)WinHookProc, hmDll); } return FALSE; }
SOM_Scope HMODULE SOMLINK WPSamFM_clsQueryModuleHandle (M_WPSamF *somSelf) { /* M_WPSamFData *somThis = M_WPSamFGetData (somSelf); */ M_WPSamFMethodDebug ("M_WPSamF","WPSamFM_clsQueryModuleHandle"); if(!hevPrfResetLock) if(DosOpenEventSem (HEV_PRFRESETLOCK, &hevPrfResetLock)) if(DosCreateEventSem(HEV_PRFRESETLOCK, // Name &hevPrfResetLock, // Pointer to sem 0, // Not used with named sems TRUE)) // Initial state (TRUE = POSTED) hevPrfResetLock = 0; if(!pShareInitOS2) if (DosGetNamedSharedMem ((PPVOID) &pShareInitOS2, SHARE_INITOS2, PAG_READ | PAG_WRITE)) pShareInitOS2 = 0; if(!hevSammy) if (DosOpenEventSem (HEV_SAMMY, &hevSammy)) hevSammy = 0; if (hmod == NULLHANDLE) { zString zsPathName; /* * Retrieve registered pathname of our module (DLL) and query the * module handle. */ zsPathName = _somLocateClassFile (SOMClassMgrObject, SOM_IdFromString (CLASSNAME), WPSamF_MajorVersion, WPSamF_MinorVersion); if (DosQueryModuleHandle (zsPathName, &hmod)) { DebugE (D_SOM, "_clsQueryModuleHandle", "Failed to load module"); hmod = NULLHANDLE; } } /* end if (hmod == NULLHANDLE) */ DebugULd (D_SOM, "_clsQueryModuleHandle", "hmod", hmod); return (hmod); }
void DlgCmd( void ) { char buff[256]; printf( "DBG>" ); fflush( stdout ); // not really necessary gets( buff ); if( buff[0] != NULLCHAR && buff[1] == NULLCHAR ) { switch( tolower( buff[0] ) ) { case 'u': WndAsmInspect( GetCodeDot() ); break; case 's': DumpSource(); break; case 'l': DumpLocals(); break; case 'i': RunRequest( REQ_TRACE_INTO ); break; case 'o': RunRequest( REQ_TRACE_OVER ); break; case 'g': RunRequest( REQ_GO ); break; case 'x': if( _IsOn( SW_REMOTE_LINK ) ) { printf( "Can't break remote task!\n" ); } else { HMODULE hmod; PFN proc = NULL; DosQueryModuleHandle( TrapParms, &hmod ); DosQueryProcAddr( hmod, 5, 0, &proc ); // if( proc != NULL ) // proc(); } // break the task break; default: printf( "Error - unrecognized command\n" ); } } else { DoCmd( DupStr( buff ) ); DoInput(); } }
void log_init(void) { long __syscall (*pfn)(void); APIRET rc; HMODULE handle; /* now check if DosLogWrite is available */ rc = DosQueryModuleHandle("DOSCALLS", &handle); if (rc) return; rc = DosQueryProcAddr(handle, LOG_ORD, 0, &pfn); if (rc != 182) // ERROR_INVALID_ORDINAL DosLogWrite = (logwrt_t)pfn; }
NS_IMETHODIMP nsScreenOS2 :: GetAvailRect(PRInt32 *outLeft, PRInt32 *outTop, PRInt32 *outWidth, PRInt32 *outHeight) { static APIRET rc = 0; static BOOL (APIENTRY * pfnQueryDesktopWorkArea)(HWND hwndDesktop, PWRECT pwrcWorkArea) = NULL; GetRect(outLeft, outTop, outWidth, outHeight); // This height is different based on whether or not // "Show on top of maximed windows" is checked LONG lWorkAreaHeight = *outHeight; if ( !rc && !pfnQueryDesktopWorkArea ) { HMODULE hmod = 0; rc = DosQueryModuleHandle( "PMMERGE", &hmod ); if ( !rc ) { rc = DosQueryProcAddr( hmod, 5469, NULL, (PFN*) &pfnQueryDesktopWorkArea ); // WinQueryDesktopWorkArea } } if ( pfnQueryDesktopWorkArea && !rc ) { RECTL rectl; pfnQueryDesktopWorkArea( HWND_DESKTOP, &rectl ); lWorkAreaHeight = rectl.yTop - rectl.yBottom; } HWND hwndWarpCenter = WinWindowFromID( HWND_DESKTOP, 0x555 ); if (hwndWarpCenter) { /* If "Show on top of maximized windows is checked" */ if (lWorkAreaHeight != *outHeight) { SWP swp; WinQueryWindowPos( hwndWarpCenter, &swp ); if (swp.y != 0) { /* WarpCenter is at the top */ *outTop += swp.cy; } *outHeight -= swp.cy; } } return NS_OK; } // GetAvailRect
BOOL EXPENTRY PGPDLLInit(HWND hwnd) { hwndPGPClient = hwnd; /* save client hwnd so we can post msgs to it */ if (!Hooked) { /* create unique message ids (can't use WM_USER in hooks) */ hAtomTblSystem = WinQuerySystemAtomTable(); srand((UINT)hwnd); sprintf(Global.szFloatToTop,"PGPToolsFloatToTop%d",rand()); Global.wmu_FloatToTop = WinAddAtom(hAtomTblSystem, Global.szFloatToTop); if(DosQueryModuleHandle("pgptools", &hRessourceModule)) return FALSE; hab = WinQueryAnchorBlock(hwnd); WinSetHook(hab, hmqType, HK_SENDMSG, (PFN)PGPHookSendMsg, hRessourceModule); Hooked = TRUE; } return TRUE; }
int init_pm(void) { PPIB pib; PTIB tib; APIRET rc; HMODULE hMte = 0; char loadErr[256]; if(hab || hmq) return 0; rc = DosGetInfoBlocks(&tib, &pib); rc = DosQueryModuleHandle("PMWIN", &hMte); if(rc) return 1; pib->pib_ultype = 3; rc = DosLoadModule(loadErr, sizeof(loadErr), "PMWIN", &hMte); if(rc) return 1; rc = DosQueryProcAddr(hMte, 707, 0, (PFN*)&_inCloseClipbrd); rc = DosQueryProcAddr(hMte, 716, 0, (PFN*)&_inCreateMsgQueue); rc = DosQueryProcAddr(hMte, 726, 0, (PFN*)&_inDestroyMsgQueue); rc = DosQueryProcAddr(hMte, 733, 0, (PFN*)&_inEmptyClipbrd); rc = DosQueryProcAddr(hMte, 763, 0, (PFN*)&_inInitialize); rc = DosQueryProcAddr(hMte, 793, 0, (PFN*)&_inOpenClipbrd); rc = DosQueryProcAddr(hMte, 806, 0, (PFN*)&_inQueryClipbrdData); rc = DosQueryProcAddr(hMte, 807, 0, (PFN*)&_inQueryClipbrdFmtInfo); rc = DosQueryProcAddr(hMte, 854, 0, (PFN*)&_inSetClipbrdData); rc = DosQueryProcAddr(hMte, 888, 0, (PFN*)&_inTerminate); hab = _inInitialize(0); hmq = _inCreateMsgQueue(hab, 0); return 0; }
SOM_Scope ULONG SOMLINK xsrvM_wpclsQueryIconData(M_XWPNetServer *somSelf, PICONINFO pIconInfo) { /* M_XWPNetServerData *somThis = M_XWPNetServerGetData(somSelf); */ M_XWPNetServerMethodDebug("M_XWPNetServer","xsrvM_wpclsQueryIconData"); if (pIconInfo) { if (!DosQueryModuleHandle("PMWP", &pIconInfo->hmod)) { pIconInfo->fFormat = ICON_RESOURCE; pIconInfo->resid = 63; // active server icon // 67; // inactive server icon // pIconInfo->hmod = cmnQueryMainResModuleHandle(); } else return (M_XWPNetServer_parent_M_WPTransient_wpclsQueryIconData(somSelf, pIconInfo)); } return sizeof(ICONINFO); }
void main(int argc,char**argv) { QMSG qmsg; /* Message from message queue */ ULONG flCreate; /* Window creation control flags*/ APIRET rc; flCreate = FCF_SYSMENU | FCF_SIZEBORDER | FCF_TITLEBAR | FCF_MINMAX | FCF_TASKLIST ; hab = WinInitialize(0); /* Initialize PM */ hmq = WinCreateMsgQueue( hab, 0 ); /* Create a message queue */ SetSpy(0,0,0,0,0); rc=DosQueryModuleHandle("TRAPITH",&hModule); if (rc) { WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, "Could not Find DLL", "TRAPIT", 1234, MB_OK | MB_ERROR); } /* endif */ WinSetHook( hab, NULLHANDLE, HK_SENDMSG, (PFN)HandleSend, hModule); WinRegisterClass( /* Register window class */ hab, /* Anchor block handle */ "MyWindow", /* Window class name */ MyWindowProc, /* Address of window procedure */ CS_SIZEREDRAW, /* No special class style */ 4 /* 1 extra window double word */ ); hwndFrame = WinCreateStdWindow( HWND_DESKTOP, /* Desktop window is parent */ 0L, /* No class style */ &flCreate, /* Frame control flag */ "MyWindow", /* Client window class name */ "TRAPIT PM", /* No window text */ 0, /* No special class style */ 0, /* Resource is in .EXE file */ ID_WINDOW, /* Frame window identifier */ &hwndClient /* Client window handle */ ); if (hwndFrame!=0) { ULONG Flags=SWP_SIZE | SWP_MOVE | SWP_ACTIVATE | SWP_SHOW; if (argc>1) { if (stricmp(argv[1],"HIDE")==0) { Flags &=~(SWP_ACTIVATE | SWP_SHOW); } /* endif */ } /* endif */ WinSetWindowPos( hwndFrame, /* Set the size and position of */ HWND_TOP, /* the window before showing. */ 100, 50, 270, 230, Flags ); /************************************************************************/ /* Get and dispatch messages from the application message queue */ /* until WinGetMsg returns FALSE, indicating a WM_QUIT message. */ /************************************************************************/ while( WinGetMsg( hab, &qmsg, 0, 0, 0 ) ) WinDispatchMsg( hab, &qmsg ); } WinDestroyWindow( hwndFrame ); /* Tidy up... */ WinDestroyMsgQueue( hmq ); /* and */ WinReleaseHook( hab, NULLHANDLE, HK_SENDMSG, (PFN)HandleSend, hModule); WinTerminate( hab ); /* terminate the application */ DosExit(EXIT_PROCESS,0); }