LdrInitSecurityCookie

UINT64 __stdcall LdrInitSecurityCookie(PVOID ModuleBase, UINT64 SizeOfImage, UINT64 ExtensionSeed){
  unsigned __int64 v3; 
  unsigned __int64 v4; 
  unsigned __int64 AddressOfSecurityCookie; 
  unsigned __int64 v6; 
  unsigned __int64 v7; 
  UINT64 v9; 
  _IMAGE_LOAD_CONFIG_DIRECTORY64 *v10; 
  HIDWORD(v9) = HIDWORD(ExtensionSeed);
  LODWORD(v9) = 0;
  v10 = 0i64;
  v4 = v3;
  AddressOfSecurityCookie = (unsigned __int64)LdrpFetchAddressOfSecurityCookie(ModuleBase, SizeOfImage, &v9, &v10);
  if( v10 && v10->Size >= 0x94 && (v10[1].DeCommitTotalFreeThreshold & 0x800) != 0 )
    return 1i64;
  if( AddressOfSecurityCookie && *(_QWORD *)AddressOfSecurityCookie == 0x2B992DDFA232i64 )
  {
    v6 = __rdtsc();
    v7 = (AddressOfSecurityCookie ^ (((unsigned __int64)HIDWORD(v6) << 32) | (unsigned int)v6) ^ HIDWORD(v4) ^ ((unsigned __int64)(unsigned int)v4 << 16)) & 0xFFFFFFFFFFFFi64;
    if( v7 == 0x2B992DDFA232i64 || !v7 )
      v7 = 0x2B992DDFA233i64;
    *(_QWORD *)AddressOfSecurityCookie = v7;
    return 1i64;
  }
  return 0i64;
}

Referenced by:

MiProcessLoadConfigForDriver