Changeset 705 for trunk/src


Ignore:
Timestamp:
Aug 26, 1999, 2:56:02 PM (26 years ago)
Author:
sandervl
Message:

Cleanup

Location:
trunk/src/kernel32
Files:
4 added
3 deleted
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/KERNEL32.CPP

    r617 r705  
    1 /* $Id: KERNEL32.CPP,v 1.17 1999-08-22 11:11:09 sandervl Exp $ */
     1/* $Id: KERNEL32.CPP,v 1.18 1999-08-26 12:55:34 sandervl Exp $ */
    22
    33/*
     
    3131#include "heap.h"
    3232#include "handlemanager.h"
    33 #include "os2util.h"
    3433#include "wprocess.h"
    3534
  • trunk/src/kernel32/console.cpp

    r435 r705  
    1 /* $Id: console.cpp,v 1.11 1999-08-06 12:14:10 phaller Exp $ */
     1/* $Id: console.cpp,v 1.12 1999-08-26 12:55:35 sandervl Exp $ */
    22
    33/*
     
    552552 *****************************************************************************/
    553553
    554 APIRET iConsoleTerminate(VOID)
     554ULONG iConsoleTerminate(VOID)
    555555{
    556556  APIRET rc;
  • trunk/src/kernel32/console.h

    r111 r705  
    1 /* $Id: console.h,v 1.1 1999-06-17 18:21:41 phaller Exp $ */
     1/* $Id: console.h,v 1.2 1999-08-26 12:55:36 sandervl Exp $ */
    22
    33/*
     
    3333BOOL  iConsoleIsActive(void);  /* returns TRUE if console window open */
    3434
    35 APIRET iConsoleTerminate(void);/* termination of the console subsystem */
     35ULONG iConsoleTerminate(void);/* termination of the console subsystem */
    3636
    3737#ifdef __cplusplus
  • trunk/src/kernel32/makefile

    r690 r705  
    1 # $Id: makefile,v 1.33 1999-08-25 14:27:07 sandervl Exp $
     1# $Id: makefile,v 1.34 1999-08-26 12:55:36 sandervl Exp $
    22
    33#
     
    2323 THREAD.OBJ virtual.obj THUNK.OBJ OBSOLETE.OBJ COMM.OBJ \
    2424 MESSAGE.OBJ RESOURCE.OBJ NAMEID.OBJ WINRES.OBJ WINMOD.OBJ \
    25  OS2NATIVE.OBJ EXCEPTIONS.OBJ LFILE.OBJ NPIPE.OBJ \
     25 EXCEPTIONS.OBJ LFILE.OBJ NPIPE.OBJ oslibdos.obj oslibmisc.obj \
    2626 MISC.OBJ EXCEPTUTIL.OBJ LANG.OBJ ICCIO.OBJ MAP.OBJ \
    2727 WIN32UTIL.OBJ heap.OBJ heapstring.obj os2heap.OBJ \
    28  vmutex.OBJ initterm.OBJ os2util.OBJ handlemanager.OBJ \
     28 vmutex.OBJ initterm.OBJ handlemanager.OBJ \
    2929 hmdevice.obj hmopen32.obj hmobjects.obj hmevent.obj \
    3030 hmmutex.obj hmsemaphore.obj wprocess.OBJ conprop.OBJ \
     
    5959    $(PDWIN32_INCLUDE)\heap.h \
    6060    $(PDWIN32_INCLUDE)\wprocess.h \
    61     os2util.h \
    6261    $(PDWIN32_INCLUDE)\nameid.h
    6362
     
    151150    mmap.h \
    152151    cio.h \
    153     os2util.h
     152    oslibmisc.h
    154153
    155154map.OBJ: \
     
    158157    mapos2.h
    159158
    160 os2native.OBJ: \
    161     .\os2native.cpp \
    162     $(PDWIN32_INCLUDE)\unicode.h
     159oslibdos.OBJ: \
     160    .\oslibdos.cpp oslibdos.h initterm.h
    163161
    164162network.OBJ: \
     
    203201lfile.OBJ: \
    204202    .\lfile.cpp \
    205     $(PDWIN32_INCLUDE)\wprocess.h \
    206     os2util.h
     203    $(PDWIN32_INCLUDE)\wprocess.h
    207204
    208205obsolete.OBJ: \
     
    249246    $(PDWIN32_INCLUDE)\misc.h
    250247
    251 os2util.OBJ: .\os2util.cpp
     248oslibmisc.OBJ: .\oslibmisc.cpp oslibmisc.h
    252249
    253250handlemanager.OBJ: \
     
    307304
    308305virtual.obj:   virtual.cpp $(PDWIN32_INCLUDE)\win\virtual.h $(PDWIN32_INCLUDE)\handlemanager.h mmap.h
    309 mmap.obj:      mmap.cpp mmap.h $(PDWIN32_INCLUDE)\vmutex.h
     306mmap.obj:      mmap.cpp mmap.h $(PDWIN32_INCLUDE)\vmutex.h oslibdos.h
    310307
    311308pefile.OBJ:    pefile.cpp $(PDWIN32_INCLUDE)\pefile.h
    312 winimage.OBJ:  winimage.cpp $(PDWIN32_INCLUDE)\winimage.h $(PDWIN32_INCLUDE)\windll.h $(PDWIN32_INCLUDE)\pefile.h $(PDWIN32_INCLUDE)\winres.h initterm.h $(PDWIN32_INCLUDE)\win\virtual.h
     309winimage.OBJ:  winimage.cpp $(PDWIN32_INCLUDE)\winimage.h $(PDWIN32_INCLUDE)\windll.h $(PDWIN32_INCLUDE)\pefile.h $(PDWIN32_INCLUDE)\winres.h initterm.h $(PDWIN32_INCLUDE)\win\virtual.h oslibmisc.h
    313310winimgres.OBJ: winimgres.cpp $(PDWIN32_INCLUDE)\winimage.h $(PDWIN32_INCLUDE)\windll.h $(PDWIN32_INCLUDE)\pefile.h $(PDWIN32_INCLUDE)\winexe.h $(PDWIN32_INCLUDE)\winres.h
    314 windll.OBJ:    windll.cpp $(PDWIN32_INCLUDE)\winimage.h $(PDWIN32_INCLUDE)\windll.h
     311windll.OBJ:    windll.cpp $(PDWIN32_INCLUDE)\winimage.h $(PDWIN32_INCLUDE)\windll.h oslibmisc.h
    315312winexe.OBJ:    winexe.cpp $(PDWIN32_INCLUDE)\winimage.h $(PDWIN32_INCLUDE)\windll.h $(PDWIN32_INCLUDE)\winexe.h
    316313stubs.obj:     stubs.cpp stubs.h
  • trunk/src/kernel32/misc.cpp

    r646 r705  
    1 /* $Id: misc.cpp,v 1.9 1999-08-23 13:54:43 sandervl Exp $ */
     1/* $Id: misc.cpp,v 1.10 1999-08-26 12:55:36 sandervl Exp $ */
    22
    33/*
     
    2626#include <stdarg.h>
    2727#include <win32type.h>
    28 #include "misc.h"
    29 #include "os2util.h"
     28#include <misc.h>
    3029#include "initterm.h"
    3130
     
    240239 *****************************************************************************/
    241240
    242 #if 1   /*PLF Mon  97-09-08 20:04:28*/
    243241static FILE *flog = NULL;   /*PLF Mon  97-09-08 20:00:15*/
    244242static BOOL init = FALSE;
     
    277275  return 1;
    278276}
    279 
     277//******************************************************************************
    280278//NOTE: No need to save/restore FS, as our FS selectors have already been
    281279//      destroyed and FS == 0x150B.
     280//******************************************************************************
    282281void CloseLogFile()
    283282{
     
    285284  flog = 0;
    286285}
    287 
    288 
     286//******************************************************************************
     287//******************************************************************************
    289288int SYSTEM EXPORT WriteLogError(char *tekst, ...)
    290289{
     
    302301  return 1;
    303302}
     303//******************************************************************************
     304//******************************************************************************
     305void SYSTEM CheckVersion(ULONG version, char *modname)
     306{
     307    dprintf(("CheckVersion of %s, %d\n", modname, version));
     308    if(version != PE2LX_VERSION){
     309        static char msg[300];
     310        int r;
     311        dprintf(("Version mismatch! %d, %d: %s\n", version, PE2LX_VERSION, modname));
     312        sprintf(msg, "%s is intended for use with a different release of PE2LX.\n", modname);
     313        do{
     314            r = WinMessageBox(HWND_DESKTOP, NULLHANDLE, msg, "Version Mismatch!", 0, MB_ABORTRETRYIGNORE | MB_ICONEXCLAMATION | MB_MOVEABLE);
     315        }while(r == MBID_RETRY);   // giggle
     316        if( r != MBID_IGNORE )
     317            exit(987);
     318    }
     319}
     320//******************************************************************************
     321//******************************************************************************
     322void SYSTEM CheckVersionFromHMOD(ULONG version, HMODULE hModule)
     323{
     324    char name[_MAX_PATH];
     325
     326    // query name of dll.
     327    if(!DosQueryModuleName(hModule, sizeof(name), name))
     328        CheckVersion(version, name);
     329}
     330//******************************************************************************
     331//******************************************************************************
     332#ifdef __WATCOMC__  /*PLF Sat  97-06-21 17:12:36*/
     333    extern void interrupt3( void );
     334    #pragma aux interrupt3= \
     335              "int 3"
    304336#endif
    305 
    306 
    307 /*****************************************************************************
    308  * Modified Standard Version                                                 *
    309  *****************************************************************************/
    310 
    311 #if 0   /*PLF Mon  97-09-08 20:04:26*/
    312 /******************************************************************************/
    313 static BOOL init = FALSE;
    314 static BOOL fLog = TRUE;
    315 /******************************************************************************/
    316 int SYSTEM EXPORT WriteLog(char *tekst, ...)
    317 {
    318 ULONG Action, Wrote;
    319 HFILE log;
    320 APIRET rc;
    321 char message[4096];
    322 va_list argptr;
    323 ULONG openFlags = OPEN_ACTION_CREATE_IF_NEW;
    324 
    325  if(fLog == FALSE)
    326     return(FALSE);
    327 
    328  if(!init) {
    329     init       = TRUE;
    330     openFlags |= OPEN_ACTION_REPLACE_IF_EXISTS;
    331         if(getenv("NOWIN32LOG"))
    332             fLog = FALSE;
    333  }
    334  else   openFlags |= OPEN_ACTION_OPEN_IF_EXISTS;
    335 
    336  rc = DosOpen(
    337               "win32os2.log",
    338               &log,           /* file handle returned */
    339               &Action,
    340               0L,
    341               FILE_NORMAL,
    342               openFlags,
    343               OPEN_ACCESS_READWRITE | OPEN_SHARE_DENYWRITE,
    344               (PEAOP2)NULL);
    345 
    346  rc = DosSetFilePtr(log, 0, FILE_END, &Wrote);
    347  va_start(argptr, tekst);
    348  vsprintf(message, tekst, argptr);
    349  va_end(argptr);
    350 
    351  rc = DosWrite(log, message, strlen(message), &Wrote);
    352 
    353  DosClose(log);   /*PLF Mon  97-09-08 20:01:43*/
    354  return(TRUE);
    355 }
    356 #endif  /*PLF Mon  97-09-08 20:04:23*/
    357 
     337void WIN32API DebugBreak()
     338{
     339  dprintf(("DebugBreak\n"));
     340#ifdef __WATCOMC__
     341  interrupt3();
     342#else
     343  _interrupt(3);
     344#endif
     345}
     346//******************************************************************************
     347//******************************************************************************
  • trunk/src/kernel32/mmap.cpp

    r699 r705  
    1 /* $Id: mmap.cpp,v 1.13 1999-08-25 17:05:57 sandervl Exp $ */
     1/* $Id: mmap.cpp,v 1.14 1999-08-26 12:55:36 sandervl Exp $ */
    22
    33/*
     
    2121 */
    2222#include <os2win.h>
     23#include <stdio.h>
    2324#include <stdlib.h>
    2425#include <string.h>
     
    3031VMutex globalmapMutex;
    3132
     33
    3234//******************************************************************************
    3335//TODO: sharing between processes
     
    5961  if(hMemFile != -1)
    6062  {
     63#if 0
    6164        if(DuplicateHandle(GetCurrentProcess(), hMemFile, GetCurrentProcess(),
    6265                           &hMemFile, 0, FALSE, DUPLICATE_SAME_ACCESS) == FALSE)
     
    6568                goto fail;
    6669        }
     70#endif
    6771        mSize = SetFilePointer(hMemFile, 0, NULL, FILE_END);
    6872        if(mSize == -1) {
     
    176180                        size = mSize - offset;
    177181                }
     182                *(char *)pageAddr = 0;  //testestestest
    178183                if(SetFilePointer(hMemFile, offset, NULL, FILE_BEGIN) != offset) {
    179184                        dprintf(("Win32MemMap::commitPage: SetFilePointer failed to set pos to %x", offset));
  • trunk/src/kernel32/nameid.cpp

    r571 r705  
    1 /* $Id: nameid.cpp,v 1.7 1999-08-19 10:25:27 sandervl Exp $ */
     1/* $Id: nameid.cpp,v 1.8 1999-08-26 12:55:36 sandervl Exp $ */
    22
    33/*
     
    2424#include <winimage.h>
    2525#include <winexe.h>
    26 #include "os2util.h"
    2726
    2827/******************************************************************************/
     
    4948//******************************************************************************
    5049//******************************************************************************
    51 char *StripPath(char *path)
    52 {
    53   /* @@@PH what does this function do ? Strip the path from a FQFN name ? */
    54   char *pszFilename;
    55  
    56   pszFilename = strrchr(path, '\\');                 /* find rightmost slash */
    57   if (pszFilename != NULL)
    58     return (pszFilename++);              /* return pointer to next character */
    59  
    60   pszFilename = strrchr(path, '/');                  /* find rightmost slash */
    61   if (pszFilename != NULL)
    62     return (pszFilename++);              /* return pointer to next character */
    63  
    64   return (path);                                     /* default return value */
    65 }
    66 //******************************************************************************
    67 //******************************************************************************
  • trunk/src/kernel32/thread.cpp

    r617 r705  
    1 /* $Id: thread.cpp,v 1.11 1999-08-22 11:11:10 sandervl Exp $ */
     1/* $Id: thread.cpp,v 1.12 1999-08-26 12:55:37 sandervl Exp $ */
    22
    33/*
     
    119119}
    120120//******************************************************************************
     121//TODO: Implement this??
     122//******************************************************************************
     123BOOL WIN32API GetThreadContext(HANDLE hThread, PCONTEXT lpContext)
     124{
     125  dprintf(("GetThreadContext NOT IMPLEMENTED!! (TRUE)\n"));
     126  memset(lpContext, 0, sizeof(CONTEXT));
     127  return TRUE;
     128}
     129//******************************************************************************
     130//TODO: Implement this??
     131//******************************************************************************
     132BOOL WIN32API SetThreadContext(HANDLE hThread, const CONTEXT *lpContext)
     133{
     134  dprintf(("SetThreadContext NOT IMPLEMENTED!!\n"));
     135
     136  return FALSE;
     137}
     138//******************************************************************************
    121139//******************************************************************************
    122140VOID WIN32API ExitThread(DWORD exitcode)
  • trunk/src/kernel32/virtual.cpp

    r690 r705  
    1 /* $Id: virtual.cpp,v 1.7 1999-08-25 14:27:07 sandervl Exp $ */
     1/* $Id: virtual.cpp,v 1.8 1999-08-26 12:55:37 sandervl Exp $ */
    22
    33/*
    44 * Win32 virtual memory functions
    55 *
    6  * Copyright 1999 Sander van Leeuwen (sandervl@xs4all.nl)
     6 * Copyright 1998-1999 Sander van Leeuwen (sandervl@xs4all.nl)
     7 * Copyright 1998 Knut St. Osmundsen
     8 * Copyright 1998 Peter FitzSimmons
    79 *
    810 * Parts (VIRTUAL_MapFileA/W) based on Wine code (memory\virtual.c):
     
    2123#include <handlemanager.h>
    2224#include "mmap.h"
     25#include "oslibdos.h"
    2326
    2427/***********************************************************************
     
    239242    return hMapping;
    240243}
     244
     245//******************************************************************************
     246//******************************************************************************
     247LPVOID WIN32API VirtualAlloc(LPVOID lpvAddress, DWORD cbSize, DWORD fdwAllocationType,
     248                             DWORD fdwProtect)
     249{
     250 PVOID Address = lpvAddress;
     251 ULONG flag = 0, base;
     252 APIRET rc;
     253
     254  dprintf(("VirtualAlloc at %X; %d bytes, fAlloc %d, fProtect %d\n", (int)lpvAddress, cbSize, fdwAllocationType, fdwProtect));
     255
     256  if (cbSize > 0x7fc00000)  /* 2Gb - 4Mb */
     257  {
     258        dprintf(("VirtualAlloc: size too large"));
     259        SetLastError( ERROR_OUTOFMEMORY );
     260        return NULL;
     261  }
     262
     263  if (!(fdwAllocationType & (MEM_COMMIT | MEM_RESERVE)) ||
     264       (fdwAllocationType & ~(MEM_COMMIT | MEM_RESERVE)))
     265  {
     266        dprintf(("VirtualAlloc: Invalid parameter"));
     267        SetLastError( ERROR_INVALID_PARAMETER );
     268        return NULL;
     269  }
     270
     271  if(fdwAllocationType & MEM_COMMIT) {
     272        dprintf(("VirtualAlloc: commit\n"));
     273        flag = PAG_COMMIT;
     274  }
     275  if(fdwProtect & PAGE_READONLY)          flag |= PAG_READ;
     276  if(fdwProtect & PAGE_READWRITE)         flag |= (PAG_READ | PAG_WRITE);
     277  if(fdwProtect & PAGE_WRITECOPY)         flag |= (PAG_READ | PAG_WRITE);
     278
     279  if(fdwProtect & PAGE_EXECUTE_READWRITE) flag |= (PAG_EXECUTE | PAG_WRITE | PAG_READ);
     280  if(fdwProtect & PAGE_EXECUTE_READ)      flag |= (PAG_EXECUTE | PAG_READ);
     281  if(fdwProtect & PAGE_EXECUTE)           flag |= PAG_EXECUTE;
     282
     283  if(fdwProtect & PAGE_GUARD)             flag |= PAG_GUARD;
     284
     285  //just do this if other options are used
     286  if(!(flag & (PAG_READ | PAG_WRITE | PAG_EXECUTE)) || flag == 0)
     287  {
     288        dprintf(("VirtualAlloc: Unknown protection flags, default to read/write"));
     289        flag |= PAG_READ | PAG_WRITE;
     290  }
     291
     292  if(fdwAllocationType & MEM_COMMIT && lpvAddress != NULL)
     293  {
     294    Address = lpvAddress;
     295
     296    rc = OSLibDosSetMem(lpvAddress, cbSize, flag);
     297
     298    //might try to commit larger part with same base address
     299    if(rc == OSLIB_ERROR_ACCESS_DENIED && cbSize > 4096 )
     300    { //knut: AND more than one page
     301      char *newbase = (char *)lpvAddress + ((cbSize-1) & 0xFFFFF000); //knut: lets not start after the last page!
     302      ULONG size, os2flags;
     303
     304      while(newbase >= (char *)lpvAddress)
     305      {  //knut: should check first page to!!
     306        size     = 4096;
     307        os2flags = 0;
     308        rc = OSLibDosQueryMem(newbase, &size, &os2flags);
     309        if(rc)
     310          break;
     311
     312        if(os2flags & PAG_COMMIT)
     313        {
     314          newbase += 4096;
     315          break;
     316        }
     317        newbase -= 4096;
     318      }
     319
     320      if(rc == 0)
     321      {
     322        //In case it wants to commit bytes that fall into the last
     323        //page of the previous commit command
     324        if(cbSize > ((int)newbase - (int)lpvAddress))
     325                rc = OSLibDosSetMem(newbase, cbSize - ((int)newbase - (int)lpvAddress), flag);
     326      }
     327      else      return(NULL);
     328
     329    }
     330    else
     331    {
     332        if(rc == OSLIB_ERROR_INVALID_ADDRESS) {
     333                rc = OSLibDosAllocMem(&Address, cbSize, flag );
     334        }
     335        else
     336        if(rc)  dprintf(("Unexpected DosSetMem error %x", rc));
     337    }
     338  }
     339  else
     340  {
     341    rc = OSLibDosAllocMem(&Address, cbSize, flag);
     342  }
     343
     344  if(rc)
     345  {
     346    dprintf(("DosSetMem returned %d\n", rc));
     347    SetLastError( ERROR_OUTOFMEMORY );
     348    return(NULL);
     349  }
     350
     351  dprintf(("VirtualAlloc returned %X\n", Address));
     352  return(Address);
     353}
     354//******************************************************************************
     355//******************************************************************************
     356BOOL WIN32API VirtualFree(LPVOID lpvAddress, DWORD cbSize, DWORD FreeType)
     357{
     358 APIRET rc;
     359
     360  dprintf(("VirtualFree at %d; %d bytes, freetype %d\n", (int)lpvAddress, cbSize, FreeType));
     361
     362  if(lpvAddress == NULL || cbSize == 0) {
     363        SetLastError(ERROR_INVALID_PARAMETER);
     364        return(FALSE);
     365  }
     366  if(FreeType & MEM_DECOMMIT) {
     367        rc = OSLibDosSetMem(lpvAddress, cbSize, PAG_DECOMMIT);
     368  }
     369  else  rc = OSLibDosFreeMem(lpvAddress);    //MEM_RELEASE, cbSize == 0 (or should be)
     370
     371  if(rc) {
     372        SetLastError(ERROR_GEN_FAILURE);
     373        return(FALSE);
     374  }
     375  return(TRUE);
     376}
     377//******************************************************************************
     378//LPVOID lpvAddress;            /* address of region of committed pages */
     379//DWORD  cbSize;                /* size of the region   */
     380//DWORD  fdwNewProtect;         /* desired access protection    */
     381//PDWORD pfdwOldProtect;        /* address of variable to get old protection    */
     382//TODO: Not 100% complete
     383//TODO: SetLastError on failure
     384//******************************************************************************
     385BOOL WIN32API VirtualProtect(LPVOID lpvAddress, DWORD cbSize, DWORD fdwNewProtect,
     386                             DWORD *pfdwOldProtect)
     387{
     388 APIRET rc;
     389 ULONG  pageFlags = 0;
     390 int npages;
     391
     392  dprintf(("VirtualProtect %X; %d bytes, new flags %X (%X)\n", (int)lpvAddress, cbSize, fdwNewProtect, pfdwOldProtect));
     393  if(pfdwOldProtect == NULL)
     394        return(FALSE);
     395
     396  rc = OSLibDosQueryMem(lpvAddress, &cbSize, &pageFlags);
     397  if(rc) {
     398        dprintf(("DosQueryMem returned %d\n", rc));
     399        return(FALSE);
     400  }
     401  dprintf(("Old memory flags %X\n", pageFlags));
     402  *pfdwOldProtect = 0;
     403  if(pageFlags & PAG_READ && !(pageFlags & PAG_WRITE))
     404        *pfdwOldProtect |= PAGE_READONLY;
     405  if(pageFlags & (PAG_WRITE))
     406        *pfdwOldProtect |= PAGE_READWRITE;
     407
     408  if(pageFlags & (PAG_WRITE | PAG_EXECUTE))
     409        *pfdwOldProtect |= PAGE_EXECUTE_READWRITE;
     410  else
     411  if(pageFlags & PAG_EXECUTE)
     412        *pfdwOldProtect |= PAGE_EXECUTE_READ;
     413
     414  if(pageFlags & PAG_GUARD)
     415        *pfdwOldProtect |= PAGE_GUARD;
     416  pageFlags = 0;
     417
     418  if(fdwNewProtect & PAGE_READONLY)     pageFlags |= PAG_READ;
     419  if(fdwNewProtect & PAGE_READWRITE)    pageFlags |= (PAG_READ | PAG_WRITE);
     420  if(fdwNewProtect & PAGE_WRITECOPY)    pageFlags |= (PAG_READ | PAG_WRITE);
     421  if(fdwNewProtect & PAGE_EXECUTE_READ) pageFlags |= (PAG_EXECUTE | PAG_READ);
     422  if(fdwNewProtect & PAGE_EXECUTE_READWRITE)
     423        pageFlags |= (PAG_EXECUTE | PAG_WRITE | PAG_READ);
     424  if(fdwNewProtect & PAGE_EXECUTE_WRITECOPY)
     425        pageFlags |= (PAG_EXECUTE | PAG_WRITE | PAG_READ);
     426  if(fdwNewProtect & PAGE_GUARD)        pageFlags |= PAG_GUARD;
     427//Not supported in OS/2??
     428//  if(fdwNewProtect & PAGE_NOACCESS)
     429
     430  dprintf(("New memory flags %X\n", pageFlags));
     431  if(pageFlags == 0) {
     432        dprintf(("pageFlags == 0\n"));
     433        return(TRUE);   //nothing to do
     434  }
     435  npages = ((int)lpvAddress + cbSize >> 12) - ((int)lpvAddress >> 12) + 1;
     436
     437  lpvAddress = (LPVOID)((int)lpvAddress & ~0xFFF);
     438  cbSize     = npages*4096;
     439  dprintf(("lpvAddress = %X, cbSize = %d\n", lpvAddress, cbSize));
     440
     441  rc = OSLibDosSetMem(lpvAddress, cbSize, pageFlags);
     442  if(rc) {
     443        dprintf(("DosSetMem returned %d\n", rc));
     444        return(FALSE);
     445  }
     446  return(TRUE);
     447}
     448//******************************************************************************
     449//******************************************************************************
     450DWORD WIN32API VirtualQuery(LPCVOID lpvAddress, LPMEMORY_BASIC_INFORMATION pmbiBuffer,
     451                            DWORD cbLength)
     452{
     453 ULONG  cbRangeSize, dAttr;
     454 APIRET rc;
     455
     456  if(lpvAddress == NULL || pmbiBuffer == NULL || cbLength == 0) {
     457        return 0;
     458  }
     459  cbRangeSize = cbLength;
     460  rc = OSLibDosQueryMem((LPVOID)lpvAddress, &cbRangeSize, &dAttr);
     461  if(rc) {
     462        dprintf(("VirtualQuery - DosQueryMem %x %x returned %d\n", lpvAddress, cbLength, rc));
     463        return 0;
     464  }
     465  memset(pmbiBuffer, 0, sizeof(MEMORY_BASIC_INFORMATION));
     466  pmbiBuffer->BaseAddress = (LPVOID)lpvAddress;
     467  pmbiBuffer->RegionSize  = cbRangeSize;
     468  if(dAttr & PAG_READ && !(dAttr & PAG_WRITE))
     469        pmbiBuffer->Protect |= PAGE_READONLY;
     470  if(dAttr & PAG_WRITE)
     471        pmbiBuffer->Protect |= PAGE_READWRITE;
     472
     473  if(dAttr & (PAG_WRITE | PAG_EXECUTE))
     474        pmbiBuffer->Protect |= PAGE_EXECUTE_READWRITE;
     475  else
     476  if(dAttr & PAG_EXECUTE)
     477        pmbiBuffer->Protect |= PAGE_EXECUTE_READ;
     478
     479  if(dAttr & PAG_GUARD)
     480        pmbiBuffer->Protect |= PAGE_GUARD;
     481
     482  if(dAttr & PAG_FREE)
     483        pmbiBuffer->State = MEM_FREE;
     484  else
     485  if(dAttr & PAG_COMMIT)
     486        pmbiBuffer->State = MEM_COMMIT;
     487  else  pmbiBuffer->State = MEM_RESERVE;
     488
     489  if(!(dAttr & PAG_SHARED))
     490        pmbiBuffer->Type = MEM_PRIVATE;
     491
     492  //TODO: This is not correct: AllocationProtect should contain the protection
     493  //      flags used in the initial call to VirtualAlloc
     494  pmbiBuffer->AllocationProtect = pmbiBuffer->Protect;
     495  if(dAttr & PAG_BASE) {
     496        pmbiBuffer->AllocationBase = (LPVOID)lpvAddress;
     497  }
     498  else {
     499   while(lpvAddress > 0) {
     500      rc = OSLibDosQueryMem((LPVOID)lpvAddress, &cbRangeSize, &dAttr);
     501      if(rc) {
     502         dprintf(("VirtualQuery - OSLibDosQueryMem %x %x returned %d\n", lpvAddress, cbLength, rc));
     503         break;
     504      }
     505      if(dAttr & PAG_BASE) {
     506         pmbiBuffer->AllocationBase = (LPVOID)lpvAddress;
     507         break;
     508      }
     509      lpvAddress = (LPVOID)((ULONG)lpvAddress - PAGE_SIZE);
     510   }
     511  }
     512  return sizeof(MEMORY_BASIC_INFORMATION);
     513}
     514//******************************************************************************
     515//******************************************************************************
     516BOOL WIN32API VirtualLock( LPVOID lpAddress, DWORD dwSize )
     517{
     518  dprintf(("VirtualLock at %d; %d bytes - stub (TRUE)\n", (int)lpAddress, dwSize));
     519  return TRUE;
     520}
     521
     522//******************************************************************************
     523BOOL WIN32API VirtualUnlock( LPVOID lpAddress, DWORD dwSize )
     524{
     525  dprintf(("VirtualUnlock at %d; %d bytes - stub (TRUE)\n", (int)lpAddress, dwSize));
     526  return TRUE;
     527}
     528
     529/*****************************************************************************
     530 * Name      : BOOL VirtualProtectEx
     531 * Purpose   : The VirtualProtectEx function changes the access protection on
     532 *             a region of committed pages in the virtual address space of a specified
     533 *             process. Note that this function differs from VirtualProtect,
     534 *             which changes the access protection on the calling process only.
     535 * Parameters: HANDLE hProcess       handle of process
     536 *             LPVOID lpvAddress     address of region of committed pages
     537 *             DWORD  cbSize         size of region
     538 *             DWORD  fdwNewProtect  desired access protection
     539 *             PDWORD pfdwOldProtect address of variable to get old protection
     540 * Variables :
     541 * Result    : size of target buffer
     542 * Remark    :
     543 * Status    : UNTESTED STUB
     544 *
     545 * Author    : Patrick Haller [Mon, 1998/06/15 08:00]
     546 *****************************************************************************/
     547
     548BOOL WIN32API VirtualProtectEx(HANDLE hProcess,
     549                                  LPVOID lpvAddress,
     550                                  DWORD  cbSize,
     551                                  DWORD  fdwNewProtect,
     552                                  LPDWORD pfdwOldProtect)
     553{
     554  dprintf(("KERNEL32: VirtualProtectEx(%08x,%08xh,%08xh,%08xh,%08xh) not implemented for different processes.\n",
     555           hProcess,
     556           lpvAddress,
     557           cbSize,
     558           fdwNewProtect,
     559           pfdwOldProtect));
     560
     561  return VirtualProtect(lpvAddress, cbSize, fdwNewProtect, pfdwOldProtect);
     562}
     563
     564
     565/*****************************************************************************
     566 * Name      : DWORD VirtualQueryEx
     567 * Purpose   : The VirtualQueryEx function provides information about a range
     568 *             of pages within the virtual address space of a specified process.
     569 * Parameters: HANDLE  hProcess                     handle of process
     570 *             LPCVOID  lpvAddress                  address of region
     571 *             LPMEMORY_BASIC_INFORMATION pmbiBuffer address of information buffer
     572 *             DWORD  cbLength                      size of buffer
     573 * Variables :
     574 * Result    : number of bytes returned in buffer
     575 * Remark    :
     576 * Status    : UNTESTED STUB
     577 *
     578 * Author    : Patrick Haller [Mon, 1998/06/15 08:00]
     579 *****************************************************************************/
     580
     581DWORD WIN32API VirtualQueryEx(HANDLE  hProcess,
     582                                 LPCVOID  lpvAddress,
     583                                 LPMEMORY_BASIC_INFORMATION pmbiBuffer,
     584                                 DWORD   cbLength)
     585{
     586  dprintf(("KERNEL32: VirtualQueryEx(%08x,%08xh,%08xh,%08xh) not implemented for different processes.\n",
     587           hProcess,
     588           lpvAddress,
     589           pmbiBuffer,
     590           cbLength));
     591
     592  return VirtualQuery(lpvAddress, pmbiBuffer, cbLength);
     593}
     594//******************************************************************************
     595//******************************************************************************
  • trunk/src/kernel32/windll.cpp

    r653 r705  
    1 /* $Id: windll.cpp,v 1.15 1999-08-23 18:06:26 sandervl Exp $ */
     1/* $Id: windll.cpp,v 1.16 1999-08-26 12:55:37 sandervl Exp $ */
    22
    33/*
     
    2323#include <fstream.h>
    2424#include <misc.h>
    25 #include <nameid.h>
    2625#include <win32type.h>
    2726#include <pefile.h>
     
    3231#include "cio.h"
    3332#include "vmutex.h"
     33#include "oslibmisc.h"
    3434
    3535VMutex dlllistmutex;   //protects linked lists of heaps
     
    492492  dprintf(("findModule %s", dllname));
    493493
    494   strcpy(szDllName, StripPath(dllname));
     494  strcpy(szDllName, OSLibStripPath(dllname));
    495495  strupr(szDllName);
    496496  dot = strstr(szDllName, ".");
  • trunk/src/kernel32/winimage.cpp

    r695 r705  
    1 /* $Id: winimage.cpp,v 1.16 1999-08-25 15:27:20 sandervl Exp $ */
     1/* $Id: winimage.cpp,v 1.17 1999-08-26 12:55:37 sandervl Exp $ */
    22
    33/*
     
    3434#include "unicode.h"
    3535#include "winres.h"
    36 #include "os2util.h"
     36#include "oslibmisc.h"
    3737#include "initterm.h"
    3838#include <win\virtual.h>
     
    7575  strcpy(this->szFileName, szFileName);
    7676
    77   strcpy(szModule, StripPath(szFileName));
     77  strcpy(szModule, OSLibStripPath(szFileName));
    7878  strupr(szModule);
    7979  char *dot = strstr(szModule, ".");
     
    115115  szFileName[0] = 0;
    116116
    117   char *name = OS2GetDllName(hinstance);
     117  char *name = OSLibGetDllName(hinstance);
    118118  strcpy(szModule, name);
    119119  strupr(szModule);
  • trunk/src/kernel32/wprocess.cpp

    r678 r705  
    1 /* $Id: wprocess.cpp,v 1.28 1999-08-25 10:28:41 sandervl Exp $ */
     1/* $Id: wprocess.cpp,v 1.29 1999-08-26 12:55:38 sandervl Exp $ */
    22
    33/*
     
    2424
    2525#include "exceptutil.h"
    26 #include "os2util.h"
     26#include "oslibmisc.h"
    2727
    2828#include "console.h"
     
    7575
    7676   //Allocate one dword to store the flat address of our TEB
    77    TIBFlatPtr = (DWORD *)OS2AllocThreadLocalMemory(1);
     77   TIBFlatPtr = (DWORD *)OSLibAllocThreadLocalMemory(1);
    7878   if(TIBFlatPtr == 0) {
    7979        dprintf(("InitializeTIB: local thread memory alloc failed!!"));
     
    8181        return NULL;
    8282   }
    83    if(OS2AllocSel(PAGE_SIZE, &tibsel) == FALSE)
     83   if(OSLibAllocSel(PAGE_SIZE, &tibsel) == FALSE)
    8484   {
    8585        dprintf(("InitializeTIB: selector alloc failed!!"));
     
    8787        return NULL;
    8888   }
    89    winteb = (TEB *)OS2SelToFlat(tibsel);
     89   winteb = (TEB *)OSLibSelToFlat(tibsel);
    9090   if(winteb == NULL)
    9191   {
     
    9999
    100100   winteb->except      = (PVOID)-1;               /* 00 Head of exception handling chain */
    101    winteb->stack_top   = (PVOID)OS2GetTIB(TIB_STACKTOP); /* 04 Top of thread stack */
    102    winteb->stack_low   = (PVOID)OS2GetTIB(TIB_STACKLOW); /* 08 Stack low-water mark */
    103    winteb->htask16     = (USHORT)OS2GetPIB(PIB_TASKHNDL); /* 0c Win16 task handle */
     101   winteb->stack_top   = (PVOID)OSLibGetTIB(TIB_STACKTOP); /* 04 Top of thread stack */
     102   winteb->stack_low   = (PVOID)OSLibGetTIB(TIB_STACKLOW); /* 08 Stack low-water mark */
     103   winteb->htask16     = (USHORT)OSLibGetPIB(PIB_TASKHNDL); /* 0c Win16 task handle */
    104104   winteb->stack_sel   = getSS();                 /* 0e 16-bit stack selector */
    105105   winteb->self        = winteb;                  /* 18 Pointer to this structure */
     
    115115   thdb->OrgTIBSel       = GetFS();
    116116
    117    if(OS2GetPIB(PIB_TASKTYPE) == TASKTYPE_PM)
     117   if(OSLibGetPIB(PIB_TASKTYPE) == TASKTYPE_PM)
    118118   {
    119119        thdb->flags      = 0;  //todo gui
     
    153153
    154154        //And free our own
    155         OS2FreeSel(thdb->teb_sel);
     155        OSLibFreeSel(thdb->teb_sel);
    156156   }
    157157   else dprintf(("Already destroyed TIB"));
     
    210210        delete(WinExe);
    211211
    212   CheckVersion(Pe2lxVersion, OS2GetDllName(hinstance));
     212  CheckVersion(Pe2lxVersion, OSLibGetDllName(hinstance));
    213213
    214214  if(getenv("WIN32_IOPL2")) {
     
    265265                io_init1();
    266266        }
    267         name = OS2GetDllName(hinstance);
     267        name = OSLibGetDllName(hinstance);
    268268        CheckVersion(Pe2lxVersion, name);
    269269
     
    362362    return(TRUE);
    363363  }
    364   dprintf(("KERNEL32: FreeLibrary %s %X\n", OS2GetDllName(hinstance), hinstance));
     364  dprintf(("KERNEL32: FreeLibrary %s %X\n", OSLibGetDllName(hinstance), hinstance));
    365365
    366366  //TODO: Not thread safe
     
    435435  if (hDll == 0)
    436436  {
    437     PSZ pszName;
     437    char * pszName;
    438438
    439439    // remove path from the image name
    440     pszName = strrchr((PSZ)lpszLibFile,
     440    pszName = strrchr((char *)lpszLibFile,
    441441                      '\\');
    442442    if (pszName != NULL)
     
    602602 DWORD rc;
    603603
    604     dprintf(("KERNEL32:  OS2GetModuleFileNameW\n"));
     604    dprintf(("KERNEL32:  OSLibGetModuleFileNameW\n"));
    605605    rc = GetModuleFileNameA(hModule, asciifilename, nSize);
    606606    if(rc)      AsciiToUnicode(asciifilename, lpFileName);
     
    623623  }
    624624  else {
    625         strcpy(szModule, StripPath((char *)lpszModule));
     625        strcpy(szModule, OSLibStripPath((char *)lpszModule));
    626626        strupr(szModule);
    627627        if(strstr(szModule, ".DLL")) {
     
    647647                        hMod = windll->getInstanceHandle();
    648648                }
    649                 else    hMod = OS2iGetModuleHandleA( (PSZ) lpszModule);
     649                else    hMod = OSLibiGetModuleHandleA((char *)lpszModule);
    650650        }
    651651  }
     
    754754
    755755  dprintf(("GetVersionStruct"));
    756   hinstance = OS2QueryModuleHandle(modname);
     756  hinstance = OSLibQueryModuleHandle(modname);
    757757  if(hinstance == 0) {
    758758        dprintf(("GetVersionStruct can't find handle for %s\n", modname));
     
    773773    return(FALSE);
    774774  }
    775   return OS2GetResource(hinstance, winimage->getVersionId(), verstruct, bufLength);
     775  return OSLibGetResource(hinstance, winimage->getVersionId(), verstruct, bufLength);
    776776}
    777777//******************************************************************************
     
    783783
    784784  dprintf(("GetVersionSize of %s\n", modname));
    785   hinstance = OS2QueryModuleHandle(modname);
     785  hinstance = OSLibQueryModuleHandle(modname);
    786786  if(hinstance == 0) {
    787787    dprintf(("GetVersionSize can't find handle for %s\n", modname));
     
    803803        return(FALSE);
    804804  }
    805   ULONG size = OS2GetResourceSize(hinstance, winimage->getVersionId());
     805  ULONG size = OSLibGetResourceSize(hinstance, winimage->getVersionId());
    806806
    807807  dprintf(("Version resource size = %d, id %d\n", size, winimage->getVersionId()));
Note: See TracChangeset for help on using the changeset viewer.