Changeset 2927 for trunk/src/win32k/pe2lx/pe2lx.cpp
- Timestamp:
- Feb 27, 2000, 3:18:10 AM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/win32k/pe2lx/pe2lx.cpp
r2590 r2927 1 /* $Id: pe2lx.cpp,v 1.1 7 2000-02-01 11:10:54bird Exp $1 /* $Id: pe2lx.cpp,v 1.18 2000-02-27 02:18:10 bird Exp $ 2 2 * 3 3 * Pe2Lx class implementation. Ring 0 and Ring 3 … … 15 15 * Defined Constants And Macros * 16 16 *******************************************************************************/ 17 #define FOR_EXEHDR 1 18 #define INCL_DOSERRORS 17 #define FOR_EXEHDR 1 /* To make all object flags OBJ???. */ 18 #define INCL_DOSERRORS /* DOS Error codes. */ 19 19 #ifdef RING0 20 #define INCL_NOAPI 20 #define INCL_NOAPI /* RING0: No apis. */ 21 21 #else /*RING3*/ 22 #define INCL_DOSFILEMGR /* RING3: DOS File api. */ 23 #define INCL_DOSPROCESS /* RING3: DosSleep. */ 22 #define INCL_DOSPROCESS /* RING3: DosSleep. */ 24 23 #endif 25 24 … … 35 34 36 35 #define MIN_STACK_SIZE 0x20000 /* 128KB stack */ 37 #define CB2PAGES_SHIFT 12 /* count of bytes to count of pages. shift right value. Note. ALIGN!*/38 36 39 37 … … 73 71 74 72 75 /*76 * Read macros.77 * ReadAt: Reads from a file, hFile, at a given offset, ulOffset, into a buffer, pvBuffer,78 * an amount of bytes, cbToRead.79 * RING0: Map this to ldrRead with 0UL as flFlags.80 * RING3: Implementes this function as a static function, ReadAt.81 * ReadAtF: Same as ReadAt but two extra parameters; an additional flag and a pointer to an MTE.82 * Used in the read method.83 * RING0: Map directly to ldrRead.84 * RING3: Map to ReadAt, ignoring the two extra parameters.85 */86 #ifdef RING087 #define ReadAt(hFile, ulOffset, pvBuffer, cbToRead) \88 ldrRead(hFile, ulOffset, pvBuffer, 0UL, cbToRead, NULL)89 #define ReadAtF(hFile, ulOffset, pvBuffer, cbToRead, flFlags, pMTE) \90 ldrRead(hFile, ulOffset, pvBuffer, flFlags, cbToRead, pMTE)91 #else92 #define ReadAtF(hFile, ulOffset, pvBuffer, cbToRead, flFlags, pMTE) \93 ReadAt(hFile, ulOffset, pvBuffer, cbToRead)94 #endif95 96 73 97 74 /******************************************************************************* 98 75 * Header Files * 99 76 *******************************************************************************/ 100 #include <os2.h> 101 #include <peexe.h> 102 #include <neexe.h> 103 #include <newexe.h> 104 #include <exe386.h> 105 106 #include "malloc.h" 107 #include "smalloc.h" 108 #include "rmalloc.h" 109 110 #include <string.h> 111 #include <stdlib.h> 112 #include <stddef.h> 113 #include <stdarg.h> 114 115 #include "vprintf.h" 116 #include "dev32.h" 117 #include "OS2Krnl.h" 77 #include <os2.h> /* OS/2 header file. */ 78 #include <peexe.h> /* Wine PE structs and definitions. */ 79 #include <neexe.h> /* Wine NE structs and definitions. */ 80 #include <newexe.h> /* OS/2 NE structs and definitions. */ 81 #include <exe386.h> /* OS/2 LX structs and definitions. */ 82 83 #include "malloc.h" /* win32k malloc (resident). Not C library! */ 84 #include "smalloc.h" /* win32k swappable heap. */ 85 #include "rmalloc.h" /* win32k resident heap. */ 86 87 #include <string.h> /* C library string.h. */ 88 #include <stdlib.h> /* C library stdlib.h. */ 89 #include <stddef.h> /* C library stddef.h. */ 90 #include <stdarg.h> /* C library stdarg.h. */ 91 92 #include "vprintf.h" /* win32k printf and vprintf. Not C library! */ 93 #include "dev32.h" /* 32-Bit part of the device driver. (SSToDS) */ 94 #include "OS2Krnl.h" /* kernel structs. (SFN) */ 118 95 #ifdef RING0 119 #include "ldrCalls.h" 96 #include "ldrCalls.h" /* ldr* calls. (ldrRead) */ 120 97 #endif 121 #include "modulebase.h" 122 #include "pe2lx.h" 123 #include <versionos2.h> 124 #include "yield.h" 98 #include "modulebase.h" /* ModuleBase class definitions, ++. */ 99 #include "pe2lx.h" /* Pe2Lx class definitions, ++. */ 100 #include <versionos2.h> /* Pe2Lx version. */ 101 #include "yield.h" /* Yield CPU. */ 125 102 126 103 … … 193 170 }; 194 171 195 196 /*******************************************************************************197 * Internal Functions *198 *******************************************************************************/199 #ifndef RING0200 static ULONG ReadAt(SFN hFile, ULONG ulOffset, PVOID pvBuffer, ULONG cbToRead);201 202 203 /**204 *205 * @returns OS/2 return code. (NO_ERROR on success...)206 * @param hFile Handle to file. (RING0: Handle to SystemFileNumber (SFN).)207 * @param ulOffset Offset in the file to start reading at.208 * @param pvBuffer Pointer to output buffer.209 * @param cbToRead Count of bytes to read.210 * @sketch Set Change filepointer to ulOffset.211 * Read cbToRead into pvBufer.212 * @status completely tested.213 * @author knut st. osmundsen214 * @remark215 */216 static ULONG ReadAt(SFN hFile, ULONG ulOffset, PVOID pvBuffer, ULONG cbToRead)217 {218 ULONG cbRead, ulMoved;219 APIRET rc;220 221 rc = DosSetFilePtr(hFile, ulOffset, FILE_BEGIN, &ulMoved);222 if (rc == NO_ERROR)223 rc = DosRead(hFile, pvBuffer, cbToRead, &cbRead);224 else225 printErr(("DosSetFilePtr(hfile, %#8x(%d),..) failed with rc = %d.",226 ulOffset, ulOffset, rc));227 228 return rc;229 }230 #endif231 172 232 173 … … 1408 1349 * @author knut st. osmundsen 1409 1350 */ 1410 ULONG Pe2Lx::write LxFile(PCSZ pszLXFilename)1351 ULONG Pe2Lx::writeFile(PCSZ pszLXFilename) 1411 1352 { 1412 1353 static CHAR achReadBuffer[65000]; … … 1922 1863 paObjTab[0].o32_flags = OBJREAD | OBJWRITE | OBJBIGDEF; 1923 1864 paObjTab[0].o32_pagemap = 1; /* 1 based */ 1924 paObjTab[0].o32_mapsize = ALIGN(paObjTab[0].o32_size, PAGESIZE) >> CB2PAGES_SHIFT;1865 paObjTab[0].o32_mapsize = ALIGN(paObjTab[0].o32_size, PAGESIZE) >> PAGESHIFT; 1925 1866 paObjTab[0].o32_reserved = 0; 1926 1867 } … … 1935 1876 paObjTab[i].o32_flags = paObjects[i].flFlags; 1936 1877 paObjTab[i].o32_pagemap = ulPageMap; 1937 paObjTab[i].o32_mapsize = ALIGN(paObjTab[i].o32_size, PAGESIZE) >> CB2PAGES_SHIFT;1878 paObjTab[i].o32_mapsize = ALIGN(paObjTab[i].o32_size, PAGESIZE) >> PAGESHIFT; 1938 1879 paObjTab[i].o32_reserved = 0; 1939 1880 ulPageMap += paObjTab[i].o32_mapsize; … … 4234 4175 { 4235 4176 if (fAllInOneObject && iObj + 1 < cObjects) 4236 cPages += ALIGN(paObjects[iObj+1].ulRVA - paObjects[iObj].ulRVA, PAGESIZE) >> CB2PAGES_SHIFT;4177 cPages += ALIGN(paObjects[iObj+1].ulRVA - paObjects[iObj].ulRVA, PAGESIZE) >> PAGESHIFT; 4237 4178 else 4238 cPages += ALIGN(paObjects[iObj].cbVirtual, PAGESIZE) >> CB2PAGES_SHIFT;4179 cPages += ALIGN(paObjects[iObj].cbVirtual, PAGESIZE) >> PAGESHIFT; 4239 4180 } 4240 4181
Note:
See TracChangeset
for help on using the changeset viewer.