Skip to content

Commit

Permalink
Revert "Fix warnings"
Browse files Browse the repository at this point in the history
This reverts commit d5d823e.
  • Loading branch information
hasherezade committed Jul 7, 2024
1 parent d921268 commit b0063c4
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 6 deletions.
1 change: 1 addition & 0 deletions commander/Commander.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ bool Commander::addCommand(const std::string& name, Command *cmd, bool overwrite
void Commander::parseCommands()
{
const std::string PROMPT = "$ ";
Command *cmd = NULL;

while (true) {
if (this->context == NULL) throw CmdException("Uninitialized commander context!");
Expand Down
1 change: 0 additions & 1 deletion commander/Commander.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ friend class Commander;
class Command
{
public:
Command() {}
Command(const std::string& v_desc) : desc(v_desc) {}
virtual ~Command() {}

Expand Down
5 changes: 4 additions & 1 deletion commander/ExeCommander.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class DumpWrapperEntriesCommand : public WrapperCommand
{
public:
DumpWrapperEntriesCommand(const std::string& desc, size_t v_wrapperId = INVALID_WRAPPER)
: WrapperCommand(desc, v_wrapperId) {}
: WrapperCommand(desc), wrapperId(v_wrapperId) {}

virtual void wrapperAction(ExeElementWrapper *wrapper)
{
Expand All @@ -196,6 +196,9 @@ class DumpWrapperEntriesCommand : public WrapperCommand
cmd_util::dumpEntryInfo(lib);
cmd_util::dumpNodeInfo(lib);
}

protected:
size_t wrapperId; //TODO: fetch it from params!
};


Expand Down
4 changes: 2 additions & 2 deletions commander/PECommander.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ void cmd_util::printStrings(PEFile *pe, size_t limit)
}
size_t count = wrapper->getResStringsCount();

for (size_t j = 0; j < count; j++) {
for (size_t i = 0; i < count; i++) {
if (limit != 0 && limCount >= limit) return;

ResString *resStr = wrapper->getResStringAt(j);
ResString *resStr = wrapper->getResStringAt(i);
if (resStr != NULL) {
OUT_PADDED_OFFSET(std::cout, resStr->offset);
std::cout << " [" << std::dec << resStr->getSize() << "]" << std::endl;
Expand Down
3 changes: 3 additions & 0 deletions commander/PECommander.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ class PrintStringsCommand : public Command

cmd_util::printStrings(pe, limit);
}
protected:
int wrapperId; //TODO: fetch it from params!
};

class PrintWrapperTypesCommand : public Command
Expand Down Expand Up @@ -208,6 +210,7 @@ class SectionDumpCommand : public Command
PEFile *pe = cmd_util::getPEFromContext(context);
if (!pe) return;

size_t sectHdrCount = pe->getSectionsCount(false);
size_t sectCount = pe->getSectionsCount(true);
std:: cout << "Sections count = " << std::dec << sectCount << "\n";
if (sectCount == 0) {
Expand Down
1 change: 1 addition & 0 deletions parser/pe/ExportDirWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ size_t ExportDirWrapper::mapNames()
bool ExportDirWrapper::wrap()
{
clear();
size_t mapNum = mapNames();

IMAGE_EXPORT_DIRECTORY* exp = exportDir();
if (exp == NULL) return 0;
Expand Down
3 changes: 2 additions & 1 deletion parser/pe/ImportBaseDirWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,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;

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

if (!isByOrdinal()) {
char *fName = this->getFunctionName();
if (!imports_util::isNameValid(m_Exe, fName)) return false;
if (!imports_util::isNameValid(m_Exe, libName)) return false;
}
return true;
}
6 changes: 6 additions & 0 deletions parser/pe/ImportDirWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ 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 @@ -120,9 +122,13 @@ 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: 2 additions & 1 deletion parser/pe/SectHdrsWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ bufsize_t SectionHdrWrapper::getMappedRawSize()
if (secEnd > peSize) {
const bufsize_t trimmedSize = peSize - secOffset; // trim to the file size
if (virtualSize) {
unit = m_PE->getAlignment(Executable::RVA);
bufsize_t unit = m_PE->getAlignment(Executable::RVA);
if (unit != 0) {
virtualSize = roundupToUnit(virtualSize, unit);
}
Expand Down Expand Up @@ -534,6 +534,7 @@ 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) {
Expand Down

0 comments on commit b0063c4

Please sign in to comment.