#Correct way to revert this for loop

22 messages · Page 1 of 1 (latest)

gloomy crypt
#
  for (size_t i = 0; i < 4; i++) {
    param_1[i] = param_1[i] - *(int *)(&DAT_0040f060 + i * 4);
  }```
What is the correct way to revert this for loop ? Do I just need to replace minus sign with plus sign ? Do I need to invert left attribute and right attribute ?
round sorrelBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.

gloomy crypt
#

I don't think so, basically imagine it is an encrypt process, I need to decrypt this process, I think what your code is doing is just reapply the encryption starting from the bottom

sterile wharf
#

ah got it sorry

#

I'm guessing you just need to add back * (int * ) (&DAT_0040f060 + local_20 * 4);

gloomy crypt
#

Ok thanks, btw do you think you can guide me on the equivalent of c *(int *)(&DAT_0040f060 + i * 4) not sure if it's the same as DAT_0040f060[i]

#

DAT_0040f060 is unsigned char array filled with bytes

round sorrelBOT
#

@gloomy crypt Has your question been resolved? If so, run !solved :)

low seal
#

because then instead of *(int *)(&DAT_0040f060 + i * 4) it would be DAT_0040f060[i]

gloomy crypt
# low seal i think `DAT_0040f060` is probably actually an `int` array

Thanks and very last question :
Is

    uVar1 = FUN_004016ff(*(byte *)(local_1c + (int)param_1),
                         (ushort)*(byte *)((int)param_1 + local_1c + 1));
    *(char *)((int)param_1 + local_1c) = (char)uVar1;```

equivalent to :

```c
param_1[local_1c] = FUN_004016ff(param_1[local_1c], param_1[local_1c + 1]);
low seal
#

it might help if you knew what these represented and could give them names

gloomy crypt
#

actually local_1c is the for loop iterator lol (i variable basically)

#
  for (local_1c = 0; local_1c < 0x40; local_1c = local_1c + 2) {
    uVar1 = FUN_004016ff(*(byte *)(local_1c + (int)param_1),
                         (ushort)*(byte *)((int)param_1 + local_1c + 1));
    *(char *)((int)param_1 + local_1c) = (char)uVar1;
  }``` that's the whole loop
low seal
#

hmmmmmmmmmmmmmmm

gloomy crypt
#

param_1 is int *

#

local_1c uint

#

FUN_004016ff takes (uint8_t param_1, short param_2)

low seal
#

it's ((byte*)param_1)[local_1c]

gloomy crypt
#

Yeah I've tried it doesn't change anything, i have no idea why it doesn't work