BSOne.SFC/Tocsg.Module/AppCtrl/LIB_Common/AppCtrlDefine.pas

776 lines
26 KiB
Plaintext

{*******************************************************}
{ }
{ AppCtrlDefine }
{ }
{ Copyright (C) 2023 kku }
{ }
{*******************************************************}
unit AppCtrlDefine;
interface
uses
{$IF Defined(_HE_) or Defined(_BS1HP_)}
GlobalDefine,
{$IFEND}
Tocsg.DRM.Encrypt, Tocsg.Obj, Winapi.Windows, System.Classes, System.SysUtils,
System.SyncObjs, Vcl.Graphics, System.Generics.Collections;
const
// \Personalization\Governance\|\Personalization\UserFacts\|\Personalization\Content\ >> \Personalization\
IGNORE_ATTACH_BLOCK_PATHS = ':\ProgramData\|:\Program Files\|:\Program Files (x86)\|:\Windows\|:\Users\Default\AppData\|' + // 이건 넘 범용적인데 일단 넣음
':\Windows\System32\|\WINDOWS\FONTS\|:\ProgramData\NVIDIA Corporation\|' +
'\Microsoft Office\|:\Windows\Microsoft.NET\|\Microsoft\Internet Explorer\|\WebServiceCache\|' +
'\AppData\Local\|\AppData\LocalLow\|:\ProgramData\Microsoft\Windows Defender\|\\.\|:\Program Files\Google\|' +
'\AppData\Roaming\|:\Program Files\Common Files\|\\?\|' +
'\\.\MOUNTPOINTMANAGER|:\PROGRAM FILES\GOOGLE\|:\WINDOWS\ASSEMBLY\|:\PROGRAM FILES (X86)\COMMON FILES\|' +
'\MyGuard\LOG\|\DesktopCentral_Agent\|\Program Files\chrome_BITS_|\Program Files (x86)\chrome_BITS_|' +
'\Manufacturer\Endpoint Agent\|\Microsoft\FORMS\|\Outlook\Offline Address Books\|\Lync\Tracing\|' +
'\Outlook\RoamCache\|\Microsoft\MSIPC\Logs\|ptnsch.dat|:\Windows\SysWOW64\|picpick.ini|\Dropbox\Client\|' +
'\Google\GoogleUpdater\|\Windows\WER\Temp\|\Local\Packages\|\Temp\System32\|\ofv1root\|\OTele\|' +
'\TokenBroker\Cache\|\DisplayForm\|\Personalization\|\Wef\{|\Microsoft\FontCache\|\Temp\Diagnostics\|' +
'\INetCache\IE\|\INetCache\Low\|\INetCache\Virtualized\|\Content.MSO\|\Content.Word\|' +
'\OneAuth\accounts\|\Floodgate\|\Opera Stable\|\Firefox\Profiles\|\WINDOWS\SystemTemp\|' +
'\ProgramData\Microsoft\Windows\|\Adobe\Acrobat DC\|\Globalization\ELS\|\WINDOWS\SysNative\|' +
'\DGAgent\|\FireEye\|\Java\Deployment\cache\|:\WWNTUSER\|\Administrator\Favorites\|' +
'\WeChat Files\|eCrmHeHelper.dll|eCrmHeHelper32.dll|eCrmHeHelperf.dll|eCrmHeHelper32f.dll|' +
'Chakra.ini|ChakraRules.ini|ChakraInfo-1.ini|ChakraGateWay.ini';
OPENDLG_WORDS = '파일|열기|다른|OPEN|SAVE|저장|첨부|打开|打開|保存|Lưu|Simpan|dạng';
IGNORE_ATTACH_BLOCK_EXTS_WB = 'CPL|PMA|manifest|PCKGDEP|API|tbres|ost|' +
'oab|db|xml|db-shm|db-wal|metadata|db-shm|db-journal|tbreq|TTF|OTF|vivaldi_reporting_data'; // |htm|html
IGNORE_ATTACH_BLOCK_EXTS = 'DLL|LNK|ICO|QMLC|' + IGNORE_ATTACH_BLOCK_EXTS_WB;
{$IF Defined(_HE_) or Defined(_BS1HP_)}
APP_WEB_BROWSERS = WEB_BROWSERS;
{$ELSE}
APP_WEB_BROWSERS = 'iexplore.exe|msedge.exe|whale.exe|chrome.exe|firefox.exe|opera.exe';
{$IFEND}
APP_MSOFFICE = 'winword.exe|excel.exe|powerpnt.exe|Microsoft.Mashup.Container.Loader.exe'; // |PDFREFLOW.EXE';
IGNORE_WEB_AB_FILES = 'debug.log|icudtl.dat|preloaded_data.pb|messages.json|CHROME.LNK|' +
'msedge.lnk|firefox.lnk|opera.lnk|mip_config.json|kernel32.pdb|ntdll.pdb|ntdll.pdb';
DRM_EXTS = 'TXT|LOG|DOC|WPS|PDF|XLS|PPT|HWP|HWPX|DOCX|DOTX|XLSX|XLTX|PPTX|POTX|' +
'PPSX|HW|RTF|MW|OW| WP|WP4|WPD|WOP|WM|PW|WMF|WS|WSD|DIF|MWK|W40|WDB|CSV|' +
'WS2|SMTP|EML|MBX|STE|AW|UNI|WKS|WK1|WK3|WK4|FM3|LWP|MWP|XLC|XLM|123|PWD|' +
'MPP|VSD|MSG|OFT|VDX|SXW|SXC|STC|SXI|NSF|DOCM|DOTM|XLSM|XLTM|XLAM|PPTM|' +
'POTM|PPSM|PPAM|XLSB|XPS|DXL|ODT|ODS|ODP|ONM|GRV|PAGES|NUMBERS|KEY|XDW|' +
'ONE|DCM|MLS|ML3|ML4|ML5|ML6|ML7|ML8|ML9|MLA|EMCMF|ACCDT|GUL|JNT|MAT|FIG|' +
'OLM|VCF|ICS|VCS|IWA|VSSX|VSTX|VSTM|SDW|SGL|VOR|SDC|SDD|SDA|SMF|YML|SCPT|' +
'MB|JT|MO|QM|IV|PBIX|IBOOKS|FDF|XFDF|MSO|RSS|SMIL|XSPF|FB2|PPJ|RDF|RSD|SBML|' +
'SRU|SSML|PLS|TEI|METS|MODS|OPF|SRGS|SRX|VXML|CCXML|YIN|CML|VTU|SXD|SXG|ODM|' +
'OTH|FODP|FODS|FODT|OXT|SVM|XDF|HTM|HTML|ASF|MHT|MHTML|MXML|MXL|XML|ASP|METALINK|XDP|XUL';
{$IFDEF DEBUG}
DRM_SUPPORT_APPS = 'EXCEL.EXE|WINWORD.EXE|POWERPNT.EXE|hwp.exe|notepad.exe|' + // 'notepad++.exe|' +
'Acrobat.exe|AcroRd32.exe|HwpViewer.exe|Microsoft.Mashup.Container.Loader.exe|' +
'FoxitPDFReader.exe|FoxitPDFEditor.exe'; //|PDFREFLOW.EXE';
{$ELSE}
DRM_SUPPORT_APPS = 'EXCEL.EXE|WINWORD.EXE|POWERPNT.EXE|hwp.exe|notepad.exe|notepad++.exe|' +
'Acrobat.exe|AcroRd32.exe|HwpViewer.exe|Microsoft.Mashup.Container.Loader.exe|' +
'FoxitPDFReader.exe|FoxitPDFEditor.exe'; //|PDFREFLOW.EXE';
{$ENDIF}
{$IFDEF DEBUG}
// 크롬 제거
// PRINT_SUPPORT_APPS = 'EXCEL.EXE|WINWORD.EXE|POWERPNT.EXE|hwp.exe|' + //'msedge.exe|' +
PRINT_SUPPORT_APPS = 'EXCEL.EXE|WINWORD.EXE|POWERPNT.EXE|hwp.exe|' + //'chrome.exe|msedge.exe|whale.exe|' +
'Evernote.exe|mspaint.exe|Honeyview.exe|notepad.exe|' + //'notepad++.exe|' +
'Acrobat.exe|AcroRd32.exe|RdrCEF.exe|AcroCEF.exe|' +
'NeoiCube.exe|MSIP.Viewer.exe|FoxitPDFReader.exe|FoxitPDFEditor.exe|' +
'scdmis.exe|scd_erp.exe|ALPDF.exe|wordpad.exe';
{$ELSE}
PRINT_SUPPORT_APPS = 'EXCEL.EXE|WINWORD.EXE|POWERPNT.EXE|hwp.exe|' + //'chrome.exe|msedge.exe|whale.exe|' +
'Evernote.exe|mspaint.exe|Honeyview.exe|notepad.exe|notepad++.exe|' +
'Acrobat.exe|AcroRd32.exe|' + //'RdrCEF.exe|AcroCEF.exe|' +
'Hword.exe|Hpdf.exe|HCell.exe|HShow.exe|' +
'NeoiCube.exe|MSIP.Viewer.exe|FoxitPDFReader.exe|FoxitPDFEditor.exe|' +
'scdmis.exe|scd_erp.exe|ALPDF.exe|wordpad.exe';
{$ENDIF}
BLUETOOTH_SUPPORT_APPS = 'FSQUIRT.exe';
USB_TO_USB_SUPPORT_APPS = 'LINKENGKM.EXE';
MTP_SUPPORT_APPS = 'EXPLORER.EXE';
CDROM_SUPPORT_APPS = 'EXPLORER.EXE';
RPINT_SUPPORT_APPS_HEC = 'EXCEL.EXE|WINWORD.EXE|POWERPNT.EXE|Acrobat.exe|AcroRd32.exe|AcroCEF.exe|' +
'MSIP.Viewer.exe|FoxitPDFReader.exe|FoxitPDFEditor.exe';
PRINT_PATH_EXT = 'DOC|DOCX|PPT|PPTX|XLS|XLSX|TXT|RTF|LOG|PDF|JPG|JPEG|PSD|' +
'BMP|PNG|HWP|HWPX|HTML|HTM|XML';
WEB_AB_DELAY_EXT = 'PDF|PPT|PPTX|DOC|DOCX|XLS|XLSX|CSV|TXT|HWP|JPG|JPEG|GIF|PNG|JFIF|SVG';
{$IFNDEF _HE_}
PASS_DRM_HEAD: AnsiString = '#df12mf8(zfq@'; // KvCttSch.exe (ThdCttSch.pas)에서 사용, 수정 시 주의
PASS_DRM_DATA: AnsiString = ':0A2CCABB38C8AD80963A5B1A668ECF9D99270819F1EEE2045B554E81043CCEC3E1E11851D7DE9C65F73F327E3E9585DA'; // 'M}[8k(Ga1/<;LE1j&q';
SIG_DRM: AnsiString = 'ToCSG';
PASS_STRENC = '(skd82_sl9+a'; // KvCttSch.exe (ThdCttSch.pas)에서 사용, 수정 시 주의
{$ENDIF}
SMALL_FONT = 'chrome.exe|msedge.exe|Evernote.exe';
// START_PROCESS = 'excel.exe';
END_PROCESS = 'chrome.exe|msedge.exe|Honeyview.exe|POWERPNT.EXE|' + // 'ApplicationFrameHost.exe|' +
'mspaint.exe|AcroRd32.exe|Acrobat.exe|Evernote.exe';
WORD_GAP = ' ';
ACC_TEST_LOG = 1001;
ACC_APP_INFO = 1002;
ACC_SET_POLICY = 1003;
ACC_SAFE_TERMINATE_CLIENT = 1004;
ACC_NOTI_MSG = 1005;
ACC_SET_CAPTURE_BLOCK = 1006;
ACC_GOODBYE = 1007;
type
TCurAppType = (catNormal, catOutlook, catWebb, catMsOffice, catHwp, catExplorer,
catAdobeReader, catNotepad, catkvHelper, catwinscp, catBizbox, catFilezilla,
catChrome, catMsedge, catMswebv, catOlk, catWhale, catFquirt, catLINKENGKM, catUsb, catCdrom, catMtp);
TDrmHeadInfo = record
sEmpNo,
sHostName,
sPartName,
sPgName: String;
dwCustomerCode: DWORD;
end;
PDrmFileInfo = ^TDrmFileInfo;
TDrmFileInfo = record
hFile: THandle;
sOrgPath,
sDecPath: String;
bChgRO,
bModified,
bModifyAble: Boolean;
// Head 없앰 24_0814 09:06:42 kku
HeadInfo: TDrmHeadInfo;
end;
{$IF not Defined(_HE_) and not Defined(_BS1HP_)}
TDrmAccessKind = (dakNone, dakEmpNo, dakDept, dakAll);
TPrtWaterCfg = record
bActive: Boolean;
sTopText,
sBotText: String;
nTopSize,
nBotSize,
nTopPos,
nBotPos: Integer
end;
TShFileCrMon = record
sMode: String; // secu, sleep, vul, off, exp
nKind: Integer; // 0 : none, 1 : monitor, 2 : block
bBlkNoti,
bMonNoti: Boolean;
sExpLst: String;
end;
{$IFEND}
TFileUseBlock = (fubNone, fubBlock, fubMonitor);
TAppCtrlOpt = record
sTaskDir: String;
dwCustomerType: DWORD;
hMainWnd: HWND;
// DRM
DrmAccessKind,
DrmModifyKind: TDrmAccessKind;
bDrmAttachAble: Boolean;
sDrmPass,
sUName,
sEmpNo,
sDeptName: String;
// Print
nFontSize,
nLineCount,
nPrintWaterAlpha: Integer;
fWmTran: Double; // 투명도
// sTextOutApp,
// sTextOutDir,
sPrtEmfOutDir,
sIpAddr,
sPrintWaterImg,
sPrintWaterExp: String;
bPrintSecu,
bPrintWater,
bPrtCollect: Boolean;
PrtWaterCfg: TPrtWaterCfg;
// File WebbAB
FileUseBlock: TFileUseBlock;
bCheckUrl,
bUseContentFilter,
bReadBlock,
bWriteBlock,
bFileApproval,
bIgrNetPathAB,
bOpenDetect: Boolean;
ShFileCrMon: TShFileCrMon;
nBlockSizeMB: Integer;
// Noti
hRcvWnd,
hTagWnd,
hCltWnd: HWND; // 캡쳐 방지 윈도우 메인값
// 기타, 테스트를 위한 기능
sAccount,
sAcName,
sAcSSid,
sAipPath: String;
bMtpWB: Boolean;
sMtpRoExp: String;
bIsTest: Boolean;
// mgkim 파일 생성 차단
IntUsbToUsbBlockNewFile,
IntUsbBlockNewFile,
IntCdromBlockNewFile,
IntMtpBlockNewFile,
IntBtBlockNewFile: TIntBlockNewFile;
end;
TAppCtrlHelper = class(TTgObject)
private
CS_: TCriticalSection;
CurAppType_: TCurAppType;
CurAppDetailType_ : TCurAppType;
bForceEncSave_: Boolean;
DrmExtList_,
IgrAttBlkExts_,
OpenDlgWordList_,
IgrAttBlkWebFiles_,
IgrAttBlkPaths_: TStringList;
DcDecPath_: TDictionary<String,String>;
DcDrmFI_: TDictionary<THandle,PDrmFileInfo>;
bDrmSupport_,
bPrtSupport_, // 탐색기에서 바로 "인쇄"하는거 때문에 추가 25_0205 13:33:50 kku
bDrmUseBoxedApp_: Boolean;
CtrlOpt_: TAppCtrlOpt;
sAppName_,
sDllPath_: String;
dwPid_: DWORD;
IgrReadL_,
IgrWriteL_: TList<THandle>;
bIsPPT_,
bIsWord_,
bIsExcel_,
bChkDelOnClose_: Boolean;
FoExpList_,
NetDrvList_,
MtpRoExpList_: TStringList;
sMtpRoExpList_: String;
// 브라우저 파일 차단할때 바로열기 체크, 지연처리를 위함
// WebAbOpenDelayExtList_: TStringList;
procedure Lock;
procedure Unlock;
procedure OnDrmFileNotify(Sender: TObject; const Item: PDrmFileInfo; Action: TCollectionNotification);
function GetCtrlOpt: TAppCtrlOpt;
procedure SetCtrlOpt(aOpt: TAppCtrlOpt);
public
hOpenDlgWnd_: HWND;
RecentDrmFI_: TDrmFileInfo; // MS오피스 저장 파일 암호화를 위함
// 프린트 관련 임시 저장
nPtrCnt_: Integer;
sPtrText_,
sCurDocName_: String;
bSmallFont_,
bBothDocProc_, // StartPage, EndPage 두번 처리 23_1024 11:02:43 kku
bEndDocProc_,
bIsPrinting_,
bIsWaterMaking_: Boolean;
// DRM 관련 임시 저장
dwRecentOpenCustomType_: DWORD;
sRecentOpenPath_,
sRecentOpenEmpNo_,
sRecentOpenDeptName_: String;
// 파일 쓰기 차단 체크
sRecentWrBkPath_: String;
nRecentWrBkCnt_: Integer;
sPrintWaterTxt: String;
Constructor Create(sAppPath: String);
Destructor Destroy; override;
function IsNetPath(sPath: String): Boolean;
procedure NoDrmUse;
// todo : 사용하지 않을거 같음 24_0122 14:18:40 kku
procedure AddIgrReadFile(aFile: THandle);
procedure DelOgrReadFile(aFile: THandle);
function IsIgrReadFile(aFile: THandle): Boolean;
// todo : 사용하지 않을거 같음 24_0122 14:18:40 kku
procedure AddIgrWriteFile(aFile: THandle);
procedure DelOgrWriteFile(aFile: THandle);
function IsIgrWriteFile(aFile: THandle): Boolean;
// function IsWebAbDelayExt(sExt: String): Boolean;
// procedure CopyPrintDC(hPtrDC: HDC);
property CurAppType: TCurAppType read CurAppType_;
property CurAppDetailType: TCurAppType read CurAppDetailType_;
property DrmExtList: TStringList read DrmExtList_;
property IgrAttBlkExts: TStringList read IgrAttBlkExts_;
property OpenDlgWordList: TStringList read OpenDlgWordList_;
property IgrAttBlkWebFiles: TStringList read IgrAttBlkWebFiles_;
property IgrAttBlkPaths: TStringList read IgrAttBlkPaths_;
property DcDecPath: TDictionary<String,String> read DcDecPath_;
property DcDrmFI: TDictionary<THandle,PDrmFileInfo> read DcDrmFI_;
property CtrlOpt: TAppCtrlOpt read GetCtrlOpt write SetCtrlOpt;
property IsDrmSupport: Boolean read bDrmSupport_;
property IsPrtSupport: Boolean read bPrtSupport_;
property IsDrmUseBoxedApp: Boolean read bDrmUseBoxedApp_;
property IsForceEncSave: Boolean read bForceEncSave_;
property IsExcel: Boolean read bIsExcel_;
property IsPPT: Boolean read bIsPPT_;
property IsWord: Boolean read bIsWord_;
property DllPath: String read sDllPath_;
property PID: DWORD read dwPid_;
property MtpRoExpList: TStringList read MtpRoExpList_;
property AppName: String read sAppName_;
property FoExpList: TStringList read FoExpList_;
property ChkDelOnClose: Boolean read bChkDelOnClose_;
end;
{$IFNDEF _HE_} // BSOne는 GlobalDefine.pas에 정의됨
function DecText(sText: String): String; inline;
{$ENDIF}
implementation
uses
{$IFDEF _APPCTRL_}
AppHook,
{$ENDIF}
Tocsg.Strings, Tocsg.Safe, Tocsg.Encrypt, Condition, Tocsg.Graphic,
Tocsg.Network, Tocsg.Exception, Vcl.Imaging.pngimage, Tocsg.Registry, Tocsg.Process;
{$IFNDEF _HE_}
function DecText(sText: String): String; inline;
begin
Result := '';
if Length(sText) < 2 then
exit;
if sText[1] = ':' then
begin
Delete(sText, 1, 1);
Result := DecBinStrToStr(ekAes256cbc, PASS_STRENC, sText);
end else
Result := sText;
end;
{$ENDIF}
procedure LogToReg(sVName, sLog: string); inline;
begin
// SetRegValueString(HKEY_CURRENT_USER, 'SOFTWARE\eCrmHomeEdition', sVName, sLog, true);
end;
{ TAppCtrlHelper }
Constructor TAppCtrlHelper.Create(sAppPath: String);
procedure Init;
var
TempList: TStringList;
sPath: array [0..512] of Char;
begin
Guard(TempList, TStringList.Create);
TempList.CaseSensitive := false;
sAppName_ := LowerCase(ExtractFileName(sAppPath));
// GetModuleFileName(0, sPath, 512); // sAppPath - Current App
if GetModuleFileName(HInstance, sPath, 512) > 0 then // DLL Path
sDllPath_ := String(sPath)
else
sDllPath_ := '';
dwPid_ := GetCurrentProcessId;
// 프린트 관련 임시 저장
nPtrCnt_ := 0;
hOpenDlgWnd_ := 0;
sPtrText_ := '';
sCurDocName_ := '';
sPrintWaterTxt := '';
bIsPrinting_ := false;
bIsWaterMaking_ := false;
// bBothDocProc_ := false;
SplitString(END_PROCESS, '|', TempList);
// bEndDocProc_ := TempList.IndexOf(sAppName_) > -1;
bIsExcel_ := SameText(sAppName_, 'excel.exe');
bIsPPT_ := SameText(sAppName_, 'powerpnt.exe');
bIsWord_ := SameText(sAppName_, 'winword.exe'); // or SameText(sAppName_, 'PDFREFLOW.EXE');
// HEC 방식 일괄적용 23_1222 10:12:57 kku
// bEndDocProc_ := true;
bEndDocProc_ := CompareText(sAppName_, 'notepad.exe') <> 0;
// 엑셀은 색상있는 셀의 경우 나중에 색상을 입히기 때문에 워터마크가 짤리는 문제가 있다.
// StartPage, EndPage 두개 모두 찍어준다. 23_1024 14:05:15 kku
bBothDocProc_ := bIsExcel_;
// 투명도를 도트 방식에서 GDI+로 변경하후 다시 이렇게 변경함.. 24_0125 13:41:22 kku
// 일단.. 위처럼 롤백함 24_0126 14:15:15 kku
// 엑셀에서 깔끔하게 투명도 적용할 방법이 떠오르지 않음 24_0126 14:15:28 kku
// bEndDocProc_ := CompareText(sAppName_, 'excel.exe') <> 0;
// bBothDocProc_ := false;
///////
SplitString(SMALL_FONT, '|', TempList);
bSmallFont_ := TempList.IndexOf(sAppName_) > -1;
CurAppType_ := catNormal;
ZeroMemory(@CtrlOpt_, SizeOf(CtrlOpt_));
ZeroMemory(@RecentDrmFI_, SizeOf(RecentDrmFI_));
if (sAppName_ = 'hwp.exe') or (sAppName_ = 'HwpViewer.exe') then
CurAppType_ := catHwp
else if sAppName_ = 'outlook.exe' then
CurAppType_ := catOutlook
else if sAppName_ = 'explorer.exe' then
CurAppType_ := catExplorer
else if (sAppName_ = 'acrobat.exe') or (sAppName_ = 'acrord32.exe') or SameText('PDFREFLOW.EXE', sAppName_) then
CurAppType_ := catAdobeReader
else if sAppName_ = 'notepad.exe' then
CurAppType_ := catNotepad
else if sAppName_ = 'kvcttsch.exe' then
CurAppType_ := catkvHelper
else if sAppName_ = 'winscp.exe' then
CurAppType_ := catwinscp
else if sAppName_ = 'filezilla.exe' then //윈스테크넷 filezilla 타입 추가 251128 mgkim
CurAppType_ := catFilezilla
else if sAppName_ = 'bizboxamessenger.exe' then // 더존 메신저, 첨부와 파일 열기 구분 처리 25_1112 10:10:17 kku
CurAppType_ := catBizbox
else if sAppName_ = 'msedgewebview2.exe' then
CurAppType_ := catMswebv
else if sAppName_ = 'olk.exe' then
CurAppType_ := catOlk
else if SameText(BLUETOOTH_SUPPORT_APPS, sAppName_) then
CurAppType_ := catFquirt
else if SameText(USB_TO_USB_SUPPORT_APPS, sAppName_) then
CurAppType_ := catLINKENGKM;
if CurAppType_ = catNormal then
begin
// ppt는 워터마크 별도 처리 때문에 catPPT 분리 했다. 주의 필요
SplitString(APP_MSOFFICE, '|', TempList);
if TempList.IndexOf(sAppName_) <> -1 then
CurAppType_ := catMsOffice;
end;
if CurAppType_ = catNormal then
begin
SplitString(APP_WEB_BROWSERS, '|', TempList);
if TempList.IndexOf(sAppName_) <> -1 then
begin
CurAppType_ := catWebb;
bSmallFont_ := true;
//20251201 mgkim catWebb 별도 브라우저 구분이 없어서 추가
if sAppName_ = 'msedge.exe' then
CurAppDetailType_ := catMsedge
else if sAppName_ = 'chrome.exe' then
CurAppDetailType_ := catChrome
else if sAppName_ = 'whale.exe' then
CurAppDetailType_ := catWhale;
end;
end;
bChkDelOnClose_ := SameText('Microsoft.Mashup.Container.Loader.exe', sAppName_); // or SameText('PDFREFLOW.EXE', sAppName_);
bDrmUseBoxedApp_ := false; // ('acrord32.exe' = sAppName_) or ('acrobat.exe' = sAppName_);
// bDrmUseBoxedApp_ := CurAppType_ = catMsOffice;
// bDrmSupport_ := ('notepad.exe' = sAppName_) or ('notepad++.exe' = sAppName_);
// bDrmSupport_ := 'hwp.exe' = sAppName_;
SplitString(DRM_SUPPORT_APPS, '|', TempList);
bDrmSupport_ := TempList.IndexOf(sAppName_) <> -1;
if bDrmSupport_ then
begin
var sPPName: String := GetProcessNameByPid(GetProcessPPidByPid(GetCurrentProcessId));
if SameText('svchost.exe', sPPName) then
begin
// 탐색기에서 "미리 보기"를 활성화 하면 .docx 파일등 미리보기를 시도할때 word가 실행되는데
// 이때는 관련 API가 적용되지 않도록 보완 25_0121 14:02:07 kku
bDrmSupport_ := false;
end else
if bIsExcel_ then
begin
// 더존 ERP에서 엑셀 실행 시 DRM 훅 무시 25_0119 15:02:10 kku
if SameText('NeoiCube.exe', sPPName) then
bDrmSupport_ := false;
end;
end;
SplitString(PRINT_SUPPORT_APPS, '|', TempList);
bPrtSupport_ := TempList.IndexOf(sAppName_) <> -1;
OpenDlgWordList_ := TStringList.Create;
SplitString(UpperCase(OPENDLG_WORDS), '|', OpenDlgWordList_);
IgrAttBlkExts_ := TStringList.Create;
if CurAppType_ = catWebb then
SplitString(UpperCase(IGNORE_ATTACH_BLOCK_EXTS_WB), '|', IgrAttBlkExts_)
else
SplitString(UpperCase(IGNORE_ATTACH_BLOCK_EXTS), '|', IgrAttBlkExts_);
IgrAttBlkWebFiles_ := TStringList.Create;
IgrAttBlkWebFiles_.CaseSensitive := false;
SplitString(IGNORE_WEB_AB_FILES, '|', IgrAttBlkWebFiles_);
IgrAttBlkPaths_ := TStringList.Create;
SplitString(UpperCase(IGNORE_ATTACH_BLOCK_PATHS), '|', IgrAttBlkPaths_);
IgrAttBlkPaths_.Add(UpperCase(ExtractFilePath(sAppPath)));
// WebAbOpenDelayExtList_ := TStringList.Create;
// WebAbOpenDelayExtList_.CaseSensitive := false;
// SplitString(WEB_AB_DELAY_EXT, '|', WebAbOpenDelayExtList_);
MtpRoExpList_ := TStringList.Create;
sMtpRoExpList_ := '';
// 컨텐츠 필터 걸고
// 아웃룩은 \Content.Outlook\만 별도로 허용하도록 보완 24_0321 15:29:16 kku
// if CurAppType_ = catOutlook then
// begin
// // 이거 안빼면 한번 포함된어서 ..\AppData\Local\.. \Content.Outlook\ 경로에 있는 파일들은 차단이 안된다 23_0425 11:09:00 kku
// var i: Integer := IgrAttBlkPaths_.IndexOf('\AppData\Local\');
// if i <> -1 then
// IgrAttBlkPaths_.Delete(i);
// end;
DrmExtList_ := TStringList.Create;
DrmExtList_.CaseSensitive := false;
SplitString(DRM_EXTS, '|', DrmExtList_);
DcDecPath_ := TDictionary<String,String>.Create;
DcDrmFI_ := TDictionary<THandle,PDrmFileInfo>.Create;
DcDrmFI_.OnValueNotify := OnDrmFileNotify;
IgrReadL_ := TList<THandle>.Create;
IgrWriteL_ := TList<THandle>.Create;
NetDrvList_ := TStringList.Create;
GetNetDrives(NetDrvList_);
FoExpList_ := TStringList.Create;
end;
begin
Inherited Create;
CS_ := TCriticalSection.Create;
Init;
InitializeGDIPlus; // 추가 24_0125 11:19:36 kku
end;
Destructor TAppCtrlHelper.Destroy;
begin
FinalizeGDIPlus; // 추가 24_0125 11:19:36 kku
FreeAndNil(FoExpList_);
FreeAndNil(NetDrvList_);
FreeAndNil(IgrWriteL_);
FreeAndNil(IgrReadL_);
FreeAndNil(DcDrmFI_);
FreeAndNil(MtpRoExpList_);
FreeAndNil(DcDecPath_);
FreeAndNil(DrmExtList_);
// FreeAndNil(WebAbOpenDelayExtList_);
FreeAndNil(IgrAttBlkPaths_);
FreeANdNil(IgrAttBlkWebFiles_);
FreeAndNil(IgrAttBlkExts_);
FreeAndNil(OpenDlgWordList_);
Inherited;
FreeAndNil(CS_);
end;
procedure TAppCtrlHelper.Lock;
begin
CS_.Acquire;
end;
procedure TAppCtrlHelper.Unlock;
begin
CS_.Release;
end;
procedure TAppCtrlHelper.OnDrmFileNotify(Sender: TObject; const Item: PDrmFileInfo; Action: TCollectionNotification);
begin
if Action = cnRemoved then
Dispose(Item);
end;
function TAppCtrlHelper.IsNetPath(sPath: String): Boolean;
begin
if sPath = '' then
begin
Result := false;
exit;
end;
Result := NetDrvList_.IndexOf(Format('%s:', [UpperCase(sPath)[1]])) <> -1;
end;
procedure TAppCtrlHelper.NoDrmUse;
begin
bDrmSupport_ := false;
end;
procedure TAppCtrlHelper.AddIgrReadFile(aFile: THandle);
begin
if IgrReadL_.IndexOf(aFile) = -1 then
IgrReadL_.Add(aFile);
end;
procedure TAppCtrlHelper.DelOgrReadFile(aFile: THandle);
var
i: Integer;
begin
i := IgrReadL_.IndexOf(aFile);
if i <> -1 then
IgrReadL_.Delete(i);
end;
function TAppCtrlHelper.IsIgrReadFile(aFile: THandle): Boolean;
begin
Result := IgrReadL_.IndexOf(aFile) <> -1;
end;
procedure TAppCtrlHelper.AddIgrWriteFile(aFile: THandle);
begin
if IgrWriteL_.IndexOf(aFile) = -1 then
IgrWriteL_.Add(aFile);
end;
procedure TAppCtrlHelper.DelOgrWriteFile(aFile: THandle);
var
i: Integer;
begin
i := IgrWriteL_.IndexOf(aFile);
if i <> -1 then
IgrWriteL_.Delete(i);
end;
function TAppCtrlHelper.IsIgrWriteFile(aFile: THandle): Boolean;
begin
Result := IgrWriteL_.IndexOf(aFile) <> -1;
end;
function TAppCtrlHelper.GetCtrlOpt: TAppCtrlOpt;
begin
Lock;
try
Result := CtrlOpt_;
finally
Unlock;
end;
end;
procedure TAppCtrlHelper.SetCtrlOpt(aOpt: TAppCtrlOpt);
begin
Lock;
try
CtrlOpt_ := aOpt;
finally
Unlock;
end;
bEndDocProc_ := CompareText(sAppName_, 'notepad.exe') <> 0; //true;
bBothDocProc_ := false;// bIsExcel_; // 클리핑 제거로 엑셀 문제 해결, HEC 나중에 확인 25_0605 15:13:25 kku
case CtrlOpt_.dwCustomerType of
// CUSTOMER_KBIZ,
// CUSTOMER_JUVIS,
CUSTOMER_GEC,
CUSTOMER_HDENG :
begin
bEndDocProc_ := true;
// 엑셀은 색상있는 셀의 경우 나중에 색상을 입히기 때문에 워터마크가 짤리는 문제가 있다.
// StartPage, EndPage 두개 모두 찍어준다. 23_1024 14:05:15 kku
// bBothDocProc_ := CtrlOpt_.dwCustomerType <> CUSTOMER_JUVIS; // bIsExcel_;
// if CtrlOpt_.dwCustomerType = CUSTOMER_HDENG then
bBothDocProc_ := bIsExcel_;
// else
// bBothDocProc_ := false;
// 두명도를 도트 방식에서 GDI+로 변경한 후 이렇게 바꿈
// 엑셀을 두번 칠하게 되면 진해지는 문제가 있음...
// bEndDocProc_ := not bIsExcel_;
// bBothDocProc_ := false;
end;
CUSTOMER_ALADIN :
begin
var n: Integer := IgrAttBlkExts_.IndexOf('EXE');
if n <> -1 then
IgrAttBlkExts_.Delete(n);
end;
{ // 워터마크 전체적인 조절로 인해 bBothDocProc_ := true를 기본으로 함 24_0820 15:28:33 kku
// CUSTOMER_KOCES :
else
begin
var TempList: TStringList;
Guard(TempList, TStringList.Create);
SplitString(END_PROCESS, '|', TempList);
bEndDocProc_ := TempList.IndexOf(sAppName_) > -1;
case CtrlOpt_.dwCustomerType of
CUSTOMER_KOCES,
CUSTOMER_INZENT : bEndDocProc_ := bEndDocProc_ or bIsExcel_;
end;
// if CtrlOpt_.dwCustomerType = CUSTOMER_KOCES then
// bBothDocProc_ := bIsExcel_
// else
bBothDocProc_ := false;
end;
}
end;
if sMtpRoExpList_ <> CtrlOpt_.sMtpRoExp then
begin
sMtpRoExpList_ := CtrlOpt_.sMtpRoExp;
SplitString(sMtpRoExpList_, ';', MtpRoExpList_);
var i: Integer;
var s: String;
var EntList: TStringList;
Guard(EntList, TStringList.Create);
for i := MtpRoExpList_.Count - 1 downto 0 do
begin
s := StringReplace(UpperCase(MtpRoExpList_[i]), 'USB\', '', [rfReplaceAll]);
SplitString(s, '&', EntList);
if EntList.Count > 1 then
MtpRoExpList_[i] := EntList[0] + '&' + EntList[1]
else
MtpRoExpList_[i] := s;
end;
end;
end;
//function TAppCtrlHelper.IsWebAbDelayExt(sExt: String): Boolean;
//begin
// Result := WebAbOpenDelayExtList_.IndexOf(sExt) <> -1;
//end;
end.