Changeset 6975 for trunk/src


Ignore:
Timestamp:
Oct 9, 2001, 10:25:21 PM (24 years ago)
Author:
sandervl
Message:

Image header page must be readonly + disabled high memory usage for heap

Location:
trunk/src/kernel32
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/os2heap.cpp

    r6957 r6975  
    1 /* $Id: os2heap.cpp,v 1.25 2001-10-06 19:08:03 sandervl Exp $ */
     1/* $Id: os2heap.cpp,v 1.26 2001-10-09 20:25:20 sandervl Exp $ */
    22
    33/*
     
    325325  *size = (*size / 65536) * 65536 + 65536;
    326326
    327   rc = DosAllocMem(&newblock, *size, flAllocMem|PAG_READ|PAG_WRITE|PAG_COMMIT|PAG_EXECUTE);
     327  rc = DosAllocMem(&newblock, *size, PAG_READ|PAG_WRITE|PAG_COMMIT|PAG_EXECUTE);
     328////  rc = DosAllocMem(&newblock, *size, flAllocMem|PAG_READ|PAG_WRITE|PAG_COMMIT|PAG_EXECUTE);
    328329  if(rc != 0) {
    329330        dprintf(("getmoreHeapMem: DosAllocMem failed with %d", rc));
  • trunk/src/kernel32/oslibdebug.cpp

    r4648 r6975  
    1 /* $Id: oslibdebug.cpp,v 1.5 2000-11-20 09:52:37 sandervl Exp $ */
     1/* $Id: oslibdebug.cpp,v 1.6 2001-10-09 20:25:20 sandervl Exp $ */
    22
    33/*
     
    173173        lpde->u.LoadDll.hFile = 0;
    174174        // TODO: make a pe fakeheader in our DLL's (kernel32,...)
    175         lpde->u.LoadDll.lpBaseOfDll = WINIMAGE_LOOKUPADDR(winmod);
     175        lpde->u.LoadDll.lpBaseOfDll = (PVOID)winmod->getInstanceHandle();
    176176        lpde->u.LoadDll.dwDebugInfoFileOffset = 0;
    177177        lpde->u.LoadDll.nDebugInfoSize = 0;
     
    281281        lpde->dwProcessId = *pid;
    282282        lpde->dwThreadId = 0;
    283         lpde->u.UnloadDll.lpBaseOfDll = WINIMAGE_LOOKUPADDR(winmod);
     283        lpde->u.UnloadDll.lpBaseOfDll = (PVOID)winmod->getInstanceHandle();
    284284        DosWriteQueue(QueueHandle, 0, sizeof(DEBUG_EVENT), lpde, 0);
    285285        break;
     
    414414    lpde->dwThreadId = 0;
    415415    lpde->u.LoadDll.hFile = 0;
    416     lpde->u.LoadDll.lpBaseOfDll = WINIMAGE_LOOKUPADDR(winmod);
     416    lpde->u.LoadDll.lpBaseOfDll = (PVOID)winmod->getInstanceHandle();
    417417    lpde->u.LoadDll.dwDebugInfoFileOffset = 0;
    418418    lpde->u.LoadDll.nDebugInfoSize = 0;
     
    427427    lpde->dwProcessId = getpid(); // debuggee pid
    428428    lpde->dwThreadId = 0;
    429     lpde->u.UnloadDll.lpBaseOfDll = WINIMAGE_LOOKUPADDR(winmod);
     429    lpde->u.UnloadDll.lpBaseOfDll = (PVOID)winmod->getInstanceHandle();
    430430    DosWriteQueue(QueueHandle, 0, sizeof(DEBUG_EVENT), lpde, 0);
    431431  }
  • trunk/src/kernel32/virtual.cpp

    r6693 r6975  
    1 /* $Id: virtual.cpp,v 1.39 2001-09-10 11:03:13 sandervl Exp $ */
     1/* $Id: virtual.cpp,v 1.40 2001-10-09 20:25:20 sandervl Exp $ */
    22
    33/*
     
    652652      pmbiBuffer->State = MEM_RESERVE;
    653653
     654  //TODO: MEM_MAPPED & MEM_IMAGE (==SEC_IMAGE)
    654655  if(!(dAttr & PAG_SHARED))
    655656        pmbiBuffer->Type = MEM_PRIVATE;
  • trunk/src/kernel32/winimagebase.h

    r5959 r6975  
    1 /* $Id: winimagebase.h,v 1.19 2001-06-10 22:32:17 sandervl Exp $ */
     1/* $Id: winimagebase.h,v 1.20 2001-10-09 20:25:20 sandervl Exp $ */
    22
    33/*
     
    175175};
    176176
    177 //SvL: This structure is placed at the end of the first page of the image (header
    178 //     page), so we can determine the Win32Image pointer from a HINSTANCE variable
    179 //     (which is actually the address of the win32 module)
    180 typedef struct
    181 {
    182   ULONG           magic1;
    183   Win32ImageBase *image;
    184   ULONG           magic2;
    185 } WINIMAGE_LOOKUP;
    186 
    187 #define WINIMAGE_LOOKUPADDR(a)  (WINIMAGE_LOOKUP *)((ULONG)a + PAGE_SIZE - sizeof(WINIMAGE_LOOKUP))
    188 
    189177#endif //__WINIMAGEBASE_H__
  • trunk/src/kernel32/winimagepeldr.cpp

    r6145 r6975  
    1 /* $Id: winimagepeldr.cpp,v 1.89 2001-07-03 06:53:39 sandervl Exp $ */
     1/* $Id: winimagepeldr.cpp,v 1.90 2001-10-09 20:25:21 sandervl Exp $ */
    22
    33/*
     
    293293            for (i=0; i<nSections; i++)
    294294            {
     295                dprintf((LOG, "Section:              %-8s", psh[i].Name ));
    295296                dprintf((LOG, "Raw data size:        %x", psh[i].SizeOfRawData ));
    296297                dprintf((LOG, "Virtual Address:      %x", psh[i].VirtualAddress ));
     
    749750        size        = 4096;
    750751        sectionsize = 4096;
    751         protflags   = PAG_READ|PAG_WRITE; //readonly?
     752        //Header page must be readonly (same as in NT)
     753        protflags   = PAG_READ;
    752754        section = findPreviousSectionByOS2Addr(virtAddress);
    753755        if(section == NULL) {//access to header
     
    779781        }
    780782    }
    781     if(fPageCmd == COMPLETE_SECTION && section->type == SECTION_DEBUG) {//ignore
     783    if(fPageCmd == COMPLETE_SECTION && (section && section->type == SECTION_DEBUG)) {//ignore
    782784        return TRUE;
    783785    }
     
    970972{
    971973 ULONG lowestAddr = 0xffffffff;
    972  ULONG index = -1;
     974 LONG index = -1;
    973975
    974976    for(int i=0;i<nrsections;i++) {
    975         if(section[i].realvirtaddr > addr) {
     977        if(section[i].realvirtaddr <= addr) {
    976978            if(section[i].realvirtaddr < lowestAddr) {
    977979                lowestAddr = section[i].realvirtaddr;
     
    10521054{
    10531055 int i;
    1054  WINIMAGE_LOOKUP *imgLookup;
    1055 
    1056   imgLookup = WINIMAGE_LOOKUPADDR(realBaseAddress);
    1057   imgLookup->magic1 = MAGIC_WINIMAGE;
    1058   imgLookup->image  = this;
    1059   imgLookup->magic2 = MAGIC_WINIMAGE;
    10601056
    10611057  // Process all the image sections
Note: See TracChangeset for help on using the changeset viewer.