KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Utility Method to Disable Adobe Reader Protect Mode
PRODUCT: 4D | VERSION: 15.3 | PLATFORM: Win
Published On: February 2, 2017

In Acrobat Reader 10, Adobe introduced a new feature to protect users against attacks by sandboxing application proceses, however this feature causes issues when opening a PDF in a 4D Web Area. Some versions of Acrobat Reader are installed with the feature enabled.

This feature can be enabled or disbled in a number of ways. The easiest method is to open the UI for the application and go to the Preferences and disable protected mode. In older versions of Acrobat Reader this is under the General section labeled as Enable Protect Mode at startup, in Acrobat Reader DC this is now under the Security (Enhanced) section.

This feature can also be disabled from 4D by modifying the Registry that contains the setting. Below is a utility method that will perform this function.

Note: Uses Utility Method to Split Text By Lines from the following Tech Tip
https://kb.4d.com/assetid=77278

// Method: Util_Disable_Adobe_Reader_Protect_Mode
//
// Details: Disables Adobe Readers Protect Mode which
// can causes hangs when using Web Area to display PDFs

C_TEXT($in;$out;$err)
C_TEXT($regSearch_t)
C_TEXT($regexPat_t)
C_TEXT($regSet_t)
C_LONGINT($pos_l)
C_LONGINT($foundPos_l)
ARRAY TEXT($resultLines_at;0)
ARRAY TEXT($locations_at;0)

$in:=""
SET ENVIRONMENT VARIABLE("_4D_OPTION_HIDE_CONSOLE";"False")
$regSearch_t:="REG QUERY \"HKCU\Software\Adobe\" /v bProtectedMode /s"
LAUNCH EXTERNAL PROCESS($regSearch_t;$in;$out;$err)

If(Match regex("ERROR";$out;1)=False)
   UTIL_SPLIT_TEXT_BY_LINES ($out;->$resultLines_at) //TechTip 77278
   $regexPat_t:=" bProtectedMode REG_DWORD 0x1"
   $pos_l:=1

   While ($pos_l<Size of array($resultLines_at))
      $foundPos_l:=Find in array($resultLines_at;$regexPat_t;$pos_l)
      If ($foundPos_l>0)
         Append to array($locations_at;$resultLines_at{$foundPos_l-1})
         $pos_l:=$foundPos_l+1
      Else
         $pos_l:=Size of array($resultLines_at)
      End if
   End while

   For ($i;1;Size of array($locations_at))
      SET ENVIRONMENT VARIABLE("_4D_OPTION_HIDE_CONSOLE";"False")
      $string:="REG ADD \""+$locations_at{$i}+"\" /v bProtectedMode /t REG_DWORD /d 0x0 /f"
      LAUNCH EXTERNAL PROCESS($string;$in;$out;$err)
   End for
End if

The method searches for all possible Adobe Reader products for a Key with the value bProtectMode, which stores the setting. Then the results are parsed for Adobe Reader Products with the key toggled on, 0x1 and an array is build with the registry paths to these keys. they are then toggled off by setting the value to 0x0. More details on this feature can be found at
https://www.adobe.com/devnet-docs/acrobatetk/tools/AppSec/protectedmode.html