diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..3c1c7079 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,45 @@ +name: Release + +on: + workflow_dispatch: + inputs: + version: + description: 'Release Version' + required: true + +jobs: + build: + runs-on: windows-latest + defaults: + run: + shell: msys2 {0} + steps: + - uses: msys2/setup-msys2@v2 + with: + msystem: MINGW32 + + - name: Install MinGW + run: | + pacman --noconfirm -S mingw-w64-i686-gcc + + - uses: actions/checkout@v2 + + - name: Download Patcher + run: curl -L "https://github.com/FAForever/FA_Patcher/releases/latest/download/FaP.exe" -o FaP.exe + + - name: Download Baseline + run: curl -L "https://content.faforever.com/build/ForgedAlliance_base.exe" -o ForgedAlliance_base.exe + + - name: Patch Binary + run: ./FaP.exe + + - name: Create Draft Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: v${{ github.event.inputs.version }} + release_name: v${{ github.event.inputs.version }} + draft: true + prerelease: true \ No newline at end of file diff --git a/FALuaFuncs.txt b/FALuaFuncs.txt new file mode 100644 index 00000000..4feda3ea --- /dev/null +++ b/FALuaFuncs.txt @@ -0,0 +1,243 @@ +namespace gpg +{ + class RRef {public: void* d; void* t;}; +}; + +namespace LuaPlus +{ + class __thiscall LuaObject + {// 0x14 bytes + public: + LuaObject* m_next; + LuaObject* m_prev; + LuaState* m_state; + lua_TObject m_object; + + LuaObject(const LuaObject&); //0x908a40 + LuaObject(const LuaStackObject&); //0x908a70 + LuaObject(LuaState*); //0x908970 + LuaObject(LuaState*, int); //0x9089c0 + LuaObject(LuaState*, const TObject*); //0x9089f0 + LuaObject(); //0x9072a0 + ~LuaObject(); //0x9075d0 + LuaObject& operator=(const LuaObject&); //0x908ab0 + LuaObject& operator=(const LuaStackObject&); //0x908b00 + LuaObject operator[](int) const; //0x9091e0 + LuaObject operator[](const char*) const; //0x908f60 + bool GetBoolean() const; //0x907c90 + bool IsBoolean() const; //0x9078d0 + bool IsConvertibleToString() const; //0x9077c0 + bool IsFunction() const; //0x907810 + bool IsInteger() const; //0x907350 + bool IsNil() const; //0x9072f0 + bool IsNumber() const; //0x907360 + bool IsString() const; //0x907370 + bool IsTable() const; //0x907310 + bool IsUserData() const; //0x907320 + LuaObject Clone() const; //0x90a180 + LuaObject CreateTable(const char*, int, int) const; //0x908c10 + LuaObject CreateTable(int, int, int) const; //0x908ca0 + LuaObject GetByIndex(int) const; //0x908df0 + LuaObject GetByName(const char*) const; //0x90a160 + LuaObject GetByObject(const LuaObject&) const; //0x908e70 + LuaObject GetMetaTable() const; //0x908ba0 + LuaObject Lookup(const char*) const; //0x9093b0 + LuaStackObject PushStack(LuaState*) const; //0x907d80 + LuaState* GetActiveState() const; //0x9072b0 + const char* GetString() const; //0x907a90 + const char* ToString(); //0x9073e0 + const char* TypeName() const; //0x908b50 + float GetNumber() const; //0x907970 + float GetNumber() const; //0x907a30 + float ToNumber(); //0x9073b0 + gpg::RRef AssignNewUserData(LuaState*, const gpg::RRef&); //0x909840 + gpg::RRef AssignNewUserData(LuaState*, const gpg::RType*); //0x9097d0 + gpg::RRef GetUserData() const; //0x907bc0 + int GetCount() const; //0x907f50 + int GetInteger() const; //0x907910 + int GetN() const; //0x907e50 + int GetTableCount() const; //0x90a410 + int IsPassed() const; //0x907440 + int Type() const; //0x9076d0 + int __cdecl Error(const char*, ...); //0x90c1d0 + lua_State* GetActiveCState() const; //0x9072c0 + void AddToUsedList(LuaState*); //0x908890 + void AddToUsedList(LuaState*, const TObject&); //0x9088e0 + void AssignBoolean(LuaState*, bool); //0x909600 + void AssignInteger(LuaState*, int); //0x909650 + void AssignNewTable(LuaState*, int, int); //0x909940 + void AssignNil(LuaState*); //0x9095c0 + void AssignNumber(LuaState*, float); //0x9096a0 + void AssignString(LuaState*, const char*); //0x909750 + void AssignTObject(LuaState*, const TObject*); //0x9099b0 + void AssignThread(LuaState*); //0x9096f0 + void Insert(const LuaObject&) const; //0x909af0 + void Insert(int, const LuaObject&) const; //0x909ce0 + void PushStack(lua_State*) const; //0x907d10 + void Register(const char*, int (__cdecl*)(lua_State*), int); //0x907630 + void Reset(); //0x9075f0 + void SetBoolean(const char*, bool) const; //0x9080c0 + void SetInteger(const char*, int) const; //0x9081f0 + void SetInteger(int, int) const; //0x908240 + void SetMetaTable(const LuaObject&); //0x907e00 + void SetN(int) const; //0x907ed0 + void SetNil(const char*) const; //0x907fa0 + void SetNil(int) const; //0x907ff0 + void SetNumber(const char*, float) const; //0x908320 + void SetNumber(int, float) const; //0x908370 + void SetObject(const LuaObject&, const LuaObject&) const; //0x908810 + void SetObject(const char*, const LuaObject&) const; //0x908760 + void SetObject(int, const LuaObject&) const; //0x9087a0 + void SetString(const char*, const char*) const; //0x908450 + void SetString(int, const char*) const; //0x9084e0 + void TypeError(const char*) const; //0x9072d0 + + protected: + void SetTableHelper(const char*, const TObject&) const; //0x9074b0 + }; + + class __thiscall LuaState + {// 0x34 bytes + public: + lua_State* m_state; + void* ForMultipleThreads; + bool m_ownState; + LuaObject m_threadObj; + LuaState* m_rootState; + struct MiniLuaObject { + LuaObject* m_next; // only valid when in free list + LuaObject* m_prev; // only valid when in used list + } m_headObject, m_tailObject; + + LuaState(LuaState*); //0x90a520 + LuaState(enum StandardLibraries); //0x90ac10 + LuaState(enum UnattachedTag); //0x90a5d0 + ~LuaState(); //0x90a600 + LuaObject GetGlobal(const char*); //0x4579d0 + LuaObject GetGlobals(); //0x90a690 + LuaState* GetActiveState(); //0x90bee0 + const char* CheckString(int); //0x912d10 + int ArgError(int, const char*); //0x90bf70 + lua_State* GetActiveCState(); //0x90bef0 + void CheckAny(int); //0x923f20 + void CollectGarbage(); //0x911e90 + void CollectGarbage(); //0x9176f0 + void CollectGarbage(); //0x917710 + + private: + void Init(enum StandardLibraries); //0x90aad0 + }; +} + +bool __cdecl LuaPlus::LuaPlusH_next(LuaState*, const LuaObject*, LuaObject*, LuaObject*); //0x90a6b0 +bool __cdecl lua_toboolean(lua_State*, int); //0x90ca40 +TObject* __cdecl negindex(lua_State*, int); //0x90c340 +char* __cdecl luaL_prepbuffer(luaL_Buffer*); //0x90e260 +const char* __cdecl luaL_checklstring(lua_State*, int, unsigned int*); //0x90eaa0 +const char* __cdecl luaL_optlstring(lua_State*, int, const char*, unsigned int*); //0x90eb10 +const char* __cdecl lua_getlocal(lua_State*, const lua_Debug*, int); //0x912680 +const char* __cdecl lua_getupvalue(lua_State*, int, int); //0x90d9a0 +const char* __cdecl lua_pushfstring(lua_State*, const char*, ...); //0x90ce90 +const char* __cdecl lua_pushvfstring(lua_State*, const char*, char*); //0x90ce50 +const char* __cdecl lua_setlocal(lua_State*, const lua_Debug*, int); //0x9126f0 +const char* __cdecl lua_setupvalue(lua_State*, int, int); //0x90da00 +const char* __cdecl lua_tostring(lua_State*, int); //0x90ca90 +const char* __cdecl lua_typename(lua_State*, int); //0x90c780 +float __cdecl luaL_checknumber(lua_State*, int); //0x90eb70 +float __cdecl luaL_optnumber(lua_State*, int, float); //0x90ebf0 +float __cdecl lua_tonumber(lua_State*, int); //0x90c9f0 +gpg::RRef __cdecl lua_newuserdata(lua_State*, const gpg::RRef&); //0x90d7e0 +gpg::RRef __cdecl lua_touserdata(lua_State*, int); //0x90cbb0 +int __cdecl luaL_argerror(lua_State*, int, const char*); //0x90e900 +int __cdecl luaL_callmeta(lua_State*, int, const char*); //0x90dda0 +int __cdecl luaL_error(lua_State*, const char*, ...); //0x90dbf0 +int __cdecl luaL_findstring(const char*, const char* const* const); //0x90dc20 +int __cdecl luaL_getmetafield(lua_State*, int, const char*); //0x90dd40 +int __cdecl luaL_getn(lua_State*, int); //0x90e090 +int __cdecl luaL_loadbuffer(lua_State*, const char*, unsigned int, const char*); //0x90e760 +int __cdecl luaL_loadfile(lua_State*, const char*); //0x90e5d0 +int __cdecl luaL_newmetatable(lua_State*, const char*); //0x90dc70 +int __cdecl luaL_typerror(lua_State*, int, const char*); //0x90e9a0 +int __cdecl lua_checkstack(lua_State*, int); //0x90c460 +int __cdecl lua_dobuffer(lua_State*, const char*, unsigned int, const char*); //0x90e870 +int __cdecl lua_dostring(lua_State*, const char*); //0x90e8d0 +int __cdecl lua_error(lua_State*); //0x90d6c0 +int __cdecl lua_getgccount(lua_State*); //0x90d660 +int __cdecl lua_getgcthreshold(lua_State*); //0x90d650 +int __cdecl lua_gethookcount(lua_State*); //0x9125d0 +int __cdecl lua_gethookmask(lua_State*); //0x9125c0 +int __cdecl lua_getinfo(lua_State*, const char*, lua_Debug*); //0x9132f0 +int __cdecl lua_getmetatable(lua_State*, int); //0x90d180 +int __cdecl lua_getn(lua_State*, int); //0x90ad30 +int __cdecl lua_getstack(lua_State*, int, lua_Debug*); //0x9125e0 +int __cdecl lua_gettop(lua_State*); //0x90c590 +int __cdecl lua_isnumber(lua_State*, int); //0x90c7a0 +int __cdecl lua_isstring(lua_State*, int); //0x90c800 +int __cdecl lua_lessthan(lua_State*, int, int); //0x90c980 +int __cdecl lua_load(lua_State*, const char* (__cdecl*)(lua_State*, void*, unsigned int*), void*, const char*); //0x90d5c0 +int __cdecl lua_next(lua_State*, int); //0x90d6d0 +int __cdecl lua_pcall(lua_State*, int, int); //0x90d430 +int __cdecl lua_rawequal(lua_State*, int, int); //0x90c890 +int __cdecl lua_resume(lua_State*, int); //0x914610 +int __cdecl lua_setfenv(lua_State*, int); //0x90d3b0 +int __cdecl lua_sethook(lua_State*, void (__cdecl*)(lua_State*, lua_Debug*), int, int); //0x912560 +int __cdecl lua_setmetatable(lua_State*, int); //0x90d340 +int __cdecl lua_traceback(lua_State*, const char*, int); //0x911ea0 +int __cdecl lua_type(lua_State*, int); //0x90c740 +int __cdecl lua_yield(lua_State*, int); //0x913e40 +int __cdecl luaopen_base(lua_State*); //0x90fd90 +int __cdecl luaopen_debug(lua_State*); //0x9124c0 +int __cdecl luaopen_loadlib(lua_State*); //0x91a4b0 +int __cdecl luaopen_math(lua_State*); //0x91a110 +int __cdecl luaopen_serialize(lua_State*); //0x923690 +int __cdecl luaopen_string(lua_State*); //0x926ef0 +lua_State* __cdecl lua_newthread(lua_State*); //0x90c530 +lua_State* __cdecl lua_open(); //0x9246d0 +lua_State* __cdecl lua_tothread(lua_State*, int); //0x90cc50 +unsigned int __cdecl lua_strlen(lua_State*, int); //0x90cb10 +void (__cdecl*__cdecl lua_gethook(lua_State*))(lua_State*, lua_Debug*); //0x9125b0 +void __cdecl luaL_addlstring(luaL_Buffer*, const char*, unsigned int); //0x90e2a0 +void __cdecl luaL_addstring(luaL_Buffer*, const char*); //0x90e300 +void __cdecl luaL_addvalue(luaL_Buffer*); //0x90e370 +void __cdecl luaL_buffinit(lua_State*, luaL_Buffer*); //0x90e400 +void __cdecl luaL_checkany(lua_State*, int); //0x90ea70 +void __cdecl luaL_checkstack(lua_State*, int, const char*); //0x90dd10 +void __cdecl luaL_checktype(lua_State*, int, int); //0x90ea20 +void __cdecl luaL_getmetatable(lua_State*, const char*); //0x90dcf0 +void __cdecl luaL_openlib(lua_State*, const char*, const luaL_reg*, int); //0x90de00 +void __cdecl luaL_pushresult(luaL_Buffer*); //0x90e330 +void __cdecl luaL_setn(lua_State*, int, int); //0x90dfb0 +void __cdecl luaL_where(lua_State*, int); //0x90db80 +void __cdecl lua_call(lua_State*, int, int); //0x90d400 +void __cdecl lua_close(lua_State*); //0x9243e0 +void __cdecl lua_concat(lua_State*, int); //0x90d740 +void __cdecl lua_getfenv(lua_State*, int); //0x90d1f0 +void __cdecl lua_gettable(lua_State*, int); //0x90d000 +void __cdecl lua_insert(lua_State*, int); //0x90c640 +void __cdecl lua_newtable(lua_State*); //0x90d110 +void __cdecl lua_pushboolean(lua_State*, int); //0x90cf80 +void __cdecl lua_pushcclosure(lua_State*, int (__cdecl*)(lua_State*), int); //0x90ced0 +void __cdecl lua_pushlightuserdata(lua_State*, void*); //0x90cfc0 +void __cdecl lua_pushlstring(lua_State*, const char*, unsigned int); //0x90cd80 +void __cdecl lua_pushnil(lua_State*); //0x90cd00 +void __cdecl lua_pushnumber(lua_State*, float); //0x90cd40 +void __cdecl lua_pushstring(lua_State*, const char*); //0x90cdf0 +void __cdecl lua_pushvalue(lua_State*, int); //0x90c6e0 +void __cdecl lua_rawget(lua_State*, int); //0x90d050 +void __cdecl lua_rawgeti(lua_State*, int, int); //0x90d0a0 +void __cdecl lua_rawset(lua_State*, int); //0x90d2a0 +void __cdecl lua_rawseti(lua_State*, int, int); //0x90d2f0 +void __cdecl lua_remove(lua_State*, int); //0x90c5f0 +void __cdecl lua_replace(lua_State*, int); //0x90c690 +void __cdecl lua_setdefaultmetatable(lua_State*, int); //0x90ad00 +void __cdecl lua_setgcthreshold(lua_State*, int); //0x90d670 +void __cdecl lua_setglobaluserdata(lua_State*, void*); //0x924060 +void __cdecl lua_setstateuserdata(lua_State*, void*); //0x9240b0 +void __cdecl lua_settable(lua_State*, int); //0x90d260 +void __cdecl lua_settop(lua_State*, int); //0x90c5a0 +void __cdecl lua_setusergcfunction(lua_State*, void (__cdecl*)(void*)); //0x924080 +void __cdecl lua_xmove(lua_State*, lua_State*, int); //0x90c4c0 +void const* __cdecl lua_topointer(lua_State*, int); //0x90cc90 +void* __cdecl lua_getglobaluserdata(lua_State*); //0x924050 +void* __cdecl lua_getstateuserdata(lua_State*); //0x9240a0 +void* __cdecl lua_tolightuserdata(lua_State*, int); //0x90cc10 \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 00000000..f94a8384 --- /dev/null +++ b/README.md @@ -0,0 +1,82 @@ +# FA Engine Patches Repository + +This are some binary patches for Supreme Commander Forged Alliance. + +To apply them build or get the patcher itself from here + +https://github.com/FAForever/FA_Patcher + +This are just the patch files for this game. I decided to separate them from patcher source code. + +# Change List +## Fixes +- Prevents the crash with 'None' collisions of air. #3235 + - hooks/AirNoneCollisionFix.cpp +- Prevents commander exploding for no reason. #3406 + - hooks/NegativeIncomeFix.cpp +- Range ring performance improvement (don't render each ring twice) + - hooks/RangeRings.cpp + - section/RangeRings.cpp +- Camera performance improvements + - hooks/CameraPerf.cpp +- Fix replays desyncing when a player leaves the game + - hooks/DesyncFix.cpp + - section/ext_sector.cpp + - section/gpg_net.cpp + - section/moho_decode.cpp + - section/moho_input.cpp +- Kill exception during map loading + - hooks/Kill_maploader_except.cpp +- Make xact3d the error message print once + - hooks/xact_3dapply.cpp + - section/ext_sector.cpp +- Prevent blueprint editor being used without cheat mode + - hooks/FixOpenBPEditor.cpp +- Can't become an observer while your human allies are still alive + - hooks/ObserverFix.cpp +- Stop the engine calling lua every time a plane turns + - hooks/OnMotionTurnEvent.cpp +- Optimised some AI actions + - hooks/aiinitattack.cpp +- Fix a crash when units arrive at waypoints + - hooks/WayPointArrive.cpp + +## Additions +- Console command: "cam_DefaultMiniLOD 0" now completely disable mesh renderer for minimap + - hooks/MinimapMesh.cpp + - section/MinimapMesh.cpp +- Allow players to double-click to select Walls + - hooks/Walls.cpp +- Similar to GetSystemTimeSecondsOnlyForProfileUse + Allows to deal with the loss of accuracy. It is present in the Sim and UI + - section/GetTimeForProfile.cpp + - section/ext_sector.cpp +- Adds optimized table.getsize2(~25 times faster) and table.empty2 + Added getn2 as alias getn. Entry point to math functions queue + - hooks/GetTableSize.cpp + - section/ext_sector.cpp +- Maximum sim rate up to 50 + - hooks/DelClampMaxSimRate.cpp +- Adds an amphibious mode toggle to the Salem + - hooks/luaSimGetStat.cpp + - section/luaSimGetStat.cpp +- Make `LOWSELECTPRIO` apply to units under construction + - hooks/selectionPriority.cpp + - section/selectionPriority.cpp +- Allow the getting of Mass or Energy spots around a location & Entry point to ui functions queue + - hooks/UserGetDepositsAroundPoint.cpp + - section/SimGetDepositsAroundPoint.cpp + - section/ext_sector.cpp +- Allow devs to write console commands to the log + - hooks/ConsoleLog.cpp + - section/ConsoleLog.cpp +- Unlock an "Ultra" graphics preset + - hooks/UnlockUltraPreset.cpp +- Allow armies to be shared by multiple players & Entry point to sim functions queue + - hooks/SimSetFocusArmy.cpp + - section/SimSetFocusArmy.cpp +- Allow upgrades to be queued on units under construction + - hooks/BuildUnit.cpp + - section/BuildUnit.cpp + - section/SelectUnit.cpp + - section/SimArmyCreate.cpp \ No newline at end of file diff --git a/config.txt b/config.txt new file mode 100644 index 00000000..93a834de --- /dev/null +++ b/config.txt @@ -0,0 +1,4 @@ +oldfile ForgedAlliance_base.exe +newfile ForgedAlliance_exxt.exe +newsect .exxt +sectsize 0x80000 \ No newline at end of file diff --git a/hooks/AirNoneCollisionFix.cpp b/hooks/AirNoneCollisionFix.cpp new file mode 100644 index 00000000..96fc2e53 --- /dev/null +++ b/hooks/AirNoneCollisionFix.cpp @@ -0,0 +1,9 @@ +asm +( + ".section h0; .set h0,0x6C018B;" + "JMP .+0x30;" //0x6C01BB + "NOP;" + "NOP;" + "NOP;" + "NOP;" +); \ No newline at end of file diff --git a/hooks/BuildUnit.cpp b/hooks/BuildUnit.cpp new file mode 100644 index 00000000..23282945 --- /dev/null +++ b/hooks/BuildUnit.cpp @@ -0,0 +1,46 @@ +#include "../define.h" +asm +( //HOOK BuildUnit + ".section h0; .set h0,0x6EFAC9;" + "JMP "QU(BuildUnit)";" + "ADD ESP,4;" + "xor ecx,ecx;" + "xor eax,eax;" + "jmp 0x6EFB0E;" //_CannotQueCommandInConstruct + "nop;" + "nop;" + "nop;" + "nop;" + "nop;" + + //HOOK SelectUnit + ".section h1; .set h1,0x8C05FE;" + "JMP "QU(SelectUnit)";" + + //HOOK SimArmyCreate + ".section h2; .set h2,0x6FF3D1;" + "JMP "QU(SimArmyCreate)";" + "NOP;" + "call 0x4059E0;" + "mov bl,0x28;" + "lea ecx, [esp+0x10C];" + "mov byte [esp+0x150],bl;" + "call 0x9075D0;" + "mov ecx, dword ptr [esp+0x7C];" + "nop;" + "nop;" + "push 0x3;" + "push 0xE2F868;" //s_Off + "push ecx;" + "push edi;" + "lea ecx, [esp+0x78];" + "call 0x40A880;" + "test eax,eax;" + "je TimerIsOff;" + "jmp 0x6FF47D;" //_EndTimerValidation + "TimerIsOff:;" + "mov dword ptr [ebp+0x1CC],0x0;" + "jmp 0x6FF47D;" //_EndTimerValidation + "nop;" + "nop;" +); diff --git a/hooks/CameraPerf.cpp b/hooks/CameraPerf.cpp new file mode 100644 index 00000000..97917ad5 --- /dev/null +++ b/hooks/CameraPerf.cpp @@ -0,0 +1,17 @@ +asm +( //HOOK LogParticleCap (removes the info log) runout + ".section h0; .set h0,0x493A9B;" + "nop;" + "nop;" + "nop;" + "nop;" + "nop;" + + //HOOK LogSegmentBuffers (removes the info log) runout + ".section h1; .set h1,0x4946F7;" + "nop;" + "nop;" + "nop;" + "nop;" + "nop;" +); diff --git a/hooks/ConsoleLog.cpp b/hooks/ConsoleLog.cpp new file mode 100644 index 00000000..84dcb664 --- /dev/null +++ b/hooks/ConsoleLog.cpp @@ -0,0 +1,8 @@ +#include "../define.h" +asm +( //HOOK ConsoleLog + ".section h0; .set h0,0x41CE0A;" + "JMP "QU(ConsoleLog)";" + "NOP;" + "NOP;" +); \ No newline at end of file diff --git a/hooks/DelClampMaxSimRate.cpp b/hooks/DelClampMaxSimRate.cpp new file mode 100644 index 00000000..62c02b75 --- /dev/null +++ b/hooks/DelClampMaxSimRate.cpp @@ -0,0 +1,24 @@ +asm +( //CalcMaxSimRate + ".section h0; .set h0,0x55AE56;" + "MOV ESP,EBP;" + "POP EBP;" + "RET;" + "NOP;" + + //WLD_IncreaseSimRate + ".section h1; .set h1,0x88D1FE;" + "CMP EAX,0x32;" + + //WLD_GameSpeed + ".section h2; .set h2,0x88E1A8;" + "CMP ESI,0x32;" + "MOV EDX,ESI;" + "JLE L1;" + "MOV EDX,0x32;" + "L1:;" + + //InitLocalClient + ".section h3; .set h3,0x53BE0D;" + ".byte 0x32;" +); \ No newline at end of file diff --git a/hooks/DesyncFix.cpp b/hooks/DesyncFix.cpp new file mode 100644 index 00000000..6f6a1211 --- /dev/null +++ b/hooks/DesyncFix.cpp @@ -0,0 +1,416 @@ +#include "../define.h" + +asm +( //HOOK decode + ".section h0; .set h0,0x6E4150;" + "jmp "QU(Moho__CDecoder__DecodeMessage)";" + "nop;" +); + +asm +( + ".section h1; .set h1,0x74B8B0;" + "jmp "QU(EndGame)";" +); + +asm +( + ".section h2; .set h2,0x489F90;" + "jmp "QU(Gpg_Net_Entry)";" + "nop;" + "nop;" +); + +asm +( //HOOK instance running + ".section h3; .set h3,0x8CF0D2;" + "jmp 0x8CF23E;" + "nop;" +); + +asm +( //HOOK recvfrom + ".section h4; .set h4,0x48A280;" + "jmp "QU(_recvfrom)";" + "nop;" +); + +asm +( //HOOK sendto + ".section h5; .set h5,0x488D80;" + "jmp "QU(_sendto)";" + "nop;" + "nop;" +); + +asm +( + ".section h6; .set h6,0x8984B0;" + "jmp "QU(SessionEndGame)";" + "nop;" + "nop;" + "nop;" + "nop;" +); + +asm +( //HOOK SetPaused + ".section h7; .set h7,0x8BC100;" + "cmp dword ptr [0x011FD23F], 0x1;" + "jne run_input_check;" + "xor eax, eax;" + "ret;" + "run_input_check:;" + "push ebp;" + "mov ebp,esp;" + "and esp,0xFFFFFFF8;" + //"mov eax,dword ptr [0x0];" + "push 0xFFFFFFFF;" + "push 0xB8B0A0;" + "push eax;" + //"mov dword ptr [0x0],esp;" + "sub esp,0x50;" + "push ebx;" + "push esi;" + "mov esi,dword ptr [0x10C5A74];" + "push edi;" + "mov edi,ecx;" + "mov eax,dword ptr [edi];" + "push eax;" + "call 0x90C590;" + "add esp,0x4;" + "cmp eax,0x2;" + "je L0xABEL_0x8BC14B;" + "push eax;" + "push 0x2;" + "push esi;" + "push 0xE0A220;" + "push edi;" + "call 0x90C1D0;" + "add esp,0x14;" + "L0xABEL_0x8BC14B:;" + "lea ecx,dword ptr [esp+0x28];" + "push ecx;" + "mov ebx,0x1;" + "lea ecx,dword ptr [esp+0x34];" + "mov dword ptr [esp+0x2C],edi;" + "mov dword ptr [esp+0x30],ebx;" + "call 0x908A70;" + "mov dword ptr [esp+0x64],0x0;" + "lea esi,dword ptr [esp+0x20];" + "mov dword ptr [esp+0x20],edi;" + "mov dword ptr [esp+0x24],0x2;" + "call 0x415560;" + "lea ecx,dword ptr [esp+0x30];" + "mov byte ptr [esp+0x13],al;" + "call 0x907310;" + "test al,al;" + "je L0xABEL_0x8BC256;" + "lea ecx,dword ptr [esp+0x30];" + "call 0x907F50;" + "cmp eax,ebx;" + "mov dword ptr [esp+0x14],eax;" + "jl L0xABEL_0x8BC256;" + "lea ecx,dword ptr [ecx];" + "L0xABEL_0x8BC1B0:;" + "push ebx;" + "lea edx,dword ptr [esp+0x48];" + "push edx;" + "lea ecx,dword ptr [esp+0x38];" + "call 0x9091E0;" + "mov byte ptr [esp+0x64],0x1;" + "call 0x822B80;" + "lea ecx,dword ptr [esp+0x44];" + "mov esi,eax;" + "mov byte ptr [esp+0x64],0x0;" + "call 0x9075D0;" + "test esi,esi;" + "je L0xABEL_0x8BC249;" + "mov eax,dword ptr [esi+0x148];" + "mov edx,dword ptr [eax+0x28];" + "lea ecx,dword ptr [esi+0x148];" + "call edx;" + "test al,al;" + "jne L0xABEL_0x8BC249;" + "cmp byte ptr [esp+0x13],0x0;" + "mov ecx,dword ptr [0x10C4F50];" + "push ecx;" + "mov dword ptr [esp+0x1C],esp;" + "mov eax,esp;" + "push ecx;" + "mov dword ptr [esp+0x20],esp;" + "je L0xABEL_0x8BC22B;" + "mov dword ptr [eax],0xE0120C;" + "mov eax,esp;" + "mov dword ptr [eax],0xE2B32C;" + "mov esi,dword ptr [esi+0x44];" + "mov eax,dword ptr [ecx];" + "mov eax,dword ptr [eax+0x60];" + "push esi;" + "lea edx,dword ptr [esp+0x28];" + "push edx;" + "call eax;" + "jmp L0xABEL_0x8BC249;" + "L0xABEL_0x8BC22B:;" + "mov dword ptr [eax],0xE01204;" + "mov eax,esp;" + "mov dword ptr [eax],0xE2B32C;" + "mov esi,dword ptr [esi+0x44];" + "mov edx,dword ptr [ecx];" + "mov edx,dword ptr [edx+0x60];" + "push esi;" + "lea eax,dword ptr [esp+0x2C];" + "push eax;" + "call edx;" + "L0xABEL_0x8BC249:;" + "add ebx,0x1;" + "cmp ebx,dword ptr [esp+0x14];" + "jle L0xABEL_0x8BC1B0;" + "L0xABEL_0x8BC256:;" + "lea ecx,dword ptr [esp+0x30];" + "mov dword ptr [esp+0x64],0xFFFFFFFF;" + "call 0x9075D0;" + "mov ecx,dword ptr [esp+0x5C];" + "pop edi;" + "pop esi;" + "xor eax,eax;" + //"mov dword ptr [0x0],ecx;" + "pop ebx;" + "mov esp,ebp;" + "pop ebp;" + "ret;" +); + +asm +( //HOOK SimCallback + ".section h8; .set h8,0x8BA770;" + "cmp dword ptr [0x011FD23F], 0x1;" + "jne run_input_check2;" + "xor eax, eax;" + "ret;" + "run_input_check2:;" + "push ebp;" + "mov ebp,esp;" + "and esp,0xFFFFFFF8;" + //"mov eax,dword ptr [0x0];" + "push 0xFFFFFFFF;" + "push 0xBA28C8;" + "push eax;" + //"mov dword ptr [0x0],esp;" + "sub esp,0x88;" + "push ebx;" + "push esi;" + "mov esi,ecx;" + "mov eax,dword ptr [esi];" + "push edi;" + "mov edi,dword ptr [0x10C5954];" + "push eax;" + "call 0x90C590;" + "add esp,0x4;" + "cmp eax,0x1;" + "jl L0xABEL_0x8BA7B1;" + "cmp eax,0x2;" + "jle L0xABEL_0x8BA7C5;" + "L0xABEL_0x8BA7B1:;" + "push eax;" + "push 0x2;" + "push 0x1;" + "push edi;" + "push 0xE0A270;" + "push esi;" + "call 0x90C1D0;" + "add esp,0x18;" + "L0xABEL_0x8BA7C5:;" + "mov ecx,dword ptr [esi];" + "push 0x2;" + "push ecx;" + "call 0x90C5A0;" + "mov edx,dword ptr [esi];" + "push 0xE4C7A4;" + "push edx;" + "call 0x90CDF0;" + "mov eax,dword ptr [esi];" + "push 0x1;" + "push eax;" + "call 0x90D000;" + "mov ecx,dword ptr [esi];" + "push ecx;" + "call 0x90C590;" + "add esp,0x1C;" + "mov dword ptr [esp+0x1C],esi;" + "mov dword ptr [esp+0x20],eax;" + "mov edx,dword ptr [esi];" + "push eax;" + "push edx;" + "call 0x90CA90;" + "mov edi,eax;" + "xor ebx,ebx;" + "add esp,0x8;" + "cmp edi,ebx;" + "jne L0xABEL_0x8BA81B;" + "push 0xE00AD0;" + "lea ecx,dword ptr [esp+0x20];" + "call 0x4154B0;" + "L0xABEL_0x8BA81B:;" + "mov eax,edi;" + "mov dword ptr [esp+0x64],0xF;" + "mov dword ptr [esp+0x60],ebx;" + "mov byte ptr [esp+0x50],bl;" + "lea edx,dword ptr [eax+0x1];" + "L0xABEL_0x8BA830:;" + "mov cl,byte ptr [eax];" + "add eax,0x1;" + "test cl,cl;" + "jne L0xABEL_0x8BA830;" + "sub eax,edx;" + "push eax;" + "push edi;" + "lea ecx,dword ptr [esp+0x54];" + "call 0x4059E0;" + "mov dword ptr [esp+0x9C],ebx;" + "mov eax,dword ptr [esi];" + "push 0xE4C7AC;" + "push eax;" + "call 0x90CDF0;" + "mov ecx,dword ptr [esi];" + "push 0x1;" + "push ecx;" + "call 0x90D000;" + "mov edx,dword ptr [esi];" + "push edx;" + "call 0x90C590;" + "mov dword ptr [esp+0x2C],eax;" + "add esp,0x14;" + "lea eax,dword ptr [esp+0x14];" + "push eax;" + "lea ecx,dword ptr [esp+0x3C];" + "mov dword ptr [esp+0x18],esi;" + "call 0x908A70;" + "lea ecx,dword ptr [esp+0x88];" + "mov edx,ecx;" + "lea eax,dword ptr [esp+0x90];" + "mov dword ptr [esp+0x24],esi;" + "mov dword ptr [esp+0x28],0x2;" + "mov dword ptr [esp+0x70],ebx;" + "mov dword ptr [esp+0x78],ecx;" + "mov dword ptr [esp+0x7C],edx;" + "mov dword ptr [esp+0x80],eax;" + "mov dword ptr [esp+0x84],ecx;" + "lea esi,dword ptr [esp+0x24];" + "mov byte ptr [esp+0x9C],0x2;" + "call 0x415560;" + "test al,al;" + "je L0xABEL_0x8BA945;" + "mov ebx,dword ptr [0x10A6470];" + "mov eax,dword ptr [ebx+0x4A4];" + "mov eax,dword ptr [eax];" + "add ebx,0x4A0;" + "push eax;" + "lea edi,dword ptr [esp+0x14];" + "mov esi,ebx;" + "call 0x66A330;" + "mov eax,dword ptr [eax];" + "cmp eax,dword ptr [ebx+0x4];" + "mov dword ptr [esp+0x14],ebx;" + "mov dword ptr [esp+0x18],eax;" + "je L0xABEL_0x8BA945;" + "nop;" + "L0xABEL_0x8BA900:;" + "mov eax,dword ptr [eax+0x10];" + "test eax,eax;" + "je L0xABEL_0x8BA90C;" + "add eax,0xFFFFFFF8;" + "jmp L0xABEL_0x8BA90E;" + "L0xABEL_0x8BA90C:;" + "xor eax,eax;" + "L0xABEL_0x8BA90E:;" + "mov esi,dword ptr [eax+0x44];" + "lea edx,dword ptr [esp+0x2C];" + "push edx;" + "lea edi,dword ptr [esp+0x74];" + "call 0x4036A0;" + "lea edx,dword ptr [esp+0x18];" + "call 0x66ADD0;" + "mov eax,dword ptr [esp+0x18];" + "mov esi,dword ptr [esp+0x14];" + "push eax;" + "lea edi,dword ptr [esp+0x14];" + "call 0x66A330;" + "mov eax,dword ptr [eax];" + "cmp eax,dword ptr [ebx+0x4];" + "mov dword ptr [esp+0x18],eax;" + "jne L0xABEL_0x8BA900;" + "L0xABEL_0x8BA945:;" + "mov ecx,dword ptr [0x10C4F50];" + "lea edx,dword ptr [esp+0x68];" + "push edx;" + "lea eax,dword ptr [esp+0x3C];" + "push eax;" + "mov eax,dword ptr [esp+0x58];" + "push ecx;" + "mov esi,0x10;" + "cmp dword ptr [esp+0x70],esi;" + "mov dword ptr [esp+0x1C],esp;" + "mov edx,esp;" + "jae L0xABEL_0x8BA96F;" + "lea eax,dword ptr [esp+0x5C];" + "L0xABEL_0x8BA96F:;" + "mov dword ptr [edx],eax;" + "mov edx,dword ptr [ecx];" + "mov edx,dword ptr [edx+0x88];" + "lea eax,dword ptr [esp+0x1C];" + "push eax;" + "call edx;" + "mov eax,dword ptr [esp+0x78];" + "cmp eax,dword ptr [esp+0x84];" + "je L0xABEL_0x8BA9AA;" + "push eax;" + "call 0xA82542;" + "mov eax,dword ptr [esp+0x88];" + "mov dword ptr [esp+0x7C],eax;" + "mov ecx,dword ptr [eax];" + "add esp,0x4;" + "mov dword ptr [esp+0x80],ecx;" + "L0xABEL_0x8BA9AA:;" + "lea ecx,dword ptr [esp+0x38];" + "mov dword ptr [esp+0x7C],eax;" + "mov byte ptr [esp+0x9C],0x0;" + "call 0x9075D0;" + "cmp dword ptr [esp+0x64],esi;" + "jb L0xABEL_0x8BA9D2;" + "mov edx,dword ptr [esp+0x50];" + "push edx;" + "call 0x957A60;" + "add esp,0x4;" + "L0xABEL_0x8BA9D2:;" + "mov ecx,dword ptr [esp+0x94];" + "pop edi;" + "pop esi;" + "xor eax,eax;" + //"mov dword ptr [0x0],ecx;" + "pop ebx;" + "mov esp,ebp;" + "pop ebp;" + "ret;" +); + +asm +( + ".section h9; .set h9,0x73D8C0;" + "jmp "QU(sim_dispatch)";" + "nop;" +); + +asm +( + ".section h10; .set h10,0x53F010;" + "jmp "QU(Update_Pipeline_Stream)";" + "nop;" +); + +asm +( //HOOK user input + ".section h11; .set h11,0x8704B0;" + "jmp "QU(MOHO_USER_INPUT)";" + "nop;" +); diff --git a/hooks/FixOpenBPEditor.cpp b/hooks/FixOpenBPEditor.cpp new file mode 100644 index 00000000..fe8b76e5 --- /dev/null +++ b/hooks/FixOpenBPEditor.cpp @@ -0,0 +1,7 @@ +#include "../define.h" +asm +( //SC_CreateEntityDialog + ".section h0; .set h0,0x8D4010;" + "JMP "QU(FixCreateEntityDialog)";" + "NOP;" +); \ No newline at end of file diff --git a/hooks/GetTableSize.cpp b/hooks/GetTableSize.cpp new file mode 100644 index 00000000..92f9972c --- /dev/null +++ b/hooks/GetTableSize.cpp @@ -0,0 +1,6 @@ +#include "../define.h" +asm +( + ".section h0; .set h0,0x9283B1;" + "JMP "QU(RegTableFuncs)";" +); \ No newline at end of file diff --git a/hooks/Kill_maploader_except.cpp b/hooks/Kill_maploader_except.cpp new file mode 100644 index 00000000..cf5af05b --- /dev/null +++ b/hooks/Kill_maploader_except.cpp @@ -0,0 +1,11 @@ +asm +( + ".section h0; .set h0,0x9071FE;" + "jmp 0x90723B;" + "nop;" + "nop;" + "nop;" + "nop;" +); + + diff --git a/hooks/MinimapMesh.cpp b/hooks/MinimapMesh.cpp new file mode 100644 index 00000000..448fb0d9 --- /dev/null +++ b/hooks/MinimapMesh.cpp @@ -0,0 +1,10 @@ +#include "../define.h" +asm +( //HOOK selectionPriority + ".section h0; .set h0,0x7D1AE9;" + "jmp "QU(minimapMesh)";" + "nop;" + "nop;" + "nop;" + "nop;" +); \ No newline at end of file diff --git a/hooks/NegativeIncomeFix.cpp b/hooks/NegativeIncomeFix.cpp new file mode 100644 index 00000000..88926f60 --- /dev/null +++ b/hooks/NegativeIncomeFix.cpp @@ -0,0 +1,17 @@ +asm +( + ".section h0; .set h0,0x7722B0;" + "FSUBRP ST(1),ST;" + "FSTP DWORD PTR [ESP+0x24];" + "MOVSS XMM1,[ESP+0x24];" + "COMISS XMM2,XMM1;" + "JBE .+0x0D;" //0x7722CC + "XORPS XMM0,XMM0;" + "JMP .+0x10;" //0x7722D4 + "NOP;" + "NOP;" + "NOP;" + "NOP;" + "NOP;" + "NOP;" +); \ No newline at end of file diff --git a/hooks/ObserverFix.cpp b/hooks/ObserverFix.cpp new file mode 100644 index 00000000..ff41b3be --- /dev/null +++ b/hooks/ObserverFix.cpp @@ -0,0 +1,5 @@ +asm +( //SetFocusArmy + ".section h0; .set h0,0x89671A;" + ".byte 0xEB;" +); \ No newline at end of file diff --git a/hooks/OnMotionTurnEvent.cpp b/hooks/OnMotionTurnEvent.cpp new file mode 100644 index 00000000..85549494 --- /dev/null +++ b/hooks/OnMotionTurnEvent.cpp @@ -0,0 +1,30 @@ +asm +( //HOOK OnMotionTurnEventChange1 + ".section h0; .set h0,0x6B8FB9;" + "jmp 0x6B8FE0;" + "nop;" + "nop;" + "nop;" + + //HOOK OnMotionTurnEventChange2 + ".section h1; .set h1,0x6B953F;" + "jmp 0x6B9567;" + "nop;" + "nop;" + "nop;" + "nop;" + "nop;" + "nop;" + + //HOOK OnMotionTurnEventChange3 + ".section h2; .set h2,0x6BFF2C;" + "jmp 0x6BFF55;" +); + + + + + + + + diff --git a/hooks/RangeRings.cpp b/hooks/RangeRings.cpp new file mode 100644 index 00000000..e062f163 --- /dev/null +++ b/hooks/RangeRings.cpp @@ -0,0 +1,6 @@ +#include "../define.h" +asm +( //HOOK RangeRings + ".section h0; .set h0,0x7F944D;" + "call "QU(RangeRings)";" +); diff --git a/hooks/SimSetFocusArmy.cpp b/hooks/SimSetFocusArmy.cpp new file mode 100644 index 00000000..c2c4b981 --- /dev/null +++ b/hooks/SimSetFocusArmy.cpp @@ -0,0 +1,6 @@ +#include "../define.h" +asm +( //HOOK SetFocusArmy + ".section h0; .set h0,0x708A9A;" + "mov eax, "QU(SSFARegDesc)";" +); \ No newline at end of file diff --git a/hooks/UnlockUltraPreset.cpp b/hooks/UnlockUltraPreset.cpp new file mode 100644 index 00000000..eb319634 --- /dev/null +++ b/hooks/UnlockUltraPreset.cpp @@ -0,0 +1,9 @@ +asm +( + ".section h0; .set h0,0x8D0E93;" + "nop;" + "nop;" + "nop;" + "nop;" + "nop;" +); \ No newline at end of file diff --git a/hooks/UserGetDepositsAroundPoint.cpp b/hooks/UserGetDepositsAroundPoint.cpp new file mode 100644 index 00000000..beeb49b0 --- /dev/null +++ b/hooks/UserGetDepositsAroundPoint.cpp @@ -0,0 +1,6 @@ +#include "../define.h" +asm +( //HOOK GetDepositsAroundPoint + ".section h0; .set h0,0x842E8A;" + "mov eax, "QU(UGDAPRegDesc)";" +); \ No newline at end of file diff --git a/hooks/Walls.cpp b/hooks/Walls.cpp new file mode 100644 index 00000000..79e2636d --- /dev/null +++ b/hooks/Walls.cpp @@ -0,0 +1,12 @@ +asm +( //HOOK WallSelection + ".section h0; .set h0,0x865EC2;" + "nop;" + "nop;" + "nop;" + "nop;" + "nop;" + "nop;" +); + + diff --git a/hooks/WayPointArrive.cpp b/hooks/WayPointArrive.cpp new file mode 100644 index 00000000..53725cc2 --- /dev/null +++ b/hooks/WayPointArrive.cpp @@ -0,0 +1,167 @@ +asm +( //HOOK Fixes crash when unit arrives at the waypoint + ".section h0; .set h0,0x598E80;" + "push ebp;" + "mov ebp,esp;" + "and esp,0xFFFFFFF8;" + "push ecx;" + "push ebp;" + "push esi;" + "push edi;" + "mov edi,ecx;" + "cmp byte ptr [edi+0x40], bl;" + "je L0xABEL_0x598F6C;" + "mov ecx,dword ptr [edi+0x44];" + "mov eax,dword ptr [ecx+0x10];" + "test eax,eax;" + "je L0xABEL_0x598EB5;" + "mov edx,dword ptr [ecx+0x14];" + "sub edx,eax;" + "sar edx,0x3;" + "je L0xABEL_0x598EB5;" + "mov eax,dword ptr [eax];" + "test eax,eax;" + "je L0xABEL_0x598EB5;" + "lea esi,dword ptr [eax-0x4];" + "jmp L0xABEL_0x598EB7;" + "L0xABEL_0x598EB5:;" + "xor esi,esi;" + "L0xABEL_0x598EB7:;" + "mov edx,0x2;" + "cmp dword ptr [edi+0x2C],edx;" + "mov byte ptr [edi+0x40], bl;" + "jne L0xABEL_0x598EEC;" + "mov esi,dword ptr [esi+0x98];" + "sub esi,0xA;" + "je L0xABEL_0x598F66;" + "sub esi,0x6;" + "je L0xABEL_0x598EE1;" + "sub esi,edx;" + "jne L0xABEL_0x598F66;" + "L0xABEL_0x598EE1:;" + "push ecx;" + "call 0x6EDFC0;" + "jmp L0xABEL_0x598F6C;" + "L0xABEL_0x598EEC:;" + //CRASH FIX (null pointer) + "cmp esi, ebx;" + "je RETURN1;" + //------------------------ + "mov eax,dword ptr [esi+0xE4];" + "cmp eax,0x1;" + "jle L0xABEL_0x598F09;" + "add eax,0xFFFFFFFF;" + "mov dword ptr [esi+0xE4],eax;" + "mov byte ptr [esi+0x141],0x1;" + "jmp L0xABEL_0x598F6C;" + "L0xABEL_0x598F09:;" + "mov ebp,dword ptr [edi+0x1C];" + "cmp byte ptr [ebp+0x2A2],bl;" + "je L0xABEL_0x598F46;" + "cmp dword ptr [esi+0x98],0x7;" + "jne L0xABEL_0x598F46;" + "mov eax,dword ptr [esi+0xE0];" + "mov dword ptr [esi+0xE4],eax;" + "mov byte ptr [esi+0x141],0x1;" + "mov ecx,dword ptr [edi+0x44];" + "push ecx;" + "call 0x6EDFC0;" + "L0xABEL_0x598F3A:;" + "RETURN1:;" + "mov eax,0x1;" + "pop edi;" + "pop esi;" + "pop ebp;" + "mov esp,ebp;" + "pop ebp;" + "ret;" + "L0xABEL_0x598F46:;" + "mov eax,dword ptr [esi+0x98];" + "sub eax,0xA;" + "je L0xABEL_0x598FDB;" + "sub eax,0x6;" + "je L0xABEL_0x598FEC;" + "sub eax,edx;" + "je L0xABEL_0x598FEC;" + "L0xABEL_0x598F66:;" + "push ecx;" + "call 0x6EDE70;" + "L0xABEL_0x598F6C:;" + "mov ecx,dword ptr [edi+0x1C];" + "mov eax,dword ptr [ecx];" + "mov edx,dword ptr [eax+0x34];" + "call edx;" + "test al,al;" + "jne L0xABEL_0x598F3A;" + "mov ecx,dword ptr [edi+0x1C];" + "mov eax,dword ptr [ecx];" + "mov edx,dword ptr [eax+0x28];" + "call edx;" + "test al,al;" + "jne L0xABEL_0x598F3A;" + "mov ecx,dword ptr [edi+0x1C];" + "mov eax,dword ptr [ecx];" + "mov edx,dword ptr [eax+0x3C];" + "push 0xE;" + "call edx;" + "test al,al;" + "jne L0xABEL_0x598F3A;" + "mov ecx,dword ptr [edi+0x1C];" + "mov eax,dword ptr [ecx];" + "mov edx,dword ptr [eax+0x3C];" + "push 0x2A;" + "call edx;" + "test al,al;" + "jne L0xABEL_0x598F3A;" + "mov esi,dword ptr [edi+0x44];" + "mov eax,esi;" + "call 0x598B90;" + "test al,al;" + "jne L0xABEL_0x598F3A;" + "mov eax,esi;" + "call 0x6EDBF0;" + "push eax;" + "push edi;" + "mov byte ptr [edi+0x40],0x1;" + "mov dword ptr [edi+0x2C],0x0;" + "call 0x608EF0;" + "add esp,0x8;" + "xor eax,eax;" + "pop edi;" + "pop esi;" + "pop ebp;" + "mov esp,ebp;" + "pop ebp;" + "ret;" + "L0xABEL_0x598FDB:;" + "cmp dword ptr [esi+0x11C],edx;" + "sete al;" + "test al,al;" + "je L0xABEL_0x598F66;" + "L0xABEL_0x598FEC:;" + "call 0x6EDC20;" + "test eax,eax;" + "je L0xABEL_0x599011;" + "mov edx,ebp;" + "call 0x6E8D70;" + "mov edx,dword ptr [edi+0x44];" + "push edx;" + "call 0x6EDFC0;" + "mov eax,0x1;" + "pop edi;" + "pop esi;" + "pop ebp;" + "mov esp,ebp;" + "pop ebp;" + "ret;" + "L0xABEL_0x599011:;" + "push ecx;" + "call 0x6EDE70;" + "pop edi;" + "mov eax,0x1;" + "pop esi;" + "pop ebp;" + "mov esp,ebp;" + "pop ebp;" + "ret;" +); diff --git a/hooks/aiinitattack.cpp b/hooks/aiinitattack.cpp new file mode 100644 index 00000000..d7f6d7b8 --- /dev/null +++ b/hooks/aiinitattack.cpp @@ -0,0 +1,19 @@ +//HOOK _aiinitattack compare with a null. +asm +( + ".section h0; .set h0,0xC0B4C2;" + "cmp ecx,0;" + "je 0x5F3B99;" + "mov edx,dword ptr [ecx];" + "lea eax,dword ptr [ebp+0x60];" + "push eax;" + "jmp 0x5F39FD;" +); + +//HOOK _aiinitattack prevents a crash when a target is in range but null is encountered. +asm +( + ".section h1; .set h1,0x5F39F7;" + "jmp 0xC0B4C2;" + "nop;" +); diff --git a/hooks/luaSimGetStat.cpp b/hooks/luaSimGetStat.cpp new file mode 100644 index 00000000..dc55dfb1 --- /dev/null +++ b/hooks/luaSimGetStat.cpp @@ -0,0 +1,8 @@ +#include "../define.h" +asm +( //HOOK luaSimGetStat + ".section h0; .set h0,0x6CC759;" + "jmp "QU(luaSimGetStat)";" + "nop;" + "nop;" +); \ No newline at end of file diff --git a/hooks/selectionPriority.cpp b/hooks/selectionPriority.cpp new file mode 100644 index 00000000..bee22fa1 --- /dev/null +++ b/hooks/selectionPriority.cpp @@ -0,0 +1,7 @@ +#include "../define.h" +asm +( //HOOK selectionPriority + ".section h0; .set h0,0x863C13;" + "jmp "QU(selectionPriority)";" + "nop;" +); diff --git a/hooks/xact_3dapply.cpp b/hooks/xact_3dapply.cpp new file mode 100644 index 00000000..d63942d4 --- /dev/null +++ b/hooks/xact_3dapply.cpp @@ -0,0 +1,9 @@ +#include "../define.h" +asm +( //HOOK make the error message print once + ".section h0; .set h0,0x4D9A60;" + "jmp "QU(xact_3d_apply)";" + "nop;" +); + + \ No newline at end of file diff --git a/section.ld b/section.ld new file mode 100644 index 00000000..27d0b9e4 --- /dev/null +++ b/section.ld @@ -0,0 +1,18 @@ +OUTPUT_FORMAT(pei-i386) +OUTPUT(section.pe) +SECTIONS { + . = __image_base__ + 0x1000; + .text : { + *(.text) + *(.data) + *(.bss) + *(.rdata) + } + /DISCARD/ : { + *(.text.startup) + *(.rdata$zzz) + *(.eh_frame) + *(.ctors) + *(.reloc) + } +} \ No newline at end of file diff --git a/section/BuildUnit.cpp b/section/BuildUnit.cpp new file mode 100644 index 00000000..f1e80ca5 --- /dev/null +++ b/section/BuildUnit.cpp @@ -0,0 +1,40 @@ + +char _sCQUEMOV[] = "CQUEMOV"; +char** _pCQUEMOV = (char**)&_sCQUEMOV; + +void BuildUnit() +{ + asm + ( + "PUSH 0x00E19824;" + "JMP SHORT L1;" + "L2:\n" + ); + + asm + ( + "PUSH %[_pCQUEMOV];" + "MOV EDX,SS:[ESP-0x80];" + "MOV ECX,SS:[ESP];" + "MOV EDX,SS:[EDX];" + "MOV ECX,SS:[ECX];" + "CMP EDX,ECX;" + "JE 0x006EFACE;" + "MOV SS:[ESP+0x20],EAX;" + "L1:;" + "LEA ECX,SS:[ESP+0x44];" + "CALL 0x00405550;" + "MOV BYTE PTR SS:[ESP+0x36C],1;" + "MOV EBX,1;" + "LEA ECX,DS:[EDI+8];" + "LEA EAX,SS:[ESP+0x40];" + "MOV SS:[ESP+0x18],EBX;" + "CALL 0x0067B050;" + "TEST AL,AL;" + "JNE 0x006EFAF8;" + "JMP SHORT L2;" + : + : [_pCQUEMOV] "d" (_pCQUEMOV) + : + ); +} \ No newline at end of file diff --git a/section/ConsoleLog.cpp b/section/ConsoleLog.cpp new file mode 100644 index 00000000..75f9ddfd --- /dev/null +++ b/section/ConsoleLog.cpp @@ -0,0 +1,11 @@ +void ConsoleLog() +{//Writes called console commands to the log. + asm + ( + "MOV DWORD PTR SS:[EBP-4],2;" + "PUSH [ESP+0xF4];" + "CALL 0x00937CB0;" + "ADD ESP,4;" + "JMP 0x0041CE11;" + ); +} \ No newline at end of file diff --git a/section/FixOpenBPEditor.cpp b/section/FixOpenBPEditor.cpp new file mode 100644 index 00000000..cb254d8e --- /dev/null +++ b/section/FixOpenBPEditor.cpp @@ -0,0 +1,16 @@ +void FixCreateEntityDialog() +{ + asm + ( + "MOV EAX,[0x10A6470];" + "MOV AL,[EAX+0x4D4];" + "CMP AL,1;" + "JE L1;" + "RET;" + "L1:;" + "PUSH EBP;" + "MOV EBP,ESP;" + "AND ESP,0xFFFFFFF8;" + "JMP 0x008D4016;" + ); +} \ No newline at end of file diff --git a/section/GetTableSize.cpp b/section/GetTableSize.cpp new file mode 100644 index 00000000..2452e91b --- /dev/null +++ b/section/GetTableSize.cpp @@ -0,0 +1,117 @@ +void GetTableSize() +{ + asm + ( + "MOV EAX,[ESI+0xC];" + "CMP EAX,[ESI+0x8];" + "JAE Err;" + "CMP DWORD PTR [EAX],0x5;" + "JNE Err;" + "MOV EAX,[EAX+0x4];" + "XOR EBX,EBX;" + "MOV CL,[EAX+0x9];" + "TEST CL,CL;" + "JZ L2;" + "MOV EDX,1;" + "SHL EDX,CL;" + "MOV ECX,[EAX+0x14];" + "L3:;" + "CMP DWORD PTR [ECX+0x8],0x0;" + "JE L4;" + "ADD EBX,0x1;" + "L4:;" + "ADD ECX,0x14;" + "DEC EDX;" + "JNZ L3;" + "L2:;" + "MOV EDX,[EAX+0x20];" + "TEST EDX,EDX;" + "JZ L7;" + "MOV ECX,[EAX+0x10];" + "L5:;" + "CMP DWORD PTR [ECX],0x0;" + "JE L6;" + "ADD EBX,0x1;" + "L6:;" + "ADD ECX,0x8;" + "DEC EDX;" + "JNZ L5;" + "L7:;" + "CVTSI2SS XMM0,EBX;" + "SUB ESP,0x4;" + "MOVSS [ESP],XMM0;" + "PUSH ESI;" + "CALL 0x0090CD40\n" //PushNumber + "ADD ESP,0x8;" + "MOV EAX,0x1;" + "RET;" + "Err:;" + "XOR EAX,EAX;" + ); +} + +void IsTableEmpty() +{ + asm + ( + "MOV EAX,[ESI+0xC];" + "CMP EAX,[ESI+0x8];" + "JAE L72;" + "CMP DWORD PTR [EAX],0x5;" + "JNE L72;" + "MOV EAX,[EAX+0x4];" + "MOV CL,[EAX+0x9];" + "TEST CL,CL;" + "JZ L22;" + "MOV EDX,1;" + "SHL EDX,CL;" + "MOV ECX,[EAX+0x14];" + "L32:;" + "CMP DWORD PTR [ECX+0x8],0x0;" + "JNE L62;" + "ADD ECX,0x14;" + "DEC EDX;" + "JNZ L32;" + "L22:;" + "MOV EDX,[EAX+0x20];" + "TEST EDX,EDX;" + "JZ L72;" + "MOV ECX,[EAX+0x10];" + "L52:;" + "CMP DWORD PTR [ECX],0x0;" + "JNE L62;" + "ADD ECX,0x8;" + "DEC EDX;" + "JNZ L52;" + "L72:;" + "PUSH 0x1;" + "JMP L12;" + "L62:;" + "PUSH 0x0;" + "L12:;" + "PUSH ESI;" + "CALL 0x0090CF80\n" //PushBool + "ADD ESP,0x8;" + "MOV EAX,0x1;" + ); +} + +int RegTableFuncsDesc[] = {"getsize2",&GetTableSize, + "empty2",&IsTableEmpty, + "getn2",0x00927C20, + 0,0}; + +void RegTableFuncs() +{ + asm + ( + "CALL 0x0090DE00;" + "MOV DWORD PTR [ESP+0x8],%[RegTableFuncsDesc];" + "MOV DWORD PTR [ESP+0xC],0x0;" + "CALL 0x0090DE00;" + "JMP 0x009283B6;" + : + : [RegTableFuncsDesc] "i" (RegTableFuncsDesc) + : + ); +} \ No newline at end of file diff --git a/section/GetTimeForProfile.cpp b/section/GetTimeForProfile.cpp new file mode 100644 index 00000000..21118a6c --- /dev/null +++ b/section/GetTimeForProfile.cpp @@ -0,0 +1,26 @@ +void GetTimeForProfile() +{ + asm + ( + "SUB ESP,0x8;" + "PUSH ESP;" + "CALL DWORD PTR [0xC0F470];" //QueryPerformanceCounter + "FILD QWORD PTR [ESP];" + + "PUSH ESP;" + "CALL DWORD PTR [0xC0F46C];" //QueryPerformanceFrequency + "FILD QWORD PTR [ESP];" + + "MOV ECX,[ESI+0xC];" + "FLD DWORD PTR [ECX+0x4];" //OriginTime + "FMUL ST(1);" + "FSUBP ST(2), ST;" + "FDIVP ST(1), ST;" + "FSTP DWORD PTR [ESP+0x4];" + + "MOV [ESP], ESI;" + "CALL 0x0090CD40\n" //PushNumber + "ADD ESP,0x8;" + "MOV EAX,0x1;" + ); +} \ No newline at end of file diff --git a/section/MinimapMesh.cpp b/section/MinimapMesh.cpp new file mode 100644 index 00000000..162c2304 --- /dev/null +++ b/section/MinimapMesh.cpp @@ -0,0 +1,20 @@ +//Adding ability to disable mesh renderer for minimap +//if DefaultMiniLOD = 0 (there is a console command for it) then Moho::Cartographic::RenderMeshes function call will be skipped +//this allows to skip an enormous amount of useless computations, as minimap works similar to main camera +//and as it's mainly zoomed out, there are thousands of objects that are always in view +//and this in turn causes mesh renderer to do thousands of useless LOD calculations per frame + +void minimapMesh() +{ + asm + ( + "cmp dword ptr [0x00F57A88], 0x0;" + "jne MeshRenderON;" + "jmp 0x007D1B02;" + "MeshRenderON:;" + "push ebp;" + "push ecx;" + "mov ecx, dword ptr [esp+0xA8];" + "jmp 0x007D1AF2;" + ); +} \ No newline at end of file diff --git a/section/RangeRings.cpp b/section/RangeRings.cpp new file mode 100644 index 00000000..f89cf21c --- /dev/null +++ b/section/RangeRings.cpp @@ -0,0 +1,652 @@ +#include "include/funcDefs.h" +#include "include/global_func_table.h" + +void GlobalRings() +{ + asm + ( + "sub esp,0x14;" + "push ebx;" + "push ebp;" + "mov ebp,dword ptr [esp+0x2C];" + "mov eax,dword ptr [ebp+0x8];" + "mov ecx,dword ptr [ebp+0x4];" + "push esi;" + "push edi;" + "push eax;" + "push ecx;" + "lea eax,dword ptr [esp+0x3C];" + "mov ebx,ebp;" + ); + asm ( + "call -0x1000 +8330320;" + "mov eax,dword ptr [esp+0x30];" + "lea esi,dword ptr [esp+0x34];" + ); + asm ( + "call -0x1000 +8327632;" + "mov eax,dword ptr [esp+0x34];" + "cmp eax,dword ptr [0x10BF00C];" + "je ExitLabel2;" + "mov eax,dword ptr [eax+0x28];" + "test eax,eax;" + "mov dword ptr [esp+0x34],eax;" + "je ExitLabel2;" + "mov eax,dword ptr [esp+0x28];" + "mov ebx,dword ptr [eax];" + "cmp ebx,dword ptr [eax+0x4];" + "je ExitLabel2;" + "ContinueLoopThroughUnits:;" + "mov eax,dword ptr [ebx];" + "test eax,eax;" + "je ExitLabel;" + "lea esi,dword ptr [eax-0x8];" + "test esi,esi;" + "je ExitLabel;" + "mov eax,dword ptr [esi];" + "mov edx,dword ptr [eax+0x34];" + "mov ecx,esi;" + "call edx;" + "test al,al;" + "jne ExitLabel;" + "mov eax,dword ptr [esi];" + "mov edx,dword ptr [eax+0xC];" + "mov ecx,esi;" + "call edx;" + "mov edi,eax;" + "test edi,edi;" + "je ExitLabel;" + "mov eax,dword ptr [edi+0x148];" + "mov edx,dword ptr [eax+0x28];" + "lea esi,dword ptr [edi+0x148];" + "mov ecx,esi;" + "call edx;" + "test al,al;" + "jne ExitLabel;" + "mov eax,dword ptr [esi];" + "mov edx,dword ptr [eax+0x2C];" + "mov ecx,esi;" + "call edx;" + "test al,al;" + "jne ExitLabel;" + "mov eax,dword ptr [esi];" + "mov edx,dword ptr [eax+0x1C];" + "mov ecx,esi;" + "call edx;" + "test eax,eax;" + "je ExitLabel;" + "mov edx,dword ptr [esp+0x30];" + "add edx,0x20;" + ); + asm ( + "call -0x1000 +5683664;" + "test eax,eax;" + "jbe ExitLabel;" + "mov ecx,dword ptr [esp+0x34];" + "fld dword ptr [esp+0x2C];" + "mov eax,dword ptr [ecx];" + "mov eax,dword ptr [eax+0x8];" + "push ecx;" + "fstp dword ptr [esp];" + "push edi;" + "lea edx,dword ptr [esp+0x18];" + "push edx;" + "call eax;" + "test al,al;" + "je ExitLabel;" + + "xor ecx,ecx;" + "mov esi, dword ptr ds:[0x011FD237];" + "cmp esi, ecx;" + "je FirstTime;" + "mov edx, dword ptr ds:[0x011FD23B];" + "cmp edx, ecx;" + "je FirstTime;" + "mov edi, 0x4;" + "mov eax, dword ptr ds:[ebx];" + "NextItem:;" + "cmp dword ptr ds:[esi], eax;" + "je ExitLabel;" + "inc ecx;" + "sub esi, edi;" + "cmp ecx, edx;" + "jl NextItem;" + + "FirstTime:;" + "lea edx,dword ptr [esp+0x10];" + "mov esi,ebp;" + ); + asm ( + "call -0x1000 +8327952;" + "ExitLabel:;" + "mov ecx,dword ptr [esp+0x28];" + "add ebx,0x8;" + "cmp ebx,dword ptr [ecx+0x4];" + "jne ContinueLoopThroughUnits;" + "ExitLabel2:;" + "pop edi;" + "pop esi;" + "pop ebp;" + "pop ebx;" + "add esp,0x14;" + "ret 0x10;" + ); +} + +void GetSelectedUnits() +{ + asm + ( + "sub esp,0x14;" + "mov eax,dword ptr [ebx+0x4A4];" + "mov eax,dword ptr [eax];" + "push ebp;" + "mov ebp,dword ptr [esp+0x1C];" + "push esi;" + "lea esi,dword ptr [ebx+0x4A0];" + "push edi;" + "push eax;" + "lea edi,dword ptr [esp+0x28];" + ); + asm ( + "call -0x1000 +6730544;" + "mov dword ptr [0x011FD23B],0;" + "mov eax,dword ptr [eax];" + "cmp eax,dword ptr [esi+0x4];" + "mov dword ptr [esp+0xC],esi;" + "mov dword ptr [esp+0x10],eax;" + "je exit;" + "continue:;" + "inc dword ptr [0x011FD23B];" + "mov eax,dword ptr [eax+0x10];" + "test eax,eax;" + "je label0;" + "lea ecx,dword ptr [eax-0x8];" + "jmp label1_sel;" + "label0:;" + "xor ecx,ecx;" + "label1_sel:;" + "mov eax,dword ptr [ecx];" + "mov edx,dword ptr [eax+0xC];" + "call edx;" + "test eax,eax;" + "je label2_sel;" + "push eax;" + "push ebp;" + "lea esi,dword ptr [esp+0x1C];" + ); + asm ( + "call -0x1000 +8532592;" + "label2_sel:;" + "lea edx,dword ptr [esp+0x10];" + ); + asm ( + "call -0x1000 +6733264;" + "mov eax,dword ptr [esp+0x10];" + "mov esi,dword ptr [esp+0xC];" + "push eax;" + "lea edi,dword ptr [esp+0x28];" + ); + asm ( + "call -0x1000 +6730544;" + "mov eax,dword ptr [eax];" + "cmp eax,dword ptr [ebx+0x4A4];" + "mov dword ptr [esp+0x10],eax;" + "jne continue;" + "exit:;" + "pop edi;" + "pop esi;" + "pop ebp;" + "add esp,0x14;" + "ret 0x4;" + ); + +} + +void SelectionRings() +{ + asm + ( + "push 0xFFFFFFFF;" + "mov eax,dword ptr [fs:0x0];" + "push 0xBA7B58;" + "push eax;" + "mov dword ptr [fs:0x0],esp;" + "sub esp,0x2C;" + "push ebx;" + "mov ebx,dword ptr [esp+0x40];" + "mov eax,dword ptr [ebx+0x8];" + "push ebp;" + "push esi;" + "push edi;" + "mov edi,ecx;" + "mov ecx,dword ptr [ebx+0x4];" + "push eax;" + "push ecx;" + "lea eax,dword ptr [esp+0x18];" + ); + asm ( + "call -0x1000 +8330320;" + "cmp byte ptr [0x10A640A],0x0;" + "je exit1;" + "mov esi,dword ptr [esp+0x50];" + "mov eax,dword ptr [esi+0x14];" + "push 0xB;" + "push 0xE3F864;" + "push eax;" + "push 0x0;" + "mov ecx,esi;" + ); + asm ( + "call -0x1000 +4241536;" + "test eax,eax;" + "je exit1;" + "mov ecx,dword ptr [esi+0x14];" + "push 0x8;" + "push 0xE3F8B0;" + "push ecx;" + "push 0x0;" + "mov ecx,esi;" + ); + asm ( + "call -0x1000 +4241536;" + "test eax,eax;" + "je exit1;" + "mov eax,dword ptr [edi+0x488];" + "test eax,eax;" + "jl exit1;" + "mov edx,dword ptr [edi+0x3F0];" + "mov eax,dword ptr [edx+eax*0x4];" + "test eax,eax;" + "mov dword ptr [esp+0x10],eax;" + "je exit1;" + "mov eax,esi;" + ); + asm ( + "call -0x1000 +8317504;" + "mov ebp,eax;" + "test ebp,ebp;" + "je exit1;" + "lea esi,dword ptr [esp+0x1C];" + ); + asm ( + "call -0x1000 +8074688;" + "mov eax,esi;" + "push eax;" + "mov ebx,edi;" + "mov dword ptr [esp+0x48],0x0;" + ); + asm ( + "call %[GetSelectedUnits];" + "lea ebx,dword ptr [esp+0x14];" + "mov eax,esi;" + : + : [GetSelectedUnits] "i" (GetSelectedUnits) + : "memory" + ); + asm ( + "call -0x1000 +8074736;" + "mov eax,dword ptr [esp+0x18];" + "cmp eax,dword ptr [esp+0x20];" + "je CleanUpExit;" + "LoopStart:;" + "mov eax,dword ptr [eax+0x10];" + "test eax,eax;" + "je ContinueLoop;" + "lea esi,dword ptr [eax-0x8];" + "test esi,esi;" + "je ContinueLoop;" + "mov ecx,dword ptr [esp+0x10];" + "cmp ecx,dword ptr [esi+0x120];" + "jne ContinueLoop;" + "mov edx,dword ptr [esi+0x148];" + "mov eax,dword ptr [edx+0x1C];" + "lea edi,dword ptr [esi+0x148];" + "mov ecx,edi;" + "call eax;" + "test eax,eax;" + "je ContinueLoop;" + "mov edx,dword ptr [edi];" + "mov eax,dword ptr [edx+0x1C];" + "mov ecx,edi;" + "call eax;" + "mov edx,dword ptr [esp+0x50];" + "add edx,0x20;" + ); + asm ( + "call -0x1000 +5683664;" + "test eax,eax;" + "jbe ContinueLoop;" + "fld dword ptr [esp+0x54];" + "mov edx,dword ptr [ebp];" + "mov edx,dword ptr [edx+0x8];" + "push ecx;" + "fstp dword ptr [esp];" + "push esi;" + "lea eax,dword ptr [esp+0x30];" + "push eax;" + "mov ecx,ebp;" + "call edx;" + "test al,al;" + "je ContinueLoop;" + + "xor ecx,ecx;" + "xor esi,esi;" + "mov edx, 0x4;" + "mov eax, dword ptr [ebx+0x4];" + "mov eax, dword ptr ds:[eax+0x10];" + "sub esp, 0x60028;" + "mov dword ptr ds:[0x011FD237], esp;" + "LoopOver:;" + "cmp dword ptr ss:[esp], esi;" + "jne isNotZero;" + "mov dword ptr ss:[esp], eax;" + "isNotZero:;" + "cmp dword ptr ss:[esp], eax;" + "je MemWritten;" + "sub esp, edx;" + "inc ecx;" + "jmp LoopOver;" + "MemWritten:;" + "cmp ecx, 1;" + "jl RegClenUp;" + "shl ecx, 2;" + "add esp, ecx;" + "RegClenUp:;" + "add esp, 0x60028;" + + + "mov esi,dword ptr [esp+0x4C];" + "lea edx,dword ptr [esp+0x28];" + ); + asm ( + "call -0x1000 +8327952;" + "ContinueLoop:;" + "lea eax,dword ptr [esp+0x14];" + "push eax;" + ); + asm ( + "call -0x1000 +8328336;" + "mov eax,dword ptr [esp+0x18];" + "cmp eax,dword ptr [esp+0x20];" + "jne LoopStart;" + "CleanUpExit:;" + "lea eax,dword ptr [esp+0x1C];" + "mov dword ptr [esp+0x44],0xFFFFFFFF;" + ); + asm ( + "call -0x1000 +8074544;" + "exit1:;" + "mov ecx,dword ptr [esp+0x3C];" + "pop edi;" + "pop esi;" + "pop ebp;" + "mov dword ptr [fs:0x0],ecx;" + "pop ebx;" + "add esp,0x38;" + "ret 0xC;" + ); + +} + + +void RangeRings() +{ + asm + ( + "push 0xFFFFFFFF;" + "push 0xBBB776;" + "mov eax,dword ptr [fs:0x0];" + "push eax;" + "mov dword ptr [fs:0x0],esp;" + "sub esp,0x188;" + "push ebp;" + "mov ebp,dword ptr [esp+0x19C];" + "push esi;" + "push edi;" + "mov edi,ecx;" + ); + asm ( + "call -0x1000 +9336624;" + "xor esi,esi;" + "mov dword ptr [esp+0x18],esi;" + "mov dword ptr [esp+0x1C],esi;" + "mov dword ptr [esp+0x20],esi;" + "mov dword ptr [esp+0x19C],esi;" + "cmp byte ptr [0x10A6414],0x0;" + "je label1;" + "mov eax,dword ptr [esp+0x1A8];" + "push eax;" + "push ebx;" + "lea ecx,dword ptr [esp+0x1C];" + "push ecx;" + "push ebp;" + "mov ecx,edi;" + ); + asm ( + "call -0x1000 +8322640;" + "label1:;" + "mov eax,dword ptr [ebp+0x14];" + "cmp eax,esi;" + "je -0x1000 + 8321877;" //STARTREGULARFUNC_NO_OVERLOAD + "mov ecx,dword ptr [ebp+0x18];" + "sub ecx,eax;" + "mov eax,0x78787879;" + "imul ecx;" + "sar edx,0x6;" + "mov eax,edx;" + "shr eax,0x1F;" + "add eax,edx;" + "je -0x1000 + 8321877;" //STARTREGULARFUNC_NO_OVERLOAD + "mov edx,dword ptr [ebx];" + "mov eax,dword ptr [edx+0x8];" + "mov ecx,ebx;" + "call eax;" + "mov edx,dword ptr [ebx];" + "mov eax,dword ptr [edx+0xA4];" + "mov ecx,ebx;" + "call eax;" + "lea ecx,dword ptr [esp+0x3C];" + "push ecx;" + "mov edx,eax;" + ); + asm ( + "call -0x1000 +8328144;" + "mov byte ptr [esp+0x19C],0x1;" + "mov eax,dword ptr [ebp+0x14];" + "cmp eax,dword ptr [ebp+0x18];" + "je label3;" + "lea esi,dword ptr [eax+0x78];" + "jmp label4;" + "lea ecx,dword ptr [ecx];" + "label4:;" + "fld dword ptr [esp+0x1AC];" + "lea edx,dword ptr [esp+0x14];" + "push edx;" + "lea eax,dword ptr [esi-0x78];" + "push eax;" + "push ecx;" + "lea ecx,dword ptr [esp+0x48];" + "fstp dword ptr [esp];" + "push ecx;" + ); + asm ( + "call %[GlobalRings];" + "lea edx,dword ptr [esp+0x14];" + "push edx;" + "mov edx,dword ptr [esp+0x1AC];" + "push esi;" + "lea eax,dword ptr [esi-0x30];" + "push eax;" + "push edx;" + "lea ecx,dword ptr [esi+0x8];" + "push ebp;" + "mov edx,ebx;" + : + : [GlobalRings] "i" (GlobalRings) + : "memory" + ); + asm ( + "call -0x1000 +8324512;" + "mov eax,dword ptr [ebp+0x18];" + "add esi,0x88;" + "lea ecx,dword ptr [esi-0x78];" + "cmp ecx,eax;" + "jne label4;" + "label3:;" + "mov byte ptr [esp+0x19C],0x0;" + + "xor esi,esi;" + "mov edx, dword ptr ds:[0x011FD237];" + "cmp edx, esi;" + "je EXITMEMCLEAN;" + "mov ecx, dword ptr ds:[0x011FD23B];" + "cmp ecx, esi;" + "je EXITMEMCLEAN;" + "mov eax,esi;" + "mov esi,edi;" + "mov edi,edx;" + "std;" + "rep stosd;" + "mov edi,esi;" + "cld;" + + "EXITMEMCLEAN:;" + "mov eax,dword ptr [esp+0x40];" + "mov edx,dword ptr [esp+0x3C];" + "cmp edx,eax;" + "mov esi,eax;" + "je label5;" + "label6:;" + "mov ecx,edx;" + "mov eax,dword ptr [ecx];" + "add edx,0x8;" + "test eax,eax;" + "je label7;" + "cmp dword ptr [eax],ecx;" + "je label8;" + "label9:;" + "mov eax,dword ptr [eax];" + "add eax,0x4;" + "cmp dword ptr [eax],ecx;" + "jne label9;" + "label8:;" + "mov ecx,dword ptr [ecx+0x4];" + "mov dword ptr [eax],ecx;" + "label7:;" + "cmp edx,esi;" + "jne label6;" + "mov edx,dword ptr [esp+0x3C];" + "label5:;" + "cmp edx,dword ptr [esp+0x48];" + "je label2;" + "push edx;" + ); + asm ( + "call -0x1000 +11023682;" + "add esp,0x4;" + "label2:;" + "mov ecx,dword ptr [ebp+0x8];" + "mov eax,dword ptr [ecx];" + "cmp eax,ecx;" + "mov dword ptr [esp+0xC],eax;" + "je label10;" + "label11:;" + "fld dword ptr [esp+0x1AC];" + "push ecx;" + "fstp dword ptr [esp];" + "lea esi,dword ptr [eax+0x30];" + "push esi;" + "lea edx,dword ptr [esp+0x1C];" + "push edx;" + "mov ecx,edi;" + ); + asm ( + "call %[SelectionRings];" + "lea eax,dword ptr [esp+0x14];" + "push eax;" + "mov eax,dword ptr [esp+0x1AC];" + "lea edx,dword ptr [esi+0x78];" + "push edx;" + "lea ecx,dword ptr [esi+0x80];" + "add esi,0x58;" + "push esi;" + "push eax;" + "push ebp;" + "mov edx,ebx;" + : + : [SelectionRings] "i" (SelectionRings) + : "memory" + ); + asm ( + "call -0x1000 +8324512;" + "lea edx,dword ptr [esp+0xC];" + ); + asm ( + "call -0x1000 +8335440;" + "mov eax,dword ptr [esp+0xC];" + "cmp eax,dword ptr [ebp+0x8];" + "jne label11;" + "label10:;" + "mov esi,dword ptr [esp+0x1A8];" + "fld dword ptr [esp+0x1AC];" + "push esi;" + "push ecx;" + "fstp dword ptr [esp];" + "push ebx;" + "lea ecx,dword ptr [esp+0x20];" + "push ecx;" + "push ebp;" + "mov eax,edi;" + ); + + asm ( + "call -0x1000 +8324128;" + "lea eax,dword ptr [esp+0x14];" + ); + asm ( + "call -0x1000 +8323520;" + "movss xmm0,dword ptr [0xDFEC20];" + "movss xmm1,dword ptr [0xDFEB0C];" + "lea edx,dword ptr [esp+0x14];" + "push edx;" + "lea eax,dword ptr [esp+0x10];" + "push eax;" + "lea ecx,dword ptr [esp+0x34];" + "push ecx;" + "push esi;" + "movss dword ptr [esp+0x34],xmm0;" + "movss dword ptr [esp+0x38],xmm1;" + "movss xmm1,dword ptr [0xE4F714];" + "movss dword ptr [esp+0x20],xmm0;" + "movss xmm0,dword ptr [0xE4F8A8];" + "push ebp;" + "lea ecx,dword ptr [esp+0x38];" + "mov edx,ebx;" + "movss dword ptr [esp+0x20],xmm1;" + "movss dword ptr [esp+0x40],xmm0;" + "movss dword ptr [esp+0x44],xmm0;" + "movss dword ptr [esp+0x48],xmm0;" + "movss dword ptr [esp+0x4C],xmm0;" + ); + asm ( + "call -0x1000 +8324512;" + "mov eax,dword ptr [esp+0x18];" + "test eax,eax;" + "je label12;" + "push eax;" + ); + asm ( + "call -0x1000 +9800288;" + "add esp,0x4;" + "label12:;" + "mov ecx,dword ptr [esp+0x194];" + "pop edi;" + "pop esi;" + "mov dword ptr [fs:0x0],ecx;" + "pop ebp;" + "add esp,0x194;" + "ret 0xC;" + ); + +} \ No newline at end of file diff --git a/section/SelectUnit.cpp b/section/SelectUnit.cpp new file mode 100644 index 00000000..f84f62bf --- /dev/null +++ b/section/SelectUnit.cpp @@ -0,0 +1,26 @@ + +char sCQUEMOV[] = "CQUEMOV"; +char** pCQUEMOV = (char**)&sCQUEMOV; + +void SelectUnit() +{ + asm + ( + "PUSH %[pCQUEMOV];" + "LEA ECX,SS:[ESP+0x50];" + "CALL 0x00405550;" + "MOV DWORD PTR SS:[ESP+0x70],1;" + "OR EBX,00000002;" + "LEA EAX,SS:[ESP+0x4C];" + "MOV ECX,ESI;" + "MOV SS:[ESP+0x10],EBX;" + "CALL 0x008B97C0;" + "TEST AL,AL;" + "JNZ 0x008C062A;" + "PUSH 0x00E19824;" + "JMP 0x008C0603;" + : + : [pCQUEMOV] "c" (pCQUEMOV) + : + ); +} \ No newline at end of file diff --git a/section/SimArmyCreate.cpp b/section/SimArmyCreate.cpp new file mode 100644 index 00000000..8340aa46 --- /dev/null +++ b/section/SimArmyCreate.cpp @@ -0,0 +1,28 @@ +void SimArmyCreate() +{ + asm + ( + "SUB ECX,ESI\n" + "PUSH ECX;" + "PUSH EAX;" + "PUSHAD;" + "MOV ESI,0;" + "MOV EBX,0;" + "L1: PUSH EAX;" + "MOV EAX,0x0A;" + "MUL BX;" + "MOV EBX,EAX;" + "POP EAX;" + "MOV EDX,DS:[ESI+EAX];" + "SUB EDX,0x30;" + "ADD BL,DL;" + "INC ESI;" + "LOOP SHORT L1;" + "MOV EAX,0x258;" + "MUL BX;" + "MOV SS:[EBP+0x1CC],EAX;" + "POPAD;" + "LEA ECX,SS:[ESP+0x70];" + "JMP 0x006FF3D6;" + ); +} \ No newline at end of file diff --git a/section/SimGetDepositsAroundPoint.cpp b/section/SimGetDepositsAroundPoint.cpp new file mode 100644 index 00000000..0da3cb69 --- /dev/null +++ b/section/SimGetDepositsAroundPoint.cpp @@ -0,0 +1,144 @@ +void SimGetDepositsAroundPoint() +{ + const char* s_X1 = "X1"; + const char* s_Z1 = "Z1"; + const char* s_X2 = "X2"; + const char* s_Z2 = "Z2"; + const char* s_Type = "Type"; + const char* s_Dist = "Dist"; + asm + ( + "SUB ESP,0x1C;" + "XORPS XMM5,XMM5;" + "MOVUPS [ESP],XMM5;" + "MOV ECX,ESP;" + "PUSH 0;" + "PUSH 0;" + "PUSH [ESI+0x44];" + "CALL 0x00909940;" // CreateTable + + "MOV EAX,[ESI+0xC];" + "MOVSS XMM0,[EAX+0x4];" // X + "ADDSS XMM0,[EAX+0xC];" // Z + "ADDSS XMM0,[EAX+0x14];" // Radius + "COMISS XMM0,[0x0F3F7D0];" + "JE L4;" //Is Inf/NaN + + "MOV ECX,[0x10A63F0];" + "MOV ECX,[ECX+0x8D0];" + "MOV EDX,[ECX+0x14];" + "MOV EDI,[ECX+0x10];" + "MOV [ESP+0x14],EDX;" + "MOV DWORD PTR[ESP+0x18],1;" + + "L1:;" + "CMP EDI,[ESP+0x14];" + "JGE L4;" + + "MOV EAX,[ESI+0xC];" + "MOVSS XMM0,[EAX+0x4];" // X + "MOVSS XMM1,[EAX+0xC];" // Z + "MOVSS XMM2,[EAX+0x14];" // Radius + "CVTTSS2SI EAX,[EAX+0x1C];" // Type + + "CMP EAX,0;" + "JE L2;" + "CMP EAX,[EDI+0x10];" + "JNE L3;" + + "L2:;" + "MOV EBX,[EDI];" + "ADD EBX,[EDI+0x8];" + "CVTSI2SS XMM3,EBX;" + "MULSS XMM3,[0xE4F724];" // 0.5 + "SUBSS XMM3,XMM0;" + "MULSS XMM3,XMM3;" + + "MOV EBX,[EDI+0x4];" + "ADD EBX,[EDI+0xC];" + "CVTSI2SS XMM4,EBX;" + "MULSS XMM4,[0xE4F724];" // 0.5 + "SUBSS XMM4,XMM1;" + "MULSS XMM4,XMM4;" + + "ADDSS XMM3,XMM4;" + "SQRTSS XMM3,XMM3;" + "COMISS XMM3,XMM2;" + "JA L3;" + + "SUB ESP,0x14;" + "XORPS XMM5,XMM5;" + "MOVUPS [ESP],XMM5;" + "MOV ECX,ESP;" + "PUSH 0;" + "PUSH 0;" + "PUSH [ESI+0x44];" + "CALL 0x00909940;" // CreateTable + + "MOV ECX,ESP;" + "PUSH [EDI];" + "PUSH %[s_X1];" + "CALL 0x009081F0;" // PushInt + + "MOV ECX,ESP;" + "PUSH [EDI+0x4];" + "PUSH %[s_Z1];" + "CALL 0x009081F0;" // PushInt + + "MOV ECX,ESP;" + "PUSH [EDI+0x8];" + "PUSH %[s_X2];" + "CALL 0x009081F0;" // PushInt + + "MOV ECX,ESP;" + "PUSH [EDI+0xC];" + "PUSH %[s_Z2];" + "CALL 0x009081F0;" // PushInt + + "MOV ECX,ESP;" + "PUSH [EDI+0x10];" + "PUSH %[s_Type];" + "CALL 0x009081F0;" // PushInt + + "MOV ECX,ESP;" + "SUB ESP,4;" + "MOVSS [ESP],XMM3;" + "PUSH %[s_Dist];" + "CALL 0x00908320;" // PushNumber + + "MOV ECX,ESP;" + "PUSH [ESI+0x44];" + "PUSH ESI;" + "CALL 0x00907D80;" // PushStack + + "MOV ECX,[ESP];" + "PUSH ESP;" + "PUSH [ESP+0x30];" + "CALL 0x009087A0;" // PushTable + + "MOV ECX,ESP;" + "CALL 0x009075D0;" // LuaObjectFinalize + "ADD ESP,0x14;" + + "ADD DWORD PTR[ESP+0x18],0x1;" + + "L3:;" + "ADD EDI,0x14;" + "JMP L1;" + + "L4:;" + "MOV ECX,ESP;" + "PUSH [ESI+0x44];" + "PUSH ESI;" + "CALL 0x00907D80;" // PushStack + + "MOV ECX,ESP;" + "CALL 0x009075D0;" // LuaObjectFinalize + "ADD ESP,0x1C;" + + "MOV EAX,0x1;" + : + : [s_X1] "i" (s_X1), [s_Z1] "i" (s_Z1), [s_X2] "i" (s_X2), [s_Z2] "i" (s_Z2), [s_Type] "i" (s_Type), [s_Dist] "i" (s_Dist) + : + ); +} \ No newline at end of file diff --git a/section/SimIsReplay.cpp b/section/SimIsReplay.cpp new file mode 100644 index 00000000..f8b14e15 --- /dev/null +++ b/section/SimIsReplay.cpp @@ -0,0 +1,13 @@ +void SimSessionIsReplay() +{ + asm + ( + "MOV EAX,[0x10A6470];" + "MOVZX EAX,byte ptr[EAX+0x484];" + "PUSH EAX;" + "PUSH ESI;" + "CALL 0x0090CF80;" // lua_pushbool + "ADD ESP,0x8;" + "MOV EAX,0x1;" + ); +} \ No newline at end of file diff --git a/section/SimSetCommandSource.cpp b/section/SimSetCommandSource.cpp new file mode 100644 index 00000000..08df6654 --- /dev/null +++ b/section/SimSetCommandSource.cpp @@ -0,0 +1,47 @@ +void SimSetCommandSource() +{ + asm + ( + "MOV EDI,[ESI+0xC];" + "MOV EAX,[0x10A63F0];" + "MOV EAX,[EAX+0x910];" + "CVTTSS2SI ECX,[EDI+0x4];" // targetArmyIndex + "MOV EAX,[ECX*0x4+EAX];" + "CVTTSS2SI ECX,[EDI+0x0C];" // sourceHumanIndex + "MOV EDX,ECX;" + "SHR EDX,0x5;" + "SUB EDX,[EAX+0x130];" + "MOV EBX,[EAX+0x138];" + "LEA EBX,[EDX*0x4+EBX];" + "CMP EBX,[EAX+0x13C];" + "JB L1;" + "MOV DWORD PTR [EBX],0x0;" + "ADD DWORD PTR [EAX+0x13C],0x4;" + "L1:;" + "AND CL,0x1F;" + "MOV EDX,0x1;" + "SHL EDX,CL;" + "XOR EAX,EAX;" // Num return values + "CMP DWORD PTR [EDI+0x14],0x1;" // Set or Unset + "JL L2;" + "OR [EBX],EDX;" + "RET;" + "L2:;" + "NOT EDX;" + "AND [EBX],EDX;" + ); +} + +/* +extern "C" int cxx_SetCommandSourceId(lua_state* lua, int armyId, int sourceId, bool set_or_unset) +{ + Sim* sim = g_Sim; + SimArmy* army = (SimArmy*)sim->armies[armyId]; + + if(set_or_unset) + army->mValidCommandSources.add(sourceId); + else + army->mValidCommandSources.remove(sourceId); + return 1; +} +*/ diff --git a/section/SimSetFocusArmy.cpp b/section/SimSetFocusArmy.cpp new file mode 100644 index 00000000..f9a43f8c --- /dev/null +++ b/section/SimSetFocusArmy.cpp @@ -0,0 +1,11 @@ +void SimSetFocusArmy() +{ + asm + ( + "MOV EAX,[ESI+0xC];" + "CVTTSS2SI EAX,[EAX+0x4];" // ArmyIndex + "MOV ECX,[0x10C4F50];" // g_STIDriver + "MOV [ECX+0x0B0],EAX;" + "XOR EAX,EAX;" // Num return values + ); +} \ No newline at end of file diff --git a/section/ext_sector.cpp b/section/ext_sector.cpp new file mode 100644 index 00000000..f07a8724 --- /dev/null +++ b/section/ext_sector.cpp @@ -0,0 +1,208 @@ +#include "include/moho.h" +#include "include/funcDefs.h" +#include "include/global_func_table.h" + +// New unit categories. +//const char* sCQUEMOV = "CQUEMOV"; +//const char* sSTAYONWATSUR = "STAYONWATSUR"; + +void SimSessionIsReplay(); +luaFuncDescReg SSIRRegDesc = {0x00E45E90, // Std register func + 0x00E4AFBC, // "SessionIsReplay" + 0x00E00D90, // "" + 0x00E4AF84, // "Return true if the active session is a replay session." + 0x010B8AE8, // Next reg desc: ArmyGetHandicap + SimSessionIsReplay, // Func ptr + 0x00000000}; // C++ class vtable ptr + +void SimSetCommandSource(); +luaFuncDescReg SSCSRegDesc = {0x00E45E90, + "SetCommandSource", + 0x00E00D90, + "(targetArmyIndex, sourceHumanIndex, Set or Unset)", + &SSIRRegDesc, + SimSetCommandSource, + 0x00000000}; + +#define s_GDAPName "GetDepositsAroundPoint" +#define s_GDAPDesc "(X, Z, Radius, Type)" +void SimGetDepositsAroundPoint(); +luaFuncDescReg SGDAPRegDesc = {0x00E45E90, + s_GDAPName, + 0x00E00D90, + s_GDAPDesc, + &SSCSRegDesc, + SimGetDepositsAroundPoint, + 0x00000000}; + +#define s_GTFPName "GetTimeForProfile" +#define s_GTFPDesc "(OriginTime)" +void GetTimeForProfile(); +luaFuncDescReg SGTFPRegDesc = {0x00E45E90, + s_GTFPName, + 0x00E00D90, + s_GTFPDesc, + &SGDAPRegDesc, + GetTimeForProfile, + 0x00000000}; + +void SimSetFocusArmy(); +luaFuncDescReg SSFARegDesc = {0x00E45E90, // Std register func + 0x00E43408, // "SetFocusArmy" + 0x00E00D90, // "" + 0x00E451FC, // "SetFocusArmy(armyIndex or -1)" + &SGTFPRegDesc, // Next reg desc + SimSetFocusArmy, // Func ptr + 0x00000000}; // C++ class vtable ptr + +luaFuncDescReg UGTFPRegDesc = {0x00E45E90, + s_GTFPName, + 0x00E00D90, + s_GTFPDesc, + 0x010C3CA4, // Next reg desc: SetFocusArmy + GetTimeForProfile, + 0x00000000}; + +luaFuncDescReg UGDAPRegDesc = {0x00E45E90, + s_GDAPName, + 0x00E00D90, + s_GDAPDesc, + &UGTFPRegDesc, // Next reg desc + SimGetDepositsAroundPoint, + 0x00000000}; + +register int eax asm("eax"); + +bool game_ended = false; + +void EndGame() +{ + game_ended = true; + asm("mov dword ptr [0x011FD23F], 0xB;"); //remove block when last player remains. + asm + ( + "push esi;" + "mov esi,eax;" + "mov eax,dword ptr [esi];" + "push edi;" + "mov edi,dword ptr [0x10BA600];" + "push eax;" + "call 0x90C590;" + "add esp,0x4;" + "test eax,eax;" + "je L0xABEL_0x0074B8DB;" + "push eax;" + "push 0x0;" + "push edi;" + "push 0xE0A220;" + "push esi;" + "call 0x90C1D0;" + "add esp,0x14;" + "L0xABEL_0x0074B8DB:;" + "mov esi,dword ptr [esi];" + "push esi;" + "call 0x924050;" + "mov edx,dword ptr [eax];" + "mov ecx,eax;" + "mov eax,dword ptr [edx+0x5C];" + "add esp,0x4;" + "call eax;" + "pop edi;" + "xor eax,eax;" + "pop esi;" + "ret;" + ); +} + +void xact_3d_apply() +{ + static bool once = true; + asm + ( + "push ebx;" + "push edi;" + "mov ebx,ecx;" + "mov edi,eax;" + "mov eax,dword ptr [ebx];" + "cmp dword ptr [eax+0x34],0x0;" + "je L0xABEL_0x004D9B2A;" + "push esi;" + "push 0x64;" + "lea esi,dword ptr [eax+0xAC];" + "push 0x0;" + "push esi;" + "call 0xA89110;" + "xorps xmm0,xmm0;" + "mov dword ptr [esi+0x3C],0x1;" + "mov dword ptr [esi],0x0;" + "fld dword ptr [edi];" + "fstp dword ptr [esi+0x1C];" + "fld dword ptr [edi+0x4];" + "fstp dword ptr [esi+0x20];" + "fld dword ptr [edi+0x8];" + "movss dword ptr [esi+0x28],xmm0;" + "movss dword ptr [esi+0x2C],xmm0;" + "fstp dword ptr [esi+0x24];" + "movss dword ptr [esi+0x30],xmm0;" + "movss xmm0,dword ptr [0xDFEC20];" + "movss dword ptr [esi+0x5C],xmm0;" + "movss dword ptr [esi+0xC],xmm0;" + "movss dword ptr [esi+0x14],xmm0;" + "mov ecx,dword ptr [ebx];" + "lea edi,dword ptr [ecx+0x7C];" + "lea eax,dword ptr [ecx+0xAC];" + "lea edx,dword ptr [ecx+0x38];" + "add ecx,0x110;" + "push ecx;" + "call 0x4D81E0;" + "add esp,0x10;" + "test eax,eax;" + "jge L0xABEL_0x004D9B04;" + "call 0x4D8A50;" + ); + + asm + ( + "push eax;" + "push 0xE0B410;" + "call 0x937D30;" + "add esp,0x8;" + ); + + asm + ( + "pop esi;" + "pop edi;" + "pop ebx;" + "ret 0x4;" + "L0xABEL_0x004D9B04:;" + "mov ebx,dword ptr [ebx];" + "mov esi,dword ptr [esp+0x10];" + "lea edi,dword ptr [ebx+0x7C];" + "call 0x4D82A0;" + "test eax,eax;" + "jge L0xABEL_0x004D9B29;" + "call 0x4D8A50;" + ); + if(once) + { + asm + ( + "push eax;" + "push 0xE0B430;" + "call 0x937D30;" + "add esp,0x8;" + ); + once = false; + } + + asm + ( + "L0xABEL_0x004D9B29:;" + "pop esi;" + "L0xABEL_0x004D9B2A:;" + "pop edi;" + "pop ebx;" + "ret 0x4;" + ); +} \ No newline at end of file diff --git a/section/gpg_net.cpp b/section/gpg_net.cpp new file mode 100644 index 00000000..1049945d --- /dev/null +++ b/section/gpg_net.cpp @@ -0,0 +1,851 @@ +#include "include/funcDefs.h" +#include "include/global_func_table.h" + +//FUNCTIONS with NAMES ARE WINAPI FOR THIS FILE. FOR EXAMPLE recvfrom + +_DWORD tag_sent = 0; +_DWORD p_index = 0; +_DWORD sender_sock = 1; +_DWORD sync_buffer[17]; +_DWORD discard = 0; + +__attribute__((noinline)) void p_SetEvent() +{ + ((int (*)(const char* fmt, ...))_Logf)("Callback packet received, exit sync is over\n"); + return; +} + +__attribute__((noinline)) void p_Tag() +{ + ((int (*)(const char* fmt, ...))_Logf)("Tag packet sent\n"); + return; +} + +__attribute__((noinline)) void CheckClients() +{ + register int eax asm("eax"); + discard = 0; + for(int i = 0; i<(current_num_clients-1); i++) + { + if (sync_buffer[i] == eax) + { + ((int (*)(const char* fmt, ...))_Logf)("Discarded: %p\n", eax); + discard = 1; + break; + } + } + return; +} + +__attribute__((noinline)) void p_rptr() +{ + register int eax asm("eax"); + ((int (*)(const char* fmt, ...))_Logf)("recv Ptr: %p\n", eax); + return; +} + +__attribute__((noinline)) void p_sptr() +{ + register int eax asm("eax"); + ((int (*)(const char* fmt, ...))_Logf)("send Ptr: %p\n", eax); + return; +} + +void _recvfrom() +{ + register int eax asm("eax"); + asm + ( + "recvfrom = 0x00C0F8D8;" //WINAPI + "L0xABEL_0x0048A94C = 4761932;" + "SetEvent = 0x00C0F578;" + "push ebp;" + "mov ebp,esp;" + "and esp,0xFFFFFFF8;" + "push 0xFFFFFFFF;" + "push 0xBB3385;" + //"mov eax,dword ptr [0x0];" + "push eax;" + //"mov byte ptr [0],esp;" + "sub esp,0xB0;" + "push ebx;" + "push esi;" + "lea eax,dword ptr [esp+0x18];" + "push edi;" + "mov edi,ecx;" + "mov ecx,eax;" + "mov dword ptr [esp+0x20],eax;" + "mov dword ptr [esp+0x1C],ecx;" + "mov dword ptr [esp+0xC4],0x0;" + "mov ebx,dword ptr [esp+0x20];" + "lea edx,dword ptr [esp+0x1C];" + "cmp ebx,edx;" + "jne L0xABEL_0x0048A338;" + "lea eax,dword ptr [edi+0x2C];" + "cmp dword ptr [eax+0x4],eax;" + "jne L0xABEL_0x0048A2F3;" + "push 0x218;" + "call 0xA825B9;" + "add esp,0x4;" + "test eax,eax;" + "je L0xABEL_0x0048A2ED;" + "mov dword ptr [eax+0x4],eax;" + "mov dword ptr [eax],eax;" + "mov ebx,eax;" + "jmp L0xABEL_0x0048A30E;" + "L0xABEL_0x0048A2ED:;" + "xor eax,eax;" + "mov ebx,eax;" + "jmp L0xABEL_0x0048A30E;" + "L0xABEL_0x0048A2F3:;" + "add dword ptr [edi+0x34],0xFFFFFFFF;" + "mov ebx,dword ptr [eax+0x4];" + "mov eax,dword ptr [ebx];" + "mov ecx,dword ptr [ebx+0x4];" + "mov dword ptr [eax+0x4],ecx;" + "mov edx,dword ptr [ebx+0x4];" + "mov eax,dword ptr [ebx];" + "mov dword ptr [edx],eax;" + "mov dword ptr [ebx+0x4],ebx;" + "mov dword ptr [ebx],ebx;" + "L0xABEL_0x0048A30E:;" + "mov ecx,dword ptr [ebx];" + "mov edx,dword ptr [ebx+0x4];" + "mov dword ptr [ecx+0x4],edx;" + "mov eax,dword ptr [ebx+0x4];" + "mov ecx,dword ptr [ebx];" + "mov dword ptr [eax],ecx;" + "mov dword ptr [ebx],ebx;" + "mov dword ptr [ebx+0x4],ebx;" + "mov edx,dword ptr [esp+0x1C];" + "mov dword ptr [ebx],edx;" + "lea eax,dword ptr [esp+0x1C];" + "mov dword ptr [ebx+0x4],eax;" + "mov dword ptr [esp+0x1C],ebx;" + "mov ecx,dword ptr [ebx];" + "mov dword ptr [ecx+0x4],ebx;" + "L0xABEL_0x0048A338:;" + "lea edx,dword ptr [esp+0x4C];" + "push edx;" // (fromlen) An optional pointer to the size, in bytes, of the buffer pointed to by the from parameter. + "mov edx,dword ptr [edi+0x14];" + "lea ecx,dword ptr [esp+0xAC];" + "push ecx;" // (from) An optional pointer to a buffer in a sockaddr structure that will hold the source address upon return. + "push 0x0;" // (flags) A set of flags that specify the way in which the call is made. + "lea eax,dword ptr [ebx+0x18];" + "push 0x200;" //(len) The length, in bytes, of the data pointed to by the buf parameter. + "push eax;" //(buf) A buffer for the incoming data. + "push edx;" // (s)A descriptor identifying a bound socket. + "mov dword ptr [esp+0x64],0x10;" + "mov dword ptr [esp+0x3C],eax;" + "mov dword ptr [0x11FD247], eax;" //STORE NETWORK BUFFER POINTER (SEE REASON BELOW) + "call dword ptr [recvfrom];" //recvfrom RETURNS NUMBER OF BYTES WRITTEN TO THE NET BUFFER IN EAX REGISTER + "mov esi,eax;" + "mov eax, dword ptr [0x11FD247];" //RETREIVE NETBUFFER PTR + ); + asm volatile + ( + "cmp dword ptr [0x011FD243], 0x1;" // check if we are the sender + "jne not_sender;" + "cmp byte ptr [eax+0x3], 0xFE;" + "jne not_received;" + "cmp byte ptr [eax+0x2], 0x18;" + "jne not_received;" + "mov byte ptr [eax+0x3], 0x0;" //JUST IN CASE CLEAR THE VARIABLE FROM NET BUFFER + "mov byte ptr [eax+0x2], 0x0;" //JUST IN CASE CLEAR THE VARIABLE FROM NET BUFFER + "mov eax,dword ptr [esp+0xA8];" //get sender's socket + ); + + asm volatile + ( + "call %[func];" + : + : [func] "i" (&CheckClients) + : "memory" + ); + + if(discard) + { + asm("jmp _skip;"); + } + + asm volatile + ( + "call %[func];" + "mov eax,dword ptr [esp+0xA8];" //get sender's socket + : + : [func] "i" (&p_rptr) + : "memory" + ); + + p_index++; + sync_buffer[p_index] = eax; + + if((current_num_clients-1) - p_index == 0) + { + asm + ( + "push dword ptr [0x11FD253];" + "call dword ptr [SetEvent];" + ); + p_index = 0; + asm volatile + ( + "call %[func];" + : + : [func] "i" (&p_SetEvent) + : "memory" + ); + } + + asm + ( + "jmp not_received;" + "not_sender:;" + "cmp byte ptr [eax+0x3], 0xA4;" //CHECK IF EXIT VARIABLE IS SET + "jne _skip;" + "cmp byte ptr [eax+0x2], 0x4E;" //CHECK IF EXIT VARIABLE IS SET + "jne _skip;" + "mov byte ptr [eax+0x3], 0x0;" //JUST IN CASE CLEAR THE VARIABLE FROM NET BUFFER + "mov byte ptr [eax+0x2], 0x0;" //JUST IN CASE CLEAR THE VARIABLE FROM NET BUFFER + "mov dword ptr [0x011FD23F], 0x1;" //WRITE INTO THE LOCAL MEMORY SO THAT BLOCK CAN READ IT LATER + "mov eax,dword ptr [esp+0xA8];" //get sender's socket + ); + if(sender_sock == 1) + { + sender_sock = eax; + } + + asm + ( + "_skip:;" + "not_received:;" + + ); + + asm + ( + + "test esi,esi;" + "mov dword ptr [esp+0x10],esi;" + "jl L0xABEL_0x0048A94C;" // function continues... + "jmp 0x0048A374;" //THERE ARE A LOT MORE CODE FURTHER BUT I AM LAZY TO WRITE IT BECAUSE THERE IS SWITCH CASE + //WHICH REQUIRES MANUAL CODING. + ); + +} + +void _sendto() +{ + register int eax asm("eax"); + asm + ( + "htons = 0x00C0F8D0;" + "htonl = 0x00C0F8CC;" + "sendto = 0x00C0F8E0;" + "push 0xFFFFFFFF;" + "push 0xB9B638;" + //"mov eax,dword ptr [0x0];" + "push eax;" + //"mov dword ptr [0x0],esp;" + "sub esp,0x7C;" + "push ebx;" + "push ebp;" + "mov ebp,dword ptr [esp+0x94];" + "mov ax,word ptr [ebp+0x4A0];" + "push esi;" + "mov ebx,ecx;" + "push edi;" + "lea edi,dword ptr [ebx+0x18];" + "mov word ptr [edi+0x5],ax;" + "mov cx,word ptr [ebp+0x4A2];" + "mov word ptr [edi+0x7],cx;" + "movzx edx,word ptr [ebp+0x420];" + "push edx;" + "mov dword ptr [esp+0x18],edi;" + "mov word ptr [esp+0x28],0x2;" + + "call dword ptr [htons];" + + "mov word ptr [esp+0x26],ax;" + "mov eax,dword ptr [ebp+0x41C];" + "push eax;" + + "call dword ptr [htonl];" + + "mov edx,dword ptr [ebp+0x418];" + "mov ecx,dword ptr [ebx+0x14];" + "push 0x10;" // (tolen) The size, in bytes, of the address pointed to by the to parameter. + "mov dword ptr [esp+0x2C],eax;" + "mov eax,dword ptr [edx+0x14];" + "lea edx,dword ptr [esp+0x28];" + "push edx;" // (to) An optional pointer to a sockaddr structure that contains the address of the target socket. + "push 0x0;" // (flags) A set of flags that specify the way in which the call is made. + "push ecx;" //(len) The length, in bytes, of the data pointed to by the buf parameter. + "push edi;" //(buf) A pointer to a buffer containing the data to be transmitted. + "push eax;" // (s) A descriptor identifying a (possibly connected) socket. + "mov dword ptr [esp+0x28],ecx;" + "cmp dword ptr [0x011FD243], 0x1;" //CHECK IF SESSIONENDGAME WAS TRIGGERED (sender only) + "jne is_receiver;" + "mov eax, edi;" //if here, it is sender + "cmp byte ptr [eax + 0x3], 0\n" //overwrite only known memory, ie 0 + "jne skip;" + "cmp byte ptr [eax + 0x2], 0\n" + "jne skip;" + "mov byte ptr [eax + 0x3], 0xA4;" //WRITE VAR INTO THE PACKET HEADER + "mov byte ptr [eax + 0x2], 0x4E;" //WRITE VAR INTO THE PACKET HEADER + "mov eax, dword ptr [edx];" + ); + asm volatile + ( + "call %[func];" + : + : [func] "i" (&p_sptr) + : "memory" + ); + asm + ( + + "jmp skip;" + + "is_receiver:;" + + "cmp dword ptr [0x011FD23F], 0x1;" //check if receiver got packet (block var) + "jne skip;" + "mov eax, dword ptr [edx];" + ); + if(!terminated) + { + if(sender_sock == eax) + { + asm volatile + ( + //"mov dword ptr [0x011FD23F+0x30],eax;" + "call %[func];" + : + : [func] "i" (&p_sptr) + : "memory" + ); + asm + ( + "mov eax, edi;" + "cmp byte ptr [eax + 0x3], 0\n" //overwrite only known memory, ie 0 + "jne skip;" + "cmp byte ptr [eax + 0x2], 0\n" + "jne skip;" + "mov byte ptr [eax + 0x3], 0xFE;" //if receiver got the packet, notify the sender with 0xFE + "mov byte ptr [eax + 0x2], 0x18;" + ); + //sender_sock = 0; + } + } + asm + ( + "skip:;" + "call dword ptr [sendto];" + + + "mov esi,dword ptr [ebp+0x418];" + "call 0x489F30;" + "cmp byte ptr [0x10A6381],0x0;" + "mov ecx,dword ptr [ebp+0x41C];" + "mov esi,eax;" + "movzx eax,word ptr [ebp+0x420];" + "mov dword ptr [esp+0x1C],esi;" + "mov dword ptr [esp+0x20],edx;" + "je L0xABEL_0x00488E59;" + "mov edx,dword ptr [esp+0x10];" + "push edx;" + "push edi;" + "mov edi,dword ptr [ebp+0x418];" + "push eax;" + "mov eax,dword ptr [esp+0x2C];" + "push ecx;" + "push eax;" + "push esi;" + "xor ecx,ecx;" + "call 0x48B040;" + "mov edi,dword ptr [esp+0x14];" + "L0xABEL_0x00488E59:;" + "cmp byte ptr [edi],0x4;" + "jne L0xABEL_0x00488EC4;" + "mov ecx,ebx;" + "mov eax,ebp;" + "call 0x488170;" + "add eax,esi;" + "adc edx,dword ptr [esp+0x20];" + "add dword ptr [ebx+0x10],0x1;" + "mov dword ptr [ebx+0x8],eax;" + "mov dword ptr [ebx+0xC],edx;" + "mov eax,dword ptr [ebp+0x514];" + "lea ecx,dword ptr [ebp+0x510];" + "cmp eax,ecx;" + "je L0xABEL_0x00488EA0;" + "L0xABEL_0x00488E87:;" + "mov edx,dword ptr [ebx+0xC];" + "cmp edx,dword ptr [eax+0xC];" + "jl L0xABEL_0x00488EA0;" + "jg L0xABEL_0x00488E99;" + "mov edx,dword ptr [ebx+0x8];" + "cmp edx,dword ptr [eax+0x8];" + "jb L0xABEL_0x00488EA0;" + "L0xABEL_0x00488E99:;" + "mov eax,dword ptr [eax+0x4];" + "cmp eax,ecx;" + "jne L0xABEL_0x00488E87;" + "L0xABEL_0x00488EA0:;" + "mov ecx,dword ptr [ebx];" + "mov edx,dword ptr [ebx+0x4];" + "mov dword ptr [ecx+0x4],edx;" + "mov ecx,dword ptr [ebx+0x4];" + "mov edx,dword ptr [ebx];" + "mov dword ptr [ecx],edx;" + "mov dword ptr [ebx],ebx;" + "mov dword ptr [ebx+0x4],ebx;" + "mov ecx,dword ptr [eax];" + "mov dword ptr [ebx],ecx;" + "mov dword ptr [ebx+0x4],eax;" + "mov dword ptr [eax],ebx;" + "mov edx,dword ptr [ebx];" + "mov dword ptr [edx+0x4],ebx;" + "jmp L0xABEL_0x00488ED1;" + "L0xABEL_0x00488EC4:;" + "mov edx,dword ptr [ebp+0x418];" + "mov eax,ebx;" + "call 0x489ED0;" + "L0xABEL_0x00488ED1:;" + "mov ecx,dword ptr [esp+0x10];" + "mov edx,dword ptr [esp+0x20];" + "mov eax,dword ptr [ebp+0x418];" + "push ecx;" + "push edx;" + "push esi;" + "push 0x0;" + "lea edx,dword ptr [eax+0x80];" + "call 0x47D0A0;" + "cmp dword ptr [0x10A6384],0x2;" + "jl L0xABEL_0x0048901B;" + "lea eax,dword ptr [esp+0x6C];" + "push eax;" + "mov esi,ebx;" + "call 0x488BC0;" + "add esp,0x4;" + "mov ebx,eax;" + "mov dword ptr [esp+0x94],0x0;" + "mov edx,dword ptr [ebp];" + "mov edx,dword ptr [edx+0x18];" + "lea eax,dword ptr [esp+0x50];" + "push eax;" + "mov ecx,ebp;" + "call edx;" + "mov dword ptr [esp+0x14],eax;" + "mov eax,dword ptr [esp+0x20];" + "mov ecx,dword ptr [esp+0x1C];" + "push eax;" + "push ecx;" + "lea esi,dword ptr [esp+0x3C];" + "mov byte ptr [esp+0x9C],0x1;" + "call 0x485CB0;" + "add esp,0x8;" + "mov esi,0x10;" + "mov byte ptr [esp+0x94],0x2;" + "cmp dword ptr [ebx+0x18],esi;" + "jb L0xABEL_0x00488F60;" + "mov ebx,dword ptr [ebx+0x4];" + "jmp L0xABEL_0x00488F63;" + "L0xABEL_0x00488F60:;" + "add ebx,0x4;" + "L0xABEL_0x00488F63:;" + "mov ecx,dword ptr [esp+0x14];" + "cmp dword ptr [ecx+0x18],esi;" + "jb L0xABEL_0x00488F71;" + "mov ecx,dword ptr [ecx+0x4];" + "jmp L0xABEL_0x00488F74;" + "L0xABEL_0x00488F71:;" + "add ecx,0x4;" + "L0xABEL_0x00488F74:;" + "cmp dword ptr [eax+0x18],esi;" + "jb L0xABEL_0x00488F7E;" + "mov eax,dword ptr [eax+0x4];" + "jmp L0xABEL_0x00488F81;" + "L0xABEL_0x00488F7E:;" + "add eax,0x4;" + "L0xABEL_0x00488F81:;" + "push 0xE00779;" + "push ebx;" + "push ecx;" + "push eax;" + "push 0xE05AB0;" + "call 0x937C30;" + "add esp,0x14;" + "cmp dword ptr [esp+0x4C],esi;" + "jb L0xABEL_0x00488FA9;" + "mov edx,dword ptr [esp+0x38];" + "push edx;" + "call 0x957A60;" + "add esp,0x4;" + "L0xABEL_0x00488FA9:;" + "xor ebx,ebx;" + "cmp dword ptr [esp+0x68],esi;" + "mov dword ptr [esp+0x4C],0xF;" + "mov dword ptr [esp+0x48],ebx;" + "mov byte ptr [esp+0x38],bl;" + "jb L0xABEL_0x00488FCE;" + "mov eax,dword ptr [esp+0x54];" + "push eax;" + "call 0x957A60;" + "add esp,0x4;" + "L0xABEL_0x00488FCE:;" + "mov dword ptr [esp+0x94],0xFFFFFFFF;" + "cmp dword ptr [esp+0x84],esi;" + "mov dword ptr [esp+0x68],0xF;" + "mov dword ptr [esp+0x64],ebx;" + "mov byte ptr [esp+0x54],0x0;" + "jb L0xABEL_0x00489000;" + "mov ecx,dword ptr [esp+0x70];" + "push ecx;" + "call 0x957A60;" + "add esp,0x4;" + "L0xABEL_0x00489000:;" + "mov esi,dword ptr [esp+0x1C];" + "mov dword ptr [esp+0x84],0xF;" + "mov dword ptr [esp+0x80],ebx;" + "mov byte ptr [esp+0x70],0x0;" + "L0xABEL_0x0048901B:;" + "add word ptr [ebp+0x4A0],0x1;" + "xor ebx,ebx;" + "lea ecx,dword ptr [ebp+0x4B8];" + "mov word ptr [ebp+0x4A2],bx;" + "call 0x9566C0;" + "test eax,eax;" + "je L0xABEL_0x00489077;" + "mov eax,dword ptr [0xF58DE4];" + "push ebx;" + "cdq;" + "push 0x3E8;" + "push edx;" + "push eax;" + "call 0xA899A0;" + "mov esi,dword ptr [ebp+0x418];" + "mov ebx,eax;" + "mov dword ptr [esp+0x18],edx;" + "call 0x489F30;" + "mov esi,dword ptr [esp+0x1C];" + "add eax,ebx;" + "adc edx,dword ptr [esp+0x18];" + "mov dword ptr [ebp+0x4A8],eax;" + "mov dword ptr [ebp+0x4AC],edx;" + "jmp L0xABEL_0x00489083;" + "L0xABEL_0x00489077:;" + "mov dword ptr [ebp+0x4A8],ebx;" + "mov dword ptr [ebp+0x4AC],ebx;" + "L0xABEL_0x00489083:;" + "movzx eax,word ptr [edi+0x5];" + "movzx edx,ax;" + "and edx,0x8000007F;" + "jns L0xABEL_0x00489097;" + "dec edx;" + "or edx,0xFFFFFF80;" + "inc edx;" + "L0xABEL_0x00489097:;" + "shl edx,0x4;" + "mov word ptr [edx+ebp+0x518],ax;" + "movzx ecx,word ptr [edi+0x5];" + "and ecx,0x8000007F;" + "jns L0xABEL_0x004890B3;" + "dec ecx;" + "or ecx,0xFFFFFF80;" + "inc ecx;" + "L0xABEL_0x004890B3:;" + "add ecx,0x52;" + "shl ecx,0x4;" + "add ecx,ebp;" + "call 0x9556F0;" + "mov eax,dword ptr [esp+0x20];" + "push eax;" + "push esi;" + "mov esi,ebp;" + "call 0x488260;" + "add eax,dword ptr [esp+0x10];" + "mov ecx,dword ptr [esp+0x20];" + "mov dword ptr [ebp+0x438],eax;" + "mov eax,dword ptr [esp+0x1C];" + "mov dword ptr [ebp+0x430],eax;" + "mov dword ptr [ebp+0x434],ecx;" + "cmp byte ptr [edi],0x5;" + "je L0xABEL_0x004890FC;" + "mov dword ptr [ebp+0x448],eax;" + "mov dword ptr [ebp+0x44C],ecx;" + "L0xABEL_0x004890FC:;" + "cmp byte ptr [edi],0x6;" + "jne L0xABEL_0x0048910B;" + "mov dword ptr [ebp+0x450],0x1E8480;" + "L0xABEL_0x0048910B:;" + "mov ecx,dword ptr [esp+0x8C];" + "pop edi;" + "pop esi;" + "pop ebp;" + //"mov dword ptr [0x0],ecx;" + "pop ebx;" + "add esp,0x88;" + "ret 0x4;" + ); +} + +void Gpg_Net_Entry() +{ + asm + ( + "GetCurrentThread = 0x00C0F588;" + "SetThreadPriority = 0x00C0F52C;" + "WSAWaitForMultipleEvents = 0x00C0F930;" + "WSAResetEvent = 0x00C0F8FC;" + "CreateEvent = 0x00C0F57C;" + + "push 0xFFFFFFFF;" + "push 0xBB33B8;" + // "mov eax,dword ptr [0x0];" + "push eax;" + // "mov dword ptr [0x0],esp;" + "sub esp,0x58;" + "push ebx;" + "push ebp;" + "push esi;" + "push edi;" + "mov edi,ecx;" + "mov dword ptr [esp+0x14],edi;" + "mov dword ptr [esp+0x70],0x0;" + "mov eax,dword ptr [edi];" + "mov edx,dword ptr [eax+0xC];" + "call edx;" + "movzx eax,ax;" + "push eax;" + "lea ecx,dword ptr [esp+0x34];" + "push 0xE05B04;" + "push ecx;" + "call 0x938F10;" + "add esp,0xC;" + "mov byte ptr [esp+0x70],0x1;" + "cmp dword ptr [esp+0x48],0x10;" + "mov eax,dword ptr [esp+0x34];" + "jae L0xABEL_0x00489FEB;" + "lea eax,dword ptr [esp+0x34];" + "L0xABEL_0x00489FEB:;" + "push eax;" + "push 0xFFFFFFFF;" + "call 0x9071D0;" + "add esp,0x8;" + "xor bl,bl;" + "call 0x4141A0;" + "push 0x2;" + "call dword ptr [GetCurrentThread];" + "push eax;" + "call dword ptr [SetThreadPriority];" + + "xor ecx, ecx;" + "push ecx;" + "push ecx;" + "push ecx;" + "push ecx;" + "call dword ptr [CreateEvent];" + "mov dword ptr [0x11FD253], eax;" + + + "lea ecx,dword ptr [edi+0x8];" + "mov dword ptr [esp+0x1C],ecx;" + "call 0xAC51B0;" + "mov byte ptr [esp+0x20],0x1;" + "mov byte ptr [esp+0x70],0x2;" + "L0xABEL_0x0048A022:;" + "cmp byte ptr [0x10A6381],0x0;" + "jne L0xABEL_0x0048A048;" + "mov eax,dword ptr [edi+0x18088];" + "test eax,eax;" + "je L0xABEL_0x0048A048;" + "push eax;" + "call 0xA8540F;" + "add esp,0x4;" + "mov dword ptr [edi+0x18088],0x0;" + "L0xABEL_0x0048A048:;" + "mov ecx,edi;" + "call 0x48A280;" + "mov ecx,edi;" + "call 0x48AC40;" + "cmp byte ptr [edi+0x50],0x0;" + "mov ebx,eax;" + "mov dword ptr [esp+0x18],ebx;" + "je L0xABEL_0x0048A0AC;" + "cmp byte ptr [edi+0x51],0x0;" + "jne L0xABEL_0x0048A0AC;" + "mov esi,dword ptr [edi+0x28];" + "lea ebx,dword ptr [edi+0x24];" + "cmp esi,ebx;" + "je L0xABEL_0x0048A09F;" + "L0xABEL_0x0048A072:;" + "test esi,esi;" + "je L0xABEL_0x0048A07E;" + "lea ebp,dword ptr [esi-0x410];" + "jmp L0xABEL_0x0048A080;" + "L0xABEL_0x0048A07E:;" + "xor ebp,ebp;" + "L0xABEL_0x0048A080:;" + "cmp byte ptr [ebp+0xE41],0x0;" + "mov esi,dword ptr [esi+0x4];" + "je L0xABEL_0x0048A09B;" + "push ebp;" + "call 0x486150;" + "push ebp;" + "call 0x957A60;" + "add esp,0x4;" + "L0xABEL_0x0048A09B:;" + "cmp esi,ebx;" + "jne L0xABEL_0x0048A072;" + "L0xABEL_0x0048A09F:;" + "cmp dword ptr [ebx+0x4],ebx;" + "je L0xABEL_0x0048A1D5;" + "mov ebx,dword ptr [esp+0x18];" + "L0xABEL_0x0048A0AC:;" + "mov ecx,dword ptr [esp+0x1C];" + "call 0xAC5200;" + + "cmp byte ptr [0x10A6380],0x0;" + "mov byte ptr [esp+0x20],0x0;" + "je L0xABEL_0x0048A0CA;" + "mov dword ptr [0x0], eax;" + "L0xABEL_0x0048A0CA:;" + + "xor ebp,ebp;" + "cmp dword ptr [0x10A6384],0x3;" + "mov dword ptr [esp+0x28],ebp;" + "jl L0xABEL_0x0048A132;" + "mov esi,edi;" + "call 0x489F30;" + "mov ebp,eax;" + "push edx;" + "push ebp;" + "lea esi,dword ptr [esp+0x54];" + "mov dword ptr [esp+0x30],edx;" + "call 0x485CB0;" + "add esp,0x8;" + "mov esi,0x10;" + "mov byte ptr [esp+0x70],0x3;" + "cmp dword ptr [eax+0x18],esi;" + "jb L0xABEL_0x0048A108;" + "mov eax,dword ptr [eax+0x4];" + "jmp L0xABEL_0x0048A10B;" + "L0xABEL_0x0048A108:;" + "add eax,0x4;" + "L0xABEL_0x0048A10B:;" + "push ebx;" + "push eax;" + "push 0xE05B24;" + "call 0x937C30;" + "add esp,0xC;" + "mov byte ptr [esp+0x70],0x2;" + "cmp dword ptr [esp+0x64],esi;" + "jb L0xABEL_0x0048A132;" + "mov edx,dword ptr [esp+0x50];" + "push edx;" + "call 0x957A60;" + "add esp,0x4;" + "L0xABEL_0x0048A132:;" + "push 0x1;" + "push ebx;" + "push 0x0;" + "lea eax,dword ptr [edi+0x18];" + "push eax;" + "push 0x1;" + "call dword ptr [WSAWaitForMultipleEvents];" + "mov eax,ebp;" + "or eax,dword ptr [esp+0x28];" + "je L0xABEL_0x0048A1B8;" + "mov esi,edi;" + "call 0x489F30;" + "mov ebx,edx;" + "mov edi,eax;" + "push ebx;" + "push edi;" + "lea esi,dword ptr [esp+0x54];" + "call 0x485CB0;" + "add esp,0x8;" + "mov byte ptr [esp+0x70],0x4;" + "cmp dword ptr [eax+0x18],0x10;" + "jb L0xABEL_0x0048A174;" + "mov esi,dword ptr [eax+0x4];" + "jmp L0xABEL_0x0048A177;" + "L0xABEL_0x0048A174:;" + "lea esi,dword ptr [eax+0x4];" + "L0xABEL_0x0048A177:;" + "push 0x0;" + "sub edi,ebp;" + "sbb ebx,dword ptr [esp+0x2C];" + "push 0x3E8;" + "push ebx;" + "push edi;" + "call 0xA8EB30;" + "push edx;" + "push eax;" + "push esi;" + "push 0xE05B40;" + "call 0x937C30;" + "add esp,0x10;" + "mov byte ptr [esp+0x70],0x2;" + "cmp dword ptr [esp+0x64],0x10;" + "jb L0xABEL_0x0048A1B4;" + "mov ecx,dword ptr [esp+0x50];" + "push ecx;" + "call 0x957A60;" + "add esp,0x4;" + "L0xABEL_0x0048A1B4:;" + "mov edi,dword ptr [esp+0x14];" + "L0xABEL_0x0048A1B8:;" + "mov ecx,dword ptr [esp+0x1C];" + "call 0xAC51B0;" + "mov edx,dword ptr [edi+0x18];" + "push edx;" + "mov byte ptr [esp+0x24],0x1;" + "call dword ptr [WSAResetEvent];" + "jmp L0xABEL_0x0048A022;" + "L0xABEL_0x0048A1D5:;" + "mov ecx,dword ptr [esp+0x1C];" + "call 0xAC5200;" + "cmp dword ptr [esp+0x48],0x10;" + "jb L0xABEL_0x0048A1F2;" + "mov eax,dword ptr [esp+0x34];" + "push eax;" + "call 0x957A60;" + "add esp,0x4;" + "L0xABEL_0x0048A1F2:;" + "mov dword ptr [esp+0x70],0xFFFFFFFF;" + "mov esi,dword ptr [esp+0x7C];" + "test esi,esi;" + "mov dword ptr [esp+0x48],0xF;" + "mov dword ptr [esp+0x44],0x0;" + "mov byte ptr [esp+0x34],0x0;" + "je L0xABEL_0x0048A241;" + "lea ecx,dword ptr [esi+0x4];" + "or edx,0xFFFFFFFF;" + "lock xadd dword ptr [ecx],edx;" + "jne L0xABEL_0x0048A241;" + "mov eax,dword ptr [esi];" + "mov edx,dword ptr [eax+0x4];" + "mov ecx,esi;" + "call edx;" + "lea eax,dword ptr [esi+0x8];" + "or ecx,0xFFFFFFFF;" + "lock xadd dword ptr [eax],ecx;" + "jne L0xABEL_0x0048A241;" + "mov edx,dword ptr [esi];" + "mov eax,dword ptr [edx+0x8];" + "mov ecx,esi;" + "call eax;" + "L0xABEL_0x0048A241:;" + "mov ecx,dword ptr [esp+0x68];" + "pop edi;" + "pop esi;" + "pop ebp;" + //"mov dword ptr [0x0],ecx;" + "pop ebx;" + "add esp,0x64;" + "ret 0x8;" + ); +} \ No newline at end of file diff --git a/section/include/funcDefs.h b/section/include/funcDefs.h new file mode 100644 index 00000000..bcc71b20 --- /dev/null +++ b/section/include/funcDefs.h @@ -0,0 +1,133 @@ +#include "global.h" +#include "typeDefs.h" +#include "moho.h" +#include + +//((int (*)(const char* fmt, ...))_Logf)("Hello World!"); //direct call example +/* typedef void __Logf(const char* fmt, ...); + __Logf* Logf = reinterpret_cast<__Logf*>(_Logf); */ + +//required functions that have not been reversed yet. + +class funcDefs +{ +public: + + typedef void __Logf(const char* fmt, ...); + //__Logf *Logf = (__Logf*)(_Logf); + + typedef void __LuaState__Error(LuaState *a1, char *a2, ...); + __LuaState__Error *LuaState__Error = (__LuaState__Error*)(_LuaState__Error); + + typedef int __lua_gettop(int a1); + //__lua_gettop *lua_gettop = (__lua_gettop*)(_lua_gettop); + + typedef __attribute__((cdecl)) _DWORD *__Eval_Lua_Object(int *a1, const struct LuaStackObject *a2, LuaState *a3, int a4); + __Eval_Lua_Object *Eval_Lua_Object = (__Eval_Lua_Object*)(_Eval_Lua_Object); + + typedef bool __Validate_IssueCommand(int a1, int a2, int a3); + __Validate_IssueCommand *Validate_IssueCommand = (__Validate_IssueCommand*)(_Validate_IssueCommand); + + typedef __attribute__((thiscall)) int __Get_Lua_Coordinates_State(int a1, LuaState *a2, int a4, lua_State **a5, int a6); + __Get_Lua_Coordinates_State *Get_Lua_Coordinates_State = (__Get_Lua_Coordinates_State*)(_Get_Lua_Coordinates_State); + + typedef int __Push_Coordinates(int result, int a2); + __Push_Coordinates *Push_Coordinates = (__Push_Coordinates*)(_Push_Coordinates); + + typedef int __Moho_UNIT_IssueCommand(int a1, int a2, Moho__SSTICommandIssueData *a3, char a4); + __Moho_UNIT_IssueCommand *Moho_UNIT_IssueCommand = (__Moho_UNIT_IssueCommand*)(_Moho_UNIT_IssueCommand); + + typedef int __Moho_SSTICommandIssueData_SSTICommandIssueData(_DWORD *_this, int a2); + __Moho_SSTICommandIssueData_SSTICommandIssueData *Moho_SSTICommandIssueData_SSTICommandIssueData = (__Moho_SSTICommandIssueData_SSTICommandIssueData*)(_Moho_SSTICommandIssueData_SSTICommandIssueData); + + typedef int __attribute__((stdcall)) __Moho_SSTICommandIssueData_Destructor_SSTICommandIssueData(int a1); + __Moho_SSTICommandIssueData_Destructor_SSTICommandIssueData *Moho_SSTICommandIssueData_Destructor_SSTICommandIssueData = + (__Moho_SSTICommandIssueData_Destructor_SSTICommandIssueData*)(_Moho_SSTICommandIssueData_Destructor_SSTICommandIssueData); + + typedef uint32 *__LuaPlus_LuaState_PushNil(int a1); + //__LuaPlus_LuaState_PushNil *LuaPlus_LuaState_PushNil = (__LuaPlus_LuaState_PushNil*)(_LuaPlus_LuaState_PushNil); + + typedef _DWORD *__LuaPlus_LuaObject_PushStack(_DWORD *_this, _DWORD *a2, lua_State **a3); + //__LuaPlus_LuaObject_PushStack *LuaPlus_LuaObject_PushStack = (__LuaPlus_LuaObject_PushStack*)(_LuaPlus_LuaObject_PushStack); + + //extern functions: + //MSVCR80.dll + typedef __attribute__((cdecl)) int __memmove_s(void *Dst, size_t DstSize, const void *Src, size_t MaxCount); + __memmove_s *memmove_s = (__memmove_s*)(_memmove_s); + + typedef __attribute__((cdecl)) int __lua_getglobaluserdata(int a1); + //__lua_getglobaluserdata *lua_getglobaluserdata = (__lua_getglobaluserdata*)(_lua_getglobaluserdata); + + //shsmp.dll + typedef void __j_shi_delete_0(int a1); + __j_shi_delete_0 *j_shi_delete_0 = (__j_shi_delete_0*)(_j_shi_delete_0); + + typedef int __j_shi_new_0(int a1); + __j_shi_new_0 *j_shi_new_0 = (__j_shi_new_0*)(_j_shi_new_0); + + + volatile int __Push_Coordinatesw(int r, int a2) + { + int result; + __asm volatile( + "mov ecx, %[a2] \n\t" //point to the structure + "mov eax, %[r] \n\t" + "call %[func]\n\t" + : "=a" (result) + : [func] "m" (_Push_Coordinates), [r] "r" (r), [a2] "r" (a2) + : "memory" + ); + return result; + } + + volatile bool __Validate_IssueCommandw(int a1, int a2, int a3) + { + int result; + __asm volatile( + "push %[a3] \n\t" + "push %[a2] \n\t" + "mov edi, %[a1] \n\t" + "call %[func]\n\t" + : "=a" (result) + : [func] "m" (_Validate_IssueCommand), [a1] "r" (a1), [a2] "r" (a2), [a3] "r" (a3) + : "memory" + ); + return result; + } + + volatile int __Get_Lua_Coordinates_Statew(int a1, LuaState *a2, int a4, lua_State **a5, int a6) + { + register int result asm("eax"); + __asm volatile( + "push %[a6] \n\t" + "push %[a5] \n\t" + "push %[a4] \n\t" + "push %[a2] \n\t" + //"mov st(0), %[a2] \n\t" + "mov edi, %[a1] \n\t" + "call %[func]\n\t" + : "=a" (result) + : [func] "m" (_Get_Lua_Coordinates_State), [a1] "r" (a1), [a2] "r" (a2), [a4] "r" (a4), [a5] "r" (a5), [a6] "r" (a6) + : "memory" + ); + return result; + } + + volatile int Moho_UNIT_IssueCommandw(int a1, int a2, Moho__SSTICommandIssueData *a3, int a4) + { + int result; + __asm volatile( + "push %[a4] \n\t" + "push %[a3] \n\t" + "push %[a2] \n\t" + "mov edx,%[a1] \n\t" + "call %[func]\n\t" + : "=a" (result) + : [func] "m" (_Moho_UNIT_IssueCommand), [a1] "r" (a1), [a2] "r" (a2), [a3] "r" (a3), [a4] "r" (a4) + : "memory" + ); + return result; + + } + +}; diff --git a/section/include/global.h b/section/include/global.h new file mode 100644 index 00000000..cd6c2ef8 --- /dev/null +++ b/section/include/global.h @@ -0,0 +1,281 @@ +#pragma once +/* +GetClassNamePtr -> [[[Self]-4]+C]+8 +GetParentClassNamePtr -> [[[[Self]-4]+24+1*4]]+8 + +TrueClassOffset -> -[[[Self]-4]+4] +ClassAncestors -> [[Self]-4]+24 + +Get debugging info about a Lua call: + +[[[lua_State+28]+lvl*5*8]-4] = FuncPtr + +[[FuncPtr+18]+20]+14 = full path to file + +[[FuncPtr+18]+3C] = line defined + +[lua_State+28]+lvl*5*8 = CallInfo //lua.org/source/5.0/lstate.h.html#CallInfo +[[[CallInfo]-4]+18] = Proto //lua.org/source/5.0/lobject.h.html#Proto +[[CallInfo+0C]-[Proto+0C]+[Proto+14]] = currentline +*/ +// Globals +const int g_STIDriver = 0x10C4F50; +const int g_SWldSessionInfo = 0x10C4F58; +const int g_CWldSession = 0x10A6470; +const int g_Sim = 0x10A63F0; +const int g_EntityCategoryTypeInfo = 0x10C6E70; +const int g_CAiBrainTypeInfo = 0x10C6FA0; +const int g_CUIManager = 0x10A6450; +const int g_EngineStats = 0x10A67B8; + +const int g_ExeVersion1 = 0x00876666; +const int g_ExeVersion2 = 0x0087612d; +const int g_ExeVersion3 = 0x004d3d40; + +const int ui_SelectTolerance = 0x0F57A90; +const int ui_ExtractSnapTolerance = 0x0F57A94; +const int ui_DisableCursorFixing = 0x10A6464; +const int ui_RenderIcons = 0x00F57B27; +const int range_RenderSelected = 0x010A640A; +const int range_RenderHighlighted = 0x010A640B; +const int range_RenderBuild = 0x010A6414; + +// String const +const int s_FACTORY = 0xE19824; +const int s_EXPERIMENTAL = 0xE204B8; +const int s_global = 0xE00D90; // "" + +// Byte const + +const char d3d_WindowsCursor = 0x010A636E; + +// Int const + +const int ui_ProgressBarColor = 0x00F57BB8; + +//Adress const +const int _CannotQueCommandInConstruct = 0x006EFB0E; +const int _CanQueCommandInConstruct = 0x006EFAF8; +const int _NeitherInCategoryInConstruct = 0x006EFACE; +const int _EndCalculateNoRushTimerVariable = 0x006FF3D6; + +// c Symbols + +const int _CheckCategory = 0x00405550; +const int _CheckCategory_sub_func = 0x004059E0; +const int _GetCatCmpResult = 0x0067B050; +const int _exit_STAYONWATSUR_check = 0x0062ADEE; +const int _exit_STAYONWATSUR_NoMatch = 0x0062ADEC; +const int _Moho_SSTICommandIssueData_SSTICommandIssueData = 0x00552550; + +//extern functions: +//MSVCR80.dll +const int _memmove_s = 0x00A824E7; + +//LuaPlus: See FALuaFuncs.txt +/* +Use Tables example: +CreateTable + CreateTable + PushNumber + PushNumber + PushNumber + PushStack + PushTable + LuaObjectFinalize + PushStack +LuaObjectFinalize + +// Other + +00937C30 SpewF(char* str, args...) +00937CB0 LogF(char* str, args...) +00937D30 WarningF(char* str, args...) +0041C990 ConsoleLogF(char* str, args...) + +00938E00 Format +00938F10 Format+1 +00A89950 RaiseException+1 + +00958B20 AllocMemory(Size):eax +00957A70 AllocMemory+1 +00A825B9 AllocMemory2(Size):eax +00A82130 AllocMemory2+1 +00958C40 FreeMemory(Ptr) +00957AF0 FreeMemory+1 +00957A60 FreeMemory+2 +00A82542 FreeMemory+3 + +00908A70 GetVar(out LuaObject* ecx, LuaState**):eax LuaObject +009132F0 lua_getinfo +00AA549E StrCmp(char* str1, char* str2) +00A89190 CopyMem(void* dest, void* src, len) +006E5660 Moho_SetSetSize(moho_set* ecx, setSize) +004036A0 Moho_SetAdd(moho_set* edi, setSize esi, out 0xC) +009072A0 NullifyBytes16(ecx) +00A89CC0 FloatToInt(value):eax +004035F0 IsValidCommandSource +00408450 CompareStrings(char* str1, char* str2, strLen1):eax -1,0,1 +0040A880 CompareStrings2(char* str1, strLen1, char* str2, strLen2):eax +0041CC90 SimConExecute +004CD3A0 Register LUA function +00528460 RRuleGameRulesAlloc(Arg1,Arg2) +00529120 RRuleGameRulesInit(Arg1,Arg2,Arg3) +00529510 DestroyRRuleGameRules +00546650 FindRes(CSimResources* ecx, Type, Rect*):Bool +00546760 FindRes(CSimResources* ecx, PtrPosXY, PtrResultXY, Radius, Type):Bool +00581AA0 CallFunctionLua(self ecx) +005BD630 Internal IsAlly +005D5540 Internal IsEnemy +00707BF0 Internal IsNeutral +006FE530 SimArmyAlloc(Arg1,Arg2,Arg3,Arg4,Arg5,Arg6) +006FE690 SimArmyCreate(Arg1,Arg2,Arg3,Arg4,Arg5,Arg6) +006FE670 DestroySimArmy +004C8270 Get_c_object //From table Ptr to value +005936C0 GetSimCUnit(Table* eax):eax +005E3800 GetCUnit(Table* eax):eax +005930D0 GetCBrain(Table* eax):eax +00707D60 GetSimArmy +0073B1B0 SetArmyIndex(CSimDriver* ecx, value) +0073F4E0 CSimDriverAlloc(Arg1,Arg2,Arg3,Arg4) +0073B570 CSimDriverInit(Arg1,Arg2,Arg3) +007433B0 SimAlloc +007434D0 SimCreate(Arg1,Arg2) +00744060 SimSetup(Arg1,Arg2) +007458E0 SimFinalize(Sim*) +006A9F40 UpdCompleteProgress +00747180 IsCheating! +005459F0 GetLuaNumber +0067AFF0 LayerChange +007A4970 OnMouseMove +008704B0 OnMouseMoveOverMap +0086E480 CUIWorldViewInit(Arg1,Arg2,Arg3,Arg4,Arg5,Arg6,Arg7) +00885DE0 WorldSessionLoad(Arg1) +0088C000 DoLoading +00897220 CWldSessionAlloc +00893160 CWldSessionCreate(Arg1,Arg2,Arg3) +008965E0 Internal SetFocusArmy +00896670 Test Set focus access rights +008C0500 SelectUnit +008CEDE0 AppInit +008D4010 SC_CreateEntityDialog +0055AE10 CalcMaxSimRate +0053E590 SetSimRate +0053E720 GetSimRate +0053E7E0 GetSimRateRequested +007EF9B0 RenderRing +008F3C40 D3DXEffect::GetPassCount ? +008F4080 D3DXEffect::BeginPass ? +008F4260 D3DXEffect::EndPass ? +00941D70 D3DXEffect::SetMatrix ? +00941F60 D3DXEffect::SetTechnique +00858D80 DisplayEconomyOverlay +00430590 D3DGetDevice +008D82F0 CreateBitArray2D +008D8210 BitArray2DReset +008D8200 DestroyBitArray2D +005C36A0 CreateCAiReconDBImpl +005BFF90 InitCAiReconDBImpl +00507720 InitCIntelGrid +0067AE70 SetEntityCollision +0067AD30 CreateCollisionSphere +0067AC40 CreateCollisionBox +0067AE00 DestroyCollision +0084C5E0 CreateCUIManager +0084C9C0 InitCUIManager +00408940 CreateEngineStats +004088C0 InitEngineStats(EngineStats*) +0040C200 CreateEngineStatsItem(EngineStats* ecx, char* pathAndName, int value):eax +0040A0A0 CreateStatItemRoot(EngineStats*):eax +00408730 InitStatItem(StatItem*, char* name):eax +008E5050 CalcHash +00542870 CreateLaunchInfoNew +00542790 InitLaunchInfoNew +005427F0 DestroyLaunchInfoNew +0088C9D0 CreateSWldSessionInfo +0088D060 InitSWldSessionInfo +0053E180 CreateCLocalClient +0053BD40 InitCClientBase +0053FAF0 CreateCClientManager +0053DF20 InitCClientManager +0053E400 CreateCReplayClient +0053BA50 InitCReplayClient +00956DB0 InitStream +009565D0 InitPipeStream +00955BD0 InitFileStream +00955870 DestroyFileStream +0048BBE0 CreateCNetUDPConnetor +004896F0 InitCNetUDPConnetor +004899E0 DestroyCNetUDPConnetor +007AA9C0 CreateCamera +007A7950 InitCamera +007A7DC0 DestroyCamera +00749F40 SimBeat +0073DAD0 SimSync +00894530 UserSync +008B1520 InitUserArmy +008B85E0 InitUserEntity +008BF420 InitUserUnit +008B8760 DestroyUserEntity +008BF990 DestroyUserUnit +004C7010 InitRObjectAndCScriptObject +00677C90 InitEntity +007489E0 CreateUnit +006A53F0 InitUnit +006A5320 DestroyUnit +006A0FB0 CreateProjectile +0069AFE0 InitProjectile +006FB3B0 CreateProp +006F9D90 InitProp +0050DD60 InitRBlueprint +00511C30 InitREntityBlueprint +00532680 CreateRMeshBlueprint +005283A0 InitRMeshBlueprint +00531D80 CreateRUnitBlueprint +0051E480 InitRUnitBlueprint +00532080 CreateRPropBlueprint +0051D250 InitRPropBlueprint +00532380 CreateRProjectileBlueprint +0051B740 InitRProjectileBlueprint +005289D0 RegisterBlueprint(RRuleGameRules*, char* Category) +00577890 InitSTIMap +005790E0 CreateCHeightField +0044FB90 GetTerrainHeight(float x, float z):int ecx +0074B120 FlattenTerrain(STIMap*, int Rect*, float Height) +00476BB0 UpdateMinimap(MapData*, int x1, int y1, int x2, int y2) +00890DA0 MapLoad +0057CBB0 CanBuildStructureAt(CAiBrain*, x, y, z, Blueprint*, ?, ?, ?):al +006856C0 SimFindEntityChainById(ecx* entities, ebx* id, eax* result) +00898DC0 UserFindEntityChainById(ecx* entities, ebx* id, eax* result) +*/ +const int _Logf = 0x937CB0; +const int LuaState__CastState = 0x90A510; // LuaState* (lua_state*) +const int _LuaState__Error = 0x90C1D0; // (LuaState*, fmt, args...) +const int _CastState_LuaState_LuaPlus__SAPAV12_PAUlua_State___Z = 0x90A510; +const int __0LuaObject_LuaPlus__QAE_ABVLuaStackObject_1__Z = 0x908A70; +const int __1LuaObject_LuaPlus__QAE_XZ = 0x9075D0; + +const int LuaStackObject__GetBoolean = 0x415560; + +const int _AssignClientIndex_CLobby_Moho__AAEXHVStrArg_gpg__AAIAAH_Z = 0x7C4E80; +const int _AssignCommandSource_CLobby_vector_allocator_USSTICommandSource = 0x7C4F60; + +const int lua_cast_CLobby_ = 0x7CB7E0; + +const int Moho__NET_MakeNATTraversal_ = 0x7BC5F0; //(LuaObject* rvo, LuaState*) +const int _Eval_Lua_Object = 0x6EEE40; + +// Utils +const int __imp_atoi = 0xA835CE; + +const int __ftol2_sse = 0xA89CC0; + +const int __stricmp = 0xAA549E; //int (const char*, const char*) + +const int _Validate_IssueCommand = 0x006EECF0; +const int _j_shi_delete_0 = 0x00A82542; +const int _j_shi_new_0 = 0x00A82130; +const int _Get_Lua_Coordinates_State = 0x006EEF60; +const int _Push_Coordinates = 0x005E27D0; +const int _Moho_UNIT_IssueCommand = 0x006F12C0; +const int _Moho_SSTICommandIssueData_Destructor_SSTICommandIssueData = 0x0057ABB0; diff --git a/section/include/global_func_table.h b/section/include/global_func_table.h new file mode 100644 index 00000000..eea152fb --- /dev/null +++ b/section/include/global_func_table.h @@ -0,0 +1,37 @@ +//emit reversed functions for later use. +#include "typeDefs.h" +#include "moho.h" + +extern _DWORD tick_num; +extern _DWORD tag_sent; +extern _DWORD num_clients; +extern _DWORD terminated; +extern _DWORD p_index; +extern _DWORD sender_sock; +extern _DWORD current_num_clients; +extern _DWORD sync_buffer[17]; +extern bool paused; +extern bool game_ended; + +void RangeRings(); +void GlobalRings(); +void SelectionRings(); +void GetSelectedUnits(); +void SearchIndexWithString(); +void GeometricCamera(); +void LowResolutionGeonometricCamera(); +void AirMotionTick(); +void AllUnitsMotionTick(); +void CalcMoveLand(); +void MoveTo(); +void Unit_MotionTick(); +void UpdateCurrentPosition(); +void NavigationTick(); +void Moho__CDecoder__DecodeMessage(); +void MOHO_USER_INPUT(); +void SessionEndGame(); +void Gpg_Net_Entry(); +void Conexecute(); +void sim_dispatch(); +void Update_Pipeline_Stream(); +void EndGame(); \ No newline at end of file diff --git a/section/include/moho.h b/section/include/moho.h new file mode 100644 index 00000000..3627a6db --- /dev/null +++ b/section/include/moho.h @@ -0,0 +1,1056 @@ +//MohoEngine Disassembling notes + +//LUA funcs map github.com/Eximius/forged_jit + +#pragma once +typedef unsigned int uint; +typedef unsigned int bool32; +typedef unsigned short uint16; + +struct luaFuncDescReg +{ + void** RegisterFunc; // call for register lua function + char* FuncName; // lua name function + char* ClassName; // lua class name. if class none + char* FuncDesc; // for log + luaFuncDescReg* Next; // reg func of chain + void* FuncPtr; // code address + void* ClassPtr; // C++ class type address. NULL if class none +}; + +struct string +{ // 0x1c bytes + void* ptr1; + char str[0x10]; // DataPtr or used as memory for 'Short Set Optimization' + uint strLen; + uint size; // 0f if SSO, 1f not SSO + +#ifdef CXX_BUILD + const char* data() + { + if(size < 0x10) + return (const char*)&m_data; + else + return (const char*)m_data; + } +#endif +}; + +struct vector +{ + char pad[4]; + void** objects_begin; + void** objects_end; + void** objects_capacity_end; + +#ifdef CXX_BUILD + void* operator[](int index) + { + if(index >= size()) + return 0; + return objects_begin[index]; + } + + int size() + { + return objects_end - objects_begin; + } +#endif +}; + +struct list // probably not from visual c++, but made by gpg +// considering, it's not capacity based, probably made by gpg +{ // 0x0C bytes + void* objects_start; // 0 if empty + void* objects_end; + void* objects_capacity_end; +}; + +typedef int SOCKET; +// GPGCore + +struct Vector2f +{ // 0x8 bytes + float x,z; +}; + +struct Vector3f +{ // 0xC bytes + float x,y,z; +}; + +struct Vector4f +{ // 0x10 bytes + float x,y,z,w; +}; + +struct RObject +{ // ~0x10 bytes + void* vtable; +}; + +struct CScriptObject // : RObject +{ // ~0x34 bytes +}; + +struct WeakObject +{ + void* vtable; +}; + +struct gpg_mutex +{ + int unknown1; + bool unknown2; // if value is 0 then NTDLL.RtlEnterCriticalSection is bypassed +}; + +struct Stream +{ // 0x1C bytes + void* vtable; +}; + +struct PipeStream // : Stream +{ // 0x48 bytes +}; + +struct FileStream // : Stream +{ // 0x34 bytes +}; + +struct StatItem // : .?AV?$TDatTreeItem@VStatItem@Moho@@@Moho@@ +{ // 0xA0 bytes + void* vtable; + // at 0x24 + int value; // int/float + // at 0x74 + string name; + // at 0x90 + int valueType; + int unknown2; + // at 0x98 + void* criticalSection; // result RtlInitializeCriticalSection + bool unknown1; // set 1 at 00AC1A69, at 00AC1AB0 check(0 -> WaitForSingleObject, 1 -> RtlEnterCriticalSection) +}; + +struct EngineStats // : .?AV?$Stats@VStatItem@Moho@@@Moho@@ +{ // 0x50 bytes + void* vtable; + StatItem* stat; + void* criticalSection; // result RtlInitializeCriticalSection + bool32 unknown1; // set 1 at 00AC1A69 + string str1; // written "stats.log" + string str2; + int unknown2; + bool32 unknown3; +}; + +struct lua_var //lua.org/source/5.0/lobject.h.html#TObject +{ // 0x8 bytes + int type; + void* value; + + /* Types: + -1 - None + 0 - Nil + 1 - Boolean + 2 - LightUserData + 3 - Number + 4 - String + 5 - Table + 6 - CFunction + 7 - Function + 8 - UserData + 9 - Thread + */ +}; + +struct lua_State //lua.org/source/5.0/lstate.h.html#lua_State +{ + void* nextGCObject; + uint16 tt, marked; + lua_var* objects_end; + lua_var* objects_start; // 1 based index + void* global_State; + void* callInfo; + lua_var* stack_last; + lua_var* stack; + int stacksize; // numVars + // at 0x44 + void* LuaState; +}; +struct LuaState; +struct LuaObject +{ // 0x14 bytes + LuaObject* m_next; + LuaObject* m_prev; + LuaState* m_state; + lua_var m_object; +}; +struct LuaState +{ // 0x34 bytes + lua_State* m_state; + void* ForMultipleThreads; + bool m_ownState; + LuaObject m_threadObj; + LuaState* m_rootState; + struct MiniLuaObject { + LuaObject* m_next; // only valid when in free list + LuaObject* m_prev; // only valid when in used list + } m_headObject, m_tailObject; +}; +struct LuaStackObject +{ // 0x8 bytes + LuaState* state; + int stack_index; +}; + +struct Moho__SSTICommandIssueData +{ +}; + +struct Camera // : RCamCamera +{ // 0x858 bytes +}; + +struct CMauiControl // : CScriptObject +{ +}; + +struct CUIWorldView // : CMauiControl +{ // 0x2A8 bytes + // at 0x120 + Camera* Camera; + // at 0x208 + void* CWldSession; +}; + +struct linked_list +{ +}; + +struct moho_set +{ // 0x20 bytes + int baseIndex; // integer_base >> 5 (bits in uint) + int unknown2; + uint* items_begin; + uint* items_end; + uint* items_capacity_end; + void* unknown6; + uint value; // Used as memory for 'Short Set Optimization' + void* unknown8; + +#ifdef CXX_BUILD + void add(int item) + { + uint* itemPtr = &items_begin[item >> 5]; + if (itemPtr >= items_end) + items_end = itemPtr + 1; + *itemPtr |= 1 << (item & 0x1f); + } + + void remove(int item) + { + items_begin[item>>5] &= ~( 1 << (item & 0x1f) ); + } + + bool operator[](int item) + { + return items_begin[item>>5] & (1 << (item & 0x1f)); + } +#endif +}; + +struct RRuleGameRules +{ // 0xD0 bytes + void* vtable; + // at 0x2C + //list L1; + // at 0x48 + //list L2; + // at 0xB8 + list Blueprints; // + //list L3; + // at 0xC4 + //void* Blueprints; + //void* Start, End; +}; + +struct LaunchInfoNew +{ // 0xA4 bytes + void* vtable; + + RRuleGameRules* rules; + void* STIMap; + + // at 0xC + string lua_gameMods; + // at 0x28 + string str2; + + // at 0x60 + int unknown1; + int unknown2; + int unknown3; // = -1 + // at 0x6C + string interfaceLang; + bool cheatsEnabled; // copied to CWldSession + 0x4D4 + char _pad1[3]; + int unknown4; +}; + +struct REffectBlueprint // : RObject +{ +}; + +struct RBeamBlueprint // : REffectBlueprint +{ // 0x140 bytes +}; + +struct RBlueprint // : RObject +{ // ~0x60 bytes + // at 0x4 + RRuleGameRules* owner; + string name; + string desc; + // at 0x40 + string source; // example: /units/uel0001/uel0001_unit.bp + uint BlueprintOrdinal; +}; + +struct RMeshBlueprint // : RBlueprint +{ // 0x80 bytes + // at 0x70 + float IconFadeInZoom; +}; + +struct REntityBlueprint // : RBlueprint +{ // ~0x17C bytes + // at 0x64 + list Categories; // +}; + +struct RPropBlueprint // : REntityBlueprint +{ // 0x1AC bytes +}; + +struct RProjectileBlueprint // : REntityBlueprint +{ // 0x268 bytes +}; + +struct RUnitBlueprint // : REntityBlueprint +{ // 0x568 bytes + // at 0x400 + int T2ClassSize; + int T3ClassSize; + int GenericClassSize; + int SClassSize; + // at 0x43C + string ArmorType; + // at 0x564 + float MaxBuildDistance; +}; + +struct CUIManager // : IUIManager +{ // 0x78 bytes + // at 0x30 + LuaState* state; // from [10A6478] +}; + +struct CAiReconDBImpl // : IAiReconDB +{ // 0xB0 bytes + void* vtable; + // at 0xA8 + bool FogOfWar; +}; + +struct CIntelGrid +{ // 0x24 bytes +}; + +struct IClientManager +{ + void* vtable; +}; + +struct CWldMap +{ + void* zero1; + void* zero2; + void* zero3; +}; + +struct Deposit +{ // 0x14 bytes + int X1,Z1,X2,Z2; // Rect + int Type; // 1 - Mass, 2 - Energy +}; + +struct CSimResources // : ISimResources // : IResources +{ // 0x1C bytes + void* vtable; + // at 0x8 in vtable + // ecx:CreateResourceDeposit(type, x, y, z, size) + // at 0x28 in vtable + // ecx:FindResourceDeposit(PtrPosXZ, PtrResultXZ, Radius, Type):Bool + + // at 0x10 + list Deposits; // +}; + +struct SWldSessionInfo +{ // 0x30 bytes + string map_name; + + // at 0x1C + void* LaunchInfoNew; + + // at 0x20 + int unknown2; + bool isBeingRecorded; + bool isReplay; + bool isMultiplayer; + char _pad1; + // at 0x2C + int ourCmdSource; + + IClientManager* clientManager; + int unknown4; // = 255 possibly cmdSourceIndex +}; + +struct SimArmyEconomyInfo +{ // 0x60 bytes + void* unknown1; + int unknown2; + float _incomeEnergy; // div 10 + float _incomeMass; // div 10 + + float baseIncomeEnergy; // div 10 + float baseIncomeMass; // div 10 + float storedEnergy; + float storedMass; + + float incomeEnergy; // div 10 + float incomeMass; // div 10 + float reclaimedEnergy; + float reclaimedMass; + + float requestedEnergy; // div 10 + float requestedMass; // div 10 + float expenseEnergy; // div 10 + float expenseMass; // div 10 + + uint maxEnergy; + int unknown3; + uint maxMass; + int unknown4; + + float unknown5; + uint isResourceSharing; + float unknown6; + float unknown7; +}; + +struct UserArmy +{ // 0x210 bytes + int armyIndex; + string name; + string nickname; + bool isCivilian; + // at 0x80 + float storedEnergy; + float storedMass; + + float incomeEnergy; // div 10 + float incomeMass; // div 10 + float reclaimedEnergy; + float reclaimedMass; + + float requestedEnergy; // div 10 + float requestedMass; // div 10 + float expenseEnergy; // div 10 + float expenseMass; // div 10 + + uint maxEnergy; + int unknown3; // =0 + uint maxMass; + int unknown4; // =0 + bool isResourceSharing; +#ifndef FORGED_ALLIANCE + char datas[0xba]; +#else + char datas[0xb2]; +#endif + // at 0x130 Moho | at 0x128 FA + moho_set mValidCommandSources; + // at 0x148 FA + uint color; + uint iconColor; + string mArmyType; // 'human' for players + // at 0x16C FA + int faction; + // at 0x188 FA + bool showScore; + // at 0x1B8 FA + bool outOfGame; +}; + +struct SimArmy // : IArmy +{ // 0x288 bytes +#ifdef FORGED_ALLIANCE + void* vtable; + // at 0xA4 in vtable + //void* GetUnitCap; + //void* SetUnitCap; + + void* unknown1; + int armyIndex; + string name; + string nickname; + + // at 0x44 + bool isCivilian; + // at 0x88 Copy from [[self+1F4]+18] + float storedEnergy; + float storedMass; + + float incomeEnergy; // div 10 + float incomeMass; // div 10 + float reclaimedEnergy; + float reclaimedMass; + + float requestedEnergy; // div 10 + float requestedMass; // div 10 + float expenseEnergy; // div 10 + float expenseMass; // div 10 + + uint maxEnergy; + int unknown3; // =0 + uint maxMass; + int unknown4; // =0 + bool isResourceSharing; + // at 0xC8 + moho_set neutrals; + moho_set allies; + moho_set enemies; + + char datas[0x4A]; + // at 0x130 FA + moho_set mValidCommandSources; + + // at 0x150 FA + uint color; + uint iconColor; + string mArmyType; // 'human' for players + // at 0x174 FA + int faction; + // at 0x1C0 FA + bool outOfGame; + // at 0x1C4 FA + Vector2f StartPosition; + // at 0x1D0 + float noRushRadius; + float noRushOffsetX; + float noRushOffsetY; + + // at 0x1E8 + void* Sim; + void* CAiBrain; + + // at 0x1F0 FA + void* CAiReconDBImpl; + SimArmyEconomyInfo* EconomyInfo; + // at 0x1F8 FA + string unknown5; + // at 0x270 + float unitCap; + // at 0x278 + int pathCap_Land; + int pathCap_Sea; + int pathCap_Both; +#else + // at 0x138 Moho + moho_set mValidCommandSources; +#endif +}; + +struct CArmyImpl // : SimArmy +{ +}; + +struct Entities +{ // 0x50 bytes +}; + +struct EntityChain // [[Entities+4]+4] +{ + void* Next; + //void* ?; + //void* ?; + int ID; + void* Entity; +}; + +struct Entity // : CScriptObject +{ // 0x270 bytes + // at 0x68 + uint EntityID; //For units x|xx|xxxxxx Type,Army,Num. Uses for UserSync + REntityBlueprint* Blueprint; + uint CreationIndex; //? +}; + +struct Projectile // : Entity +{ // 0x380 bytes + // at 0x6C + RProjectileBlueprint* Blueprint; +}; + +struct Prop // : Entity +{ // 0x288 bytes + // at 0x6C + RPropBlueprint* Blueprint; +}; + +struct Unit // : Entity +{ // 0x6A8 bytes + // at 0x50 + void* self1; + // at 0x70 + int UnitID; + RUnitBlueprint* Blueprint; + // at 0x98 + float CurHealth; + float MaxHealth; + // at 0xA4 + Vector4f Rot1; + Vector3f Pos1; + Vector4f Rot2; + Vector4f Pos2; + float FractionComplete; + // at 0x154 + SimArmy* Owner; + Vector4f Rot3; + Vector3f Pos3; + // at 0x17C + int TickCount1; // Readonly + void* CColPrimitiveBase; + // at 0x248 + Vector3f Pos4; + Vector3f Pos5; + // at 0x294 + float FuelRatio; + float ShieldRatio; // Readonly + // at 0x2AC + float WorkProgress; + // at 0x4B0 + void* MotionEngine; // +0xC FuelUseTime + // at 0x534 + void* WorkValues; //+0x8 + bool Flag; + // at 0x53C + float WorkRate; + // at 0x55C + void* IAiTransport; + // at 0x59C + Vector3f Pos6; + // at 0x668 + int TickCount2; // Readonly +}; + +struct UserEntity // : WeakObject +{ // 0x148 bytes + // at 0x44 + int EntityID; + RPropBlueprint* Blueprint; + // at 0x58 + RMeshBlueprint* Mesh; + // at 0x68 + float CurHealth; + float MaxHealth; + // at 0x74 + Vector4f Rot1; + Vector3f Pos1; + // at 0x90 + Vector4f Rot2; + Vector4f Pos2; + // at 0xD0 + //float x1,y1,x2,y2; + // at 0x120 + UserArmy* Owner; + Vector4f Rot3; + Vector4f Pos3; +}; + +struct UserUnit // : UserEntity +{ // 0x3E8 bytes + // at 0x44 + int UnitID; + RUnitBlueprint* Blueprint; + // at 0x1DC + string customUnitName; +}; + +struct Sim // : ICommandSink +{ // 0xAF8 bytes + void* vtable; + // at 0x50 + char dynamicHash[16]; + char hashTrash[0x50]; + char simHashes[16*128]; // at 0xB0-8B0 + // at 0x8C0 + void* CEffectManager; // 0x18 bytes + void* CSimSoundManager; // 0x720 bytes + RRuleGameRules* rules; // from CSimDriver.LaunchInfoNew + void* STIMap; // from CSimDriver.LaunchInfoNew + CSimResources* Deposits; + // at 0x8D8 + void* LuaStack; // 0x34 bytes + // at 0x8E6 + bool cheatsEnabled; + // at 0x8F8 + uint beatCounter1; + void* unknown1; // self+0x900 or null + uint beatCounter2; + // at 0x904 + void* unknown2; // 0x9CC bytes + void* unknown3; // 0x68 bytes + // at 0x91C Moho | at 0x90C FA + vector armies;// + // at 0x920 + list SSTICommandSources; + // at 0x93C Moho | at 0x92C FA + int ourCmdSource; // possibly just current in simulation. + // at 0x97C + void** unknown4; // 0x30 bytes + void* CAiFormationDB; // 0x40 bytes + // at 0x984 + void* Entities; + void* unknown5; // 0xCD0 bytes + // at 0x99C + void* unknown6; // 0xCF0 bytes + // at 0xA38 + void* unknown7; // 0xC bytes + // at 0xA88 + int focusArmyIndex; // focused army, -1 = observer +}; +struct CWldSession +{ // 0x508 bytes + CWldSession* self1; + CWldSession* self2; + + void* self_weird1; // = this + 0x8 + void* self_weird2; // = this + 0x8 + + // at 0x10 + LuaState* state; // sim? set from constructor argument + void* unknown1; // 0x14 bytes + RRuleGameRules* rules; + CWldMap* map; + void* LaunchInfoNew; + void* unknown2; // .?AV?$sp_counted_impl_p@ULaunchInfoNew@Moho@@@detail@boost@@ + string map_name; + Entities entities; + + char stuff[0x35c]; + + // at 0x3F0 + list armies; // + // at 0x3FC + void* unknown3; // 0xCC0 bytes + void* unknown4; // 0x64 bytes + // at 0x424 + CSimResources* Deposits; + // at 0x470 + vector cmdSources; // + + // at 0x480 + int ourCmdSource; + + bool isReplay; + bool isBeingRecorded; + bool isMultiplayer; + bool allowObservers; + + int focusArmyIndex; // focused army, -1 = observer + + bool32 isGameOver; + // at 0x4B4 + float mouseWorldPosX; + float mouseWorldPosY; + float mouseWorldPosZ; + // at 0x4CC + float mouseScreenPosX; + float mouseScreenPosY; + // at 0x4D4 + bool cheatsEnabled; // copied from LaunchInfoNew + 0x88 + // at 0x4E8 + bool displayEconomyOverlay; + bool relationsArmyColors; +}; + +struct CSimDriver // : ISTIDriver +{ // 0x230 bytes + void* vtable; + Sim* sim; + IClientManager* ClientManager; + // at 0x10 + void* LaunchInfoNew; // from g_SWldSessionInfo, only when loading game init + // at 0x1C + uint beatCounter1; + uint beatCounter2; // copied to address 0x1290710 + uint beatCounter3; + // at 0xb0 + int simFocusArmyIndex; + // at 0x228 + int maxSimRate; // from CalcMaxSimRate +}; + +struct CHeightField // : .?AVsp_counted_base@detail@boost@@ +{ // 0x10 bytes + void* vtable; +}; + +struct MapData +{ // 0x1C bytes + uint* TerrainHeights; // Word(TerrainHeights+(Y*SizeX+X)*2) + int SizeX; // +1 + int SizeY; // +1 +}; + +struct STIMap +{ // 0x1548 bytes + MapData* MapData; + CHeightField* HeightField; + // at 0x18 + //list Data; -> Data + // at 0x28 + char Data[0x1400]; + char* TerrainTypes; // TerrainTypes+(Y*SizeX+X) + int SizeX; + int SizeY; + // at 0x1534 + bool Water; + // at 0x1538 + float WaterLevel; +}; + +struct SSTICommandSource +{ // 0x24 bytes + int index; + string name; + int protocol; // -1 SinglePlayer, 3 MultiPlayer +}; + +struct CPushTask +{ + char datas[0x24]; +}; + +typedef CPushTask CPullTask; + +struct INetConnector +{ + void* vtable; +}; +struct CLobby +{ // 0xC8 bytes + + // at 0x20 + LuaObject unknown0; + + int unknown1; + int unknown2; + int unknown3; + int unknown4; + // at 0x44 + CPushTask pushTask; + + // at 0x60 + CPullTask pullTask; + + // at 0x84 + bool hosted_or_joined; // Has CLobby been used to host/join yet? + + // at 0x88 + void* not_host; // 0 if we're host + + // at 0x90 + string our_name; + // at 0xAC + int our_UID; + + // at 0xB0 + struct + { + INetConnector* first_element; + INetConnector* last_element; // It will probably always be our CNetXXXConnector + } peer_list; // Probably singly-linked list +}; + +/// Tres Importante +struct sub_10392B10_ret +{ // 0x20 bytes + + void* zero1; // self in CLobbyPeer.unknown2 + void* zero2; // self in CLobbyPeer.unknown2 + void* zero3; // self in CLobbyPeer.unknown2 + int unknown1; + + // at 0x10 + char one1; + char zero4; // 1 in CLobbyPeer.unknown2 +}; +struct CLobbyPeer +{ // 0x50 bytes + + CLobbyPeer* next; // Doubly linked list pointers + CLobbyPeer* prev; + + string playerName; + + // at 0x24 + int ownerID; // User UID + int constant1; + short constant2; + char _pad1[2]; + + // at 0x30 + int constant3; // enum? + float constant4; // = 0 + int constant5; + int unknown1; + + // at 0x40 + sub_10392B10_ret* unknown2; // made in sub_10394180 + int zero1; + int cmdSourceIndex; // == 255 => Unassigned + int playerNo; + + /* + constant1, constant2, constant3, constant5 + specially define the CLobbyUser + + constant3: + 1 - Host for a lobby we joined? + 3 - Peer who connected to us? + 6 - Game Peer of a Launched Game? + */ +}; + +struct CClientManagerImpl // : IClientManager +{ // 0x184D0 bytes + void* vtable; + + // at 0x40C + gpg_mutex mLock; + + // at 0x420 + list mClients; // + INetConnector* mConnector; + + // at 0x434 + bool mWeAreReady; + bool mEveryoneIsReady; + char _pad1[2]; + int mDispatchedBeat; + int mAvailableBeat; + int mFullyQueuedBeat; + int mPartiallyQueuedBeat; + int gameSpeedChangeCounter; // mGameSpeedClock + int mGameSpeedRequester; // always 0 + int gameSpeedRequested; // mGameSpeed + bool speedControlEnabled; + // at 0x458 + uint hEvent; // for KERNEL32.SetEvent + // at 0x18470 + PipeStream mPipe; + // at 0x184BC + bool unknown; // if value is 1 then KERNEL32.SetEvent is bypassed +}; + +struct CClientBase // : IClient +{ // 0xD8 bytes + void* vtable; + string mNickname; + // at 0x20 + int mIndex; // client index + int mUID; + IClientManager* clientManager; + + // at 0x30 + moho_set unknown1; + // at 0x50 + int mCommandSource; + bool mReady; + char _pad1[3]; + PipeStream mPipe; + + // at 0xA0 + int mQueuedBeat; + int mDispatchedBeat; + int mAvailableBeatRemote; + vector mLatestAckReceived; // + int mLatestBeatDispatchedRemote; + // at 0xC0 + bool mEjectPending; + bool mEjected; + char _pad2[2]; + vector mEjectRequests; // + int maxSimRate; // from CalcMaxSimRate +}; + +struct CLocalClient // : CClientBase +{ // 0xD8 bytes +}; // equal CClientBase + +struct CReplayClient // : CClientBase +{ // 0x160 bytes + // before 0xD8 it CClientBase + // at 0xD8 + FileStream* stream; + // at 0xE0 + void* ptr1; // self+0xF0 + void* ptr2; // self+0xF0 + void* ptr3; // self+0x130 + void* ptr4; // self+0xF0 + void* unknown1; + // at 0x130 + void* unknown2; + // at 0x138 + uint replayBeat; + char unknown3; + void* unknown4; + uint hSemaphore1; + uint hSemaphore2; + uint hMutex; + // at 0x15C + char unknown5; + char unknown6; +}; + +struct CNetUDPConnetor // : INetConnector +{ // 0x18090 bytes + void* vtable; + void* smth; // listen socket fd? + gpg_mutex mMutex; + // at 0x14 + SOCKET mSocket; + // at 0x24 + linked_list mConnections; // +}; +/** Game Types + Multiplayer - CLobby::LaunchGame + Replay - VCR_SetupReplaySession + SinglePlayer - WLD_SetupSessionInfo + Saved Game - CSavedGame::CreateSinglePlayerSession +*/ + +/** Session State + 0 - None? + 1 - Loading? + 2 - Started? + 3 - SIM Initialized + 4 - SIM Started + 5 - Game Started + 7 - Restart Requested + 8 - Session Halted +*/ diff --git a/section/include/typeDefs.h b/section/include/typeDefs.h new file mode 100644 index 00000000..13524c0c --- /dev/null +++ b/section/include/typeDefs.h @@ -0,0 +1,316 @@ +#pragma once +/* + This file contains definitions used by the Hex-Rays decompiler output. + It has type definitions and convenience macros to make the + output more readable. + Copyright (c) 2007 Hex-Rays +*/ + +#if defined(__GNUC__) +typedef long long ll; +typedef unsigned long long ull; +#define __int64 long long +#define __int32 int +#define __int16 short +#define __int8 char +#define MAKELL(num) num ## LL +#define FMT_64 "ll" +#elif defined(_MSC_VER) +typedef __int64 ll; +typedef unsigned __int64 ull; +#define MAKELL(num) num ## i64 +#define FMT_64 "I64" +#elif defined (__BORLANDC__) +typedef __int64 ll; +typedef unsigned __int64 ull; +#define MAKELL(num) num ## i64 +#define FMT_64 "L" +#else +#error "unknown compiler" +#endif +typedef unsigned int uint; +typedef unsigned char uchar; +typedef unsigned short ushort; +//typedef unsigned long ulong; + +typedef char int8; +typedef signed char sint8; +typedef unsigned char uint8; +typedef short int16; +typedef signed short sint16; +typedef unsigned short uint16; +typedef int int32; +typedef signed int sint32; +typedef unsigned int uint32; +typedef ll int64; +typedef ll sint64; +typedef ull uint64; + +// Partially defined types: +#define _BYTE uint8 +#define _WORD uint16 +#define _DWORD uint32 +#define _QWORD uint64 +#if !defined(_MSC_VER) +#define _LONGLONG __int128 +#endif + +#ifndef _WINDOWS_ +typedef int8 BYTE; +typedef int16 WORD; +typedef int32 DWORD; +typedef int32 LONG; +#endif +typedef int64 QWORD; +#ifndef __cplusplus +typedef int bool; // we want to use bool in our C programs +#endif + +// Some convenience macros to make partial accesses nicer +// first unsigned macros: +#define LOBYTE(x) (*((_BYTE*)&(x))) // low byte +#define LOWORD(x) (*((_WORD*)&(x))) // low word +#define LODWORD(x) (*((_DWORD*)&(x))) // low dword +#define HIBYTE(x) (*((_BYTE*)&(x)+1)) +#define HIWORD(x) (*((_WORD*)&(x)+1)) +#define HIDWORD(x) (*((_DWORD*)&(x)+1)) +#define BYTEn(x, n) (*((_BYTE*)&(x)+n)) +#define WORDn(x, n) (*((_WORD*)&(x)+n)) +#define BYTE1(x) BYTEn(x, 1) // byte 1 (counting from 0) +#define BYTE2(x) BYTEn(x, 2) +#define BYTE3(x) BYTEn(x, 3) +#define BYTE4(x) BYTEn(x, 4) +#define BYTE5(x) BYTEn(x, 5) +#define BYTE6(x) BYTEn(x, 6) +#define BYTE7(x) BYTEn(x, 7) +#define BYTE8(x) BYTEn(x, 8) +#define BYTE9(x) BYTEn(x, 9) +#define BYTE10(x) BYTEn(x, 10) +#define BYTE11(x) BYTEn(x, 11) +#define BYTE12(x) BYTEn(x, 12) +#define BYTE13(x) BYTEn(x, 13) +#define BYTE14(x) BYTEn(x, 14) +#define BYTE15(x) BYTEn(x, 15) +#define WORD1(x) WORDn(x, 1) +#define WORD2(x) WORDn(x, 2) // third word of the object, unsigned +#define WORD3(x) WORDn(x, 3) +#define WORD4(x) WORDn(x, 4) +#define WORD5(x) WORDn(x, 5) +#define WORD6(x) WORDn(x, 6) +#define WORD7(x) WORDn(x, 7) + +// now signed macros (the same but with sign extension) +#define SLOBYTE(x) (*((int8*)&(x))) +#define SLOWORD(x) (*((int16*)&(x))) +#define SLODWORD(x) (*((int32*)&(x))) +#define SHIBYTE(x) (*((int8*)&(x)+1)) +#define SHIWORD(x) (*((int16*)&(x)+1)) +#define SHIDWORD(x) (*((int32*)&(x)+1)) +#define SBYTEn(x, n) (*((int8*)&(x)+n)) +#define SWORDn(x, n) (*((int16*)&(x)+n)) +#define SBYTE1(x) SBYTEn(x, 1) +#define SBYTE2(x) SBYTEn(x, 2) +#define SBYTE3(x) SBYTEn(x, 3) +#define SBYTE4(x) SBYTEn(x, 4) +#define SBYTE5(x) SBYTEn(x, 5) +#define SBYTE6(x) SBYTEn(x, 6) +#define SBYTE7(x) SBYTEn(x, 7) +#define SBYTE8(x) SBYTEn(x, 8) +#define SBYTE9(x) SBYTEn(x, 9) +#define SBYTE10(x) SBYTEn(x, 10) +#define SBYTE11(x) SBYTEn(x, 11) +#define SBYTE12(x) SBYTEn(x, 12) +#define SBYTE13(x) SBYTEn(x, 13) +#define SBYTE14(x) SBYTEn(x, 14) +#define SBYTE15(x) SBYTEn(x, 15) +#define SWORD1(x) SWORDn(x, 1) +#define SWORD2(x) SWORDn(x, 2) +#define SWORD3(x) SWORDn(x, 3) +#define SWORD4(x) SWORDn(x, 4) +#define SWORD5(x) SWORDn(x, 5) +#define SWORD6(x) SWORDn(x, 6) +#define SWORD7(x) SWORDn(x, 7) + + +// Helper functions to represent some assembly instructions. + +#ifdef __cplusplus + +// Fill memory block with an integer value +inline void memset32(void *ptr, uint32 value, int count) +{ + uint32 *p = (uint32 *)ptr; + for ( int i=0; i < count; i++ ) + *p++ = value; +} + +// Generate a reference to pair of operands +template int16 __PAIR__( int8 high, T low) +{ + return ((( int16)high) << sizeof(high)*8) | uint8(low); +} +template int32 __PAIR__( int16 high, T low) +{ + return ((( int32)high) << sizeof(high)*8) | uint16(low); +} +template int64 __PAIR__( int32 high, T low) +{ + return ((( int64)high) << sizeof(high)*8) | uint32(low); +} +template uint16 __PAIR__(uint8 high, T low) +{ + return (((uint16)high) << sizeof(high)*8) | uint8(low); +} +template uint32 __PAIR__(uint16 high, T low) +{ + return (((uint32)high) << sizeof(high)*8) | uint16(low); +} +template uint64 __PAIR__(uint32 high, T low) +{ + return (((uint64)high) << sizeof(high)*8) | uint32(low); +} + +// rotate left +template T __ROL__(T value, uint count) +{ + const uint nbits = sizeof(T) * 8; + count %= nbits; + + T high = value >> (nbits - count); + value <<= count; + value |= high; + return value; +} + +// rotate right +template T __ROR__(T value, uint count) +{ + const uint nbits = sizeof(T) * 8; + count %= nbits; + + T low = value << (nbits - count); + value >>= count; + value |= low; + return value; +} + +// carry flag of left shift +template int8 __MKCSHL__(T value, uint count) +{ + const uint nbits = sizeof(T) * 8; + count %= nbits; + + return (value >> (nbits-count)) & 1; +} + +// carry flag of right shift +template int8 __MKCSHR__(T value, uint count) +{ + return (value >> (count-1)) & 1; +} + +// sign flag +template int8 __SETS__(T x) +{ + if ( sizeof(T) == 1 ) + return int8(x) < 0; + if ( sizeof(T) == 2 ) + return int16(x) < 0; + if ( sizeof(T) == 4 ) + return int32(x) < 0; + return int64(x) < 0; +} + +// overflow flag of subtraction (x-y) +template int8 __OFSUB__(T x, U y) +{ + if ( sizeof(T) < sizeof(U) ) + { + U x2 = x; + int8 sx = __SETS__(x2); + return (sx ^ __SETS__(y)) & (sx ^ __SETS__(x2-y)); + } + else + { + T y2 = y; + int8 sx = __SETS__(x); + return (sx ^ __SETS__(y2)) & (sx ^ __SETS__(x-y2)); + } +} + +// overflow flag of addition (x+y) +template int8 __OFADD__(T x, U y) +{ + if ( sizeof(T) < sizeof(U) ) + { + U x2 = x; + int8 sx = __SETS__(x2); + return ((1 ^ sx) ^ __SETS__(y)) & (sx ^ __SETS__(x2+y)); + } + else + { + T y2 = y; + int8 sx = __SETS__(x); + return ((1 ^ sx) ^ __SETS__(y2)) & (sx ^ __SETS__(x+y2)); + } +} + +// carry flag of subtraction (x-y) +template int8 __CFSUB__(T x, U y) +{ + int size = sizeof(T) > sizeof(U) ? sizeof(T) : sizeof(U); + if ( size == 1 ) + return uint8(x) < uint8(y); + if ( size == 2 ) + return uint16(x) < uint16(y); + if ( size == 4 ) + return uint32(x) < uint32(y); + return uint64(x) < uint64(y); +} + +// carry flag of addition (x+y) +template int8 __CFADD__(T x, U y) +{ + int size = sizeof(T) > sizeof(U) ? sizeof(T) : sizeof(U); + if ( size == 1 ) + return uint8(x) > uint8(x+y); + if ( size == 2 ) + return uint16(x) > uint16(x+y); + if ( size == 4 ) + return uint32(x) > uint32(x+y); + return uint64(x) > uint64(x+y); +} + +#else +// The following definition is not quite correct because it always returns +// uint64. The above C++ functions are good, though. +#define __PAIR__(high, low) (((uint64)(high)<>y) +#define __CFADD__(x, y) invalid_operation // Generate carry flag for (x+y) +#define __CFSUB__(x, y) invalid_operation // Generate carry flag for (x-y) +#define __OFADD__(x, y) invalid_operation // Generate overflow flag for (x+y) +#define __OFSUB__(x, y) invalid_operation // Generate overflow flag for (x-y) +#endif + +// No definition for rcl/rcr because the carry flag is unknown +#define __RCL__(x, y) invalid_operation // Rotate left thru carry +#define __RCR__(x, y) invalid_operation // Rotate right thru carry +#define __MKCRCL__(x, y) invalid_operation // Generate carry flag for a RCL +#define __MKCRCR__(x, y) invalid_operation // Generate carry flag for a RCR +#define __SETP__(x, y) invalid_operation // Generate parity flag for (x-y) + +// In the decompilation listing there are some objects declarared as _UNKNOWN +// because we could not determine their types. Since the C compiler does not +// accept void item declarations, we replace them by anything of our choice, +// for example a char: + +#define _UNKNOWN char + +#ifdef _MSC_VER +#define snprintf _snprintf +#define vsnprintf _vsnprintf +#endif diff --git a/section/luaSimGetStat.cpp b/section/luaSimGetStat.cpp new file mode 100644 index 00000000..3dd633da --- /dev/null +++ b/section/luaSimGetStat.cpp @@ -0,0 +1,103 @@ + +char SalemWaterOnlyBp[1536]; +char SalemDefaultBp[4]; + +// This patch allows to turn off Salem's amphibious ability to exclude accidental land moves +// We take default Salem's blueprint and copy it to `SalemWaterOnlyBp` +// Then change 2 values in it: MinWaterDepth = 1.5 and OccupancyCaps = 8 +// Only these 2 do matter in movement calculations, other bp values stay the same +// Then we just change a pointer to blueprint in unit object depending on what mode should be activated +// Amphibious mode ON: SalemDefaultBp, amphibious mode OFF: SalemWaterOnlyBp. + +void luaSimGetStat() +{ + asm + ( + "cmp byte ptr [eax], 0x68;" + "jne EXIT;" + "cmp byte ptr [eax+0x1], 0x31;" + "jne EXIT;" + "push eax;" + "push ebx;" + "mov eax, %[SalemDefaultBp];" + "cmp eax, 0x0;" + "je UpdateBlueprints;" + "cmp byte ptr [eax + 0xDA], 0x9;" // Check if SalemDefaultBp pointer is still valid (OccupancyCaps = 9 means it is) + "mov eax, %[SalemWaterOnlyBp];" // and if not then update both blueprints (prevents crashes on simulation restart) + "je dummyExists;" + "UpdateBlueprints:;" + "mov eax, %[SalemWaterOnlyBp];" + "push ebx;" + "push ecx;" + "push edx;" + "mov ebx, dword ptr [ebx+0x74];" + "mov %[SalemDefaultBp], ebx;" + "mov eax, ebx;" + "mov ebx, %[SalemWaterOnlyBp];" + "mov edx, dword ptr [eax];" + "mov [ebx], edx;" + "mov ecx, 0x4;" + "MemCpyCycle:;" + "add ebx, 4;" + "mov edx, dword ptr [eax+ecx];" + "mov [ebx], edx;" + "add ecx, 4;" + "cmp ecx, 1532;" + "jbe MemCpyCycle;" + "mov dword ptr [ebx - 0x51C], 0x3fc00000;" //MinWaterDepth = 1.5 + "mov dword ptr [ebx - 0x522], 0x8;" //OccupancyCaps = 8 + "pop edx;" + "pop ecx;" + "pop ebx;" + "dummyExists:;" + "cmp dword ptr [esp+0x20], 0x0;" + "jne SetAmphON;" + "mov eax, dword ptr [ebx+0x74];" + "cmp byte ptr [eax + 0xDA], 0x8;" + "je POPEXIT;" + "mov eax, %[SalemWaterOnlyBp];" + "mov dword ptr [ebx+0x74], eax;" + "jmp POPEXIT;" + "SetAmphON:;" + "mov eax, dword ptr [ebx+0x74];" + "cmp byte ptr [eax + 0xDA], 0x9;" + "je POPEXIT;" + "mov eax, %[SalemDefaultBp];" + "mov dword ptr [ebx+0x74], eax;" + "POPEXIT:;" + "pop ebx;" + "pop eax;" + "EXIT:;" + "mov esi, eax;" + "add esp,0x8;" + "test esi, esi;" + "jmp 0x006CC760;" + : + : [SalemWaterOnlyBp] "i" (SalemWaterOnlyBp), [SalemDefaultBp] "m" (SalemDefaultBp) + : + ); +} + +/* Lua sim function: unit:GetStat(char statName, int defValue) +unit:GetStat("h1_SetSalemAmph", 1) + +if (statName.at(0) == "h") { + if (statName.at(1) == "1") { + + if !SalemWaterOnlyBp { + SalemWaterOnlyBp = defaultBP //handmade memcpy here :) + SalemWaterOnlyBp.Footprint.MinWaterDepth = 1.5 //default 0 + SalemWaterOnlyBp.Footprint.OccupancyCaps = 8 //default 9 Only these 2 parameters do matter + } + + if (defValue == 0){ //turn off amphibious + if (unit.Blueprint.Footprint.OccupancyCaps != 8) { + unit.Blueprint = SalemWaterOnlyBp + } + } else { //turn on + if (unit.Blueprint.Footprint.OccupancyCaps != 9) { + unit.Blueprint = SalemDefaultBp + } + } + } +} */ \ No newline at end of file diff --git a/section/moho_decode.cpp b/section/moho_decode.cpp new file mode 100644 index 00000000..ebebf433 --- /dev/null +++ b/section/moho_decode.cpp @@ -0,0 +1,1010 @@ +#include "include/funcDefs.h" +#include "include/global_func_table.h" + +const char* safe_quit = "safeQuit"; +_DWORD tick_num = 0; +static bool update_pl_count = true; +_DWORD terminated = 0; +_DWORD num_clients = 0; +_DWORD current_num_clients = 0; +bool paused = false; + +int strCmp(const char* s1, const char* s2) +{ + while(*s1 && (*s1 == *s2)) + { + s1++; + s2++; + } + return *(const unsigned char*)s1 - *(const unsigned char*)s2; +} + +void Conexecute() +{ + register int eax asm("eax"); + asm + ( + "push ebp;" + "mov ebp,esp;" + "and esp,0xFFFFFFF8;" + "sub esp,0x8;" + "push esi;" + "mov esi,eax;" + "mov eax,dword ptr [esi];" + "push edi;" + "mov edi,dword ptr [0x10A7704];" + "push eax;" + "call 0x90C590;" + "add esp,0x4;" + "cmp eax,0x1;" + "je L0xABEL_0x0041CC15;" + "push eax;" + "push 0x1;" + "push edi;" + "push 0xE0A220;" + "push esi;" + "call 0x90C1D0;" + "add esp,0x14;" + "L0xABEL_0x0041CC15:;" + "mov dword ptr [esp+0x8],esi;" + "mov dword ptr [esp+0xC],0x1;" + "mov ecx,dword ptr [esi];" + "push 0x1;" + "push ecx;" + "call 0x90CA90;" + "mov esi,eax;" + ); + + if(strCmp(eax, safe_quit) == 0) + { + asm + ( + "mov dword ptr [0x011FD24F], 0x1;" + "add esp,0x8;" + "pop edi;" + "xor eax,eax;" + "pop esi;" + "mov esp,ebp;" + "pop ebp;" + ); + return; + } + + asm + ( + + "add esp,0x8;" + "test esi,esi;" + "jne L0xABEL_0x0041CC42;" + "push 0xE00AD0;" + "lea ecx,dword ptr [esp+0xC];" + "call 0x4154B0;" + "L0xABEL_0x0041CC42:;" + "push esi;" + "call 0x41CC90;" + "add esp,0x4;" + "pop edi;" + "xor eax,eax;" + "pop esi;" + "mov esp,ebp;" + "pop ebp;" + ); + return; +} + +__attribute__((noinline)) void timed_out() +{ + ((int (*)(const char* fmt, ...))_Logf)("SafeQuit sync timed out.\n"); + return; +} + +__attribute__((noinline)) void p_Version() +{ + ((int (*)(const char* fmt, ...))_Logf)("Exe Version: 1.0\n"); + return; +} + +__attribute__((noinline)) void xor_sync() +{ + register int eax asm("eax"); + asm("xor eax,eax;"); + for(int i = 0; i<16; i++) + { + sync_buffer[i] = eax; + } + return; +} + +void SessionEndGame() +{ + register int eax asm("eax"); + asm + ( + "Sleep = 0x00C0F574;" + "GetCurrentThread = 0x00C0F588;" + "SuspendThread = 0x00C0F4F8;" + "WaitForSingleObject = 0x00C0F524;" + ); + + if(current_num_clients > 1 && current_num_clients < 17 && !game_ended) + { + asm + ( + "mov dword ptr [0x011FD243], 0x1;" // send network var + "push 0x2500;" + "push dword ptr [0x11FD253];" + "call dword ptr [WaitForSingleObject];" + ); + + if(eax == 0x00000102) + { + asm volatile + ( + "call %[func];" + : + : [func] "i" (&timed_out) + : "memory" + ); + } + +/* asm + ( + "push 100;" + "call dword ptr [Sleep];" + ); */ + } + asm + ( + //"push 30000;" + //"call dword ptr [Sleep];" + "mov dword ptr [0x011FD243], 0xC;" //reset send trigger + "mov eax,dword ptr [edi];" + "push esi;" + "mov esi,dword ptr [0x10C5234];" + "push eax;" + "call 0x90C590;" + "add esp,0x4;" + "test eax,eax;" + "je L0xABEL_0x008984D8;" + "push eax;" + "push 0x0;" + "push esi;" + "push 0xE0A220;" + "push edi;" + "call 0x90C1D0;" + "add esp,0x14;" + "L0xABEL_0x008984D8:;" + "mov eax,dword ptr [0x10C4F50];" + "test eax,eax;" + "mov esi,eax;" + "jne L0xABEL_0x008984F1;" + "push 0xE4AFCC;" + "push edi;" + "call 0x90C1D0;" + "add esp,0x8;" + "L0xABEL_0x008984F1:;" + "mov edx,dword ptr [esi];" + "mov eax,dword ptr [edx+0x4];" + "mov ecx,esi;" + "call eax;" + ); + + asm volatile + ( + "call %[func];" + : + : [func] "i" (&xor_sync) + : "memory" + ); + + asm + ( + "mov dword ptr [0x011FD23F], 0xB;" //RESET BLOCK VARIABLE + //"mov dword ptr [0x011FD243], 0xC;" //reset send trigger + "xor eax,eax;" + "pop esi;" + "ret;" + ); +} + +__attribute__((noinline)) void err_print() +{ + ((int (*)(const char* fmt, ...))_Logf)("Block is too late !\n"); + return; +} + +__attribute__((noinline)) void term() +{ + ((int (*)(const char* fmt, ...))_Logf)("terminated\n"); + return; +} + +void Moho__CDecoder__DecodeMessage() +{ + register int eax asm("eax"); + asm + ( + "push ebp;" + "mov ebp,esp;" + "and esp,0xFFFFFFF8;" + "push 0xFFFFFFFF;" + "push 0xBA8D10;" + //"mov eax,dword ptr [0x0];" + "push eax;" + //"mov dword ptr [0x0],esp;" + "sub esp,0x70;" + "push esi;" + "mov esi,ecx;" + "lea ecx,dword ptr [esp+0x28];" + "call 0x956DB0;" + "mov ecx,dword ptr [edi];" + "xor edx,edx;" + "mov dword ptr [esp+0x28],0xE03BEC;" + "mov dword ptr [esp+0x44],edi;" + "mov dh,byte ptr [ecx+0x2];" + "mov eax,dword ptr [edi];" + "add eax,0x3;" + "mov dl,byte ptr [ecx+0x1];" // <- test for size of the message + "cmp edx,0x3;" + "jae L0xABEL_0x006E419E;" + "xor edx,edx;" + "jmp L0xABEL_0x006E41A1;" + "L0xABEL_0x006E419E:;" + "add edx,0xFFFFFFFD;" + "L0xABEL_0x006E41A1:;" + "add edx,eax;" + "mov dword ptr [esp+0x30],eax;" + "mov dword ptr [esp+0x2C],eax;" + "mov dword ptr [esp+0x34],edx;" + "mov dword ptr [esp+0x7C],0x0;" + "mov cl,byte ptr [ecx];" + "lea eax,dword ptr [esp+0x28];" + "mov dword ptr [esp+0x8],eax;" + "movzx eax,cl;" + +/* "cmp dword ptr [0x011FD23F], 0x1;" + "jne skip;" + "mov byte ptr [0x10A6380],0x0;" + "inc dword ptr [0x011FD23F+0xC];" + "cmp dword ptr [0x011FD23F+0xC], 0x4;" + "jl skip;" + "mov dword ptr [0x011FD23F+0xC], 0x0;" + "mov dword ptr [0x011FD23F], 0x0;" + "skip:;" */ + ); + + switch (eax) + { + case 0: //decode_advance -> On_Beat() + asm + ( + "lea ecx,dword ptr [esp+0x8];" + "push ecx;" + "call 0x6E4400;" + ); + break; + case 1: //decode_set_command_source + asm + ( + "push esi;" + "lea eax,dword ptr [esp+0xC];" + "call 0x6E4440;" + ); + break; + case 2: // command source terminated + + //This acts both, like a boolean and a 32bit integer + //this is what i like about C the most, there is no limitation of what you can do with + //the data type, i bet you to try this in Java and see what kind of shit code you'll have to write + //tag_sent = 0; + asm + ( + "cmp dword ptr [0x011FD23F], 0x1;" + "jne late;" + ); + terminated = tick_num; + asm("jmp next;"); + asm("late:;"); + asm volatile + ( + "call %[func];" + : + : [func] "i" (&err_print) + : "memory" + ); + + asm + ( + "next:;" + "mov ecx,dword ptr [esi+0xC];" + "mov edx,dword ptr [ecx];" + "mov eax,dword ptr [edx+0x4];" + "call eax;" + ); + asm volatile + ( + "call %[func];" + : + : [func] "i" (&term) + : "memory" + ); + current_num_clients--; + break; + case 3: //verify checksum + asm + ( + "push esi;" + "lea esi,dword ptr [esp+0xC];" + "call 0x6E4480;" + ); + break; + case 4: //sim request pause + paused = true; + asm + ( + "pause:;" + "mov ecx,dword ptr [esi+0xC];" //3 + "mov edx,dword ptr [ecx];" + "mov eax,dword ptr [edx+0xC];" + "call eax;" + ); + break; + case 5: // sim resume + paused = false; + asm + ( + "mov ecx,dword ptr [esi+0xC];" //4 + "mov edx,dword ptr [ecx];" + "mov eax,dword ptr [edx+0x10];" + "call eax;" + ); + break; + case 6: + asm + ( + "mov ecx,dword ptr [esi+0xC];" + "mov edx,dword ptr [ecx];" + "mov eax,dword ptr [edx+0x14];" + "call eax;" + ); + break; + case 7: + asm + ( + "push esi;" + "lea ecx,dword ptr [esp+0xC];" + "call 0x6E44F0;" + ); + break; + case 8: + asm + ( + "push esi;" + "lea ecx,dword ptr [esp+0xC];" //7 + "call 0x6E45D0;" + ); + break; + case 9: + asm + ( + "push esi;" + "lea eax,dword ptr [esp+0xC];" + "call 0x6E4670;" + ); + break; + case 0xA: + asm + ( + "push esi;" + "lea esi,dword ptr [esp+0xC];" //9 + "call 0x6E46A0;" + ); + break; + case 0xB: + asm + ( + "push esi;" + "lea ecx,dword ptr [esp+0xC];" //10 + "call 0x6E46E0;" + ); + break; + case 0xC: + asm + ( + "push esi;" + "lea esi,dword ptr [esp+0xC];" //11 + "call 0x6E47D0;" + ); + break; + case 0xD: + asm + ( + "push esi;" + "lea esi,dword ptr [esp+0xC];" //12 + "call 0x6E48E0;" + ); + break; + case 0xE: + asm + ( + "push esi;" + "lea esi,dword ptr [esp+0xC];" //13 + "call 0x6E49F0;" + ); + break; + case 0xF: + asm + ( + "push esi;" + "lea esi,dword ptr [esp+0xC];" //14 + "call 0x6E4A30;" + ); + break; + case 0x10: + asm + ( + "push esi;" + "lea eax,dword ptr [esp+0xC];" //15 + "call 0x6E4A70;" + ); + break; + case 0x11: + asm + ( + "push esi;" + "lea esi,dword ptr [esp+0xC];" //16 + "call 0x6E4AC0;" + ); + break; + case 0x12: + asm + ( + "push esi;" + "lea esi,dword ptr [esp+0xC];" //17 + "call 0x6E4B00;" + ); + break; + case 0x13: + asm + ( + "push esi;" + "lea esi,dword ptr [esp+0xC];" //18 + "call 0x6E4BB0;" + ); + break; + case 0x14: + asm + ( + "push esi;" + "lea ecx,dword ptr [esp+0xC];" //19 + "call 0x6E4D80;" + ); + break; + case 0x15: + asm + ( + "lea ecx,dword ptr [esp+0x8];" //20 + "call 0x6E4BF0;" + ); + break; + case 0x16: + asm + ( + "lea ecx,dword ptr [esp+0x8];" //21 + "call 0x6E4CA0;" + ); + break; + case 0x17: + asm + ( + "call 0x6E4E70;" //22 + ); + break; + default: + asm + ( + "movzx ecx,cl;" + "push ecx;" + "lea edx,dword ptr [esp+0x10];" + "push 0xE2E568;" + "push edx;" + "call 0x938F10;" + "add esp,0xC;" + "push eax;" + "lea ecx,dword ptr [esp+0x4C];" + "mov byte ptr [esp+0x80],0x1;" + "call 0x405130;" + "push 0xEC2624;" + "lea eax,dword ptr [esp+0x4C];" + "push eax;" + "mov dword ptr [esp+0x50],0xE2E73C;" + "call 0xA89950;" + "int3;" + ); + return; + } + asm + ( + "lea ecx,dword ptr [esp+0x28];" + "mov dword ptr [esp+0x7C],0xFFFFFFFF;" + "call 0x956DD0;" + "mov ecx,dword ptr [esp+0x74];" + "pop esi;" + "mov esp,ebp;" + "pop ebp;" + "ret;" + ); +} + +void sim_dispatch() +{ + register int eax asm("eax"); + asm + ( + "Sleep = 0x00C0F574;" + "ResetEvent = 0x00C0F4CC;" + "push ebp;" + "mov ebp,esp;" + "and esp,0xFFFFFFF8;" + "push 0xFFFFFFFF;" + "push 0xBB49E0;" + //"mov eax,dword ptr [0x0];" + "push eax;" + //"mov dword ptr [0x0],esp;" + "sub esp,0x4C;" + "push ebx;" + "mov ebx,ecx;" + "push esi;" + "lea ecx,dword ptr [esp+0x10];" + "call 0x9556D0;" + "mov eax,dword ptr [edi+0x20];" + "mov dword ptr [esp+0x8],eax;" + + "add eax,0x1;" // counts sim ticks + ); + + tick_num = eax; + if(terminated && eax >= (terminated + 10)) //wait 10 more sim ticks + { + asm + ( + "mov dword ptr [0x011FD23F], 0xB;" //RESET BLOCK VARIABLE + "mov dword ptr [0x011FD243], 0xC;" //reset send trigger + "mov byte ptr [0x011FD24F], 0x0;" //reset safeQuit + ); + tag_sent = 0; + terminated = 0; + p_index = 0; + sender_sock = 1; + } + + static bool overflow = false; + if(eax <= 10) + { + asm + ( + "mov dword ptr [0x011FD23F], 0xB;" //RESET BLOCK VARIABLE + "mov dword ptr [0x011FD243], 0xC;" //reset send trigger + "mov byte ptr [0x011FD24F], 0x0;" //reset safeQuit + ); + tag_sent = 0; + terminated = 0; + p_index = 0; + sender_sock = 1; + game_ended = false; + if(!overflow) + { + update_pl_count = true; + } + } + else + { + overflow = false; + } + + if(eax == 0xFFFFFFFF) + { + overflow = true; + } + + asm + ( + "mov dword ptr [edi+0x20],eax;" + "cmp byte ptr [ebx+0x4],0x0;" + "jne L0xABEL_0x0073D916;" + "lea ecx,dword ptr [esp+0x18];" + "call 0xAC1E60;" + "push 0xEC2180;" + "lea eax,dword ptr [esp+0x1C];" + "push eax;" + "call 0xA89950;" + "L0xABEL_0x0073D916:;" + "mov ecx,dword ptr [ebx];" + "call 0xAC1AD0;" + "mov eax,0xE3333C;" + "lea esi,dword ptr [esp+0x38];" + "mov byte ptr [ebx+0x4],0x0;" + "call 0x4E6DF0;" + "mov dword ptr [esp+0x5C],0x0;" + "cmp dword ptr [0x10C7694],0x0;" + "jne L0xABEL_0x0073D962;" + "call 0x408940;" + "push 0xE00B5C;" + "mov ecx,eax;" + "call 0x417B60;" + "mov esi,0x1;" + "mov edx,eax;" + "mov dword ptr [0x10C7694],eax;" + "call 0x4151E0;" + "L0xABEL_0x0073D962:;" + "mov ecx,dword ptr [0x10C7694];" + "mov dword ptr [esp+0x18],ecx;" + "lea ecx,dword ptr [esp+0x20];" + "call 0x9556D0;" + "mov eax,dword ptr [esp+0x8];" + "mov byte ptr [esp+0x5C],0x1;" + "mov ecx,dword ptr [edi+0x8];" + "mov edx,dword ptr [ecx];" + "mov edx,dword ptr [edx+0x58];" + "push eax;" + "call edx;" + "mov eax,dword ptr [0x10A63E8];" + "test eax,eax;" + "je L0xABEL_0x0073D999;" + "push eax;" + "call dword ptr [Sleep];" + "L0xABEL_0x0073D999:;" + "lea ecx,dword ptr [esp+0x20];" + "mov byte ptr [esp+0x5C],0x0;" + "call 0x955700;" + "push edx;" + "push eax;" + "call 0x955520;" + "mov ecx,dword ptr [esp+0x20];" + "add esp,0x8;" + "mov dword ptr [esp+0xC],edx;" + "add ecx,0x24;" + "lock xadd dword ptr [ecx],eax;" + "lea esi,dword ptr [esp+0x38];" + "mov dword ptr [esp+0x5C],0xFFFFFFFF;" + "call 0x4E6E90;" + "cmp byte ptr [ebx+0x4],0x0;" + "je L0xABEL_0x0073D9EF;" + "lea ecx,dword ptr [esp+0x28];" + "call 0xAC1E60;" + "push 0xEC2180;" + "lea edx,dword ptr [esp+0x2C];" + "push edx;" + "call 0xA89950;" + "L0xABEL_0x0073D9EF:;" + "mov ecx,dword ptr [ebx];" + "call 0xAC1AB0;" + "mov byte ptr [ebx+0x4],0x1;" + "mov ecx,ebx;" + "mov ebx,edi;" + "call 0x73DAD0;" + "cmp byte ptr [edi+0x68],0x0;" + "jne L0xABEL_0x0073DAB7;" + "lea ecx,dword ptr [esp+0x10];" + "call 0x955700;" + "push edx;" + "push eax;" + "call 0x9554E0;" + "fstp dword ptr [esp+0x10];" + "mov eax,dword ptr [edi+0x224];" + "lea ecx,dword ptr [edi+0x1B8];" + "add eax,0x1;" + "cdq;" + "mov ebx,0x19;" + "idiv ebx;" + "mov esi,dword ptr [ecx+0x68];" + "add esp,0x8;" + "cmp edx,esi;" + "jne L0xABEL_0x0073DA4D;" + "lea eax,dword ptr [esi+0x1];" + "cdq;" + "mov esi,ebx;" + "idiv esi;" + "mov dword ptr [ecx+0x68],edx;" + "L0xABEL_0x0073DA4D:;" + "mov eax,dword ptr [ecx+0x6C];" + "lea eax,dword ptr [ecx+eax*0x4];" + "test eax,eax;" + "je L0xABEL_0x0073DA61;" + "movss xmm0,dword ptr [esp+0x8];" + "movss dword ptr [eax],xmm0;" + "L0xABEL_0x0073DA61:;" + "mov eax,dword ptr [ecx+0x6C];" + "add eax,0x1;" + "cdq;" + "mov esi,ebx;" + "idiv esi;" + "mov dword ptr [ecx+0x6C],edx;" + "call 0x48BF00;" + "movss xmm1,dword ptr [0xE4F814];" + "divss xmm1,xmm0;" + "mulss xmm1,dword ptr [0xE4F714];" + "movss dword ptr [esp+0x8],xmm1;" + "fld dword ptr [esp+0x8];" + "push ecx;" + "fstp dword ptr [esp];" + "call 0x55AE10;" + "add esp,0x4;" + "cmp eax,dword ptr [edi+0x228];" + "je L0xABEL_0x0073DAB7;" + "mov ecx,dword ptr [edi+0x8];" + "mov dword ptr [edi+0x228],eax;" + "mov edx,dword ptr [ecx];" + "push eax;" + "mov eax,dword ptr [edx+0x40];" + "call eax;" + "L0xABEL_0x0073DAB7:;" + "mov ecx,dword ptr [esp+0x54];" + "pop esi;" + //"mov dword ptr [0x0],ecx;" + "pop ebx;" + "mov esp,ebp;" + "pop ebp;" + // "ret;" + ); + return; +} + +void Update_Pipeline_Stream() +{ + register int eax asm("eax"); + asm + ( + "push ebp;" + "mov ebp,esp;" + "and esp,0xFFFFFFF8;" + "push 0xFFFFFFFF;" + "push 0xBAA10B;" + // "mov eax,dword ptr [0x0];" + "push eax;" + // "mov dword ptr [0x0],esp;" + "sub esp,0x88;" + "push ebx;" + "push esi;" + "push edi;" + "mov edi,ecx;" + "lea ecx,dword ptr [edi+0x40C];" + "mov dword ptr [esp+0x18],ecx;" + "call 0xAC51B0;" + "mov byte ptr [esp+0x1C],0x1;" + "xor esi,esi;" + "mov dword ptr [esp+0x9C],esi;" + "mov eax,dword ptr [edi+0x420];" + "cmp eax,esi;" + "je L0xABEL_0x0053F098;" + "mov ebx,dword ptr [edi+0x424];" + "sub ebx,eax;" + "sar ebx,0x2;" + "je L0xABEL_0x0053F098;" + "lea ebx,dword ptr [ebx];" + "L0xABEL_0x0053F070:;" + "mov ecx,dword ptr [edi+0x420];" + "mov edx,dword ptr [ecx+esi*0x4];" + "lea eax,dword ptr [edi+0x18470];" + "push eax;" + "lea eax,dword ptr [edi+0x184B8];" + "push eax;" + "mov eax,dword ptr [ebp+0x8];" + "push eax;" + "push edx;" + "call 0x53C550;" + "add esi,0x1;" + "cmp esi,ebx;" + "jb L0xABEL_0x0053F070;" + "L0xABEL_0x0053F098:;" + "mov eax,ebx;" + ); + num_clients = eax; + if(update_pl_count) + { + asm volatile + ( + "call %[func];" + : + : [func] "i" (&p_Version) + : "memory" + ); + current_num_clients = num_clients; + update_pl_count = false; + } + asm + ( + "push 0x33;" + "lea eax,dword ptr [esp+0x44];" + "push eax;" + "xor edx,edx;" + "call 0x483490;" + "lea ecx,dword ptr [esp+0x20];" + "mov byte ptr [esp+0x9C],0x1;" + "call 0x956DB0;" + "lea ecx,dword ptr [esp+0x40];" + "mov dword ptr [esp+0x3C],ecx;" + "mov ecx,dword ptr [esp+0x40];" + "xor edx,edx;" + "mov dword ptr [esp+0x20],0xE03BEC;" + "mov dh,byte ptr [ecx+0x2];" + "lea eax,dword ptr [ecx+0x3];" + "mov dl,byte ptr [ecx+0x1];" + "mov ecx,edx;" + "cmp ecx,0x3;" + "jae L0xABEL_0x0053F0E1;" + "xor ecx,ecx;" + "jmp L0xABEL_0x0053F0E4;" + "L0xABEL_0x0053F0E1:;" + "add ecx,0xFFFFFFFD;" + "L0xABEL_0x0053F0E4:;" + "add ecx,eax;" + "mov dword ptr [esp+0x28],eax;" + "mov dword ptr [esp+0x24],eax;" + "mov dword ptr [esp+0x2C],ecx;" + "mov dword ptr [esp+0x34],eax;" + "mov dword ptr [esp+0x30],eax;" + "mov dword ptr [esp+0x38],ecx;" + "sub ecx,eax;" + "cmp ecx,0x4;" + "mov byte ptr [esp+0x9C],0x2;" + "jb L0xABEL_0x0053F119;" + "mov ecx,dword ptr [ebp+0x8];" + "mov dword ptr [eax],ecx;" + "add dword ptr [esp+0x34],0x4;" + "jmp L0xABEL_0x0053F129;" + "L0xABEL_0x0053F119:;" + "push 0x4;" + "lea edx,dword ptr [ebp+0x8];" + "push edx;" + "lea ecx,dword ptr [esp+0x28];" + "call dword ptr [0xE03C08];" + "L0xABEL_0x0053F129:;" + "mov eax,dword ptr [edi];" + "mov edx,dword ptr [eax+0x44];" + "lea ecx,dword ptr [esp+0x40];" + "push ecx;" + "mov ecx,edi;" + "call edx;" + "mov ecx,dword ptr [esp+0x18];" + "add dword ptr [edi+0x438],0x1;" + "call 0xAC5200;" + "mov eax,dword ptr [edi+0x18470];" + "mov edx,dword ptr [eax+0x20];" + "lea esi,dword ptr [edi+0x18470];" + "mov ecx,esi;" + "mov byte ptr [esp+0x1C],0x0;" + "call edx;" + "mov ecx,esi;" + "call 0x9566C0;" + "test eax,eax;" + + "je L0xABEL_0x0053F1A0;" + "lea ebx,dword ptr [edi+0x4];" + "lea ecx,dword ptr [ecx];" + + "L0xABEL_0x0053F170:;" + ); + asm + ( + "push esi;" + "lea eax,dword ptr [esp+0x44];" + "call 0x47BD40;" + "mov eax,dword ptr [esp+0x40];" + "movzx ecx,byte ptr [eax];" + "mov ecx,dword ptr [ebx+ecx*0x4+0x8];" + "test ecx,ecx;" + "je L0xABEL_0x0053F195;" + "mov edx,dword ptr [ecx];" + "mov edx,dword ptr [edx];" + "push ebx;" + "lea eax,dword ptr [esp+0x44];" + "push eax;" + "call edx;" + "L0xABEL_0x0053F195:;" + "mov ecx,esi;" + "call 0x9566C0;" + "test eax,eax;" + + "jne L0xABEL_0x0053F170;" + "L0xABEL_0x0053F1A0:;" + ); + + asm + ( + "lea eax,dword ptr [esp+0x13];" + "push eax;" + "mov eax,0x3;" + "lea esi,dword ptr [esp+0x44];" + "mov byte ptr [esp+0x17],0x0;" + "call 0x47C680;" + "mov ecx,dword ptr [esp+0x40];" + "mov byte ptr [ecx+0x1],0x3;" + "mov edx,dword ptr [esp+0x40];" + "mov byte ptr [edx+0x2],0x0;" + "mov eax,dword ptr [esp+0x40];" + "mov byte ptr [eax],0x0;" + "mov ecx,dword ptr [esp+0x3C];" + "mov ecx,dword ptr [ecx];" + "xor edx,edx;" + "mov dh,byte ptr [ecx+0x2];" + "lea eax,dword ptr [ecx+0x3];" + "mov dl,byte ptr [ecx+0x1];" + "mov ecx,edx;" + "cmp ecx,0x3;" + "jae L0xABEL_0x0053F1EB;" + "xor ecx,ecx;" + "jmp L0xABEL_0x0053F1EE;" + "L0xABEL_0x0053F1EB:;" + "add ecx,0xFFFFFFFD;" + "L0xABEL_0x0053F1EE:;" + "add ecx,eax;" + "cmp dword ptr [esp+0x30],0x0;" + "mov dword ptr [esp+0x28],eax;" + "mov dword ptr [esp+0x24],eax;" + "mov dword ptr [esp+0x2C],ecx;" + "je L0xABEL_0x0053F211;" + "mov dword ptr [esp+0x34],eax;" + "mov dword ptr [esp+0x30],eax;" + "mov dword ptr [esp+0x38],ecx;" + "jmp L0xABEL_0x0053F219;" + "L0xABEL_0x0053F211:;" + "mov ecx,dword ptr [esp+0x38];" + "mov eax,dword ptr [esp+0x34];" + "L0xABEL_0x0053F219:;" + "sub ecx,eax;" + "cmp ecx,0x4;" + "mov edx,0x1;" + "mov dword ptr [esp+0x14],edx;" + "jb L0xABEL_0x0053F232;" + "mov dword ptr [eax],edx;" + "add dword ptr [esp+0x34],0x4;" + "jmp L0xABEL_0x0053F246;" + "L0xABEL_0x0053F232:;" + "mov edx,dword ptr [esp+0x20];" + "push 0x4;" + "lea eax,dword ptr [esp+0x18];" + "push eax;" + "mov eax,dword ptr [edx+0x1C];" + "lea ecx,dword ptr [esp+0x28];" + "call eax;" + "L0xABEL_0x0053F246:;" + "mov ecx,dword ptr [esp+0x40];" + "movzx edx,byte ptr [ecx];" + "mov ecx,dword ptr [edi+edx*0x4+0xC];" + "test ecx,ecx;" + "lea eax,dword ptr [edi+0x4];" + "je L0xABEL_0x0053F264;" + "mov edx,dword ptr [ecx];" + "mov edx,dword ptr [edx];" + "push eax;" + "lea eax,dword ptr [esp+0x44];" + "push eax;" + "call edx;" + "L0xABEL_0x0053F264:;" + "mov eax,dword ptr [edi+0x438];" + "cmp eax,dword ptr [edi+0x43C];" + "jne L0xABEL_0x0053F27D;" + "lea ecx,dword ptr [edi+0x184C0];" + "call 0x9556F0;" + "L0xABEL_0x0053F27D:;" + "lea ecx,dword ptr [esp+0x20];" + "mov byte ptr [esp+0x9C],0x1;" + "call 0x956DD0;" + "mov eax,dword ptr [esp+0x40];" + "cmp eax,dword ptr [esp+0x4C];" + "je L0xABEL_0x0053F2A1;" + "push eax;" + "call 0xA82542;" + "add esp,0x4;" + "L0xABEL_0x0053F2A1:;" + "mov ecx,dword ptr [esp+0x94];" + "pop edi;" + "pop esi;" + // "mov dword ptr [0x0],ecx;" + "pop ebx;" + "mov esp,ebp;" + "pop ebp;" + "ret 0x4;" + ); +} \ No newline at end of file diff --git a/section/moho_input.cpp b/section/moho_input.cpp new file mode 100644 index 00000000..fd9a7bdb --- /dev/null +++ b/section/moho_input.cpp @@ -0,0 +1,994 @@ +#include "include/funcDefs.h" +#include "include/global_func_table.h" + +_DWORD input_tick = 0; +_DWORD prev_tick = 0; +_DWORD init_tick = 0; + +void MOHO_USER_INPUT() +{ + register int eax asm("eax"); + + asm + ( + "SetCursorPos = 0x00C0F7C0;" + "Sleep = 0x00C0F574;" + "WaitForSingleObject = 0x00C0F524;" + "cmp dword ptr [0x011FD23F], 0x1;" + "jne run_input_check;" + ); + input_tick++; + if((input_tick - init_tick) > 600) + { + if(!paused) + { + asm("mov dword ptr [0x011FD23F], 0xB;"); + } + } + asm + ( + "mov al, 0x1;" + "ret 0x4;" + "run_input_check:;" + ); + init_tick = input_tick; + asm + ( + + "push ebp;" + "mov ebp,esp;" + "and esp,0xFFFFFFF8;" + "push 0xFFFFFFFF;" + "push 0xBC29A5;" + "push eax;" + "sub esp,0x150;" + "push ebx;" + "mov ebx,dword ptr [ebp+0x8];" + "mov eax,dword ptr [ebx];" + "cmp eax,0x2;" + "push esi;" + "push edi;" + "mov edi,ecx;" + "mov dword ptr [esp+0x20],edi;" + "jne L0xABEL_0x008704F0;" + "mov byte ptr [edi+0x275],0x1;" + "jmp L0xABEL_0x008705BB;" + "L0xABEL_0x008704F0:;" + "cmp eax,0x4;" + "jne L0xABEL_0x008705BB;" + "cmp byte ptr [edi+0x276],0x0;" + "mov byte ptr [edi+0x275],0x0;" + "je L0xABEL_0x0087051F;" + "cmp byte ptr [0x10A645F],0x0;" + "jne L0xABEL_0x0087051F;" + "mov ecx,dword ptr [edi+0x120];" + "mov eax,dword ptr [ecx];" + "mov edx,dword ptr [eax+0x74];" + "call edx;" + "L0xABEL_0x0087051F:;" + "mov byte ptr [edi+0x276],0x0;" + "cmp byte ptr [0x10A6464],0x0;" + "jne L0xABEL_0x0087056C;" + "cmp byte ptr [0x10C4840],0x0;" + "je L0xABEL_0x0087056C;" + "mov ecx,dword ptr [0x10A6450];" + "mov byte ptr [0x10C4840],0x0;" + "mov eax,dword ptr [ecx];" + "mov edx,dword ptr [eax+0x34];" + "call edx;" + "mov cl,0x1;" + "cmp byte ptr [eax+0x45],cl;" + "je L0xABEL_0x00870559;" + "mov byte ptr [eax+0x45],cl;" + "mov byte ptr [eax+0x44],cl;" + "L0xABEL_0x00870559:;" + "mov eax,dword ptr [0x10C4848];" + "mov ecx,dword ptr [0x10C4844];" + "push eax;" + "push ecx;" + "call dword ptr [SetCursorPos];" + "L0xABEL_0x0087056C:;" + "mov edx,dword ptr [edi+0x208];" + "mov eax,dword ptr [edx+0x400];" + "cmp byte ptr [eax+0x10],0x0;" + "je L0xABEL_0x008705BB;" + "lea esi,dword ptr [esp+0x2C];" + "call 0x7B25C0;" + "mov dword ptr [esp+0x164],0x0;" + "mov eax,dword ptr [edi+0x208];" + "mov esi,dword ptr [eax+0x400];" + "mov byte ptr [esi+0x10],0x0;" + "call 0x8380E0;" + "lea eax,dword ptr [esp+0x2C];" + "mov dword ptr [esp+0x164],0xFFFFFFFF;" + "call 0x7B2530;" + "L0xABEL_0x008705BB:;" + "cmp byte ptr [0x10C4840],0x0;" + "jne L0xABEL_0x008705E5;" + "movss xmm0,dword ptr [ebx+0x4];" + "movss xmm1,dword ptr [ebx+0x8];" + "lea ecx,dword ptr [esp+0x24];" + "push ecx;" + "push edi;" + "movss dword ptr [esp+0x2C],xmm0;" + "movss dword ptr [esp+0x30],xmm1;" + "call 0x86F520;" + "L0xABEL_0x008705E5:;" + "mov esi,dword ptr [edi+0x208];" + "add esi,0x4B0;" + "push ebx;" + "mov ecx,edi;" + "mov dword ptr [esp+0x1C],esi;" + "call 0x7873A0;" + "test al,al;" + "jne L0xABEL_0x0087094A;" + "cmp dword ptr [edi+0x138],0x0;" + "jg L0xABEL_0x0087094A;" + "cmp dword ptr [edi+0x20C],0x0;" + "mov byte ptr [edi+0x274],al;" + "mov byte ptr [esp+0x17],0x1;" + "je L0xABEL_0x008708AF;" + +/* "cmp dword ptr [0x011FD23F], 0x1;" + "je L0xABEL_0x0087110F;" */ + + "mov edx,dword ptr [esi+0x18];" + "and edx,0xFF000000;" + "cmp edx,0xFF000000;" + "je L0xABEL_0x008708AF;" + "mov eax,dword ptr [edi+0x208];" + "mov ecx,dword ptr [esi+0x18];" + "mov eax,dword ptr [eax+0x3FC];" + "push ecx;" + "mov esi,eax;" + "call 0x8B5BB0;" + "test eax,eax;" + "mov dword ptr [esp+0x10],eax;" + "je L0xABEL_0x008708AF;" + "lea edx,dword ptr [esp+0x38];" + "push edx;" + "call 0x83DDA0;" + "add esp,0x4;" + "lea esi,dword ptr [esp+0x2C];" + "mov dword ptr [esp+0x164],0x1;" + "call 0x7B25C0;" + "mov eax,esi;" + "mov byte ptr [esp+0x164],0x2;" + "mov ebx,dword ptr [edi+0x208];" + "push eax;" + "call 0x896000;" + "lea ebx,dword ptr [esp+0x24];" + "mov eax,esi;" + "call 0x7B25F0;" + "mov eax,dword ptr [esp+0x28];" + "cmp eax,dword ptr [esp+0x30];" + "je L0xABEL_0x008706E9;" + "mov edi,edi;" + "L0xABEL_0x008706B0:;" + "mov eax,dword ptr [eax+0x10];" + "xor ebx,ebx;" + "cmp eax,ebx;" + "je L0xABEL_0x008706BE;" + "add eax,0xFFFFFFF8;" + "jmp L0xABEL_0x008706C0;" + "L0xABEL_0x008706BE:;" + "xor eax,eax;" + "L0xABEL_0x008706C0:;" + "mov ecx,dword ptr [esp+0x10];" + "push eax;" + "push ecx;" + "call 0x8B4300;" + "test al,al;" + "jne L0xABEL_0x008707D5;" + "lea edx,dword ptr [esp+0x24];" + "push edx;" + "call 0x7F0490;" + "mov eax,dword ptr [esp+0x28];" + "cmp eax,dword ptr [esp+0x30];" + "jne L0xABEL_0x008706B0;" + "jmp L0xABEL_0x008706EB;" + "L0xABEL_0x008706E9:;" + "xor ebx,ebx;" + "L0xABEL_0x008706EB:;" + "mov esi,dword ptr [esp+0x10];" + "push esi;" + "call 0x8B4140;" + "cmp eax,0xA;" + "je L0xABEL_0x00870709;" + "push esi;" + "call 0x8B4140;" + "cmp eax,0xB;" + "jne L0xABEL_0x008707D5;" + "L0xABEL_0x00870709:;" + "mov eax,dword ptr [edi+0x208];" + "mov esi,dword ptr [esp+0x18];" + "push eax;" + "push ebx;" + "lea ecx,dword ptr [esp+0xA0];" + "push esi;" + "push ecx;" + "call 0x81EC00;" + "push ebx;" + "lea edx,dword ptr [esp+0x10C];" + "mov byte ptr [esp+0x178],0x3;" + "mov ecx,dword ptr [edi+0x208];" + "push esi;" + "push edx;" + "call 0x81F7B0;" + "add esp,0x1C;" + "mov eax,0x4;" + "mov byte ptr [esp+0x164],al;" + "cmp dword ptr [esp+0x9C],eax;" + "je L0xABEL_0x00870761;" + "cmp dword ptr [esp+0xFC],eax;" + "jne L0xABEL_0x008707A8;" + "L0xABEL_0x00870761:;" + "lea eax,dword ptr [esp+0x38];" + "push 0xE42360;" + "push eax;" + "call 0x4207D0;" + "fld dword ptr [0xE4F6E8];" + "add esp,0x8;" + "push ebx;" + "push ecx;" + "fstp dword ptr [esp];" + "push 0xFFFFFFFF;" + "push ecx;" + "test al,al;" + "mov dword ptr [esp+0x20],esp;" + "lea ecx,dword ptr [esi+0x1C];" + "mov eax,esp;" + "je L0xABEL_0x00870796;" + "mov dword ptr [eax],0xE48938;" + "jmp L0xABEL_0x0087079C;" + "L0xABEL_0x00870796:;" + "mov dword ptr [eax],0xE48974;" + "L0xABEL_0x0087079C:;" + "call 0x83ECF0;" + "add esp,0x10;" + "mov byte ptr [esp+0x17],bl;" + "L0xABEL_0x008707A8:;" + "lea edx,dword ptr [esp+0xF8];" + "mov byte ptr [esp+0x164],0x3;" + "call 0x7EF070;" + "lea edx,dword ptr [esp+0x98];" + "mov byte ptr [esp+0x164],0x2;" + "call 0x7EF070;" + "jmp L0xABEL_0x0087085A;" + "L0xABEL_0x008707D5:;" + "mov esi,dword ptr [esp+0x10];" + "push esi;" + "call 0x8B4140;" + "cmp eax,0x2;" + "je L0xABEL_0x008707EF;" + "push esi;" + "call 0x8B4140;" + "cmp eax,0x4;" + "jne L0xABEL_0x0087085A;" + "L0xABEL_0x008707EF:;" + "mov eax,dword ptr [edi+0x208];" + "add eax,0x4A0;" + "push esi;" + "push eax;" + "call 0x81DD00;" + "add esp,0x8;" + "test al,al;" + "je L0xABEL_0x0087085A;" + "lea ecx,dword ptr [esp+0x38];" + "push 0xE42360;" + "push ecx;" + "call 0x4207D0;" + "fld dword ptr [0xE4F6E8];" + "add esp,0x8;" + "push ebx;" + "push ecx;" + "fstp dword ptr [esp];" + "push 0xFFFFFFFF;" + "push ecx;" + "mov ecx,dword ptr [esp+0x28];" + "add ecx,0x1C;" + "test al,al;" + "mov dword ptr [esp+0x20],esp;" + "mov eax,esp;" + "je L0xABEL_0x00870841;" + "mov dword ptr [eax],0xE489B0;" + "jmp L0xABEL_0x00870847;" + "L0xABEL_0x00870841:;" + "mov dword ptr [eax],0xE489E8;" + "L0xABEL_0x00870847:;" + "call 0x83ECF0;" + "add esp,0x10;" + "mov byte ptr [esp+0x17],bl;" + "mov byte ptr [edi+0x274],0x1;" + "L0xABEL_0x0087085A:;" + "mov byte ptr [esp+0x164],0x1;" + "mov eax,dword ptr [esp+0x30];" + "mov ecx,dword ptr [eax];" + "push eax;" + "push ecx;" + "lea edx,dword ptr [esp+0x18];" + "push edx;" + "lea edi,dword ptr [esp+0x38];" + "call 0x7B33B0;" + "mov eax,dword ptr [esp+0x30];" + "push eax;" + "call 0x957A60;" + "add esp,0x4;" + "lea ecx,dword ptr [esp+0x38];" + "mov dword ptr [esp+0x30],ebx;" + "mov dword ptr [esp+0x34],ebx;" + "push ecx;" + "mov dword ptr [esp+0x168],0xFFFFFFFF;" + "call 0x81F700;" + "cmp byte ptr [esp+0x17],bl;" + "mov edi,dword ptr [esp+0x20];" + "mov ebx,dword ptr [ebp+0x8];" + "je L0xABEL_0x008708B4;" + "L0xABEL_0x008708AF:;" + "call 0x83EDF0;" + "L0xABEL_0x008708B4:;" + "mov eax,dword ptr [ebx];" + + "cmp eax,0x8;" + + "mov esi,dword ptr [esp+0x18];" + "jne L0xABEL_0x00870963;" + "mov edx,dword ptr [ebx+0x1C];" + "mov ecx,esi;" + "push edx;" + "lea esi,dword ptr [esp+0x3C];" + "call 0x81FC80;" + "add esp,0x4;" + "mov dword ptr [esp+0x164],0x7;" + "cmp dword ptr [esp+0x38],0x0;" + "jne L0xABEL_0x00870921;" + "mov ecx,dword ptr [edi+0x120];" + "mov edx,dword ptr [esp+0x18];" + "mov eax,dword ptr [ecx];" + "mov eax,dword ptr [eax+0x78];" + "add edx,0x1C;" + "push edx;" + "call eax;" + "mov edi,dword ptr [edi+0x120];" + "mov edx,dword ptr [edi];" + "cvtsi2ss xmm0,dword ptr [ebx+0xC];" + "cvtsi2ss xmm1,dword ptr [ebx+0x10];" + "mov eax,dword ptr [edx+0x7C];" + "push ecx;" + "divss xmm0,xmm1;" + "mov ecx,edi;" + "movss dword ptr [esp],xmm0;" + "call eax;" + "jmp L0xABEL_0x00870936;" + "L0xABEL_0x00870921:;" + "mov ecx,dword ptr [edi+0x208];" + "push 0x0;" + "push ecx;" + "lea ecx,dword ptr [esp+0x40];" + "call 0x81FCD0;" + "add esp,0x8;" + "L0xABEL_0x00870936:;" + "lea edx,dword ptr [esp+0x38];" + "mov dword ptr [esp+0x164],0xFFFFFFFF;" + "call 0x7EF070;" + "L0xABEL_0x0087094A:;" + "mov al,0x1;" + "mov ecx,dword ptr [esp+0x15C];" + //"mov dword ptr [0x0],ecx;" + "pop edi;" + "pop esi;" + "pop ebx;" + "mov esp,ebp;" + "pop ebp;" + "ret 0x4;" + "L0xABEL_0x00870963:;" + "mov ecx,0x1;" + "cmp eax,ecx;" + "jne L0xABEL_0x00870B0A;" + "push 0x20;" + "call 0x79CB70;" + "add esp,0x4;" + "test al,al;" + "je L0xABEL_0x00870A70;" + "cmp byte ptr [0x10A645F],0x0;" + "jne L0xABEL_0x008709A8;" + "mov ecx,dword ptr [edi+0x120];" + "mov edx,dword ptr [ecx];" + "mov eax,dword ptr [edx+0x4C];" + "call eax;" + "fld dword ptr [0xF57AA0];" + "fcomip st(1);" + "fstp st(0)\n " + "jbe L0xABEL_0x00870A70;" + "L0xABEL_0x008709A8:;" + "cmp byte ptr [edi+0x275],0x0;" + "je L0xABEL_0x00870ADE;" + "cmp byte ptr [edi+0x276],0x0;" + "je L0xABEL_0x00870A55;" + "push edi;" + "push 0x1;" + "call 0x86DE30;" + "cmp byte ptr [0x10A6464],0x0;" + "mov ecx,dword ptr [edi+0x120];" + "je L0xABEL_0x00870A1C;" + "movss xmm0,dword ptr [esi+0x1C];" + "subss xmm0,dword ptr [edi+0x278];" + "movss dword ptr [esp+0x24],xmm0;" + "movss xmm0,dword ptr [esi+0x20];" + "subss xmm0,dword ptr [edi+0x27C];" + "movss dword ptr [esp+0x28],xmm0;" + "mov edx,dword ptr [ecx];" + "mov edx,dword ptr [edx+0x6C];" + "lea eax,dword ptr [esp+0x24];" + "push eax;" + "call edx;" + "xor eax,eax;" + "xor ecx,ecx;" + "mov dword ptr [0x10C484C],eax;" + "mov dword ptr [0x10C4850],ecx;" + "jmp L0xABEL_0x00870A5C;" + "L0xABEL_0x00870A1C:;" + "cvtsi2ss xmm0,dword ptr [0x10C484C];" + "movss dword ptr [esp+0x24],xmm0;" + "cvtsi2ss xmm0,dword ptr [0x10C4850];" + "movss dword ptr [esp+0x28],xmm0;" + "mov eax,dword ptr [ecx];" + "mov eax,dword ptr [eax+0x6C];" + "lea edx,dword ptr [esp+0x24];" + "push edx;" + "call eax;" + "xor eax,eax;" + "xor ecx,ecx;" + "mov dword ptr [0x10C484C],eax;" + "mov dword ptr [0x10C4850],ecx;" + "jmp L0xABEL_0x00870A5C;" + "L0xABEL_0x00870A55:;" + "mov byte ptr [edi+0x276],0x1;" + "L0xABEL_0x00870A5C:;" + "fld dword ptr [esi+0x1C];" + "fstp dword ptr [edi+0x278];" + "fld dword ptr [esi+0x20];" + "fstp dword ptr [edi+0x27C];" + "jmp L0xABEL_0x00870ADE;" + "L0xABEL_0x00870A70:;" + "cmp byte ptr [edi+0x276],0x0;" + "je L0xABEL_0x00870A8F;" + "cmp byte ptr [0x10A645F],0x0;" + "jne L0xABEL_0x00870A8F;" + "mov ecx,dword ptr [edi+0x120];" + "mov edx,dword ptr [ecx];" + "mov eax,dword ptr [edx+0x74];" + "call eax;" + "L0xABEL_0x00870A8F:;" + "mov byte ptr [edi+0x276],0x0;" + "cmp byte ptr [0x10A6464],0x0;" + "jne L0xABEL_0x00870ADE;" + "cmp byte ptr [0x10C4840],0x0;" + "je L0xABEL_0x00870ADE;" + "mov ecx,dword ptr [0x10A6450];" + "mov byte ptr [0x10C4840],0x0;" + "mov edx,dword ptr [ecx];" + "mov eax,dword ptr [edx+0x34];" + "call eax;" + "cmp byte ptr [eax+0x45],0x1;" + "je L0xABEL_0x00870ACA;" + "mov byte ptr [eax+0x45],0x1;" + "mov byte ptr [eax+0x44],0x1;" + "L0xABEL_0x00870ACA:;" + "mov ecx,dword ptr [0x10C4848];" + "mov edx,dword ptr [0x10C4844];" + "push ecx;" + "push edx;" + "call dword ptr [SetCursorPos];" + "L0xABEL_0x00870ADE:;" + "mov edi,dword ptr [edi+0x120];" + "mov eax,dword ptr [edi];" + "mov edx,dword ptr [eax+0x78];" + "add esi,0x1C;" + "push esi;" + "mov ecx,edi;" + "call edx;" + "mov al,0x1;" + "mov ecx,dword ptr [esp+0x15C];" + ////"mov dword ptr [0x0],ecx;" + "pop edi;" + "pop esi;" + "pop ebx;" + "mov esp,ebp;" + "pop ebp;" + "ret 0x4;" + "L0xABEL_0x00870B0A:;" + "cmp eax,0x5;" + "jne L0xABEL_0x00870BC9;" + "cmp dword ptr [ebx+0x14],0x2;" + "jne L0xABEL_0x00870BC9;" + "mov eax,dword ptr [ebx+0x1C];" + "mov ecx,dword ptr [esp+0x18];" + "push eax;" + "lea esi,dword ptr [esp+0x3C];" + "call 0x81F760;" + "add esp,0x4;" + "mov dword ptr [esp+0x164],0x8;" + "cmp dword ptr [esp+0x38],0x0;" + "jne L0xABEL_0x00870B9B;" + "push 0x20;" + "call 0xA825B9;" + "add esp,0x4;" + "mov dword ptr [esp+0x10],eax;" + "test eax,eax;" + "mov byte ptr [esp+0x164],0x9;" + "je L0xABEL_0x00870B7E;" + "mov esi,dword ptr [edi+0x120];" + "xor edx,edx;" + "push edx;" + "mov ecx,0x873BD0;" + "push ecx;" + "mov ecx,dword ptr [esp+0x20];" + "push edi;" + "add ecx,0x1C;" + "push ecx;" + "push esi;" + "push eax;" + "call 0x86E060;" + "jmp L0xABEL_0x00870B80;" + "L0xABEL_0x00870B7E:;" + "xor eax,eax;" + "L0xABEL_0x00870B80:;" + "mov byte ptr [esp+0x164],0x8;" + "mov edi,dword ptr [edi+0xFC];" + "push ebx;" + "mov esi,eax;" + "call 0x78DDE0;" + "add esp,0x4;" + "jmp L0xABEL_0x00870BB0;" + "L0xABEL_0x00870B9B:;" + "mov edx,dword ptr [edi+0x208];" + "push 0x0;" + "push edx;" + "lea ecx,dword ptr [esp+0x40];" + "call 0x81FCD0;" + "add esp,0x8;" + "L0xABEL_0x00870BB0:;" + "lea edx,dword ptr [esp+0x38];" + "mov dword ptr [esp+0x164],0xFFFFFFFF;" + "call 0x7EF070;" + "jmp L0xABEL_0x0087110F;" + "L0xABEL_0x00870BC9:;" + +/* "cmp dword ptr [0x011FD23F], 0x1;" + "je L0xABEL_0x00870FF7;" */ + + "cmp eax,0x6;" + "jne L0xABEL_0x00870CA4;" + "cmp dword ptr [ebx+0x14],ecx;" + "jne L0xABEL_0x00870CA4;" + "mov eax,dword ptr [edi+0x208];" + "mov eax,dword ptr [eax+0x400];" + "cmp byte ptr [eax+0x10],0x0;" + "je L0xABEL_0x00870C0D;" + "mov esi,eax;" + "L0xABEL_0x00870BEF:;" + "call 0x838A80;" + "mov al,0x1;" + "mov ecx,dword ptr [esp+0x15C];" + //"mov dword ptr [0x0],ecx;" + "pop edi;" + "pop esi;" + "pop ebx;" + "mov esp,ebp;" + "pop ebp;" + "ret 0x4;" + "L0xABEL_0x00870C0D:;" + "mov eax,dword ptr [edi+0x148];" + "sub eax,ecx;" + "mov dword ptr [edi+0x140],0x6;" + "je L0xABEL_0x00870C7A;" + "sub eax,0x3;" + "jne L0xABEL_0x0087110F;" + "mov eax,dword ptr [esi+0x10];" + "test eax,eax;" + "je L0xABEL_0x00870C61;" + "add eax,0xFFFFFFF8;" + "je L0xABEL_0x00870C61;" + "mov edx,dword ptr [edi+0x11C];" + "mov eax,dword ptr [edx+0x28];" + "lea ecx,dword ptr [edi+0x11C];" + "call eax;" + "test al,al;" + "jne L0xABEL_0x00870C61;" + "mov ecx,dword ptr [edi+0x120];" + "mov edx,dword ptr [edi+0x208];" + "push ecx;" + "push edx;" + "call 0x865E20;" + "add esp,0x8;" + "L0xABEL_0x00870C61:;" + "mov al,0x1;" + "mov ecx,dword ptr [esp+0x15C];" + //"mov dword ptr [0x0],ecx;" + "pop edi;" + "pop esi;" + "pop ebx;" + "mov esp,ebp;" + "pop ebp;" + "ret 0x4;" + "L0xABEL_0x00870C7A:;" + "movzx eax,byte ptr [ebx+0x1C];" + "and eax,0xFFFFFF01;" + "push eax;" + "push esi;" + "push edi;" + "call 0x870310;" + "mov al,0x1;" + "mov ecx,dword ptr [esp+0x15C];" + //"mov dword ptr [0x0],ecx;" + "pop edi;" + "pop esi;" + "pop ebx;" + "mov esp,ebp;" + "pop ebp;" + "ret 0x4;" + "L0xABEL_0x00870CA4:;" + "cmp eax,0x5;" + "jne L0xABEL_0x00870F12;" + "cmp dword ptr [ebx+0x14],ecx;" + "jne L0xABEL_0x00870F1B;" + "mov ecx,dword ptr [edi+0x208];" + "mov esi,dword ptr [ecx+0x400];" + "cmp byte ptr [esi+0x10],0x0;" + "jne L0xABEL_0x00870BEF;" + "mov dword ptr [edi+0x140],eax;" + "mov edx,dword ptr [ebx+0x1C];" + "mov eax,dword ptr [esp+0x18];" + "push edx;" + "push eax;" + "lea edx,dword ptr [esp+0xA0];" + "push edx;" + "call 0x81F7B0;" + "add esp,0xC;" + "add edi,0x148;" + "mov ebx,eax;" + "mov dword ptr [esp+0x164],0xA;" + "call 0x82B230;" + "lea edx,dword ptr [esp+0x98];" + "mov dword ptr [esp+0x164],0xFFFFFFFF;" + "call 0x7EF070;" + "mov eax,dword ptr [edi];" + //"cmp edi,0x5;" + //"ja L0xABEL_0x00870EDC;" + ); + switch(eax) + { + case 0: + asm("jmp L0xABEL_0x0087110F;"); + break; + case 2: + case 3: + asm("jmp case3;"); + break; + case 4: + break; + case 5: + asm("jmp case5;"); + break; + default: + asm("jmp L0xABEL_0x00870EDC;"); + break; + } + asm + ( + + //"jmp L0xABEL_0x00000000;" + "mov edi,dword ptr [esp+0x20];" + "mov eax,dword ptr [edi+0x11C];" + "mov edx,dword ptr [eax+0x28];" + "lea ecx,dword ptr [edi+0x11C];" + "call edx;" + "test al,al;" + "je L0xABEL_0x00870E0C;" + "cmp dword ptr [edi+0x294],0x0;" + "je L0xABEL_0x00870E3A;" + "push ecx;" + "lea ebx,dword ptr [edi+0x280];" + "mov ecx,esp;" + "mov dword ptr [esp+0x14],esp;" + "push ebx;" + "call 0x408710;" + "call 0x7AAD00;" + "add esp,0x4;" + "test eax,eax;" + "je L0xABEL_0x00870D8C;" + "fldz;" + "mov edx,dword ptr [eax];" + "mov edx,dword ptr [edx+0x28];" + "push ecx;" + "mov ecx,dword ptr [esp+0x1C];" + "fstp dword ptr [esp];" + "add ecx,0x4;" + "push ecx;" + "mov ecx,eax;" + "call edx;" + "L0xABEL_0x00870D8C:;" + "push 0x24;" + "call 0xA825B9;" + "mov esi,eax;" + "add esp,0x4;" + "mov dword ptr [esp+0x10],esi;" + "test esi,esi;" + "mov dword ptr [esp+0x164],0xB;" + "je L0xABEL_0x00870DD2;" + "sub esp,0x1C;" + "mov ecx,esp;" + "mov dword ptr [esp+0x3C],esp;" + "push ebx;" + "call 0x405590;" + "mov byte ptr [esp+0x180],0xC;" + "push esi;" + "mov byte ptr [esp+0x184],0xB;" + "call 0x86E270;" + "jmp L0xABEL_0x00870DD4;" + "L0xABEL_0x00870DD2:;" + "xor eax,eax;" + "L0xABEL_0x00870DD4:;" + "mov ecx,dword ptr [ebp+0x8];" + "mov dword ptr [esp+0x164],0xFFFFFFFF;" + "mov edi,dword ptr [edi+0xFC];" + "push ecx;" + "mov esi,eax;" + "call 0x78DDE0;" + "add esp,0x4;" + "mov al,0x1;" + "mov ecx,dword ptr [esp+0x15C];" + //"mov dword ptr [0x0],ecx;" + "pop edi;" + "pop esi;" + "pop ebx;" + "mov esp,ebp;" + "pop ebp;" + "ret 0x4;" + "L0xABEL_0x00870E0C:;" + "mov edx,dword ptr [ebp+0x8];" + "mov eax,dword ptr [edi+0xFC];" + "mov ecx,dword ptr [edi+0x120];" + "push edx;" + "mov edx,dword ptr [edi+0x208];" + "push eax;" + "call 0x865880;" + "lea edx,dword ptr [edi+0x29C];" + "mov ecx,eax;" + "add esp,0x8;" + "mov eax,edx;" + "call 0x873810;" + "L0xABEL_0x00870E3A:;" + "mov al,0x1;" + "mov ecx,dword ptr [esp+0x15C];" + //"mov dword ptr [0x0],ecx;" + "pop edi;" + "pop esi;" + "pop ebx;" + "mov esp,ebp;" + "pop ebp;" + "ret 0x4;" + "case3:;" + "mov eax,dword ptr [esp+0x20];" + "mov edx,dword ptr [eax+0x120];" + "mov edi,dword ptr [eax+0xFC];" + "lea ecx,dword ptr [eax+0x214];" + "push ecx;" + "mov ecx,dword ptr [ebp+0x8];" + "push edx;" + "mov edx,dword ptr [eax+0x208];" + "push ecx;" + "push edx;" + "call 0x823CB0;" + "add esp,0x10;" + "mov al,0x1;" + "mov ecx,dword ptr [esp+0x15C];" + //"mov dword ptr [0x0],ecx;" + "pop edi;" + "pop esi;" + "pop ebx;" + "mov esp,ebp;" + "pop ebp;" + "ret 0x4;" + "case5:;" + "mov eax,dword ptr [esp+0x18];" + "mov ecx,dword ptr [eax+0x18];" + "mov eax,dword ptr [esp+0x20];" + "mov edx,dword ptr [eax+0x120];" + "mov edi,dword ptr [eax+0xFC];" + "push ecx;" + "mov ecx,dword ptr [ebp+0x8];" + "push edx;" + "mov edx,dword ptr [eax+0x208];" + "push ecx;" + "push edx;" + "call 0x8242B0;" + "add esp,0x10;" + "mov al,0x1;" + "mov ecx,dword ptr [esp+0x15C];" + //"mov dword ptr [0x0],ecx;" + "pop edi;" + "pop esi;" + "pop ebx;" + "mov esp,ebp;" + "pop ebp;" + "ret 0x4;" + "L0xABEL_0x00870EDC:;" + "mov eax,dword ptr [ebp+0x8];" + "movzx ecx,byte ptr [eax+0x1C];" + "mov edx,dword ptr [esp+0x18];" + "mov eax,dword ptr [esp+0x20];" + "and ecx,0xFFFFFF01;" + "push ecx;" + "push edx;" + "push eax;" + "call 0x870310;" + "mov al,0x1;" + "mov ecx,dword ptr [esp+0x15C];" + //"mov dword ptr [0x0],ecx;" + "pop edi;" + "pop esi;" + "pop ebx;" + "mov esp,ebp;" + "pop ebp;" + "ret 0x4;" + "L0xABEL_0x00870F12:;" + + "cmp eax,0x6;" + "jne L0xABEL_0x00870FF7;" + "L0xABEL_0x00870F1B:;" + "cmp dword ptr [ebx+0x14],0x3;" + "jne L0xABEL_0x00870FF7;" + "mov ecx,dword ptr [edi+0x208];" + "push ecx;" + "mov dword ptr [edi+0x144],eax;" + "mov edx,dword ptr [ebx+0x1C];" + "mov eax,dword ptr [esp+0x1C];" + "push edx;" + "push eax;" + "lea ecx,dword ptr [esp+0xA4];" + "push ecx;" + "call 0x81EC00;" + "add esp,0x10;" + "lea esi,dword ptr [edi+0x1A8];" + "mov ebx,eax;" + "mov edi,esi;" + "mov dword ptr [esp+0x164],0xD;" + "call 0x82B230;" + "lea edx,dword ptr [esp+0x98];" + "mov dword ptr [esp+0x164],0xFFFFFFFF;" + "call 0x7EF070;" + "cmp dword ptr [esi],0x1;" + "jne L0xABEL_0x0087110F;" + "mov edi,dword ptr [esp+0x20];" + "mov eax,dword ptr [edi+0x208];" + "add eax,0x4A0;" + "call 0x7B59B0;" + "test eax,eax;" + "jbe L0xABEL_0x0087110F;" + "mov edx,dword ptr [ebp+0x8];" + "mov al,byte ptr [edx+0x1C];" + "and al,0x1;" + "lea esi,dword ptr [esp+0x2C];" + "mov byte ptr [esp+0x10],al;" + "call 0x7B25C0;" + "mov ecx,esi;" + "mov dword ptr [esp+0x164],0xE;" + "mov ebx,dword ptr [edi+0x208];" + "push ecx;" + "call 0x896000;" + "mov edx,dword ptr [edi+0x208];" + "mov eax,dword ptr [edx+0x400];" + "mov ecx,dword ptr [esp+0x10];" + "mov edx,dword ptr [esp+0x18];" + "push ecx;" + "add edx,0x4;" + "push edx;" + "push 0x1;" + "push eax;" + "mov eax,esi;" + "call 0x838800;" + "jmp L0xABEL_0x008710FB;" + "L0xABEL_0x00870FF7:;" + + "cmp eax,0x7;" + + "jne L0xABEL_0x0087110F;" + "cmp dword ptr [ebx+0x14],0x3;" + + "jne L0xABEL_0x0087110F;" + + "mov eax,dword ptr [esi+0x18];" + +/* "cmp dword ptr [0x011FD23F], 0x1;" + "je L0xABEL_0x0087110F;" */ + + "and eax,0xFF000000;" // -> right click input + "cmp eax,0xFF000000;" + + "je L0xABEL_0x008710A0;" + + "mov ebx,dword ptr [ebx+0x1C];" + "test cl,bl;" + + "je L0xABEL_0x008710A0;" + + "test bl,0x2;" + + "je L0xABEL_0x008710A0;" + + "mov ebx,dword ptr [edi+0x208];" + "mov ecx,ebx;" + "call 0x896590;" + "test al,al;" + "jne L0xABEL_0x008710A0;" + "mov ecx,dword ptr [esp+0x18];" + "mov edx,dword ptr [ecx+0x18];" + "mov esi,dword ptr [ebx+0x3FC];" + "push edx;" + "call 0x8B5BB0;" + "test eax,eax;" + "mov dword ptr [esp+0x10],eax;" + "je L0xABEL_0x008710D2;" + "push eax;" + "call 0x8B43F0;" + "mov esi,eax;" + "lea ebx,dword ptr [esp+0x18];" + "mov dword ptr [esp+0x20],esi;" + "call 0x7B25F0;" + "mov esi,dword ptr [esi+0x4];" + "cmp dword ptr [esp+0x1C],esi;" + "je L0xABEL_0x008710D2;" + "L0xABEL_0x00871073:;" + "lea eax,dword ptr [esp+0x18];" + "call 0x7B2920;" + "mov ebx,dword ptr [esp+0x10];" + "mov esi,eax;" + "call 0x8B1220;" + "lea ecx,dword ptr [esp+0x18];" + "push ecx;" + "call 0x7F0490;" + "mov edx,dword ptr [esp+0x20];" + "mov eax,dword ptr [edx+0x4];" + "cmp dword ptr [esp+0x1C],eax;" + "jne L0xABEL_0x00871073;" + "jmp L0xABEL_0x008710D2;" + "L0xABEL_0x008710A0:;" + "cmp dword ptr [edi+0x1A8],0x0;" + "lea ecx,dword ptr [edi+0x1A8];" + "je L0xABEL_0x008710D2;" + "cmp byte ptr [0x10C4840],0x0;" + "jne L0xABEL_0x008710D2;" + "cmp dword ptr [edi+0x144],0x6;" + "mov edx,dword ptr [edi+0x208];" + "sete al;" + "push eax;" + "push edx;" + "call 0x81FCD0;" + "add esp,0x8;" + "L0xABEL_0x008710D2:;" + "lea esi,dword ptr [esp+0x2C];" + "call 0x7B25C0;" + "mov dword ptr [esp+0x164],0xF;" + "mov eax,dword ptr [edi+0x208];" + "mov esi,dword ptr [eax+0x400];" + "mov byte ptr [esi+0x10],0x0;" + "call 0x8380E0;" + "L0xABEL_0x008710FB:;" + "lea eax,dword ptr [esp+0x2C];" + "mov dword ptr [esp+0x164],0xFFFFFFFF;" + "call 0x7B2530;" + "L0xABEL_0x0087110F:;" + "mov ecx,dword ptr [esp+0x15C];" + "pop edi;" + "pop esi;" + "xor al,al;" + //"mov dword ptr [0x0],ecx;" + "pop ebx;" + "mov esp,ebp;" + "pop ebp;" + "ret 0x4;" + ); + +} \ No newline at end of file diff --git a/section/selectionPriority.cpp b/section/selectionPriority.cpp new file mode 100644 index 00000000..d5ad37df --- /dev/null +++ b/section/selectionPriority.cpp @@ -0,0 +1,51 @@ + +char LOWSELECTPRIO[] = "LOWSELECTPRIO"; +char buf[48]; + +void selectionPriority() +{ + asm + ( + "cmp byte ptr [ebx-0xD8],0x1;" + "je label1;" + "label2:;" + "mov eax,dword ptr [eax+0x1FC];" + "jmp 0x00863C19;" + "label1:;" + "push eax;" + "push ecx;" + "push edx;" + "push %[LOWSELECTPRIO];" + "mov ecx, %[buf];" + "call 0x00405550;" + "mov eax, %[buf];" + "lea ecx,dword ptr [ebx-0x148];" + "call 0x008B97C0;" + "test al, al;" + "pop edx;" + "pop ecx;" + "pop eax;" + "je label2;" + "mov eax, 0x6;" + "jmp 0x00863C19;" + : + : [LOWSELECTPRIO] "i" (LOWSELECTPRIO), [buf] "i" (buf) + : + ); +} + + +/* This patch changes the drag selection code so unfinished units +with "LOWSELECTPRIO" category get lowest priority - 6. + +Before patch: + selectionPriority = unitBlueprint.General.SelectionPriority + +After: + if (unit::IsBeingBuilt() && unit::IsInCatgory("LOWSELECTPRIO")) { + selectionPriority = 6 + } else { + selectionPriority = unitBP.General.SelectionPriority + } +*/ + \ No newline at end of file