unit Dbs1fsgMain; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls; type TDlgbs1fsgMain = class(TForm) Button1: TButton; tMtx: TTimer; procedure Button1Click(Sender: TObject); procedure tMtxTimer(Sender: TObject); private { Private declarations } sOwnerMtx_, sFsDir_: String; InfoList_: TStringList; public { Public declarations } Constructor Create(aOwner: TComponent); override; Destructor Destroy; override; procedure process_WM_COPYDATA(var msg: TMessage); Message WM_COPYDATA; end; var Dlgbs1fsgMain: TDlgbs1fsgMain; implementation uses Tocsg.Fasoo.Global, Tocsg.Safe, Tocsg.Strings, Tocsg.Win32, ProcessParam, Tocsg.Exception, superobject, Tocsg.Fasoo.Global.Define, Tocsg.Trace; {$R *.dfm} Constructor TDlgbs1fsgMain.Create(aOwner: TComponent); begin Inherited Create(aOwner); sOwnerMtx_ := gParam.OwnerMtx; sFsDir_ := gParam.FsDir; InfoList_ := TStringList.Create; ChangeWindowMessageFilter(WM_COPYDATA, MSGFLT_ADD); if sOwnerMtx_ = '' then TerminateProcess(GetCurrentProcess, 98); tMtx.Enabled := true; end; Destructor TDlgbs1fsgMain.Destroy; begin FreeAndNil(InfoList_); Inherited; end; procedure TDlgbs1fsgMain.Button1Click(Sender: TObject); var nType: Integer; sHInfo, sFsDir, sEncPath, sDecPath, sCPID: String; InfoList: TStringList; begin SetOverWriteFlag(1); // sFsDir := 'C:\taskToCSG\Tocsg.Module\FasooDRM\Document\25_0123 CJ_EDLP_¾Ïº¹È£È­ API (¼öÁ¤)\FasooPackagerADK_DLL\Release\fsdinit'; sFsDir := 'C:\taskToCSG\eCrmHE\OUT_Debug - Win64\conf\fsdinitg'; sEncPath := 'C:\taskToCSG\Tocsg.Module\FasooDRM\Document\25_0123 CJ_EDLP_¾Ïº¹È£È­ API (¼öÁ¤)\FasooPackagerADK_DLL\Release\content\encfile\FED5.xls'; sDecPath := 'C:\taskToCSG\Tocsg.Module\FasooDRM\Document\25_0123 CJ_EDLP_¾Ïº¹È£È­ API (¼öÁ¤)\FasooPackagerADK_DLL\Release\content\decfile\FED5_dec.xls'; // sEncPath := 'C:\taskToCSG\Tocsg.Module\FasooDRM\Document\25_0123 CJ_EDLP_¾Ïº¹È£È­ API (¼öÁ¤)\FasooPackagerADK_DLL\Release\content\encfile\FED4.xls'; // sDecPath := 'C:\taskToCSG\Tocsg.Module\FasooDRM\Document\25_0123 CJ_EDLP_¾Ïº¹È£È­ API (¼öÁ¤)\FasooPackagerADK_DLL\Release\content\decfile\FED4_dec.xls'; // GetFileType_r()´Â Á¦´ë·Î µ¿ÀÛ¾ÏÇÔ 25_0217 18:44:44 kku nType := GetFileTypeW_r(sEncPath); case nType of 26, 103, 105, 106 : ; else begin ShowMessage(Format('ÆÄ¼öDRM ÆÄÀÏÀÌ ¾Æ´Õ´Ï´Ù. Type=%d', [nType])); exit; end; end; sHInfo := GetFileHeader_r(sEncPath); if sHInfo = '' then begin ShowMessage('ÆÄÀÏ Çì´õ Á¤º¸¸¦ °¡Á®¿Ã ¼ö ¾ø½À´Ï´Ù.'); exit; end; Guard(InfoList, TStringList.Create); SplitString(sHInfo, ';', InfoList, true); if InfoList.Count < 18 then begin ShowMessage('CPID °ªÀ» È®ÀÎ ÇÒ ¼ö ¾ø½À´Ï´Ù.'); exit; end; sCPID := InfoList[17]; // 18¹øÂ°¿¡ ÀÖÀ½ if DoExtract_r(sFsDir, sCPID, sEncPath, sDecPath) = FASOO_OK then ShowMessage('º¹È£È­ ¼º°ø') else ShowMessage('º¹È£È­ ½ÇÆÐ'); end; procedure TDlgbs1fsgMain.tMtxTimer(Sender: TObject); begin if not MutexExists(sOwnerMtx_) then TerminateProcess(GetCurrentProcess, 99); end; procedure TDlgbs1fsgMain.process_WM_COPYDATA(var msg: TMessage); var dwData: DWORD; pCpData: PCopyDataStruct; O: ISuperObject; sTemp, sEncPath, sDecPath: String; nType: Integer; begin msg.Result := 0; dwData := 0; pCpData := PCopyDataStruct(msg.LParam); try dwData := pCpData.dwData; case dwData of FSCMD_DECRYPT_FILE : begin sTemp := Copy(PChar(pCpData.lpData), 1, pCpData.cbData); O := SO(sTemp); sEncPath := O.S['EncPath']; sDecPath := O.S['DecPath']; if not FileExists(sEncPath) then begin TTgTrace.T('ÆÄ¼öDRM º¹È£È­ ´ë»ó ÆÄÀÏÀÌ ¾ø½À´Ï´Ù. EncPath=%s', [sEncPath]); exit; end; // GetFileType_r()´Â Á¦´ë·Î µ¿ÀÛ¾ÏÇÔ 25_0217 18:44:44 kku // ƯÁ¤ ȯ°æ? ŸÀ̹Ö? ¿¡¼­ DRM ÆÄÀÏÀε¥µµ 20¸¸ ¹ÝȯÇÔ nType := GetFileTypeW_r(sEncPath); TTgTrace.T('ÆÄ¼öDRM º¹È£È­ ½ÃÀÛ. Type=%d, EncPath=%s, DecPath=%s', [nType, sEncPath, sDecPath]); 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; sTemp := GetFileHeader_r(sEncPath); if sTemp = '' then begin TTgTrace.T('ÆÄÀÏ Çì´õ Á¤º¸¸¦ °¡Á®¿Ã ¼ö ¾ø½À´Ï´Ù. Path=%s', [sEncPath]); exit; end; SplitString(sTemp, ';', InfoList_, true); if InfoList_.Count < 18 then begin TTgTrace.T('CPID °ªÀ» È®ÀÎ ÇÒ ¼ö ¾ø½À´Ï´Ù.'); exit; end; sTemp := InfoList_[17]; // 18¹øÂ°¿¡ ÀÖÀ½ if not DirectoryExists(sFsDir_) then begin TTgTrace.T('FSD Æú´õ°¡ ¾ø½À´Ï´Ù.'); exit; end; nType := DoExtract_r(sFsDir_, sTemp, sEncPath, sDecPath); if nType = FASOO_OK then msg.Result := 10 else TTgTrace.T('ÆÄ¼öDRM º¹È£È­ ½ÇÆÐ, Path=%s, Error=%d', [sEncPath, nType]); end; end; except on E: Exception do ETgException.TraceException(Self, E, 'Fail .. process_WM_COPYDATA()'); end; end; end.