mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 15:23:51 +00:00
Bug 784739 - Switch from NULL to nullptr in build/; r=ehsan
This commit is contained in:
parent
7fcf2892da
commit
1bde8d50d8
@ -106,7 +106,7 @@ Elf_Shdr null_section(null32_section);
|
||||
|
||||
Elf_Ehdr::Elf_Ehdr(std::ifstream &file, char ei_class, char ei_data)
|
||||
: serializable<Elf_Ehdr_Traits>(file, ei_class, ei_data),
|
||||
ElfSection(null_section, NULL, NULL)
|
||||
ElfSection(null_section, nullptr, nullptr)
|
||||
{
|
||||
shdr.sh_size = Elf_Ehdr::size(ei_class);
|
||||
}
|
||||
@ -176,9 +176,9 @@ Elf::Elf(std::ifstream &file)
|
||||
// Fill sections list
|
||||
sections = new ElfSection *[ehdr->e_shnum];
|
||||
for (int i = 0; i < ehdr->e_shnum; i++)
|
||||
sections[i] = NULL;
|
||||
sections[i] = nullptr;
|
||||
for (int i = 1; i < ehdr->e_shnum; i++) {
|
||||
if (sections[i] != NULL)
|
||||
if (sections[i] != nullptr)
|
||||
continue;
|
||||
getSection(i);
|
||||
}
|
||||
@ -193,31 +193,31 @@ Elf::Elf(std::ifstream &file)
|
||||
s.sh_link = 0;
|
||||
s.sh_info = 0;
|
||||
s.sh_addralign = (e_ident[EI_CLASS] == ELFCLASS32) ? 4 : 8;
|
||||
shdr_section = new ElfSection(s, NULL, NULL);
|
||||
shdr_section = new ElfSection(s, nullptr, nullptr);
|
||||
|
||||
// Fake section for program headers
|
||||
s.sh_offset = ehdr->e_phoff;
|
||||
s.sh_addr = ehdr->e_phoff;
|
||||
s.sh_entsize = Elf_Phdr::size(e_ident[EI_CLASS]);
|
||||
s.sh_size = s.sh_entsize * ehdr->e_phnum;
|
||||
phdr_section = new ElfSection(s, NULL, NULL);
|
||||
phdr_section = new ElfSection(s, nullptr, nullptr);
|
||||
|
||||
phdr_section->insertAfter(ehdr, false);
|
||||
|
||||
sections[1]->insertAfter(phdr_section, false);
|
||||
for (int i = 2; i < ehdr->e_shnum; i++) {
|
||||
// TODO: this should be done in a better way
|
||||
if ((shdr_section->getPrevious() == NULL) && (shdr[i]->sh_offset > ehdr->e_shoff)) {
|
||||
if ((shdr_section->getPrevious() == nullptr) && (shdr[i]->sh_offset > ehdr->e_shoff)) {
|
||||
shdr_section->insertAfter(sections[i - 1], false);
|
||||
sections[i]->insertAfter(shdr_section, false);
|
||||
} else
|
||||
sections[i]->insertAfter(sections[i - 1], false);
|
||||
}
|
||||
if (shdr_section->getPrevious() == NULL)
|
||||
if (shdr_section->getPrevious() == nullptr)
|
||||
shdr_section->insertAfter(sections[ehdr->e_shnum - 1], false);
|
||||
|
||||
tmp_file = NULL;
|
||||
tmp_shdr = NULL;
|
||||
tmp_file = nullptr;
|
||||
tmp_shdr = nullptr;
|
||||
for (int i = 0; i < ehdr->e_shnum; i++)
|
||||
delete shdr[i];
|
||||
delete[] shdr;
|
||||
@ -280,7 +280,7 @@ Elf::~Elf()
|
||||
delete *seg;
|
||||
delete[] sections;
|
||||
ElfSection *section = ehdr;
|
||||
while (section != NULL) {
|
||||
while (section != nullptr) {
|
||||
ElfSection *next = section->getNext();
|
||||
delete section;
|
||||
section = next;
|
||||
@ -296,11 +296,11 @@ ElfSection *Elf::getSection(int index)
|
||||
index = ehdr->e_shstrndx; // TODO: should be fixed to use the actual current number
|
||||
// Special case: the section at index 0 is void
|
||||
if (index == 0)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
// Infinite recursion guard
|
||||
if (sections[index] == (ElfSection *)this)
|
||||
return NULL;
|
||||
if (sections[index] == NULL) {
|
||||
return nullptr;
|
||||
if (sections[index] == nullptr) {
|
||||
sections[index] = (ElfSection *)this;
|
||||
switch (tmp_shdr[index]->sh_type) {
|
||||
case SHT_DYNAMIC:
|
||||
@ -330,11 +330,11 @@ ElfSection *Elf::getSectionAt(unsigned int offset)
|
||||
{
|
||||
for (int i = 1; i < ehdr->e_shnum; i++) {
|
||||
ElfSection *section = getSection(i);
|
||||
if ((section != NULL) && (section->getFlags() & SHF_ALLOC) && !(section->getFlags() & SHF_TLS) &&
|
||||
if ((section != nullptr) && (section->getFlags() & SHF_ALLOC) && !(section->getFlags() & SHF_TLS) &&
|
||||
(offset >= section->getAddr()) && (offset < section->getAddr() + section->getSize()))
|
||||
return section;
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ElfSegment *Elf::getSegmentByType(unsigned int type, ElfSegment *last)
|
||||
@ -348,7 +348,7 @@ ElfSegment *Elf::getSegmentByType(unsigned int type, ElfSegment *last)
|
||||
for (; seg != segments.end(); seg++)
|
||||
if ((*seg)->getType() == type)
|
||||
return *seg;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void Elf::removeSegment(ElfSegment *segment)
|
||||
@ -366,18 +366,18 @@ void Elf::removeSegment(ElfSegment *segment)
|
||||
ElfDynamic_Section *Elf::getDynSection()
|
||||
{
|
||||
for (std::vector<ElfSegment *>::iterator seg = segments.begin(); seg != segments.end(); seg++)
|
||||
if (((*seg)->getType() == PT_DYNAMIC) && ((*seg)->getFirstSection() != NULL) &&
|
||||
if (((*seg)->getType() == PT_DYNAMIC) && ((*seg)->getFirstSection() != nullptr) &&
|
||||
(*seg)->getFirstSection()->getType() == SHT_DYNAMIC)
|
||||
return (ElfDynamic_Section *)(*seg)->getFirstSection();
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void Elf::normalize()
|
||||
{
|
||||
// fixup section headers sh_name; TODO: that should be done by sections
|
||||
// themselves
|
||||
for (ElfSection *section = ehdr; section != NULL; section = section->getNext()) {
|
||||
for (ElfSection *section = ehdr; section != nullptr; section = section->getNext()) {
|
||||
if (section->getIndex() == 0)
|
||||
continue;
|
||||
else
|
||||
@ -414,7 +414,7 @@ void Elf::write(std::ofstream &file)
|
||||
{
|
||||
normalize();
|
||||
for (ElfSection *section = ehdr;
|
||||
section != NULL; section = section->getNext()) {
|
||||
section != nullptr; section = section->getNext()) {
|
||||
file.seekp(section->getOffset());
|
||||
if (section == phdr_section) {
|
||||
for (std::vector<ElfSegment *>::iterator seg = segments.begin(); seg != segments.end(); seg++) {
|
||||
@ -431,7 +431,7 @@ void Elf::write(std::ofstream &file)
|
||||
}
|
||||
} else if (section == shdr_section) {
|
||||
null_section.serialize(file, ehdr->e_ident[EI_CLASS], ehdr->e_ident[EI_DATA]);
|
||||
for (ElfSection *sec = ehdr; sec!= NULL; sec = sec->getNext()) {
|
||||
for (ElfSection *sec = ehdr; sec!= nullptr; sec = sec->getNext()) {
|
||||
if (sec->getType() != SHT_NULL)
|
||||
sec->getShdr().serialize(file, ehdr->e_ident[EI_CLASS], ehdr->e_ident[EI_DATA]);
|
||||
}
|
||||
@ -442,11 +442,11 @@ void Elf::write(std::ofstream &file)
|
||||
|
||||
ElfSection::ElfSection(Elf_Shdr &s, std::ifstream *file, Elf *parent)
|
||||
: shdr(s),
|
||||
link(shdr.sh_link == SHN_UNDEF ? NULL : parent->getSection(shdr.sh_link)),
|
||||
next(NULL), previous(NULL), index(-1)
|
||||
link(shdr.sh_link == SHN_UNDEF ? nullptr : parent->getSection(shdr.sh_link)),
|
||||
next(nullptr), previous(nullptr), index(-1)
|
||||
{
|
||||
if ((file == NULL) || (shdr.sh_type == SHT_NULL) || (shdr.sh_type == SHT_NOBITS))
|
||||
data = NULL;
|
||||
if ((file == nullptr) || (shdr.sh_type == SHT_NULL) || (shdr.sh_type == SHT_NOBITS))
|
||||
data = nullptr;
|
||||
else {
|
||||
data = new char[shdr.sh_size];
|
||||
int pos = file->tellg();
|
||||
@ -455,12 +455,12 @@ ElfSection::ElfSection(Elf_Shdr &s, std::ifstream *file, Elf *parent)
|
||||
file->seekg(pos);
|
||||
}
|
||||
if (shdr.sh_name == 0)
|
||||
name = NULL;
|
||||
name = nullptr;
|
||||
else {
|
||||
ElfStrtab_Section *strtab = (ElfStrtab_Section *) parent->getSection(-1);
|
||||
// Special case (see elfgeneric.cpp): if strtab is NULL, the
|
||||
// Special case (see elfgeneric.cpp): if strtab is nullptr, the
|
||||
// section being created is the strtab.
|
||||
if (strtab == NULL)
|
||||
if (strtab == nullptr)
|
||||
name = &data[shdr.sh_name];
|
||||
else
|
||||
name = strtab->getStr(shdr.sh_name);
|
||||
@ -468,7 +468,7 @@ ElfSection::ElfSection(Elf_Shdr &s, std::ifstream *file, Elf *parent)
|
||||
// Only SHT_REL/SHT_RELA sections use sh_info to store a section
|
||||
// number.
|
||||
if ((shdr.sh_type == SHT_REL) || (shdr.sh_type == SHT_RELA))
|
||||
info.section = shdr.sh_info ? parent->getSection(shdr.sh_info) : NULL;
|
||||
info.section = shdr.sh_info ? parent->getSection(shdr.sh_info) : nullptr;
|
||||
else
|
||||
info.index = shdr.sh_info;
|
||||
}
|
||||
@ -480,7 +480,7 @@ unsigned int ElfSection::getAddr()
|
||||
|
||||
// It should be safe to adjust sh_addr for all allocated sections that
|
||||
// are neither SHT_NOBITS nor SHT_PROGBITS
|
||||
if ((previous != NULL) && isRelocatable()) {
|
||||
if ((previous != nullptr) && isRelocatable()) {
|
||||
unsigned int addr = previous->getAddr();
|
||||
if (previous->getType() != SHT_NOBITS)
|
||||
addr += previous->getSize();
|
||||
@ -498,7 +498,7 @@ unsigned int ElfSection::getOffset()
|
||||
if (shdr.sh_offset != (Elf32_Word)-1)
|
||||
return shdr.sh_offset;
|
||||
|
||||
if (previous == NULL)
|
||||
if (previous == nullptr)
|
||||
return (shdr.sh_offset = 0);
|
||||
|
||||
unsigned int offset = previous->getOffset();
|
||||
@ -547,8 +547,8 @@ int ElfSection::getIndex()
|
||||
if (getType() == SHT_NULL)
|
||||
return (index = 0);
|
||||
ElfSection *reference;
|
||||
for (reference = previous; (reference != NULL) && (reference->getType() == SHT_NULL); reference = reference->getPrevious());
|
||||
if (reference == NULL)
|
||||
for (reference = previous; (reference != nullptr) && (reference->getType() == SHT_NULL); reference = reference->getPrevious());
|
||||
if (reference == nullptr)
|
||||
return (index = 1);
|
||||
return (index = reference->getIndex() + 1);
|
||||
}
|
||||
@ -661,13 +661,13 @@ ElfValue *ElfDynamic_Section::getValueForType(unsigned int tag)
|
||||
if (dyns[i].tag == tag)
|
||||
return dyns[i].value;
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ElfSection *ElfDynamic_Section::getSectionForType(unsigned int tag)
|
||||
{
|
||||
ElfValue *value = getValueForType(tag);
|
||||
return value ? value->getSection() : NULL;
|
||||
return value ? value->getSection() : nullptr;
|
||||
}
|
||||
|
||||
bool ElfDynamic_Section::setValueForType(unsigned int tag, ElfValue *val)
|
||||
@ -739,7 +739,7 @@ ElfDynamic_Section::ElfDynamic_Section(Elf_Shdr &s, std::ifstream *file, Elf *pa
|
||||
dyns[i].value = new ElfLocation(dyn.d_un.d_ptr, parent);
|
||||
break;
|
||||
default:
|
||||
dyns[i].value = NULL;
|
||||
dyns[i].value = nullptr;
|
||||
}
|
||||
}
|
||||
// Another loop to get the section sizes
|
||||
@ -788,7 +788,7 @@ void ElfDynamic_Section::serialize(std::ofstream &file, char ei_class, char ei_d
|
||||
for (unsigned int i = 0; i < shdr.sh_size / shdr.sh_entsize; i++) {
|
||||
Elf_Dyn dyn;
|
||||
dyn.d_tag = dyns[i].tag;
|
||||
dyn.d_un.d_val = (dyns[i].value != NULL) ? dyns[i].value->getValue() : 0;
|
||||
dyn.d_un.d_val = (dyns[i].value != nullptr) ? dyns[i].value->getValue() : 0;
|
||||
dyn.serialize(file, ei_class, ei_data);
|
||||
}
|
||||
}
|
||||
@ -805,7 +805,7 @@ ElfSymtab_Section::ElfSymtab_Section(Elf_Shdr &s, std::ifstream *file, Elf *pare
|
||||
syms[i].name = strtab->getStr(sym.st_name);
|
||||
syms[i].info = sym.st_info;
|
||||
syms[i].other = sym.st_other;
|
||||
ElfSection *section = (sym.st_shndx == SHN_ABS) ? NULL : parent->getSection(sym.st_shndx);
|
||||
ElfSection *section = (sym.st_shndx == SHN_ABS) ? nullptr : parent->getSection(sym.st_shndx);
|
||||
new (&syms[i].value) ElfLocation(section, sym.st_value, ElfLocation::ABSOLUTE);
|
||||
syms[i].size = sym.st_size;
|
||||
syms[i].defined = (sym.st_shndx != SHN_UNDEF);
|
||||
@ -843,7 +843,7 @@ ElfSymtab_Section::lookup(const char *name, unsigned int type_filter)
|
||||
return &*sym;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const char *
|
||||
@ -856,14 +856,14 @@ ElfStrtab_Section::getStr(unsigned int index)
|
||||
index -= t->used;
|
||||
}
|
||||
assert(1 == 0);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const char *
|
||||
ElfStrtab_Section::getStr(const char *string)
|
||||
{
|
||||
if (string == NULL)
|
||||
return NULL;
|
||||
if (string == nullptr)
|
||||
return nullptr;
|
||||
|
||||
// If the given string is within the section, return it
|
||||
for (std::vector<table_storage>::iterator t = table.begin();
|
||||
@ -892,7 +892,7 @@ ElfStrtab_Section::getStr(const char *string)
|
||||
unsigned int
|
||||
ElfStrtab_Section::getStrIndex(const char *string)
|
||||
{
|
||||
if (string == NULL)
|
||||
if (string == nullptr)
|
||||
return 0;
|
||||
|
||||
unsigned int index = 0;
|
||||
|
@ -26,7 +26,7 @@
|
||||
#define R_ARM_THM_JUMP24 0x1e
|
||||
#endif
|
||||
|
||||
char *rundir = NULL;
|
||||
char *rundir = nullptr;
|
||||
|
||||
template <typename T>
|
||||
struct wrapped {
|
||||
@ -63,7 +63,7 @@ typedef serializable<Elf_RelHack_Traits> Elf_RelHack;
|
||||
class ElfRelHack_Section: public ElfSection {
|
||||
public:
|
||||
ElfRelHack_Section(Elf_Shdr &s)
|
||||
: ElfSection(s, NULL, NULL)
|
||||
: ElfSection(s, nullptr, nullptr)
|
||||
{
|
||||
name = elfhack_data;
|
||||
};
|
||||
@ -90,7 +90,7 @@ private:
|
||||
class ElfRelHackCode_Section: public ElfSection {
|
||||
public:
|
||||
ElfRelHackCode_Section(Elf_Shdr &s, Elf &e, unsigned int init)
|
||||
: ElfSection(s, NULL, NULL), parent(e), init(init) {
|
||||
: ElfSection(s, nullptr, nullptr), parent(e), init(init) {
|
||||
std::string file(rundir);
|
||||
file += "/inject/";
|
||||
switch (parent.getMachine()) {
|
||||
@ -114,15 +114,15 @@ public:
|
||||
if (elf->getMachine() != parent.getMachine())
|
||||
throw std::runtime_error("architecture of object for injected code doesn't match");
|
||||
|
||||
ElfSymtab_Section *symtab = NULL;
|
||||
ElfSymtab_Section *symtab = nullptr;
|
||||
|
||||
// Find the symbol table.
|
||||
for (ElfSection *section = elf->getSection(1); section != NULL;
|
||||
for (ElfSection *section = elf->getSection(1); section != nullptr;
|
||||
section = section->getNext()) {
|
||||
if (section->getType() == SHT_SYMTAB)
|
||||
symtab = (ElfSymtab_Section *) section;
|
||||
}
|
||||
if (symtab == NULL)
|
||||
if (symtab == nullptr)
|
||||
throw std::runtime_error("Couldn't find a symbol table for the injected code");
|
||||
|
||||
// Find the init symbol
|
||||
@ -171,7 +171,7 @@ public:
|
||||
|
||||
// Apply relocations
|
||||
for (std::vector<ElfSection *>::iterator c = code.begin(); c != code.end(); c++) {
|
||||
for (ElfSection *rel = elf->getSection(1); rel != NULL; rel = rel->getNext())
|
||||
for (ElfSection *rel = elf->getSection(1); rel != nullptr; rel = rel->getNext())
|
||||
if (((rel->getType() == SHT_REL) ||
|
||||
(rel->getType() == SHT_RELA)) &&
|
||||
(rel->getInfo().section == *c)) {
|
||||
@ -205,7 +205,7 @@ private:
|
||||
* sections that it requires */
|
||||
void find_code(ElfSection *section)
|
||||
{
|
||||
for (ElfSection *s = elf->getSection(1); s != NULL;
|
||||
for (ElfSection *s = elf->getSection(1); s != nullptr;
|
||||
s = s->getNext()) {
|
||||
if (((s->getType() == SHT_REL) ||
|
||||
(s->getType() == SHT_RELA)) &&
|
||||
@ -225,9 +225,9 @@ private:
|
||||
for (auto r = rel->rels.begin(); r != rel->rels.end(); r++) {
|
||||
ElfSection *section = symtab->syms[ELF32_R_SYM(r->r_info)].value.getSection();
|
||||
if (section) {
|
||||
for (ElfSection *s = elf->getSection(1); s != NULL; s = s->getNext()) {
|
||||
for (ElfSection *s = elf->getSection(1); s != nullptr; s = s->getNext()) {
|
||||
if (section == s)
|
||||
section = NULL;
|
||||
section = nullptr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -346,7 +346,7 @@ private:
|
||||
// TODO: various checks on the symbol
|
||||
const char *name = symtab->syms[ELF32_R_SYM(r->r_info)].name;
|
||||
unsigned int addr;
|
||||
if (symtab->syms[ELF32_R_SYM(r->r_info)].value.getSection() == NULL) {
|
||||
if (symtab->syms[ELF32_R_SYM(r->r_info)].value.getSection() == nullptr) {
|
||||
if (strcmp(name, "relhack") == 0) {
|
||||
addr = getNext()->getAddr();
|
||||
} else if (strcmp(name, "elf_header") == 0) {
|
||||
@ -500,7 +500,7 @@ template <typename Rel_Type>
|
||||
int do_relocation_section(Elf *elf, unsigned int rel_type, unsigned int rel_type2, bool force, bool fill)
|
||||
{
|
||||
ElfDynamic_Section *dyn = elf->getDynSection();
|
||||
if (dyn ==NULL) {
|
||||
if (dyn == nullptr) {
|
||||
fprintf(stderr, "Couldn't find SHT_DYNAMIC section\n");
|
||||
return -1;
|
||||
}
|
||||
@ -535,7 +535,7 @@ int do_relocation_section(Elf *elf, unsigned int rel_type, unsigned int rel_type
|
||||
// are actually run by DT_INIT code.
|
||||
ElfValue *value = dyn->getValueForType(DT_INIT);
|
||||
unsigned int original_init = value ? value->getValue() : 0;
|
||||
ElfSection *init_array = NULL;
|
||||
ElfSection *init_array = nullptr;
|
||||
if (!value || !value->getValue()) {
|
||||
value = dyn->getValueForType(DT_INIT_ARRAYSZ);
|
||||
if (value && value->getValue() >= entry_sz)
|
||||
@ -562,9 +562,9 @@ int do_relocation_section(Elf *elf, unsigned int rel_type, unsigned int rel_type
|
||||
// __cxa_pure_virtual is a function used in vtables to point at pure
|
||||
// virtual methods. The __cxa_pure_virtual function usually abort()s.
|
||||
// These functions are however normally never called. In the case
|
||||
// where they would, jumping to the NULL address instead of calling
|
||||
// where they would, jumping to the null address instead of calling
|
||||
// __cxa_pure_virtual is going to work just as well. So we can remove
|
||||
// relocations for the __cxa_pure_virtual symbol and NULL out the
|
||||
// relocations for the __cxa_pure_virtual symbol and null out the
|
||||
// content at the offset pointed by the relocation.
|
||||
if (sym) {
|
||||
if (sym->defined) {
|
||||
@ -617,7 +617,7 @@ int do_relocation_section(Elf *elf, unsigned int rel_type, unsigned int rel_type
|
||||
}
|
||||
if (relhack_entry.r_offset)
|
||||
relhack->push_back(relhack_entry);
|
||||
// Last entry must be NULL
|
||||
// Last entry must be nullptr
|
||||
relhack_entry.r_offset = relhack_entry.r_info = 0;
|
||||
relhack->push_back(relhack_entry);
|
||||
|
||||
@ -699,7 +699,7 @@ void do_file(const char *name, bool backup = false, bool force = false, bool fil
|
||||
return;
|
||||
}
|
||||
|
||||
for (ElfSection *section = elf.getSection(1); section != NULL;
|
||||
for (ElfSection *section = elf.getSection(1); section != nullptr;
|
||||
section = section->getNext()) {
|
||||
if (section->getName() &&
|
||||
(strncmp(section->getName(), ".elfhack.", 9) == 0)) {
|
||||
@ -744,8 +744,8 @@ void undo_file(const char *name, bool backup = false)
|
||||
return;
|
||||
}
|
||||
|
||||
ElfSection *data = NULL, *text = NULL;
|
||||
for (ElfSection *section = elf.getSection(1); section != NULL;
|
||||
ElfSection *data = nullptr, *text = nullptr;
|
||||
for (ElfSection *section = elf.getSection(1); section != nullptr;
|
||||
section = section->getNext()) {
|
||||
if (section->getName() &&
|
||||
(strcmp(section->getName(), elfhack_data) == 0))
|
||||
@ -766,7 +766,7 @@ void undo_file(const char *name, bool backup = false)
|
||||
|
||||
ElfSegment *first = elf.getSegmentByType(PT_LOAD);
|
||||
ElfSegment *second = elf.getSegmentByType(PT_LOAD, first);
|
||||
ElfSegment *filler = NULL;
|
||||
ElfSegment *filler = nullptr;
|
||||
// If the second PT_LOAD is a filler from elfhack --fill, check the third.
|
||||
if (!second->isElfHackFillerSegment()) {
|
||||
filler = second;
|
||||
@ -803,7 +803,7 @@ int main(int argc, char *argv[])
|
||||
bool revert = false;
|
||||
bool fill = false;
|
||||
char *lastSlash = rindex(argv[0], '/');
|
||||
if (lastSlash != NULL)
|
||||
if (lastSlash != nullptr)
|
||||
rundir = strndup(argv[0], lastSlash - argv[0]);
|
||||
for (arg = 1; arg < argc; arg++) {
|
||||
if (strcmp(argv[arg], "-f") == 0)
|
||||
|
@ -2,6 +2,8 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/NullPtr.h"
|
||||
|
||||
#include <stdexcept>
|
||||
#include <list>
|
||||
#include <vector>
|
||||
@ -115,7 +117,7 @@ public:
|
||||
class ElfValue {
|
||||
public:
|
||||
virtual unsigned int getValue() { return 0; }
|
||||
virtual ElfSection *getSection() { return NULL; }
|
||||
virtual ElfSection *getSection() { return nullptr; }
|
||||
};
|
||||
|
||||
class ElfPlainValue: public ElfValue {
|
||||
@ -130,7 +132,7 @@ class ElfLocation: public ElfValue {
|
||||
unsigned int offset;
|
||||
public:
|
||||
enum position { ABSOLUTE, RELATIVE };
|
||||
ElfLocation(): section(NULL), offset(0) {};
|
||||
ElfLocation(): section(nullptr), offset(0) {};
|
||||
ElfLocation(ElfSection *section, unsigned int off, enum position pos = RELATIVE);
|
||||
ElfLocation(unsigned int location, Elf *elf);
|
||||
unsigned int getValue();
|
||||
@ -270,7 +272,7 @@ public:
|
||||
|
||||
ElfSection *getSectionAt(unsigned int offset);
|
||||
|
||||
ElfSegment *getSegmentByType(unsigned int type, ElfSegment *last = NULL);
|
||||
ElfSegment *getSegmentByType(unsigned int type, ElfSegment *last = nullptr);
|
||||
|
||||
ElfDynamic_Section *getDynSection();
|
||||
|
||||
@ -355,17 +357,17 @@ public:
|
||||
}
|
||||
|
||||
void insertAfter(ElfSection *section, bool dirty = true) {
|
||||
if (previous != NULL)
|
||||
if (previous != nullptr)
|
||||
previous->next = next;
|
||||
if (next != NULL)
|
||||
if (next != nullptr)
|
||||
next->previous = previous;
|
||||
previous = section;
|
||||
if (section != NULL) {
|
||||
if (section != nullptr) {
|
||||
next = section->next;
|
||||
section->next = this;
|
||||
} else
|
||||
next = NULL;
|
||||
if (next != NULL)
|
||||
next = nullptr;
|
||||
if (next != nullptr)
|
||||
next->previous = this;
|
||||
if (dirty)
|
||||
markDirty();
|
||||
@ -373,17 +375,17 @@ public:
|
||||
}
|
||||
|
||||
void insertBefore(ElfSection *section, bool dirty = true) {
|
||||
if (previous != NULL)
|
||||
if (previous != nullptr)
|
||||
previous->next = next;
|
||||
if (next != NULL)
|
||||
if (next != nullptr)
|
||||
next->previous = previous;
|
||||
next = section;
|
||||
if (section != NULL) {
|
||||
if (section != nullptr) {
|
||||
previous = section->previous;
|
||||
section->previous = this;
|
||||
} else
|
||||
previous = NULL;
|
||||
if (previous != NULL)
|
||||
previous = nullptr;
|
||||
if (previous != nullptr)
|
||||
previous->next = this;
|
||||
if (dirty)
|
||||
markDirty();
|
||||
@ -391,7 +393,7 @@ public:
|
||||
}
|
||||
|
||||
void markDirty() {
|
||||
if (link != NULL)
|
||||
if (link != nullptr)
|
||||
shdr.sh_link = -1;
|
||||
if (info.index)
|
||||
shdr.sh_info = -1;
|
||||
@ -446,7 +448,7 @@ public:
|
||||
unsigned int getFlags() { return flags; }
|
||||
unsigned int getAlign() { return align; }
|
||||
|
||||
ElfSection *getFirstSection() { return sections.empty() ? NULL : sections.front(); }
|
||||
ElfSection *getFirstSection() { return sections.empty() ? nullptr : sections.front(); }
|
||||
int getVPDiff() { return v_p_diff; }
|
||||
unsigned int getFileSize();
|
||||
unsigned int getMemSize();
|
||||
@ -654,7 +656,7 @@ inline char Elf::getMachine() {
|
||||
inline unsigned int Elf::getSize() {
|
||||
ElfSection *section;
|
||||
for (section = shdr_section /* It's usually not far from the end */;
|
||||
section->getNext() != NULL; section = section->getNext());
|
||||
section->getNext() != nullptr; section = section->getNext());
|
||||
return section->getOffset() + section->getSize();
|
||||
}
|
||||
|
||||
@ -662,7 +664,7 @@ inline ElfSegment *ElfSection::getSegmentByType(unsigned int type) {
|
||||
for (std::vector<ElfSegment *>::iterator seg = segments.begin(); seg != segments.end(); seg++)
|
||||
if ((*seg)->getType() == type)
|
||||
return *seg;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
inline void ElfSection::insertInSegments(std::vector<ElfSegment *> &segs) {
|
||||
@ -689,7 +691,7 @@ inline unsigned int ElfLocation::getValue() {
|
||||
}
|
||||
|
||||
inline const char *ElfLocation::getBuffer() {
|
||||
return section ? section->getData() + offset : NULL;
|
||||
return section ? section->getData() + offset : nullptr;
|
||||
}
|
||||
|
||||
inline unsigned int ElfSize::getValue() {
|
||||
|
@ -27,11 +27,12 @@ int main(int argc, char** argv)
|
||||
|
||||
// find our DLL to inject
|
||||
wchar_t filename[_MAX_PATH];
|
||||
if (GetModuleFileNameW(NULL, filename, sizeof(filename) / sizeof(wchar_t)) == 0)
|
||||
if (GetModuleFileNameW(nullptr, filename,
|
||||
sizeof(filename) / sizeof(wchar_t)) == 0)
|
||||
return 1;
|
||||
|
||||
wchar_t* slash = wcsrchr(filename, L'\\');
|
||||
if (slash == NULL)
|
||||
if (slash == nullptr)
|
||||
return 1;
|
||||
|
||||
slash++;
|
||||
@ -41,7 +42,7 @@ int main(int argc, char** argv)
|
||||
HANDLE targetProc = OpenProcess(PROCESS_VM_OPERATION | PROCESS_VM_WRITE | PROCESS_CREATE_THREAD | PROCESS_QUERY_INFORMATION,
|
||||
FALSE,
|
||||
pid);
|
||||
if (targetProc == NULL) {
|
||||
if (targetProc == nullptr) {
|
||||
fprintf(stderr, "Error %d opening target process\n", GetLastError());
|
||||
return 1;
|
||||
}
|
||||
@ -58,16 +59,16 @@ int main(int argc, char** argv)
|
||||
*/
|
||||
HMODULE hKernel32 = GetModuleHandleW(L"Kernel32");
|
||||
// allocate some memory to hold the path in the remote process
|
||||
void* pLibRemote = VirtualAllocEx(targetProc, NULL, sizeof(filename),
|
||||
void* pLibRemote = VirtualAllocEx(targetProc, nullptr, sizeof(filename),
|
||||
MEM_COMMIT, PAGE_READWRITE);
|
||||
if (pLibRemote == NULL) {
|
||||
if (pLibRemote == nullptr) {
|
||||
fprintf(stderr, "Error %d in VirtualAllocEx\n", GetLastError());
|
||||
CloseHandle(targetProc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!WriteProcessMemory(targetProc, pLibRemote, (void*)filename,
|
||||
sizeof(filename), NULL)) {
|
||||
sizeof(filename), nullptr)) {
|
||||
fprintf(stderr, "Error %d in WriteProcessMemory\n", GetLastError());
|
||||
VirtualFreeEx(targetProc, pLibRemote, sizeof(filename), MEM_RELEASE);
|
||||
CloseHandle(targetProc);
|
||||
@ -75,11 +76,11 @@ int main(int argc, char** argv)
|
||||
}
|
||||
// Now create a thread in the target process that will load our DLL
|
||||
HANDLE hThread = CreateRemoteThread(
|
||||
targetProc, NULL, 0,
|
||||
targetProc, nullptr, 0,
|
||||
(LPTHREAD_START_ROUTINE)GetProcAddress(hKernel32,
|
||||
"LoadLibraryW"),
|
||||
pLibRemote, 0, NULL);
|
||||
if (hThread == NULL) {
|
||||
pLibRemote, 0, nullptr);
|
||||
if (hThread == nullptr) {
|
||||
fprintf(stderr, "Error %d in CreateRemoteThread\n", GetLastError());
|
||||
VirtualFreeEx(targetProc, pLibRemote, sizeof(filename), MEM_RELEASE);
|
||||
CloseHandle(targetProc);
|
||||
|
@ -28,10 +28,10 @@ BOOL WINAPI DllMain(
|
||||
// we have to crash on another thread because LoadLibrary() will
|
||||
// catch memory access errors and return failure to the calling process
|
||||
CreateThread(
|
||||
NULL, // default security attributes
|
||||
nullptr, // default security attributes
|
||||
0, // use default stack size
|
||||
CrashingThread , // thread function name
|
||||
NULL, // argument to thread function
|
||||
CrashingThread, // thread function name
|
||||
nullptr, // argument to thread function
|
||||
0, // use default creation flags
|
||||
&tid); // returns the thread identifier
|
||||
return TRUE;
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
/* compile-time and runtime tests for whether to use various ARM extensions */
|
||||
|
||||
#include "mozilla/NullPtr.h"
|
||||
|
||||
#include "arm.h"
|
||||
|
||||
#if defined(MOZILLA_ARM_HAVE_CPUID_DETECTION)
|
||||
|
Loading…
Reference in New Issue
Block a user