The fopenEx function is a custom wrapper for the standard fopen function in C. It utilizes a function pointer a1 to call fopen and performs additional processing on the resulting file pointer. The function also includes logic for reading and processing file metadata.

int __fastcall fopenEx(int (__fastcall *a1)(int, int), int a2, int a3)
{
  int (__fastcall *v3)(int, int); // r9
  int v4; // r4
  int v5; // r8
  int v6; // r5
  int v7; // r4
  FILE *v8; // r6
  int v9; // r0
  FILE *v10; // r6
  int v11; // r5
  int *v12; // r6
  _DWORD *v13; // r6
  int v14; // t1
  size_t v15; // r0
  FILE *v16; // r6
  int v17; // r5
  int v18; // r8
  int v19; // r0
  FILE *v20; // r6
  int v21; // r5
  int v22; // r6
  size_t v23; // r0
  FILE *v24; // r5
  int v25; // r8
  int v26; // r6
  int *v27; // r1
  FILE *v28; // r5
  int v29; // r6
  int v30; // r5
  size_t v31; // r0
  FILE *v32; // r5
  int v33; // r2
  int *v34; // r0
  int v35; // r2
  int result; // r0
  int ptr; // [sp+4h] [bp-64h]
  int v38; // [sp+8h] [bp-60h]
  int v39; // [sp+Ch] [bp-5Ch]
  __int16 v40; // [sp+10h] [bp-58h]
  int v41; // [sp+18h] [bp-50h]
  int v42; // [sp+1Ch] [bp-4Ch]
  __int16 v43; // [sp+20h] [bp-48h]
  int v44; // [sp+28h] [bp-40h]
  int v45; // [sp+2Ch] [bp-3Ch]
  int v46; // [sp+30h] [bp-38h]
  int v47; // [sp+34h] [bp-34h]
  unsigned __int8 v48; // [sp+38h] [bp-30h]
  unsigned __int8 v49; // [sp+39h] [bp-2Fh]
  int v50; // [sp+58h] [bp-10h]

  v3 = a1;
  v4 = 0;
  v5 = a3;
  v6 = a2;
  ptr = 0;
  j_OpenShowInterfaceDLL();
  v46 = 0;
  v47 = 0;
  v44 = 0;
  v45 = 0;
  v43 = 0;
  v41 = 0;
  v42 = 0;
  v40 = 0;
  v38 = 0;
  v39 = 0;
  if ( dword_12B48 <= 64 )
  {
    if ( !dword_12B48 )
    {
      v7 = 0;
      ptr = 0;
      do
      {
        _aeabi_memclr4((int)&dword_12048[v7], 44);
        v7 += 11;
      } while ( v7 != 704 );
      ptr = 64;
    }
    v8 = (FILE *)v3(v6, v5);
    dword_12048[11 * dword_12B48] = (int)v8;
    if ( v8 )
    {
      _aeabi_memclr8(&v48, 32);
      v4 = 0;
      j_fseekEx((int)v8, 0, 0);
      fread(&v48, 2u, 1u, v8);
      v9 = 11 * dword_12B48;
      dword_12048[11 * dword_12B48 + 1] += 2;
      v10 = (FILE *)dword_12048[v9];
      _aeabi_memclr8(&v48, 32);
      j_fseekEx((int)v10, 0, 0);
      fread(&v48, 5u, 1u, v10);
      v11 = dword_12B48;
      v12 = &dword_12048[11 * dword_12B48];
      v14 = v12[1];
      v13 = v12 + 1;
      *v13 = v14 + 5;
      v15 = strlen((const char *)&v48);
      _aeabi_memcpy8((int)&v38, (int)&v48, v15 + 1);
      if ( !strcmp((const char *)&v38, 'YZJM') )
      {
        v16 = (FILE *)dword_12048[11 * v11];
        _aeabi_memclr8(&v48, 32);
        j_fseekEx((int)v16, 0, 0);
        fread(&v48, 2u, 1u, v16);
        v17 = v48;
        v18 = v49;
        v19 = 11 * dword_12B48;
        dword_12048[11 * dword_12B48 + 1] += 2;
        v20 = (FILE *)dword_12048[v19];
        _aeabi_memclr8(&v48, 32);
        j_fseekEx((int)v20, 0, 0);
        v21 = v17 | (v18 << 8);
        fread(&v48, v21, 1u, v20);
        v22 = dword_12B48;
        dword_12048[11 * dword_12B48 + 1] += v21;
        v23 = strlen((const char *)&v48);
        _aeabi_memcpy8((int)&v44, (int)&v48, v23 + 1);
        v24 = (FILE *)dword_12048[11 * v22];
        _aeabi_memclr8(&v48, 32);
        j_fseekEx((int)v24, 0, 0);
        fread(&v48, 2u, 1u, v24);
        v25 = v48;
        v26 = v49;
        v27 = &dword_12048[11 * dword_12B48];
        v27[1] += 2;
        v28 = (FILE *)*v27;
        _aeabi_memclr8(&v48, 32);
        j_fseekEx((int)v28, 0, 0);
        v29 = v25 | (v26 << 8);
        fread(&v48, v29, 1u, v28);
        v30 = dword_12B48;
        dword_12048[11 * dword_12B48 + 1] += v29;
        v31 = strlen((const char *)&v48);
        _aeabi_memcpy8((int)&v41, (int)&v48, v31 + 1);
        ptr = 0;
        v32 = (FILE *)dword_12048[11 * v30];
        j_fseekEx((int)v32, 0, 0);
        fread(&ptr, 4u, 1u, v32);
        v33 = ptr;
        v34 = &dword_12048[11 * dword_12B48];
        v34[1] += 4;
        if ( sub_70D4(&v44, &v41, v33, v34 + 3) )
        {
          v35 = 11 * dword_12B48++;
          v4 = dword_12048[v35];
        }
      }
      else
      {
        *v13 = 0;
        dword_12B48 = v11 + 1;
        v4 = dword_12048[11 * v11];
      }
    }
    else
    {
      v4 = 0;
    }
  }
  result = _stack_chk_guard - v50;
  if ( _stack_chk_guard == v50 )
    result = v4;
  return result;
}

The function performs the following steps:

  1. Initialization: The function initializes several variables and sets them to 0. It then calls the j_OpenShowInterfaceDLL() function, which is likely used to load a DLL.
  2. File Opening: If the global variable dword_12B48 is less than or equal to 64, the function calls the function pointed to by a1 (which is assumed to be fopen) to open a file. The resulting file pointer is stored in dword_12048.
  3. Metadata Processing: If the file was opened successfully, the function reads metadata from the file, including a string that appears to be 'YZJM'. Based on this metadata, the function performs additional processing, including reading and comparing other strings from the file.
  4. Error Handling: If the file opening fails or the metadata check fails, the function returns a value of 0.
  5. Return: Finally, the function returns the file pointer, which is stored in v4, or 0 if there were any errors.

The fopenEx function appears to be designed for specific file types that include metadata in a particular format. It handles the opening and processing of this metadata before returning the file pointer. The specific details of the metadata format and the internal function sub_70D4 are not readily available from the code provided.

This analysis provides a high-level understanding of the function's purpose and operation. To fully understand the function's functionality and the specific file types it handles, more information is needed about the metadata format, the internal functions used, and the overall context within which the function is used.

fopenEx Function: A Custom Wrapper for fopen in C

原文地址: https://www.cveoy.top/t/topic/o92C 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录