
4.46 patched

.text:0050339A 80 3D 1C 45 53 00 00                 cmp     byte_53451C, 0
.text:005033A1 0F 84 B2 0E 00 00                    jz      loc_504259
.text:005033A7 E8 28 F8 EF FF                       call    @System@Randomize$qqrv ; System::Randomize(void)
.text:005033AC A1 80 48 53 00                       mov     eax, lpAccessMode
.text:005033B1 80 38 02                             cmp     byte ptr [eax], 2
.text:005033B4 75 47                                jnz     short loc_5033FD
.text:005033B6 8B 05 78 74 53 00                    mov     eax, dword ptr LenLBA64
.text:005033BC 8B 15 7C 74 53 00                    mov     edx, dword ptr LenLBA64+4
.text:005033C2 52                                   push    edx
.text:005033C3 50                                   push    eax
.text:005033C4 0F B7 05 64 74 53 00                 movzx   eax, SectorsInBlock
.text:005033CB 33 D2                                xor     edx, edx
.text:005033CD 29 04 24                             sub     dword ptr [esp+74h+size], eax     ; LenLBA64 -= SectorsInBlock
.text:005033D0 19 54 24 04                          sbb     dword ptr [esp+74h+size+4], edx
.text:005033D4 58                                   pop     eax
.text:005033D5 5A                                   pop     edx
.text:005033D6 E8 75 44 03 04                       call    Random64                 ; <--- original: "call  System_RandInt"
.text:005033DB 90                                   nop                              ; <--- original: "cdq"
.text:005033DC 03 05 10 73 53 00                    add     eax, dword ptr Beg_LBA64
.text:005033E2 13 15 14 73 53 00                    adc     edx, dword ptr Beg_LBA64+4
.text:005033E8 71 05                                jno     short loc_5033EF
.text:005033EA E8 B5 07 F0 FF                       call    System_Error_5
.text:005033EF                      ; ---------------------------------------------------------------------------
.text:005033EF
.text:005033EF                      loc_5033EF:                             ; CODE XREF: sub_5032F8+F0j
.text:005033EF 89 05 08 73 53 00                    mov     dword ptr CurLBA64, eax
.text:005033F5 89 15 0C 73 53 00                    mov     dword ptr CurLBA64+4, edx
.text:005033FB EB 45                                jmp     short loc_503442


4.46 patched

.text:00502492 80 3D BC 44 53 00 00                 cmp     byte_5344BC, 0
.text:00502499 0F 84 EC 05 00 00                    jz      loc_502A8B
.text:0050249F A1 E0 4C 53 00                       mov     eax, off_534CE0
.text:005024A4 8B 00                                mov     eax, [eax]
.text:005024A6 E8 0D 18 F8 FF                       call    unknown_libname_1307 ; BDS 2005-2007 and Delphi6-7 Visual Component Library
.text:005024AB 8B 05 E4 6F 53 00                    mov     eax, dword ptr EndXXX64
.text:005024B1 8B 15 E8 6F 53 00                    mov     edx, dword ptr EndXXX64+4
.text:005024B7 2B 05 DC 6F 53 00                    sub     eax, dword ptr BegXXX64
.text:005024BD 1B 15 E0 6F 53 00                    sbb     edx, dword ptr BegXXX64+4
.text:005024C3 71 05                                jno     short loc_5024CA
.text:005024C5 E8 DA 16 F0 FF                       call    System_Error_5
.text:005024CA                      ; ---------------------------------------------------------------------------
.text:005024CA
.text:005024CA                      loc_5024CA:                             ; CODE XREF: sub_502434+8Fj
.text:005024CA E8 81 53 03 04                       call    Random64                 ; <--- original: "call  System_RandInt"
.text:005024CF 90                                   nop                              ; <--- original: "cdq"
.text:005024D0 03 05 DC 6F 53 00                    add     eax, dword ptr BegXXX64
.text:005024D6 13 15 E0 6F 53 00                    adc     edx, dword ptr BegXXX64+4
.text:005024DC 71 05                                jno     short loc_5024E3
.text:005024DE E8 C1 16 F0 FF                       call    System_Error_5




4.46 new function

.text:04537850                      ; unsigned __int64 __fastcall Random64(unsigned __int64 Len)
.text:04537850                      Random64        proc near
.text:04537850 56                                   push    esi
.text:04537851 52                                   push    edx
.text:04537852 8B F2                                mov     esi, edx
.text:04537854 8B C8                                mov     ecx, eax
.text:04537856 A1 08 20 53 00                       mov     eax, RandSeed
.text:0453785B 69 C0 05 84 08 08                    imul    eax, 8088405h
.text:04537861 40                                   inc     eax
.text:04537862 A3 08 20 53 00                       mov     RandSeed, eax
.text:04537867 33 D2                                xor     edx, edx
.text:04537869 0B F2                                or      esi, edx
.text:0453786B 75 09                                jnz     short loc_4537876
.text:0453786D F7 E1                                mul     ecx
.text:0453786F 8B C2                                mov     eax, edx
.text:04537871 5A                                   pop     edx
.text:04537872 33 D2                                xor     edx, edx
.text:04537874 5E                                   pop     esi
.text:04537875 C3                                   retn
.text:04537876                      ; ---------------------------------------------------------------------------
.text:04537876
.text:04537876                      loc_4537876:                            ; CODE XREF: Random64+1Bj
.text:04537876 8B F0                                mov     esi, eax
.text:04537878 69 C0 05 84 08 08                    imul    eax, 8088405h
.text:0453787E 40                                   inc     eax
.text:0453787F A3 84 33 40 00                       mov     RandSeed, eax
.text:04537884 8B D0                                mov     edx, eax
.text:04537886 58                                   pop     eax
.text:04537887 F7 E2                                mul     edx
.text:04537889 8B C6                                mov     eax, esi
.text:0453788B 5E                                   pop     esi
.text:0453788C C3                                   retn
.text:0453788C                      Random64        endp



__declspec(noinline)
unsigned __int64 __fastcall Random64(unsigned __int64 delta)
{
  unsigned int dh;
  ULARGE_INTEGER a;
  RandSeed = 134775813 * RandSeed + 1;
  if (!(delta >> 32)) {
    return ((unsigned __int64)((unsigned int)delta) * (unsigned int)RandSeed) >> 32;
  }
  a.LowPart = RandSeed;
  RandSeed = 134775813 * RandSeed + 1;
  dh = delta >> 32;
  a.HighPart = ((unsigned __int64)dh * (unsigned int)RandSeed) >> 32;
  return a.QuadPart;
}



