- Timestamp:
- Oct 14, 1999, 3:25:39 AM (26 years ago)
- Location:
- trunk/src/win32k
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/win32k/Makefile
r1178 r1273 1 1 ################################################################################ 2 # $Id: Makefile,v 1. 5 1999-10-08 00:28:51bird Exp $2 # $Id: Makefile,v 1.6 1999-10-14 01:25:37 bird Exp $ 3 3 # 4 4 # Copyright 1998-1999 knut st. osmundsen … … 161 161 object\yield.obj \ 162 162 object\vsprintf.obj \ 163 object\vprintf.obj \ 163 164 object\ldr.obj \ 164 165 object\myldrClose.obj \ … … 166 167 object\myldrRead.obj \ 167 168 object\myLDRQAppType.obj \ 168 object\lxSuper.obj \ 169 object\lxFile.obj \ 170 object\accelerator.obj \ 171 object\bitmap.obj \ 172 object\cursor.obj \ 173 object\cursorgrp.obj \ 174 object\dialog.obj \ 175 object\icon.obj \ 176 object\icongrp.obj \ 177 object\menu.obj \ 178 object\misc.obj \ 179 object\pefile.obj \ 180 object\rcdata.obj \ 181 object\strings.obj \ 169 object\pe2lx.obj 170 # 171 # object\lxSuper.obj \ 172 # object\lxFile.obj \ 173 # object\accelerator.obj \ 174 # object\bitmap.obj \ 175 # object\cursor.obj \ 176 # object\cursorgrp.obj \ 177 # object\dialog.obj \ 178 # object\icon.obj \ 179 # object\icongrp.obj \ 180 # object\menu.obj \ 181 # object\misc.obj \ 182 # object\pefile.obj \ 183 # object\rcdata.obj \ 184 # object\strings.obj \ 182 185 183 186 … … 187 190 object\probkrnl.obj 188 191 189 192 LIBS = \ 190 193 !if "$(CCENV)" == "VAC36" 191 LIBS =$(VACPATH)\lib\cpprni36.lib \194 $(VACPATH)\lib\cpprni36.lib \ 192 195 !else 193 LIBS =$(VACPATH)\lib\cppon30.lib \196 $(VACPATH)\lib\cppon30.lib \ 194 197 !endif 195 198 $(DDKPATH)\lib\os2286.lib … … 208 211 $(CDEFINES16) -DDEBUGR3 -Fa$(WIN32KLIST)\$(*B).s \ 209 212 -Foprobkrnl.obj $(CINCLUDES16) dev16\probkrnl.c 210 $(MSCPATH)\binb\link /NOD /MAP:FULL /CO /pmtype:vio probkrnl.obj, probkrnl.exe, probkrnl.map, $(TOOLKIT)\lib\os2286.lib + $(MSCPATH)\lib\clibcr.lib;211 # link /NOD /MAP:FULL /CO /pmtype:vio probkrnl.obj, probkrnl.exe, probkrnl.map, f:\toolkit\lib\os2286.lib + $(MSCPATH)\lib\clibcep.lib;213 link /NOD /MAP:FULL /CO /pmtype:vio probkrnl.obj, probkrnl.exe, probkrnl.map, f:\toolkit\lib\os2286.lib + $(MSCPATH)\lib\clibcep.lib; 214 # $(MSCPATH)\binb\link /NOD /MAP:FULL /CO /pmtype:vio probkrnl.obj, probkrnl.exe, probkrnl.map, $(TOOLKIT)\lib\os2286.lib + $(MSCPATH)\lib\clibcr.lib; 212 215 213 216 … … 270 273 ################################################################################ 271 274 clean: 272 @$(ECHO) cleaning....273 @$(ECHO) #do nmake depend > .depend274 @$(RM) $(NAME).sys *.lib $(WIN32KOBJ)\* $(WIN32KLIST)\* *.obj *.exe275 @$(RM) *.sym *.map275 $(ECHO) cleaning.... 276 $(ECHO) #do nmake depend > .depend 277 $(RM) $(NAME).sys *.lib $(WIN32KOBJ)\* $(WIN32KLIST)\* *.obj *.exe 278 $(RM) *.sym *.map 276 279 # @$(RM) $(PDWIN32_BIN)\$(NAME).sys 277 280 -
trunk/src/win32k/fastdep.c
r1178 r1273 408 408 else 409 409 fprintf(stderr, "%s(%d): warning include file '%s' not found!\n", 410 pszFilename, iLine, szFullname +1);410 pszFilename, iLine, szFullname); 411 411 } 412 412 } -
trunk/src/win32k/ldr/ldr.cpp
r847 r1273 1 /* $Id: ldr.cpp,v 1. 1 1999-09-06 02:20:00bird Exp $1 /* $Id: ldr.cpp,v 1.2 1999-10-14 01:25:38 bird Exp $ 2 2 * 3 3 * ldr.cpp - Loader helper functions a structures. … … 18 18 *******************************************************************************/ 19 19 #include <os2.h> 20 #include <string.h>21 20 22 21 #include "malloc.h" 23 22 #include "new.h" 23 #include <memory.h> 24 #include <stdlib.h> 25 24 26 #include "log.h" 25 #include "pefile.h" 26 #include "lx.h" 27 #include <peexe.h> 28 #include <exe386.h> 29 #include "OS2Krnl.h" 30 #include "pe2lx.h" 27 31 #include "ldr.h" 28 32 … … 31 35 * Global Variables * 32 36 *******************************************************************************/ 33 unsigned char ahStates[MAX_FILE_HANDLES/4];34 UNCERTAIN ahUncertain[MAX_UNCERTAIN_FILES];35 37 PPENODE pPE; 38 unsigned char achHandleStates[MAX_FILE_HANDLES/8]; 36 39 37 40 … … 40 43 *******************************************************************************/ 41 44 static PPENODE findNodePtr2(PPENODE pRoot, const char *pszFilename); 42 static ULONG freeNode(PPENODE pNode);43 45 static ULONG depth(PPENODE pNode); 44 45 46 /**47 * Get a free entry in the ahUncertain table.48 * @returns Index to free entry in the ahUncertain table.49 */50 ULONG getFreeUncertainEntry(void)51 {52 ULONG i;53 54 i = 0;55 while (i < MAX_UNCERTAIN_FILES && ahUncertain[i].hFile != 0xFFFF)56 i++;57 58 return i < MAX_UNCERTAIN_FILES ? i : -1;59 }60 61 62 /**63 * Free uncertain entry.64 * Mark entry with hFile in the uncertain table as unused65 * @returns NO_ERROR on success, -1 on error.66 * @param hFile Filehandle (key) to free.67 */68 ULONG freeUncertainEntry(SFN hFile)69 {70 int i;71 int rc;72 73 i = 0;74 while (i < MAX_UNCERTAIN_FILES && ahUncertain[i].hFile != hFile)75 i++;76 77 if (i < MAX_UNCERTAIN_FILES && ahUncertain[i].hFile == hFile)78 {79 ahUncertain[i].hFile = 0xFFFF;80 ahUncertain[i].offsetNEHdr = 0;81 ahUncertain[i].fMZ = 0;82 ahUncertain[i].fPE = 0;83 free(ahUncertain[i].pszName);84 ahUncertain[i].pszName = NULL;85 rc = NO_ERROR;86 }87 else88 rc = -1;89 return rc;90 }91 92 93 /**94 * Find the uncertain entry for hFile95 * @returns Index into ahUncertain if found. ~0UL on error.96 * @param hFile Filehandle (key) to find.97 */98 ULONG findUncertainEntry(SFN hFile)99 {100 int i = 0;101 while (i < MAX_UNCERTAIN_FILES && ahUncertain[i].hFile != hFile)102 i++;103 104 return i < MAX_UNCERTAIN_FILES ? (ULONG)i : ~0UL;105 }106 46 107 47 … … 322 262 323 263 /*depth first search thru the whole tree */ 324 if ( pRoot == NULL || pRoot->lxfile.queryIsModuleName(pszFilename))264 if (pRoot == NULL || pRoot->pPe2Lx->queryIsModuleName(pszFilename)) 325 265 return pRoot; 326 266 … … 344 284 pNode = new PENODE; 345 285 if (pNode == NULL) 346 kprintf(("allocateNode: malloc returned anNULL-pointer\n"));286 kprintf(("allocateNode: new returned a NULL-pointer\n")); 347 287 348 288 return pNode; … … 355 295 * @param pNode Pointer to node which is to be freed. 356 296 */ 357 staticULONG freeNode(PPENODE pNode)297 ULONG freeNode(PPENODE pNode) 358 298 { 359 299 if (pNode != NULL) … … 404 344 405 345 /* init state table */ 406 for (i = 0; i < MAX_FILE_HANDLES/4; i++) 407 ahStates[i] = 0; 408 409 /* init uncertain files */ 410 for (i = 0; i < MAX_UNCERTAIN_FILES; i++) 411 { 412 ahUncertain[i].hFile = 0xFFFF; 413 ahUncertain[i].offsetNEHdr = 0; 414 ahUncertain[i].fMZ = 0; 415 ahUncertain[i].fPE = 0; 416 ahUncertain[i].pszName = NULL; 417 } 346 memset(&achHandleStates[0], 0, sizeof(achHandleStates)); 418 347 419 348 /* init pPEFiles* */ -
trunk/src/win32k/ldr/myldrClose.cpp
r847 r1273 1 /* $Id: myldrClose.cpp,v 1. 1 1999-09-06 02:20:01bird Exp $1 /* $Id: myldrClose.cpp,v 1.2 1999-10-14 01:25:38 bird Exp $ 2 2 * 3 3 * myldrClose - _ldrClose … … 18 18 #include <os2.h> 19 19 20 #include <memory.h> 21 #include <stdlib.h> 22 23 #include "log.h" 24 #include <peexe.h> 25 #include <exe386.h> 20 26 #include "OS2Krnl.h" 21 #include "log.h" 22 #if 0 23 #include "lxFile.h" 24 #else 25 #define LXFile class { public: BOOL queryIsModuleName(const char *) {return FALSE;}} 26 #endif 27 #include "pe2lx.h" 27 28 #include "ldr.h" 28 29 #include "ldrCalls.h" … … 41 42 /* closes handle */ 42 43 kprintf(("_ldrClose: hFile = %.4x\n", hFile)); 43 if (GetState(hFile) == HSTATE_CHECK) 44 freeUncertainEntry(hFile); 45 else 44 if (GetState(hFile) == HSTATE_OUR) 46 45 { 47 if (GetState(hFile) == HSTATE_PE) 48 { 49 rc = deleteNode(hFile); 50 if (rc != NO_ERROR) 51 kprintf(("Funny! deleteNode failed rc = %d\n", rc)); 52 } 46 rc = deleteNode(hFile); 47 if (rc != NO_ERROR) 48 kprintf(("Funny! deleteNode failed rc = %d\n", rc)); 49 50 SetState(hFile, HSTATE_UNUSED); 53 51 } 54 52 55 SetState(hFile, HSTATE_UNUSED);56 53 return _ldrClose(hFile); 57 54 } -
trunk/src/win32k/ldr/myldrOpen.cpp
r847 r1273 1 /* $Id: myldrOpen.cpp,v 1. 1 1999-09-06 02:20:01bird Exp $1 /* $Id: myldrOpen.cpp,v 1.2 1999-10-14 01:25:38 bird Exp $ 2 2 * 3 3 * myldrOpen - _ldrOpen. … … 19 19 #include <os2.h> 20 20 21 #include <string.h> 21 #include "malloc.h" 22 #include <memory.h> 23 #include <stdlib.h> 22 24 25 26 #include "log.h" 27 #include <peexe.h> 28 #include <exe386.h> 23 29 #include "OS2Krnl.h" 24 #include "log.h" 25 #include "malloc.h" 26 #if 0 27 #include "lxFile.h" 28 #else 29 #define LXFile class { public: BOOL queryIsModuleName(const char *) {return FALSE;}} 30 #endif 30 #include "pe2lx.h" 31 31 #include "ldr.h" 32 32 #include "ldrCalls.h" 33 33 34 34 #include "elf.h" 35 35 36 36 /** … … 53 53 if (rc == NO_ERROR) 54 54 { 55 i = getFreeUncertainEntry(); 56 if (i != -1) 55 static char achBuffer[sizeof(IMAGE_DOS_HEADER)]; 56 PIMAGE_DOS_HEADER pMzHdr = (PIMAGE_DOS_HEADER)&achBuffer[0]; 57 char *pach = &achBuffer[0]; 58 59 /** 60 * See if this is an recognizable module format. 61 * This costs up to two disk reads! 62 */ 63 rc = _ldrRead(*phFile, 0UL, pMzHdr, 0UL, sizeof(*pMzHdr), NULL); 64 if (rc == NO_ERROR) 57 65 { 58 ahUncertain[i].offsetNEHdr = 0; 59 ahUncertain[i].fMZ = 0; 60 ahUncertain[i].fPE = 0; 61 ahUncertain[i].hFile = *phFile; 62 ahUncertain[i].pszName = (char*)malloc(strlen(pszFilename)+1); 63 if (ahUncertain[i].pszName != NULL) 64 { 65 strcpy(ahUncertain[i].pszName, pszFilename); 66 SetState(*phFile, HSTATE_CHECK); 66 if (pMzHdr->e_magic == IMAGE_DOS_SIGNATURE && 67 pMzHdr->e_lfanew > sizeof(IMAGE_DOS_HEADER) && pMzHdr->e_lfanew < 0x04000000UL) /* Larger than 64 bytes and less that 64MB. */ 68 { /* MZ header found */ 69 /* read */ 70 rc = _ldrRead(*phFile, pMzHdr->e_lfanew, pMzHdr, 0UL, 4UL, NULL); 71 if (rc == NO_ERROR && *(PULONG)pach == IMAGE_NT_SIGNATURE) 72 { /* PE signature found */ 73 PPENODE pNode; 74 75 kprintf(("_ldrOpen: PE executable!(?)\n")); 76 #pragma info(none) 77 if (/* invoke pe.exe or do conversion now? */ 1) 78 { /* pe2lx - win32k */ 79 #pragma info(restore) 80 pNode = allocateNode(); 81 if (pNode != NULL) 82 { 83 pNode->pPe2Lx = new Pe2Lx(*phFile); 84 if (pNode->pPe2Lx != NULL) 85 { 86 rc = pNode->pPe2Lx->init(pszFilename); 87 if (rc == NO_ERROR) 88 { 89 kprintf(("_ldrOpen: Successfully init of Pe2Lx object.\n")); 90 rc = insertNode(pNode); 91 if (rc != NO_ERROR) 92 { 93 kprintf(("_ldrOpen: Failed to insert PeNode into tree. rc=%d\n")); 94 delete pNode->pPe2Lx; 95 pNode->pPe2Lx = NULL; 96 freeNode(pNode); 97 SetState(*phFile, HSTATE_OUR); 98 } 99 } 100 else 101 { 102 kprintf(("_ldrOpen: Failed to init Pe2Lx object. rc=%d\n")); 103 delete pNode->pPe2Lx; 104 pNode->pPe2Lx = NULL; 105 freeNode(pNode); 106 } 107 } 108 else 109 { 110 kprintf(("_ldrOpen: Failed to allocate Pe2Lx object.\n")); 111 freeNode(pNode); 112 } 113 } 114 else 115 kprintf(("_ldrOpen: Failed to allocate node.\n")); 116 } 117 else 118 { /* pe.exe */ 119 kprintf(("_ldrOpen: pe.exe - opening\n")); 120 _ldrClose(*phFile); 121 rc = _ldrOpen(phFile, "pe.exe", param3); /* path....! problems! */ 122 kprintf(("_ldrOpen: pe.exe - open returned with rc = %d\n", rc)); 123 } 124 } 125 rc = NO_ERROR; 67 126 } 68 127 else 69 128 { 70 kprintf(("myldrOpen: warning - malloc returned NULL\n")); 71 freeUncertainEntry(*phFile); 72 SetState(*phFile, HSTATE_NOT_PE); 129 if (*pach == '#') 130 { 131 /* unix styled script...? must be more than 64 bytes long.... */ 132 char *pszStart = pach+1; 133 char *pszEnd; 134 kprintf(("_ldrOpen: unix script?\n")); 135 /* skip blanks */ 136 while (*pszStart != '\0' && (*pszStart == ' ' || *pszStart == '\t')) 137 pszStart++; 138 if (*pszStart != '\0' && *pszStart != '\r' && *pszStart != '\n') 139 { /* find end-of-word */ 140 while (*pszEnd != '\0' && *pszEnd != '\n' && *pszEnd != '\r' 141 && *pszEnd != '\t' && *pszEnd != ' ') 142 pszEnd++; 143 *pszEnd = '\0'; 144 kprintf(("_ldrOpen: unix script - opening %s\n", pszStart)); 145 _ldrClose(*phFile); 146 rc = _ldrOpen(phFile, pszStart, param3); 147 kprintf(("_ldrOpen: unix script - open returned with rc = %d\n", rc)); 148 } 149 else 150 kprintf(("_ldrOpen: unix script - unexpected end of line/file. (line: %.10s\n", pach)); 151 } 152 else if (pach[0] == ELFMAG0 && pach[1] == ELFMAG1 && pach[2] == ELFMAG2 && pach[3] == ELFMAG3) 153 { 154 /* ELF signature found */ 155 kprintf(("_ldrOpen: ELF executable! - not implemented yet!\n")); 156 } 73 157 } 74 158 } 75 159 else 76 kprintf(("getFreeUncertainEntry failed\n")); 160 { 161 kprintf(("_ldrOpen: _ldrRead failed with rc=%d when reading DosHdr.\n", rc)); 162 rc = NO_ERROR; 163 } 77 164 } 78 165 return rc; -
trunk/src/win32k/ldr/myldrRead.cpp
r847 r1273 1 /* $Id: myldrRead.cpp,v 1. 1 1999-09-06 02:20:01bird Exp $1 /* $Id: myldrRead.cpp,v 1.2 1999-10-14 01:25:39 bird Exp $ 2 2 * 3 3 * myldrRead - _ldrRead. … … 18 18 #include <os2.h> 19 19 20 #include "pefile.h" 21 #include "lx.h" 20 #include <memory.h> 21 #include <stdlib.h> 22 22 23 #include "log.h" 23 24 #include "dev32.h" 25 #include <peexe.h> 26 #include <exe386.h> 27 #include "OS2Krnl.h" 28 #include "pe2lx.h" 29 #include "ldrCalls.h" 24 30 #include "ldr.h" 25 #include "ldrCalls.h"26 27 31 28 32 … … 37 41 { 38 42 ULONG rc; 39 ULONG ulRead;40 int i;41 PPENODE pNode;42 43 43 /* check if this is an PE-file */44 if (GetState(hFile) == HSTATE_ PE)44 /* Check if this is an overrided handle */ 45 if (GetState(hFile) == HSTATE_OUR) 45 46 { 47 PPENODE pNode; 48 46 49 pNode = getNodePtr(hFile); 47 50 if (pNode != NULL) … … 51 54 pNode->pMTE == pMTE; 52 55 53 /* debug*/56 /* debug */ 54 57 if (ulFlags != 0) 55 58 kprintf(("_ldrRead: Warning ulFlags = 0x%x (!= 0)\n", ulFlags)); 56 rc = pNode->lxfile.read(ulOffset, pBuffer, ulBytesToRead, (PULONG)SSToDS(&ulRead), ulFlags); 59 60 rc = pNode->pPe2Lx->read(ulOffset, pBuffer, ulBytesToRead, ulFlags); 57 61 return rc; 58 62 } 59 63 else 60 kprintf(("_ldrRead: DON'T PANIC! - I can't get Node ptr!\n"));64 kprintf(("_ldrRead: DON'T PANIC! - but I can't get Node ptr! - This is really an IPE!\n")); 61 65 } 62 63 66 64 67 rc = _ldrRead( hFile, ulOffset, pBuffer, ulFlags, ulBytesToRead, pMTE ); … … 66 69 // kprintf(("_ldrRead: hF=%+04x off=%+08x pB=%+08x fl=%+08x cb=%+04x pMTE=%+08x rc=%d\n",hFile,ulOffset,pBuffer,ulFlags,ulBytesToRead,pMTE,rc)); 67 70 68 /* check if file is uncertain - try make it certain */69 if (GetState(hFile) == HSTATE_CHECK)70 {71 i = findUncertainEntry(hFile);72 if (!ahUncertain[i].fMZ && ulOffset == 0 && ulBytesToRead >= 0x40)73 {74 /* Stage 1: */75 if (((PUSHORT)pBuffer)[0] == IMAGE_DOS_SIGNATURE)76 { /* MZ */77 ahUncertain[i].offsetNEHdr = *(PULONG)((ULONG)pBuffer+0x3c); /*Need more verification???*/78 ahUncertain[i].fMZ = 1;79 //kprintf(("_ldrRead: Yeah! Detected MZ file - offset of NEHdr=%#x.\n", ahUncertain[i].offsetNEHdr));80 }81 else82 { /* CERTAIN: not a PE-file */83 SetState(hFile, HSTATE_NOT_PE);84 freeUncertainEntry(hFile);85 }86 }87 else88 {89 if (ahUncertain[i].fMZ && ulOffset == ahUncertain[i].offsetNEHdr && ulBytesToRead == sizeof(struct e32_exe))90 {91 /* Stage 2: */92 if (LXFile::isPEFile((PIMAGE_SIG_FILE_HEADER)pBuffer))93 {94 kprintf(("_ldrRead: Yeah! Detected PE file.\n"));95 if (!fQAppType)96 {97 pNode = allocateNode();98 if (pNode != NULL)99 {100 /* setup node */101 pNode->hFile = hFile; //key - but yes it is duplicateded in lxfile102 pNode->pMTE = pMTE;103 insertNode(pNode);104 SetState(hFile, HSTATE_PE);105 pNode->lxfile.SetModuleName(ahUncertain[i].pszName);106 107 /* initiate lxfile */108 if (pNode->lxfile.init(hFile, (PIMAGE_SIG_FILE_HEADER)pBuffer, ahUncertain[i].offsetNEHdr))109 {110 /* init ok - do read */111 ULONG read;112 /*debug*/113 if (ulFlags != 0)114 kprintf(("_ldrRead: Warning ulFlags = 0x%x (!= 0)\n", ulFlags));115 rc = pNode->lxfile.read(ulOffset, pBuffer, ulBytesToRead, (PULONG)SSToDS(&read), ulFlags);116 }117 else118 {119 /* init failed - complain */120 kprintf(("_ldrRead: opps! lxfile.init() failed!\n"));121 }122 }123 else124 {125 /* to not enter an unstable state - free all and mark as no pefile*/126 SetState(hFile, HSTATE_NOT_PE);127 kprintf(("_ldrRead: oops! could not allocate a Node for this file - why?\n"));128 }129 }130 else131 {132 kprintf(("_ldrRead: Building an QAppType-Header!\n"));133 LXFile::buildQAppTypeHeader((struct e32_exe*)pBuffer);134 SetState(hFile, HSTATE_NOT_PE);135 }136 }137 else138 {139 /* CERTAIN: not a pefile! */140 SetState(hFile,HSTATE_NOT_PE);141 }142 freeUncertainEntry(hFile);143 }144 }145 }146 147 71 return rc; 148 72 }
Note:
See TracChangeset
for help on using the changeset viewer.