{*******************************************************} { } { ProcessParam } { } { Copyright (C) 2025 kku } { } {*******************************************************} unit ProcessParam; interface uses System.SysUtils, Winapi.Windows, Winapi.Messages, Tocsg.Param, Tocsg.Trace, System.Classes; type TProcessParam = class(TTgParam) private sFsDir_, sOwnerMtx_: String; Trace_: TTgTrace; public Constructor Create; Destructor Destroy; override; function IsParamOK: Boolean; property OwnerMtx: String read sOwnerMtx_; property FsDir: String read sFsDir_; end; var gParam: TProcessParam = nil; implementation uses Tocsg.Path, superobject, Tocsg.Fasoo.Global, Tocsg.Safe, Tocsg.Strings, Tocsg.Fasoo.Global.Define; { TProcessParam } Constructor TProcessParam.Create; begin Inherited Create; ASSERT(gParam = nil); sOwnerMtx_ := ''; Trace_ := nil; {$IFDEF DEBUG} var sLog: String := GetRunExePath; if FileExists(sLog) then DeleteFile(PChar(sLog)); Trace_ := TTgTrace.Create(sLog); {$ENDIF} sFsDir_ := GetRunExePathDir + 'fsdinitg'; if not DirectoryExists(sFsDir_) then sFsDir_ := GetRunExePathDir + 'conf\fsdinitg'; gParam := Self; end; Destructor TProcessParam.Destroy; begin if Trace_ <> nil then FreeAndNil(Trace_); gParam := nil; Inherited; end; function TProcessParam.IsParamOK: Boolean; var sPath, sEncPath, sDecPath, sCPID: String; O: ISuperObject; nType: Integer; InfoList: TStringList; begin Result := false; sPath := GetParamValue('/p'); if sPath = '' then sPath := GetParamValue('-p'); if (sPath = '') or not FileExists(sPath) then sPath := GetRunExePathDir + DAT_PARAM; sEncPath := ''; sDecPath := ''; if LoadJsonObjFromFile(O, sPath) then begin {$IFNDEF DEBUG} DeleteFile(PChar(sPath)); {$ENDIF} if (Trace_ = nil) and O.B['Trace'] and (O.S['TracePath'] <> '') then begin DeleteFile(PChar(O.S['TracePath'])); Trace_ := TTgTrace.Create(O.S['TracePath']); end; if (O.S['FsDir'] <> '') and DirectoryExists(O.S['FsDir']) then sFsDir_ := O.S['FsDir']; if O.I['Type'] = 1 then begin sOwnerMtx_ := O.S['OwnerX']; Result := true; exit; end; sEncPath := O.S['EncPath']; sDecPath := O.S['DecPath']; end else begin sPath := GetParamValue('/c'); if sPath = '' then sPath := GetParamValue('-c'); if sPath <> CODE_CMD then exit; sEncPath := GetParamValue('/s'); if sEncPath = '' then sEncPath := GetParamValue('-s'); sDecPath := GetParamValue('/d'); if sDecPath = '' then sDecPath := GetParamValue('-d'); end; if not FileExists(sEncPath) then exit; TTgTrace.T('ÆÄ¼öDRM º¹È£È­ ½ÃÀÛ. EncPath=%s, DecPath=%s', [sEncPath, sDecPath]); nType := GetFileTypeW_r(sEncPath); case nType of 109, // À̰йºÁö ¸ð¸£Áö¸¸ GetFileTypeW_r()·Î FED5 ¾ÏȣȭÆÄÀÏ¿¡¼­ °ËÃâµÊ.. 25_0217 18:54:27 kku 26, 103, 105, 106 : ; else begin TTgTrace.T('ÆÄ¼öDRM ÆÄÀÏÀÌ ¾Æ´Õ´Ï´Ù. Path=%s, Type=%d', [sEncPath, nType]); exit; end; end; sPath := GetFileHeader_r(sEncPath); if sPath = '' then begin TTgTrace.T('ÆÄÀÏ Çì´õ Á¤º¸¸¦ °¡Á®¿Ã ¼ö ¾ø½À´Ï´Ù. Path=%s', [sEncPath]); exit; end; Guard(InfoList, TStringList.Create); SplitString(sPath, ';', InfoList, true); if InfoList.Count < 18 then begin TTgTrace.T('CPID °ªÀ» È®ÀÎ ÇÒ ¼ö ¾ø½À´Ï´Ù.'); exit; end; sCPID := InfoList[17]; // 18¹øÂ°¿¡ ÀÖÀ½ if not DirectoryExists(sFsDir_) then begin TTgTrace.T('FSD Æú´õ°¡ ¾ø½À´Ï´Ù.'); exit; end; nType := DoExtract_r(sFsDir_, sCPID, sEncPath, sDecPath); if nType = FASOO_OK then TTgTrace.T('ÆÄ¼öDRM º¹È£È­ ¼º°ø') else TTgTrace.T('ÆÄ¼öDRM º¹È£È­ ½ÇÆÐ, Error=%d', [nType]); end; end.