#include "spawn.h"
#include "analizador.h"
#include <versionhelpers.h>

#pragma warning(disable: 4996)

#define ProcessWow64Information 26

int osMajorVersion;

BOOL SelfIsWindowsVistaOrLater() {
    return IsWindowsVistaOrGreater();

}

typedef WINBASEAPI BOOL(WINAPI* FN_KERNEL32_ISWOW64PROCESS)(_In_ HANDLE hProcess, _Out_ PBOOL Wow64Process);


BOOL IsWow64ProcessEx(HANDLE hProcess) {
    HMODULE hModule = GetModuleHandleA("kernel32");
    FN_KERNEL32_ISWOW64PROCESS _IsWow64Process = (FN_KERNEL32_ISWOW64PROCESS)GetProcAddress(hModule, "IsWow64Process");
    if (_IsWow64Process == NULL)
    {
        _err("kernel32$IsWow64Process: IsWow64Process is NULL");
        return FALSE;
    }

    BOOL bStatus = FALSE;
    BOOL Wow64Process = FALSE;

    // bStatus = _IsWow64Process(hProcess, &Wow64Process);
    bStatus = _IsWow64Process(hProcess, &Wow64Process);
    if (!bStatus)
    {
        _err("_IsWow64Process failed with status code : %d", GetLastError());
        return FALSE;
    }

    return Wow64Process;		// TODO bug ! - returns 0 (x86) for current process?
}