× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Keith,

I've been tinkering and the preprocessor API's are a HUGE pain. I was
getting problems with them a while back (if you Google
"QbnStartPreProcessor" you'll find a thread on this forum about it).

I'm using the following program (SETPASR) to add the source (currently
unencrypted) to the PAS of a program (this program is called from my
compile preprocessor, prior to the program being compiled):


    H DEBUG(*YES)
    FTMPSRC    UF   F  112        DISK    UsrOpn
    F                                     Extfile(TmpSrcFile)
    F                                     ExtMbr(TmpSrcMbr)
     *---------------------------------------------------------------------
    D ThisProgram     C                   'SETPASR'
     *---------------------------------------------------------------------
    D QUSEC           DS
    D  ErrBytesProv                 10I 0 Inz(%size(QUSEC))
    D  ErrBytesAvail                10I 0 Inz
    D  ErrMsgID                      7A
    D                                1
    D  ErrMsgDta                   512A
     *
    D QbnStartPreProcessor...
    D                 PR                  Extproc('QbnStartPreProcessor')
    D ApiError                                  Like(QUSEC)
     *
    D QbnEndPreProcessor...
    D                 PR                  Extproc('QbnEndPreProcessor')
    D qInputSrcFile                 20A   Const
    D InputSrcMbr                   10A   Const
    D qOutputSrcFile                20A   Const
    D OutputSrcMbr                  10A   Const
    D qExitPgm                      20A   Const
    D Data                       32767A   Const
    D DataLen                       10I 0 Const
    D ApiError                                  Like(QUSEC)
     *
    D QbnAddAssociatedSpaceEntry...
    D                 PR                  Extproc('QbnAddAssociatedSpaceEntry')
    D   SpaceID                     10A   Const
    D   SpaceData                65535A   Const Options(*Varsize)
    D   SpaceDataLen                10I 0 Const
    D   Options                      1A   Const
    D   ApiError                                Like(QUSEC)
     *
    D TmpSrcFile      S             21A   Inz
    D TmpSrcMbr       S             10A   Inz
     *
    D SrcRcd          DS
    D   SrcSeq                       6S 2
    D   SrcDat                       6S 0
    D   SrcDta                     100A
     *
    D qOutFile        DS                  Inz
    D   OutFile                     10A
    D   OutLib                      10A   Inz('*LIBL')
    D OutMbr          S             10A   Inz('*FIRST') Varying
     *
    D ModSrc          S          65535A   Inz Varying
     *
     *---------------------------------------------------------------------
     * Program interface
     *---------------------------------------------------------------------
     *
    D main            PR                  Extpgm(ThisProgram)
    D   Cmd                         10A   Const
    D   SrcMbr                      10A   Const
    D   SrcFile                     10A   Const
    D   SrcLib                      10A   Const
     *
    D main            PI
    D   Cmd                         10A   Const
    D   SrcMbr                      10A   Const
    D   SrcFile                     10A   Const
    D   SrcLib                      10A   Const
     *
     /free

       // Load ModSrc with the module source

       TmpSrcFile = %trim( SrcLib ) + '/' + SrcFile;
       TmpSrcMbr = SrcMbr;
       OutFile = SrcFile;
       OutLib = SrcLib;
       OutMbr = SrcMbr;

       open(e) TMPSRC;
       if %error;
         return;
       endif;
       read(e) TMPSRC SrcRcd;
       ModSrc = SrcLib + SrcFile + SrcMbr;
       dow not %error and not %eof;
         ModSrc = ModSrc + %trimr( SrcDta ) + x'00';
         read(e) TMPSRC SrcRcd;
       enddo;
       close(e) TMPSRC;
       if %error;
         exsr *pssr;
       endif;

       // Encrypt source here...

       reset QUSEC;
       QbnStartPreProcessor( QUSEC );
       if ErrBytesAvail > 0;
         exsr *pssr;
       endif;

       reset QUSEC;
       QbnAddAssociatedSpaceEntry( cQbnSpaceID : ModSrc : %len( ModSrc ) :
                                   cQbnNoExtend : QUSEC );
       if ErrBytesAvail > 0;
         exsr *pssr;
       endif;

       reset QUSEC;
       QbnEndPreProcessor( SrcFile + SrcLib : SrcMbr :
                           qOutFile : OutMbr :
                           '*NONE' : *Blanks : 0 : QUSEC );
       if ErrBytesAvail > 0;
         exsr *pssr;
       endif;

       return;

       begsr *pssr;
         dump(a);
         return;
       endsr;

     /end-free

The calls to QbnStartPreProcessor() and QbnAddAssociatedSpaceEntry()
show no errors, but the call to QbnEndPreProcessor() always throws a
CPF5D23 ("Source file member has been changed."). I'm stumped - I'm
not actually changing the source member at all - just reading it. The
change date timestamp on the member isn't changing at all...

Then, of course, because the QbnRetrieveAssociatedSpace() API uses a
relative call stack entry rather than a qualified program name, the
ability to retrieve this information is dependent on the debugged
program being in the call stack. In other words, I'd need to have a
call within each module I'd want to debug in this way to the procedure
which retrieves the PAS and gets the source (and potentially starts
debug).

I also have a separate program called GETPASR which has a single
parameter of the password to use to decrypt the source. So in my
application programs, I'd have the following:

/free
  getpasr( 'a1@3e%dd*F' );
/end-free

In GETPASR, I check for the existence of a debug data area. If it
exists, I pop up a box asking for the debug password. If the user
correctly enters 'a1@3e%dd*F', GETPASR retrieves the PAS for the
application program (one up the call stack from GETPASR), decrypts the
source, creates the source library/file/member (as defined in the
first 30 bytes of the PAS), copies the source into it, and then starts
debug.

The GETPASR processing works great (if I get the source from a
manually created user space rather than from a user space created from
the PAS). So as long as I can figure out why the QbnEndPreProcessor()
API is always throwing an error...

Oh well, back to 'proper' work. If you can get the SETPASR program to
work, I'd love to know why I can't!

It's ALMOST too much hassle.

Rory

On 1/10/07, Keith Carpenter <carpcon@xxxxxxx> wrote:
Rory Hewitt wrote:
> Jon,
>
> A good point - I will look into doing this. Also, I've been experimenting
> with including an encrypted copy of the program source in the Program
> Associated Space, which is yielding good results also...

Looking at the Retrieve API, it uses "call level" to identity the
module's associated space.  Sounds like it should work for both programs
and service programs.  great.

I would assume you'd use your retrieval tool while the application is in
use but before starting debug.

Novel idea.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.