Results 1 to 19 of 19

Thread: Adding space to exe (not a question, but a reality!)

  1. #1

    Join Date
    14-04-14
    Location
    Romania
    Posts
    4
    vCash
    4000

    Adding space to exe (not a question, but a reality!)

    Hi all, my first ever post to this forum which I've been following and using its resources for so many years...I am quite a fanatic of CM, you might all understand the feeling of assimilating it to a drug I've modified the exe quite a lot, mostly just replicating the fabulous findings of this great community (I've discovered only a few on my own). I am usually patching the exe manually, I have almost zero coding experience, but I've come to understand the basics of assembly and, by modifying and checking the realtime results, gained that minimum level to allow me to discover new things.
    Ok, enough with the intro, so... I've discovered the Holy Grail (actually, the Holy Grail would've been the source code, but I think what I describe below is the closest to what we need to go one level up in keeping the game alive). I just insisted in searching on how one can expand the code space in an exe to allow for adding code in assembly - and the answer, apparently, was quite easy to find and even easier to implement.
    Go to https://ntcore.com/?tag=cff-explorer, download and run CFF Explorer, load the exe in it, on the left menu click on "Section Headers", on the top right window right click anywhere, select "Add Section (empty space)", for size enter a multiple of 2000, click OK. A new section appeared at the bottom of the list of sections, double click in the Name tab and give it a name (e.g. ".extra"). Then again in the same area right click and select "Rebuild Image Size", then again right click and "Rebuild PE Header".Now click on that row, the bottom half will show you that new section in HEX, right click in that area, "select all", then again right click and "Fill with", enter 90 (i.e. NOP). Save the exe.
    Open the exe in olly, from the menu View/Memory Map. You will immediately identify the new section there, right click on it, "Dump in CPU", it will show up in the bottom left section - if it shows as HEX, right click and select "Disassemble", you will see the new section filled with NOPs. And now you are able to add code, all that's needed is to create jumps or calls from original code space to the code written here. Those of you who are much more used to coding and manipulating this exe will probably understand better what's happened here, tbh I wouldn't be able to provide too much support or explanations outside of this pure "follow the instructions step by step" approach. Main sources that I used: https://reverseengineering.stackexch...ile-on-windows and https://resources.infosecinstitute.c...-to-pe-binary/
    I tested this by adding a 2000 byte section and adding the code described at https://champman0102.co.uk/showthrea...743#post346743, using Spain and Argentina and making a jump from the original code at 0053DA6E and then jumping back to 0053DA95. Works flawlessly!
    Now...let's see what you skilled patchers are able to do!
    Last edited by mihaigrad; 06-02-19 at 12:25 AM.

  2. The Following 3 Users Say Thank You to mihaigrad For This Useful Post:


  3. #2

    Join Date
    14-04-14
    Location
    Romania
    Posts
    4
    vCash
    4000
    So, as it appears that this hasn't quite generated to others the excitement that I felt when found out about this possibility, let me put here some gains that I believe can be achieved with additional space, by replicating blocks of existing competitions and changing references accordingly: African Nations Cup qualifications, U21 European and World Tournaments, new leagues (Austria, Serbia, Bulgaria, Romania, Uruguay, Columbia, China, UAE...), English full pyramid, French CFA, updated Champions League and Europa League structures, fictional regional/international leagues.
    My goal, to work during my little spare time, is to add Austria Premier and FIrst divisions, plus the Cup and Supercup, as a replica of Netherlands's competitions, as this looks to be the most simple competition system to replicate and a way to learn by doing.
    Happy to get your feedback on this whole new range of possibilities.

  4. The Following 2 Users Say Thank You to mihaigrad For This Useful Post:


  5. #3
    ebfatz is offline Social Media Bod
    Former Holy Trinity Member
    Stories Mod
    Tournaments Won: 1

    Join Date
    02-03-12
    Posts
    8,182
    vCash
    435000
    I think, and this is certainly true for me personally, is that you need to explain it in layman's terms.

    Does this mean that essentially expanding the available space on the disk/iso?

    So, I believe, the CM0102.iso is around 295MB (May be wrong).
    So if you were able to double it for example and you had 600MB, you could add additional leagues and competitions or have more steps in a certain countries league pyramid?

    Forgive me if I'm completely wrong on my example.

  6. #4

    Join Date
    14-04-14
    Location
    Romania
    Posts
    4
    vCash
    4000
    I'm talking about the exe. it's always been the issue of only being able to change certain values, for example to change the number of subs or foreigners. When having to alter fixtures or competition structures, it was very diificult to add new features, or to make changes that required more code, as you only had a limited "code space". But it is now possible to add more such space, to add code in assembly and have additional "native" competitions, on top of those already available originally.

  7. #5

    Join Date
    27-10-14
    Location
    The Netherlands
    Posts
    7,086
    vCash
    0
    Quote Originally Posted by mihaigrad View Post
    I'm talking about the exe. it's always been the issue of only being able to change certain values, for example to change the number of subs or foreigners. When having to alter fixtures or competition structures, it was very difficult to add new features, or to make changes that required more code, as you only had a limited "code space". But it is now possible to add more such space, to add code in assembly and have additional "native" competitions, on top of those already available originally.
    If that doesn't cause the game to crash after a season or so that would be marvelous. I hope Saturn can use this!!

  8. #6
    ebfatz is offline Social Media Bod
    Former Holy Trinity Member
    Stories Mod
    Tournaments Won: 1

    Join Date
    02-03-12
    Posts
    8,182
    vCash
    435000
    Quote Originally Posted by mihaigrad View Post
    I'm talking about the exe. it's always been the issue of only being able to change certain values, for example to change the number of subs or foreigners. When having to alter fixtures or competition structures, it was very diificult to add new features, or to make changes that required more code, as you only had a limited "code space". But it is now possible to add more such space, to add code in assembly and have additional "native" competitions, on top of those already available originally.
    if it's workable then it sounds good but it's all over my head I'm afraid.

  9. #7

    Join Date
    26-09-18
    Location
    Brazil
    Posts
    729
    vCash
    698
    @saturn how helpful do you think this can be for future patches?

  10. #8

    Join Date
    14-04-14
    Location
    Romania
    Posts
    4
    vCash
    4000
    Brief update on the progress: I understood how to add nations to the first screen, where one chooses the countries where to play; to achieve this I had to add to the exe, beyond the already additional ""code"" section, also a new ""data"" section (i.e. similar to where text strings are stored, but also where temporary values are stored during game).
    For the new code that adds, for example, Austria, I have to reference some new ""data"" locations, but because the game expected these to be at other addresses, I had to change all data references in some large areas of code to point to the new ""data"" section, for then to be able to redesign the sequences and let the code run the same loops, at the same location intervals, and maintaining the same relativity between addresses. So now I should be very close to add a new country - Austria - with a structure replicating the one of Holland's, for testing purposes for now (so using Austrian clubs, but on Holland's championship and cup formats) - I really hope to get a stable version by end of week. Once that works, only then we can really think big, though it appears to be not that simple to add workable code and features...

  11. The Following 4 Users Say Thank You to mihaigrad For This Useful Post:


  12. #9

    Join Date
    18-03-14
    Posts
    1,209
    vCash
    7700
    Quote Originally Posted by MadScientist View Post
    @saturn how helpful do you think this can be for future patches?
    Yes, definitely has the potential to be very useful. For the moment a lot of new code can be added to the Credits section (quite a big section and all disabled by removing one CALL). But the addition of potenitally unlimited space would of course be great.

    Quote Originally Posted by mihaigrad View Post
    Brief update on the progress: I understood how to add nations to the first screen, where one chooses the countries where to play; to achieve this I had to add to the exe, beyond the already additional ""code"" section, also a new ""data"" section (i.e. similar to where text strings are stored, but also where temporary values are stored during game).
    For the new code that adds, for example, Austria, I have to reference some new ""data"" locations, but because the game expected these to be at other addresses, I had to change all data references in some large areas of code to point to the new ""data"" section, for then to be able to redesign the sequences and let the code run the same loops, at the same location intervals, and maintaining the same relativity between addresses. So now I should be very close to add a new country - Austria - with a structure replicating the one of Holland's, for testing purposes for now (so using Austrian clubs, but on Holland's championship and cup formats) - I really hope to get a stable version by end of week. Once that works, only then we can really think big, though it appears to be not that simple to add workable code and features...
    Sounds promising! Perhaps try using South Korea's league structure, it's probably the most straightforward in the game.

  13. The Following 5 Users Say Thank You to saturn For This Useful Post:


  14. #10

    Join Date
    24-02-13
    Posts
    13
    vCash
    500
    Modifing main cm0102.exe is not nessesary.
    I wrote wrapper as dll, is loaded on cm started.

    Explaint: cm0102.exe load funtion DirectDrawCreate from ddraw.dll.
    Orginal file (ddraw.dll) is in Windows/System32, but if add file named ddraw.dll in cm0102 working directory this will by loaded first.
    My file wrap the oryginal function DirectDrawCreate and load the oryginal file from windows.
    This way you can load any function writed in C/C++. (ASM is not nessasary more).

    In example i redraw original "Web Sites" button text with my text.
    Source code in C++ (Visual Studio Solution)

    Link to file and source :
    DOWNLOAD

  15. The Following 4 Users Say Thank You to Anoxic For This Useful Post:


  16. #11

    Join Date
    26-09-18
    Location
    Brazil
    Posts
    729
    vCash
    698
    Quote Originally Posted by Anoxic View Post
    Modifing main cm0102.exe is not nessesary.
    I wrote wrapper as dll, is loaded on cm started.

    Explaint: cm0102.exe load funtion DirectDrawCreate from ddraw.dll.
    Orginal file (ddraw.dll) is in Windows/System32, but if add file named ddraw.dll in cm0102 working directory this will by loaded first.
    My file wrap the oryginal function DirectDrawCreate and load the oryginal file from windows.
    This way you can load any function writed in C/C++. (ASM is not nessasary more).

    In example i redraw original "Web Sites" button text with my text.
    Source code in C++ (Visual Studio Solution)

    Link to file and source :
    DOWNLOAD
    This is great! And thanks for sharing VS project

    I think tapani did something like that for the idle sensivity patch, or for something in his 3.xx patch. For sure it is promising if used with creativity

  17. The Following User Says Thank You to MadScientist For This Useful Post:


  18. #12

    Join Date
    03-03-12
    Location
    Italy
    Posts
    752
    vCash
    1600
    Quote Originally Posted by MadScientist View Post
    This is great! And thanks for sharing VS project

    I think tapani did something like that for the idle sensivity patch, or for something in his 3.xx patch. For sure it is promising if used with creativity
    Mihaigrad wrote me saying he experienced 2 errors but he's working about!!! Obviously Anoxic gave us a magic touch!!

  19. The Following User Says Thank You to Ratio For This Useful Post:


  20. #13

    Join Date
    26-09-18
    Location
    Brazil
    Posts
    729
    vCash
    698
    Quote Originally Posted by Ratio View Post
    Mihaigrad wrote me saying he experienced 2 errors but he's working about!!! Obviously Anoxic gave us a magic touch!!
    yeah, each of the ideas are great and can be used differently.

    I think mihaigrad's solution (add space to .exe) is more suited for when you want to increment something that already exists in the .exe (like create a new league as he is doing) as you would duplicate existing assembly league code and make adjusts to it.
    And Anoxic's solution (.dll) is more suited for adding some new functionality different than already exists in the .exe (like the idle sensivity from tapani) because its easier to create new C++ code than assembly code.
    And more uses can be invented with creativity for each solution.

  21. The Following User Says Thank You to MadScientist For This Useful Post:


  22. #14

    Join Date
    30-03-12
    Location
    Cracow , Poland
    Posts
    25
    vCash
    500
    I keep my fingers crossed for you guys. And for your work-life balance too

  23. #15

    Join Date
    08-06-18
    Posts
    30
    vCash
    700
    I am curious, guys. Is it possible to duplicate the structure of a league or cup, making another league without replacing? Or not? Anyone came close to do this?

  24. #16

    Join Date
    18-03-14
    Posts
    1,209
    vCash
    7700
    Tapani having both the Northern League Premier and Welsh league in his 3.xx patches is probably the closest anyone's got. I've thought about it before but never tried it. As well as creating the new league and cup code you'd also have to create things like the new nation's awards, discipline/ruling body, transfer rules, plus edit the following parts of the code (very likely to be more):
    award_manager
    discipline
    hall_of_fame
    key_nation
    setup x3
    transfer_manager

  25. #17

    Join Date
    08-06-18
    Posts
    30
    vCash
    700
    Quote Originally Posted by saturn View Post
    Tapani having both the Northern League Premier and Welsh league in his 3.xx patches is probably the closest anyone's got. I've thought about it before but never tried it. As well as creating the new league and cup code you'd also have to create things like the new nation's awards, discipline/ruling body, transfer rules, plus edit the following parts of the code (very likely to be more):
    award_manager
    discipline
    hall_of_fame
    key_nation
    setup x3
    transfer_manager
    Thanks, saturn. So it's extremely dificult! rs
    I make part of a brazilian community that helps to keep CM 01/02 alive in Brazil. I have done some substitutions of leagues that I don't used to play to other ones ( sulamericans, such as Colombia, Chile, Uruguay... ) based on the march update.
    One easier thing that can be done ( at least I think!), but I don't know how, is to make the correct teams of the two asian leagues that we have in the game participating in Asian Club Championship.
    Actually if we choose to start a new game with these two leagues, only clubs of one of then go to the continental correctlly and not the other.
    Is it possible and easy to fix this? With sulamerican leagues we don't have this problem!
    Thanks to the oportunity and I'm sorry to my terrible english...

  26. #18

    Join Date
    18-03-14
    Posts
    1,209
    vCash
    7700
    I know the bug you're talking about but unfortunately no, I don't know how to fix it.

  27. #19

    Join Date
    08-06-18
    Posts
    30
    vCash
    700
    Quote Originally Posted by saturn View Post
    I know the bug you're talking about but unfortunately no, I don't know how to fix it.
    I imagined. Without the source code some modifications are almost impossible.
    But one thing, if the guys make a comparison between the versions 3.90 and the 3.98 of CM 01/02 (in version 3.98 has been added the Korean league), wouldn't be possible to do the same in the code to make a new league?
    And thanks to everyone here. What you have done with the game was amazing!
    Last edited by luisfrjgua; 02-11-19 at 12:29 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •