Example #1
0
 public bool Create(String AppID, String AppVirtDll, String LoaderExe, out APIRET Ret)
 {
     Ret = (APIRET)PackageCreate(AppID, AppVirtDll, LoaderExe, ref hPkg);
     lastError = (Ret != APIRET.SUCCESS ? Ret : lastError);
     if (Ret == APIRET.SUCCESS)
     {
         opened = true;
         // Note: openedFile remains empty
         return true;
     }
     else
         return false;
 }
Example #2
0
 public bool DeleteFile(
     String FileName)
 {
     APIRET Ret = (APIRET)VirtFsDelete(hPkg, FileName);
     lastError = (Ret != APIRET.SUCCESS ? Ret : lastError);
     if (Ret == APIRET.SUCCESS)
         return true;
     else if (Ret == APIRET.NOT_FOUND)
         return false;
     else
         return false;
 }
Example #3
0
 public bool AddEmptyDir(
     String DirName,
     bool bVariablizeName)
 {
     APIRET Ret = (APIRET)VirtFsAddEmptyDir(hPkg, DirName, bVariablizeName);
     lastError = (Ret != APIRET.SUCCESS ? Ret : lastError);
     if (Ret == APIRET.SUCCESS)
         return true;
     else if (Ret == APIRET.VIRTFILES_DB_ERROR)
         return true;
     else
         return false;
 }
Example #4
0
 public bool AddFileEx(
     String SrcFileName,
     String DestFileName,
     bool bVariablizeName,
     VIRT_FILE_FLAGS fileFlags)
 {
     APIRET Ret = (APIRET)VirtFsAddEx(hPkg, SrcFileName, DestFileName, bVariablizeName, (uint)fileFlags);
     lastError = (Ret != APIRET.SUCCESS ? Ret : lastError);
     if (Ret == APIRET.SUCCESS)
         return true;
     else if (Ret == APIRET.VIRTFILES_DB_ERROR)
         return true;
     else if (Ret == APIRET.NOT_FOUND)
         return false;
     else
         return false;
 }
Example #5
0
 public bool GetProperty(String Name, ref String Value, out APIRET Ret)
 {
     StringBuilder sbValue = new StringBuilder(MAX_STRING);
     Ret = (APIRET)PackageGetProperty(hPkg, Name, sbValue, MAX_STRING);
     //lastError = (Ret != APIRET.SUCCESS ? Ret : lastError);
     if (Ret == APIRET.SUCCESS)
     {
         Value = sbValue.ToString();
         return true;
     }
     else if (Ret == APIRET.NOT_FOUND)
         return false;
     else
         return false;
 }
Example #6
0
 public static void ApiRetStr(APIRET apiRet, out string name, out string description)
 {
     switch (apiRet)
     {
     case APIRET.SUCCESS:				name = "APIRET_SUCCESS"; description = "Success"; break;
     case APIRET.FAILURE:				name = "APIRET_FAILURE"; description = "Failure"; break;
     case APIRET.VIRTFILES_DB_ERROR:		name = "APIRET_VIRTFILES_DB_ERROR"; description = "Virtual filesystem database error"; break;
     case APIRET.VIRTFILES_ZIP_ERROR:	name = "APIRET_VIRTFILES_ZIP_ERROR"; description = "ZIP error"; break;
     case APIRET.NOT_FOUND:				name = "APIRET_NOT_FOUND"; description = "File / resource not found"; break;
     case APIRET.INVALID_PARAMETER:		name = "APIRET_INVALID_PARAMETER"; description = "Invalid parameter"; break;
     case APIRET.FILE_CREATE_ERROR:		name = "APIRET_FILE_CREATE_ERROR"; description = "File creation error"; break;
     case APIRET.PE_RESOURCE_ERROR:		name = "APIRET_PE_RESOURCE_ERROR"; description = "Virtual package resource error"; break;
     case APIRET.MEMORY_ERROR:			name = "APIRET_MEMORY_ERROR"; description = "Memory error"; break;
     case APIRET.COMMIT_ERROR:			name = "APIRET_COMMIT_ERROR"; description = "Error committing virtual package changes"; break;
     case APIRET.VIRTREG_DEPLOY_ERROR:	name = "APIRET_VIRTREG_DEPLOY_ERROR"; description = "Error deploying virtual registry"; break;
     case APIRET.OUTPUT_ERROR:			name = "APIRET_OUTPUT_ERROR"; description = "Output error"; break;
     case APIRET.INSUFFICIENT_BUFFER:	name = "APIRET_INSUFFICIENT_BUFFER"; description = "Insufficient buffer size"; break;
     case APIRET.LOADLIBRARY_ERROR:		name = "APIRET_LOADLIBRARY_ERROR"; description = "LoadLibrary error"; break;
     case APIRET.VIRTFILES_INI_ERROR:	name = "APIRET_VIRTFILES_INI_ERROR"; description = "Virtual package INI error"; break;
     case APIRET.APP_NOT_DEPLOYED:		name = "APIRET_APP_NOT_DEPLOYED"; description = "Application not depliyed"; break;
     case APIRET.INSUFFICIENT_PRIVILEGES:name = "APIRET_INSUFFICIENT_PRIVILEGES"; description = "Insufficient user permissions"; break;
     case APIRET._32_64_BIT_MISMATCH:	name = "APIRET_32_64_BIT_MISMATCH"; description = "32/64 bit mismatch"; break;
     case APIRET.DOTNET_REQUIRED:		name = "APIRET_DOTNET_REQUIRED"; description = ".NET framework required"; break;
     case APIRET.CANCELLED:				name = "APIRET_CANCELLED"; description = "Operation cancelled"; break;
     case APIRET.INJECTION_FAILED:		name = "APIRET_INJECTION_FAILED"; description = "Injection failed"; break;
     case APIRET.OLD_VERSION:			name = "APIRET_OLD_VERSION"; description = "Old package version"; break;
     case APIRET.PASSWORD_REQUIRED:		name = "APIRET_PASSWORD_REQUIRED"; description = "Password required"; break;
     case APIRET.PASSWORD_MISMATCH:		name = "APIRET_PASSWORD_MISMATCH"; description = "Password mismatch"; break;
     case APIRET.INSUFFICIENT_LICENSE:	name = "APIRET_INSUFFICIENT_LICENSE"; description = "Insufficient license"; break;
     default:							name = String.Format("{0}", (int)apiRet); description = "Unknown error " + ((int)apiRet).ToString(); break;
     }
 }
Example #7
0
 public bool SetProperty(String Name, String Value, out APIRET Ret)
 {
     Ret = (APIRET)PackageSetProperty(hPkg, Name, Value);
     lastError = (Ret != APIRET.SUCCESS ? Ret : lastError);
     if (Ret == APIRET.SUCCESS)
         return true;
     else if (Ret == APIRET.FILE_CREATE_ERROR)
         return false;
     else
         return false;
 }
Example #8
0
 public bool Open(String PackageExeFile, out APIRET apiRet)
 {
     apiRet = (APIRET)PackageOpen(PackageExeFile, 0, ref hPkg);
     if (apiRet == APIRET.SUCCESS)
     {
         opened = true;
         int passwordPos = PackageExeFile.IndexOf('|');
         if (passwordPos == -1)
             openedFile = PackageExeFile;
         else
             openedFile = PackageExeFile.Substring(0, passwordPos);
         return true;
     }
     else
         return false;
 }
Example #9
0
 public void SetFileFlags(String Path, VIRT_FILE_FLAGS FileFlags)
 {
     APIRET apiRet = (APIRET)VirtFsSetFileFlags(hPkg, Path, (UInt32)FileFlags);
     lastError = (apiRet != APIRET.SUCCESS ? apiRet : lastError);
 }
Example #10
0
 public bool SetIcon(String FileName, out APIRET Ret)
 {
     Ret = (APIRET)PackageSetIconFile(hPkg, FileName);
     lastError = (Ret != APIRET.SUCCESS ? Ret : lastError);
     if (Ret == APIRET.SUCCESS)
         return true;
     else if (Ret == APIRET.NOT_FOUND)
         return false;
     else
         return false;
 }
Example #11
0
 public bool SaveRegWorkKey()
 {
     APIRET Ret = (APIRET)VirtRegSaveWorkKey(hPkg);
     OutputDebugString("SaveRegWorkKey() ret=" + (int)Ret + " LE=" + Marshal.GetLastWin32Error() + "\n");
     lastError = (Ret != APIRET.SUCCESS ? Ret : lastError);
     if (Ret == APIRET.SUCCESS)
         return true;
     else if (Ret == APIRET.INVALID_PARAMETER)
         return false;
     else
         return false;
 }
Example #12
0
 public void ResetLastError()
 {
     lastError = APIRET.SUCCESS;
 }
Example #13
0
        //
        // VirtReg functions
        public RegistryKey GetRegWorkKeyEx(System.Threading.AutoResetEvent abortEvent)
        {
            StringBuilder sbWorkKey = new StringBuilder(MAX_STRING);

            SafeWaitHandle waitHandle;
            if (abortEvent != null)
                waitHandle = abortEvent.SafeWaitHandle;
            else
                waitHandle = new SafeWaitHandle(IntPtr.Zero, true); ;
            APIRET Ret = (APIRET)VirtRegGetWorkKeyEx(hPkg, sbWorkKey, MAX_STRING, waitHandle);
            lastError = (Ret != APIRET.SUCCESS ? Ret : lastError);
            if (Ret == APIRET.SUCCESS)
            {
                RegistryKey key = Registry.CurrentUser.OpenSubKey(sbWorkKey.ToString(), true);
                if (key == null)
                {
                    key = Registry.CurrentUser.CreateSubKey(sbWorkKey.ToString());
                }
                return (key);
            }
            else if (Ret == APIRET.INSUFFICIENT_BUFFER)
                return null;
            else
                return null;
        }
Example #14
0
 public bool ExtractFile(
     String FileName,
     String TargetDir)
 {
     APIRET Ret = (APIRET)VirtFsExtract(hPkg, FileName, TargetDir);
     lastError = (Ret != APIRET.SUCCESS ? Ret : lastError);
     if (Ret == APIRET.SUCCESS)
         return true;
     else if (Ret == APIRET.NOT_FOUND)
         return false;
     else if (Ret == APIRET.FILE_CREATE_ERROR)
         return false;
     else
         return false;
 }
Example #15
0
 public bool SetProtection(String Password, int ProtectedActions, String RequireCertificate, out APIRET Ret)
 {
     Ret = (APIRET)PackageSetProtection(hPkg, Password, ProtectedActions, RequireCertificate);
     lastError = (Ret != APIRET.SUCCESS ? Ret : lastError);
     if (Ret == APIRET.SUCCESS)
         return true;
     else if (Ret == APIRET.FILE_CREATE_ERROR)
         return false;
     else
         return false;
 }
Example #16
0
 public bool Open(String PackageExeFile, out APIRET apiRet)
 {
     apiRet = (APIRET)PackageOpen(PackageExeFile, 0, ref hPkg);
     if (apiRet == APIRET.SUCCESS)
     {
         opened = true;
         openedFile = PackageExeFile;
         return true;
     }
     else
         return false;
 }
Example #17
0
 //
 // .NET wrapper
 public VirtPackage()
 {
     opened = false;
     openedFile = "";
     lastError = APIRET.SUCCESS;
     //private const String DLLNAME = "PackagerDll.dll";
 }
Example #18
0
 public bool SaveEx(String FileName, out APIRET apiRet)
 {
     int Ret = PackageSave(hPkg, FileName);
     apiRet = (APIRET)Ret;
     if (apiRet == APIRET.SUCCESS)
         return true;
     else
         return false;
 }
Example #19
0
 public VIRT_FILE_FLAGS GetFileFlags(String Path)
 {
     UInt32 FileFlags = 0;
     APIRET apiRet = (APIRET)VirtFsGetFileFlags(hPkg, Path, ref FileFlags);
     lastError = (apiRet != APIRET.SUCCESS ? apiRet : lastError);
     return (VIRT_FILE_FLAGS)FileFlags;
 }