Skip to content

Commit

Permalink
[REFACT] Cleanup. Removed redundant lines
Browse files Browse the repository at this point in the history
  • Loading branch information
hasherezade committed Jul 7, 2024
1 parent fc8aded commit a29b22f
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 13 deletions.
3 changes: 1 addition & 2 deletions parser/pe/ExportDirWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,13 @@ size_t ExportDirWrapper::mapNames()
nameOrdRVA += sizeof(WORD);
//nameRVA += sizeof(DWORD);
}
//printf("parsed num: %d\n", this->ordToNameRVA.size());
return i;
}

bool ExportDirWrapper::wrap()
{
clear();
size_t mapNum = mapNames();
mapNames();

IMAGE_EXPORT_DIRECTORY* exp = exportDir();
if (exp == NULL) return 0;
Expand Down
5 changes: 2 additions & 3 deletions parser/pe/ImportBaseDirWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ void ImportBaseDirWrapper::reloadMapping()

for (size_t i = 0; i < entriesCount; i++) {
ImportBaseEntryWrapper* lib = dynamic_cast<ImportBaseEntryWrapper*> (this->getEntryAt(i));
if (lib == NULL) continue;
size_t libId = lib->entryNum;
if (!lib) continue;

size_t funcCount = lib->getEntriesCount();
for (size_t fI = 0; fI < funcCount; fI++) {
Expand Down Expand Up @@ -254,7 +253,7 @@ bool ImportBaseFuncWrapper::isValid()

if (!isByOrdinal()) {
char *fName = this->getFunctionName();
if (!imports_util::isNameValid(m_Exe, libName)) return false;
if (!imports_util::isNameValid(m_Exe, fName)) return false;
}
return true;
}
6 changes: 0 additions & 6 deletions parser/pe/ImportDirWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ uint64_t ImportedFuncWrapper::getThunkValue()

bool ImportedFuncWrapper::isByOrdinal()
{
bool isOk = false;

void *p = getValuePtr(ImportEntryWrapper::ORIG_FIRST_THUNK);
if (!p) p = getValuePtr(ImportEntryWrapper::FIRST_THUNK);
if (!p) return false;
Expand Down Expand Up @@ -122,13 +120,9 @@ bufsize_t ImportedFuncWrapper::getSize()

void* ImportedFuncWrapper::getFieldPtr(size_t fId, size_t subField)
{
bool is64 = isBit64();
void *entryPtr = this->getPtr();
if (entryPtr == NULL) return NULL;

IMAGE_THUNK_DATA32* en32 = is64 ? NULL : (IMAGE_THUNK_DATA32*) entryPtr;
IMAGE_THUNK_DATA64* en64 = is64 ? (IMAGE_THUNK_DATA64*) entryPtr : NULL;

switch (fId) {
case ORIG_THUNK: return (void*) getValuePtr(ImportEntryWrapper::ORIG_FIRST_THUNK);
case THUNK: return (void*) getValuePtr(ImportEntryWrapper::FIRST_THUNK);
Expand Down
3 changes: 1 addition & 2 deletions parser/pe/SectHdrsWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -534,15 +534,14 @@ QString SectHdrsWrapper::getFieldName(size_t fieldId)

SectionHdrWrapper* SectHdrsWrapper::getSecHdrAtOffset(offset_t offset, Executable::addr_type addrType, bool recalculate, bool verbose)
{
size_t size = this->entries.size();
std::map<offset_t, SectionHdrWrapper*> *secMap = NULL;

if (addrType == Executable::RAW) {
secMap = &this->rSec;
} else if (addrType == Executable::RVA || addrType == Executable::VA) {
secMap = &this->vSec;
}
if (secMap == NULL) return NULL;
if (!secMap) return NULL;

std::map<offset_t, SectionHdrWrapper*>::iterator found = secMap->lower_bound(offset);
std::map<offset_t, SectionHdrWrapper*>::iterator itr;
Expand Down

0 comments on commit a29b22f

Please sign in to comment.