- Timestamp:
- Mar 16, 2014, 9:06:52 PM (11 years ago)
- Location:
- Daodan
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
Daodan/makefile
r877 r983 1 FOLDERS = patches flatline 2 FILES = Daodan.c Daodan_BSL.c Daodan_Character.c Daodan_Cheater.c Daodan_Config.c Daodan_Console.c Daodan_GL.c Daodan_Patch.c Daodan_Persistence.c Daodan_Utility.c Daodan_Win32.c Inifile_Reader.c _DLLInfo.rc patches/Patches.c flatline/Flatline.c flatline/Flatline_BSL.c flatline/Flatline_Client.c flatline/Flatline_Hooks.c flatline/Flatline_Net.c flatline/Flatline_Packet.c flatline/Flatline_PacketReader.c flatline/Flatline_PacketBuilder.c flatline/Flatline_Server.c flatline/Flatline_Win32.c flatline/Mariusnet.c flatline/Flatline_Events.c 1 SRC = src 2 TARGET = build 3 SUBFOLDERS = patches flatline beaengine 3 4 4 DEF = 5 GCCFLAGS = -std=c99 -O0 -Wall -fomit-frame-pointer -fpack-struct -Wextra -Wno-unused-variable -Wno-unused-parameter $(addprefix -D,$(DEF)) 5 DEF = BEA_ENGINE_STATIC 6 INCLUDEPATHS = . 7 GCCFLAGS = -std=c99 -O0 -Wall -fomit-frame-pointer -fpack-struct -Wextra -Wno-pragmas -Wno-unused-variable $(addprefix -I$(SRC)/,$(INCLUDEPATHS)) -Wno-unused-parameter $(addprefix -D,$(DEF)) 6 8 LINKFLAGS = -O0 -Wall -fomit-frame-pointer -fpack-struct -s -mdll 7 9 LOCALE = LC_MESSAGES=C … … 9 11 #LIBS = -lwinmm -lopengl32 10 12 LIBS = -lgdi32 -lwsock32 11 OBJS = src/binkw32.def12 OUT = build/binkw32.dll13 OBJS = $(SRC)/binkw32.def 14 OUT = $(TARGET)/binkw32.dll 13 15 16 FILES := src/_DLLInfo.rc $(foreach dir,. $(SUBFOLDERS),$(wildcard $(SRC)/$(dir)/*.c)) 14 17 15 18 ################################################### … … 28 31 endif 29 32 30 DESTFOLDERS = $(addprefix build/,$(FOLDERS)) 31 SRC = $(addprefix src/,$(FILES)) 32 DEST = $(patsubst src/%.rc,build/%.o,$(patsubst src/%.c,build/%.o,$(SRC))) 33 DESTFOLDERS = $(addprefix $(TARGET)/,$(SUBFOLDERS)) 34 DEST = $(patsubst $(SRC)/%.rc,$(TARGET)/%.o,$(patsubst $(SRC)/%.c,$(TARGET)/%.o,$(FILES))) 33 35 34 36 ALL: $(DESTFOLDERS) $(DEST) $(OBJS) … … 37 39 38 40 clean: 39 rm $(DEST)40 rm -R $(DESTFOLDERS)41 rm $(OUT)41 rm -f $(DEST) 42 rm -Rf $(DESTFOLDERS) 43 rm -f $(OUT) 42 44 43 45 $(DESTFOLDERS): 44 46 mkdir -p $@ 45 47 46 build/%.o: src/%.c48 $(TARGET)/%.o: $(SRC)/%.c 47 49 @echo "Compiling $<" 48 50 $(LOCALE) $(GCC) $(GCCFLAGS) -c -o $@ $< 49 51 @echo 50 52 51 build/%.o: src/%.rc53 $(TARGET)/%.o: $(SRC)/%.rc 52 54 @echo "Assembling resource $<" 53 55 $(WINDRES) -i $< -o $@ -
Daodan/src/Daodan.c
r893 r983 21 21 HMODULE DDrONiModule; 22 22 23 24 23 void __cdecl DDrMain(int argc, char* argv[]) 25 24 { … … 37 36 38 37 DD_Patch_Init(); 39 40 38 41 39 ONiMain(argc, argv); 42 40 } -
Daodan/src/Daodan_Config.c
r894 r983 27 27 bool patch_getcmdline = true; 28 28 bool patch_hdscreens_lowres = true; 29 bool patch_highres_console = true; 29 30 bool patch_kickguns = false; 30 31 bool patch_killvtune = true; … … 134 135 else if (!_stricmp(name, "hdscreens_lowres")) 135 136 patch_hdscreens_lowres = !_stricmp(inifile_cleanstr(value), "true"); 137 else if (!_stricmp(name, "highres_console")) 138 patch_highres_console = !_stricmp(inifile_cleanstr(value), "true"); 136 139 else if (!_stricmp(name, "kickguns")) 137 140 patch_kickguns = !_stricmp(inifile_cleanstr(value), "true"); -
Daodan/src/Daodan_Config.h
r894 r983 22 22 extern bool patch_getcmdline; 23 23 extern bool patch_hdscreens_lowres; 24 extern bool patch_highres_console; 24 25 extern bool patch_kickguns; 25 26 extern bool patch_killvtune; -
Daodan/src/Daodan_Patch.c
r689 r983 1 1 #include "Daodan_Patch.h" 2 #include "Daodan_Utility.h" 3 #include <beaengine/BeaEngine.h> 4 2 5 #include <windows.h> 3 6 #include <stdlib.h> … … 36 39 } 37 40 41 void* DDrPatch_MakeDetour(void* from, void* to) 42 { 43 int len = 0; 44 /* 45 DISASM MyDisasm; 46 int i = 0; 47 DDrStartupMessage(""); 48 DDrStartupMessage(""); 49 50 memset (&MyDisasm, 0, sizeof(DISASM)); 51 MyDisasm.EIP = (UIntPtr) from; 52 i = 0; 53 DDrStartupMessage("Orig before @ 0x%06x", from); 54 while (i<10){ 55 len = Disasm(&MyDisasm); 56 if (len != UNKNOWN_OPCODE) { 57 DDrStartupMessage("%s, Opcode: 0x%x, len: %d, branch: %d, to: 0x%06x", MyDisasm.CompleteInstr, MyDisasm.Instruction.Opcode, len, MyDisasm.Instruction.BranchType, MyDisasm.Instruction.AddrValue); 58 DDrStartupMessage(" Cat: 0x%04x, prefix count: %d", MyDisasm.Instruction.Category & 0xffff, MyDisasm.Prefix.Number ); 59 MyDisasm.EIP += (UIntPtr)len; 60 i++; 61 } 62 }; 63 DDrStartupMessage(""); 64 */ 65 66 DISASM disasm; 67 memset(&disasm, 0, sizeof(DISASM)); 68 disasm.EIP = (UIntPtr) from; 69 70 char* trampoline = malloc(40); 71 DDrPatch_NOOP(trampoline, 40); 72 int pos = 0; 73 int branches = 0; 74 75 while (((void*)disasm.EIP - from) < 5) { 76 len = Disasm(&disasm); 77 if (len != UNKNOWN_OPCODE) { 78 if ((disasm.Instruction.Category & 0xffff) == CONTROL_TRANSFER) { 79 if (disasm.Prefix.Number > 0) { 80 DDrStartupMessage("Daodan: Detour: Branch in trampoline area from address 0x%08x with prefixes", from); 81 return (void*)-1; 82 } 83 branches++; 84 int target = disasm.Instruction.AddrValue; 85 bool targetInTrampoline = ((void*)disasm.Instruction.AddrValue - from) < 5; 86 switch (disasm.Instruction.BranchType) { 87 case JmpType: 88 case CallType: 89 if (targetInTrampoline) { 90 int offset = disasm.Instruction.AddrValue - disasm.EIP; 91 if (disasm.Instruction.BranchType == JmpType) 92 DDrPatch_MakeJump(&trampoline[pos], &trampoline[pos]+offset); 93 else 94 DDrPatch_MakeCall(&trampoline[pos], &trampoline[pos]+offset); 95 } else { 96 if (disasm.Instruction.BranchType == JmpType) 97 DDrPatch_MakeJump(&trampoline[pos], (void*)target); 98 else 99 DDrPatch_MakeCall(&trampoline[pos], (void*)target); 100 } 101 pos += 5; 102 break; 103 case RetType: 104 case JECXZ: 105 memcpy(&trampoline[pos], (void*)disasm.EIP, len); 106 pos += len; 107 break; 108 // Opcode +1 109 case JO: 110 case JC: 111 case JE: 112 case JNA: 113 case JS: 114 case JP: 115 case JL: 116 case JNG: 117 if (targetInTrampoline) { 118 memcpy(&trampoline[pos], (void*)disasm.EIP, len); 119 pos += len; 120 } else { 121 trampoline[pos++] = disasm.Instruction.Opcode + 1; 122 trampoline[pos++] = 5; 123 DDrPatch_MakeJump(&trampoline[pos], (void*)target); 124 pos += 5; 125 } 126 break; 127 // Opcode -1 128 case JNO: 129 case JNC: 130 case JNE: 131 case JA: 132 case JNS: 133 case JNP: 134 case JNL: 135 case JG: 136 if (targetInTrampoline) { 137 memcpy(&trampoline[pos], (void*)disasm.EIP, len); 138 pos += len; 139 } else { 140 trampoline[pos++] = disasm.Instruction.Opcode - 1; 141 trampoline[pos++] = 5; 142 DDrPatch_MakeJump(&trampoline[pos], (void*)target); 143 pos += 5; 144 } 145 break; 146 default: 147 DDrStartupMessage("Daodan: Detour: Unknown branch in trampoline area from address 0x%08x", from); 148 return (void*)-1; 149 } 150 } else { 151 memcpy(&trampoline[pos], (void*)disasm.EIP, len); 152 pos += len; 153 } 154 disasm.EIP += (UIntPtr)len; 155 } 156 else { 157 DDrStartupMessage("Daodan: Detour: Unknown opcode in trampoline area from address 0x%08x", from); 158 return (void*)-1; 159 } 160 } 161 162 if (branches > 1) { 163 DDrStartupMessage("Daodan: Detour: Too many branches in trampoline'd code from address 0x%08x: %d", from, branches); 164 return (void*)-1; 165 } 166 167 168 DDrPatch_MakeJump(&trampoline[pos], (void*)disasm.EIP); 169 DDrPatch_NOOP(from, (void*)disasm.EIP - from); 170 DDrPatch_MakeJump(from, to); 171 /* 172 memset (&MyDisasm, 0, sizeof(DISASM)); 173 MyDisasm.EIP = (UIntPtr) trampoline; 174 i = 0; 175 DDrStartupMessage("Trampoline @ 0x%06x", trampoline); 176 while (i<10){ 177 len = Disasm(&MyDisasm); 178 if (len != UNKNOWN_OPCODE) { 179 DDrStartupMessage(MyDisasm.CompleteInstr); 180 MyDisasm.EIP += (UIntPtr)len; 181 i++; 182 } 183 }; 184 DDrStartupMessage(""); 185 186 memset (&MyDisasm, 0, sizeof(DISASM)); 187 MyDisasm.EIP = disasm.EIP; 188 i = 0; 189 DDrStartupMessage("Orig after @ 0x%06x", disasm.EIP); 190 while (i<7){ 191 len = Disasm(&MyDisasm); 192 if (len != UNKNOWN_OPCODE) { 193 DDrStartupMessage(MyDisasm.CompleteInstr); 194 MyDisasm.EIP += (UIntPtr)len; 195 i++; 196 } 197 }; 198 DDrStartupMessage(""); 199 200 memset (&MyDisasm, 0, sizeof(DISASM)); 201 MyDisasm.EIP = (UIntPtr) from; 202 i = 0; 203 DDrStartupMessage("Orig start after @ 0x%06x", from); 204 while (i<3){ 205 len = Disasm(&MyDisasm); 206 if (len != UNKNOWN_OPCODE) { 207 DDrStartupMessage(MyDisasm.CompleteInstr); 208 MyDisasm.EIP += (UIntPtr)len; 209 i++; 210 } 211 }; 212 DDrStartupMessage(""); 213 DDrStartupMessage(""); 214 DDrStartupMessage(""); 215 */ 216 return trampoline; 217 } 218 38 219 bool DDrPatch_String(char* dest, const unsigned char* string, int length) 39 220 { -
Daodan/src/Daodan_Patch.h
r692 r983 10 10 bool DDrPatch_MakeJump(void* from, void* to); 11 11 bool DDrPatch_MakeCall(void* from, void* to); 12 void* DDrPatch_MakeDetour(void* from, void* to); 12 13 bool DDrPatch_String(char* dest, const unsigned char* string, int length); 13 14 bool DDrPatch_Byte(char* dest, unsigned char value); -
Daodan/src/Oni.h
r705 r983 16 16 } ONtPlatformData; 17 17 18 typedef struct { 19 int16_t left; 20 int16_t top; 21 int16_t right; 22 int16_t bottom; 23 } UUtRect; 18 24 19 25 void ONICALL TMrInstance_GetDataPtr_List( -
Daodan/src/Oni_Symbols.h
r894 r983 23 23 #define COgConsoleLines (*((uint32_t*)0x005cb468)) 24 24 25 // Command line instance 26 #define COgCommandLine (*((void**)0x00571b74)) 27 28 25 29 // Default console text color 26 30 #define COgDefaultTextShade (*((uint32_t*)0x00533f70)) … … 156 160 // Print message to console 157 161 DefFunc(void, COrTextArea_Print, ONICALL, (uint32_t area, uint32_t priority, uint32_t textshade, uint32_t textshadowshade, const char* text, uint32_t unk_alwaws_0, uint32_t fadetime), 0x00431340); 162 DefFunc(int16_t, COrTextArea_Resize, ONICALL, (void* inTextArea, UUtRect* inBounds, int16_t inNumTextEntries), 0x00431460); 158 163 159 164 // Original cheat function … … 195 200 DefFunc(int16_t, TSrContext_DrawText, ONICALL, (uint32_t TSrContext, char* Text, char alpha, uint32_t usuallyzero, void* pRect), 0x0042DF00); 196 201 DefFunc(int16_t, TSrContext_New, ONICALL, (void* FontInstance, int size, int hthsik1,int hthsik2,int hthsik3, void* TSrContext), 0x0042EA30); 197 198 DefFunc(int16_t, TSrContext_SetShade, ONICALL, (void *ioTextContext, uint32_t inShade), 0x0042EE50);202 DefFunc(int16_t, TSrContext_SetFontSize, ONICALL, (void* ioTextContext, uint16_t inSize), 0x0042ED50); 203 DefFunc(int16_t, TSrContext_SetShade, ONICALL, (void* ioTextContext, uint32_t inShade), 0x0042EE50); 199 204 200 205 DefFunc(uint16_t, TRrAnimation_GetDuration, ONICALL, (void* Animation), 0x00428740); -
Daodan/src/_Version.h
r894 r983 6 6 7 7 #define DAODAN_VERSION_MAJOR 3 8 #define DAODAN_VERSION_MINOR 58 #define DAODAN_VERSION_MINOR 6 9 9 #define DAODAN_VERSION_STRING STRINGIZE(DAODAN_VERSION_MAJOR) "." STRINGIZE(DAODAN_VERSION_MINOR) 10 10 -
Daodan/src/patches/Patches.c
r896 r983 90 90 //this was broken 91 91 FILE** _UUgError_WarningFile = (FILE**)0x005711B4; 92 FILE *__fastcall DDrPrintWarning(int filename, int linenumber, unsigned __int16 errornum, int message) 93 { 94 92 FILE* ONICALL DDrPrintWarning(int filename, int linenumber, unsigned __int16 errornum, int message) 93 { 95 94 FILE *v4; // eax@1 96 95 FILE *result; // eax@4 … … 121 120 } 122 121 122 _COrTextArea_Resize Oni_COrTextArea_Resize = (_COrTextArea_Resize)0; 123 int16_t ONICALL DD_COrTextArea_Resize(void* inTextArea, UUtRect* inBounds, int16_t inNumTextEntries) { 124 if (inTextArea == COgCommandLine) { 125 inBounds->top -= 5; 126 } 127 return Oni_COrTextArea_Resize(inTextArea, inBounds, inNumTextEntries); 128 } 123 129 124 130 int DD_Patch_DebugNameTextureInit(short width, short height, int type, int allocated, int flags, char* name, void** output) … … 320 326 } 321 327 328 void DD_Patch_HighresConsole() { 329 Oni_COrTextArea_Resize = DDrPatch_MakeDetour((void*)COrTextArea_Resize, (void*)DD_COrTextArea_Resize); 330 } 331 322 332 // Hackish fix for Konoko not kicking guns 323 333 // Don't use this, it breaks stairs. … … 594 604 if (patch_hdscreens_lowres) 595 605 DD_Patch_HDScreens_LowRes(); 606 607 if (patch_highres_console) 608 DD_Patch_HighresConsole(); 596 609 597 610 if (patch_kickguns)
Note:
See TracChangeset
for help on using the changeset viewer.