Advertisement
MattFiler

add_resource_ptr

Jan 23rd, 2022
828
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.26 KB | None | 0 0
  1. bool __thiscall
  2. CATHODE::ResourceDatabase::add_resource_ptr(ResourceDatabase *this,uint param_1,MemoryPtr *param_2)
  3.  
  4. {
  5.   int *piVar1;
  6.   MemoryAllocationBase **ppMVar2;
  7.   uint uVar3;
  8.   char cVar4;
  9.   bool bVar5;
  10.   MemoryAllocationBase *pMVar6;
  11.   long lVar7;
  12.   uint uVar8;
  13.   int iVar9;
  14.   uint uVar10;
  15.   uint uVar11;
  16.   uint local_48 [2];
  17.   MemoryAllocationBase *local_40;
  18.   MemoryAllocationBase *local_38;
  19.  
  20.   if (param_1 == 0xffffffff) goto LAB_10180a7c0;
  21.   local_40 = (MemoryAllocationBase *)0x0;
  22.   pMVar6 = *(MemoryAllocationBase **)param_2;
  23.   if (pMVar6 != (MemoryAllocationBase *)0x0) {
  24.     piVar1 = (int *)(pMVar6 + 8);
  25.     do {
  26.       cVar4 = '\x01';
  27.       bVar5 = (bool)ExclusiveMonitorPass(piVar1,0x10);
  28.       if (bVar5) {
  29.         *piVar1 = *piVar1 + 1;
  30.         cVar4 = ExclusiveMonitorsStatus();
  31.       }
  32.       local_40 = pMVar6;
  33.     } while (cVar4 != '\0');
  34.   }
  35.   local_38 = (MemoryAllocationBase *)0x0;
  36.   lVar7 = *(long *)this;
  37.   local_48[0] = param_1;
  38.   if ((lVar7 == 0) || (*(int *)(lVar7 + 0xc) == 0)) {
  39. LAB_10180a728:
  40.     ArrayPtr<CATHODE::ResourceDatabase::ResourceKey>::push_sort
  41.               ((ArrayPtr_CATHODE__ResourceDatabase__ResourceKey_ *)this,(ResourceKey *)local_48);
  42.   }
  43.   else {
  44.     uVar3 = *(uint *)(lVar7 + 0xc);
  45.     uVar8 = uVar3;
  46.     if (uVar3 == 0) {
  47. LAB_10180a674:
  48.       if (uVar8 == 0xffffffff) goto LAB_10180a728;
  49.     }
  50.     else {
  51.       uVar8 = uVar3 | uVar3 >> 1;
  52.       uVar8 = uVar8 | uVar8 >> 2;
  53.       uVar8 = uVar8 | uVar8 >> 4;
  54.       uVar8 = uVar8 | uVar8 >> 8;
  55.       uVar8 = uVar8 | uVar8 >> 0x10;
  56.       uVar8 = ((uVar8 & 0xaaaaaaaa) >> 1) + (uVar8 & 0x55555555);
  57.       uVar8 = ((uVar8 & 0xcccccccc) >> 2) + (uVar8 & 0x33333333);
  58.       uVar8 = ((uVar8 & 0xf0f0f0f0) >> 4) + (uVar8 & 0xf0f0f0f);
  59.       uVar8 = ((uVar8 & 0xff00ff00) >> 8) + (uVar8 & 0xff00ff);
  60.       iVar9 = -((uVar8 >> 0x10) + (uVar8 & 0xffff));
  61.       if (iVar9 != 0) {
  62.         uVar10 = 1 << (ulong)((iVar9 + 0x20U ^ 0x1f) & 0x1f);
  63.         uVar8 = uVar10 - 1;
  64.         do {
  65.           while( true ) {
  66.             uVar11 = uVar8;
  67.             if (uVar3 <= uVar8) {
  68.               uVar11 = *(int *)(lVar7 + 0xc) - 1;
  69.             }
  70.             uVar10 = uVar10 >> 1;
  71.             uVar11 = *(uint *)(*(long *)(lVar7 + 0x10) + (ulong)uVar11 * 0x18);
  72.             if (uVar11 < param_1) break;
  73.             if (uVar11 <= param_1) goto LAB_10180a668;
  74.             uVar8 = uVar8 - uVar10;
  75.             bVar5 = iVar9 == -1;
  76.             iVar9 = iVar9 + 1;
  77.             if (bVar5) goto LAB_10180a668;
  78.           }
  79.           uVar8 = uVar8 + uVar10;
  80.           bVar5 = iVar9 != -1;
  81.           iVar9 = iVar9 + 1;
  82.         } while (bVar5);
  83. LAB_10180a668:
  84.         if (uVar3 <= uVar8) {
  85.           uVar8 = uVar3 - 1;
  86.         }
  87.         goto LAB_10180a674;
  88.       }
  89.       uVar8 = 0;
  90.     }
  91.     if (*(uint *)(*(long *)(lVar7 + 0x10) + (ulong)uVar8 * 0x18) != param_1) goto LAB_10180a728;
  92.     ppMVar2 = (MemoryAllocationBase **)(*(long *)(lVar7 + 0x10) + (ulong)uVar8 * 0x18 + 0x10);
  93.     if (ppMVar2 != (MemoryAllocationBase **)param_2) {
  94.       pMVar6 = *ppMVar2;
  95.       if (pMVar6 != (MemoryAllocationBase *)0x0) {
  96.         if (*(int *)(pMVar6 + 8) == 1) {
  97.           (**(code **)**(undefined8 **)(pMVar6 + 0x10))();
  98.           pMVar6 = *ppMVar2;
  99.         }
  100.         piVar1 = (int *)(pMVar6 + 8);
  101.         do {
  102.           iVar9 = *piVar1;
  103.           cVar4 = '\x01';
  104.           bVar5 = (bool)ExclusiveMonitorPass(piVar1,0x10);
  105.           if (bVar5) {
  106.             *piVar1 = iVar9 + -1;
  107.             cVar4 = ExclusiveMonitorsStatus();
  108.           }
  109.         } while (cVar4 != '\0');
  110.         if (iVar9 + -1 == 0) {
  111.           MemoryAllocationBase::release(pMVar6);
  112.         }
  113.         *ppMVar2 = (MemoryAllocationBase *)0x0;
  114.       }
  115.       pMVar6 = *(MemoryAllocationBase **)param_2;
  116.       if (pMVar6 != (MemoryAllocationBase *)0x0) {
  117.         *ppMVar2 = pMVar6;
  118.         piVar1 = (int *)(pMVar6 + 8);
  119.         do {
  120.           cVar4 = '\x01';
  121.           bVar5 = (bool)ExclusiveMonitorPass(piVar1,0x10);
  122.           if (bVar5) {
  123.             *piVar1 = *piVar1 + 1;
  124.             cVar4 = ExclusiveMonitorsStatus();
  125.           }
  126.         } while (cVar4 != '\0');
  127.       }
  128.     }
  129.   }
  130.   if (local_38 != (MemoryAllocationBase *)0x0) {
  131.     if (*(int *)(local_38 + 8) == 1) {
  132.       (**(code **)**(undefined8 **)(local_38 + 0x10))();
  133.     }
  134.     piVar1 = (int *)(local_38 + 8);
  135.     do {
  136.       iVar9 = *piVar1;
  137.       cVar4 = '\x01';
  138.       bVar5 = (bool)ExclusiveMonitorPass(piVar1,0x10);
  139.       if (bVar5) {
  140.         *piVar1 = iVar9 + -1;
  141.         cVar4 = ExclusiveMonitorsStatus();
  142.       }
  143.     } while (cVar4 != '\0');
  144.     if (iVar9 + -1 == 0) {
  145.       MemoryAllocationBase::release(local_38);
  146.     }
  147.     local_38 = (MemoryAllocationBase *)0x0;
  148.   }
  149.   if (local_40 != (MemoryAllocationBase *)0x0) {
  150.     if (*(int *)(local_40 + 8) == 1) {
  151.       (**(code **)**(undefined8 **)(local_40 + 0x10))();
  152.     }
  153.     piVar1 = (int *)(local_40 + 8);
  154.     do {
  155.       iVar9 = *piVar1;
  156.       cVar4 = '\x01';
  157.       bVar5 = (bool)ExclusiveMonitorPass(piVar1,0x10);
  158.       if (bVar5) {
  159.         *piVar1 = iVar9 + -1;
  160.         cVar4 = ExclusiveMonitorsStatus();
  161.       }
  162.     } while (cVar4 != '\0');
  163.     if (iVar9 + -1 == 0) {
  164.       MemoryAllocationBase::release(local_40);
  165.     }
  166.   }
  167. LAB_10180a7c0:
  168.   return param_1 != 0xffffffff;
  169. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement