Annotation of os232sdk/toolkt20/c/samples/spy/spyutil.c, revision 1.1

1.1     ! root        1: /****************************** Module Header ******************************\
        !             2: * Module Name:  spyutil.c
        !             3: *
        !             4: * Created: Microsoft, IBM Corporation 1990
        !             5: *
        !             6: \***************************************************************************/
        !             7: 
        !             8: #include <os2.h>
        !             9: 
        !            10: BOOL FGuessValidPointer (PVOID pvoid, SHORT cbStruct, ULONG ulMemFlags) {
        !            11: 
        !            12:     ULONG   ulSize = (ULONG)cbStruct;
        !            13:     ULONG   ulFlags;
        !            14: 
        !            15:     if (DosQueryMem(pvoid, &ulSize, &ulFlags) != 0)
        !            16:         return (FALSE);     // Not valid memory
        !            17: 
        !            18:     if (ulSize < (ULONG)cbStruct)
        !            19:         return (FALSE);
        !            20: 
        !            21:     // Make sure right flags are set
        !            22:     if ((ulFlags & ulMemFlags) != ulMemFlags)
        !            23:         return (FALSE);
        !            24: 
        !            25:     // Not perfect, but maybe sufficent for now to say it is valid!
        !            26:     return (TRUE);
        !            27: }
        !            28: 
        !            29: BOOL   CopyStruct(UCHAR *pbSrc, UCHAR *pbDst, SHORT cb)
        !            30: {
        !            31: 
        !            32:     // For now simply make sure both source and destination pointers
        !            33:     // appear to be valid
        !            34:     if (!FGuessValidPointer(pbSrc, cb, PAG_READ) ||
        !            35:             !FGuessValidPointer(pbDst, cb, PAG_READ | PAG_WRITE))
        !            36:         return (FALSE);
        !            37: 
        !            38:     for (; cb > 0 ; cb--) {
        !            39:         *pbDst++ = *pbSrc++;
        !            40:     }
        !            41: 
        !            42:     return (TRUE);
        !            43: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.