diff options
| author | Anghelo Carvajal <angheloalf95@gmail.com> | 2021-09-23 15:09:12 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-09-23 14:09:12 -0400 |
| commit | 00fe996c8a23c3a5b593e94f21715eee5f843f16 (patch) | |
| tree | 53c4bf0117f78e19c3e0f1f5b938a024fb35a50f /ZAPD/ZResource.cpp | |
| parent | cc481b7945d3940f2343b1b646cd53733440f1a4 (diff) | |
Add `BaseAddress` check (#191)
* Add BaseAddress check
* Fix makefile stuff
* remove "aborting"
* i'm dumb
Diffstat (limited to 'ZAPD/ZResource.cpp')
| -rw-r--r-- | ZAPD/ZResource.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/ZAPD/ZResource.cpp b/ZAPD/ZResource.cpp index bff7037..a28204f 100644 --- a/ZAPD/ZResource.cpp +++ b/ZAPD/ZResource.cpp @@ -235,7 +235,18 @@ uint32_t Seg2Filespace(segptr_t segmentedAddress, uint32_t parentBaseAddress) uint32_t currentPtr = GETSEGOFFSET(segmentedAddress); if (GETSEGNUM(segmentedAddress) == 0x80) // Is defined in code? - currentPtr -= GETSEGOFFSET(parentBaseAddress); + { + uint32_t parentBaseOffset = GETSEGOFFSET(parentBaseAddress); + if (parentBaseOffset > currentPtr) + { + throw std::runtime_error(StringHelper::Sprintf( + "\nSeg2Filespace: Segmented address is smaller than 'BaseAddress'. Maybe your 'BaseAddress' is wrong?\n" + "\t SegmentedAddress: 0x%08X\n" + "\t BaseAddress: 0x%08X\n", + segmentedAddress, parentBaseAddress)); + } + currentPtr -= parentBaseOffset; + } return currentPtr; } |
