Changeset 1325 for trunk/src/kernel32/winimagepe2lx.cpp
- Timestamp:
- Oct 17, 1999, 3:49:09 AM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/winimagepe2lx.cpp
r1274 r1325 1 /* $Id: winimagepe2lx.cpp,v 1. 2 1999-10-14 01:37:56bird Exp $ */1 /* $Id: winimagepe2lx.cpp,v 1.3 1999-10-17 01:49:09 bird Exp $ */ 2 2 3 3 /* … … 118 118 * @param fWin32k TRUE: Win32k module. 119 119 * FALSE: Pe2Lx module. 120 * @status partially implemented. 121 * @author knut st. osmundsen, Sander van Leeuwen 122 */ 123 Win32Pe2LxImage::Win32Pe2LxImage(HINSTANCE hinstance, BOOL fWin32k) 124 : Win32ImageBase(hinstance), 125 paSections(NULL), cSections(0), pNtHdrs(NULL), fWin32k(fWin32k) 126 { 127 } 128 129 130 /** 131 * Free memory associated with this object. 132 * @status completely implemented. 133 * @author knut st. osmundsen, Sander van Leeuwen 134 */ 135 Win32Pe2LxImage::~Win32Pe2LxImage() 136 { 137 cleanup(); 138 } 139 140 141 /** 142 * Initiates the object. 143 * Must be called immediately after the object construction. 144 * @returns Success indicator, TRUE == success; FALSE = failure. 120 145 * @sketch Get section placement and sizes for this module. (paSections, cSections) 121 146 * Verify that there is at least one section - the header section. … … 127 152 * Locate the resource directory (if any). (pResDir, pResourceSectionStart) 128 153 * TLS - FIXME! 129 * @status partially implmented. 130 * @author knut st. osmundsen, Sander van Leeuwen 131 */ 132 Win32Pe2LxImage::Win32Pe2LxImage(HINSTANCE hinstance, BOOL fWin32k) throw(ULONG) 133 : Win32ImageBase(hinstance), 134 paSections(NULL), cSections(0), pNtHdrs(NULL), fWin32k(fWin32k) 154 * @status completely implemented. 155 * @author knut st. osmundsen 156 * @remark Object must be destroyed if failure! 157 */ 158 BOOL Win32Pe2LxImage::init() 135 159 { 136 160 APIRET rc; … … 142 166 dprintf(("Win32Pe2LxImage::Win32Pe2LxImage: error - getSection failed with rc=%d\n", 143 167 rc)); 144 Win32Pe2LxImage::~Win32Pe2LxImage(); 145 throw((ULONG)rc); 168 return FALSE; 146 169 } 147 170 … … 150 173 { 151 174 dprintf(("Win32Pe2LxImage::Win32Pe2LxImage: no header section, cSections is 0\n")); 152 Win32Pe2LxImage::~Win32Pe2LxImage(); 153 throw((ULONG)ERROR_BAD_EXE_FORMAT); 175 return FALSE; 154 176 } 155 177 … … 164 186 { 165 187 dprintf(("Win32Pe2LxImage::Win32Pe2LxImage: Not a pe2lx image!(?)\n")); 166 Win32Pe2LxImage::~Win32Pe2LxImage(); 167 throw((ULONG)ERROR_BAD_EXE_FORMAT); 188 return FALSE; 168 189 } 169 190 … … 186 207 { 187 208 dprintf(("Win32Pe2LxImage::Win32Pe2LxImage: Not a pe2lx image!(?)\n")); 188 Win32Pe2LxImage::~Win32Pe2LxImage(); 189 throw((ULONG)ERROR_BAD_EXE_FORMAT); 209 return FALSE; 190 210 } 191 211 … … 195 215 { 196 216 dprintf(("Win32Pe2LxImage::Win32Pe2LxImage: setSectionRVAs failed with rc=%d\n", rc)); 197 Win32Pe2LxImage::~Win32Pe2LxImage(); 198 throw((ULONG)rc); 217 return FALSE; 199 218 } 200 219 … … 208 227 dprintf(("Win32Pe2LxImage::Win32Pe2LxImage: entrypoint is incorrect, AddrOfEP=0x%08x, entryPoint=0x%08x\n", 209 228 pNtHdrs->OptionalHeader.AddressOfEntryPoint, entryPoint)); 210 Win32Pe2LxImage::~Win32Pe2LxImage(); 211 throw((ULONG)ERROR_INVALID_STARTING_CODESEG); 229 return FALSE; 212 230 } 213 231 … … 220 238 } 221 239 222 /* TLS - FIXME! */ 223 } 224 225 226 /** 227 * Free memory associated with this object. 228 * @status completely implemented. 229 * @author knut st. osmundsen, Sander van Leeuwen 230 */ 231 Win32Pe2LxImage::~Win32Pe2LxImage() 232 { 233 cleanup(); 234 } 240 /* TLS - Thread Local Storage */ 241 if (pNtHdrs->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_TLS].VirtualAddress != 0UL 242 && pNtHdrs->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_TLS].Size != 0UL) 243 { 244 PIMAGE_TLS_DIRECTORY pTLSDir; 245 pTLSDir = (PIMAGE_TLS_DIRECTORY)getPointerFromRVA(pNtHdrs->OptionalHeader. 246 DataDirectory[IMAGE_DIRECTORY_ENTRY_TLS]. 247 VirtualAddress); 248 249 if (pTLSDir != NULL) 250 { 251 PVOID pv; 252 pv = getPointerFromRVA(pTLSDir->StartAddressOfRawData); 253 if (pv == NULL) 254 { 255 eprintf(("Win32Pe2LxImage::init: invalid RVA to TLS StartAddressOfRawData - %#8x.\n", 256 pTLSDir->StartAddressOfRawData)); 257 return FALSE; 258 } 259 setTLSAddress(pv); 260 setTLSInitSize(pTLSDir->EndAddressOfRawData - pTLSDir->StartAddressOfRawData); 261 setTLSTotalSize(pTLSDir->EndAddressOfRawData - pTLSDir->StartAddressOfRawData + pTLSDir->SizeOfZeroFill); 262 pv = getPointerFromRVA((ULONG)pTLSDir->AddressOfIndex); 263 if (pv == NULL) 264 { 265 eprintf(("Win32Pe2LxImage::init: invalid RVA to TLS AddressOffIndex - %#8x.\n", 266 pTLSDir->AddressOfIndex)); 267 return FALSE; 268 } 269 setTLSIndexAddr((LPDWORD)pv); 270 pv = getPointerFromRVA((ULONG)pTLSDir->AddressOfCallBacks); 271 if (pv == NULL) 272 { 273 eprintf(("Win32Pe2LxImage::init: invalid RVA to TLS AddressOffIndex - %#8x.\n", 274 pTLSDir->AddressOfIndex)); 275 return FALSE; 276 } 277 setTLSCallBackAddr((PIMAGE_TLS_CALLBACK*)pv); 278 } 279 else 280 { 281 eprintf(("Win32Pe2LxImage::init: invalid RVA to TLS Dir - %#8x. (getPointerFromRVA failed)\n", 282 pNtHdrs->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_TLS].VirtualAddress)); 283 return FALSE; 284 } 285 } 286 return TRUE; 287 } 288 235 289 236 290
Note:
See TracChangeset
for help on using the changeset viewer.