From a91edf1c54be688899136cbe6805eb35c5aeb687 Mon Sep 17 00:00:00 2001 From: anderson.peterle@previdencia.gov.br Date: Wed, 15 Apr 2009 16:34:27 +0000 Subject: [PATCH] Ajustes no agente principal (cacic2.exe) para tratamento da reexibicao do icone no systray quando em logoff/logon, ajustes no chkCACIC para criacao de excecoes no firewall nativo do XP para o srCACICsrv, implementacao de indicador da condicao para Desativacao do Suporte Remoto pelo cliente. --- cacic2.res | Bin 4916 -> 0 bytes cacicservice/CACICsvcMain.pas | 27 +++++++++++++-------------- chkcacic/chkcacic.res | Bin 5192 -> 0 bytes chkcacic/main.pas | 44 +++++++++++++++++++++++++++++++++++++------- ger_cols/ger_cols.dpr | 10 ++++++---- ger_cols/ger_cols.res | Bin 4816 -> 0 bytes main.pas | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------- 7 files changed, 136 insertions(+), 59 deletions(-) diff --git a/cacic2.res b/cacic2.res index 6496dde..d06e924 100755 Binary files a/cacic2.res and b/cacic2.res differ diff --git a/cacicservice/CACICsvcMain.pas b/cacicservice/CACICsvcMain.pas index 8a5723e..f6bc318 100755 --- a/cacicservice/CACICsvcMain.pas +++ b/cacicservice/CACICsvcMain.pas @@ -110,10 +110,10 @@ procedure TCACICservice.logDEBUG(Msg : String); var fLog: textfile; begin // Somente gravarei informações para debug se o arquivo ":\CACICsvc.log" existir - if FileExists(g_oCacic.Windows.getHomeDrive + 'CACICsvc.log') then + if FileExists(g_oCacic.Windows.getHomeDrive + g_oCacic.Windows.getWinDir + 'CACICsvc.log') then Begin - AssignFile(fLog, g_oCacic.Windows.getHomeDrive + 'CACICsvc.log'); - if FileExists(g_oCacic.Windows.getHomeDrive + 'CACICsvc.log') then + AssignFile(fLog, g_oCacic.Windows.getHomeDrive + g_oCacic.Windows.getWinDir + 'CACICsvc.log'); + if FileExists(g_oCacic.Windows.getHomeDrive + g_oCacic.Windows.getWinDir + 'CACICsvc.log') then Append(fLog) else Rewrite(fLog); @@ -148,6 +148,9 @@ procedure TCACICservice.ServiceStart(Sender: TService; var Started: Boolean); begin g_oCacic := TCACIC.Create; + g_oCacic.setCacicPath(GetValorChaveRegIni('Cacic2', 'cacic_dir', g_oCacic.getWinDir + 'chksis.ini')); + CACICservice.logDEBUG('TCACICservice.ExecutaCACIC : setCacicPath => '+GetValorChaveRegIni('Cacic2', 'cacic_dir', g_oCacic.getWinDir + 'chksis.ini')); + CACICservice.logDEBUG('TCACICservice.ServiceStart'); Started := true; @@ -162,9 +165,6 @@ end; procedure TCACICservice.ExecutaCACIC; Begin - CACICservice.logDEBUG('TCACICservice.ExecutaCACIC : setCacicPath => '+GetValorChaveRegIni('Cacic2', 'cacic_dir', g_oCacic.getWinDir + 'chksis.ini')); - g_oCacic.setCacicPath(GetValorChaveRegIni('Cacic2', 'cacic_dir', g_oCacic.getWinDir + 'chksis.ini')); - CACICservice.logDEBUG('TCACICservice.ExecutaCACIC : deleteFile => '+g_oCacic.getCacicPath + 'aguarde_CACIC.txt'); DeleteFile(g_oCacic.getCacicPath + 'aguarde_CACIC.txt'); Sleep(3000); @@ -181,15 +181,14 @@ Begin While not (FileExists(g_oCacic.getCacicPath + 'cacic2.exe')) do Sleep(5000); // Espero 5 segundos... - End; - - // Executo o Agente Principal do CACIC - Try - CACICservice.logDEBUG('TCACICservice.ExecutaCACIC : winExec => '+g_oCacic.getCacicPath + 'cacic2.exe'); - g_oCacic.createSampleProcess(g_oCacic.getCacicPath + 'cacic2.exe',false); - Except - End; + // Executo o Agente Principal do CACIC + Try + CACICservice.logDEBUG('TCACICservice.ExecutaCACIC : winExec => '+g_oCacic.getCacicPath + 'cacic2.exe'); + g_oCacic.createSampleProcess(g_oCacic.getCacicPath + 'cacic2.exe',false); + Except + End; + End; End; procedure TCACICservice.ServiceAfterInstall(Sender: TService); diff --git a/chkcacic/chkcacic.res b/chkcacic/chkcacic.res index 5b0c2c2..6a6aed2 100755 Binary files a/chkcacic/chkcacic.res and b/chkcacic/chkcacic.res differ diff --git a/chkcacic/main.pas b/chkcacic/main.pas index 3e928ea..c96b732 100644 --- a/chkcacic/main.pas +++ b/chkcacic/main.pas @@ -901,14 +901,32 @@ begin End else LogDebug('Exceção para "'+p_objeto+'" já existente.'); + + if (trim(GetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile\AuthorizedApplications\List\'+StringReplace(p_objeto+'.exe','\','?\',[rfReplaceAll])))='') then + Begin + SetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile\AuthorizedApplications\List\'+StringReplace(p_objeto+'.exe','\','?\',[rfReplaceAll]),p_objeto+'.exe:*:Enabled:'+p_objeto); + End + else + LogDebug('Exceção para "'+p_objeto+'" já existente.'); + End else - if (trim(GetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile\AuthorizedApplications\List\'+StringReplace(p_objeto+'.exe','\','?\',[rfReplaceAll])))='') then - Begin - SetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile\AuthorizedApplications\List\'+StringReplace(p_objeto+'.exe','\','?\',[rfReplaceAll]),p_objeto+'.exe:*:Enabled:'+p_objeto); - End - else - LogDebug('Exceção para "'+p_objeto+'" já existente.'); + Begin + if (trim(GetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile\AuthorizedApplications\List\'+StringReplace(p_objeto+'.exe','\','?\',[rfReplaceAll])))='') then + Begin + SetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile\AuthorizedApplications\List\'+StringReplace(p_objeto+'.exe','\','?\',[rfReplaceAll]),p_objeto+'.exe:*:Enabled:'+p_objeto); + End + else + LogDebug('Exceção para "'+p_objeto+'" já existente.'); + + if (trim(GetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile\AuthorizedApplications\List\'+StringReplace(p_objeto+'.exe','\','?\',[rfReplaceAll])))='') then + Begin + SetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile\AuthorizedApplications\List\'+StringReplace(p_objeto+'.exe','\','?\',[rfReplaceAll]),p_objeto+'.exe:*:Enabled:'+p_objeto); + End + else + LogDebug('Exceção para "'+p_objeto+'" já existente.'); + + End Except LogDebug('Problema adicionando "'+p_objeto+'" à lista de exceções do FireWall!'); End; @@ -1249,22 +1267,33 @@ begin // Liberando as conexões de Saída para o FTP SetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\FirewallRules\FTP-Out-TCP','v2.0|Action=Allow|Active=TRUE|Dir=Out|Protocol=6|Profile=Private|App='+g_oCacic.getHomeDrive+'system32\\ftp.exe|Name=Programa de transferência de arquivos|Desc=Programa de transferência de arquivos|Edge=FALSE|'); SetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\FirewallRules\FTP-Out-UDP','v2.0|Action=Allow|Active=TRUE|Dir=Out|Protocol=17|Profile=Private|App='+g_oCacic.getHomeDrive+'system32\\ftp.exe|Name=Programa de transferência de arquivos|Desc=Programa de transferência de arquivos|Edge=FALSE|'); + SetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\SharedAccess\Parameters\FirewallPolicy\FirewallRules\FTP-Out-TCP','v2.0|Action=Allow|Active=TRUE|Dir=Out|Protocol=6|Profile=Private|App='+g_oCacic.getHomeDrive+'system32\\ftp.exe|Name=Programa de transferência de arquivos|Desc=Programa de transferência de arquivos|Edge=FALSE|'); + SetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\SharedAccess\Parameters\FirewallPolicy\FirewallRules\FTP-Out-UDP','v2.0|Action=Allow|Active=TRUE|Dir=Out|Protocol=17|Profile=Private|App='+g_oCacic.getHomeDrive+'system32\\ftp.exe|Name=Programa de transferência de arquivos|Desc=Programa de transferência de arquivos|Edge=FALSE|'); // Liberando as conexões de Saída para o Ger_Cols SetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\FirewallRules\CACIC-GERCOLS-Out-TCP','v2.0|Action=Allow|Active=TRUE|Dir=Out|Protocol=6|Profile=Private|App='+g_oCacic.getCacicPath+'modulos\\ger_cols.exe|Name=Módulo Gerente de Coletas do Sistema CACIC|Desc=Módulo Gerente de Coletas do Sistema CACIC|Edge=FALSE|'); SetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\FirewallRules\CACIC-GERCOLS-Out-UDP','v2.0|Action=Allow|Active=TRUE|Dir=Out|Protocol=17|Profile=Private|App='+g_oCacic.getCacicPath+'modulos\\ger_cols.exe|Name=Módulo Gerente de Coletas do Sistema CACIC|Desc=Módulo Gerente de Coletas do Sistema CACIC|Edge=FALSE|'); + SetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\SharedAccess\Parameters\FirewallPolicy\FirewallRules\CACIC-GERCOLS-Out-TCP','v2.0|Action=Allow|Active=TRUE|Dir=Out|Protocol=6|Profile=Private|App='+g_oCacic.getCacicPath+'modulos\\ger_cols.exe|Name=Módulo Gerente de Coletas do Sistema CACIC|Desc=Módulo Gerente de Coletas do Sistema CACIC|Edge=FALSE|'); + SetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\SharedAccess\Parameters\FirewallPolicy\FirewallRules\CACIC-GERCOLS-Out-UDP','v2.0|Action=Allow|Active=TRUE|Dir=Out|Protocol=17|Profile=Private|App='+g_oCacic.getCacicPath+'modulos\\ger_cols.exe|Name=Módulo Gerente de Coletas do Sistema CACIC|Desc=Módulo Gerente de Coletas do Sistema CACIC|Edge=FALSE|'); // Liberando as conexões de Saída para o SrCACICsrv SetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\FirewallRules\CACIC-SRCACICSRV-Out-TCP','v2.0|Action=Allow|Active=TRUE|Dir=Out|Protocol=6|Profile=Private|App='+g_oCacic.getCacicPath+'modulos\\srcacicsrv.exe|Name=Módulo Suporte Remoto Seguro do Sistema CACIC|Desc=Módulo Suporte Remoto Seguro do Sistema CACIC|Edge=FALSE|'); SetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\FirewallRules\CACIC-SRCACICSRV-Out-UDP','v2.0|Action=Allow|Active=TRUE|Dir=Out|Protocol=17|Profile=Private|App='+g_oCacic.getCacicPath+'modulos\\srcacicsrv.exe|Name=Módulo Suporte Remoto Seguro do Sistema CACIC|Desc=Módulo Suporte Remoto Seguro do Sistema CACIC|Edge=FALSE|'); + SetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\SharedAccess\Parameters\FirewallPolicy\FirewallRules\CACIC-SRCACICSRV-Out-TCP','v2.0|Action=Allow|Active=TRUE|Dir=Out|Protocol=6|Profile=Private|App='+g_oCacic.getCacicPath+'modulos\\srcacicsrv.exe|Name=Módulo Suporte Remoto Seguro do Sistema CACIC|Desc=Módulo Suporte Remoto Seguro do Sistema CACIC|Edge=FALSE|'); + SetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\SharedAccess\Parameters\FirewallPolicy\FirewallRules\CACIC-SRCACICSRV-Out-UDP','v2.0|Action=Allow|Active=TRUE|Dir=Out|Protocol=17|Profile=Private|App='+g_oCacic.getCacicPath+'modulos\\srcacicsrv.exe|Name=Módulo Suporte Remoto Seguro do Sistema CACIC|Desc=Módulo Suporte Remoto Seguro do Sistema CACIC|Edge=FALSE|'); // Liberando as conexões de Saída para o ChkCacic SetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\FirewallRules\CACIC-CHKCACIC-Out-TCP','v2.0|Action=Allow|Active=TRUE|Dir=Out|Protocol=6|Profile=Private|App='+ExtractFilePath(Application.Exename) + '\chkcacic.exe|Name=chkcacic.exe|Desc=chkcacic.exe|Edge=FALSE|'); SetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\FirewallRules\CACIC-CHKCACIC-Out-UDP','v2.0|Action=Allow|Active=TRUE|Dir=Out|Protocol=17|Profile=Private|App='+ExtractFilePath(Application.Exename) + '\chkcacic.exe|Name=chkcacic.exe|Desc=chkcacic.exe|Edge=FALSE|'); + SetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\SharedAccess\Parameters\FirewallPolicy\FirewallRules\CACIC-CHKCACIC-Out-TCP','v2.0|Action=Allow|Active=TRUE|Dir=Out|Protocol=6|Profile=Private|App='+ExtractFilePath(Application.Exename) + '\chkcacic.exe|Name=chkcacic.exe|Desc=chkcacic.exe|Edge=FALSE|'); + SetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\SharedAccess\Parameters\FirewallPolicy\FirewallRules\CACIC-CHKCACIC-Out-UDP','v2.0|Action=Allow|Active=TRUE|Dir=Out|Protocol=17|Profile=Private|App='+ExtractFilePath(Application.Exename) + '\chkcacic.exe|Name=chkcacic.exe|Desc=chkcacic.exe|Edge=FALSE|'); // Liberando as conexões de Saída para o ChkSis SetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\FirewallRules\CACIC-CHKSIS-Out-TCP','v2.0|Action=Allow|Active=TRUE|Dir=Out|Protocol=6|Profile=Private|App='+g_oCacic.getWinDir + 'chksis.exe|Name=Módulo Verificador de Integridade do Sistema CACIC|Desc=Módulo Verificador de Integridade do Sistema CACIC|Edge=FALSE|'); SetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\FirewallRules\CACIC-CHKSIS-Out-UDP','v2.0|Action=Allow|Active=TRUE|Dir=Out|Protocol=17|Profile=Private|App='+g_oCacic.getWinDir + 'chksis.exe|Name=Módulo Verificador de Integridade do Sistema CACIC|Desc=Módulo Verificador de Integridade do Sistema CACIC|Edge=FALSE|'); + SetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\SharedAccess\Parameters\FirewallPolicy\FirewallRules\CACIC-CHKSIS-Out-TCP','v2.0|Action=Allow|Active=TRUE|Dir=Out|Protocol=6|Profile=Private|App='+g_oCacic.getWinDir + 'chksis.exe|Name=Módulo Verificador de Integridade do Sistema CACIC|Desc=Módulo Verificador de Integridade do Sistema CACIC|Edge=FALSE|'); + SetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\SharedAccess\Parameters\FirewallPolicy\FirewallRules\CACIC-CHKSIS-Out-UDP','v2.0|Action=Allow|Active=TRUE|Dir=Out|Protocol=17|Profile=Private|App='+g_oCacic.getWinDir + 'chksis.exe|Name=Módulo Verificador de Integridade do Sistema CACIC|Desc=Módulo Verificador de Integridade do Sistema CACIC|Edge=FALSE|'); + End Except LogDebug('Problema Liberando Policies de FireWall!'); @@ -1272,10 +1301,11 @@ begin End else Begin - // Acrescento o ChkCacic às exceções do FireWall nativo... + // Acrescento o ChkCacic e srCACICsrv às exceções do FireWall nativo... {chkcacic} LogDebug('Inserindo "'+ExtractFilePath(Application.Exename) + 'chkcacic" nas exceções do FireWall!'); LiberaFireWall(ExtractFilePath(Application.Exename) + 'chkcacic'); + LiberaFireWall(g_oCacic.getCacicPath + 'modulos\srcacicsrv.exe'); End; Except End; diff --git a/ger_cols/ger_cols.dpr b/ger_cols/ger_cols.dpr index 5dfea80..c332cc9 100755 --- a/ger_cols/ger_cols.dpr +++ b/ger_cols/ger_cols.dpr @@ -170,7 +170,7 @@ procedure log_DEBUG(p_msg:string); Begin if v_Debugs then log_diario('(v.'+getVersionInfo(ParamStr(0))+') DEBUG - '+p_msg); End; - +{ function Compress(p_strToCompress : string) : String; var v_tstrToCompress, v_tstrCompressed : TStringStream; Zip : TZCompressionStream; @@ -182,7 +182,7 @@ begin Zip.Free; Result := ZlibEx.ZCompressStrWeb(v_tstrCompressed.DataString); -end; {Compress} +end; function DeCompress(p_ToDeCompress : String) : String; var v_tstrToDeCompress, v_tstrDeCompressed : TStringStream; @@ -203,8 +203,8 @@ end; DeZip.Free; Result := ZlibEx.ZDecompressStrEx(v_tstrDeCompressed.DataString); -end; {DeCompress} - +end; +} Function RemoveCaracteresEspeciais(Texto, p_Fill : String; p_start, p_end:integer) : String; var I : Integer; Begin @@ -2435,6 +2435,8 @@ Begin SetValorDatMemoria('Configs.IN_EXIBE_BANDEJA' ,UpperCase(g_oCacic.deCrypt(XML_RetornaValor('in_exibe_bandeja' , strRetorno))), v_tstrCipherOpened); SetValorDatMemoria('Configs.TE_JANELAS_EXCECAO' ,g_oCacic.deCrypt(XML_RetornaValor('te_janelas_excecao' , strRetorno)) , v_tstrCipherOpened); SetValorDatMemoria('TcpIp.TE_ENDERECOS_MAC_INVALIDOS' ,g_oCacic.deCrypt(XML_RetornaValor('te_enderecos_mac_invalidos' , strRetorno)) , v_tstrCipherOpened); + SetValorDatMemoria('Configs.NU_PORTA_SRCACIC' ,g_oCacic.deCrypt(XML_RetornaValor('nu_porta_srcacic' , strRetorno)) , v_tstrCipherOpened); + SetValorDatMemoria('Configs.CS_PERMITIR_DESATIVAR_SRCACIC' ,g_oCacic.deCrypt(XML_RetornaValor('cs_permitir_desativar_srcacic' , strRetorno)) , v_tstrCipherOpened); SetValorDatMemoria('Configs.DT_HR_COLETA_FORCADA' ,stringreplace(stringreplace(stringreplace(g_oCacic.deCrypt(XML_RetornaValor('dt_hr_coleta_forcada' , strRetorno)),'-','',[rfReplaceAll]),' ','',[rfReplaceAll]),':','',[rfReplaceAll]), v_tstrCipherOpened); SetValorDatMemoria('Configs.DT_HR_COLETA_FORCADA_ANVI' ,stringreplace(stringreplace(stringreplace(g_oCacic.deCrypt(XML_RetornaValor('dt_hr_coleta_forcada_anvi', strRetorno)),'-','',[rfReplaceAll]),' ','',[rfReplaceAll]),':','',[rfReplaceAll]), v_tstrCipherOpened); SetValorDatMemoria('Configs.DT_HR_COLETA_FORCADA_COMP' ,stringreplace(stringreplace(stringreplace(g_oCacic.deCrypt(XML_RetornaValor('dt_hr_coleta_forcada_comp', strRetorno)),'-','',[rfReplaceAll]),' ','',[rfReplaceAll]),':','',[rfReplaceAll]), v_tstrCipherOpened); diff --git a/ger_cols/ger_cols.res b/ger_cols/ger_cols.res index 0e7bd7c..1392858 100755 Binary files a/ger_cols/ger_cols.res and b/ger_cols/ger_cols.res differ diff --git a/main.pas b/main.pas index 508f70d..af5fb3c 100755 --- a/main.pas +++ b/main.pas @@ -62,6 +62,10 @@ var v_tstrCipherOpened : TStrings; var + g_intTaskBarAtual, + g_intTaskBarAnterior : integer; + +var boolDebugs : Boolean; var @@ -1054,6 +1058,11 @@ var strAux, v_Aguarde : TextFile; v_SystemDrive : TStrings; begin + // Essas variáveis ajudarão a controlar o redesenho do ícone no systray, + // evitando o "roubo" do foco. + g_intTaskBarAtual := 0; + g_intTaskBarAnterior := 0; + // Não mostrar o formulário... Application.ShowMainForm:=false; g_oCacic := TCACIC.Create; @@ -2158,15 +2167,20 @@ end; } procedure TFormularioGeral.Mnu_SuporteRemotoClick(Sender: TObject); var boolAux : boolean; - strPalavraChave, - strTeSO, - strTeNodeAddress : String; + v_strPalavraChave, + v_strTeSO, + v_strTeNodeAddress, + v_strNuPortaSR : String; fileAguarde : TextFile; begin if boolServerON then // Ordeno ao SrCACICsrv que auto-finalize Begin Log_Diario('Desativando Suporte Remoto Seguro.'); + WinExec(PChar(g_oCacic.getCacicPath + 'modulos\srcacicsrv.exe -kill'), SW_NORMAL); + { g_oCacic.createSampleProcess(g_oCacic.getCacicPath + 'modulos\srcacicsrv.exe -kill',false); + } + boolServerON := false; End else @@ -2176,28 +2190,31 @@ begin // Alguns cuidados necessários ao tráfego e recepção de valores pelo Gerente WEB // Some cares about send and receive at Gerente WEB - strPalavraChave := FormularioGeral.getValorDatMemoria('Configs.te_palavra_chave', v_tstrCipherOpened); - strPalavraChave := StringReplace(strPalavraChave,' ' ,'' ,[rfReplaceAll]); - strPalavraChave := StringReplace(strPalavraChave,'"' ,'' ,[rfReplaceAll]); - strPalavraChave := StringReplace(strPalavraChave,'''' ,'' ,[rfReplaceAll]); - strPalavraChave := StringReplace(strPalavraChave,'\' ,'' ,[rfReplaceAll]); - strPalavraChave := g_oCacic.enCrypt(strPalavraChave); - strPalavraChave := StringReplace(strPalavraChave,'+','',[rfReplaceAll]); - - strTeSO := trim(StringReplace(FormularioGeral.getValorDatMemoria('Configs.TE_SO', v_tstrCipherOpened),' ','',[rfReplaceAll])); - strTeSO := g_oCacic.enCrypt(strTeSO); - strTeSO := StringReplace(strTeSO,'+','',[rfReplaceAll]); - - strTeNodeAddress := trim(StringReplace(FormularioGeral.getValorDatMemoria('TcpIp.TE_NODE_ADDRESS' , v_tstrCipherOpened),' ','' ,[rfReplaceAll])); - strTeNodeAddress := g_oCacic.enCrypt(strTeNodeAddress); - strTeNodeAddress := StringReplace(strTeNodeAddress,'+','',[rfReplaceAll]); + v_strPalavraChave := FormularioGeral.getValorDatMemoria('Configs.te_palavra_chave', v_tstrCipherOpened); + v_strPalavraChave := StringReplace(v_strPalavraChave,' ' ,'' ,[rfReplaceAll]); + v_strPalavraChave := StringReplace(v_strPalavraChave,'"' ,'' ,[rfReplaceAll]); + v_strPalavraChave := StringReplace(v_strPalavraChave,'''' ,'' ,[rfReplaceAll]); + v_strPalavraChave := StringReplace(v_strPalavraChave,'\' ,'' ,[rfReplaceAll]); + v_strPalavraChave := g_oCacic.enCrypt(v_strPalavraChave); + v_strPalavraChave := StringReplace(v_strPalavraChave,'+','',[rfReplaceAll]); + + v_strTeSO := trim(StringReplace(FormularioGeral.getValorDatMemoria('Configs.TE_SO', v_tstrCipherOpened),' ','',[rfReplaceAll])); + v_strTeSO := g_oCacic.enCrypt(v_strTeSO); + v_strTeSO := StringReplace(v_strTeSO,'+','',[rfReplaceAll]); + + v_strTeNodeAddress := trim(StringReplace(FormularioGeral.getValorDatMemoria('TcpIp.TE_NODE_ADDRESS' , v_tstrCipherOpened),' ','' ,[rfReplaceAll])); + v_strTeNodeAddress := g_oCacic.enCrypt(v_strTeNodeAddress); + v_strTeNodeAddress := StringReplace(v_strTeNodeAddress,'+','',[rfReplaceAll]); + + v_strNuPortaSR := trim(FormularioGeral.getValorDatMemoria('Configs.NU_PORTA_SRCACIC' , v_tstrCipherOpened)); log_DEBUG('Invocando "'+g_oCacic.getCacicPath + 'modulos\srcacicsrv.exe -start [' + g_oCacic.enCrypt(FormularioGeral.getValorDatMemoria('Configs.EnderecoServidor', v_tstrCipherOpened)) + ']' + - '[' + g_oCacic.enCrypt(FormularioGeral.getValorDatMemoria('Configs.Endereco_WS' , v_tstrCipherOpened)) + ']' + - '[' + strTeSO + ']' + - '[' + strTeNodeAddress + ']' + - '[' + strPalavraChave + ']' + - '[' + g_oCacic.getCacicPath + 'Temp\aguarde_srCACIC.txt' + ']'); + '[' + g_oCacic.enCrypt(FormularioGeral.getValorDatMemoria('Configs.Endereco_WS' , v_tstrCipherOpened)) + ']' + + '[' + v_strTeSO + ']' + + '[' + v_strTeNodeAddress + ']' + + '[' + v_strPalavraChave + ']' + + '[' + g_oCacic.getCacicPath + 'Temp\' + ']' + + '[' + v_strNuPortaSR + ']'); // Detectar versão do Windows antes de fazer a chamada seguinte... try @@ -2215,12 +2232,23 @@ begin CloseFile(fileAguarde); Finally End; - g_oCacic.createSampleProcess(g_oCacic.getCacicPath + 'modulos\srcacicsrv.exe -start [' + g_oCacic.enCrypt(FormularioGeral.getValorDatMemoria('Configs.EnderecoServidor', v_tstrCipherOpened)) + ']' + - '[' + g_oCacic.enCrypt(FormularioGeral.getValorDatMemoria('Configs.Endereco_WS' , v_tstrCipherOpened)) + ']' + - '[' + strTeSO + ']' + - '[' + strTeNodeAddress + ']' + - '[' + strPalavraChave + ']' + - '[' + g_oCacic.getCacicPath + 'Temp\' + ']',false); + WinExec(PChar(g_oCacic.getCacicPath + 'modulos\srcacicsrv.exe -start [' + g_oCacic.enCrypt(FormularioGeral.getValorDatMemoria('Configs.EnderecoServidor', v_tstrCipherOpened)) + ']' + + '[' + g_oCacic.enCrypt(FormularioGeral.getValorDatMemoria('Configs.Endereco_WS' , v_tstrCipherOpened)) + ']' + + '[' + v_strTeSO + ']' + + '[' + v_strTeNodeAddress + ']' + + '[' + v_strPalavraChave + ']' + + '[' + g_oCacic.getCacicPath + 'Temp\' + ']' + + '[' + v_strNuPortaSR + ']'),SW_NORMAL); + { + g_oCacic.createSampleProcess(g_oCacic.getCacicPath + 'modulos\srcacicsrv.exe -start [' + g_oCacic.enCrypt(FormularioGeral.getValorDatMemoria('Configs.EnderecoServidor', v_tstrCipherOpened)) + ']' + + '[' + g_oCacic.enCrypt(FormularioGeral.getValorDatMemoria('Configs.Endereco_WS' , v_tstrCipherOpened)) + ']' + + '[' + v_strTeSO + ']' + + '[' + v_strTeNodeAddress + ']' + + '[' + v_strPalavraChave + ']' + + '[' + g_oCacic.getCacicPath + 'Temp\' + ']' + + '[' + v_strNuPortaSR + ']',false); + } + BoolServerON := true; End; @@ -2240,8 +2268,17 @@ begin FormularioGeral.Matar(g_oCacic.getCacicPath+'temp\','aguarde_SRCACIC.txt'); if FileExists(g_oCacic.getCacicPath + 'temp\aguarde_SRCACIC.txt') then Begin - Mnu_SuporteRemoto.Caption := 'Suporte Remoto Ativo!'; - Mnu_SuporteRemoto.Enabled := false; + if (getValorDatMemoria('Configs.CS_PERMITIR_DESATIVAR_SRCACIC',v_tstrCipherOpened) = 'S') then + Begin + Mnu_SuporteRemoto.Caption := 'Desativar Suporte Remoto'; + Mnu_SuporteRemoto.Enabled := true; + End + else + Begin + Mnu_SuporteRemoto.Caption := 'Suporte Remoto Ativo!'; + Mnu_SuporteRemoto.Enabled := false; + End; + boolServerON := true; End else @@ -2254,9 +2291,18 @@ end; procedure TFormularioGeral.Timer_InicializaTrayTimer(Sender: TObject); begin - Timer_InicializaTray.Enabled := false; - InicializaTray; - Timer_InicializaTray.Enabled := true; + Timer_InicializaTray.Enabled := false; + + g_intTaskBarAtual := FindWindow('Shell_TrayWnd', Nil); + Log_DEBUG('g_intTaskBarAnterior: '+ intToStr(g_intTaskBarAnterior)); + Log_DEBUG('g_intTaskBarAtual: ' + intToStr(g_intTaskBarAtual)); + + if (g_intTaskBarAnterior = 0) and (g_intTaskBarAtual > 0) then + InicializaTray; + + g_intTaskBarAnterior := g_intTaskBarAtual; + + Timer_InicializaTray.Enabled := true; end; end. -- libgit2 0.21.2