[core] Remove useless files (#750)

This commit is contained in:
LoveSy 2021-06-17 19:05:08 +08:00 committed by GitHub
parent 73e27dc86b
commit f410634dc9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 7 additions and 148 deletions

View File

@ -1,59 +0,0 @@
/*
* This file is part of LSPosed.
*
* LSPosed is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LSPosed is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LSPosed. If not, see <https://www.gnu.org/licenses/>.
*
* Copyright (C) 2020 EdXposed Contributors
* Copyright (C) 2021 LSPosed Contributors
*/
#ifndef LSPOSED_TEMP_BYTEORDER_H
#define LSPOSED_TEMP_BYTEORDER_H
#include <cstdint>
static inline uint32_t android_swap_long(uint32_t v)
{
return (v<<24) | ((v<<8)&0x00FF0000) | ((v>>8)&0x0000FF00) | (v>>24);
}
static inline uint16_t android_swap_short(uint16_t v)
{
return (v<<8) | (v>>8);
}
#define DEVICE_BYTE_ORDER LITTLE_ENDIAN
#if BYTE_ORDER == DEVICE_BYTE_ORDER
#define dtohl(x) (x)
#define dtohs(x) (x)
#define htodl(x) (x)
#define htods(x) (x)
#else
#define dtohl(x) (android_swap_long(x))
#define dtohs(x) (android_swap_short(x))
#define htodl(x) (android_swap_long(x))
#define htods(x) (android_swap_short(x))
#endif
#if BYTE_ORDER == LITTLE_ENDIAN
#define fromlel(x) (x)
#define fromles(x) (x)
#define tolel(x) (x)
#define toles(x) (x)
#else
#define fromlel(x) (android_swap_long(x))
#define fromles(x) (android_swap_short(x))
#define tolel(x) (android_swap_long(x))
#define toles(x) (android_swap_short(x))
#endif
#endif //LSPOSED_TEMP_BYTEORDER_H

View File

@ -1,78 +0,0 @@
/*
* This file is part of LSPosed.
*
* LSPosed is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LSPosed is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LSPosed. If not, see <https://www.gnu.org/licenses/>.
*
* Copyright (C) 2020 EdXposed Contributors
* Copyright (C) 2021 LSPosed Contributors
*/
#pragma once
#include <dlfcn.h>
#include "logging.h"
namespace lspd {
inline static void *DlOpen(const char *file) {
void *handle = dlopen(file, RTLD_LAZY | RTLD_GLOBAL);
if (!handle) {
LOGE("dlopen(%s) failed: %s", file, dlerror());
}
return handle;
}
template<typename T>
inline static T DlSym(void *handle, const char *sym_name) {
if (!handle) {
LOGE("dlsym(%s) failed: handle is null", sym_name);
}
T symbol = reinterpret_cast<T>(dlsym(handle, sym_name));
if (!symbol) {
LOGE("dlsym(%s) failed: %s", sym_name, dlerror());
}
return symbol;
}
class ScopedDlHandle {
public:
ScopedDlHandle(const char *file) {
handle_ = DlOpen(file);
}
~ScopedDlHandle() {
if (handle_) {
dlclose(handle_);
}
}
void *Get() const {
return handle_;
}
template<typename T>
T DlSym(const char *sym_name) const {
return lspd::DlSym<T>(handle_, sym_name);
}
bool IsValid() const {
return handle_ != nullptr;
}
private:
void *handle_;
};
}

View File

@ -23,7 +23,6 @@
#include "jni/art_class_linker.h"
#include "jni/yahfa.h"
#include "jni/resources_hook.h"
#include <dl_util.h>
#include <art/runtime/jni_env_ext.h>
#include "jni/pending_hooks.h"
#include "context.h"

View File

@ -22,9 +22,7 @@
#include <dex_builder.h>
#include <art/runtime/thread.h>
#include <art/runtime/mirror/class.h>
#include <dl_util.h>
#include <framework/androidfw/resource_types.h>
#include <byte_order.h>
#include <HookMain.h>
#include <elf_util.h>
#include "native_util.h"
@ -164,18 +162,18 @@ namespace lspd {
switch (ResXMLParser_next(parser)) {
case android::ResXMLParser::START_TAG:
tag = (android::ResXMLTree_attrExt *) parser->mCurExt;
attrCount = dtohs(tag->attributeCount);
attrCount = tag->attributeCount;
for (int idx = 0; idx < attrCount; idx++) {
auto attr = (android::ResXMLTree_attribute *)
(((const uint8_t *) tag)
+ dtohs(tag->attributeStart)
+ (dtohs(tag->attributeSize) * idx));
+ tag->attributeStart
+ tag->attributeSize * idx);
// find resource IDs for attribute names
int32_t attrNameID = ResXMLParser_getAttributeNameID(parser, idx);
// only replace attribute name IDs for app packages
if (attrNameID >= 0 && (size_t) attrNameID < mTree.mNumResIds &&
dtohl(mResIds[attrNameID]) >= 0x7f000000) {
mResIds[attrNameID] >= 0x7f000000) {
auto attrName = mTree.mStrings.stringAt(attrNameID);
jint attrResID = env->CallStaticIntMethod(classXResources,
methodXResourcesTranslateAttrId,
@ -186,14 +184,14 @@ namespace lspd {
if (env->ExceptionCheck())
goto leave;
mResIds[attrNameID] = htodl(attrResID);
mResIds[attrNameID] = attrResID;
}
// find original resource IDs for reference values (app packages only)
if (attr->typedValue.dataType != android::Res_value::TYPE_REFERENCE)
continue;
jint oldValue = dtohl(attr->typedValue.data);
jint oldValue = attr->typedValue.data;
if (oldValue < 0x7f000000)
continue;
@ -204,7 +202,7 @@ namespace lspd {
goto leave;
if (newValue != oldValue)
attr->typedValue.data = htodl(newValue);
attr->typedValue.data = newValue;
}
continue;
case android::ResXMLParser::END_DOCUMENT:

View File

@ -22,7 +22,6 @@
#include <string>
#include <vector>
#include <art/runtime/runtime.h>
#include <dl_util.h>
#include <art/runtime/jni_env_ext.h>
#include <dobby.h>
#include "symbol_cache.h"