이전 항목: 샘플 헤더다음 항목: 언어 기능


샘플 스크립트

#include "SampleHeader.hdr"

function Detection()
{
     var e;

     SharedFunction( "Detection" );

     RecursionTest( "x" );

     {
     var result0 = ReturnTest( 0 );

     Print( "반환 테스트 = " + result0 );
     }

     ScopeTest();

     BreakTest();

     lang = LANGUAGE;
     Print( "언어 = " + lang );

     if (Detect("foo.exe") == false) return;

     Option( "Test", "TestStore", "TestApply", "test" );

     var eList = EnumKey(  "HKLM\\Software" );
     for (var eIdx in eList)
     {
          var e = eList[eIdx];

          var strWhileScope = "while 범위 키 = " + e;

          Print( strWhileScope, VERY_DETAILED );
     }

     e = e;

     var eList = EnumValue(  "HKLM\\Software" );
     for (var eIdx in eList)
     {
          var e = eList[eIdx];

          Print( "값 = " + e, VERY_DETAILED );
     }

     var eList = EnumFiles(  "c:\\" );
     for (var eIdx in eList)
     {
          var e = eList[eIdx];

          Print( "파일 = " + e, VERY_DETAILED );
     }

     var eList = EnumDirectories(  "c:\\" );
     for (var eIdx in eList)
     {
          var e = eList[eIdx];

          Print( "디렉터리 = " + e, VERY_DETAILED );
     }

     path = WINDOWSPATH;
     Print( path, MODERATE );

     Message( "클라이언트에게 다른 이벤트를 유발하지 말아야 합니다. 이미 캐시되었어야 합니다" );
     path = WINDOWSPATH;
     Print( path, MODERATE );
     
     RestartRequired(false);

     var myString               = "매우 특수한 문자열입니다.";
     var myStringBinary     = ConvertStringToBinary(myString);
     var myStringString = ConvertBinaryToString(myStringBinary);
     if (myString == myStringString)
     {
          Print("문자열/이진 변환이 작동합니다.");
     }
}

function PreProcess()
{
     Print("PreProcess() 함수 내");
}

function PostProcess()
{
     Print("PostProcess() 함수 내");
}

function TestStore()
{
     SharedFunction( "TestStore" );

     StoreKey( "HKCU\\Software\\Foo International\\Foo application" );
     StoreValue( "HKCU\\Software\\Foo International\\Foo application", "foo" );

     StoreMappedKey( "HKCU\\Software\\Foo International\\Foo application" );
     StoreMappedKey( "HKCU\\Software\\Foo International\\Foo application", "," );
     StoreMappedSubKeys( "HKCU\\Software\\Foo International\\Foo application" );
     StoreMappedSubKeys( "HKCU\\Software\\Foo International\\Foo application", "," );
     StoreMappedValue( "HKCU\\Software\\Foo International\\Foo application", "설치 경로" );
     StoreMappedValue( "HKCU\\Software\\Foo International\\Foo application", "설치 경로", "," );

     StoreFile( APPLICATIONPATH + "\\foo.exe" );
     StoreMappedFile( DESKTOPPATH + "\\mapped.txt" );
     StoreDirectory( APPLICATIONPATH );
}

function TestApply()
{
     SharedFunction( "TestApply" );

     strBaseKey = "HKCU\\Software\\Foo International\\Foo application";
     strMoveKey = "HKCU\\Software\\Foo International\\evil Foo application";

     MapPath( SYSTEMPATH, NEW_SYSTEMPATH );

     strMappedPath = GetMappedPath( WINDOWSPATH );
     Print( "매핑된 경로 = " + strMappedPath );
     strMappedPath = GetMappedPath( NEW_WINDOWSPATH, "," );
     Print( "매핑된 경로 = " + strMappedPath );

     ApplyKey( strBaseKey );
     ApplyKey( strBaseKey, strMoveKey );
     ApplySubKeys( strBaseKey );
     ApplySubKeys( strBaseKey, strMoveKey );
     ApplyValue( strBaseKey, "foo" );
     ApplyValue( strBaseKey, "foo", strMoveKey );
     ApplyValue( strBaseKey, "foo", strMoveKey, "evil foo" );

     ApplyMappedKey( strBaseKey );
     ApplyMappedKey( strBaseKey, strMoveKey );
     ApplyMappedKey( strBaseKey, strMoveKey, false );
     ApplyMappedKey( strBaseKey, strMoveKey, true, "," );
     ApplyMappedSubKeys( strBaseKey );
     ApplyMappedSubKeys( strBaseKey, strMoveKey );
     ApplyMappedSubKeys( strBaseKey, strMoveKey, false );
     ApplyMappedSubKeys( strBaseKey, strMoveKey, true, "," );
     ApplyMappedValue( strBaseKey, "설치 경로" );
     ApplyMappedValue( strBaseKey, "설치 경로", strMoveKey );
     ApplyMappedValue( strBaseKey, "설치 경로", strMoveKey, "불량 설치 경로" );
     ApplyMappedValue( strBaseKey, "설치 경로", strMoveKey, "불량 설치 경로", false );
     ApplyMappedValue( strBaseKey, "설치 경로", strMoveKey, "불량 설치 경로", true, "," );

     ApplyFile( APPLICATIONPATH + "\\foo.exe" );
     ApplyFile( APPLICATIONPATH + "\\foo.exe", ALWAYS );
     ApplyFile( APPLICATIONPATH + "\\foo.exe", NEW_APPLICATIONPATH + "\\evil foo.exe" );
     ApplyFile( APPLICATIONPATH + "\\foo.exe", NEW_APPLICATIONPATH + "\\evil foo.exe", NEVER );
     ApplyMappedFile( DESKTOPPATH + "\\mapped.txt" );
     ApplyMappedFile( DESKTOPPATH + "\\mapped.txt", ALWAYS );
     ApplyMappedFile( DESKTOPPATH + "\\mapped.txt", NEW_DESKTOPPATH + "\\mapped.txt");
     ApplyMappedFile( DESKTOPPATH + "\\mapped.txt", NEW_DESKTOPPATH + "\\mapped.txt", NEVER);
     ApplyDirectory( APPLICATIONPATH );
     ApplyDirectory( APPLICATIONPATH, NEW_APPLICATIONPATH );
     ApplyDirectory( APPLICATIONPATH, NEW_APPLICATIONPATH, ALWAYS );
     ApplyDirectory( APPLICATIONPATH, NEW_APPLICATIONPATH, NEWER );

     DeleteKey( strBaseKey );
     DeleteValue( strBaseKey, "foo" );

     Register( APPLICATIONPATH + "\\FooCom.dll" );

     SetKey( strBaseKey );
     SetValue( strBaseKey, "foo", "STRING 값", STRING );
     SetValue( strBaseKey, "foo", "DWORD 값", DWORD );
     SetValue( strBaseKey, "foo", "BINARY 값", BINARY );
     SetValue( strBaseKey, "foo", "EXPAND_STRING 값", EXPAND_STRING );
     SetValue( strBaseKey, "foo", "MULTI_STRING 값", MULTI_STRING );
     SetValue( strBaseKey, "foo", "DWORD_LITTLE_ENDIAN 값", DWORD_LITTLE_ENDIAN );
     SetValue( strBaseKey, "foo", "DWORD_BIG_ENDIAN 값", DWORD_BIG_ENDIAN );
     SetValue( strBaseKey, "foo", "SYMBOLIC_LINK 값", SYMBOLIC_LINK );
     SetValue( strBaseKey, "foo", "RESOURCE_LIST 값", RESOURCE_LIST );
     SetValue( strBaseKey, "foo", "FULL_RESOURCE_DESCRIPTOR 값", FULL_RESOURCE_DESCRIPTOR );
     SetValue( strBaseKey, "foo", "RESOURCE_REQUIREMENTS_LIST 값", RESOURCE_REQUIREMENTS_LIST );

     if (     KeyExists( strBaseKey )
          &&     KeyExists( strBaseKey, SOURCE ))
     {
          Print( "키가 존재합니다" );
     }

     if (     ValueExists( strBaseKey, "foo" )
          &&     ValueExists( strBaseKey, "foo", SOURCE ))
     {
          Print( "값이 존재합니다" );
     }

     if (     FileExists( APPLICATIONPATH + "\\foo.exe" )
          &&     FileExists( APPLICATIONPATH + "\\foo.exe", SOURCE ))
     {
          Print( "파일이 존재합니다" );
     }

     if (     DirectoryExists( APPLICATIONPATH )
          &&     DirectoryExists( APPLICATIONPATH, SOURCE ))
     {
          Print( "디렉터리가 존재합니다" );
     }

     platform = GetPlatform();
     PrintException( "플랫폼 = " + platform );

     platform = GetPlatform( true );
     PrintException( "플랫폼 = " + platform, VERY_DETAILED );

     Execute( NEW_APPLICATIONPATH + "\\foo.exe", "foo args" );
     Execute( NEW_APPLICATIONPATH + "\\foo.exe", "foo args", true );

     /* finish with a bang */
     Exit( "***BANG*** (테스트 종료)" );
     Exit("접근 불가능한 코드, 구문 분석만을 위한 것임");
     Exit();     /* unreachable code, just for parsing */
}