Jump to content

dreadylein

Members
  • Posts

    179
  • Joined

  • Last visited

Posts posted by dreadylein

  1. Does anyone know if the ModPatcher author ever made his code open-source? ModPatcher was pretty convenient. However, if I have to instruct people to copy over the DefaultGameCore.ini file in the local folder and patch their EXE then that solution will work as well.

     

    I never bothered with it and the code was a damn mess anyway ;)

    But there is no Obfuscation so decompiling it should yield pretty proper code.

     

     

    But the only intresting parts are this:

    
            [DllImport("kernel32", CharSet = CharSet.Unicode)]
            private static extern IntPtr BeginUpdateResource(String pFileName, bool
            bDeleteExistingResources);
    
            [DllImport("kernel32", CharSet = CharSet.Unicode, SetLastError = true)]
            private static extern int UpdateResource(IntPtr hUpdate,
            IntPtr lpType, Int16 lpName, Int16
            wLanguage, Byte[] lpData, int cbData);
    
            [DllImport("kernel32", SetLastError = true)]
            private static extern int EndUpdateResource(IntPtr hUpdate, bool fDiscard);
    
    
        try
                {
    
                   
                    string comp = @buildpath(); //path
                    log("updateres var: " + comp);
                    log("getmodfile: " + getmodfile());
                    IntPtr hResource = BeginUpdateResource(comp, false);
                    System.IO.FileStream fss =
                    new System.IO.FileStream(getmodfile(), System.IO.FileMode.Open);
    
                    System.IO.BinaryReader fileReader =
                    new System.IO.BinaryReader(fss);
    
                    Byte[] ba =
                    fileReader.ReadBytes((int)fss.Length);
    
                    UpdateResource(hResource, (IntPtr)10, 1020, 1033, ba,
                    ba.Length);
    
                    EndUpdateResource(hResource, false);
    
                    fileReader.Close();
                    fss.Close();
                }
                catch
                {
                    MessageBox.Show("Error @ patching");
                }
    

    Simply let Windows do the job for you :)

  2. Amineri gave a good explanation :)

     

    @johnnylump

     

    The biggest difference between compiled nativ code and bytecode that runs in any sort of interpreter/vm is:

     

    1. Bytecode has normaly more highlevel informations

    2. Bytecode has less optimations as most of it is done by optimizing the VM code.

     

    This leads to some problems for the modding community:

     

    Reversing Binary Code needs a good understanding of the host system and a quiet big skillset.

    If i remember right here a quiet some people able todo it, but it is always realy timeconsuming.

     

    There is no way to get highlevel Code out of a Binary, as many informations are striped by the compiler(as example variable names), additional optimazations done by the compiler make the code we can see even more unreadable(the same codepart in highlevel can translate to two quiet different parts in the binary, as example the code calls function a on two different points, but the compilere decides it would be faster to directly inline them)

    now the binary code would change from:

     

    Function b:

    bla

    call Function a

    bla

     

    Function c:

    bla

    call Function a

    bla

     

    to

     

    Function b:

    bla1

    code of Function a

    bla2

     

    Function c:

    bla3

    code of Function a

    bla4

     

    In the next step of the opimization the Compiler looks at the Code and mix him for getting a better perfomance out of it ,backing together the whole code of Function b and c

     

    In the End it would look like:

     

    Function b:

    bla5

     

    Function c:

    bla6

     

    And there are tons of codepart where such things can happen.

    Additional the Work must be done on every different platform, as different compileres for different platforms give totaly different code(see Amineri`s Response).

     

    Reversing is the art of rebuilding a cow out of hamburgers ;)

     

    Are there any nativ Functions which are absolutly needed to be moddable ?

  3. Anyone up for some fun ?

    My time is kinda limited at the moment, but my proof of concept is properly working, the main point i didnt worked further on it was more or less no intressted in it in the official forum.

     

    Are there intressted people ?

    Any Programmers willing to help ?

     

    :)

  4. i think it was bokatau who asked about how nativ functions are matched up from the upk code to the engine, not totaly sure, but as it could be intressting for more people i decided to just post it in a new Thread.

     

    Iam unsure if its because of an Old Binary or if they still include the Debug infos (hey if you did that by decession :-* )

     

    .data:01CFBAA8 off_1CFBAA8     dd offset aUxcomengineexe ; DATA XREF: sub_B56850+31Ao
    .data:01CFBAA8                                         ; "UXComEngineexecFindClassType"
    .data:01CFBAAC                 dd offset sub_96D2E0
    .data:01CFBAB0                 dd offset aUxcomenginee_0 ; "UXComEngineexecAddStreamingTextureSlave"...
    .data:01CFBAB4                 dd offset sub_693E70
    .data:01CFBAB8                 dd offset aUxcomenginee_1 ; "UXComEngineexecIsPointInTriangle"
    .data:01CFBABC                 dd offset sub_10E2C40
    .data:01CFBAC0                 dd offset aUxcomenginee_2 ; "UXComEngineexecGetCurrentDeviceID"
    .data:01CFBAC4                 dd offset sub_CE8A00
    .data:01CFBAC8                 dd offset aUxcomenginee_3 ; "UXComEngineexecGetCurrentTime"
    .data:01CFBACC                 dd offset sub_635C70
    .data:01CFBAD0                 dd offset aUxcomenginee_4 ; "UXComEngineexecHasStorageDeviceBeenRemo"...
    .data:01CFBAD4                 dd offset sub_91C5B0
    .data:01CFBAD8                 dd offset aUxcomenginee_5 ; "UXComEngineexecSetCurrentDeviceID"
    .data:01CFBADC                 dd offset sub_1058130
    .data:01CFBAE0                 dd offset aUxcomenginee_6 ; "UXComEngineexecUnpauseMovie"
    .data:01CFBAE4                 dd offset sub_645B20
    .data:01CFBAE8                 dd offset aUxcomenginee_7 ; "UXComEngineexecPauseMovie"
    .data:01CFBAEC                 dd offset sub_7A08A0
    .data:01CFBAF0                 dd offset aUxcomenginee_8 ; "UXComEngineexecStopCurrentMovie"
    .data:01CFBAF4                 dd offset sub_827EC0
    .data:01CFBAF8                 dd offset aUxcomenginee_9 ; "UXComEngineexecIsLoadingMoviePlaying"
    .data:01CFBAFC                 dd offset sub_BE7A30
    .data:01CFBB00                 dd offset aUxcomengine_10 ; "UXComEngineexecIsAnyMoviePlaying"
    .data:01CFBB04                 dd offset sub_80EF70
    .data:01CFBB08                 dd offset aUxcomengine_11 ; "UXComEngineexecIsMoviePlaying"
    .data:01CFBB0C                 dd offset sub_10D12A0
    .data:01CFBB10                 dd offset aUxcomengine_12 ; "UXComEngineexecIsWaitingForMovie"
    .data:01CFBB14                 dd offset sub_6CA880
    .data:01CFBB18                 dd offset aUxcomengine_13 ; "UXComEngineexecWaitForMovie"
    .data:01CFBB1C                 dd offset sub_DC4E20
    .data:01CFBB20                 dd offset aUxcomengine_14 ; "UXComEngineexecPlayMovie"
    .data:01CFBB24                 dd offset sub_B944B0
    .data:01CFBB28                 dd offset aUxcomengine_15 ; "UXComEngineexecPlayLoadMapMovie"
    .data:01CFBB2C                 dd offset sub_10C5AF0
    .data:01CFBB30                 dd offset aUxcomengine_16 ; "UXComEngineexecPlaySpecificLoadingMovie"...
    .data:01CFBB34                 dd offset sub_10C0630
    .data:01CFBB38                 dd offset aUxcomengine_17 ; "UXComEngineexecGetARandomSeed"
    .data:01CFBB3C                 dd offset sub_B564A0
    .data:01CFBB40                 dd offset aUxcomengine_18 ; "UXComEngineexecSyncVRand"
    .data:01CFBB44                 dd offset sub_10D9AA0
    .data:01CFBB48                 dd offset aUxcomengine_19 ; "UXComEngineexecSyncFRand"
    .data:01CFBB4C                 dd offset sub_D9B430
    .data:01CFBB50                 dd offset aUxcomengine_20 ; "UXComEngineexecSyncRand"
    .data:01CFBB54                 dd offset sub_10690A0
    .data:01CFBB58                 dd offset aUxcomengine_21 ; "UXComEngineexecGetSyncSeed"
    .data:01CFBB5C                 dd offset sub_A87F40
    .data:01CFBB60                 dd offset aUxcomengine_22 ; "UXComEngineexecSetRandomSeeds"
    .data:01CFBB64                 dd offset sub_CC6EC0
    .data:01CFBB68                 dd offset aUxcomengine_23 ; "UXComEngineexecGetMaxSaveSizeInBytes"
    .data:01CFBB6C                 dd offset sub_65B650
    .data:01CFBB70                 dd offset aUxcomengine_24 ; "UXComEngineexecGetStringCRC"
    .data:01CFBB74                 dd offset sub_F15420
    .data:01CFBB78                 dd offset aUxcomengine_25 ; "UXComEngineexecGetMCP"
    .data:01CFBB7C                 dd offset sub_C42900
    
    

     

    The offsets arent usefull as this is an outdated Binary, but finding this tables again should be easy (there are a LOT of them ;) )

  5. Smashed together a little Patcher, but as i dont have xcom installed here i cant test it, would be nice if anyone could drop me a line if he wants to test it :smile:

    ps. nearly forgot :wink: grats to this awesome find, quite neat, we should have thought of this before hehe



    Another edit:

     

    https://www.dropbox.com/s/0q48wn3urn6kges/patchpatch.rar

     

    Reeealy Messy, dont judge me :P

    As explained iam not able to test it, but in theory it should patch out phone home, the config stuff and sha1 checks for xcomgame.upk, xcomstrategygame.upk and xcomshell.upk.

     

     

    Needs .net 4.5

    Needs to be in the same directory as the xcom binary, should produce a xcommodded.exe or smth like this :P

     

    I dont have a clue if this all is working :P in theory it should but meh ^^

  6. There is no way to patch Another File into the Binary :)

    Working as intended as we didnt wanted to supply a way for patching mp data

    Send me a Pn, why you need it :)

  7. Did you check for refrences to the adress of this string ? :)

     

    Greyer Area mhm, tbh hooking into a running program would be less of a problem then what we do now, altering a binary ;)

    DMCA Countrys is another Topic, but they wouldnt be allowed to reverse anything of the game, like the upks anyway :P

  8. as you have the proper arguments for calling the function allready, i would suggest starting a framework for hooking the nativ functions.

     

    As it sounds it shouldnt be terrible hard to just replace the function with what you wanted, or mod the return values based on the input values.

  9. @bokauk

     

    not sure how the engine handles this, guess there ARE somewhere informations about the nativ functions

    But why the trouble ? :P

    Just put the binary into any decent disassambler and look for the xrefs to the function string, should bring you to the right point in no time normaly

  10. neat work eliot :)

     

    @Fogia_99

     

    Altering the Behavior of a nativ Function isnt that hard, we did it pretty much on the first days for getting acess to the debug stuff before we were able to understand enough bytecode to change it :P

    All you have todo is Hooking the Function.

    So you change

    BytecodeInterpreter <--> nativ Function

    to

    Bytecode interpreter <--> your function <--> nativ Function

     

    Then just alter the Return Values as you like

×
×
  • Create New...