8000 Minor changes to address compile-time warnings. · coderforlife/pe-file@b53a851 · GitHub
[go: up one dir, main page]

Skip to content

Commit b53a851

Browse files
committed
Minor changes to address compile-time warnings.
1 parent 86c96e2 commit b53a851

File tree

4 files changed

+31
-31
lines changed

4 files changed

+31
-31
lines changed

PEDataSource.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,14 @@ bool RawDataSource::resize(size_t new_size) {
9292
using namespace std;
9393
typedef map<const_str, vector<void*> > MMFs;
9494
static MMFs mmfs;
95-
static void _RemoveMMF(MMFs &mmfs, const_str file, void* x) {
96-
MMFs::iterator v = mmfs.find(file);
97-
if (v != mmfs.end()) {
95+
static void _RemoveMMF(MMFs &mmfs_, const_str file, void* x) {
96+
MMFs::iterator v = mmfs_.find(file);
97+
if (v != mmfs_.end()) {
9898
size_t size = v->second.size();
9999
for (size_t i = 0; i < size; ++i) {
100100
if (v->second[i] == x) {
101101
if (size == 1) {
102-
mmfs.erase(v);
102+
mmfs_.erase(v);
103103
} else {
104104
if (i != size-1) // move the last element up
105105
v->second[i] = v->second[size-1];
@@ -118,13 +118,13 @@ static MMFs mmfViews;
118118
typedef BOOL (WINAPI *UNMAP_OR_CLOSE)(void*);
119119
static void* AddMMFView(const_str file, void* view) { if (view != NULL) mmfViews[file].push_back(view); return view; }
120120
static void RemoveMMFView(const_str file, void* view) { _RemoveMMF(mmfViews, file, view); }
121-
static void _UnmapAll(MMFs &mmfs, const_str file, UNMAP_OR_CLOSE func) {
122-
MMFs::iterator v = mmfs.find(file);
123-
if (v != mmfs.end()) {
121+
static void _UnmapAll(MMFs &mmfs_, const_str file, UNMAP_OR_CLOSE func) {
122+
MMFs::iterator v = mmfs_.find(file);
123+
if (v != mmfs_.end()) {
124124
size_t size = v->second.size();
125125
for (size_t i = 0; i < size; ++i)
126126
func(v->second[i]);
127-
mmfs.erase(v);
127+
mmfs_.erase(v);
128128
}
129129
}
130130
void MemoryMappedDataSource::UnmapAllViewsOfFile(const_str file) {

PEDataTypes.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ namespace PE {
118118
template<typename T> class dyn_ptr : public dyn_ptr_base<T> {
119119
public:
120120
inline dyn_ptr() : dyn_ptr_base<T>() { }
121-
inline dyn_ptr(void*const* base, size_t off = 0) : dyn_ptr_base<T>(base, off) { }
122-
inline dyn_ptr(void*const* base, T* val) : dyn_ptr_base<T>(base, val) { }
121+
inline dyn_ptr(void*const* base, size_t off_ = 0) : dyn_ptr_base<T>(base, off_) { }
122+
inline dyn_ptr(void*const* base, T* val) : dyn_ptr_base<T>(base, val) { }
123123
inline dyn_ptr(const dyn_ptr<T>& b) : dyn_ptr_base<T>(b.base, b.off) { }
124124
template<typename T2> inline dyn_ptr(const dyn_ptr_base<T2>& b) : dyn_ptr_base<T>(b.base, b.off) { }
125125
template<typename T2> inline dyn_ptr(const dyn_ptr_base<T2> base, T* val) : dyn_ptr_base<T>(base.base, val) { }
@@ -192,12 +192,12 @@ namespace PE {
192192

193193
// +/- operations for many integer sizes, both signed and unsigned
194194
#define PLUS_MINUS_OPS(I) \
195-
inline dyn_ptr<T> operator + (const I& off) { return dyn_ptr<T>(this->base, this->off + sizeof(T)*off); } \
196-
inline const dyn_ptr<T> operator + (const I& off) const { return dyn_ptr<T>(this->base, this->off + sizeof(T)*off); } \
197-
inline dyn_ptr<T> operator - (const I& off) { return dyn_ptr<T>(this->base, this->off - sizeof(T)*off); } \
198-
inline const dyn_ptr<T> operator - (const I& off) const { return dyn_ptr<T>(this->base, this->off - sizeof(T)*off); } \
199-
inline dyn_ptr<T>& operator +=(const I& off) { this->off += sizeof(T)*off; return *this; } \
200-
inline dyn_ptr<T>& operator -=(const I& off) { this->off -= sizeof(T)*off; return *this; }
195+
inline dyn_ptr<T> operator + (const I& off_) { return dyn_ptr<T>(this->base, this->off + sizeof(T)*off_); } \
196+
inline const dyn_ptr<T> operator + (const I& off_) const { return dyn_ptr<T>(this->base, this->off + sizeof(T)*off_); } \
197+
inline dyn_ptr<T> operator - (const I& off_) { return dyn_ptr<T>(this->base, this->off - sizeof(T)*off_); } \
198+
inline const dyn_ptr<T> operator - (const I& off_) const { return dyn_ptr<T>(this->base, this->off - sizeof(T)*off_); } \
199+
inline dyn_ptr<T>& operator +=(const I& off_) { this->off += sizeof(T)*off_; return *this; } \
200+
inline dyn_ptr<T>& operator -=(const I& off_) { this->off -= sizeof(T)*off_; return *this; }
201201
PLUS_MINUS_OPS(size_t)
202202
PLUS_MINUS_OPS(ptrdiff_t)
203203
#if SIZE_MAX > 0xffffffffffffffff

PEFile.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -347,9 +347,9 @@ dyn_ptr<SectionHeader> File::createSection(int i, const char *name, uint32_t roo
347347
if (!at_end && !this->move(pos, header_used_size-pos, sizeof(SectionHeader))) { return nulldp; }
348348
if (!this->set(&s, sizeof(SectionHeader), pos)) { return nulldp; }
349349
++this->header->NumberOfSections;
350-
for (uint16_t s = (uint16_t)i + 1; s <= nSects; ++s) { // update the location and VA of all subsequent sections
351-
this->sections[s].VirtualAddress += move_va;
352-
this->sections[s].PointerToRawData += raw_size;
350+
for (uint16_t si = (uint16_t)i + 1; si <= nSects; ++si) { // update the location and VA of all subsequent sections
351+
this->sections[si].VirtualAddress += move_va;
352+
this->sections[si].PointerToRawData += raw_size;
353353
}
354354
uint32_t ddCount = this->getDataDirectoryCount();
355355
for (uint32_t d = 0; d < ddCount; ++d) { // update the VA of all subsequent data directories
@@ -410,7 +410,7 @@ bool File::resourceExists(const_resid type, const_resid name, uint16_t* lang) co
410410
void* File::getResource(const_resid type, const_resid name, uint16_t lang, size_t* size) const { return this->res->get(type, name, lang, size); }
411411
void* File::getResource(const_resid type, const_resid name, uint16_t* lang, size_t* size) const { return this->res->get(type, name, lang, size); }
412412
bool File::removeResource(const_resid type, const_resid name, uint16_t lang) { return !this->data.isreadonly() && this->res->remove(type, name, lang); }
413-
bool File::addResource(const_resid type, const_resid name, uint16_t lang, const void* data, size_t size, Overwrite overwrite) { return !this->data.isreadonly() && this->res->add(type, name, lang, data, size, overwrite); }
413+
bool File::addResource(const_resid type, const_resid name, uint16_t lang, const void* dat, size_t size, Overwrite overwrite) { return !this->data.isreadonly() && this->res->add(type, name, lang, dat, size, overwrite); }
414414
#pragma endregion
415415

416416
#pragma region Direct Data Functions
@@ -536,7 +536,7 @@ bool File::removeRelocs(uint32_t start, uint32_t end, bool reverse) {
536536
if (!sect) { return true; } // no relocations exist, so nothing to remove!
537537

538538
uint32_t size = sect->SizeOfRawData, pntr = sect->PointerToRawData;
539-
dyn_ptr<byte> data = this->get(pntr);
539+
dyn_ptr<byte> dat = this->get(pntr);
540540

541541
//ABSOLUTE = IMAGE_REL_I386_ABSOLUTE or IMAGE_REL_AMD64_ABSOLUTE
542542
//HIGHLOW => ??? or IMAGE_REL_AMD64_ADDR32NB (32-bit address w/o image base (RVA))
@@ -545,8 +545,8 @@ bool File::removeRelocs(uint32_t start, uint32_t end, bool reverse) {
545545

546546
// Remove everything that is between start and end
547547
// We do a thorough search for possible relocations and do not assume that they are in order
548-
dyn_ptr<void> entry_end = data + size;
549-
for (dyn_ptr<BaseRelocation> entry = (dyn_ptr<BaseRelocation>)data; entry < entry_end && entry->SizeOfBlock > 0; entry = NEXT_RELOCS(entry)) {
548+
dyn_ptr<void> entry_end = dat + size;
549+
for (dyn_ptr<BaseRelocation> entry = (dyn_ptr<BaseRelocation>)dat; entry < entry_end && entry->SizeOfBlock > 0; entry = NEXT_RELOCS(entry)) {
550550

551551
// Check that the ranges overlap
552552
if (entry->VirtualAddress+0xFFF < start || entry->VirtualAddress > end) continue;

PEFileResources.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -669,29 +669,29 @@ ResourceLang::ResourceLang(uint16_t lang, const void* data, size_t size) : lang(
669669
ResourceLang::~ResourceLang() { free(this->data); }
670670
const_resid ResourceLang::getId() const { return MakeResID(this->lang); }
671671
void* ResourceLang::get(size_t *size) const { return memcpy(malloc(this->length), this->data, *size = this->length); }
672-
bool ResourceLang::set(const void* data, size_t size) {
672+
bool ResourceLang::set(const void* dat, size_t size) {
673673
if (this->length != size)
674674
{
675675
free(this->data);
676676
this->data = malloc(this->length = size);
677677
}
678-
memcpy(this->data, data, size);
678+
memcpy(this->data, dat, size);
679679
return true;
680680
}
681681
size_t ResourceLang::getDataSize() const { return this->length; }
682682
size_t ResourceLang::getHeaderSize() const { return sizeof(ResourceDataEntry); }
683683
size_t ResourceLang::getThisHeaderSize() const { return sizeof(ResourceDataEntry); }
684-
void ResourceLang::writeData(bytes data, size_t& posDataEntry, size_t& posData, size_t startVA) const {
684+
void ResourceLang::writeData(bytes dat, size_t& posDataEntry, size_t& posData, size_t startVA) const {
685685
ResourceDataEntry de = {(uint32_t)(posData+startVA), (uint32_t)this->length, 0, 0}; // needs to be an RVA
686-
memcpy(data+posDataEntry, &de, sizeof(ResourceDataEntry));
686+
memcpy(dat+posDataEntry, &de, sizeof(ResourceDataEntry));
687687
posDataEntry += sizeof(ResourceDataEntry);
688-
memcpy(data+posData, this->data, this->length);
688+
memcpy(dat+posData, this->data, this->length);
689689
posData += roundUpTo<4>(this->length);
690690
}
691691
size_t ResourceLang::getRESSize(size_t addl_hdr_size) const { return roundUpTo<4>(this->length + RESHeaderSize + addl_hdr_size); }
692-
void ResourceLang::writeRESData(bytes data, size_t& pos, const_resid type, const_resid name) const {
693-
pos += WriteRESHeader(data+pos, type, name, this->lang, this->length);
694-
memcpy(data+pos, this->data, this->length);
692+
void ResourceLang::writeRESData(bytes dat, size_t& pos, const_resid type, const_resid name) const {
693+
pos += WriteRESHeader(dat+pos, type, name, this->lang, this->length);
694+
memcpy(dat+pos, this->data, this->length);
695695
pos = roundUpTo<4>(pos + this->length);
696696
}
697697
#pragma endregion

0 commit comments

Comments
 (0)
0