Jump to content

DosQueryProcType: Difference between revisions

From EDM2
Ak120 (talk | contribs)
mNo edit summary
Ak120 (talk | contribs)
mNo edit summary
 
Line 2: Line 2:


==Syntax==
==Syntax==
<PRE>
  DosQueryProcType(hmod, ordinal, pszName, pulproctype)
#define INCL_DOSMODULEMGR
#include <os2.h>
 
HMODULE hmod;        /* The handle of the dynamic link module that contains the procedure. */
ULONG    ordinal;    /* The ordinal number of the procedure whose type is desired. */
PSZ      pszName;    /* The address of an ASCIIZ name string that contains the procedure name
                        that is being referenced. */
PULONG  pulproctype; /* The address of a ULONG in which the procedure type is returned. */
APIRET  ulrc;        /* Return Code. */
 
ulrc = DosQueryProcType(hmod, ordinal, pszName, pulproctype);
</PRE>


==Parameters==
==Parameters==
Line 22: Line 10:
;pszName (PSZ) - input : The address of an ASCIIZ name string that contains the procedure name that is being referenced.
;pszName (PSZ) - input : The address of an ASCIIZ name string that contains the procedure name that is being referenced.
:Calls to DosQueryProcType for entries within the DOSCALLS module are supported for ordinal references only. References to the DOSCALLS module by name strings are not supported, and will return an error. Dynamic link ordinal numbers for DOSCALLS routines are resolved by linking with OS2386.LIB.
:Calls to DosQueryProcType for entries within the DOSCALLS module are supported for ordinal references only. References to the DOSCALLS module by name strings are not supported, and will return an error. Dynamic link ordinal numbers for DOSCALLS routines are resolved by linking with OS2386.LIB.
; pulproctype (PULONG) - output : The address of a ULONG in which the procedure type is returned.
;pulproctype (PULONG) - output : The address of a ULONG in which the procedure type is returned.
:The value returned in this field is one of the following:
:The value returned in this field is one of the following:
::0 - PT_16BIT - Procedure is 16-bit.
::0 - PT_16BIT - Procedure is 16-bit.
Line 28: Line 16:


==Return Code==
==Return Code==
ulrc (APIRET) - returns
;ulrc (APIRET) - returns:DosQueryProcType returns one of the following values:
DosQueryProcType returns one of the following values:
* 0  NO_ERROR
* 0  NO_ERROR
* 6  ERROR_INVALID_HANDLE
* 6  ERROR_INVALID_HANDLE
* 123 ERROR_INVALID_NAME
*123 ERROR_INVALID_NAME
* 182 ERROR_INVALID_ORDINAL
*182 ERROR_INVALID_ORDINAL


==Remarks==
==Remarks==
DosQueryProcType returns the type of the specified procedure within a dynamic link module.
If return code ERROR_INVALID_HANDLE is received, issue [[DosLoadModule]] and then issue DosQueryProcType again.
 
The type returned indicates whether the specified procedure is a 16-bit or 32-bit callable procedure.
 
If return code ERROR_INVALID_HANDLE is received, issue [[DosLoadModule]] and then issue DosQueryProcType again.  


==Example Code==
==Example Code==
This example loads the dynamic link module <tt>DISPLAY.DDL</tt>, queries its address and type, and finally frees it.
This example loads the dynamic link module <tt>DISPLAY.DDL</tt>, queries its address and type, and finally frees it.
<PRE>
<code>
  #define INCL_DOSMODULEMGR    /* Module Manager values */
  #define INCL_DOSMODULEMGR    /* Module Manager values */
  #define INCL_DOSERRORS        /* Error values */
  #define INCL_DOSERRORS        /* Error values */
  #include <os2.h>
  #include <os2.h>
  #include <stdio.h>
  #include <stdio.h>
 
int main(VOID) {
int main(VOID){
 
  PSZ      ModuleName    = "C:\\OS2\\DLL\\DISPLAY.DLL";  /* Name of module  */
  PSZ      ModuleName    = "C:\\OS2\\DLL\\DISPLAY.DLL";  /* Name of module  */
  UCHAR    LoadError[256] = "";          /* Area for Load failure information */
  UCHAR    LoadError[256] = "";          /* Area for Load failure information */
Line 58: Line 41:
  ULONG    ModuleType    = 0;          /* Module type                      */
  ULONG    ModuleType    = 0;          /* Module type                      */
  APIRET  rc            = NO_ERROR;    /* Return code                      */
  APIRET  rc            = NO_ERROR;    /* Return code                      */
 
   rc = DosLoadModule(LoadError,              /* Failure information buffer */
   rc = DosLoadModule(LoadError,              /* Failure information buffer */
                       sizeof(LoadError),      /* Size of buffer            */
                       sizeof(LoadError),      /* Size of buffer            */
Line 69: Line 52:
       printf("Module %s loaded.\n", ModuleName);
       printf("Module %s loaded.\n", ModuleName);
   } /* endif */
   } /* endif */
 
   rc = DosQueryProcAddr(ModuleHandle,        /* Handle to module          */
   rc = DosQueryProcAddr(ModuleHandle,        /* Handle to module          */
                         1L,                  /* No ProcName specified      */
                         1L,                  /* No ProcName specified      */
Line 78: Line 61:
       return 1;
       return 1;
   } else printf("Address of module is 0x%x.\n", ModuleAddr);
   } else printf("Address of module is 0x%x.\n", ModuleAddr);
 
   rc = DosQueryProcType(ModuleHandle,        /* Handle to module          */
   rc = DosQueryProcType(ModuleHandle,        /* Handle to module          */
                         1L,                  /* Indicate no ProcName given */
                         1L,                  /* Indicate no ProcName given */
Line 87: Line 70:
       return 1;
       return 1;
   } else printf("This is a %s module.\n", ( ModuleType ? "32-bit" : "16-bit"));
   } else printf("This is a %s module.\n", ( ModuleType ? "32-bit" : "16-bit"));
 
   rc = DosFreeModule(ModuleHandle);
   rc = DosFreeModule(ModuleHandle);
   if (rc != NO_ERROR) {
   if (rc != NO_ERROR) {
Line 93: Line 76:
       return 1;
       return 1;
   } else printf("Module %s freed.\n", ModuleName);
   } else printf("Module %s freed.\n", ModuleName);
 
   return NO_ERROR;
   return NO_ERROR;
}
}
</PRE>
</code>


==Related Functions==
==Related Functions==

Latest revision as of 15:09, 15 March 2019

Returns the type of the specified procedure within a dynamic link module. The type returned indicates whether the specified procedure is a 16-bit or 32-bit callable procedure.

Syntax

DosQueryProcType(hmod, ordinal, pszName, pulproctype)

Parameters

hmod (HMODULE) - input
The handle of the dynamic link module that contains the procedure.
ordinal (ULONG) - input
The ordinal number of the procedure whose type is desired.
If the ordinal number is nonzero, pszName is ignored.
pszName (PSZ) - input
The address of an ASCIIZ name string that contains the procedure name that is being referenced.
Calls to DosQueryProcType for entries within the DOSCALLS module are supported for ordinal references only. References to the DOSCALLS module by name strings are not supported, and will return an error. Dynamic link ordinal numbers for DOSCALLS routines are resolved by linking with OS2386.LIB.
pulproctype (PULONG) - output
The address of a ULONG in which the procedure type is returned.
The value returned in this field is one of the following:
0 - PT_16BIT - Procedure is 16-bit.
1 - PT_32BIT - Procedure is 32-bit.

Return Code

ulrc (APIRET) - returns
DosQueryProcType returns one of the following values:
  • 0 NO_ERROR
  • 6 ERROR_INVALID_HANDLE
  • 123 ERROR_INVALID_NAME
  • 182 ERROR_INVALID_ORDINAL

Remarks

If return code ERROR_INVALID_HANDLE is received, issue DosLoadModule and then issue DosQueryProcType again.

Example Code

This example loads the dynamic link module DISPLAY.DDL, queries its address and type, and finally frees it.

#define INCL_DOSMODULEMGR     /* Module Manager values */
#define INCL_DOSERRORS        /* Error values */
#include <os2.h>
#include <stdio.h>

int main(VOID){

PSZ      ModuleName     = "C:\\OS2\\DLL\\DISPLAY.DLL";  /* Name of module   */
UCHAR    LoadError[256] = "";          /* Area for Load failure information */
HMODULE  ModuleHandle   = NULLHANDLE;  /* Module handle                     */
PFN      ModuleAddr     = 0;           /* Pointer to a system function      */
ULONG    ModuleType     = 0;           /* Module type                       */
APIRET   rc             = NO_ERROR;    /* Return code                       */

  rc = DosLoadModule(LoadError,               /* Failure information buffer */
                     sizeof(LoadError),       /* Size of buffer             */
                     ModuleName,              /* Module to load             */
                     &ModuleHandle);          /* Module handle returned     */
  if (rc != NO_ERROR) {
     printf("DosLoadModule error: return code = %u\n", rc);
     return 1;
  } else {
     printf("Module %s loaded.\n", ModuleName);
  } /* endif */

  rc = DosQueryProcAddr(ModuleHandle,         /* Handle to module           */
                        1L,                   /* No ProcName specified      */
                        NULL,                 /* ProcName (not specified)   */
                        &ModuleAddr);         /* Address returned           */
  if (rc != NO_ERROR) {
     printf("DosQueryProcAddr error: return code = %u\n", rc);
     return 1;
  } else printf("Address of module is 0x%x.\n", ModuleAddr);

  rc = DosQueryProcType(ModuleHandle,         /* Handle to module           */
                        1L,                   /* Indicate no ProcName given */
                        NULL,                 /* ProcName (not specified)   */
                        &ModuleType);         /* Type 0=16-bit   1=32-bit   */
  if (rc != NO_ERROR) {
     printf("DosQueryProcType error: return code = %u\n", rc);
     return 1;
  } else printf("This is a %s module.\n", ( ModuleType ? "32-bit" : "16-bit"));

  rc = DosFreeModule(ModuleHandle);
  if (rc != NO_ERROR) {
     printf("DosFreeModule error: return code = %u\n", rc);
     return 1;
  } else printf("Module %s freed.\n", ModuleName);

  return NO_ERROR;

}

Related Functions