Finding a string literal in a *PGM object - IBM AS400

This is a discussion on Finding a string literal in a *PGM object - IBM AS400 ; Hi All, We work mostly on Unix where the "what" command is used to extract specific string tokens from compiled executable binaries. We use this to determine version and customer information. I would like to know how to do this ...

+ Reply to Thread
Results 1 to 16 of 16

Thread: Finding a string literal in a *PGM object

  1. Finding a string literal in a *PGM object

    Hi All,

    We work mostly on Unix where the "what" command is used to extract
    specific string tokens from compiled executable binaries. We use this
    to determine version and customer information.

    I would like to know how to do this for a compiled OPM COBOL *PGM
    object on the AS400. I've looked at DSPPGM but it seems restricted in
    the information is can extract.

    To break this down:
    1)Are string literals from the COBOL WORKING-STORAGE section VALUE
    clauses contained in a readable format in the *PGM object?

    2)If they are, how would I go about searching for one?

    Following is an example version string from a Unix COBOL binary:

    @(#) VERSION 5.13.

    This string was contained in a working storage VALUE clause for a 01
    level item.

    Thanks in advance,

    Elliot


  2. Re: Finding a string literal in a *PGM object

    Hi Elliot,

    Yes, you can see literal strings by dumping the program with System
    Service Tools, like this:

    1. Enter the STRSST command
    2. Enter user and password -- user 22222222 & password 22222222 (8 2's)
    may work if the password hasn't been changed
    3. Option 1 Start a service tool
    4. Option 4 Display/Alter/Dump
    5. Option 2 Dump to printer
    6. Option 1 Machine Interface object
    7. Option 2 Program
    8. Option 1 Find by object name and context name
    9. Enter the program name and context (library) name
    10. Press ENTER on the MI Object Found screen
    11. Option 2 Dump in hexadecimal (logical blocks)
    12. Press ENTER on the Specify Dump Title screen
    13. Wait til dump finishes then exit with F3's
    14. Scan or page thru the spoolfile to find literals.

    --Dave

    Elliot wrote:
    > Hi All,
    >
    > We work mostly on Unix where the "what" command is used to extract
    > specific string tokens from compiled executable binaries. We use this
    > to determine version and customer information.
    >
    > I would like to know how to do this for a compiled OPM COBOL *PGM
    > object on the AS400. I've looked at DSPPGM but it seems restricted in
    > the information is can extract.
    >
    > To break this down:
    > 1)Are string literals from the COBOL WORKING-STORAGE section VALUE
    > clauses contained in a readable format in the *PGM object?
    >
    > 2)If they are, how would I go about searching for one?
    >
    > Following is an example version string from a Unix COBOL binary:
    >
    > @(#) VERSION 5.13.
    >
    > This string was contained in a working storage VALUE clause for a 01
    > level item.
    >
    > Thanks in advance,
    >
    > Elliot
    >


  3. Re: Finding a string literal in a *PGM object

    From the observable template you should be able to find the string.
    However shorter literals may be generated in the code instead of being
    stored; I believe such optimization is only done out of the template on
    translation into the RISC byte stream, and is unlikely to be done by any
    compilers. You would however have to use the MI object dump feature in
    STRSST to see the template. If there is a dump facility without the
    interactive screens, I am unaware.
    If such a value is desirable to be stored in a visible location, it
    should be stored as an object information attribute [e.g. Object Control
    Level or text], or perhaps in the associated space using the available
    binder APIs, or as a procedure name, or export, or copyright which are
    visible from the DSPxxxPGM.
    Part of the integrity of the system requires preventing such a
    general access to the program, beyond the object itself, which merely
    encapsulates the byte streams that make up the template and executable.

    Regards, Chuck
    -- All comments provided "as is" with no warranties of any kind whatsoever.

    Elliot wrote:
    > Hi All,
    >
    > We work mostly on Unix where the "what" command is used to extract
    > specific string tokens from compiled executable binaries. We use this
    > to determine version and customer information.
    >
    > I would like to know how to do this for a compiled OPM COBOL *PGM
    > object on the AS400. I've looked at DSPPGM but it seems restricted in
    > the information is can extract.
    >
    > To break this down:
    > 1)Are string literals from the COBOL WORKING-STORAGE section VALUE
    > clauses contained in a readable format in the *PGM object?
    >
    > 2)If they are, how would I go about searching for one?
    >
    > Following is an example version string from a Unix COBOL binary:
    >
    > @(#) VERSION 5.13.
    >
    > This string was contained in a working storage VALUE clause for a 01
    > level item.
    >
    > Thanks in advance,
    >
    > Elliot
    >


  4. Re: Finding a string literal in a *PGM object

    On May 23, 7:35 pm, Elliot wrote:
    > Hi All,
    >
    > We work mostly on Unix where the "what" command is used to extract
    > specific string tokens from compiled executable binaries. We use this
    > to determine version and customer information.
    >
    > I would like to know how to do this for a compiled OPM COBOL *PGM
    > object on the AS400. I've looked at DSPPGM but it seems restricted in
    > the information is can extract.
    >
    > To break this down:
    > 1)Are string literals from the COBOL WORKING-STORAGE section VALUE
    > clauses contained in a readable format in the *PGM object?
    >
    > 2)If they are, how would I go about searching for one?
    >
    > Following is an example version string from a Unix COBOL binary:
    >
    > @(#) VERSION 5.13.
    >
    > This string was contained in a working storage VALUE clause for a 01
    > level item.
    >
    > Thanks in advance,
    >
    > Elliot


    If you cant get the strsst passwords then try dmpobj or dmpsysobj.
    These produce spooled files & maybe an optional outfile. If not the
    spooled file may be transfigured into a dbf. In either case searching
    for a string will be more problematic as there will most likely be a
    break in the string at a line end unlike a stream file.

    HTH
    Jonathan.


  5. Re: Finding a string literal in a *PGM object

    On May 23, 2:35 pm, Elliot wrote:
    > Hi All,
    >
    > We work mostly on Unix where the "what" command is used to extract
    > specific string tokens from compiled executable binaries. We use this
    > to determine version and customer information.
    >
    > I would like to know how to do this for a compiled OPM COBOL *PGM
    > object on the AS400. I've looked at DSPPGM but it seems restricted in
    > the information is can extract.
    >
    > To break this down:
    > 1)Are string literals from the COBOL WORKING-STORAGE section VALUE
    > clauses contained in a readable format in the *PGM object?
    >
    > 2)If they are, how would I go about searching for one?
    >
    > Following is an example version string from a Unix COBOL binary:
    >
    > @(#) VERSION 5.13.
    >
    > This string was contained in a working storage VALUE clause for a 01
    > level item.
    >
    > Thanks in advance,
    >
    > Elliot


    if the program is compiled with the option to include debug views of
    the source code, you can use the QteRetrieveModuleViews and
    QteRetrieveViewText APIs to get scannable compile listings or input
    source code.

    ** ------------------ QteRetrieveModuleViews
    ------------------
    dQteRetrieveModuleViews...
    d pr
    extproc('QteRetrieveModuleViews')
    d OutReceiver
    likeds(Vewl0100)
    d InReceiverSx 10i 0
    const
    d InFormat 8a
    const
    d InPgm const
    likeds(fObject)
    d InPgmt 10a
    const
    d InModule 10a
    const
    d OutPgmLib
    10a
    d OutErr
    likeds(fProcError)

    ** ------------------ QteRetrieveViewText ------------------
    dQteRetrieveViewText...
    d pr extproc('QteRetrieveViewText')
    d OutReceiver 9999a options(*VarSize)
    d InReceiverSx 10i 0 const
    d InViewId 10i 0 const
    d InSlno 10i 0 const
    d InLineCx 10i 0 const
    d InLineSx 10i 0 const
    d OutErr likeds(fProcError)



  6. Re: Finding a string literal in a *PGM object

    il 23/05/2007 20.35, Scrive Elliot 40749624:
    > Hi All,
    >
    > We work mostly on Unix where the "what" command is used to extract
    > specific string tokens from compiled executable binaries. We use this
    > to determine version and customer information.
    >
    > I would like to know how to do this for a compiled OPM COBOL *PGM
    > object on the AS400. I've looked at DSPPGM but it seems restricted in
    > the information is can extract.
    >
    > To break this down:
    > 1)Are string literals from the COBOL WORKING-STORAGE section VALUE
    > clauses contained in a readable format in the *PGM object?
    >
    > 2)If they are, how would I go about searching for one?
    >
    > Following is an example version string from a Unix COBOL binary:
    >
    > @(#) VERSION 5.13.
    >
    > This string was contained in a working storage VALUE clause for a 01
    > level item.
    >
    > Thanks in advance,
    >
    > Elliot
    >

    You can DMPOBJ jourlib/yourpgm *PGM, this will produce a printed output
    (a spooled file), then you can search inside the spooled file.

    --
    Dr.Ugo Gagliardelli,Modena,ItalyCertifiedUindoscrasherAńe joAlcoolInside
    Spaccamaroni andate a cagare/Spammers not welcome/Spammers văo ŕ merda
    Spamers iros a la mierda/Spamers allez vous faire foutre/Spammers loop
    schijten/Spammers macht Euch vom Acker/Spamerzy wypierdalac'

  7. Re: Finding a string literal in a *PGM object

    Out of curiousity, I tried running "what" from the QP2TERM shell, but
    without success (I got "A system call received a parameter that is not
    valid."). This may be because "what" isn't fully supported, or (more
    likely) because I don't know UNIX and have messed up the parameters /
    flags on the "what" command. You may want to try this avenue yourself
    and see if you can make it return anything useful.


  8. Re: Finding a string literal in a *PGM object

    To all of you who replied to my question,

    I would like to thank you for the wealth of ideas. It will take me a
    while to try them out but I'll certainly keep you posted. And please
    don't stop coming up with new ones.

    Thanks

    Elliot


  9. Re: Finding a string literal in a *PGM object

    "walker.l2" wrote in message
    news:1180021813.977806.114060@g4g2000hsf.googlegro ups.com...
    > Out of curiousity, I tried running "what" from the QP2TERM shell, but
    > without success (I got "A system call received a parameter that is not
    > valid.").


    The i5/OS PASE version of the "what" utility does what any UNIX
    implementation does: open the file, and read/scan the stream. The
    encapsulated architecture of MI program (and service program) objects
    doesn't allow them to be opened and/or read as streams.

    --
    George Timms
    IBM Rochester



  10. Re: Finding a string literal in a *PGM object

    That makes sense.

    Hopefully QP2TERM will be of some use (if not in this situation then
    perhaps others) to the OP as a Unix guy though.


  11. Re: Finding a string literal in a *PGM object

    Elliot wrote:

    > 1)Are string literals from the COBOL WORKING-STORAGE section VALUE
    > clauses contained in a readable format in the *PGM object?
    >
    > 2)If they are, how would I go about searching for one?
    >
    > Following is an example version string from a Unix COBOL binary:
    >
    > @(#) VERSION 5.13.


    Elliot:

    As others have mentioned or implied, a compiled *PGM object is not a
    file and can't be read as a file -- it's a different kind of object with
    different 'methods'. There are ways to get at such data using variations
    of techniques mentioned, but I'm not at all clear why you'd want to.

    That is, data such as a version number can be stored in the program
    object header much better than buried in the object code. The object
    header info can be fairly easily retrieved by use of supported APIs.
    Lots of info of various kinds can be stored and retrieved. It's a fairly
    standard function.


    Can you give more examples of what you want to do? There might be much
    better solutions than what you're trying to do.

    --
    Tom Liotta
    http://zap.to/tl400

  12. Re: Finding a string literal in a *PGM object

    Tom,

    As I said in my first post, I am looking for a specific string that is
    coded as follows in all of our COBOL programs:

    77 WHAT-VER-ID PIC X(25) VALUE
    "@(#) VERSION 5.00".

    It might be interesting going forward to store this information in the
    "program header" for easier retrieval, although I've been told that
    using API's effectively on the AS400 is not for the faint of heart. Be
    that as it may, the utility I need to create must be able to look at
    existing program at our clients.

    In fact I've already been able to find another solution that temporary
    adds the version number to the end of the 8 character source member
    name before compilation. The 2 digit version number is then
    retrievable with DSPOBJD via the ODSRCM field in the QLIDOBJD format.
    But as I say this doesn't help with existing programs.

    The good news is that DMPOBJ creates a spoolfile which does contain
    the "@(#)" string. My next problem is how to parse it reasonably
    quickly. I use CPYSPLF to to copy the dump to a database file that I
    can look at in REXX. These files are quite big depending on the size
    of the original *PGM object. I just wonder how long it's going to take
    to parse one in REXX.

    If anyone has any ideas to speed this up they would be most welcome.

    Thanks

    Elliot




  13. Re: Finding a string literal in a *PGM object

    Elliot wrote:
    >
    > It might be interesting going forward to store this information in the
    > "program header" for easier retrieval, although I've been told that
    > using API's effectively on the AS400 is not for the faint of heart. Be
    > that as it may, the utility I need to create must be able to look at
    > existing program at our clients.
    >


    Another option for the future is to use ILE COBOL, and use the copyright
    information which is visible from DSPMOD, DSPPGM and DSPSRVPGM, as well
    as from an API (QBNLPGMI, for programs). For ILE COBOL, the value put
    into the copyright is taken from the SECURITY paragraph.
    IDENTIFICATION DIVISION.
    PROGRAM-ID. AACOBOL.
    SECURITY. @(#) VERSION 5.13.
    ENVIRONMENT DIVISION.
    DSPPGM AACOBOL DETAIL(*COPYRIGHT) shows " @(#) VERSION 5.13 "

    Using API's isn't that hard; it seems to me much easier for the faint of
    heart than locating @(#) in the DMPOBJ output, given that the string
    might be split across two lines, and given the (vanishingly?) faint
    possibility that the non-string data in the program might contain @(#).

  14. Re: Finding a string literal in a *PGM object

    > the "@(#)" string. My next problem is how to parse it reasonably
    > quickly. I use CPYSPLF to to copy the dump to a database file that I


    PASE also provides the SED command.


  15. Re: Finding a string literal in a *PGM object

    Barbara Morris wrote:

    > Using API's isn't that hard; it seems to me much easier for the faint of
    > heart than locating @(#) in the DMPOBJ output, given that the string
    > might be split across two lines, and given the (vanishingly?) faint
    > possibility that the non-string data in the program might contain @(#).


    This is an important point. I often see convoluted attempts to solve
    some problem where a couple APIs provide direct solutions. In this case,
    it might be as simple as running the Change Object Description
    (QLICOBJD) API before sipping a program and then running the Retrieve
    Object Description (QUSROBJD) API against the *PGM at the customer site
    to retrieve whatever value was stamped at creation. When Change Object
    Description is run, it could include the option to lock the object
    description. ILE copyright info is an excellent alternative or
    additional possibility.

    In either case, it's easier than trying to process a spooled file
    reliably. Fairly minor CL programs are all that's required at a minimum.

    --
    Tom Liotta
    http://zap.to/tl400

  16. Re: Finding a string literal in a *PGM object

    On 30 May, 19:25, Elliot wrote:
    > Tom,
    >
    > As I said in my first post, I am looking for a specific string that is
    > coded as follows in all of our COBOL programs:
    >
    > 77 WHAT-VER-ID PIC X(25) VALUE
    > "@(#) VERSION 5.00".
    >
    > It might be interesting going forward to store this information in the
    > "program header" for easier retrieval, although I've been told that
    > using API's effectively on the AS400 is not for the faint of heart. Be
    > that as it may, the utility I need to create must be able to look at
    > existing program at our clients.
    >
    > In fact I've already been able to find another solution that temporary
    > adds the version number to the end of the 8 character source member
    > name before compilation. The 2 digit version number is then
    > retrievable with DSPOBJD via the ODSRCM field in the QLIDOBJD format.
    > But as I say this doesn't help with existing programs.
    >
    > The good news is that DMPOBJ creates a spoolfile which does contain
    > the "@(#)" string. My next problem is how to parse it reasonably
    > quickly. I use CPYSPLF to to copy the dump to a database file that I
    > can look at in REXX. These files are quite big depending on the size
    > of the original *PGM object. I just wonder how long it's going to take
    > to parse one in REXX.
    >
    > If anyone has any ideas to speed this up they would be most welcome.
    >
    > Thanks
    >
    > Elliot


    I take on board the comments of Tom and Barbara but it sounds like you
    need to work out what versions the programs are before you can apply
    it to the copyright info etc.

    Not tried it but saving all the programs you need to examine to a save
    file and then ripping that (using a simple blocked RPG 10 liner) into
    a db file might give some performance improvements.

    Rob.


+ Reply to Thread