Changeset 2827 for trunk/src


Ignore:
Timestamp:
Feb 19, 2000, 9:40:31 AM (26 years ago)
Author:
bird
Message:

g_tkExecPgm is overloaded, so we may change paramerters for a process later.

Location:
trunk/src/win32k
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/win32k/dev16/probkrnl.c

    r2823 r2827  
    1 /* $Id: probkrnl.c,v 1.9 2000-02-18 19:27:29 bird Exp $
     1/* $Id: probkrnl.c,v 1.10 2000-02-19 08:40:29 bird Exp $
    22 *
    33 * Description:   Autoprobes the os2krnl file and os2krnl[*].sym files.
     
    9494    {FALSE, -1,  8, "_ldrOpen",             -1,  -1, EPT_PROC},        /* 1 */
    9595    {FALSE, -1,  9, "_ldrClose",            -1,  -1, EPT_PROC},        /* 2 */
    96     {FALSE, -1, 12, "_LDRQAppType",         -1,  -1, EPT_PROC},        /* 3 */
     96    {FALSE, -1, 12, "_LDRQAppType",         -1,  -1, EPT_PROCIMPORT},  /* 3 */ /* to be removed? */
    9797    {FALSE, -1, 20, "_ldrEnum32bitRelRecs", -1,  -1, EPT_PROC},        /* 4 */
    9898    {FALSE, -1, 10, "_IOSftOpen",           -1,  -1, EPT_PROCIMPORT},  /* 5 */
     
    101101    {FALSE, -1, 12, "_IOSftReadAt",         -1,  -1, EPT_PROCIMPORT},  /* 8 */
    102102    {FALSE, -1, 13, "_IOSftWriteAt",        -1,  -1, EPT_PROCIMPORT},  /* 9 */
    103     {FALSE, -1, 11, "_VMAllocMem",          -1,  -1, EPT_PROCIMPORT},  /* 10 */
    104     {FALSE, -1, 11, "_VMGetOwner",          -1,  -1, EPT_PROCIMPORT},  /* 11 */
    105     {FALSE, -1, 11, "g_tkExecPgm",          -1,  -1, EPT_PROC}         /* 12 */
     103    {FALSE, -1, 12, "_SftFileSize",         -1,  -1, EPT_PROCIMPORT},  /* 10 */
     104    {FALSE, -1, 11, "_VMAllocMem",          -1,  -1, EPT_PROCIMPORT},  /* 11 */
     105    {FALSE, -1, 11, "_VMGetOwner",          -1,  -1, EPT_PROCIMPORT},  /* 12 */
     106    {FALSE, -1, 11, "g_tkExecPgm",          -1,  -1, EPT_PROC}         /* 13 */
    106107};
    107108
  • trunk/src/win32k/dev32/d32init.c

    r2823 r2827  
    1 /* $Id: d32init.c,v 1.9 2000-02-18 19:27:29 bird Exp $
     1/* $Id: d32init.c,v 1.10 2000-02-19 08:40:29 bird Exp $
    22 *
    33 * d32init.c - 32-bits init routines.
     
    566566                        (unsigned)myldrOpen,
    567567                        (unsigned)myldrClose,
    568                         (unsigned)myLDRQAppType,
     568                        0,//(unsigned)myLDRQAppType,
    569569                        (unsigned)myldrEnum32bitRelRecs,
     570                        0,
    570571                        0,
    571572                        0,
  • trunk/src/win32k/include/OS2KIO.h

    r2501 r2827  
    1 /* $Id: OS2KIO.h,v 1.3 2000-01-22 18:20:58 bird Exp $
     1/* $Id: OS2KIO.h,v 1.4 2000-02-19 08:40:30 bird Exp $
    22 *
    33 * OS/2 kernel IO: prototypes, typedefs and macros.
     
    1313/**
    1414 * Opens a given file.
    15  * @returns  NO_ERROR on success. other on error.
     15 * @returns  NO_ERROR on success. OS/2 error code on error.
    1616 * @param    pszFilename   Pointer to filename.
    1717 * @param    flOpenFlags   Open flags. (similar to DosOpen)
     
    3131/**
    3232 * Closes the specified file.
    33  * @returns  NO_ERROR on success. other on error.
     33 * @returns  NO_ERROR on success. OS/2 error code on error.
    3434 * @param    hFile      File handle - System File Number.
    3535 */
     
    4141/**
    4242 * Probably this function will expand a relative path to a full path.
    43  * @returns  NO_ERROR on success. other on error. (?)
     43 * @returns  NO_ERROR on success. OS/2 error code on error.
    4444 * @param    pszPath  Pointer to path to expand. Contains the full path upon return. (?)
    4545 *                    This buffer should probably be of CCHMAXPATH length.
     
    5252/**
    5353 * Read at a given offset in the a file.
    54  * @returns  NO_ERROR on success. other on error.
     54 * @returns  NO_ERROR on success. OS/2 error code on error.
    5555 * @param    hFile      File handle - System File Number.
    5656 * @param    pcbActual  Pointer to variable which upon input holds the number
     
    7171/**
    7272 * Write at a given offset in the a file.
    73  * @returns  NO_ERROR on success. other on error.
     73 * @returns  NO_ERROR on success. OS/2 error code on error.
    7474 * @param    hFile      File handle - System File Number.
    7575 * @param    pcbActual  Pointer to variable which upon input holds the number
     
    8787    );
    8888
     89
     90/**
     91 * Gets the filesize.
     92 * @returns   NO_ERROR on success; OS/2 error code on error.
     93 * @param     hFile    File handle - System File Number.
     94 * @param     pcbFile  Pointer to ULONG which will hold the file size upon return.
     95 */
     96APIRET KRNLCALL SftFileSize(
     97    SFN hFile,
     98    PULONG pcbFile
     99    );
     100
    89101#endif
  • trunk/src/win32k/include/probkrnl.h

    r2823 r2827  
    1 /* $Id: probkrnl.h,v 1.6 2000-02-18 19:27:29 bird Exp $
     1/* $Id: probkrnl.h,v 1.7 2000-02-19 08:40:30 bird Exp $
    22 *
    33 * Include file for ProbKrnl.
     
    1616*   Defined Constants And Macros                                               *
    1717*******************************************************************************/
    18 #define NUMBER_OF_PROCS      13
     18#define NUMBER_OF_PROCS      14
    1919#define MAX_LENGTH_NAME      32
    2020
  • trunk/src/win32k/ldr/calltab.asm

    r2823 r2827  
    1 ; $Id: calltab.asm,v 1.5 2000-02-18 19:27:30 bird Exp $
     1; $Id: calltab.asm,v 1.6 2000-02-19 08:40:30 bird Exp $
    22;
    33; callTab - Call back again table - table with entry for each function which is overrided.
     
    3030    public _IOSftReadAt@20
    3131    public _IOSftWriteAt@20
     32    public _SftFileSize@8
    3233
    3334    public _VMAllocMem@36
     
    9495_IOSftWriteAt@20 ENDP
    9596
     97_SftFileSize@8 PROC NEAR
     98    db MAXSIZE_PROLOG dup(0cch)
     99_SftFileSize@8 ENDP
     100
    96101
    97102_VMAllocMem@36 PROC NEAR
  • trunk/src/win32k/ldr/myldrOpen.cpp

    r2501 r2827  
    1 /* $Id: myldrOpen.cpp,v 1.6 2000-01-22 18:21:02 bird Exp $
     1/* $Id: myldrOpen.cpp,v 1.7 2000-02-19 08:40:30 bird Exp $
    22 *
    33 * myldrOpen - ldrOpen.
     
    1616#define INCL_NOPMAPI
    1717
     18#define INCL_OS2KRNL_IO
     19
    1820/*******************************************************************************
    1921*   Header Files                                                               *
     
    2123#include <os2.h>
    2224
     25#include "rmalloc.h"
    2326#include "malloc.h"
    2427#include <memory.h>
    2528#include <stdlib.h>
     29#include <string.h>
    2630
    2731#include "log.h"
     
    2933#include <exe386.h>
    3034#include "OS2Krnl.h"
     35#include "dev32.h"
    3136#include "ModuleBase.h"
    3237#include "pe2lx.h"
     
    3641#include "ldrCalls.h"
    3742#include "options.h"
     43#include "myExecPgm.h"
     44
     45
     46/*******************************************************************************
     47*   Internal Functions                                                         *
     48*******************************************************************************/
     49static unsigned getArgsLength(const char *pachArgs);
    3850
    3951
     
    4961    ULONG rc;
    5062
     63    /*
     64     * Try open the file (thats why this function is called anyway)
     65     */
    5166    rc = ldrOpen(phFile, pszFilename, param3);
    5267
     68    /* log sucesses */
    5369    if (rc == NO_ERROR)
    5470        kprintf(("ldrOpen:  phFile=%#.4x, flags=%#.8x, pszFn=%s\n", *phFile, param3, pszFilename));
    5571
     72    /*
     73     * Are we to intercept the loading?
     74     * - Only if open were succesful and one of the loaders are enabled.
     75     */
    5676    if (rc == NO_ERROR && (options.fElf || options.fPE != FLAGS_PE_NOT || options.fScript))
    5777    {
    58         static char achBuffer[sizeof(IMAGE_DOS_HEADER)];
    59         PIMAGE_DOS_HEADER   pMzHdr = (PIMAGE_DOS_HEADER)&achBuffer[0];
    60         PIMAGE_NT_HEADERS   pNtHdrs = (PIMAGE_NT_HEADERS)&achBuffer[0]; /* oops. Last accessible field is OptionalHeader.FileAlignment */
    61         char               *pach = &achBuffer[0];
    62 
    63         /**
     78        char               *pszBuffer = (char*)rmalloc(640);        /* Read buffer. */
     79        PIMAGE_DOS_HEADER   pMzHdr = (PIMAGE_DOS_HEADER)pszBuffer;  /* Pointer to the buffer as it were a dosheader. */
     80        PIMAGE_NT_HEADERS   pNtHdrs = (PIMAGE_NT_HEADERS)pszBuffer; /* Pointer to the buffer as if it were an NT header. */
     81        char               *pach = pszBuffer;                       /* Finally an pointer to the buffer as if it were chars.. (which it is!) */
     82        PEXECPGMBUFFER      pBuffer;                                /* Pointer to a buffer containing the programname and arguments. */
     83                                                                    /* For scripts and PE.EXE this has to be changed to have correct */
     84                                                                    /* parameters sendt in to the program. */
     85        unsigned            cchRead = sizeof(IMAGE_DOS_HEADER);     /* Amount of the buffer which contains valid data. */
     86        unsigned            cbFile;                                 /* Filesize (0xffffffff if call to SftFileSize failed - should _never_ happen though)  */
     87
     88        /*
     89         * Verify that rmalloc completed successfully.
     90         */
     91        if (pszBuffer == NULL)
     92        {
     93            kprintf(("ldrOpen: rmalloc(1024) failed\n"));
     94            return NO_ERROR;
     95        }
     96
     97        /*
     98         * Try get the filesize
     99         */
     100        /*
     101        rc = SftFileSize(*phFile, (PULONG)SSToDS(&cbFile));
     102        if (rc != NO_ERROR)
     103        {
     104            kprintf(("ldrOpen: SftFileSize failed with rc=%d\n", rc));
     105        */
     106            cbFile = (unsigned)~0;
     107        /*
     108        } */
     109
     110        /*
    64111         * See if this is an recognizable module format.
    65112         * This costs up to two disk reads!
    66113         */
    67         rc = ldrRead(*phFile, 0UL, pMzHdr, 0UL, sizeof(IMAGE_DOS_HEADER), NULL);
     114        rc = ldrRead(*phFile, 0UL, pMzHdr, 0UL, cchRead, NULL);
    68115        if (rc == NO_ERROR)
    69116        {
     117            /*
     118             * PE header?
     119             *  - If DOS Magic is found AND a valid e_lfanew (offset of NE/LX/LE/PE header) is found
     120             *  - OR if PE siganture is found.
     121             */
    70122            if ((pMzHdr->e_magic == IMAGE_DOS_SIGNATURE &&
    71123                 pMzHdr->e_lfanew > sizeof(IMAGE_DOS_HEADER) && pMzHdr->e_lfanew < 0x04000000UL) /* Larger than 64 bytes and less that 64MB. */
    72124                || *(PULONG)pach == IMAGE_NT_SIGNATURE)
    73             {   /* MZ or PE header found */
     125            {   /*
     126                 * MZ or PE header found
     127                 */
     128
     129                /* if PE loading is diable return to the caller */
    74130                if (options.fPE == FLAGS_PE_NOT)
     131                {
     132                    free(pszBuffer);
    75133                    return NO_ERROR;
    76 
     134                }
     135
     136                /*
     137                 * Read the PE header if it isn't what we allready have!
     138                 */
     139                cchRead = sizeof(IMAGE_NT_HEADERS);
    77140                if (*(PULONG)pach != IMAGE_NT_SIGNATURE)
    78                     rc = ldrRead(*phFile, pMzHdr->e_lfanew, pach, 0UL, sizeof(achBuffer), NULL);
    79 
     141                    rc = ldrRead(*phFile, pMzHdr->e_lfanew, pach, 0UL, cchRead, NULL);
     142                else
     143                    rc = ldrRead(*phFile, 0UL, pach, 0UL, cchRead, NULL);
     144
     145                /*
     146                 * If successfully read, and a PE signature is present the continue and try load it!
     147                 * Else don't do anything, simply return NO_ERROR to the caller. (probably NE or LX exec)
     148                 */
    80149                if (rc == NO_ERROR && *(PULONG)pach == IMAGE_NT_SIGNATURE)
    81                 {   /* PE signature found */
     150                {   /*
     151                     * PE signature found.
     152                     */
    82153                    kprintf(("ldrOpen: PE executable...\n"));
     154
     155                    /*
     156                     * PE2LX?
     157                     *  - When PE2LX flag is set
     158                     *  - OR when the MIXED flag is set and the image is with the first 64MB of memory.
     159                     */
    83160                    if (options.fPE == FLAGS_PE_PE2LX
    84161                        || (options.fPE == FLAGS_PE_MIXED
     
    88165                            )
    89166                        )
    90                     {   /* pe2lx */
     167                    {   /*
     168                         * Pe2Lx (Ring0 of course)
     169                         * - Create a Pe2Lx class,
     170                         * - initiate it
     171                         * - Add the module to the module tree so we may find it later...
     172                         * - Set the handle state to 'our'.
     173                         */
    91174                        Pe2Lx * pPe2Lx = new Pe2Lx(*phFile);
    92175                        if (pPe2Lx != NULL)
     
    113196                    }
    114197                    else
     198                    {
     199                        /*
     200                         * Starting of PE.EXE enable?
     201                         */
    115202                        if (options.fPE == FLAGS_PE_PE || options.fPE == FLAGS_PE_MIXED)
    116                         {   /* pe.exe */
     203                        {   /*
     204                             * pe.exe - need the path!
     205                             */
    117206                            kprintf(("ldrOpen: pe.exe - opening\n"));
    118207                            ldrClose(*phFile);
    119208                            rc = ldrOpen(phFile, "pe.exe", param3);  /* path....! problems! */
    120209                            kprintf(("ldrOpen: pe.exe - open returned with rc = %d\n", rc));
     210                            free(pszBuffer);
    121211                            return rc;
    122212                        }
     213                    }
    123214                }
    124                 rc = NO_ERROR;
     215                free(pszBuffer);
     216                return NO_ERROR;
    125217            }
    126218            else
    127219            {
     220                /*
     221                 * ELF image?
     222                 */
    128223                if (pach[0] == ELFMAG0 && pach[1] == ELFMAG1 && pach[2] == ELFMAG2 && pach[3] == ELFMAG3)
    129224                {
    130                     /* ELF signature found */
     225                    /*
     226                     * ELF signature found.
     227                     */
    131228                    kprintf(("ldrOpen: ELF executable! - not implemented yet!\n"));
     229
     230                    /*
     231                     * Do nothing more yet. NEED AN ELF LOADER!!!
     232                     */
     233                    free(pszBuffer);
     234                    return NO_ERROR;
    132235                }
    133                 else
    134                     if (*pach == '#' && pach[1] == '!')
     236            }
     237
     238            /*
     239             * Only unreconized files and readerror passes this point!
     240             *
     241             * * Fileformats with lower priority should reside here. *
     242             *
     243             */
     244
     245            /*
     246             * If the initial readoperation failed try to read a smaller amount, in case it is a small script...
     247             * 4 bytes is a small amount isn't it?
     248             */
     249            if (rc != NO_ERROR)
     250            {
     251                kprintf(("ldrOpen: first ldrread failed with rc=%d. tries to read 4 byte.\n", rc));
     252                cchRead = 4;
     253                if ((rc = ldrRead(*phFile, 0UL, pach, 0UL, cchRead, NULL)) != NO_ERROR)
     254                    kprintf(("ldrOpen: second ldrread failed with rc=%d.\n ", rc));
     255            }
     256
     257            /*
     258             * Now we'll try again, UNIX styled script?
     259             */
     260            if (rc == NO_ERROR && *pach == '#' && pach[1] == '!')
     261            {
     262                /*
     263                 * UNIX styled script?
     264                 * FIXME! Must be more than 64 bytes long?
     265                 *        No options!
     266                 *        Firstline < 64 bytes!
     267                 */
     268                kprintf(("ldrOpen: unix script?\n"));
     269
     270                cchRead = min(cbFile, 256);
     271                rc = ldrRead(*phFile, 0UL, pach, 0UL, cchRead, NULL);
     272                if (rc != NO_ERROR)
     273                {
     274                    char *pszStart = pach+2;
     275
     276                    /* Make sure we don't read to much... */
     277                    pszBuffer[cchRead] = '\0';
     278
     279                    /*
     280                     * Skip blanks
     281                     */
     282                    pszStart = pszBuffer + 2; /* skips the "#!" stuff. */
     283                    while (*pszStart != '\0' && (*pszStart == ' ' || *pszStart == '\t'))
     284                        pszStart++;
     285
     286                    /* anything left on the line? */
     287                    if (*pszStart != '\0' && *pszStart != '\r' && *pszStart != '\n')
    135288                    {
    136                         /* unix styled script...? Must be more than 64 bytes long? No options. firstline < 64 bytes. */
    137                         char *pszStart = pach+2;
    138                         char *pszEnd;
    139                         kprintf(("ldrOpen: unix script?\n"));
    140 
    141                         achBuffer[sizeof(achBuffer)-1] = '\0'; /* just to make sure we don't read to much... */
    142 
    143                         /* skip blanks */
    144                         while (*pszStart != '\0' && (*pszStart == ' ' || *pszStart == '\t'))
    145                             pszStart++;
    146                         if (*pszStart != '\0' && *pszStart != '\r' && *pszStart != '\n')
    147                         {   /* find end-of-word */
    148                             pszEnd = pszStart + 1;
    149                             while (*pszEnd != '\0' && *pszEnd != '\n' && *pszEnd != '\r'
    150                                    && *pszEnd != '\t' && *pszEnd != ' ')
    151                                 pszEnd++;
    152                             if (*pszEnd != '\0')
     289                        char *      pszEnd;         /* Pointer to the end of the string(s) when the next step is finished. */
     290                        //char *      pszFirstArg;    /* Pointer to the first argument, the one after the interpreter name. */
     291                        unsigned    cchToAdd = 1;   /* Chars to add */
     292                        int         f = TRUE;       /* flag which tells me if I have just closed the last argument.  */
     293                        /*
     294                         * find linesize and make parameters ready for copying
     295                         */
     296                        pszEnd = pszStart;
     297                        //pszFirstArg = NULL;
     298                        while (*pszEnd != '\0' && *pszEnd != '\r' && *pszEnd != '\n')
     299                        {
     300                            if (f)
    153301                            {
    154                                 *pszEnd = '\0';
    155                                 kprintf(("ldrOpen: unix script - opening %s\n", pszStart));
    156                                 ldrClose(*phFile);
    157                                 rc = ldrOpen(phFile, pszStart, param3);
    158                                 kprintf(("ldrOpen: unix script - open returned with rc = %d\n", rc));
     302                                f = FALSE;
     303                                //if (pszFirstArg != NULL) pszFirstArg = pszEnd + 1;
     304                            }
     305                            else if (!f && (*pszEnd == ' ' || *pszEnd == '\t'))
     306                            {
     307                                 *pszEnd = '\0';
     308                                 f = TRUE;
     309                            }
     310
     311                            /* next */
     312                            pszEnd++;
     313                            cchToAdd++;
     314                        }
     315                        *pszEnd = '\0';
     316
     317                        /*
     318                         * Find the ExecPgm buffer.
     319                         */
     320                        pBuffer = QueryBufferPointerFromFilename(pszFilename);
     321                        if (pBuffer != NULL)
     322                        {
     323                            unsigned cchArguments = getArgsLength(pBuffer->achArgs);
     324                            kprintf(("ldrOpen: debug1\n"));
     325
     326                            /*
     327                             * Is there enough space in the struct?
     328                             */
     329                            if (cchArguments + cchToAdd < sizeof(pBuffer->achArgs))
     330                            {
     331                                kprintf(("ldrOpen: debug2\n"));
     332                                /*
     333                                 * Open the interpreter.
     334                                 */
     335                                rc = ldrClose(*phFile);
     336                                rc = ldrOpen(phFile, pszStart, param3); /* FIXME, recusion! check that name not equal! Use flags to prevent race? */
     337                                if (rc == NO_ERROR)
     338                                {
     339                                    kprintf(("ldrOpen: debug3\n"));
     340                                    /* Make space for the addition arguments. */
     341                                    memmove(&pBuffer->achArgs[cchToAdd], &pBuffer->achArgs[0], cchArguments);
     342                                    memcpy(&pBuffer->achArgs[0], pszBuffer, cchToAdd);
     343                                    kprintf(("ldrOpen: debug4\n"));
     344                                }
     345                                else
     346                                    kprintf(("ldrOpen: failed to open interpreter (%s), rc=%d\n", pszStart, rc));
     347                            }
     348                            else
     349                            {
     350                                kprintf(("ldrOpen: Argument buffer too small, %d\n", cchArguments + cchToAdd));
     351                                rc = ERROR_BAD_EXE_FORMAT;
    159352                            }
    160353                        }
    161354                        else
    162                             kprintf(("ldrOpen: unix script - unexpected end of line/file. (line: %.10s\n", pach));
     355                        {
     356                            kprintf(("ldrOpen: QueryBufferPointerFromFilename failed.\n"));
     357                            rc = ERROR_BAD_EXE_FORMAT; /*?*/
     358                        }
    163359                    }
    164             }
     360                    else
     361                    {
     362                        kprintf(("ldrOpen: no interpereter on the first line.\n"));
     363                        rc = ERROR_BAD_EXE_FORMAT; /*?*/
     364                    }
     365                }
     366                else
     367                {
     368                    kprintf(("ldrOpen: read of min(cbFile, 256) = %d failed, rc = %d\n", cchRead, rc));
     369                }
     370            } /* else inn other formats here. */
    165371        }
    166372        else
     
    169375            rc = NO_ERROR;
    170376        }
     377        free(pszBuffer);
    171378    }
    172379    return rc;
    173380}
     381
     382
     383/**
     384 * Get the lenght of the arguments.
     385 * @returns   Lenght in char, includes the two '\0's.
     386 * @param     pachArgs  Pointer to the ASCIIZs which makes up the arguments.
     387 * @status    completely implemented.
     388 * @author    knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
     389 */
     390static unsigned getArgsLength(const char *pachArgs)
     391{
     392    unsigned    cch = 1;
     393    const char *psz = pachArgs;
     394
     395    while (*psz != '\0')
     396    {
     397        register unsigned cch2 = strlen(psz);
     398        cch += cch2;
     399        psz += cch2 + 1;
     400    }
     401
     402    return cch;
     403}
  • trunk/src/win32k/ldr/mytkExecPgm.asm

    r2825 r2827  
    1 ; $Id: mytkExecPgm.asm,v 1.2 2000-02-18 19:54:19 bird Exp $
     1; $Id: mytkExecPgm.asm,v 1.3 2000-02-19 08:40:31 bird Exp $
    22;
    33; mytkExecPgm - tkExecPgm overload
     
    1717;   Imported Functions
    1818;
     19DATA32 SEGMENT
    1920    extrn  g_tkExecPgm:PROC
     21DATA32 ENDS
    2022    extrn  AcquireBuffer:PROC
    2123    extrn  ReleaseBuffer:PROC
     
    5456;   struct Buffer
    5557;   {
    56 ;       char szFilename[261]; /* offset 0   */
    57 ;       char szArg[4096-261]; /* offset 261 */
     58;       char szFilename[261];  /* offset 0   */
     59;       char achArg[1536-261]; /* offset 261 */
    5860;   };
    5961;
     
    7779    push    edi
    7880
    79     ; init local variables
    80     mov     [ebp+pBuffer], 0
     81IF 0
     82;    ; Check if this overloading has anything too say, after all it is using some stack space!
     83;    jmp     mytkExecPgm_CalltkExecPgm_X1
     84ENDIF
     85
     86    ; parameter validations
     87    mov     ax, ds                      ; pointer to filename
     88    cmp     ax, 4
     89    jb      mytkExecPgm_CalltkExecPgm_X1
     90
     91    ; This test is currently disabled. We'll pass on an empty string if the argument pointer is NULL.
     92    ; Hopefully an empty string is treated equally to an NULL pointer.
     93;    cmp     di, 4
     94;    jl      mytkExecPgm_CalltkExecPgm_X1
    8195
    8296    ; filename length
     
    86100    movzx   edi, dx                     ; es:di is now filename address (ds:dx).
    87101    mov     ecx, 0ffffffffh
     102    cld
    88103    repne scasb
    89104    not     ecx
     
    98113    ;
    99114    ; args length
    100     ;
    101     pop     edi
    102     push    edi
     115    ; Note: the arguments are a series of ASCIIZs ended by an empty string (ie. '\0').
     116    ;
     117    pop     edi
     118    push    edi
     119    xor     ecx, ecx
     120    cmp     di, 4                       ; The argument might me a invalid pointer...
     121    jb      mytkExecPgm_CalltkExecPgm_1
    103122    mov     es, di
    104     movzx   edi, si                     ; es:di is now args address (di:si), eax is still 0
    105     mov     ecx, 0ffffffffh
    106     repne scasb
     123    movzx   edi, si                     ; es:edi is now args address (di:si), eax is still 0
     124    dec     ecx
     125    cld
     126mytkExecPgm_CalltkExecPgm_loop:         ; loop true all ASCIIZ strings
     127    repne scasb                         ; scans forwards until '\0' is read. es:edi is pointing at the char after the '\0'.
     128    cmp     byte ptr es:[edi], 0        ; is this char '\0' ? stop looping : loop once more;
     129    jnz     mytkExecPgm_CalltkExecPgm_loop
     130    dec     ecx                         ; update count - count terminating zero too
    107131    not     ecx
    108132
     133mytkExecPgm_CalltkExecPgm_1:
    109134    mov     [ebp+cchArgs], ecx
    110135    add     ecx, [ebp+cchFilename]      ; filename
    111136    add     ecx, 3 + 260                ;  260 = new argument from a scrip file or something.
    112137                                        ;    3 = two '\0's and a space after added argument.
    113     cmp     ecx, 4096                   ; 4096 = Buffersize.  FIXME! Define this!!!
     138    cmp     ecx, 1536                   ; 1536 = Buffersize.  FIXME! Define this!!!
    114139    jae     mytkExecPgm_CalltkExecPgm_X1; jmp if argument + file + new file > buffer size
    115140
     
    139164    movzx   esi, dx                     ; ds:si  Filename pointer (input ds:dx)
    140165    mov     ecx, [ebp+cchFilename]
    141     repnz movsb
     166    cld
     167    rep movsb
    142168
    143169    ;
     
    149175    push    edi
    150176    push    esi
     177    add     eax, 261                    ; we'll use eax in the branch
     178    cmp     di, 4
     179    jb      mytkExecPgm_CalltkExecPgm_2
     180    and     esi, 00000ffffh             ; remove high part of the register
    151181    mov     ds, di                      ; ds:si -> arguments
    152     mov     edi, eax
    153     add     edi, 261                    ; es:di -> pBuffer + 261
     182    mov     edi, eax                    ; es:di -> pBuffer + 261
    154183    mov     ecx, [ebp+cchArgs]
    155     repnz movsb
     184    cld
     185    rep movsb
     186    jmp     mytkExecPgm_CalltkExecPgm_3
     187
     188mytkExecPgm_CalltkExecPgm_2:
     189    mov     byte ptr es:[eax], 0        ; Terminate the empty string!
    156190
    157191    ;
    158192    ; Set Pointers, pszFilename and pszArguments
    159193    ;
     194mytkExecPgm_CalltkExecPgm_3:
    160195    mov     ax, seg FLAT:DATA32
    161196    mov     ds, ax
     
    197232    ; Call g_tkExecPgm
    198233    ;
    199     call far ptr FLAT:g_tkExecPgm;WARNING far call!!!
     234    push    cs
     235    call    near ptr FLAT:g_tkExecPgm
    200236    pushfd
    201237
     
    235271
    236272mytkExecPgm_CalltkExecPgm:
    237     call    far ptr FLAT:g_tkExecPgm
     273    call    far ptr FLAT:g_tkExecPgmStub
    238274    leave
    239275    retf
    240276mytkExecPgm ENDP
    241277
     278
     279;;
     280; Stub which jumps to g_tkExecPgmStub.
     281; (This way I will hopefully get the right selector.)
     282g_tkExecPgmStub PROC FAR
     283    jmp     near ptr FLAT:g_tkExecPgm
     284g_tkExecPgmStub ENDP
     285
     286
    242287CODE32 ENDS
    243288END
  • trunk/src/win32k/misc/asmutils.asm

    r1467 r2827  
    1 ; $Id: asmutils.asm,v 1.3 1999-10-27 02:02:59 bird Exp $
     1; $Id: asmutils.asm,v 1.4 2000-02-19 08:40:31 bird Exp $
    22;
    33; asmutils - assembly utility functions
     
    2424    public GetSS
    2525    public Int3
    26     public _memrevmov@12
    27     public _memmov@12
     26;    public _memrevmov@12
     27;    public _memmov@12
    2828;    public DisableInterrupts
    2929;    public EnableInterrupts
     
    9494;EnableInterrupts ENDP
    9595
    96 
     96if 0
    9797;void __stdcall memrevmov(void *pTo, void* pFrom, unsigned int Len);
    9898pTo     EQU dword ptr [ebp+08]
     
    193193    jmp memmov_end
    194194_memmov@12 ENDP
    195 
     195endif
    196196
    197197CODE32 ends
  • trunk/src/win32k/misc/buffer.asm

    r2823 r2827  
    1 ; $Id: buffer.asm,v 1.2 2000-02-18 19:27:31 bird Exp $
     1; $Id: buffer.asm,v 1.3 2000-02-19 08:40:31 bird Exp $
    22;
    33; Simple resident buffer for use when overloading tkExecPgm.
     
    88;
    99    .486p
     10
     11
     12;
     13;   Defined Constants And Macros
     14;
     15NBR_BUFFERS     EQU 20
     16BUFFER_SIZE     EQU 1536
    1017
    1118;
     
    2027    public ReleaseBuffer
    2128    public QueryBufferSegmentOffset
    22 ;    public cbBuffer
     29    public QueryBufferPointerFromFilename
     30
     31
     32;
     33;   Imported Functions
     34;
     35    extrn stricmp:PROC
    2336
    2437
     
    2740;
    2841DATA16 SEGMENT
    29 ;DATA32 SEGMENT
    30 achBuffer   db 4096 dup(?)
     42aachBuffer  db BUFFER_SIZE*NBR_BUFFERS dup(?) ; The buffer
    3143DATA16 ENDS
    32 ;DATA32 ENDS
    33 
    34 ;DATA16 SEGMENT
     44
    3545DATA32 SEGMENT
    36 fBuffer     db 0            ;Access "semaphore"
     46afBuffer    db NBR_BUFFERS dup(0)       ; Access "semaphore"
     47                                        ; 0 - not in use
     48                                        ; 1 - in use
    3749DATA32 ENDS
    3850
     
    4658; @returns   Pointer to buffer
    4759; @uses      eax
    48 ; @sketch    if fBuffer == 0 then
     60; @sketch    if AfBuffer == 0 then
    4961;               ok!
    5062;               fBuffer <- 1
     
    5971AcquireBuffer PROC NEAR
    6072    push    ds
    61     ;mov     ax,
    62 ;    push    FLAT
    63     pop     ds
    64     ;mov     ds, ax
     73    push    ecx
     74    push    edx
     75
     76    ; make ds flat
     77    mov     ax, seg FLAT:DATA32
     78    mov     ds, ax
    6579    ASSUME  DS:FLAT
    66     mov     al, 0
    67     mov     ah, 1
    68     lock cmpxchg fBuffer, ah
    69     jnz     AcquireBuffer_nok
    70 AcquireBuffer_ok:
    71     mov     eax, offset achBuffer
    72     pop     ds
    73     ret
     80
     81    ; loop thru all buffers and try reserve one
     82    mov     ah, 1                       ; afBuffer[ecx] is set to this value (if equal to al)
     83    mov     ecx, NBR_BUFFERS            ; interations.
     84    mov     edx, offset FLAT:afBuffer
     85    add     edx, ecx
     86AcquireBuffer_loop:
     87    dec     edx
     88    mov     al, 0                       ; afBuffer[ecx] should have this value
     89    lock cmpxchg [edx], ah
     90    je      AcquireBuffer_ok
     91    loop    AcquireBuffer_loop
     92
     93    ; failure
    7494AcquireBuffer_nok:
    7595    xor     eax,eax
     96    jmp     AcquireBuffer_ret
     97
     98    ;success - calc buffer pointer
     99AcquireBuffer_ok:
     100    mov     eax, BUFFER_SIZE
     101    dec     ecx
     102    imul    eax, ecx                    ; ecx has the buffer number
     103    add     eax, offset FLAT:aachBuffer
     104AcquireBuffer_ret:
     105    pop     edx
     106    pop     ecx
    76107    pop     ds
    77108    ret
     
    85116; @uses      eax
    86117; @equiv
    87 ; @sketch    if eax == achBuffer then
    88 ;                set fBuffer to 0 if 1.
    89 ;                if fBuffer was not 1 then fail with rc = 87!
    90 ;            else
    91 ;                fail with rc = 87
    92 ;            endif
    93118; @status
    94119; @author    knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
     
    97122    ASSUME  DS:NOTHING
    98123    push    ds
    99 ;    mov     ax, DATA16
    100 ;    mov     ds, ax
    101 ;    push    FLAT
    102     pop     ds
     124    push    ecx
     125    push    edx
     126
     127    ; make ds flat
     128    push    eax
     129    mov     ax, seg FLAT:DATA32
     130    mov     ds, ax
    103131    ASSUME  DS:FLAT
    104     cmp     eax, offset achBuffer
    105     jne     ReleaseBuffer_nok
     132    pop     eax
     133    push    eax
     134
     135    ; validate input and calc buffer number
     136    cmp     eax, offset FLAT:aachBuffer
     137    jl      ReleaseBuffer_nok           ; if eax (buffer pointer) is less than the first buffer, then fail.
     138    sub     eax, offset FLAT:aachBuffer ; eax <- offset to buffer from aachBuffer
     139    xor     edx, edx
     140    mov     ecx, BUFFER_SIZE
     141    div     ecx                         ; eax <- buffer number, edx <- offset into buffer (should be NULL)
     142    or      edx, edx
     143    jnz     ReleaseBuffer_nok           ; if offset into buffer not 0 the fail.
     144    cmp     eax, NBR_BUFFERS
     145    jge     ReleaseBuffer_nok           ; if buffernumber >= number of buffers then fail.
     146
     147    ; unlock buffer - if locked
     148    mov     edx, eax
     149    add     edx, offset FLAT:afBuffer   ; ds:edx  points at buffer "semaphore"
    106150    mov     al, 1
    107151    mov     ah, 0
    108     lock cmpxchg fBuffer, ah
    109     jnz     ReleaseBuffer_nok
     152    lock cmpxchg [edx], ah
     153    jne     ReleaseBuffer_nok           ; fail if buffer was not locked
     154
    110155ReleaseBuffer_ok:
    111     xor     eax, eax
    112     pop     ds
    113     ret
     156    ;swipe out buffer
     157    pop     eax
     158    push    edi
     159    push    es
     160    mov     edi, eax
     161    mov     ax, ds
     162    mov     es, ax
     163    ASSUME  es:FLAT
     164    xor     eax, eax                    ; ecx is allready BUFFER_SIZE
     165    rep     stosb
     166    pop     es
     167    pop     edi
     168
     169    ;return successfully
     170    jmp     ReleaseBuffer_ret
     171
    114172ReleaseBuffer_nok:
     173    ;failure
     174    pop     eax
    115175    mov     eax, 87 ;some error
     176
     177ReleaseBuffer_ret:
     178    pop     edx
     179    pop     ecx
    116180    pop     ds
    117181    ret
     
    132196    ASSUME  DS:NOTHING
    133197    push    ds
    134 ;    mov     ax, DATA16
    135 ;    mov     ds, ax
    136 ;    push    FLAT
    137     pop     ds
     198
     199    ; make ds FLAT
     200    push    eax
     201    mov     ax, seg FLAT:DATA32
     202    mov     ds, ax
    138203    ASSUME  DS:FLAT
    139     cmp     eax, offset achBuffer
    140     jne     QueryBufferSegmentOffset_nok
    141     cmp     fBuffer, 1
    142     jne     QueryBufferSegmentOffset_nok
     204    pop     eax
     205
     206    ; validate parameter and calc offset relative to aachBuffer
     207    cmp     eax, offset FLAT:aachBuffer
     208    jl      QueryBufferSegmentOffset_nok
     209    sub     eax, offset FLAT:aachBuffer
     210    cmp     eax, NBR_BUFFERS * BUFFER_SIZE
     211    jge     QueryBufferSegmentOffset_nok
    143212
    144213QueryBufferSegmentOffset_ok:
    145     xor     eax, eax
    146214    jmp     far ptr CODE16:GetBufferSegmentOffset16
    147215QueryBufferSegmentOffset_Back::
     
    156224
    157225
     226;;
     227; Special function which checks all used buffers for the string passed in in eax.
     228; @cproto    PCHAR _Optlink QueryBufferPointerFromFilename(const char *pszFilename)
     229; @returns   Pointer to Buffer. NULL on error/notfound.
     230; @param     ds:eax   Pointer to filename. The filename will later be compared to the string at buffer start.
     231;                     Currently this parameter is not used, since there is only one buffer.
     232; @uses      eax.
     233; @sketch
     234; @status    completely implemented
     235; @author    knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
     236; @remark    assumes ds flat on call.
     237QueryBufferPointerFromFilename PROC NEAR
     238    ASSUME  cs:CODE32, ds:FLAT
     239    push    ecx
     240    push    edx
     241    push    ebx
     242
     243    ; loop thru all buffers until found or non left
     244    mov     ecx, NBR_BUFFERS
     245    mov     edx, BUFFER_SIZE
     246    imul    edx, ecx                    ; edx <- sizeof(aachBuffer)
     247    add     edx, offset FLAT:aachBuffer ; edx points at the first byte after the buffers.
     248    mov     ebx, offset FLAT:afBuffer
     249    add     ebx, ecx                    ; edx points at the first byte after the "semaphore" array (afBuffer).
     250QueryBufferPointerFromFilename_loop:
     251    sub     edx, BUFFER_SIZE            ; edx points at the buffer being concidered.
     252    dec     ebx                         ; ebx points at the "semaphore" for the buffer being concidered.
     253    cmp     byte ptr [edx], 1           ; Is buffer in use?
     254    jne     QueryBufferPointerFromFilename_next
     255
     256    ; buffer is active - lets compare
     257    push    eax
     258    push    ecx
     259    push    edx
     260    call    stricmp
     261    pop     edx
     262    pop     ecx
     263    or      eax, eax
     264    jz      QueryBufferPointerFromFilename_found
     265    pop     eax
     266
     267QueryBufferPointerFromFilename_next:
     268    loop QueryBufferPointerFromFilename_loop
     269    ; when we exit this loop we have failed!
     270
     271QueryBufferPointerFromFilename_nok:
     272    ; The buffer was not found, return NULL pointer.
     273    xor     eax, eax
     274    pop     edx
     275    pop     ecx
     276    ret
     277
     278QueryBufferPointerFromFilename_found:
     279    ; The buffer was found, return the pointer to it!
     280    pop     eax
     281    mov     eax, edx
     282    pop     edx
     283    pop     ecx
     284    ret
     285
     286QueryBufferPointerFromFilename ENDP
     287
     288
     289
     290
    158291CODE32 ENDS
    159292
     293
    160294CODE16 SEGMENT
    161 
    162 ;;
    163 ; Gets the segment(->es) and offset(->ax) of the achBuffer.
     295;;
     296; Gets the segment(->es) and offset(+ax -> ax) of the achBuffer.
     297; @param    ax  offset to buffer relative to aachBuffer
    164298; Jumps back to GetBufferOffset32
    165299GetBufferSegmentOffset16:
    166300    ASSUME CS:CODE16, DS:NOTHING
    167     mov     ax, seg achBuffer
     301    push    ax
     302    mov     ax, seg aachBuffer
    168303    mov     es, ax
    169     mov     ax, offset achBuffer
     304    pop     ax
     305    add     ax, offset aachBuffer
    170306    jmp     far ptr FLAT:QueryBufferSegmentOffset_Back
    171307CODE16 ENDS
  • trunk/src/win32k/win32k.def

    r1678 r2827  
    1717    CODE32          class 'CODE'
    1818    CALLTAB         class 'DATA'
     19;    CALLTAB         class 'CODE' WRITABLE
    1920    DATA32          class 'DATA'
    2021    c_common        class 'DATA'
Note: See TracChangeset for help on using the changeset viewer.