{"id":26607062,"url":"https://github.com/widberg/msvc8.0_patcher","last_synced_at":"2025-03-23T22:36:41.924Z","repository":{"id":280200746,"uuid":"940952617","full_name":"widberg/msvc8.0_patcher","owner":"widberg","description":"A conglomeration of magical artifacts that patch MSVC 8.0 binaries to add pseudo-__usercall syntax","archived":false,"fork":false,"pushed_at":"2025-03-09T04:35:50.000Z","size":25,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-20T00:38:11.206Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/widberg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-01T05:58:15.000Z","updated_at":"2025-03-09T04:35:54.000Z","dependencies_parsed_at":"2025-03-01T23:37:04.066Z","dependency_job_id":null,"html_url":"https://github.com/widberg/msvc8.0_patcher","commit_stats":null,"previous_names":["widberg/msvc8.0_patcher"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/widberg%2Fmsvc8.0_patcher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/widberg%2Fmsvc8.0_patcher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/widberg%2Fmsvc8.0_patcher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/widberg%2Fmsvc8.0_patcher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/widberg","download_url":"https://codeload.github.com/widberg/msvc8.0_patcher/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245180726,"owners_count":20573708,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-23T22:36:26.883Z","updated_at":"2025-03-23T22:36:41.900Z","avatar_url":"https://github.com/widberg.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# msvc8.0_patcher\n\nA conglomeration of magical artifacts that patch MSVC 8.0 binaries to add pseudo-`__usercall` syntax from IDA Pro in support of the [FUELDecompilation project](https://github.com/widberg/FUELDecompilation).\n\n## Syntax\n\n### Example 1\n\nPass `x` in `edx` and `y` on the stack. Callee cleans up the stack. Only ecx needs to be caller preserved across the call, if it is live; eax and edx do not need to be preserved even though they are traditionally call spoiled registers.\n\n```cpp\nint __usercall __edx __spoils __ecx func(int x, int y)\n{\n  return x + y;\n}\n```\n\n### Example 2\n\nPass `this` in `esi`, `x` in `ebx`, and `y` on the stack. Caller cleans up the stack. Default spoils behavior.\n\n```cpp\nint __userpurge __esi __ebx class::func(int x, int y)\n{\n  return x + y + this-\u003ez;\n}\n```\n\n## Usage\n\nClone the repository and submodules. Use a modern Visual Studio and Ninja to build the project. Make sure to define `-DMSVC_ORIGINAL_BIN=\u003cpath to original msvc8.0 bin directory\u003e -DMSVC_PATCHED_BIN=\u003cpath to patched msvc8.0 bin directory\u003e`. A compatible MSVC 8.0 can be found in the [widberg/msvc8.0 repository](https://github.com/widberg/msvc8.0).\n\n## TODO\n\nOrdered by priority.\n\n* For some reason reg args are treated as \"used\" aka overwritten even if they aren't\n  - Only the regs not in the clobber list\n  - This is really annoying because it makes it impossible to match functions using regs other than eax, ecx, and edx for args\n  - Actual flex params are not treated as used, try to copy what those do if I can figure that out\n* figure out if we need spoils/preseved regs\n  - Probably need preserved\n  - The compiler will save off eax before a call to a function that doesn't modify it but in the game it doesn't\n  - likely the ltcg optimizer can be more restrictive with the spoils list\n  - this might solve the ebp problem too?\n* Figure out if we need a way to force using base pointer as reg\n  - Sometimes the compiler uses another reg when it should be using ebp\n  - Even with /Oy- it still uses another reg\n  - This could be due to not matching instructions elsewhere in the functions due to the previous todo\n* Store the regs data out of band\n  - We're stepping on memory used by the compiler putting the pointer where we are\n* force inline/no inline per call\n  - Likely unnecessary\n  - Not sure if LTCG would cause anything to be inlined that wouldn't be otherwise if available\n  - If we do need this then probably just allow forceinline and noinline keywords after a function call and tag the call\n\n## Notes\n\n* Which regs are supported for parameters\n  - IDA thinks the compiler passes floats in st regs for user code but I think its confused\n  - I don't see any evidence that the compiler is capable of using st regs for flex params. Only the 8 gprs and 8 xmm regs are used\n  - The compiler may emit calls to compiler runtime functions such as __ftol2_sse which does pass the argument in st0 but these are a special case an user code will never do this\n  - FUEL doesn't use xmm regs for params outside of library code so I won't bother supporting it\n  - FUEL also never passes arguments in EBP or ESP\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwidberg%2Fmsvc8.0_patcher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwidberg%2Fmsvc8.0_patcher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwidberg%2Fmsvc8.0_patcher/lists"}