#pragma once
#ifndef _ASAR_H
#define _ASAR_H

#include <Windows.h>

// ==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==
// Compilation Flags
//\
#define VERBOSE_OUTPUT

// ==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==
// Structures Defintions

typedef struct _FILE_ENTRY
{
    LPSTR   pszRelativePath;    // Path relative to ASAR root (e.g. "app\\main.js")
    DWORD   dwOffset;           // Byte offset into data section
    DWORD   dwSize;             // File size in bytes
    BOOL    bIsDirectory;       // TRUE if entry represents a directory
    BOOL    bIsExecutable;      // TRUE if file has executable flag set
    LPSTR   pszHash;            // Hex-encoded SHA-256 of entire file
    LPSTR*  ppszBlocks;         // Array of hex-encoded SHA-256 block hashes
    DWORD   dwBlockCount;       // Number of 4MB blocks
    struct _FILE_ENTRY* pNext;  // Next entry in linked list
} FILE_ENTRY, * PFILE_ENTRY;


// ==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==


BOOL UnpackAsarFile(IN LPCSTR pszAsarPath, IN LPCSTR pszOutputDir);
BOOL PackAsarFile(IN LPCSTR pszInputDir, IN LPCSTR pszAsarPath);
BOOL VerifyAsarFile(IN LPCSTR pszAsarPath);

// ==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==

#endif // !_ASAR_H
