SOM_Scope void   SOMLINK vptextc_somInitClass(M_VPText *somSelf,
                IN zString className,
                IN SOMAny *parentClass,
                IN integer4 instanceSize,
                IN int maxStaticMethods,
                IN integer4 majorVersion,
                IN integer4 minorVersion)
{
    M_VPTextData *somThis = M_VPTextGetData(somSelf);
    CHAR ErrorBuffer[100];
    M_VPTextMethodDebug("M_VPText","vptextc_somInitClass");

    DosLoadModule((PSZ) ErrorBuffer, sizeof(ErrorBuffer), "VPText",
                  &_hModResource);
    WinRegisterClass(                     /* Register window class        */
         0,                             /* Anchor block handle          */
         szClass,                       /* Window class name            */
         TestWndProc,              /* Address of window procedure  */
         0,                               /* Class style                  */
         12                                /* No extra window words        */
         );

    parent_somInitClass(somSelf,className,parentClass,instanceSize,
                        maxStaticMethods,majorVersion,minorVersion);
}
void        DrvMountDrivesThread( void * hev)

{
    ULONG       rc;
    HMODULE     hmod = 0;
    pRediscover_PRMs    pfn = 0;
    char *      pErr = 0;
    char        szErr[16];

    rc = DosLoadModule( szErr, sizeof(szErr), "LVM", &hmod);
    if (rc)
        pErr = "DosLoadModule";
    else {
        rc = DosQueryProcAddr( hmod, 0, "Rediscover_PRMs", (PFN*)&pfn);
        if (rc)
            pErr = "DosQueryProcAddr";
        else {
            pfn( &rc);
            if (rc)
                pErr = "Rediscover_PRMs";
        }
        rc = DosFreeModule( hmod);
        if (rc && !pErr)
            pErr = "DosFreeModule";
    }

    if (pErr)
        printf( "DrvMountDrivesThread - %s - rc= %lx\n", pErr, rc);

    rc = DosPostEventSem( (HEV)hev);
    if (rc)
        printf( "DrvMountDrivesThread - DosPostEventSem - rc= %lx\n", rc);

    return;
}
Exemple #3
0
/****************************************************************************
REMARKS:
This function returns a pointer to the common graphics driver loaded in the
helper VxD. The memory for the VxD is shared between all processes via
the VxD, so that the VxD, 16-bit code and 32-bit code all see the same
state when accessing the graphics binary portable driver.
****************************************************************************/
GA_sharedInfo * NAPI GA_getSharedInfo(
    int device)
{
    /* Initialise the PM library and connect to our runtime DLL's */
    PM_init();

    /* Open our helper device driver */
    if (DosOpen(PMHELP_NAME,&hSDDHelp,&result,0,0,
	    FILE_OPEN, OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE,
	    NULL))
	PM_fatalError("Unable to open SDDHELP$ helper device driver!");
    outLen = sizeof(result);
    DosDevIOCtl(hSDDHelp,PMHELP_IOCTL,PMHELP_GETSHAREDINFO,
	NULL, 0, NULL,
	&result, outLen, &outLen);
    DosClose(hSDDHelp);
    if (result) {
	/* We have found the shared Nucleus packet. Because not all processes
	 * map to SDDPMI.DLL, we need to ensure that we connect to this
	 * DLL so that it gets mapped into our address space (that is
	 * where the shared Nucleus packet is located). Simply doing a
	 * DosLoadModule on it is enough for this.
	 */
	HMODULE hModSDDPMI;
	char    buf[80];
	DosLoadModule((PSZ)buf,sizeof(buf),(PSZ)"SDDPMI.DLL",&hModSDDPMI);
	}
    return (GA_sharedInfo*)result;
}
Exemple #4
0
/* *************************************************************** */
void _catcher(bundle s)
{
    char    msg[512];
    char   *b[4];
    HMODULE hmod;
    PFNWP   DlgProc;
    int  c  = 0,
         bx = 0;

    if (msgHead != NULL) {
      for (msg[0] = '\0'; *msgHead != NULL; ++msgHead) strcat(msg,*msgHead);
      b[bx++] = msg;
      c = strlen(msg) + 1;
    }
    for (msg[c] = '\0'; *s != NULL; ++s) strcat(&msg[c],*s);
    b[bx++] = &msg[c];
    b[bx++] = "Application will terminate now";
    b[bx]   = NULL;

    if (DosLoadModule(NULL, 0, "GPRTS", &hmod) ||
        DosQueryProcAddr(hmod, 0, "DlgProc", (PFN *)&DlgProc))
      WinMessageBox(HWND_DESKTOP, HWND_DESKTOP,
                    "Unable to load error message","GPM Fatal Error",
                    0, MB_ICONHAND | MB_OK);
    else {
      WinAlarm(HWND_DESKTOP, WA_ERROR);
      WinDlgBox(HWND_DESKTOP, HWND_DESKTOP, DlgProc, hmod, GPRTS_DLG, b);
      DosFreeModule(hmod);
    }
    DosExit(EXIT_PROCESS, 0);
}
Exemple #5
0
/*
** Interfaces for opening a shared library, finding entry points
** within the shared library, and closing the shared library.
*/
static void *os2DlOpen(sqlite3_vfs *pVfs, const char *zFilename){
  UCHAR loadErr[256];
  HMODULE hmod;
  APIRET rc;
  rc = DosLoadModule((PSZ)loadErr, sizeof(loadErr), zFilename, &hmod);
  return rc != NO_ERROR ? 0 : (void*)hmod;
}
Exemple #6
0
APIRET LoadModule(PSZ pszModuleName,
                  PHMODULE phModule)
{
  APIRET rc;                                        /* operation return code */
  char pszBuffer[512];              /* module name buffer in case of failure */
  HMODULE hModule;                   /* load result buffer for module handle */

  if (NULL == phModule)                 /* check if module handle is desired */
    phModule = &hModule;       /* point to local buffer, forget after return */

  pszBuffer[0] = 0;              /* prevent previous results from disturbing */
  rc = DosLoadModule(pszBuffer,
                     sizeof(pszBuffer),
                     pszModuleName,
                     phModule);
  if (rc != NO_ERROR)
  {
    if (pszBuffer[0] != 0)
      ToolsErrorDosEx(rc,                           /* display error message */
                      pszBuffer);
    else
      ToolsErrorDos(rc);
  }

  return rc;                                                           /* OK */
}
Exemple #7
0
void
_PR_MD_INIT_IO()
{
    APIRET rc;
    HMODULE module;

    sock_init();
    
    rc = DosLoadModule(NULL, 0, "DOSCALL1", &module);
    if (rc != NO_ERROR)
    {
        return;
    }
    rc = DosQueryProcAddr(module, 981, NULL, (PFN*) &myDosOpenL);
    if (rc != NO_ERROR)
    {
        return;
    }
    rc = DosQueryProcAddr(module, 986, NULL, (PFN*) &myDosSetFileLocksL);
    if (rc != NO_ERROR)
    {
        return;
    }
    rc = DosQueryProcAddr(module, 988, NULL, (PFN*) &myDosSetFilePtrL);
    if (rc != NO_ERROR)
    {
        return;
    }
    isWSEB = PR_TRUE;
}
Exemple #8
0
APIRET APIENTRY WtkLoadNlsResourceModule( PFN pfnMod, PHMODULE phmod, PSZ pszDefaultLanguage,
                                          PSZ pszEnvVar, PSZ pszFileMaskPath)
{
         APIRET         rc = NO_ERROR;

         CHAR           szLanguageModule[ _MAX_PATH];
         CHAR           szError[ 20];

do
   {
   // determine filename
   rc = WtkGetNlsPackageFilename( pfnMod, pszDefaultLanguage, pszEnvVar, pszFileMaskPath,
                                     szLanguageModule, sizeof( szLanguageModule));
   if (rc != NO_ERROR)
      break;

   // load resource file
   rc = DosLoadModule( szError, sizeof( szError), szLanguageModule, phmod);
   if (rc != NO_ERROR)
      break;

   } while (FALSE);

return rc;
}
bool wxDynamicLibrary::Load(const wxString& libnameOrig, int flags)
{
    wxASSERT_MSG(m_handle == 0, _T("Library already loaded."));

    // add the proper extension for the DLL ourselves unless told not to
    wxString libname = libnameOrig;
    if ( !(flags & wxDL_VERBATIM) )
    {
        // and also check that the libname doesn't already have it
        wxString ext;
        wxFileName::SplitPath(libname, NULL, NULL, &ext);
        if ( ext.empty() )
        {
            libname += GetDllExt();
        }
    }

    // different ways to load a shared library
    //
    // FIXME: should go to the platform-specific files!
#if defined(__WXMAC__) && !defined(__DARWIN__)
    FSSpec      myFSSpec;
    Ptr         myMainAddr;
    Str255      myErrName;

    wxMacFilename2FSSpec( libname , &myFSSpec );

    if( GetDiskFragment( &myFSSpec,
                         0,
                         kCFragGoesToEOF,
                         "\p",
                         kPrivateCFragCopy,
                         &m_handle,
                         &myMainAddr,
                         myErrName ) != noErr )
    {
        wxLogSysError( _("Failed to load shared library '%s' Error '%s'"),
                       libname.c_str(),
                       wxMacMakeStringFromPascal( myErrName ).c_str() );
        m_handle = 0;
    }

#elif defined(__WXPM__) || defined(__EMX__)
    char    err[256] = "";
    DosLoadModule(err, sizeof(err), (PSZ)libname.c_str(), &m_handle);
#else
    m_handle = RawLoad(libname, flags);
#endif

    if ( m_handle == 0 )
    {
#ifdef wxHAVE_DYNLIB_ERROR
        Error();
#else
        wxLogSysError(_("Failed to load shared library '%s'"), libname.c_str());
#endif
    }

    return IsLoaded();
}
BOOL Settings :: ReloadResources (PSZ psz)
{
    if (g_hmod)
        DosFreeModule(g_hmod);

    APIRET  rc;

    if ((rc = DosLoadModule(PSZ(NULL), 0, psz, &g_hmod)))
    {
        DisplayError("ERROR", "Could not (re)load Gotcha! resource module "
                     "'%s' (DosLoadModule() return code %d). First make sure the DLL is in the LIBPATH. If this is the case, try to delete "
                     "GOTCHA.INI and start Gotcha! again. If it does not work "
                     "then, contact the author ([email protected]).", psz, rc);
        exit(1);
    }

    ResourceString::Module(g_hmod);

    pszPageTab[0] = RSTR (IDS_PAGESAVE);
    pszPageTab[1] = RSTR (IDS_PAGESNAPSHOT);
    pszPageTab[2] = RSTR (IDS_PAGEMISC);
    pszPageTab[3] = RSTR (IDS_PAGELANGUAGE);

    for( int i = 0; i < BMF_INVALID; i++ ) {
        ifi[ i ].label = RSTR ( IDS_BITMAP12INTERNAL+i ); }

    return TRUE;
}
Exemple #11
0
APIRET InitializeXPIStub()
{
  char szBuf[MAX_BUF];
  char szXPIStubFile[MAX_BUF];

  hXPIStubInst = NULL;

  /* get full path to xpistub.dll */
  if(DosQueryPathInfo("xpistub.dll", sizeof(szXPIStubFile), szXPIStubFile, NULL) == FALSE)
    PrintError("File not found: xpistub.dll", ERROR_CODE_SHOW, 2);

  /* load xpistub.dll */
  if((DosLoadModule(&szBuf, sizeof(szBuf), szXPIStubFile, &hXPIStubInst)) != NO_ERROR)
  {
    sprintf(szBuf, "Error loading library: %s\n", szXPIStubFile);
    PrintError(szBuf, ERROR_CODE_SHOW, 1);
  }
  if((pfnXpiInit = DosQueryProcAddr(hXPIStubInst, 1L, NULL,"XPI_Init")) == NULL)
  {
    sprintf(szBuf, "DosQueryProcAddr() failed: XPI_Init\n");
    PrintError(szBuf, ERROR_CODE_SHOW, 1);
  }
  if((pfnXpiInstall = DosQueryProcAddr(hXPIStubInst, 1L, NULL,"XPI_Install")) == NULL)
  {
    sprintf(szBuf, "DosQueryProcAddr() failed: XPI_Install\n");
    PrintError(szBuf, ERROR_CODE_SHOW, 1);
  }
  if((pfnXpiExit = DosQueryProcAddr(hXPIStubInst, 1L, NULL,"XPI_Exit")) == NULL)
  {
    sprintf(szBuf, "DosQueryProcAddr() failed: XPI_Exit\n");
    PrintError(szBuf, ERROR_CODE_SHOW, 1);
  }

  return(0);
}
Exemple #12
0
// Just put DLL loading into separate function
static BOOL LoadOverlay(void)
{
    char szTempStr[ 255 ];

    // Load WarpOverlay! API DLL
    if( DosLoadModule( szTempStr, sizeof( szTempStr ), "hwvideo", &m_HWVideoHandle ))
        return FALSE;

    // Get all functions entry points
    if( DosQueryProcAddr( m_HWVideoHandle, 0, "HWVIDEOInit", ( PFN * )&m_pfnHWVIDEOInit ))
        return FALSE;

    if( DosQueryProcAddr( m_HWVideoHandle, 0, "HWVIDEOCaps", ( PFN * )&m_pfnHWVIDEOCaps ))
        return FALSE;

    if( DosQueryProcAddr( m_HWVideoHandle, 0, "HWVIDEOSetup", ( PFN * )&m_pfnHWVIDEOSetup ))
        return FALSE;

    if( DosQueryProcAddr( m_HWVideoHandle, 0, "HWVIDEOBeginUpdate", ( PFN * )&m_pfnHWVIDEOBeginUpdate ))
        return FALSE;

    if( DosQueryProcAddr( m_HWVideoHandle, 0, "HWVIDEOEndUpdate", ( PFN * )&m_pfnHWVIDEOEndUpdate ))
        return FALSE;

    if( DosQueryProcAddr( m_HWVideoHandle, 0, "HWVIDEOGetAttrib", ( PFN * )&m_pfnHWVIDEOGetAttrib ))
        return FALSE;

    if( DosQueryProcAddr( m_HWVideoHandle, 0, "HWVIDEOSetAttrib", ( PFN * )&m_pfnHWVIDEOSetAttrib ))
        return FALSE;

    if( DosQueryProcAddr( m_HWVideoHandle, 0, "HWVIDEOClose", ( PFN * )&m_pfnHWVIDEOClose ))
        return FALSE;

    return TRUE;
}
Exemple #13
0
/* Depending on GBM.DLL version the number of pages can be retrieved (versions > 1.35)
 * or the functionality does not yet exist.
 *
 * Dynamically link the specific function to support also older versions of GBM.DLL.
 */
gbm_boolean SupportsNumberOfPagesQuery(void)
{
#if defined(__OS2__) || defined(OS2)

   HMODULE hmod;
   PFN     functionAddr = NULL;
   APIRET  rc = 0;

   /* check version first */
   if (gbm_version() < 135)
   {
      return GBM_FALSE;
   }

   /* now dynamically link GBM.DLL */
   rc = DosLoadModule("", 0, "GBM", &hmod);
   if (rc)
   {
      return GBM_FALSE;
   }

   /* lookup gbm_read_imgcount() */
   rc = DosQueryProcAddr(hmod, 0L, "gbm_read_imgcount", &functionAddr);

   DosFreeModule(hmod);

   return rc ? GBM_FALSE : GBM_TRUE;
#else
   /* On all other platforms we assume so far that the correct lib is there. */
   return GBM_TRUE;
#endif
}
Exemple #14
0
dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname,
				    const char *pathname, FILE *fp)
{
	dl_funcptr p;
	APIRET  rc;
	HMODULE hDLL;
	char failreason[256];
	char funcname[258];

	rc = DosLoadModule(failreason,
			   sizeof(failreason),
			   pathname,
			   &hDLL);

	if (rc != NO_ERROR) {
		char errBuf[256];
		PyOS_snprintf(errBuf, sizeof(errBuf),
			      "DLL load failed, rc = %d: %.200s",
			      rc, failreason);
		PyErr_SetString(PyExc_ImportError, errBuf);
		return NULL;
	}

	PyOS_snprintf(funcname, sizeof(funcname), "init%.200s", shortname);
	rc = DosQueryProcAddr(hDLL, 0L, funcname, &p);
	if (rc != NO_ERROR)
		p = NULL; /* Signify Failure to Acquire Entrypoint */
	return p;
}
Exemple #15
0
mad_status MADSysLoad( const char *path, mad_client_routines *cli,
                       mad_imp_routines **imp, mad_sys_handle *sys_hdl )
{
    HMODULE             dll;
    mad_init_func       *init_func;
    mad_status          status;
    char                madname[CCHMAXPATH] = "";
    char                madpath[CCHMAXPATH] = "";

    /* To prevent conflicts with the 16-bit MAD DLLs, the 32-bit versions have the "D32"
     * extension. We will search for them along the PATH (not in LIBPATH);
     */
    strcpy( madname, path );
    strcat( madname, ".D32" );
    _searchenv( madname, "PATH", madpath );
    if( madpath[0] == '\0' || DosLoadModule( NULL, 0, madpath, &dll ) != 0 ) {
        return( MS_ERR|MS_FOPEN_FAILED );
    }
    status = MS_ERR|MS_INVALID_MAD;
    if( DosQueryProcAddr( dll, 0, "MADLOAD", (PFN FAR *)&init_func ) == 0
      && (*imp = init_func( &status, cli )) != NULL ) {
        *sys_hdl = dll;
        return( MS_OK );
    }
    DosFreeModule( dll );
    return( status );
}
Exemple #16
0
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;
}
Exemple #17
0
// Obtains all of the information currently available for this plugin.
nsresult nsPluginFile::GetPluginInfo( nsPluginInfo &info)
{
   nsresult   rv = NS_ERROR_FAILURE;
   HMODULE    hPlug = 0; // Need a HMODULE to query resource statements
   char       failure[ CCHMAXPATH] = "";
   APIRET     ret;

   nsCAutoString path;
   if (NS_FAILED(rv = mPlugin->GetNativePath(path)))
     return rv;

   nsCAutoString fileName;
   if (NS_FAILED(rv = mPlugin->GetNativeLeafName(fileName)))
     return rv;

   ret = DosLoadModule( failure, CCHMAXPATH, path.get(), &hPlug);
   info.fVersion = nsnull;

   while( ret == NO_ERROR)
   {
      info.fName = LoadRCDATAString( hPlug, NS_INFO_ProductName);

      info.fVersion = LoadRCDATAVersion( hPlug, NS_INFO_ProductVersion);

      // get description (doesn't matter if it's missing)...
      info.fDescription = LoadRCDATAString( hPlug, NS_INFO_FileDescription);

      char * mimeType = LoadRCDATAString( hPlug, NS_INFO_MIMEType);
      if( nsnull == mimeType) break;

      char * mimeDescription = LoadRCDATAString( hPlug, NS_INFO_FileOpenName);
      if( nsnull == mimeDescription) break;

      char * extensions = LoadRCDATAString( hPlug, NS_INFO_FileExtents);
      if( nsnull == extensions) break;

      info.fVariantCount = CalculateVariantCount(mimeType);

      info.fMimeTypeArray = MakeStringArray(info.fVariantCount, mimeType);
      if( info.fMimeTypeArray == nsnull) break;

      info.fMimeDescriptionArray = MakeStringArray(info.fVariantCount, mimeDescription);
      if( nsnull == info.fMimeDescriptionArray) break;

      info.fExtensionArray = MakeStringArray(info.fVariantCount, extensions);
      if( nsnull == info.fExtensionArray) break;

      info.fFullPath = PL_strdup(path.get());
      info.fFileName = PL_strdup(fileName.get());

      rv = NS_OK;
      break;
   }

   if( 0 != hPlug)
      DosFreeModule( hPlug);

   return rv;
}
Exemple #18
0
HMODULE Load7ZLibrary(const wstring & name) {
    unsigned char  szErrorName[CCHMAXPATH];
    unsigned char libname[20];
    szErrorName[0]= '\0';
    void *pHandler = NULL;
    HMODULE *hmod = (HMODULE *) calloc(1, sizeof(HMODULE));
    APIRET rc;
	string tmpName = NarrowString(wstring(L".\\") + name + L".dll");
    strncpy((char *)libname, tmpName.c_str(), 19);
    rc = DosLoadModule(szErrorName, CCHMAXPATH-1, libname, hmod);
    /*
	  return codes:
	  0	NO_ERROR
	  2	ERROR_FILE_NOT_FOUND
	  3	ERROR_PATH_NOT_FOUND
	  4	ERROR_TOO_MANY_OPEN_FILES
	  5	ERROR_ACCESS_DENIED
	  8	ERROR_NOT_ENOUGH_MEMORY
	  11	ERROR_BAD_FORMAT
	  26	ERROR_NOT_DOS_DISK
	  32	ERROR_SHARING_VIOLATION
	  33	ERROR_LOCK_VIOLATION
	  36	ERROR_SHARING_BUFFER_EXCEEDED
	  95	ERROR_INTERRUPT
	  108	ERROR_DRIVE_LOCKED
	  123	ERROR_INVALID_NAME
	  127	ERROR_PROC_NOT_FOUND
	  180	ERROR_INVALID_SEGMENT_NUMBER
	  182	ERROR_INVALID_ORDINAL
	  190	ERROR_INVALID_MODULETYPE
	  191	ERROR_INVALID_EXE_SIGNATURE
	  192	ERROR_EXE_MARKED_INVALID
	  194	ERROR_ITERATED_DATA_EXCEEDS_64K
	  195	ERROR_INVALID_MINALLOCSIZE
	  196	ERROR_DYNLINK_FROM_INVALID_RING
	  198	ERROR_INVALID_SEGDPL
	  199	ERROR_AUTODATASEG_EXCEEDS_64K
	  201	ERROR_RELOCSRC_CHAIN_EXCEEDS_SEGLIMIT
	  206	ERROR_FILENAME_EXCED_RANGE
	  295	ERROR_INIT_ROUTINE_FAILED
    */
    hmod2 = hmod;
    pHandler = hmod2;
#if defined(_OS2_LIBDEBUG)
    std::cerr << "DosLoadModule: rc:" << rc << ", pHandler: " << pHandler << std::endl;
#endif
    if (rc) {
#if defined(_OS2_LIBDEBUG)
        std::cerr << "DosLoadModule: loading " << libname << " failed: " <<  szErrorName << ",  (ret code: " << rc << ")" << std::endl;
#endif
		pHandler = NULL;
    } else {
#if defined(_OS2_LIBDEBUG)
        std::cerr << "DosLoadModule: loading " << libname << " succeeded. " << std::endl;
#endif
    }

	return pHandler;
}
nsresult
XPCOMGlueLoad(const char *xpcomFile, GetFrozenFunctionsFunc *func)
{
    CHAR pszError[_MAX_PATH];
    ULONG ulrc = NO_ERROR;
    HMODULE h;

    if (xpcomFile[0] == '.' && xpcomFile[1] == '\0') {
        xpcomFile = XPCOM_DLL;
    }
    else {
        char xpcomDir[MAXPATHLEN];

        _fullpath(xpcomDir, xpcomFile, sizeof(xpcomDir));
        char *lastSlash = ns_strrpbrk(xpcomDir, "/\\");
        if (lastSlash) {
            *lastSlash = '\0';

            XPCOMGlueLoadDependentLibs(xpcomDir, ReadDependentCB);

            snprintf(lastSlash, MAXPATHLEN - strlen(xpcomDir), "\\" XUL_DLL);

            DosLoadModule(pszError, _MAX_PATH, xpcomDir, &sXULLibrary);
        }
    }

    ulrc = DosLoadModule(pszError, _MAX_PATH, xpcomFile, &h);

    if (ulrc != NO_ERROR)
        return nsnull;

    AppendDependentLib(h);

    GetFrozenFunctionsFunc sym;

    ulrc = DosQueryProcAddr(h, 0, "_NS_GetFrozenFunctions", (PFN*)&sym);

    if (ulrc != NO_ERROR) {
        XPCOMGlueUnload();
        return NS_ERROR_NOT_AVAILABLE;
    }

    *func = sym;

    return NS_OK;
}
Exemple #20
0
VOID InitSoftDebug(VOID)
{
    // Create the thread creation event sem and load the queue hook DLL
    DosCreateEventSem( NULL, &BeginThreadSem, 0, FALSE );
    DosLoadModule( NULL, 0, HOOKER, &HookDLL );
    DosQueryProcAddr( HookDLL, 0, "SendMsgHookProc", (PFN*)&PSendMsgHookProc );
    DosQueryProcAddr( HookDLL, 0, "SetHmqDebugee", (PFN*)&PSetHmqDebugee );
}
Exemple #21
0
char *LoadTrap( const char *parms, char *buff, trap_version *trap_ver )
{
    char                trpfile[CCHMAXPATH];
    unsigned            len;
    const char          *ptr;
    APIRET              rc;
    char                trpname[CCHMAXPATH] = "";
    char                trppath[CCHMAXPATH] = "";
    trap_init_func      *init_func;

    if( parms == NULL || *parms == '\0' )
        parms = "std";
    for( ptr = parms; *ptr != '\0' && *ptr != TRAP_PARM_SEPARATOR; ++ptr )
        ;
    len = ptr - parms;
    memcpy( trpfile, parms, len );
    trpfile[len] = '\0';

    /* To prevent conflicts with the 16-bit DIP DLLs, the 32-bit versions have the "D32"
     * extension. We will search for them along the PATH (not in LIBPATH);
     */
    strcpy( trpname, trpfile );
    strcat( trpname, ".D32" );
    _searchenv( trpname, "PATH", trppath );
    if( trppath[0] == '\0' ) {
        sprintf( buff, TC_ERR_CANT_LOAD_TRAP, trpname );
        return( buff );
    }
    rc = DosLoadModule( NULL, 0, trppath, &TrapFile );
    if( rc != 0 ) {
        sprintf( buff, TC_ERR_CANT_LOAD_TRAP, trppath );
        return( buff );
    }
    strcpy( buff, TC_ERR_WRONG_TRAP_VERSION );
    if( DosQueryProcAddr( TrapFile, 1, NULL, (PFN*)&init_func ) == 0
      && DosQueryProcAddr( TrapFile, 2, NULL, (PFN*)&FiniFunc ) == 0
      && DosQueryProcAddr( TrapFile, 3, NULL, (PFN*)&ReqFunc ) == 0 ) {
        if( DosQueryProcAddr( TrapFile, 4, NULL, (PFN*)&InfoFunc ) != 0 ) {
            InfoFunc = NULL;
        }
        if( DosQueryProcAddr( TrapFile, 5, NULL, (PFN*)&HardFunc ) != 0 ) {
            HardFunc = NULL;
        }
        parms = ptr;
        if( *parms != '\0' )
            ++parms;
        *trap_ver = init_func( parms, buff, trap_ver->remote );
        if( buff[0] == '\0' ) {
            if( TrapVersionOK( *trap_ver ) ) {
                TrapVer = *trap_ver;
                return( NULL );
            }
            strcpy( buff, TC_ERR_WRONG_TRAP_VERSION );
        }
    }
    KillTrap();
    return( buff );
}
Exemple #22
0
void
_PR_MD_EARLY_INIT()
{
    HMODULE hmod;

    if (DosLoadModule(NULL, 0, "DOSCALL1", &hmod) == 0)
        DosQueryProcAddr(hmod, 877, "DOSQUERYTHREADCONTEXT",
                         (PFN *)&QueryThreadContext);
}
/**
 * Initialize data members.
 */
USBProxyBackendOs2::USBProxyBackendOs2(USBProxyService *aUsbProxyService, const com::Utf8Str &strId)
    : USBProxyBackend(aUsbProxyService, strId), mhev(NULLHANDLE), mhmod(NULLHANDLE),
    mpfnUsbRegisterChangeNotification(NULL), mpfnUsbDeregisterNotification(NULL),
    mpfnUsbQueryNumberDevices(NULL), mpfnUsbQueryDeviceReport(NULL)
{
    LogFlowThisFunc(("aUsbProxyService=%p\n", aUsbProxyService));

    /*
     * Try initialize the usbcalls stuff.
     */
    int rc = DosCreateEventSem(NULL, &mhev, 0, FALSE);
    rc = RTErrConvertFromOS2(rc);
    if (RT_SUCCESS(rc))
    {
        rc = DosLoadModule(NULL, 0, (PCSZ)"usbcalls", &mhmod);
        rc = RTErrConvertFromOS2(rc);
        if (RT_SUCCESS(rc))
        {
            if (    (rc = DosQueryProcAddr(mhmod, 0, (PCSZ)"UsbQueryNumberDevices",         (PPFN)&mpfnUsbQueryNumberDevices))          == NO_ERROR
                &&  (rc = DosQueryProcAddr(mhmod, 0, (PCSZ)"UsbQueryDeviceReport",          (PPFN)&mpfnUsbQueryDeviceReport))           == NO_ERROR
                &&  (rc = DosQueryProcAddr(mhmod, 0, (PCSZ)"UsbRegisterChangeNotification", (PPFN)&mpfnUsbRegisterChangeNotification))  == NO_ERROR
                &&  (rc = DosQueryProcAddr(mhmod, 0, (PCSZ)"UsbDeregisterNotification",     (PPFN)&mpfnUsbDeregisterNotification))      == NO_ERROR
               )
            {
                rc = mpfnUsbRegisterChangeNotification(&mNotifyId, mhev, mhev);
                if (!rc)
                {
                    /*
                     * Start the poller thread.
                     */
                    rc = start();
                    if (RT_SUCCESS(rc))
                    {
                        LogFlowThisFunc(("returns successfully - mNotifyId=%d\n", mNotifyId));
                        mLastError = VINF_SUCCESS;
                        return;
                    }
                }

                LogRel(("USBProxyServiceOs2: failed to register change notification, rc=%d\n", rc));
            }
            else
                LogRel(("USBProxyServiceOs2: failed to load usbcalls\n"));

            DosFreeModule(mhmod);
        }
        else
            LogRel(("USBProxyServiceOs2: failed to load usbcalls, rc=%d\n", rc));
        mhmod = NULLHANDLE;
    }
    else
        mhev = NULLHANDLE;

    mLastError = rc;
    LogFlowThisFunc(("returns failure!!! (rc=%Rrc)\n", rc));
}
Exemple #24
0
static int sysdepDLLLoad( IDEDRV *inf )
{
#define SIZE 32
    unsigned char   badfile[SIZE];

    return (int)DosLoadModule( (PSZ)badfile
                             , sizeof( badfile )
                             , (PSZ)inf->dll_name
                             , (DLL_HANDLE *)&inf->dll_handle );
}
nsIdleServiceOS2::nsIdleServiceOS2()
  : mHMod(NULLHANDLE), mInitialized(PR_FALSE)
{
  const char error[256] = "";
  if (DosLoadModule(error, 256, "SSCORE", &mHMod) == NO_ERROR) {
    if (DosQueryProcAddr(mHMod, 0, "SSCore_GetInactivityTime",
                         (PFN*)&DSSaver_GetInactivityTime) == NO_ERROR) {
      mInitialized = PR_TRUE;
    }
  }
}
void *SDL_LoadObject(const char *sofile)
{
    HMODULE handle = NULL;
    char buf[512];
    APIRET ulrc = DosLoadModule(buf, sizeof (buf), (char *) sofile, &handle);

    /* Generate an error message if all loads failed */
    if ((ulrc != NO_ERROR) || (handle == NULL))
        SDL_SetError("Failed loading %s: %s", sofile, buf);

    return((void *) handle);
}
Exemple #27
0
static SDL_INLINE void *get_sdlapi_entry(const char *fname, const char *sym)
{
    HMODULE hmodule;
    PFN retval = NULL;
    char error[256];
    if (DosLoadModule(&error, sizeof(error), fname, &hmodule) == NO_ERROR) {
        if (DosQueryProcAddr(hmodule, 0, sym, &retval) != NO_ERROR) {
            DosFreeModule(hmodule);
        }
    }
    return (void *) retval;
}
VOID main( ULONG argc, CHAR *argv[] )
{
   ULONG    rc        = 0;
   ULONG    Address   = 0;
   ULONG   *ROBase    = 0;
   ULONG   *ROContent = 0;
   CHAR     pszError[256];
   HMODULE  hModule;
   INT      i = 1;

   printf("Loading Test of R/O Data to Code Dll\n");

   rc = DosLoadModule( pszError,
                       sizeof( pszError ),
                       "object",
                       &hModule );

   if( rc )
   {
      printf("Error trying to load module [%d] on module [%s]\n",rc, pszError );
   }
   else
   {
      printf("Loaded Successfully\n");

      rc = DosQueryProcAddr( hModule,
                             0,
                             "DataOffset",
                             &Address );

      if(!rc)
      {
         ROBase    = (ULONG *)Address;
         ROContent = (ULONG *)*ROBase;

         printf("Address to RO Data Query Addr  [0x%8.8x]\n" \
                "                   Load  Addr  [0x%8.8x]\n" \
                "                   Ptr Content [0x%8.8x]\n", Address,
                                                             *ROBase,
                                                             *ROContent );
      }

   }

   while( i )
   {
      i = 1;
   }


   return;
}
Exemple #29
0
static BOOL VManInit(SDL_PrivateVideoData *pPVData)
{
  CHAR			achBuf[256];
  ULONG			ulRC;
  INITPROCOUT		sInitProcOut;

  ulRC = DosLoadModule( achBuf, sizeof(achBuf), "VMAN", &hmodVMan );
  if ( ulRC != NO_ERROR )
  {
    debug( "Could not load VMAN.DLL, rc = %u : %s", ulRC, achBuf );
    return FALSE;
  }

  ulRC = DosQueryProcAddr( hmodVMan, 0L, "VMIEntry", (PFN *)&pfnVMIEntry );
  if ( ulRC != NO_ERROR )
  {
    debug( "Could not query address of pfnVMIEntry function of VMAN.DLL, "
           "rc = %u", ulRC );
    DosFreeModule( hmodVMan );
    hmodVMan = NULLHANDLE;
    return FALSE;
  }

  sInitProcOut.ulLength = sizeof(sInitProcOut);
  ulRC = pfnVMIEntry( 0, VMI_CMD_INITPROC, NULL, &sInitProcOut );
  if ( ulRC != RC_SUCCESS )
  {
    debug( "Could not initialize VMAN for this process" );
    DosFreeModule( hmodVMan );
    hmodVMan = NULLHANDLE;
    return FALSE;
  }


  if ( pPVData == NULL )
  {
    // It only check VMan availability...
    pfnVMIEntry( 0, VMI_CMD_TERMPROC, NULL, NULL );
    return TRUE;
  }

  ulVRAMAddress = sInitProcOut.ulVRAMVirt;

  // Set routine that run when the current process ends, before PM-related
  // internal procedure.
  ulRC = DosExitList( EXLST_ADD
                     | 0x00009900, // Before Presentation Manager (0xA0 - 0xA8)
                     _AtExit );

  return TRUE;
}
static void *
xmlModulePlatformOpen(const char *name)
{
    char errbuf[256];
    void *handle;
    int rc;

    rc = DosLoadModule(errbuf, sizeof(errbuf) - 1, name, &handle);

    if (rc)
        return 0;
    else
        return (handle);
}