Kbase 17271: How to Call WIN32 API Function: IsBadCodePtr
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  5/10/1998 |
|
How to Call WIN32 API Function: IsBadCodePtr
DISCLAIMER:
===========
The code example in this knowledgebase is for informational purposes
only. If you have specific questions about which API calls would be
best suited to your design goals, please consult your Microsoft
documentation.
INTRODUCTION:
=============
The following code sample shows how to call the Win32 API function
called IsBadCodePtr. This function determines whether the calling
process (i.e. Progress) has read access to the memory at the
specified address. This function does not guarantee read access to
a range of memory.
The example code shows the first parameter to the function being an
integer. You might have to change this to a MEMPTR depending on your
requirements. This code would only be useful in scenarios where you
are working with external DLL's. The testing of this code has been
limited to verifying that it compiles and runs. Obviously, it is
hard to get a pointer to executable code when using the 4GL (grin).
This code has been tested on Windows NT 4.0 Workstation only.
DEFINE VARIABLE intResult AS INTEGER NO-UNDO.
DEFINE VARIABLE intAddress AS INTEGER NO-UNDO.
PROCEDURE IsBadCodePtr EXTERNAL "KERNEL32.DLL":
DEFINE INPUT PARAMETER intAddress AS LONG.
DEFINE RETURN PARAMETER intResult AS LONG.
END PROCEDURE.
RUN IsBadCodePtr (intAddress, OUTPUT intResult).
IF intResult = 0 THEN
MESSAGE "Code Pointer :: Valid" VIEW-AS ALERT-BOX.
ELSE
MESSAGE "Code Pointer :: Invalid" VIEW-AS ALERT-BOX.
Progress Software Technical Support Note # 17271