From e5785a1729040b2b5258eaecff46688fd26f8564 Mon Sep 17 00:00:00 2001 From: KenjiroIchise Date: Thu, 2 Jan 2020 18:56:49 +0900 Subject: [PATCH] Support for gcc -m32 option --- Cheat Engine/ceserver/api.c | 4 +- Cheat Engine/ceserver/context.h | 2 +- .../ceserver/extension/gcc/makefile32 | 35 +++++++++++ Cheat Engine/ceserver/extensionloader.c | 4 +- Cheat Engine/ceserver/gcc/makefile32 | 35 +++++++++++ Cheat Engine/ceserver/native-api.c | 63 ------------------- 6 files changed, 75 insertions(+), 68 deletions(-) create mode 100644 Cheat Engine/ceserver/extension/gcc/makefile32 create mode 100644 Cheat Engine/ceserver/gcc/makefile32 diff --git a/Cheat Engine/ceserver/api.c b/Cheat Engine/ceserver/api.c index cda9cf03..8dc134e3 100755 --- a/Cheat Engine/ceserver/api.c +++ b/Cheat Engine/ceserver/api.c @@ -44,7 +44,7 @@ #include #ifndef __x86_64__ -#include +//#include #endif @@ -60,7 +60,7 @@ #ifndef __x86_64__ #include -#include +//#include #endif diff --git a/Cheat Engine/ceserver/context.h b/Cheat Engine/ceserver/context.h index 2a277e72..d598a515 100755 --- a/Cheat Engine/ceserver/context.h +++ b/Cheat Engine/ceserver/context.h @@ -27,7 +27,7 @@ #ifdef __i386__ - typedef struct pt_regs CONTEXT_REGS; + typedef struct user_regs_struct CONTEXT_REGS; #endif #ifdef __x86_64__ diff --git a/Cheat Engine/ceserver/extension/gcc/makefile32 b/Cheat Engine/ceserver/extension/gcc/makefile32 new file mode 100644 index 00000000..55d58e63 --- /dev/null +++ b/Cheat Engine/ceserver/extension/gcc/makefile32 @@ -0,0 +1,35 @@ +COMPILER = gcc +CFLAGS = -m32 -fPIC -g -MMD -MP -Wall -Wextra -Winit-self -Wno-missing-field-initializers -Doff64_t=__off64_t +ifeq "$(shell getconf LONG_BIT)" "64" + LDFLAGS = -l:libz.so.1 -ldl -pthread -lm -shared +else + LDFLAGS = -l:libz.so.1 -ldl -pthread -lm -shared +endif +LIBS = +INCLUDE = -I./include +TARGET = ./bin/libceserver-extension_x86.so +SRCDIR = ./source +ifeq "$(strip $(SRCDIR))" "" + SRCDIR = . +endif +SOURCES = $(wildcard $(SRCDIR)/*.c) +OBJDIR = ./obj +ifeq "$(strip $(OBJDIR))" "" + OBJDIR = . +endif +OBJECTS = $(addprefix $(OBJDIR)/, $(notdir $(SOURCES:.c=.o))) +DEPENDS = $(OBJECTS:.o=.d) + +$(TARGET): $(OBJECTS) $(LIBS) + $(COMPILER) -m32 -o $@ $^ $(LDFLAGS) + +$(OBJDIR)/%.o: $(SRCDIR)/%.c + -mkdir -p $(OBJDIR) + $(COMPILER) $(CFLAGS) $(INCLUDE) -o $@ -c $< + +all: clean $(TARGET) + +clean: + -rm -f $(OBJECTS) $(DEPENDS) $(TARGET) + +-include $(DEPENDS) diff --git a/Cheat Engine/ceserver/extensionloader.c b/Cheat Engine/ceserver/extensionloader.c index 903b563b..c5de0e74 100755 --- a/Cheat Engine/ceserver/extensionloader.c +++ b/Cheat Engine/ceserver/extensionloader.c @@ -382,8 +382,8 @@ printf("After wait 2. PID=%d\n", pid); //save the current state and set the state to what I need it to be #ifdef __i386__ - struct pt_regs origregs; - struct pt_regs newregs; + struct user_regs_struct origregs; + struct user_regs_struct newregs; #endif #ifdef __x86_64__ diff --git a/Cheat Engine/ceserver/gcc/makefile32 b/Cheat Engine/ceserver/gcc/makefile32 new file mode 100644 index 00000000..841bd67c --- /dev/null +++ b/Cheat Engine/ceserver/gcc/makefile32 @@ -0,0 +1,35 @@ +COMPILER = gcc +CFLAGS = -m32 -g -MMD -MP -Wall -Wextra -Winit-self -Wno-missing-field-initializers -Doff64_t=__off64_t +ifeq "$(shell getconf LONG_BIT)" "64" + LDFLAGS = -l:libz.so.1 -ldl -pthread +else + LDFLAGS = -l:libz.so.1 -ldl -pthread +endif +LIBS = +INCLUDE = -I./include +TARGET = ./bin/ceserver +SRCDIR = ./source +ifeq "$(strip $(SRCDIR))" "" + SRCDIR = . +endif +SOURCES = $(wildcard $(SRCDIR)/*.c) +OBJDIR = ./obj +ifeq "$(strip $(OBJDIR))" "" + OBJDIR = . +endif +OBJECTS = $(addprefix $(OBJDIR)/, $(notdir $(SOURCES:.c=.o))) +DEPENDS = $(OBJECTS:.o=.d) + +$(TARGET): $(OBJECTS) $(LIBS) + $(COMPILER) -m32 -o $@ $^ $(LDFLAGS) + +$(OBJDIR)/%.o: $(SRCDIR)/%.c + -mkdir -p $(OBJDIR) + $(COMPILER) $(CFLAGS) $(INCLUDE) -o $@ -c $< + +all: clean $(TARGET) + +clean: + -rm -f $(OBJECTS) $(DEPENDS) $(TARGET) + +-include $(DEPENDS) diff --git a/Cheat Engine/ceserver/native-api.c b/Cheat Engine/ceserver/native-api.c index 69a02b0f..1388294e 100755 --- a/Cheat Engine/ceserver/native-api.c +++ b/Cheat Engine/ceserver/native-api.c @@ -1,66 +1,3 @@ - -#include -#include - -#include - - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include - -#ifndef __x86_64__ -#include -#endif - - -#include - -#include - -#include -#include -#include - -#include - -#ifndef __x86_64__ -#include -#include -#endif - - -#ifdef __arm__ -#ifndef __ANDROID__ -#include -#endif -#endif - - -#ifndef __ANDROID__ -#if defined(__i386__) || defined(__x86_64__) -#include -#endif -#endif - #include "api.h" #include "porthelp.h" #include "ceserver.h"