- Timestamp:
- Aug 26, 1999, 2:56:02 PM (26 years ago)
- 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.1 7 1999-08-22 11:11:09sandervl Exp $ */1 /* $Id: KERNEL32.CPP,v 1.18 1999-08-26 12:55:34 sandervl Exp $ */ 2 2 3 3 /* … … 31 31 #include "heap.h" 32 32 #include "handlemanager.h" 33 #include "os2util.h"34 33 #include "wprocess.h" 35 34 -
trunk/src/kernel32/console.cpp
r435 r705 1 /* $Id: console.cpp,v 1.1 1 1999-08-06 12:14:10 phallerExp $ */1 /* $Id: console.cpp,v 1.12 1999-08-26 12:55:35 sandervl Exp $ */ 2 2 3 3 /* … … 552 552 *****************************************************************************/ 553 553 554 APIRETiConsoleTerminate(VOID)554 ULONG iConsoleTerminate(VOID) 555 555 { 556 556 APIRET rc; -
trunk/src/kernel32/console.h
r111 r705 1 /* $Id: console.h,v 1. 1 1999-06-17 18:21:41 phallerExp $ */1 /* $Id: console.h,v 1.2 1999-08-26 12:55:36 sandervl Exp $ */ 2 2 3 3 /* … … 33 33 BOOL iConsoleIsActive(void); /* returns TRUE if console window open */ 34 34 35 APIRETiConsoleTerminate(void);/* termination of the console subsystem */35 ULONG iConsoleTerminate(void);/* termination of the console subsystem */ 36 36 37 37 #ifdef __cplusplus -
trunk/src/kernel32/makefile
r690 r705 1 # $Id: makefile,v 1.3 3 1999-08-25 14:27:07sandervl Exp $1 # $Id: makefile,v 1.34 1999-08-26 12:55:36 sandervl Exp $ 2 2 3 3 # … … 23 23 THREAD.OBJ virtual.obj THUNK.OBJ OBSOLETE.OBJ COMM.OBJ \ 24 24 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 \ 26 26 MISC.OBJ EXCEPTUTIL.OBJ LANG.OBJ ICCIO.OBJ MAP.OBJ \ 27 27 WIN32UTIL.OBJ heap.OBJ heapstring.obj os2heap.OBJ \ 28 vmutex.OBJ initterm.OBJ os2util.OBJhandlemanager.OBJ \28 vmutex.OBJ initterm.OBJ handlemanager.OBJ \ 29 29 hmdevice.obj hmopen32.obj hmobjects.obj hmevent.obj \ 30 30 hmmutex.obj hmsemaphore.obj wprocess.OBJ conprop.OBJ \ … … 59 59 $(PDWIN32_INCLUDE)\heap.h \ 60 60 $(PDWIN32_INCLUDE)\wprocess.h \ 61 os2util.h \62 61 $(PDWIN32_INCLUDE)\nameid.h 63 62 … … 151 150 mmap.h \ 152 151 cio.h \ 153 os 2util.h152 oslibmisc.h 154 153 155 154 map.OBJ: \ … … 158 157 mapos2.h 159 158 160 os2native.OBJ: \ 161 .\os2native.cpp \ 162 $(PDWIN32_INCLUDE)\unicode.h 159 oslibdos.OBJ: \ 160 .\oslibdos.cpp oslibdos.h initterm.h 163 161 164 162 network.OBJ: \ … … 203 201 lfile.OBJ: \ 204 202 .\lfile.cpp \ 205 $(PDWIN32_INCLUDE)\wprocess.h \ 206 os2util.h 203 $(PDWIN32_INCLUDE)\wprocess.h 207 204 208 205 obsolete.OBJ: \ … … 249 246 $(PDWIN32_INCLUDE)\misc.h 250 247 251 os 2util.OBJ: .\os2util.cpp248 oslibmisc.OBJ: .\oslibmisc.cpp oslibmisc.h 252 249 253 250 handlemanager.OBJ: \ … … 307 304 308 305 virtual.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 306 mmap.obj: mmap.cpp mmap.h $(PDWIN32_INCLUDE)\vmutex.h oslibdos.h 310 307 311 308 pefile.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 309 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 oslibmisc.h 313 310 winimgres.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 311 windll.OBJ: windll.cpp $(PDWIN32_INCLUDE)\winimage.h $(PDWIN32_INCLUDE)\windll.h oslibmisc.h 315 312 winexe.OBJ: winexe.cpp $(PDWIN32_INCLUDE)\winimage.h $(PDWIN32_INCLUDE)\windll.h $(PDWIN32_INCLUDE)\winexe.h 316 313 stubs.obj: stubs.cpp stubs.h -
trunk/src/kernel32/misc.cpp
r646 r705 1 /* $Id: misc.cpp,v 1. 9 1999-08-23 13:54:43sandervl Exp $ */1 /* $Id: misc.cpp,v 1.10 1999-08-26 12:55:36 sandervl Exp $ */ 2 2 3 3 /* … … 26 26 #include <stdarg.h> 27 27 #include <win32type.h> 28 #include "misc.h" 29 #include "os2util.h" 28 #include <misc.h> 30 29 #include "initterm.h" 31 30 … … 240 239 *****************************************************************************/ 241 240 242 #if 1 /*PLF Mon 97-09-08 20:04:28*/243 241 static FILE *flog = NULL; /*PLF Mon 97-09-08 20:00:15*/ 244 242 static BOOL init = FALSE; … … 277 275 return 1; 278 276 } 279 277 //****************************************************************************** 280 278 //NOTE: No need to save/restore FS, as our FS selectors have already been 281 279 // destroyed and FS == 0x150B. 280 //****************************************************************************** 282 281 void CloseLogFile() 283 282 { … … 285 284 flog = 0; 286 285 } 287 288 286 //****************************************************************************** 287 //****************************************************************************** 289 288 int SYSTEM EXPORT WriteLogError(char *tekst, ...) 290 289 { … … 302 301 return 1; 303 302 } 303 //****************************************************************************** 304 //****************************************************************************** 305 void 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 //****************************************************************************** 322 void 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" 304 336 #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 337 void 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.1 3 1999-08-25 17:05:57sandervl Exp $ */1 /* $Id: mmap.cpp,v 1.14 1999-08-26 12:55:36 sandervl Exp $ */ 2 2 3 3 /* … … 21 21 */ 22 22 #include <os2win.h> 23 #include <stdio.h> 23 24 #include <stdlib.h> 24 25 #include <string.h> … … 30 31 VMutex globalmapMutex; 31 32 33 32 34 //****************************************************************************** 33 35 //TODO: sharing between processes … … 59 61 if(hMemFile != -1) 60 62 { 63 #if 0 61 64 if(DuplicateHandle(GetCurrentProcess(), hMemFile, GetCurrentProcess(), 62 65 &hMemFile, 0, FALSE, DUPLICATE_SAME_ACCESS) == FALSE) … … 65 68 goto fail; 66 69 } 70 #endif 67 71 mSize = SetFilePointer(hMemFile, 0, NULL, FILE_END); 68 72 if(mSize == -1) { … … 176 180 size = mSize - offset; 177 181 } 182 *(char *)pageAddr = 0; //testestestest 178 183 if(SetFilePointer(hMemFile, offset, NULL, FILE_BEGIN) != offset) { 179 184 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:27sandervl Exp $ */1 /* $Id: nameid.cpp,v 1.8 1999-08-26 12:55:36 sandervl Exp $ */ 2 2 3 3 /* … … 24 24 #include <winimage.h> 25 25 #include <winexe.h> 26 #include "os2util.h"27 26 28 27 /******************************************************************************/ … … 49 48 //****************************************************************************** 50 49 //****************************************************************************** 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.1 1 1999-08-22 11:11:10sandervl Exp $ */1 /* $Id: thread.cpp,v 1.12 1999-08-26 12:55:37 sandervl Exp $ */ 2 2 3 3 /* … … 119 119 } 120 120 //****************************************************************************** 121 //TODO: Implement this?? 122 //****************************************************************************** 123 BOOL 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 //****************************************************************************** 132 BOOL WIN32API SetThreadContext(HANDLE hThread, const CONTEXT *lpContext) 133 { 134 dprintf(("SetThreadContext NOT IMPLEMENTED!!\n")); 135 136 return FALSE; 137 } 138 //****************************************************************************** 121 139 //****************************************************************************** 122 140 VOID 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 $ */ 2 2 3 3 /* 4 4 * Win32 virtual memory functions 5 5 * 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 7 9 * 8 10 * Parts (VIRTUAL_MapFileA/W) based on Wine code (memory\virtual.c): … … 21 23 #include <handlemanager.h> 22 24 #include "mmap.h" 25 #include "oslibdos.h" 23 26 24 27 /*********************************************************************** … … 239 242 return hMapping; 240 243 } 244 245 //****************************************************************************** 246 //****************************************************************************** 247 LPVOID 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 //****************************************************************************** 356 BOOL 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 //****************************************************************************** 385 BOOL 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 //****************************************************************************** 450 DWORD 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 //****************************************************************************** 516 BOOL 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 //****************************************************************************** 523 BOOL 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 548 BOOL 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 581 DWORD 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.1 5 1999-08-23 18:06:26sandervl Exp $ */1 /* $Id: windll.cpp,v 1.16 1999-08-26 12:55:37 sandervl Exp $ */ 2 2 3 3 /* … … 23 23 #include <fstream.h> 24 24 #include <misc.h> 25 #include <nameid.h>26 25 #include <win32type.h> 27 26 #include <pefile.h> … … 32 31 #include "cio.h" 33 32 #include "vmutex.h" 33 #include "oslibmisc.h" 34 34 35 35 VMutex dlllistmutex; //protects linked lists of heaps … … 492 492 dprintf(("findModule %s", dllname)); 493 493 494 strcpy(szDllName, StripPath(dllname));494 strcpy(szDllName, OSLibStripPath(dllname)); 495 495 strupr(szDllName); 496 496 dot = strstr(szDllName, "."); -
trunk/src/kernel32/winimage.cpp
r695 r705 1 /* $Id: winimage.cpp,v 1.1 6 1999-08-25 15:27:20sandervl Exp $ */1 /* $Id: winimage.cpp,v 1.17 1999-08-26 12:55:37 sandervl Exp $ */ 2 2 3 3 /* … … 34 34 #include "unicode.h" 35 35 #include "winres.h" 36 #include "os 2util.h"36 #include "oslibmisc.h" 37 37 #include "initterm.h" 38 38 #include <win\virtual.h> … … 75 75 strcpy(this->szFileName, szFileName); 76 76 77 strcpy(szModule, StripPath(szFileName));77 strcpy(szModule, OSLibStripPath(szFileName)); 78 78 strupr(szModule); 79 79 char *dot = strstr(szModule, "."); … … 115 115 szFileName[0] = 0; 116 116 117 char *name = OS 2GetDllName(hinstance);117 char *name = OSLibGetDllName(hinstance); 118 118 strcpy(szModule, name); 119 119 strupr(szModule); -
trunk/src/kernel32/wprocess.cpp
r678 r705 1 /* $Id: wprocess.cpp,v 1.2 8 1999-08-25 10:28:41sandervl Exp $ */1 /* $Id: wprocess.cpp,v 1.29 1999-08-26 12:55:38 sandervl Exp $ */ 2 2 3 3 /* … … 24 24 25 25 #include "exceptutil.h" 26 #include "os 2util.h"26 #include "oslibmisc.h" 27 27 28 28 #include "console.h" … … 75 75 76 76 //Allocate one dword to store the flat address of our TEB 77 TIBFlatPtr = (DWORD *)OS 2AllocThreadLocalMemory(1);77 TIBFlatPtr = (DWORD *)OSLibAllocThreadLocalMemory(1); 78 78 if(TIBFlatPtr == 0) { 79 79 dprintf(("InitializeTIB: local thread memory alloc failed!!")); … … 81 81 return NULL; 82 82 } 83 if(OS 2AllocSel(PAGE_SIZE, &tibsel) == FALSE)83 if(OSLibAllocSel(PAGE_SIZE, &tibsel) == FALSE) 84 84 { 85 85 dprintf(("InitializeTIB: selector alloc failed!!")); … … 87 87 return NULL; 88 88 } 89 winteb = (TEB *)OS 2SelToFlat(tibsel);89 winteb = (TEB *)OSLibSelToFlat(tibsel); 90 90 if(winteb == NULL) 91 91 { … … 99 99 100 100 winteb->except = (PVOID)-1; /* 00 Head of exception handling chain */ 101 winteb->stack_top = (PVOID)OS 2GetTIB(TIB_STACKTOP); /* 04 Top of thread stack */102 winteb->stack_low = (PVOID)OS 2GetTIB(TIB_STACKLOW); /* 08 Stack low-water mark */103 winteb->htask16 = (USHORT)OS 2GetPIB(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 */ 104 104 winteb->stack_sel = getSS(); /* 0e 16-bit stack selector */ 105 105 winteb->self = winteb; /* 18 Pointer to this structure */ … … 115 115 thdb->OrgTIBSel = GetFS(); 116 116 117 if(OS 2GetPIB(PIB_TASKTYPE) == TASKTYPE_PM)117 if(OSLibGetPIB(PIB_TASKTYPE) == TASKTYPE_PM) 118 118 { 119 119 thdb->flags = 0; //todo gui … … 153 153 154 154 //And free our own 155 OS 2FreeSel(thdb->teb_sel);155 OSLibFreeSel(thdb->teb_sel); 156 156 } 157 157 else dprintf(("Already destroyed TIB")); … … 210 210 delete(WinExe); 211 211 212 CheckVersion(Pe2lxVersion, OS 2GetDllName(hinstance));212 CheckVersion(Pe2lxVersion, OSLibGetDllName(hinstance)); 213 213 214 214 if(getenv("WIN32_IOPL2")) { … … 265 265 io_init1(); 266 266 } 267 name = OS 2GetDllName(hinstance);267 name = OSLibGetDllName(hinstance); 268 268 CheckVersion(Pe2lxVersion, name); 269 269 … … 362 362 return(TRUE); 363 363 } 364 dprintf(("KERNEL32: FreeLibrary %s %X\n", OS 2GetDllName(hinstance), hinstance));364 dprintf(("KERNEL32: FreeLibrary %s %X\n", OSLibGetDllName(hinstance), hinstance)); 365 365 366 366 //TODO: Not thread safe … … 435 435 if (hDll == 0) 436 436 { 437 PSZpszName;437 char * pszName; 438 438 439 439 // remove path from the image name 440 pszName = strrchr(( PSZ)lpszLibFile,440 pszName = strrchr((char *)lpszLibFile, 441 441 '\\'); 442 442 if (pszName != NULL) … … 602 602 DWORD rc; 603 603 604 dprintf(("KERNEL32: OS 2GetModuleFileNameW\n"));604 dprintf(("KERNEL32: OSLibGetModuleFileNameW\n")); 605 605 rc = GetModuleFileNameA(hModule, asciifilename, nSize); 606 606 if(rc) AsciiToUnicode(asciifilename, lpFileName); … … 623 623 } 624 624 else { 625 strcpy(szModule, StripPath((char *)lpszModule));625 strcpy(szModule, OSLibStripPath((char *)lpszModule)); 626 626 strupr(szModule); 627 627 if(strstr(szModule, ".DLL")) { … … 647 647 hMod = windll->getInstanceHandle(); 648 648 } 649 else hMod = OS 2iGetModuleHandleA( (PSZ)lpszModule);649 else hMod = OSLibiGetModuleHandleA((char *)lpszModule); 650 650 } 651 651 } … … 754 754 755 755 dprintf(("GetVersionStruct")); 756 hinstance = OS 2QueryModuleHandle(modname);756 hinstance = OSLibQueryModuleHandle(modname); 757 757 if(hinstance == 0) { 758 758 dprintf(("GetVersionStruct can't find handle for %s\n", modname)); … … 773 773 return(FALSE); 774 774 } 775 return OS 2GetResource(hinstance, winimage->getVersionId(), verstruct, bufLength);775 return OSLibGetResource(hinstance, winimage->getVersionId(), verstruct, bufLength); 776 776 } 777 777 //****************************************************************************** … … 783 783 784 784 dprintf(("GetVersionSize of %s\n", modname)); 785 hinstance = OS 2QueryModuleHandle(modname);785 hinstance = OSLibQueryModuleHandle(modname); 786 786 if(hinstance == 0) { 787 787 dprintf(("GetVersionSize can't find handle for %s\n", modname)); … … 803 803 return(FALSE); 804 804 } 805 ULONG size = OS 2GetResourceSize(hinstance, winimage->getVersionId());805 ULONG size = OSLibGetResourceSize(hinstance, winimage->getVersionId()); 806 806 807 807 dprintf(("Version resource size = %d, id %d\n", size, winimage->getVersionId()));
Note:
See TracChangeset
for help on using the changeset viewer.