unit DDrmDecrypt; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.Buttons; type TDlgDrmDecrypt = class(TForm) Label1: TLabel; Label2: TLabel; edEncPath: TEdit; edDecPath: TEdit; btnOpenFile: TSpeedButton; btnOk: TButton; btnCancel: TButton; OpenDialog: TOpenDialog; procedure btnOpenFileClick(Sender: TObject); procedure btnOkClick(Sender: TObject); private { Private declarations } public { Public declarations } end; var DlgDrmDecrypt: TDlgDrmDecrypt; implementation uses Tocsg.Path, Tocsg.DRM.Encrypt, Tocsg.Safe, GlobalDefine, ManagerService, Condition, ManagerModel; {$R *.dfm} procedure TDlgDrmDecrypt.btnOkClick(Sender: TObject); var dec: TTgDrmDec; begin edEncPath.Text := Trim(edEncPath.Text); edDecPath.Text := Trim(edDecPath.Text); if edEncPath.Text = '' then begin MessageBox(Handle, PChar('DRM 파일 경로를 입력해 주십시오.'), PChar(Caption), MB_ICONWARNING or MB_OK); edEncPath.SetFocus; exit; end; if edDecPath.Text = '' then begin MessageBox(Handle, PChar('복호화 파일 경로를 입력해 주십시오.'), PChar(Caption), MB_ICONWARNING or MB_OK); edDecPath.SetFocus; exit; end; if not FileExists(edEncPath.Text) then begin MessageBox(Handle, PChar('DRM 파일이 존재하지 않습니다.'), PChar(Caption), MB_ICONWARNING or MB_OK); edEncPath.SetFocus; exit; end; Guard(dec, TTgDrmDec.Create(edEncPath.Text)); if not dec.CheckSig(SIG_DRM) then begin MessageBox(Handle, PChar('DRM 파일이 아닙니다.'), PChar(Caption), MB_ICONWARNING or MB_OK); edEncPath.SetFocus; exit; end; if not dec.ExtrHead(PASS_DRM_HEAD) then begin MessageBox(Handle, PChar('DRM 헤더 확인중 오류가 발생했습니다.'), PChar(Caption), MB_ICONWARNING or MB_OK); exit; end; if dec.DecryptToFile(GetMK, edDecPath.Text) then begin MessageBox(Handle, PChar('DRM 파일을 복호화 했습니다.'), PChar(Caption), MB_ICONINFORMATION or MB_OK); if gMgSvc.IsNewApi then begin var LogInfo: TLogInfo; ZeroMemory(@LogInfo, SizeOf(LogInfo)); LogInfo.sCode := PREVENT_DRM_DECRYPT; LogInfo.sPath := edEncPath.Text; LogInfo.sSummary := ExtractFileName(edEncPath.Text); gMgSvc.SendEventLogEx(@LogInfo, false); end else gMgSvc.SendEventLog(URI_USER_ACTION, PREVENT_DRM_DECRYPT, Format('%s', [edEncPath.Text])); ModalResult := mrOk; end else MessageBox(Handle, PChar('DRM 파일 복호화를 실패했습니다.'), PChar(Caption), MB_ICONWARNING or MB_OK); end; procedure TDlgDrmDecrypt.btnOpenFileClick(Sender: TObject); begin OpenDialog.FileName := ''; if OpenDialog.Execute(Handle) then begin edEncPath.Text := OpenDialog.FileName; edDecPath.Text := CutFileExt(edEncPath.Text) + '_dec' + ExtractFileExt(edEncPath.Text); end; end; end.