#pragma once
/*
     Malware.
*/

#include "crypt.h"

namespace MalwareTools
{
  //  .
  enum
  {
    NCF_ALL_LOWER    = 0x0, //   .
    //NCF_ALL_UPPER   = 0x1,   
    NCF_FIRST_UPPER  = 0x2, //    ,   .
    NCF_ALLOW_SPACES = 0x4 // .
  };

  //   .
  enum
  {
    KON_DEFAULT, // ,  .
    KON_SESSION, //  ,  Local.
    KON_GLOBAL,  //,  Global.
  };
  
  /*
    .
  */
  void init(void);

  /*
    .
  */
  void uninit(void);

  /*
     .

    IN dwCaseFlags -  NCF_*.
    OUT pstrName   -   .
    IN bMinChars   -     .
    IN bMaxChars   -     .
  */
  void _GenerateRandomNameW(DWORD dwCaseFlags, LPWSTR pstrName, BYTE bMinChars, BYTE bMaxChars);
  void _GenerateRandomNameA(DWORD dwCaseFlags, LPSTR pstrName, BYTE bMinChars, BYTE bMaxChars);

  /*
      _GenerateRandomNameW,        .

    IN dwCaseFlags   -  NCF_*.
    IN pstrPath      -   .
    OUT pstrName     -   ,       MAX_PATH  
                         .
    IN pstrExtension -  ,  NULL.
    IN bMinChars     -     .
    IN bMaxChars     -     .

    Return           - true -   ,
                       false -   .
  */
  bool _GenerateRandomFileName(DWORD dwCaseFlags, LPWSTR pstrPath, LPWSTR pstrName, LPWSTR pstrExtension, BYTE bMinChars, BYTE bMaxChars);

  
  /*
      _GenerateRandomNameW,        .

    IN dwCaseFlags -  NCF_*.
    IN hRoot       -   .
    IN pstrPath    -   .
    OUT pstrName   -    pstrPath.
    IN bMinChars   -     .
    IN bMaxChars   -     .

    Return         - true -   ,
                     false -   .
  */
  bool _GenerateRandomRegKeyName(DWORD dwCaseFlags, HKEY hRoot, LPWSTR pstrPath, LPWSTR pstrName, BYTE bMinChars, BYTE bMaxChars);
  
  /*
      ID .

    OUT guid - ID .

    Return   - true -   ,
               false -    (pGUID   ).
  */
  bool _getOsGuid(GUID *guid);

  /*
            GUID.

    IN osGuid          -  _getOsGuid().
    IN advId1          -   1.
    IN advId2          -   2.
    OUT buffer         -   "CLSID",   40 .   (asLocal == true),  50.
    IN rc4Key          -   ( ),  NULL.
    IN objectNamespace -   KON_*.
  */
  void _generateKernelObjectName(GUID *osGuid, DWORD advId1, DWORD advId2, LPWSTR buffer, Crypt::RC4KEY *rc4Key, BYTE objectNamespace);
};
