ExpCreateOutputSIGNATURE

NTSTATUS __stdcall ExpCreateOutputSIGNATURE(
        _FILE_PATH *OutputPath,
        UINT64 *OutputPathLength,
        _DISK_SIGNATURE_NEW *pDiskSignature,
        UINT64 *pPartitionNumber,
        UINT64 *pPartitionStart,
        UINT64 *pPartitionSize,
        PWCHAR pPathName,
        UINT8 GPTpartition){
  unsigned int v8; 
  __int64 v10; 
  NTSTATUS v11; 
  __int64 v12; 
  unsigned int v13; 
  unsigned __int8 *FilePath; 
  __int64 v15; 
  NTSTATUS result; 
  __int64 v17; 
  __int64 v18; 
  __int64 v19; 
  _UNICODE_STRING GuidString[4]; 
  UINT64 *v21; 

  v21 = OutputPathLength;
  v8 = 93;
  GuidString[0] = 0i64;
  if( GPTpartition != 1 )
    v8 = 63;
  v10 = -1i64;
  v11 = 0;
  if( pPathName )
  {
    v12 = -1i64;
    do
      ++v12;
    while( pPathName[v12] );
    v8 += v12;
  }
  else
  {
    LODWORD(v12) = 0;
  }
  v13 = 2 * v8 + 12;
  if( *(_DWORD *)OutputPathLength >= v13 )
  {
    FilePath = OutputPath->FilePath;
    OutputPath->Version = 1;
    OutputPath->Length = v13;
    OutputPath->Type = 2;
    wcscpy_s((PWCHAR)OutputPath->FilePath, v8, (PWCHAR)L"signature(");
    v15 = -1i64;
    do
      ++v15;
    while( *(_WORD *)&FilePath[2 * v15] );
    if( GPTpartition == 1 )
    {
      result = RtlStringFromGUIDEx((_GUID *)pDiskSignature, GuidString, 1u);
      if( result < 0 )
        return result;
      wcscat_s((WCHAR *)&FilePath[2 * (unsigned int)v15], v8 - (unsigned int)v15, GuidString[0].Buffer);
      ExFreePoolWithTag(GuidString[0].Buffer, 0);
      LODWORD(v17) = GuidString[0].Length >> 1;
    }
    else
    {
      swprintf_s(
        (WCHAR *)&FilePath[2 * (unsigned int)v15],
        v8 - (unsigned int)v15,
        (WCHAR *)L"%08x",
        pDiskSignature->Signature);
      v17 = -1i64;
      do
        ++v17;
      while( *(_WORD *)&FilePath[2 * (unsigned int)v15 + 2 * v17] );
    }
    v18 = (unsigned int)(v17 + v15);
    swprintf_s(
      (WCHAR *)&FilePath[2 * v18],
      v8 - (unsigned int)v18,
      (WCHAR *)L"-%08x-%016I64x-%016I64x)",
      *(unsigned int *)pPartitionNumber,
      *pPartitionStart,
      *pPartitionSize);
    do
      ++v10;
    while( *(_WORD *)&FilePath[2 * v18 + 2 * v10] );
    v19 = (unsigned int)(v18 + v10);
    if( (_DWORD)v12 )
      wcscpy_s((PWCHAR)&FilePath[2 * v19], v8 - (unsigned int)v19, pPathName);
    OutputPathLength = v21;
  }
  else
  {
    v11 = -1073741789;
  }
  *(_DWORD *)OutputPathLength = v13;
  return v11;
}

Referenced by:

ExpTranslateEfiPath
ExpTranslateNtPath