Database mapping for memory dumps.
| 360 | |
| 361 | |
| 362 | class MemoryDTO(BaseDTO): |
| 363 | """ |
| 364 | Database mapping for memory dumps. |
| 365 | """ |
| 366 | |
| 367 | # Declare the table mapping. |
| 368 | __tablename__ = "memory" |
| 369 | id = Column(Integer, Sequence(__tablename__ + "_seq"), primary_key=True, autoincrement=True) |
| 370 | crash_id = Column(Integer, ForeignKey("crashes.id", ondelete="CASCADE", onupdate="CASCADE"), nullable=False) |
| 371 | address = Column(BigInteger, nullable=False, index=True) |
| 372 | size = Column(BigInteger, nullable=False) |
| 373 | state = Column(MEM_STATE_ENUM, nullable=False) |
| 374 | access = Column(MEM_ACCESS_ENUM) |
| 375 | type = Column(MEM_TYPE_ENUM) |
| 376 | alloc_base = Column(BigInteger) |
| 377 | alloc_access = Column(MEM_ALLOC_ACCESS_ENUM) |
| 378 | filename = Column(String) |
| 379 | content = deferred(Column(LargeBinary)) |
| 380 | |
| 381 | def __init__(self, crash_id, mbi): |
| 382 | """ |
| 383 | Process a L{win32.MemoryBasicInformation} object for database storage. |
| 384 | """ |
| 385 | |
| 386 | # Crash ID. |
| 387 | self.crash_id = crash_id |
| 388 | |
| 389 | # Address. |
| 390 | self.address = mbi.BaseAddress |
| 391 | |
| 392 | # Size. |
| 393 | self.size = mbi.RegionSize |
| 394 | |
| 395 | # State (free or allocated). |
| 396 | if mbi.State == win32.MEM_RESERVE: |
| 397 | self.state = "Reserved" |
| 398 | elif mbi.State == win32.MEM_COMMIT: |
| 399 | self.state = "Commited" |
| 400 | elif mbi.State == win32.MEM_FREE: |
| 401 | self.state = "Free" |
| 402 | else: |
| 403 | self.state = "Unknown" |
| 404 | |
| 405 | # Page protection bits (R/W/X/G). |
| 406 | if mbi.State != win32.MEM_COMMIT: |
| 407 | self.access = None |
| 408 | else: |
| 409 | self.access = self._to_access(mbi.Protect) |
| 410 | |
| 411 | # Type (file mapping, executable image, or private memory). |
| 412 | if mbi.Type == win32.MEM_IMAGE: |
| 413 | self.type = "Image" |
| 414 | elif mbi.Type == win32.MEM_MAPPED: |
| 415 | self.type = "Mapped" |
| 416 | elif mbi.Type == win32.MEM_PRIVATE: |
| 417 | self.type = "Private" |
| 418 | elif mbi.Type == 0: |
| 419 | self.type = None |