diff --git a/core/src/main/cpp/main/include/byte_order.h b/core/src/main/cpp/main/include/byte_order.h
deleted file mode 100644
index 9302fe7ce0e..00000000000
--- a/core/src/main/cpp/main/include/byte_order.h
+++ /dev/null
@@ -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 .
- *
- * Copyright (C) 2020 EdXposed Contributors
- * Copyright (C) 2021 LSPosed Contributors
- */
-
-#ifndef LSPOSED_TEMP_BYTEORDER_H
-#define LSPOSED_TEMP_BYTEORDER_H
-
-#include
-
-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
diff --git a/core/src/main/cpp/main/include/dl_util.h b/core/src/main/cpp/main/include/dl_util.h
deleted file mode 100644
index 4c1e6a60353..00000000000
--- a/core/src/main/cpp/main/include/dl_util.h
+++ /dev/null
@@ -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 .
- *
- * Copyright (C) 2020 EdXposed Contributors
- * Copyright (C) 2021 LSPosed Contributors
- */
-
-#pragma once
-
-#include
-#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
- 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(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
- T DlSym(const char *sym_name) const {
- return lspd::DlSym(handle_, sym_name);
- }
-
- bool IsValid() const {
- return handle_ != nullptr;
- }
-
- private:
- void *handle_;
- };
-
-}
diff --git a/core/src/main/cpp/main/src/context.cpp b/core/src/main/cpp/main/src/context.cpp
index 3189034c715..8392cd7d41a 100644
--- a/core/src/main/cpp/main/src/context.cpp
+++ b/core/src/main/cpp/main/src/context.cpp
@@ -23,7 +23,6 @@
#include "jni/art_class_linker.h"
#include "jni/yahfa.h"
#include "jni/resources_hook.h"
-#include
#include
#include "jni/pending_hooks.h"
#include "context.h"
diff --git a/core/src/main/cpp/main/src/jni/resources_hook.cpp b/core/src/main/cpp/main/src/jni/resources_hook.cpp
index b28957c7777..7f0d677067a 100644
--- a/core/src/main/cpp/main/src/jni/resources_hook.cpp
+++ b/core/src/main/cpp/main/src/jni/resources_hook.cpp
@@ -22,9 +22,7 @@
#include
#include
#include
-#include
#include
-#include
#include
#include
#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:
diff --git a/core/src/main/cpp/main/src/native_hook.cpp b/core/src/main/cpp/main/src/native_hook.cpp
index d54c0aeaadf..f9dd1524e05 100644
--- a/core/src/main/cpp/main/src/native_hook.cpp
+++ b/core/src/main/cpp/main/src/native_hook.cpp
@@ -22,7 +22,6 @@
#include
#include
#include
-#include
#include
#include
#include "symbol_cache.h"