// DIE's signature file

init("packer","NsPacK");

function getNSPackVersion()
{
    if((PE.section[0].FileSize>0)&&(PE.section[0].FileOffset<0x200))
    {
        sVersion="2.x";
    }
    else if((PE.section[0].FileSize==0)&&(PE.section[0].FileOffset>=0x200))
    {
        sVersion="3.x";
    }
}

function detect(bShowType,bShowVersion,bShowOptions)
{
    var nNumberOfFunctions=PE.getNumberOfImportThunks(0);
    if((nNumberOfFunctions==6)&&(!PE.getSizeOfCode()))
    {
        if(PE.getImportFunctionName(0,0)=="LoadLibraryA"
         &&PE.getImportFunctionName(0,1)=="GetProcAddress"
         &&PE.getImportFunctionName(0,2)=="VirtualProtect"
         &&PE.getImportFunctionName(0,3)=="VirtualAlloc"
         &&PE.getImportFunctionName(0,4)=="VirtualFree"
         &&PE.getImportFunctionName(0,5)=="ExitProcess")
        {
            getNSPackVersion();
            bDetected=1;
        }
    }
    if(!bDetected)
    {
        if(PE.isLibraryPresent("mscoree.dll")
         &&PE.getImportLibraryName(0)=="KERNEL32.dll"
         &&PE.getImportFunctionName(0,nNumberOfFunctions-1)=="GetSystemInfo")
        {
            getNSPackVersion();
            sOptions=".NET";
            bDetected=1;
        }
        else if(PE.isNETStringPresent("nsnet"))
        {
            sVersion="3.X";
            bDetected=1;
        }
    }

    return result(bShowType,bShowVersion,bShowOptions);
}
