How does it calculate a checksum?

46 views Asked by At

in Ghidra I found a function that calculates a checksum and checks it against a checksum in a protobuf I'm stuck in this function for days and I tried using frida to get the ret value but it doesn't return. I know it's void but on another function that called this calculateBackupChecksum it does return a value

    this_00 = (GameController *)ei::Backup::Backup(aBSta ck_4d8,(Backup *)param_1);
    lVar44 = calculateBackupChecksum(this_00,(Backup)t his_00);
    lVar8 = *(longlong *)(param_1 + 0x88);
    ei::Backup::~Backup(aBStack_4d8);
    if (lVar44 != lVar8) {
      // Checksum invalid ret do return 
    }
void __thiscall GameController::calculateBackupChecksum (GameController *this,Backup param_1)

{
  int iVar1;
  int iVar2;
  uint uVar3;
  uint uVar4;
  uint uVar5;
  undefined4 extraout_r1;
  uint uVar6;
  undefined4 uVar7;
  uint uVar8;
  int iVar9;
  undefined4 uVar10;
  uint uVar11;
  undefined4 uVar12;
  undefined4 uVar13;
  double dVar14;
  double dVar15;
  undefined4 in_stack_fffffd68;
  undefined4 in_stack_fffffd6c;
  uint local_270;
  Backup aBStack_268 [76];
  Backup_Simulation *local_21c;
  Backup_Simulation **local_218;
  int local_214;
  Backup aBStack_1d0 [76];
  Backup_Simulation *local_184;
  Backup_Simulation **local_180;
  int local_17c;
  Backup_Simulation aBStack_138 [64];
  uint local_f8;
  int iStack_f4;
  int local_28;
  
  local_28 = __stack_chk_guard;
  iVar9 = *(int *)(param_1 + 0x44);
  if (iVar9 == 0) {
    dVar14 = *(double *)(*(int *)(DAT_00cd9bf0 + 0x44) + 0 x70);
    if (dVar14 != 0.0 && dVar14 < 0.0 == NAN(dVar14)) goto  LAB_007196be;
  }
  else {
    dVar14 = *(double *)(iVar9 + 0x70);
    if (dVar14 != 0.0 && dVar14 < 0.0 == NAN(dVar14)) {
LAB_007196be:
      iVar1 = iVar9;
      if (iVar9 == 0) {
        iVar1 = *(int *)(DAT_00cd9bf0 + 0x44);
      }
      uVar7 = (undefined4)*(undefined8 *)(iVar1 + 0x70);
      log10((double)CONCAT44(in_stack_fffffd6c,in_stack_ff fffd68));
      dVar15 = (double)CONCAT44(extraout_r1,uVar7);
      dVar14 = 0.0;
      if (dVar15 != 0.0 && dVar15 < 0.0 == NAN(dVar15)) {
        dVar14 = dVar15;
      }
      local_270 = (uint)(longlong)(dVar14 * 100.0);
      goto joined_r0x0071971c;
    }
  }
  local_270 = 0;
joined_r0x0071971c:
  if (iVar9 == 0) {
    iVar9 = *(int *)(DAT_00cd9bf0 + 0x44);
  }
  uVar7 = *(undefined4 *)(iVar9 + 0x18);
  uVar10 = *(undefined4 *)(iVar9 + 0x1c);
  uVar13 = *(undefined4 *)(iVar9 + 0x30);
  uVar12 = *(undefined4 *)(iVar9 + 0x34);
  ei::Backup::Backup(aBStack_1d0,(Backup *)param_1);
  if (local_17c < 1) {
    if (local_184 == (Backup_Simulation *)0x0) {
      local_184 = *(Backup_Simulation **)(DAT_00cd9bf0 +  0x4c);
    }
    ei::Backup_Simulation::Backup_Simulation(aBStack_13 8,local_184);
  }
  else {
    ei::Backup_Simulation::Backup_Simulation(aBStack_13 8,*local_180);
  }
  iVar9 = *(int *)(param_1 + 0x60);
  if (iVar9 == 0) {
    iVar9 = *(int *)(DAT_00cd9bf0 + 0x60);
  }
  ei::Backup_Simulation::~Backup_Simulation(aBStack_13 8);
  ei::Backup::~Backup(aBStack_1d0);
  iVar9 = *(int *)(param_1 + 0x44);
  if (iVar9 == 0) {
    iVar9 = *(int *)(DAT_00cd9bf0 + 0x44);
  }
  uVar8 = *(uint *)(iVar9 + 0x18);
  iVar1 = *(int *)(iVar9 + 0x1c);
  uVar11 = *(uint *)(iVar9 + 0x30);
  iVar9 = *(int *)(iVar9 + 0x34);
  ei::Backup::Backup(aBStack_268,(Backup *)param_1);
  if (local_214 < 1) {
    if (local_21c == (Backup_Simulation *)0x0) {
      local_21c = *(Backup_Simulation **)(DAT_00cd9bf0 +  0x4c);
    }
    ei::Backup_Simulation::Backup_Simulation(aBStack_13 8,local_21c);
  }
  else {
    ei::Backup_Simulation::Backup_Simulation(aBStack_13 8,*local_218);
  }
  iVar2 = *(int *)(param_1 + 0x60);
  if (iVar2 == 0) {
    iVar2 = *(int *)(DAT_00cd9bf0 + 0x60);
  }
  uVar6 = *(uint *)(iVar2 + 0x34);
  ei::Backup_Simulation::~Backup_Simulation(aBStack_13 8);
  ei::Backup::~Backup(aBStack_268);
  uVar3 = uVar8 + local_270;
  uVar4 = uVar3 + uVar11;
  uVar5 = uVar4 + local_f8;
  if (__stack_chk_guard != local_28) {
                    /* WARNING: Subroutine does not return */
    __stack_chk_fail(uVar5 + uVar6,
                     iVar1 + ((int)local_270 >> 0x1f) + (uint)CARR Y4(uVar8,local_270) + iVar9 +
                     (uint)CARRY4(uVar3,uVar11) + iStack_f4 + (ui nt)CARRY4(uVar4,local_f8) +
                     ((int)uVar6 >> 0x1f) + (uint)CARRY4(uVar5,uV ar6));
  }
  return;
}
0

There are 0 answers