Changeset 1535 for trunk/src/win32k/ldr/myldrOpen.cpp
- Timestamp:
- Nov 1, 1999, 12:57:09 AM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/win32k/ldr/myldrOpen.cpp
r1467 r1535 1 /* $Id: myldrOpen.cpp,v 1. 3 1999-10-27 02:02:58bird Exp $1 /* $Id: myldrOpen.cpp,v 1.4 1999-10-31 23:57:06 bird Exp $ 2 2 * 3 3 * myldrOpen - _ldrOpen. … … 23 23 #include <stdlib.h> 24 24 25 26 25 #include "log.h" 27 26 #include <peexe.h> … … 33 32 #include "ldr.h" 34 33 #include "ldrCalls.h" 34 #include "options.h" 35 35 36 36 … … 52 52 kprintf(("_ldrOpen: phFile=%#.4x, flags=%#.8x, pszFn=%s\n", *phFile, param3, pszFilename)); 53 53 54 if (rc == NO_ERROR )54 if (rc == NO_ERROR && (options.fElf || options.fPE != FLAGS_PE_NOT || options.fScript)) 55 55 { 56 56 static char achBuffer[sizeof(IMAGE_DOS_HEADER)]; 57 57 PIMAGE_DOS_HEADER pMzHdr = (PIMAGE_DOS_HEADER)&achBuffer[0]; 58 PIMAGE_NT_HEADERS pNtHdrs = (PIMAGE_NT_HEADERS)&achBuffer[0]; /* oops. Last accessible field is OptionalHeader.FileAlignment */ 58 59 char *pach = &achBuffer[0]; 59 60 … … 62 63 * This costs up to two disk reads! 63 64 */ 64 rc = _ldrRead(*phFile, 0UL, pMzHdr, 0UL, sizeof( *pMzHdr), NULL);65 rc = _ldrRead(*phFile, 0UL, pMzHdr, 0UL, sizeof(IMAGE_DOS_HEADER), NULL); 65 66 if (rc == NO_ERROR) 66 67 { 67 if (pMzHdr->e_magic == IMAGE_DOS_SIGNATURE && 68 pMzHdr->e_lfanew > sizeof(IMAGE_DOS_HEADER) && pMzHdr->e_lfanew < 0x04000000UL) /* Larger than 64 bytes and less that 64MB. */ 69 { /* MZ header found */ 70 /* read */ 71 rc = _ldrRead(*phFile, pMzHdr->e_lfanew, pMzHdr, 0UL, 4UL, NULL); 68 if ((pMzHdr->e_magic == IMAGE_DOS_SIGNATURE && 69 pMzHdr->e_lfanew > sizeof(IMAGE_DOS_HEADER) && pMzHdr->e_lfanew < 0x04000000UL) /* Larger than 64 bytes and less that 64MB. */ 70 || *(PULONG)pach == IMAGE_NT_SIGNATURE) 71 { /* MZ or PE header found */ 72 if (options.fPE == FLAGS_PE_NOT) 73 return NO_ERROR; 74 75 if (*(PULONG)pach != IMAGE_NT_SIGNATURE) 76 rc = _ldrRead(*phFile, pMzHdr->e_lfanew, pach, 0UL, sizeof(achBuffer), NULL); 77 72 78 if (rc == NO_ERROR && *(PULONG)pach == IMAGE_NT_SIGNATURE) 73 79 { /* PE signature found */ 74 PMODULE pMod;75 76 80 kprintf(("_ldrOpen: PE executable...\n")); 77 #pragma info(none) 78 if (/* invoke pe.exe or do conversion now? */ 1) 79 { /* pe2lx - win32k */ 80 #pragma info(restore) 81 if (options.fPE == FLAGS_PE_PE2LX 82 || (options.fPE == FLAGS_PE_MIXED 83 && !((pNtHdrs->FileHeader.Characteristics & IMAGE_FILE_DLL == 0UL) 84 && pNtHdrs->OptionalHeader.ImageBase >= 0x04000000UL /* 64MB */ 85 ) 86 ) 87 ) 88 { /* pe2lx */ 81 89 Pe2Lx * pPe2Lx = new Pe2Lx(*phFile); 82 90 if (pPe2Lx != NULL) … … 101 109 } 102 110 else 103 { /* pe.exe */ 104 kprintf(("_ldrOpen: pe.exe - opening\n")); 105 _ldrClose(*phFile); 106 rc = _ldrOpen(phFile, "pe.exe", param3); /* path....! problems! */ 107 kprintf(("_ldrOpen: pe.exe - open returned with rc = %d\n", rc)); 108 } 111 if (options.fPE == FLAGS_PE_PE || options.fPE == FLAGS_PE_MIXED) 112 { /* pe.exe */ 113 kprintf(("_ldrOpen: pe.exe - opening\n")); 114 _ldrClose(*phFile); 115 rc = _ldrOpen(phFile, "pe.exe", param3); /* path....! problems! */ 116 kprintf(("_ldrOpen: pe.exe - open returned with rc = %d\n", rc)); 117 return rc; 118 } 109 119 } 110 120 rc = NO_ERROR; … … 112 122 else 113 123 { 114 if (*pach == '#') 115 { 116 /* unix styled script...? must be more than 64 bytes long.... */ 117 char *pszStart = pach+1; 118 char *pszEnd; 119 kprintf(("_ldrOpen: unix script?\n")); 120 /* skip blanks */ 121 while (*pszStart != '\0' && (*pszStart == ' ' || *pszStart == '\t')) 122 pszStart++; 123 if (*pszStart != '\0' && *pszStart != '\r' && *pszStart != '\n') 124 { /* find end-of-word */ 125 while (*pszEnd != '\0' && *pszEnd != '\n' && *pszEnd != '\r' 126 && *pszEnd != '\t' && *pszEnd != ' ') 127 pszEnd++; 128 *pszEnd = '\0'; 129 kprintf(("_ldrOpen: unix script - opening %s\n", pszStart)); 130 _ldrClose(*phFile); 131 rc = _ldrOpen(phFile, pszStart, param3); 132 kprintf(("_ldrOpen: unix script - open returned with rc = %d\n", rc)); 133 } 134 else 135 kprintf(("_ldrOpen: unix script - unexpected end of line/file. (line: %.10s\n", pach)); 136 } 137 else if (pach[0] == ELFMAG0 && pach[1] == ELFMAG1 && pach[2] == ELFMAG2 && pach[3] == ELFMAG3) 124 if (pach[0] == ELFMAG0 && pach[1] == ELFMAG1 && pach[2] == ELFMAG2 && pach[3] == ELFMAG3) 138 125 { 139 126 /* ELF signature found */ 140 127 kprintf(("_ldrOpen: ELF executable! - not implemented yet!\n")); 141 128 } 129 else 130 if (*pach == '#') 131 { 132 /* unix styled script...? Must be more than 64 bytes long? No options. firstline < 64 bytes. */ 133 char *pszStart = pach+1; 134 char *pszEnd; 135 kprintf(("_ldrOpen: unix script?\n")); 136 137 achBuffer[sizeof(achBuffer)-1] = '\0'; /* just to make sure we don't read to much... */ 138 139 /* skip blanks */ 140 while (*pszStart != '\0' && (*pszStart == ' ' || *pszStart == '\t')) 141 pszStart++; 142 if (*pszStart != '\0' && *pszStart != '\r' && *pszStart != '\n') 143 { /* find end-of-word */ 144 while (*pszEnd != '\0' && *pszEnd != '\n' && *pszEnd != '\r' 145 && *pszEnd != '\t' && *pszEnd != ' ') 146 pszEnd++; 147 *pszEnd = '\0'; 148 if (*pszEnd != '\0') 149 { 150 kprintf(("_ldrOpen: unix script - opening %s\n", pszStart)); 151 _ldrClose(*phFile); 152 rc = _ldrOpen(phFile, pszStart, param3); 153 kprintf(("_ldrOpen: unix script - open returned with rc = %d\n", rc)); 154 } 155 } 156 else 157 kprintf(("_ldrOpen: unix script - unexpected end of line/file. (line: %.10s\n", pach)); 158 } 142 159 } 143 160 }
Note:
See TracChangeset
for help on using the changeset viewer.