- Timestamp:
- Feb 19, 2000, 9:40:31 AM (26 years ago)
- 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 $ 2 2 * 3 3 * Description: Autoprobes the os2krnl file and os2krnl[*].sym files. … … 94 94 {FALSE, -1, 8, "_ldrOpen", -1, -1, EPT_PROC}, /* 1 */ 95 95 {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? */ 97 97 {FALSE, -1, 20, "_ldrEnum32bitRelRecs", -1, -1, EPT_PROC}, /* 4 */ 98 98 {FALSE, -1, 10, "_IOSftOpen", -1, -1, EPT_PROCIMPORT}, /* 5 */ … … 101 101 {FALSE, -1, 12, "_IOSftReadAt", -1, -1, EPT_PROCIMPORT}, /* 8 */ 102 102 {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 */ 106 107 }; 107 108 -
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 $ 2 2 * 3 3 * d32init.c - 32-bits init routines. … … 566 566 (unsigned)myldrOpen, 567 567 (unsigned)myldrClose, 568 (unsigned)myLDRQAppType,568 0,//(unsigned)myLDRQAppType, 569 569 (unsigned)myldrEnum32bitRelRecs, 570 0, 570 571 0, 571 572 0, -
trunk/src/win32k/include/OS2KIO.h
r2501 r2827 1 /* $Id: OS2KIO.h,v 1. 3 2000-01-22 18:20:58bird Exp $1 /* $Id: OS2KIO.h,v 1.4 2000-02-19 08:40:30 bird Exp $ 2 2 * 3 3 * OS/2 kernel IO: prototypes, typedefs and macros. … … 13 13 /** 14 14 * Opens a given file. 15 * @returns NO_ERROR on success. otheron error.15 * @returns NO_ERROR on success. OS/2 error code on error. 16 16 * @param pszFilename Pointer to filename. 17 17 * @param flOpenFlags Open flags. (similar to DosOpen) … … 31 31 /** 32 32 * Closes the specified file. 33 * @returns NO_ERROR on success. otheron error.33 * @returns NO_ERROR on success. OS/2 error code on error. 34 34 * @param hFile File handle - System File Number. 35 35 */ … … 41 41 /** 42 42 * 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. 44 44 * @param pszPath Pointer to path to expand. Contains the full path upon return. (?) 45 45 * This buffer should probably be of CCHMAXPATH length. … … 52 52 /** 53 53 * Read at a given offset in the a file. 54 * @returns NO_ERROR on success. otheron error.54 * @returns NO_ERROR on success. OS/2 error code on error. 55 55 * @param hFile File handle - System File Number. 56 56 * @param pcbActual Pointer to variable which upon input holds the number … … 71 71 /** 72 72 * Write at a given offset in the a file. 73 * @returns NO_ERROR on success. otheron error.73 * @returns NO_ERROR on success. OS/2 error code on error. 74 74 * @param hFile File handle - System File Number. 75 75 * @param pcbActual Pointer to variable which upon input holds the number … … 87 87 ); 88 88 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 */ 96 APIRET KRNLCALL SftFileSize( 97 SFN hFile, 98 PULONG pcbFile 99 ); 100 89 101 #endif -
trunk/src/win32k/include/probkrnl.h
r2823 r2827 1 /* $Id: probkrnl.h,v 1. 6 2000-02-18 19:27:29bird Exp $1 /* $Id: probkrnl.h,v 1.7 2000-02-19 08:40:30 bird Exp $ 2 2 * 3 3 * Include file for ProbKrnl. … … 16 16 * Defined Constants And Macros * 17 17 *******************************************************************************/ 18 #define NUMBER_OF_PROCS 1 318 #define NUMBER_OF_PROCS 14 19 19 #define MAX_LENGTH_NAME 32 20 20 -
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 $ 2 2 ; 3 3 ; callTab - Call back again table - table with entry for each function which is overrided. … … 30 30 public _IOSftReadAt@20 31 31 public _IOSftWriteAt@20 32 public _SftFileSize@8 32 33 33 34 public _VMAllocMem@36 … … 94 95 _IOSftWriteAt@20 ENDP 95 96 97 _SftFileSize@8 PROC NEAR 98 db MAXSIZE_PROLOG dup(0cch) 99 _SftFileSize@8 ENDP 100 96 101 97 102 _VMAllocMem@36 PROC NEAR -
trunk/src/win32k/ldr/myldrOpen.cpp
r2501 r2827 1 /* $Id: myldrOpen.cpp,v 1. 6 2000-01-22 18:21:02bird Exp $1 /* $Id: myldrOpen.cpp,v 1.7 2000-02-19 08:40:30 bird Exp $ 2 2 * 3 3 * myldrOpen - ldrOpen. … … 16 16 #define INCL_NOPMAPI 17 17 18 #define INCL_OS2KRNL_IO 19 18 20 /******************************************************************************* 19 21 * Header Files * … … 21 23 #include <os2.h> 22 24 25 #include "rmalloc.h" 23 26 #include "malloc.h" 24 27 #include <memory.h> 25 28 #include <stdlib.h> 29 #include <string.h> 26 30 27 31 #include "log.h" … … 29 33 #include <exe386.h> 30 34 #include "OS2Krnl.h" 35 #include "dev32.h" 31 36 #include "ModuleBase.h" 32 37 #include "pe2lx.h" … … 36 41 #include "ldrCalls.h" 37 42 #include "options.h" 43 #include "myExecPgm.h" 44 45 46 /******************************************************************************* 47 * Internal Functions * 48 *******************************************************************************/ 49 static unsigned getArgsLength(const char *pachArgs); 38 50 39 51 … … 49 61 ULONG rc; 50 62 63 /* 64 * Try open the file (thats why this function is called anyway) 65 */ 51 66 rc = ldrOpen(phFile, pszFilename, param3); 52 67 68 /* log sucesses */ 53 69 if (rc == NO_ERROR) 54 70 kprintf(("ldrOpen: phFile=%#.4x, flags=%#.8x, pszFn=%s\n", *phFile, param3, pszFilename)); 55 71 72 /* 73 * Are we to intercept the loading? 74 * - Only if open were succesful and one of the loaders are enabled. 75 */ 56 76 if (rc == NO_ERROR && (options.fElf || options.fPE != FLAGS_PE_NOT || options.fScript)) 57 77 { 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 /* 64 111 * See if this is an recognizable module format. 65 112 * This costs up to two disk reads! 66 113 */ 67 rc = ldrRead(*phFile, 0UL, pMzHdr, 0UL, sizeof(IMAGE_DOS_HEADER), NULL);114 rc = ldrRead(*phFile, 0UL, pMzHdr, 0UL, cchRead, NULL); 68 115 if (rc == NO_ERROR) 69 116 { 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 */ 70 122 if ((pMzHdr->e_magic == IMAGE_DOS_SIGNATURE && 71 123 pMzHdr->e_lfanew > sizeof(IMAGE_DOS_HEADER) && pMzHdr->e_lfanew < 0x04000000UL) /* Larger than 64 bytes and less that 64MB. */ 72 124 || *(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 */ 74 130 if (options.fPE == FLAGS_PE_NOT) 131 { 132 free(pszBuffer); 75 133 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); 77 140 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 */ 80 149 if (rc == NO_ERROR && *(PULONG)pach == IMAGE_NT_SIGNATURE) 81 { /* PE signature found */ 150 { /* 151 * PE signature found. 152 */ 82 153 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 */ 83 160 if (options.fPE == FLAGS_PE_PE2LX 84 161 || (options.fPE == FLAGS_PE_MIXED … … 88 165 ) 89 166 ) 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 */ 91 174 Pe2Lx * pPe2Lx = new Pe2Lx(*phFile); 92 175 if (pPe2Lx != NULL) … … 113 196 } 114 197 else 198 { 199 /* 200 * Starting of PE.EXE enable? 201 */ 115 202 if (options.fPE == FLAGS_PE_PE || options.fPE == FLAGS_PE_MIXED) 116 { /* pe.exe */ 203 { /* 204 * pe.exe - need the path! 205 */ 117 206 kprintf(("ldrOpen: pe.exe - opening\n")); 118 207 ldrClose(*phFile); 119 208 rc = ldrOpen(phFile, "pe.exe", param3); /* path....! problems! */ 120 209 kprintf(("ldrOpen: pe.exe - open returned with rc = %d\n", rc)); 210 free(pszBuffer); 121 211 return rc; 122 212 } 213 } 123 214 } 124 rc = NO_ERROR; 215 free(pszBuffer); 216 return NO_ERROR; 125 217 } 126 218 else 127 219 { 220 /* 221 * ELF image? 222 */ 128 223 if (pach[0] == ELFMAG0 && pach[1] == ELFMAG1 && pach[2] == ELFMAG2 && pach[3] == ELFMAG3) 129 224 { 130 /* ELF signature found */ 225 /* 226 * ELF signature found. 227 */ 131 228 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; 132 235 } 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') 135 288 { 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) 153 301 { 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; 159 352 } 160 353 } 161 354 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 } 163 359 } 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. */ 165 371 } 166 372 else … … 169 375 rc = NO_ERROR; 170 376 } 377 free(pszBuffer); 171 378 } 172 379 return rc; 173 380 } 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 */ 390 static 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:19bird Exp $1 ; $Id: mytkExecPgm.asm,v 1.3 2000-02-19 08:40:31 bird Exp $ 2 2 ; 3 3 ; mytkExecPgm - tkExecPgm overload … … 17 17 ; Imported Functions 18 18 ; 19 DATA32 SEGMENT 19 20 extrn g_tkExecPgm:PROC 21 DATA32 ENDS 20 22 extrn AcquireBuffer:PROC 21 23 extrn ReleaseBuffer:PROC … … 54 56 ; struct Buffer 55 57 ; { 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 */ 58 60 ; }; 59 61 ; … … 77 79 push edi 78 80 79 ; init local variables 80 mov [ebp+pBuffer], 0 81 IF 0 82 ; ; Check if this overloading has anything too say, after all it is using some stack space! 83 ; jmp mytkExecPgm_CalltkExecPgm_X1 84 ENDIF 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 81 95 82 96 ; filename length … … 86 100 movzx edi, dx ; es:di is now filename address (ds:dx). 87 101 mov ecx, 0ffffffffh 102 cld 88 103 repne scasb 89 104 not ecx … … 98 113 ; 99 114 ; 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 103 122 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 126 mytkExecPgm_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 107 131 not ecx 108 132 133 mytkExecPgm_CalltkExecPgm_1: 109 134 mov [ebp+cchArgs], ecx 110 135 add ecx, [ebp+cchFilename] ; filename 111 136 add ecx, 3 + 260 ; 260 = new argument from a scrip file or something. 112 137 ; 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!!! 114 139 jae mytkExecPgm_CalltkExecPgm_X1; jmp if argument + file + new file > buffer size 115 140 … … 139 164 movzx esi, dx ; ds:si Filename pointer (input ds:dx) 140 165 mov ecx, [ebp+cchFilename] 141 repnz movsb 166 cld 167 rep movsb 142 168 143 169 ; … … 149 175 push edi 150 176 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 151 181 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 154 183 mov ecx, [ebp+cchArgs] 155 repnz movsb 184 cld 185 rep movsb 186 jmp mytkExecPgm_CalltkExecPgm_3 187 188 mytkExecPgm_CalltkExecPgm_2: 189 mov byte ptr es:[eax], 0 ; Terminate the empty string! 156 190 157 191 ; 158 192 ; Set Pointers, pszFilename and pszArguments 159 193 ; 194 mytkExecPgm_CalltkExecPgm_3: 160 195 mov ax, seg FLAT:DATA32 161 196 mov ds, ax … … 197 232 ; Call g_tkExecPgm 198 233 ; 199 call far ptr FLAT:g_tkExecPgm;WARNING far call!!! 234 push cs 235 call near ptr FLAT:g_tkExecPgm 200 236 pushfd 201 237 … … 235 271 236 272 mytkExecPgm_CalltkExecPgm: 237 call far ptr FLAT:g_tkExecPgm 273 call far ptr FLAT:g_tkExecPgmStub 238 274 leave 239 275 retf 240 276 mytkExecPgm ENDP 241 277 278 279 ;; 280 ; Stub which jumps to g_tkExecPgmStub. 281 ; (This way I will hopefully get the right selector.) 282 g_tkExecPgmStub PROC FAR 283 jmp near ptr FLAT:g_tkExecPgm 284 g_tkExecPgmStub ENDP 285 286 242 287 CODE32 ENDS 243 288 END -
trunk/src/win32k/misc/asmutils.asm
r1467 r2827 1 ; $Id: asmutils.asm,v 1. 3 1999-10-27 02:02:59bird Exp $1 ; $Id: asmutils.asm,v 1.4 2000-02-19 08:40:31 bird Exp $ 2 2 ; 3 3 ; asmutils - assembly utility functions … … 24 24 public GetSS 25 25 public Int3 26 public _memrevmov@1227 public _memmov@1226 ; public _memrevmov@12 27 ; public _memmov@12 28 28 ; public DisableInterrupts 29 29 ; public EnableInterrupts … … 94 94 ;EnableInterrupts ENDP 95 95 96 96 if 0 97 97 ;void __stdcall memrevmov(void *pTo, void* pFrom, unsigned int Len); 98 98 pTo EQU dword ptr [ebp+08] … … 193 193 jmp memmov_end 194 194 _memmov@12 ENDP 195 195 endif 196 196 197 197 CODE32 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 $ 2 2 ; 3 3 ; Simple resident buffer for use when overloading tkExecPgm. … … 8 8 ; 9 9 .486p 10 11 12 ; 13 ; Defined Constants And Macros 14 ; 15 NBR_BUFFERS EQU 20 16 BUFFER_SIZE EQU 1536 10 17 11 18 ; … … 20 27 public ReleaseBuffer 21 28 public QueryBufferSegmentOffset 22 ; public cbBuffer 29 public QueryBufferPointerFromFilename 30 31 32 ; 33 ; Imported Functions 34 ; 35 extrn stricmp:PROC 23 36 24 37 … … 27 40 ; 28 41 DATA16 SEGMENT 29 ;DATA32 SEGMENT 30 achBuffer db 4096 dup(?) 42 aachBuffer db BUFFER_SIZE*NBR_BUFFERS dup(?) ; The buffer 31 43 DATA16 ENDS 32 ;DATA32 ENDS 33 34 ;DATA16 SEGMENT 44 35 45 DATA32 SEGMENT 36 fBuffer db 0 ;Access "semaphore" 46 afBuffer db NBR_BUFFERS dup(0) ; Access "semaphore" 47 ; 0 - not in use 48 ; 1 - in use 37 49 DATA32 ENDS 38 50 … … 46 58 ; @returns Pointer to buffer 47 59 ; @uses eax 48 ; @sketch if fBuffer == 0 then60 ; @sketch if AfBuffer == 0 then 49 61 ; ok! 50 62 ; fBuffer <- 1 … … 59 71 AcquireBuffer PROC NEAR 60 72 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 65 79 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 86 AcquireBuffer_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 74 94 AcquireBuffer_nok: 75 95 xor eax,eax 96 jmp AcquireBuffer_ret 97 98 ;success - calc buffer pointer 99 AcquireBuffer_ok: 100 mov eax, BUFFER_SIZE 101 dec ecx 102 imul eax, ecx ; ecx has the buffer number 103 add eax, offset FLAT:aachBuffer 104 AcquireBuffer_ret: 105 pop edx 106 pop ecx 76 107 pop ds 77 108 ret … … 85 116 ; @uses eax 86 117 ; @equiv 87 ; @sketch if eax == achBuffer then88 ; set fBuffer to 0 if 1.89 ; if fBuffer was not 1 then fail with rc = 87!90 ; else91 ; fail with rc = 8792 ; endif93 118 ; @status 94 119 ; @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no) … … 97 122 ASSUME DS:NOTHING 98 123 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 103 131 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" 106 150 mov al, 1 107 151 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 110 155 ReleaseBuffer_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 114 172 ReleaseBuffer_nok: 173 ;failure 174 pop eax 115 175 mov eax, 87 ;some error 176 177 ReleaseBuffer_ret: 178 pop edx 179 pop ecx 116 180 pop ds 117 181 ret … … 132 196 ASSUME DS:NOTHING 133 197 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 138 203 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 143 212 144 213 QueryBufferSegmentOffset_ok: 145 xor eax, eax146 214 jmp far ptr CODE16:GetBufferSegmentOffset16 147 215 QueryBufferSegmentOffset_Back:: … … 156 224 157 225 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. 237 QueryBufferPointerFromFilename 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). 250 QueryBufferPointerFromFilename_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 267 QueryBufferPointerFromFilename_next: 268 loop QueryBufferPointerFromFilename_loop 269 ; when we exit this loop we have failed! 270 271 QueryBufferPointerFromFilename_nok: 272 ; The buffer was not found, return NULL pointer. 273 xor eax, eax 274 pop edx 275 pop ecx 276 ret 277 278 QueryBufferPointerFromFilename_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 286 QueryBufferPointerFromFilename ENDP 287 288 289 290 158 291 CODE32 ENDS 159 292 293 160 294 CODE16 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 164 298 ; Jumps back to GetBufferOffset32 165 299 GetBufferSegmentOffset16: 166 300 ASSUME CS:CODE16, DS:NOTHING 167 mov ax, seg achBuffer 301 push ax 302 mov ax, seg aachBuffer 168 303 mov es, ax 169 mov ax, offset achBuffer 304 pop ax 305 add ax, offset aachBuffer 170 306 jmp far ptr FLAT:QueryBufferSegmentOffset_Back 171 307 CODE16 ENDS -
trunk/src/win32k/win32k.def
r1678 r2827 17 17 CODE32 class 'CODE' 18 18 CALLTAB class 'DATA' 19 ; CALLTAB class 'CODE' WRITABLE 19 20 DATA32 class 'DATA' 20 21 c_common class 'DATA'
Note:
See TracChangeset
for help on using the changeset viewer.