Changeset 2838 for trunk/src/win32k/ldr


Ignore:
Timestamp:
Feb 21, 2000, 10:24:02 AM (26 years ago)
Author:
bird
Message:

Nearly there!

Location:
trunk/src/win32k/ldr
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/win32k/ldr/calltab.asm

    r2836 r2838  
    1 ; $Id: calltab.asm,v 1.9 2000-02-21 04:45:47 bird Exp $
     1; $Id: calltab.asm,v 1.10 2000-02-21 09:24:01 bird Exp $
    22;
    33; callTab - Call back again table - table with entry for each function which is overrided.
     
    119119f_FuStrLenZ ENDP
    120120
     121f_FuStrLen PROC FAR
     122    db MAXSIZE_PROLOG dup(0cch)
     123f_FuStrLen ENDP
     124
    121125f_FuBuff PROC FAR
    122126    db MAXSIZE_PROLOG dup(0cch)
  • trunk/src/win32k/ldr/myldrOpen.cpp

    r2837 r2838  
    1 /* $Id: myldrOpen.cpp,v 1.9 2000-02-21 05:00:52 bird Exp $
     1/* $Id: myldrOpen.cpp,v 1.10 2000-02-21 09:24:01 bird Exp $
    22 *
    33 * myldrOpen - ldrOpen.
     
    4343#include "myExecPgm.h"
    4444
     45/*******************************************************************************
     46*   Global Variables                                                           *
     47*******************************************************************************/
     48extern BOOL fQAppType;                  /* From LDRQAppType */
    4549
    4650/*******************************************************************************
     
    98102         * Try get the filesize
    99103         */
    100         /*
    101104        rc = SftFileSize(*phFile, (PULONG)SSToDS(&cbFile));
    102105        if (rc != NO_ERROR)
    103106        {
    104107            kprintf(("ldrOpen: SftFileSize failed with rc=%d\n", rc));
    105         */
    106108            cbFile = (unsigned)~0;
    107         /*
    108         } */
     109        }
    109110
    110111        /*
     
    235236                }
    236237            }
    237 
     238        }
     239
     240        /*
     241         * Only unreconized files and readerror passes this point!
     242         *
     243         * * Fileformats with lower priority should reside here. *
     244         *
     245         */
     246
     247        /*
     248         * If the initial readoperation failed try to read a smaller amount, in case it is a small script...
     249         * 4 bytes is a small amount isn't it?
     250         */
     251        if (rc != NO_ERROR)
     252        {
     253            kprintf(("ldrOpen: first ldrread failed with rc=%d. tries to read 4 byte.\n", rc));
     254            cchRead = 4;
     255            if ((rc = ldrRead(*phFile, 0UL, pach, 0UL, cchRead, NULL)) != NO_ERROR)
     256                kprintf(("ldrOpen: second ldrread failed with rc=%d.\n ", rc));
     257        }
     258
     259        /*
     260         * Now we'll try again, UNIX styled script?
     261         */
     262        if (rc == NO_ERROR && *pach == '#' && pach[1] == '!')
     263        {
    238264            /*
    239              * Only unreconized files and readerror passes this point!
    240              *
    241              * * Fileformats with lower priority should reside here. *
    242              *
     265             * UNIX styled script?
     266             * FIXME! Must be more than 64 bytes long?
     267             *        No options!
     268             *        Firstline < 64 bytes!
    243269             */
    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)
     270            kprintf(("ldrOpen: unix script?\n"));
     271            cchRead = min(cbFile, 256);
     272            rc = ldrRead(*phFile, 0UL, pach, 0UL, cchRead, NULL);
     273            if (rc == NO_ERROR)
    250274            {
    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             {
     275                char *pszStart = pach+2;
     276                kprintf(("ldrOpen: script debug 1\n"));
     277
     278                /* Make sure we don't read to much... */
     279                pszBuffer[cchRead] = '\0';
     280
    262281                /*
    263                  * UNIX styled script?
    264                  * FIXME! Must be more than 64 bytes long?
    265                  *        No options!
    266                  *        Firstline < 64 bytes!
     282                 * Skip blanks
    267283                 */
    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)
     284                pszStart = pszBuffer + 2; /* skips the "#!" stuff. */
     285                while (*pszStart != '\0' && (*pszStart == ' ' || *pszStart == '\t'))
     286                    pszStart++;
     287                kprintf(("ldrOpen: script debug 2\n"));
     288
     289                /* anything left on the line? */
     290                if (*pszStart != '\0' && *pszStart != '\r' && *pszStart != '\n')
    273291                {
    274                     char *pszStart = pach+2;
    275                     kprintf(("ldrOpen: script debug 1\n"));
    276 
    277                     /* Make sure we don't read to much... */
    278                     pszBuffer[cchRead] = '\0';
     292                    char *      pszEnd;         /* Pointer to the end of the string(s) when the next step is finished. */
     293                    unsigned    cchToAdd = 1;   /* Chars to add */
     294                    BOOL        fFirst = TRUE;  /* Set if a '\0' has not been set yet.
     295                                                 * If this is clear, there are one or more parameters after the interpreter name. */
    279296
    280297                    /*
    281                      * Skip blanks
    282                      */
    283                     pszStart = pszBuffer + 2; /* skips the "#!" stuff. */
    284                     while (*pszStart != '\0' && (*pszStart == ' ' || *pszStart == '\t'))
    285                         pszStart++;
    286                     kprintf(("ldrOpen: script debug 2\n"));
    287 
    288                     /* anything left on the line? */
    289                     if (*pszStart != '\0' && *pszStart != '\r' && *pszStart != '\n')
     298                     * find linesize and make parameters ready for copying
     299                     */
     300                    pszEnd = pszStart;
     301                    kprintf(("ldrOpen: script debug 3\n"));
     302                    while (*pszEnd != '\0' && *pszEnd != '\r' && *pszEnd != '\n')
    290303                    {
    291                         char *      pszEnd;         /* Pointer to the end of the string(s) when the next step is finished. */
    292                         //char *      pszFirstArg;    /* Pointer to the first argument, the one after the interpreter name. */
    293                         unsigned    cchToAdd = 1;   /* Chars to add */
    294                         int         f = TRUE;       /* flag which tells me if I have just closed the last argument.  */
    295                         /*
    296                          * find linesize and make parameters ready for copying
    297                          */
    298                         pszEnd = pszStart;
    299                         kprintf(("ldrOpen: script debug 3\n"));
    300                         //pszFirstArg = NULL;
    301                         while (*pszEnd != '\0' && *pszEnd != '\r' && *pszEnd != '\n')
     304                        if (fFirst && (*pszEnd == ' ' || *pszEnd == '\t'))
    302305                        {
    303                             if (f)
    304                             {
    305                                 f = FALSE;
    306                                 //if (pszFirstArg != NULL) pszFirstArg = pszEnd + 1;
    307                             }
    308                             else if (!f && (*pszEnd == ' ' || *pszEnd == '\t'))
    309                             {
    310                                  *pszEnd = '\0';
    311                                  f = TRUE;
    312                             }
    313 
    314                             /* next */
    315                             pszEnd++;
    316                             cchToAdd++;
     306                            *pszEnd = '\0';
     307                            fFirst = FALSE;
     308                            if (pszEnd[1] == '\0' || pszEnd[1] == '\r' || pszEnd[1] == '\n')
     309                                fFirst = TRUE;
    317310                        }
    318                         *pszEnd = '\0';
    319                         kprintf(("ldrOpen: script debug 4\n"));
    320 
     311
     312                        /* next */
     313                        pszEnd++;
     314                        cchToAdd++;
     315                    }
     316                    *pszEnd = '\0';
     317                    kprintf(("ldrOpen: script debug 4\n"));
     318
     319                    /*
     320                     * If ldrQueryApp type we don't have any ExecPgm buffer we need to mess with.
     321                     * We'll simply try open the the interpreter.
     322                     */
     323                    if (fQAppType)
     324                    {
     325                        rc = ldrClose(*phFile);
     326                        rc = ldrOpen(phFile, pszStart, param3); /* FIXME, recusion! check that name not equal! Use flags to prevent race? */
     327                    }
     328                    else
     329                    {
    321330                        /*
    322331                         * Find the ExecPgm buffer.
     
    326335                        if (pBuffer != NULL)
    327336                        {
    328                             unsigned cchArguments = getArgsLength(pBuffer->achArgs);
    329                             kprintf(("ldrOpen: debug1\n"));
     337                            unsigned cchArguments = getArgsLength(pBuffer->achArgs); /* minus the first argument. */
     338                            unsigned cchScriptnameDelta = strlen(pBuffer->szFilename) - strlen(pBuffer->achArgs); /* scriptname size difference. */
    330339
    331340                            kprintf(("ldrOpen: script debug 6\n"));
     
    334343                             * Is there enough space in the struct?
    335344                             */
    336                             if (cchArguments + cchToAdd < sizeof(pBuffer->achArgs))
     345                            if (cchArguments + cchToAdd + cchScriptnameDelta < sizeof(pBuffer->achArgs))
    337346                            {
    338347                                kprintf(("ldrOpen: script debug 7\n"));
     
    344353                                if (rc == NO_ERROR)
    345354                                {
    346                                     kprintf(("ldrOpen: scritp debug 8\n"));
     355                                    kprintf(("ldrOpen: script debug 8\n"));
    347356                                    /* Make space for the addition arguments. */
    348                                     memmove(&pBuffer->achArgs[cchToAdd], &pBuffer->achArgs[0], cchArguments);
    349                                     memcpy(&pBuffer->achArgs[0], pszBuffer, cchToAdd);
    350                                     kprintf(("ldrOpen: script debug 9\n"));
     357                                    #ifdef DEBUG
     358                                    char *psz = &pBuffer->achArgs[0];
     359                                    int   i = 0;
     360                                    while (*psz != '\0')
     361                                    {
     362                                        kprintf(("Arg %d: %s\n", i++, psz));
     363                                        psz += 1 + strlen(psz);
     364                                    }
     365                                    #endif
     366                                    memmove(&pBuffer->achArgs[cchToAdd + cchScriptnameDelta],
     367                                            &pBuffer->achArgs[0], cchArguments);
     368
     369                                    /*
     370                                     * Copy the arguments.
     371                                     */
     372                                    kprintf(("ldrOpen: script debug 8\n"));
     373                                    memcpy(&pBuffer->achArgs[0], pszStart, cchToAdd); /* Interpreter with arguments */
     374                                    if (!fFirst)
     375                                        pBuffer->achArgs[cchToAdd - 1] = ' ';
     376                                    strcpy(&pBuffer->achArgs[cchToAdd], pszFilename); /* Scriptname */
     377                                    kprintf(("ldrOpen: script debug a\n"));
     378
     379                                    #ifdef DEBUG
     380                                    psz = &pBuffer->achArgs[0];
     381                                    i = 0;
     382                                    while (*psz != '\0')
     383                                    {
     384                                        kprintf(("Arg %d: %s\n", i++, psz));
     385                                        psz += 1 + strlen(psz);
     386                                    }
     387                                    #endif
    351388                                }
    352389                                else
     
    365402                        }
    366403                    }
    367                     else
    368                     {
    369                         kprintf(("ldrOpen: no interpereter on the first line.\n"));
    370                         rc = ERROR_BAD_EXE_FORMAT; /*?*/
    371                     }
    372404                }
    373405                else
    374406                {
    375                     kprintf(("ldrOpen: read of min(cbFile, 256) = %d failed, rc = %d\n", cchRead, rc));
     407                    kprintf(("ldrOpen: no interpereter on the first line.\n"));
     408                    rc = ERROR_BAD_EXE_FORMAT; /*?*/
    376409                }
    377             } /* else inn other formats here. */
    378         }
    379         else
    380         {
    381             kprintf(("ldrOpen: ldrRead failed with rc=%d when reading DosHdr.\n", rc));
    382             rc = NO_ERROR;
    383         }
     410            }
     411            else
     412            {
     413                kprintf(("ldrOpen: read of min(cbFile, 256) = %d failed, rc = %d\n", cchRead, rc));
     414            }
     415        } /* else inn other formats here. */
    384416        rfree(pszBuffer);
    385417    }
  • trunk/src/win32k/ldr/mytkExecPgm.asm

    r2837 r2838  
    1 ; $Id: mytkExecPgm.asm,v 1.4 2000-02-21 05:00:53 bird Exp $
     1; $Id: mytkExecPgm.asm,v 1.5 2000-02-21 09:24:01 bird Exp $
    22;
    33; mytkExecPgm - tkExecPgm overload
     
    2323    extrn  ReleaseBuffer:PROC
    2424    extrn  QueryBufferSegmentOffset:PROC
    25     extrn  f_FuStrLenZ
    26     extrn  f_FuBuff
     25
     26    ; Scans strings until empy-string is reached.
     27    ; input:  bx:di
     28    ; uses:   nearly all (save bp)
     29    ; return: cx size - CF clear
     30    ;         ax error- CF set
     31    extrn  f_FuStrLenZ:PROC
     32
     33    ; Stringlength
     34    ; input:  bx:di
     35    ; uses:   nearly all (save bp)
     36    ; return: cx size - CF clear
     37    ;         ax error- CF set
     38    extrn  f_FuStrLen:PROC
     39
     40    ;memcpy
     41    ;input:  bx:si pointer to source
     42    ;        es:di pointer to target
     43    ;        cx    count of bytes to copy
     44    ;uses:   nearly all (save bp)
     45    ;return: success CF clear
     46    ;        failure CF set
     47    extrn  f_FuBuff:PROC
    2748
    2849;
     
    81102    push    edi
    82103
    83 IF 0
    84 ;    ; Check if this overloading has anything too say, after all it is using some stack space!
    85 ;    jmp     mytkExecPgm_CalltkExecPgm_X1
    86 ENDIF
    87 
    88104    ; parameter validations
    89105    mov     ax, ds                      ; pointer to filename
     
    91107    jb      mytkExecPgm_CalltkExecPgm_X1
    92108
    93     ; This test is currently disabled. We'll pass on an empty string if the argument pointer is NULL.
    94     ; Hopefully an empty string is treated equally to an NULL pointer.
    95 ;    cmp     di, 4
    96 ;    jl      mytkExecPgm_CalltkExecPgm_X1
    97 
     109    ;
    98110    ; filename length
     111    ;
    99112    mov     ax, ds
    100113    mov     es, ax
    101     xor     eax, eax
    102     movzx   edi, dx                     ; es:di is now filename address (ds:dx).
    103     mov     ecx, 0ffffffffh
    104     cld
    105     repne scasb
    106     not     ecx
     114    pushad
     115    mov     bx, ds
     116    mov     di, dx                      ; es:di is now filename address (ds:dx).
     117    push    cs                          ; Problem calling far into the calltab segement.
     118    call    near ptr FLAT:f_FuStrLen
     119    movzx   ecx, cx
     120    mov     [ebp+cchFilename], ecx
     121    popad
     122    jc      mytkExecPgm_CalltkExecPgm_X1; If the FuStrLen call failed we bail out!
    107123
    108124    ;
    109125    ; if filename length is more that CCHMAXPATH then we don't do anything!.
    110126    ;
     127    mov     ecx, [ebp+cchFilename]
    111128    cmp     ecx, 260
    112129    jae     mytkExecPgm_CalltkExecPgm_X1; length >= 260
    113     mov     [ebp+cchFilename], ecx
    114130
    115131    ;
     
    122138    cmp     di, 4                       ; The argument might me a invalid pointer...
    123139    jb      mytkExecPgm_CalltkExecPgm_1
    124     mov     es, di
    125     movzx   edi, si                     ; es:edi is now args address (di:si), eax is still 0
    126     dec     ecx
    127     cld
    128 mytkExecPgm_CalltkExecPgm_loop:         ; loop true all ASCIIZ strings
    129     repne scasb                         ; scans forwards until '\0' is read. es:edi is pointing at the char after the '\0'.
    130     cmp     byte ptr es:[edi], 0        ; is this char '\0' ? stop looping : loop once more;
    131     jnz     mytkExecPgm_CalltkExecPgm_loop
    132     dec     ecx                         ; update count - count terminating zero too
    133     not     ecx
     140
     141    pushad
     142    mov     bx, di                      ;
     143    mov     di, si                      ; bx:di -> arguments
     144    push    cs                          ; Problem calling far into the calltab segement.
     145    call    near ptr FLAT:f_FuStrLenZ
     146    movzx   ecx, cx
     147    mov     [ebp+cchArgs], ecx
     148    popad
     149    jc      mytkExecPgm_CalltkExecPgm_X1
    134150
    135151mytkExecPgm_CalltkExecPgm_1:
    136     mov     [ebp+cchArgs], ecx
     152    mov     ecx, [ebp+cchArgs]
    137153    add     ecx, [ebp+cchFilename]      ; filename
    138154    add     ecx, 3 + 260                ;  260 = new argument from a scrip file or something.
     
    162178    ; Copy filename to pBuffer.
    163179    ;
    164     push    esi
    165     mov     edi, eax                    ; es:di  pBuffer
    166     movzx   esi, dx                     ; ds:si  Filename pointer (input ds:dx)
     180    pushad
     181    mov     di, ax                      ; es:di  pBuffer
     182    mov     si, dx
     183    mov     bx, ds                      ; bx:si  Filename pointer (input ds:dx)
    167184    mov     ecx, [ebp+cchFilename]
    168     cld
    169     rep movsb
     185    push    cs                          ; Problem calling far into the calltab segement.
     186    call    near ptr FLAT:f_FuBuff
     187    popad
     188    jc      mytkExecPgm_CalltkExecPgm_X2
    170189
    171190    ;
    172191    ; Copy Args to pBuffer + 261
    173192    ;
    174     ; stack: esi, edi, es, ds, ecx, eax
    175     pop     esi
     193    ; stack: edi, es, ds, ecx, eax
    176194    pop     edi
    177195    push    edi
    178     push    esi
    179196    add     eax, 261                    ; we'll use eax in the branch
    180197    cmp     di, 4
    181198    jb      mytkExecPgm_CalltkExecPgm_2
    182     and     esi, 00000ffffh             ; remove high part of the register
    183     mov     ds, di                      ; ds:si -> arguments
    184     mov     edi, eax                    ; es:di -> pBuffer + 261
     199    pushad
    185200    mov     ecx, [ebp+cchArgs]
    186     cld
    187     rep movsb
     201    mov     bx, di                      ; ds:si -> arguments
     202    push    cs                          ; Problem calling far into the calltab segement.
     203    call    near ptr FLAT:f_FuBuff
     204    popad
     205    jc      mytkExecPgm_CalltkExecPgm_X2
    188206    jmp     mytkExecPgm_CalltkExecPgm_3
    189207
    190208mytkExecPgm_CalltkExecPgm_2:
    191     mov     byte ptr es:[eax], 0        ; Terminate the empty string!
     209    mov     word ptr es:[eax], 0        ; Terminate the empty string!
    192210
    193211    ;
     
    206224    ; Restore variables pushed on the stack
    207225    ;
    208     ; stack: esi, edi, es, ds, ecx, eax
    209     pop     esi
     226    ; stack: edi, es, ds, ecx, eax
    210227    pop     edi
    211228    pop     es
     
    234251    ; Call g_tkExecPgm
    235252    ;
    236     push    cs
     253    push    cs                          ; Problem calling far into the calltab segement.
    237254    call    near ptr FLAT:g_tkExecPgm
    238255    pushfd
Note: See TracChangeset for help on using the changeset viewer.