Skip to content

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
masagrator authored Sep 9, 2022
2 parents df41429 + 05eb718 commit 6cb175c
Show file tree
Hide file tree
Showing 624 changed files with 2,271,017 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Plugin/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
MIT License

Copyright (c) 2020 The Skyline Project
Copyright (c) 2021 MasaGratoR

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
16 changes: 16 additions & 0 deletions Plugin/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.PHONY: all clean skyline

NAME := $(shell basename $(CURDIR))
NAME_LOWER := $(shell echo $(NAME) | tr A-Z a-z)

BUILD_DIR := build

MAKE_NSO := nso.mk

all: skyline

skyline:
$(MAKE) all -f $(MAKE_NSO) MAKE_NSO=$(MAKE_NSO) BUILD=$(BUILD_DIR) TARGET=$(NAME)

clean:
$(MAKE) clean -f $(MAKE_NSO)
14 changes: 14 additions & 0 deletions Plugin/exported.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
global:
__custom_init;
__custom_fini;
skyline_tcp_send_raw;
getRegionAddress;
A64HookFunction;
A64InlineHook;
sky_memcpy;
get_program_id;
get_plugin_addresses;

local: *;
};
67 changes: 67 additions & 0 deletions Plugin/include/ModuleObject.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#pragma once

#include <assert.h>
#include <elf.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>

namespace rtld {
struct ModuleObject {
private:
// ResolveSymbols internals
inline void ResolveSymbolRelAbsolute(Elf64_Rel* entry);
inline void ResolveSymbolRelaAbsolute(Elf64_Rela* entry);
inline void ResolveSymbolRelJumpSlot(Elf64_Rel* entry, bool do_lazy_got_init);
inline void ResolveSymbolRelaJumpSlot(Elf64_Rela* entry, bool do_lazy_got_init);

public:
struct ModuleObject* next;
struct ModuleObject* prev;
union {
Elf64_Rel* rel;
Elf64_Rela* rela;
void* raw;
} rela_or_rel_plt;
union {
Elf64_Rel* rel;
Elf64_Rela* rela;
} rela_or_rel;
uint64_t module_base;
Elf64_Dyn* dynamic;
bool is_rela;
uint64_t rela_or_rel_plt_size;
void (*dt_init)(void);
void (*dt_fini)(void);
uint32_t* hash_bucket;
uint32_t* hash_chain;
char* dynstr;
Elf64_Sym* dynsym;
uint64_t dynstr_size;
void** got;
uint64_t rela_dyn_size;
uint64_t rel_dyn_size;
uint64_t rel_count;
uint64_t rela_count;
uint64_t hash_nchain_value;
uint64_t hash_nbucket_value;
uint64_t got_stub_ptr;
#ifdef __RTLD_6XX__
uint64_t soname_idx;
uint64_t nro_size;
bool cannot_revert_symbols;
#endif

void Initialize(uint64_t aslr_base, Elf64_Dyn* dynamic);
void Relocate();
Elf64_Sym* GetSymbolByName(const char* name);
void ResolveSymbols(bool do_lazy_got_init);
bool TryResolveSymbol(Elf64_Addr* target_symbol_address, Elf64_Sym* symbol);
};

#ifdef __RTLD_6XX__
static_assert(sizeof(ModuleObject) == 0xD0, "ModuleObject size isn't valid");
#else
static_assert(sizeof(ModuleObject) == 0xB8, "ModuleObject size isn't valid");
#endif
} // namespace rtld
Loading

0 comments on commit 6cb175c

Please sign in to comment.