From e33fca21a94522da706047b17539beadeff531a6 Mon Sep 17 00:00:00 2001 From: harpiain@gmail.com Date: Tue, 31 Mar 2009 03:42:17 +0000 Subject: [PATCH] - merge de branch (2.4) revisão [751:730] --- col_anvi/col_anvi.dpr | 75 ++++++++------------------------------------------------------------------- col_anvi/main_anvi.ddp | Bin 51 -> 0 bytes col_anvi/main_anvi.dfm | 21 --------------------- col_anvi/main_anvi.pas | 461 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- col_anvi/utils.pas | 153 --------------------------------------------------------------------------------------------------------------------------------------------------------- col_hard/col_hard.dpr | 16 +++++++++++----- col_patr/main_col_patr.pas | 70 +++++++++------------------------------------------------------------- ger_cols/ger_cols.dpr | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ini_cols/ini_cols.dpr | 76 ++++++---------------------------------------------------------------------- main.pas | 108 +++++++++--------------------------------------------------------------------------------------------------- 10 files changed, 106 insertions(+), 937 deletions(-) delete mode 100755 col_anvi/main_anvi.ddp delete mode 100755 col_anvi/main_anvi.dfm delete mode 100755 col_anvi/main_anvi.pas delete mode 100755 col_anvi/utils.pas diff --git a/col_anvi/col_anvi.dpr b/col_anvi/col_anvi.dpr index 6b3bbf3..9ecb205 100755 --- a/col_anvi/col_anvi.dpr +++ b/col_anvi/col_anvi.dpr @@ -42,6 +42,9 @@ var v_Debugs : boolean; var v_tstrCipherOpened, v_tstrCipherOpened1 : TStrings; +var + g_oCacic : TCACIC; + // Some constants that are dependant on the cipher being used // Assuming MCRYPT_RIJNDAEL_128 (i.e., 128bit blocksize, 256bit keysize) const KeySize = 32; // 32 bytes = 256 bits @@ -235,64 +238,6 @@ begin end; end; -function GetWinVer: Integer; -const - { operating system (OS)constants } - cOsUnknown = 0; - cOsWin95 = 1; - cOsWin95OSR2 = 2; // Não implementado. - cOsWin98 = 3; - cOsWin98SE = 4; - cOsWinME = 5; - cOsWinNT = 6; - cOsWin2000 = 7; - cOsXP = 8; -var - osVerInfo: TOSVersionInfo; - majorVer, minorVer: Integer; -begin - Result := cOsUnknown; - { set operating system type flag } - osVerInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfo); - if GetVersionEx(osVerInfo) then - begin - majorVer := osVerInfo.dwMajorVersion; - minorVer := osVerInfo.dwMinorVersion; - case osVerInfo.dwPlatformId of - VER_PLATFORM_WIN32_NT: { Windows NT/2000 } - begin - if majorVer <= 4 then - Result := cOsWinNT - else if (majorVer = 5) and (minorVer = 0) then - Result := cOsWin2000 - else if (majorVer = 5) and (minorVer = 1) then - Result := cOsXP - else - Result := cOsUnknown; - end; - VER_PLATFORM_WIN32_WINDOWS: { Windows 9x/ME } - begin - if (majorVer = 4) and (minorVer = 0) then - Result := cOsWin95 - else if (majorVer = 4) and (minorVer = 10) then - begin - if osVerInfo.szCSDVersion[1] = 'A' then - Result := cOsWin98SE - else - Result := cOsWin98; - end - else if (majorVer = 4) and (minorVer = 90) then - Result := cOsWinME - else - Result := cOsUnknown; - end; - else - Result := cOsUnknown; - end; - end - else - Result := cOsUnknown; -end; Function Explode(Texto, Separador : String) : TStrings; var strItem : String; @@ -350,7 +295,7 @@ begin if (trim(v_strCipherOpened)<>'') then Result := explode(v_strCipherOpened,'=CacicIsFree=') else - Result := explode('Configs.ID_SO=CacicIsFree='+inttostr(GetWinVer)+'=CacicIsFree=Configs.Endereco_WS=CacicIsFree=/cacic2/ws/','=CacicIsFree='); + Result := explode('Configs.ID_SO=CacicIsFree='+ g_oCacic.getWindowsStrId() +'=CacicIsFree=Configs.Endereco_WS=CacicIsFree=/cacic2/ws/','=CacicIsFree='); if Result.Count mod 2 <> 0 then Result.Add(''); @@ -499,7 +444,7 @@ begin nu_versao_engine := ''; nu_versao_pattern := ''; log_diario('Coletando informações de Antivírus OfficeScan.'); - If Win32Platform = VER_PLATFORM_WIN32_WINDOWS Then { Windows 9x/ME } + If g_oCacic.isWindows9xME() Then { Windows 9x/ME } Begin ChaveRegistro := 'HKEY_LOCAL_MACHINE\Software\TrendMicro\OfficeScanCorp\CurrentVersion'; NomeExecutavel := 'pccwin97.exe'; @@ -593,13 +538,10 @@ var tstrTripa1 : TStrings; const CACIC_APP_NAME = 'col_anvi'; -var - oCacic : TCACIC; - begin - oCacic := TCACIC.Create(); + g_oCacic := TCACIC.Create(); - if( not oCacic.isAppRunning( CACIC_APP_NAME ) ) then + if( not g_oCacic.isAppRunning( CACIC_APP_NAME ) ) then if (ParamCount>0) then Begin For intAux := 1 to ParamCount do @@ -645,8 +587,7 @@ begin CipherClose(p_path_cacic + 'temp\col_anvi.dat', v_tstrCipherOpened1); End; End; - Halt(0); End; End; - oCacic.Free(); + g_oCacic.Free(); end. diff --git a/col_anvi/main_anvi.ddp b/col_anvi/main_anvi.ddp deleted file mode 100755 index 4370276..0000000 Binary files a/col_anvi/main_anvi.ddp and /dev/null differ diff --git a/col_anvi/main_anvi.dfm b/col_anvi/main_anvi.dfm deleted file mode 100755 index 5f91f9d..0000000 --- a/col_anvi/main_anvi.dfm +++ /dev/null @@ -1,21 +0,0 @@ -object frm_col_anvi: Tfrm_col_anvi - Left = 911 - Top = 713 - Width = 112 - Height = 27 - Caption = 'CACIC - Coletor AntiV'#237'rus' - Color = clBtnFace - TransparentColor = True - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -11 - Font.Name = 'MS Sans Serif' - Font.Style = [] - OldCreateOrder = False - OnCreate = FormCreate - PixelsPerInch = 96 - TextHeight = 13 - object PJVersionInfo1: TPJVersionInfo - Left = 40 - end -end diff --git a/col_anvi/main_anvi.pas b/col_anvi/main_anvi.pas deleted file mode 100755 index 984fe26..0000000 --- a/col_anvi/main_anvi.pas +++ /dev/null @@ -1,461 +0,0 @@ -(** ---------------------------------------------------------------------------------------------------------------------------------------------------------------- -Copyright 2000, 2001, 2002, 2003, 2004, 2005 Dataprev - Empresa de Tecnologia e Informações da Previdência Social, Brasil - -Este arquivo é parte do programa CACIC - Configurador Automático e Coletor de Informações Computacionais - -O CACIC é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como -publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença, ou (na sua opinião) qualquer versão. - -Este programa é distribuido na esperança que possa ser util, mas SEM NENHUMA GARANTIA; sem uma garantia implicita de ADEQUAÇÂO a qualquer -MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes. - -Você deve ter recebido uma cópia da Licença Pública Geral GNU, sob o título "LICENCA.txt", junto com este programa, se não, escreva para a Fundação do Software -Livre(FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ---------------------------------------------------------------------------------------------------------------------------------------------------------------- -*) - -unit main_anvi; - -interface - -uses Windows, Forms, classes, sysutils, inifiles, Registry, TLHELP32, ShellAPI, - PJVersionInfo; -var p_path_cacic, p_path_cacic_ini : string; - -type - Tfrm_col_anvi = class(TForm) - PJVersionInfo1: TPJVersionInfo; - procedure Executa_Col_Anvi; - procedure Log_Historico(strMsg : String); - Function Crip(PNome: String): String; - Function DesCrip(PNome: String): String; - function SetValorChaveRegIni(p_Secao: String; p_Chave: String; p_Valor: String; p_Path : String): String; -// function GetValorChaveRegIni(p_Secao: String; p_Chave : String; p_Path : String): String; - function GetValorChaveRegIni(p_SectionName, p_KeyName, p_IniFileName : String) : String; - function GetValorChaveRegEdit(Chave: String): Variant; - function GetRootKey(strRootKey: String): HKEY; - Function Explode(Texto, Separador : String) : TStrings; - Function RemoveCaracteresEspeciais(Texto : String) : String; - function GetVersionInfo(p_File: string):string; - function VerFmt(const MS, LS: DWORD): string; - function ProgramaRodando(NomePrograma: String): Boolean; - procedure FormCreate(Sender: TObject); - private - { Private declarations } - public - { Public declarations } - end; -var - frm_col_anvi: Tfrm_col_anvi; - - -implementation - -{$R *.dfm} -function Tfrm_col_anvi.VerFmt(const MS, LS: DWORD): string; - // Format the version number from the given DWORDs containing the info -begin - Result := Format('%d.%d.%d.%d', - [HiWord(MS), LoWord(MS), HiWord(LS), LoWord(LS)]) -end; - -{ TMainForm } - -function Tfrm_col_anvi.GetVersionInfo(p_File: string):string; -begin - PJVersionInfo1.FileName := PChar(p_File); - Result := VerFmt(PJVersionInfo1.FixedFileInfo.dwFileVersionMS, PJVersionInfo1.FixedFileInfo.dwFileVersionLS); -end; - -//Para gravar no Arquivo INI... -function Tfrm_col_anvi.SetValorChaveRegIni(p_Secao: String; p_Chave: String; p_Valor: String; p_Path : String): String; -var Reg_Ini : TIniFile; -begin - FileSetAttr (p_Path,0); - Reg_Ini := TIniFile.Create(p_Path); -// Reg_Ini.WriteString(frm_col_anvi.Crip(p_Secao), frm_col_anvi.Crip(p_Chave), frm_col_anvi.Crip(p_Valor)); - Reg_Ini.WriteString(p_Secao, p_Chave, p_Valor); - Reg_Ini.Free; -end; - -//Para buscar do Arquivo INI... -//function Tfrm_col_anvi.GetValorChaveRegIni(p_Secao: String; p_Chave : String; p_Path : String): String; -//var Reg_Ini: TIniFile; -//begin -// FileSetAttr (p_Path,0); -// Reg_Ini := TIniFile.Create(p_Path); -//// Result := frm_col_anvi.DesCrip(Reg_Ini.ReadString(frm_col_anvi.Crip(p_Secao), frm_col_anvi.Crip(p_Chave), '')); -// Result := Reg_Ini.ReadString(p_Secao, p_Chave, ''); -// Reg_Ini.Free; -//end; -function Tfrm_col_anvi.GetValorChaveRegIni(p_SectionName, p_KeyName, p_IniFileName : String) : String; -var - FileText : TStringList; - i, j, v_Size_Section, v_Size_Key : integer; - v_SectionName, v_KeyName : string; - begin - Result := ''; - v_SectionName := '[' + p_SectionName + ']'; - v_Size_Section := strLen(PChar(v_SectionName)); - v_KeyName := p_KeyName + '='; - v_Size_Key := strLen(PChar(v_KeyName)); - FileText := TStringList.Create; - try - FileText.LoadFromFile(p_IniFileName); - For i := 0 To FileText.Count - 1 Do - Begin - if (LowerCase(Trim(PChar(Copy(FileText[i],1,v_Size_Section)))) = LowerCase(Trim(PChar(v_SectionName)))) then - Begin - For j := i to FileText.Count - 1 Do - Begin - if (LowerCase(Trim(PChar(Copy(FileText[j],1,v_Size_Key)))) = LowerCase(Trim(PChar(v_KeyName)))) then - Begin - Result := PChar(Copy(FileText[j],v_Size_Key + 1,strLen(PChar(FileText[j]))-v_Size_Key)); - Break; - End; - End; - End; - if (Result <> '') then break; - End; - finally - FileText.Free; - end; - end; - - -Function Tfrm_col_anvi.Explode(Texto, Separador : String) : TStrings; -var - strItem : String; - ListaAuxUTILS : TStrings; - NumCaracteres, I : Integer; -Begin - ListaAuxUTILS := TStringList.Create; - strItem := ''; - NumCaracteres := Length(Texto); - For I := 0 To NumCaracteres Do - If (Texto[I] = Separador) or (I = NumCaracteres) Then - Begin - If (I = NumCaracteres) then strItem := strItem + Texto[I]; - ListaAuxUTILS.Add(Trim(strItem)); - strItem := ''; - end - Else strItem := strItem + Texto[I]; - Explode := ListaAuxUTILS; -end; - -function Tfrm_col_anvi.GetRootKey(strRootKey: String): HKEY; -begin - /// Encontrar uma maneira mais elegante de fazer esses testes. - if Trim(strRootKey) = 'HKEY_LOCAL_MACHINE' Then Result := HKEY_LOCAL_MACHINE - else if Trim(strRootKey) = 'HKEY_CLASSES_ROOT' Then Result := HKEY_CLASSES_ROOT - else if Trim(strRootKey) = 'HKEY_CURRENT_USER' Then Result := HKEY_CURRENT_USER - else if Trim(strRootKey) = 'HKEY_USERS' Then Result := HKEY_USERS - else if Trim(strRootKey) = 'HKEY_CURRENT_CONFIG' Then Result := HKEY_CURRENT_CONFIG - else if Trim(strRootKey) = 'HKEY_DYN_DATA' Then Result := HKEY_DYN_DATA; -end; - -Function Tfrm_col_anvi.RemoveCaracteresEspeciais(Texto : String) : String; -var I : Integer; - strAux : String; -Begin - For I := 0 To Length(Texto) Do - if ord(Texto[I]) in [32..126] Then - strAux := strAux + Texto[I] - else strAux := strAux + ' '; // Coloca um espaço onde houver caracteres especiais - Result := strAux; -end; - -function Tfrm_col_anvi.GetValorChaveRegEdit(Chave: String): Variant; -var RegEditGet: TRegistry; - RegDataType: TRegDataType; - strRootKey, strKey, strValue, s: String; - ListaAuxGet : TStrings; - DataSize, Len, I : Integer; -begin - try - Result := ''; - ListaAuxGet := frm_col_anvi.Explode(Chave, '\'); - - strRootKey := ListaAuxGet[0]; - For I := 1 To ListaAuxGet.Count - 2 Do strKey := strKey + ListaAuxGet[I] + '\'; - strValue := ListaAuxGet[ListaAuxGet.Count - 1]; - if (strValue = '(Padrão)') then strValue := ''; //Para os casos de se querer buscar o valor default (Padrão) - RegEditGet := TRegistry.Create; - - RegEditGet.Access := KEY_READ; - RegEditGet.Rootkey := GetRootKey(strRootKey); - if RegEditGet.OpenKeyReadOnly(strKey) then //teste - Begin - RegDataType := RegEditGet.GetDataType(strValue); - if (RegDataType = rdString) or (RegDataType = rdExpandString) then Result := RegEditGet.ReadString(strValue) - else if RegDataType = rdInteger then Result := RegEditGet.ReadInteger(strValue) - else if (RegDataType = rdBinary) or (RegDataType = rdUnknown) - then - begin - DataSize := RegEditGet.GetDataSize(strValue); - if DataSize = -1 then exit; - SetLength(s, DataSize); - Len := RegEditGet.ReadBinaryData(strValue, PChar(s)^, DataSize); - if Len <> DataSize then exit; - Result := frm_col_anvi.RemoveCaracteresEspeciais(s); - end - end; - finally - RegEditGet.CloseKey; - RegEditGet.Free; - ListaAuxGet.Free; - - end; -end; - - -// Simples rotinas de Criptografação e Descriptografação -// Baixadas de http://www.costaweb.com.br/forum/delphi/474.shtml -Function Tfrm_col_anvi.Crip(PNome: String): String; -Var - TamI, TamF: Integer; - SenA, SenM, SenD: String; -Begin - SenA := Trim(PNome); - TamF := Length(SenA); - if (TamF > 1) then - begin - SenM := ''; - SenD := ''; - For TamI := TamF Downto 1 do - Begin - SenM := SenM + Copy(SenA,TamI,1); - End; - SenD := Chr(TamF+95)+Copy(SenM,1,1)+Copy(SenA,1,1)+Copy(SenM,2,TamF-2)+Chr(75+TamF); - end - else SenD := SenA; - Result := SenD; -End; - -Function Tfrm_col_anvi.DesCrip(PNome: String): String; -Var - TamI, TamF: Integer; - SenA, SenM, SenD: String; -Begin - SenA := Trim(PNome); - TamF := Length(SenA) - 2; - if (TamF > 1) then - begin - SenM := ''; - SenD := ''; - SenA := Copy(SenA,2,TamF); - SenM := Copy(SenA,1,1)+Copy(SenA,3,TamF)+Copy(SenA,2,1); - For TamI := TamF Downto 1 do - Begin - SenD := SenD + Copy(SenM,TamI,1); - End; - end - else SenD := SenA; - Result := SenD; -End; - -procedure Tfrm_col_anvi.Log_Historico(strMsg : String); -var - HistoricoLog : TextFile; - strDataArqLocal, strDataAtual : string; -begin - try - FileSetAttr (p_path_cacic + 'cacic2.log',0); // Retira os atributos do arquivo para evitar o erro FILE ACCESS DENIED em máquinas 2000 - AssignFile(HistoricoLog,p_path_cacic + 'cacic2.log'); {Associa o arquivo a uma variável do tipo TextFile} - {$IOChecks off} - Reset(HistoricoLog); {Abre o arquivo texto} - {$IOChecks on} - if (IOResult <> 0) then // Arquivo não existe, será recriado. - begin - Rewrite (HistoricoLog); - Append(HistoricoLog); - Writeln(HistoricoLog,FormatDateTime('dd/mm hh:nn:ss : ', Now) + '======================> Iniciando o Log do CACIC <======================='); - end; - DateTimeToString(strDataArqLocal, 'yyyymmdd', FileDateToDateTime(Fileage(p_path_cacic + 'cacic2.log'))); - DateTimeToString(strDataAtual , 'yyyymmdd', Date); - if (strDataAtual <> strDataArqLocal) then // Se o arquivo INI não é da data atual... - begin - Rewrite (HistoricoLog); //Cria/Recria o arquivo - Append(HistoricoLog); - Writeln(HistoricoLog,FormatDateTime('dd/mm hh:nn:ss : ', Now) + '======================> Iniciando o Log do CACIC <======================='); - end; - Append(HistoricoLog); - Writeln(HistoricoLog,FormatDateTime('dd/mm hh:nn:ss : ', Now) + strMsg); {Grava a string Texto no arquivo texto} - CloseFile(HistoricoLog); {Fecha o arquivo texto} -// FileSetAttr (ExtractFilePath(Application.Exename) + '\cacic2.log',6); // Muda o atributo para arquivo de SISTEMA e OCULTO - - except - Log_Historico('Erro na gravação do log!'); - end; -end; - -{ -function Tfrm_col_anvi.getVersionInfo(Arquivo : String) : String; -var - VerInfoSize, VerValueSize, Dummy : DWORD; - VerInfo : Pointer; - VerValue : PVSFixedFileInfo; - V1, // Major Version - V2, // Minor Version - V3, // Release - V4: Word; // Build Number -begin - Try - messagedlg('Passo 1...',mtConfirmation,[mbok],0); - VerInfoSize := GetFileVersionInfoSize(PChar(ParamStr(0)), Dummy); - messagedlg('Passo 2...',mtConfirmation,[mbok],0); - GetMem(VerInfo, VerInfoSize); - messagedlg('Passo 3...',mtConfirmation,[mbok],0); - GetFileVersionInfo(PChar(Arquivo), 0, VerInfoSize, VerInfo); - messagedlg('Passo 4...',mtConfirmation,[mbok],0); - VerQueryValue(VerInfo, '\', Pointer(VerValue), VerValueSize); - messagedlg('Passo 5...',mtConfirmation,[mbok],0); - With VerValue^ do - begin - messagedlg('Passo 6...',mtConfirmation,[mbok],0); - V1 := dwFileVersionMS shr 16; - messagedlg('Passo 7...',mtConfirmation,[mbok],0); - V2 := dwFileVersionMS and $FFFF; - messagedlg('Passo 8...',mtConfirmation,[mbok],0); - V3 := dwFileVersionLS shr 16; - messagedlg('Passo 9...',mtConfirmation,[mbok],0); - V4 := dwFileVersionLS and $FFFF; - messagedlg('Passo 10...',mtConfirmation,[mbok],0); - end; - messagedlg('Passo 11...',mtConfirmation,[mbok],0); - FreeMem(VerInfo, VerInfoSize); - messagedlg('Passo 12...',mtConfirmation,[mbok],0); - Result := IntToStr(V1) + '.' + IntToStr(V2) + '.' + IntToStr(V3) + '.' + IntToStr(V4); - messagedlg('Passo 13...',mtConfirmation,[mbok],0); - Except - messagedlg('Passo 14...',mtConfirmation,[mbok],0); - Result := '?.?.?.?'; - End; -end; -} - - -function Tfrm_col_anvi.ProgramaRodando(NomePrograma: String): Boolean; -var - IsRunning, ContinueTest: Boolean; - FSnapshotHandle: THandle; - FProcessEntry32: TProcessEntry32; -begin - IsRunning := False; - FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); - FProcessEntry32.dwSize := Sizeof(FProcessEntry32); - ContinueTest := Process32First(FSnapshotHandle, FProcessEntry32); - while ContinueTest do - begin - IsRunning := UpperCase(ExtractFileName(FProcessEntry32.szExeFile)) = UpperCase(NomePrograma); - if IsRunning then ContinueTest := False - else ContinueTest := Process32Next(FSnapshotHandle, FProcessEntry32); - end; - CloseHandle(FSnapshotHandle); - Result := IsRunning; -end; - - -procedure Tfrm_col_anvi.Executa_Col_Anvi; -var Lista1_RCO : TStringList; - Lista2_RCO : TStrings; - nu_versao_engine, dt_hr_instalacao, nu_versao_pattern, ChaveRegistro, te_servidor, in_ativo, - NomeExecutavel, ValorChaveColetado, ValorChaveRegistro, strAux, strDirTrend : String; - searchResult : TSearchRec; // Necessário apenas para Win9x -begin - Try - nu_versao_engine := ''; - nu_versao_pattern := ''; - Log_Historico('* Coletando informações de Antivírus OfficeScan.'); - If Win32Platform = VER_PLATFORM_WIN32_WINDOWS Then { Windows 9x/ME } - Begin - ChaveRegistro := 'HKEY_LOCAL_MACHINE\Software\TrendMicro\OfficeScanCorp\CurrentVersion'; - NomeExecutavel := 'pccwin97.exe'; - dt_hr_instalacao := frm_col_anvi.GetValorChaveRegEdit(ChaveRegistro + '\Install Date') + frm_col_anvi.GetValorChaveRegEdit(ChaveRegistro + '\Install Time'); - strDirTrend := frm_col_anvi.GetValorChaveRegEdit(ChaveRegistro + '\Application Path'); - If FileExists(strDirTrend + '\filter32.vxd') Then - Begin - // Em máquinas Windows 9X a versão do engine e do pattern não são gravadas no registro. Tenho que pegar direto dos arquivos. - Lista2_RCO := frm_col_anvi.Explode(frm_col_anvi.getVersionInfo(strDirTrend + 'filter32.vxd'), '.'); // Pego só os dois primeiros dígitos. Por exemplo: 6.640.0.1001 vira 6.640. - nu_versao_engine := Lista2_RCO[0] + '.' + Lista2_RCO[1]; - Lista2_RCO.Free; - end - Else nu_versao_engine := '0'; - // A gambiarra para coletar a versão do pattern é obter a maior extensão do arquivo lpt$vpn - if FindFirst(strDirTrend + '\lpt$vpn.*', faAnyFile, searchResult) = 0 then - begin - Lista1_RCO := TStringList.Create; - repeat Lista1_RCO.Add(ExtractFileExt(searchResult.Name)); - until FindNext(searchResult) <> 0; - Sysutils.FindClose(searchResult); - Lista1_RCO.Sort; // Ordeno, para, em seguida, obter o último. - strAux := Lista1_RCO[Lista1_RCO.Count - 1]; - Lista1_RCO.Free; - nu_versao_pattern := Copy(strAux, 2, Length(strAux)); // Removo o '.' da extensão. - end; - end - Else - Begin // NT a XP - ChaveRegistro := 'HKEY_LOCAL_MACHINE\Software\TrendMicro\PC-cillinNTCorp\CurrentVersion'; - NomeExecutavel := 'ntrtscan.exe'; - dt_hr_instalacao := frm_col_anvi.GetValorChaveRegEdit(ChaveRegistro + '\InstDate') + frm_col_anvi.GetValorChaveRegEdit(ChaveRegistro + '\InstTime'); - nu_versao_engine := frm_col_anvi.GetValorChaveRegEdit(ChaveRegistro + '\Misc.\EngineZipVer'); - nu_versao_pattern := frm_col_anvi.GetValorChaveRegEdit(ChaveRegistro + '\Misc.\PatternVer'); - nu_versao_pattern := Copy(nu_versao_pattern, 2, Length(nu_versao_pattern)-3); - end; - te_servidor := frm_col_anvi.GetValorChaveRegEdit(ChaveRegistro + '\Server'); - If (frm_col_anvi.ProgramaRodando(NomeExecutavel)) Then in_ativo := '1' Else in_ativo := '0'; - // Monto a string que será comparada com o valor armazenado no registro. - ValorChaveColetado := Trim(nu_versao_engine + ';' + - nu_versao_pattern + ';' + - te_servidor + ';' + - dt_hr_instalacao + ';' + - in_ativo); - // Obtenho do registro o valor que foi previamente armazenado - ValorChaveRegistro := Trim(GetValorChaveRegIni('Coleta','OfficeScan',p_path_cacic_ini)); - - // Se essas informações forem diferentes significa que houve alguma alteração - // na configuração. Nesse caso, gravo as informações no BD Central - // e, se não houver problemas durante esse procedimento, atualizo as - // informações no registro. - - If (GetValorChaveRegIni('Configs','IN_COLETA_FORCADA_ANVI',p_path_cacic_ini)='S') or (ValorChaveColetado <> ValorChaveRegistro) Then - Begin - frm_col_anvi.SetValorChaveRegIni('Col_Anvi','nu_versao_engine' , nu_versao_engine ,frm_col_anvi.GetValorChaveRegIni('Configs','P_PATH_COLETAS_INI',p_path_cacic + 'cacic2.ini')+'col_anvi.ini'); - frm_col_anvi.SetValorChaveRegIni('Col_Anvi','nu_versao_pattern' , nu_versao_pattern ,frm_col_anvi.GetValorChaveRegIni('Configs','P_PATH_COLETAS_INI',p_path_cacic + 'cacic2.ini')+'col_anvi.ini'); - frm_col_anvi.SetValorChaveRegIni('Col_Anvi','dt_hr_instalacao' , dt_hr_instalacao ,frm_col_anvi.GetValorChaveRegIni('Configs','P_PATH_COLETAS_INI',p_path_cacic + 'cacic2.ini')+'col_anvi.ini'); - frm_col_anvi.SetValorChaveRegIni('Col_Anvi','te_servidor' , te_servidor ,frm_col_anvi.GetValorChaveRegIni('Configs','P_PATH_COLETAS_INI',p_path_cacic + 'cacic2.ini')+'col_anvi.ini'); - frm_col_anvi.SetValorChaveRegIni('Col_Anvi','in_ativo' , in_ativo ,frm_col_anvi.GetValorChaveRegIni('Configs','P_PATH_COLETAS_INI',p_path_cacic + 'cacic2.ini')+'col_anvi.ini'); - frm_col_anvi.SetValorChaveRegIni('Col_Anvi','ValorChaveColetado', ValorChaveColetado,frm_col_anvi.GetValorChaveRegIni('Configs','P_PATH_COLETAS_INI',p_path_cacic + 'cacic2.ini')+'col_anvi.ini'); - end - else frm_col_anvi.SetValorChaveRegIni('Col_Anvi', 'nada', 'nada',frm_col_anvi.GetValorChaveRegIni('Configs','P_PATH_COLETAS_INI',p_path_cacic + 'cacic2.ini')+'col_anvi.ini'); - application.Terminate; - Except - frm_col_anvi.SetValorChaveRegIni('Col_Anvi', 'nada', 'nada',frm_col_anvi.GetValorChaveRegIni('Configs','P_PATH_COLETAS_INI',p_path_cacic + 'cacic2.ini')+'col_anvi.ini'); - application.Terminate; - End; -end; -procedure Tfrm_col_anvi.FormCreate(Sender: TObject); -var tstrTripa1 : TStrings; - intAux : integer; -begin - //Pegarei o nível anterior do diretório, que deve ser, por exemplo \Cacic, para leitura do cacic2.ini - tstrTripa1 := explode(ExtractFilePath(Application.Exename),'\'); - p_path_cacic := ''; - For intAux := 0 to tstrTripa1.Count -2 do - begin - p_path_cacic := p_path_cacic + tstrTripa1[intAux] + '\'; - end; - p_path_cacic_ini := p_path_cacic + 'cacic2.ini'; - Application.ShowMainForm := false; - - Try - Executa_Col_Anvi; - Except - frm_col_anvi.SetValorChaveRegIni('Col_Anvi', 'nada', 'nada',frm_col_anvi.GetValorChaveRegIni('Configs','P_PATH_COLETAS_INI',p_path_cacic + 'cacic2.ini')+'col_anvi.ini'); - application.Terminate; - End; -end; - -end. diff --git a/col_anvi/utils.pas b/col_anvi/utils.pas deleted file mode 100755 index 8238995..0000000 --- a/col_anvi/utils.pas +++ /dev/null @@ -1,153 +0,0 @@ -unit utils; - -interface - -Uses Classes, SysUtils, Windows, TLHELP32, dialogs, main; - -Function Explode(Texto, Separador : String) : TStrings; -Function RemoveCaracteresEspeciais(Texto : String) : String; -function ProgramaRodando(NomePrograma: String): Boolean; -function API_GetEnvironmentVariable(EnVar : string) : string; -Function getVersionInfo(Arquivo : String): String; -function LastPos(SubStr, S: string): Integer; -function LetrasDrives : string; - - -implementation - -function LetrasDrives : string; -var i:integer; -strAux : string; - begin - frmmain.MSystemInfo.Disk.GetInfo; - with main.frmMain.MSystemInfo.Disk do - begin - for i:=1 to length(AvailableDisks) do - begin - Drive := UpperCase(Copy(AvailableDisks,i,1)) + ':'; - if (UpperCase(GetMediaTypeStr(MediaType)) = 'FIXED') then - Begin - strAux := strAux + UpperCase(Copy(Drive,1,1)); - end; - end; - end; - Result := strAux; - end; - - -function LastPos(SubStr, S: string): Integer; -var - Found, Len, Pos: integer; -begin - Pos := Length(S); - Len := Length(SubStr); - Found := 0; - while (Pos > 0) and (Found = 0) do - begin - if Copy(S, Pos, Len) = SubStr then - Found := Pos; - Dec(Pos); - end; - LastPos := Found; -end; -Function Explode(Texto, Separador : String) : TStrings; -var - strItem : String; - ListaAuxUTILS : TStrings; - NumCaracteres, I : Integer; -Begin - ListaAuxUTILS := TStringList.Create; - strItem := ''; - NumCaracteres := Length(Texto); - For I := 0 To NumCaracteres Do - If (Texto[I] = Separador) or (I = NumCaracteres) Then - Begin - If (I = NumCaracteres) then strItem := strItem + Texto[I]; - ListaAuxUTILS.Add(Trim(strItem)); - strItem := ''; - end - Else strItem := strItem + Texto[I]; - Explode := ListaAuxUTILS; -//Não estava sendo liberado -// ListaAuxUTILS.Free; -//Ao ativar esta liberação tomei uma baita surra!!!! 11/05/2004 - 20:30h - Uma noite muito escura! :) Anderson Peterle -end; - - -Function RemoveCaracteresEspeciais(Texto : String) : String; -var I : Integer; - strAux : String; -Begin - For I := 0 To Length(Texto) Do - if ord(Texto[I]) in [32..126] Then - strAux := strAux + Texto[I] - else strAux := strAux + ' '; // Coloca um espaço onde houver caracteres especiais - Result := strAux; -end; - - -function ProgramaRodando(NomePrograma: String): Boolean; -var - IsRunning, ContinueTest: Boolean; - FSnapshotHandle: THandle; - FProcessEntry32: TProcessEntry32; -begin - IsRunning := False; - FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); - FProcessEntry32.dwSize := Sizeof(FProcessEntry32); - ContinueTest := Process32First(FSnapshotHandle, FProcessEntry32); - while ContinueTest do - begin - IsRunning := UpperCase(ExtractFileName(FProcessEntry32.szExeFile)) = UpperCase(NomePrograma); - if IsRunning then ContinueTest := False - else ContinueTest := Process32Next(FSnapshotHandle, FProcessEntry32); - end; - CloseHandle(FSnapshotHandle); - Result := IsRunning; -end; - -function API_GetEnvironmentVariable(EnVar : string) : string; -// -// Retorna informações sobre uma variável do ambiente -// -var -pEnvStrings : pointer; -begin -pEnvStrings := GetEnvironmentStrings; -SetLength(Result, 256); -SetLength(Result, GetEnvironmentVariable(pchar(EnVar), pchar(Result),256)); -FreeEnvironmentStrings(pEnvStrings); -end; - -function getVersionInfo(Arquivo : String) : String; -var - VerInfoSize, VerValueSize, Dummy : DWORD; - VerInfo : Pointer; - VerValue : PVSFixedFileInfo; - V1, // Major Version - V2, // Minor Version - V3, // Release - V4: Word; // Build Number -begin - Try - VerInfoSize := GetFileVersionInfoSize(PChar(ParamStr(0)), Dummy); - GetMem(VerInfo, VerInfoSize); - GetFileVersionInfo(PChar(Arquivo), 0, VerInfoSize, VerInfo); - VerQueryValue(VerInfo, '\', Pointer(VerValue), VerValueSize); - With VerValue^ do - begin - V1 := dwFileVersionMS shr 16; - V2 := dwFileVersionMS and $FFFF; - V3 := dwFileVersionLS shr 16; - V4 := dwFileVersionLS and $FFFF; - end; - FreeMem(VerInfo, VerInfoSize); - Result := IntToStr(V1) + '.' + IntToStr(V2) + '.' + IntToStr(V3) + '.' + IntToStr(V4); - Except - Result := ''; - End; -end; - - - -end. diff --git a/col_hard/col_hard.dpr b/col_hard/col_hard.dpr index ab2b3a3..08e7e3d 100644 --- a/col_hard/col_hard.dpr +++ b/col_hard/col_hard.dpr @@ -936,18 +936,24 @@ begin v_te_mem_ram_desc := v_te_mem_ram_desc + ' - '; v_te_mem_ram_desc := v_te_mem_ram_desc + 'Slot '+ inttostr(i) + ': ' + v_SMBIOS.MemoryDevice[i].Manufacturer + ' ' - //+ v_SMBIOS.MemoryDevice[i].Device + ' ' + inttostr(v_SMBIOS.MemoryModule[i].Size) + 'Mb ' + '(' + v_te_mem_ram_tipo +')'; end; end; end; - if (trim(v_te_placa_mae_fabricante)='') then - v_te_placa_mae_fabricante := v_SMBIOS.MainBoardManufacturer; + if (trim(v_te_placa_mae_fabricante)='') then begin + v_te_placa_mae_fabricante := v_SMBIOS.MainBoardManufacturer; + if (trim(v_te_placa_mae_fabricante)='') then + v_te_placa_mae_fabricante := v_SMBIOS.SystemManufacturer; + end; + + if (trim(v_te_placa_mae_desc)='') then begin + v_te_placa_mae_desc := v_SMBIOS.MainBoardModel; + if (trim(v_te_placa_mae_desc)='') then + v_te_placa_mae_desc := v_SMBIOS.SystemModel; + end; - if (trim(v_te_placa_mae_desc)='') then - v_te_placa_mae_desc := v_SMBIOS.MainBoardModel; v_te_bios_data := v_SMBIOS.BIOSDate; v_te_bios_fabricante := v_SMBIOS.BIOSVendor; diff --git a/col_patr/main_col_patr.pas b/col_patr/main_col_patr.pas index 3ad4ad7..4f80196 100755 --- a/col_patr/main_col_patr.pas +++ b/col_patr/main_col_patr.pas @@ -35,7 +35,8 @@ uses IniFiles, DCPrijndael, DCPbase64, ExtCtrls, - Math; + Math, + CACIC_Library; var p_path_cacic : String; v_Dados_Patrimonio : TStrings; @@ -51,6 +52,9 @@ var p_path_cacic : String; var v_tstrCipherOpened, v_tstrCipherOpened1 : TStrings; +var + g_oCacic : TCACIC; + // Some constants that are dependant on the cipher being used // Assuming MCRYPT_RIJNDAEL_128 (i.e., 128bit blocksize, 256bit keysize) const KeySize = 32; // 32 bytes = 256 bits @@ -93,7 +97,6 @@ type function HomeDrive : string; Function Implode(p_Array : TStrings ; p_Separador : String) : String; Function CipherClose(p_DatFileName : string; p_tstrCipherOpened : TStrings) : String; - function GetWinVer: Integer; Function Explode(Texto, Separador : String) : TStrings; Function CipherOpen(p_DatFileName : string) : TStrings; Function GetValorDatMemoria(p_Chave : String; p_tstrCipherOpened : TStrings) : String; @@ -344,64 +347,7 @@ begin except end; end; -function TFormPatrimonio.GetWinVer: Integer; -const - { operating system (OS)constants } - cOsUnknown = 0; - cOsWin95 = 1; - cOsWin95OSR2 = 2; // Não implementado. - cOsWin98 = 3; - cOsWin98SE = 4; - cOsWinME = 5; - cOsWinNT = 6; - cOsWin2000 = 7; - cOsXP = 8; -var - osVerInfo: TOSVersionInfo; - majorVer, minorVer: Integer; -begin - Result := cOsUnknown; - { set operating system type flag } - osVerInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfo); - if GetVersionEx(osVerInfo) then - begin - majorVer := osVerInfo.dwMajorVersion; - minorVer := osVerInfo.dwMinorVersion; - case osVerInfo.dwPlatformId of - VER_PLATFORM_WIN32_NT: { Windows NT/2000 } - begin - if majorVer <= 4 then - Result := cOsWinNT - else if (majorVer = 5) and (minorVer = 0) then - Result := cOsWin2000 - else if (majorVer = 5) and (minorVer = 1) then - Result := cOsXP - else - Result := cOsUnknown; - end; - VER_PLATFORM_WIN32_WINDOWS: { Windows 9x/ME } - begin - if (majorVer = 4) and (minorVer = 0) then - Result := cOsWin95 - else if (majorVer = 4) and (minorVer = 10) then - begin - if osVerInfo.szCSDVersion[1] = 'A' then - Result := cOsWin98SE - else - Result := cOsWin98; - end - else if (majorVer = 4) and (minorVer = 90) then - Result := cOsWinME - else - Result := cOsUnknown; - end; - else - Result := cOsUnknown; - end; - end - else - Result := cOsUnknown; -end; + Function TFormPatrimonio.Explode(Texto, Separador : String) : TStrings; var strItem : String; @@ -466,7 +412,7 @@ begin if (trim(v_strCipherOpened)<>'') then Result := explode(v_strCipherOpened,'=CacicIsFree=') else - Result := explode('Configs.ID_SO=CacicIsFree='+inttostr(GetWinVer)+'=CacicIsFree=Configs.Endereco_WS=CacicIsFree=/cacic2/ws/','=CacicIsFree='); + Result := explode('Configs.ID_SO=CacicIsFree='+ g_oCacic.getWindowsStrId() +'=CacicIsFree=Configs.Endereco_WS=CacicIsFree=/cacic2/ws/','=CacicIsFree='); if Result.Count mod 2 = 0 then Result.Add(''); @@ -1128,6 +1074,7 @@ var boolColeta : boolean; i,intAux : integer; v_Aux : String; Begin + g_oCacic := TCACIC.Create(); if (ParamCount>0) then Begin @@ -1216,6 +1163,7 @@ Begin SetValorDatMemoria('Col_Patr.nada','nada', v_tstrCipherOpened1); SetValorDatMemoria('Col_Patr.Fim', '99999999', v_tstrCipherOpened1); CipherClose(p_path_cacic + 'temp\col_patr.dat', v_tstrCipherOpened1); + g_oCacic.Free(); Application.Terminate; End; End; diff --git a/ger_cols/ger_cols.dpr b/ger_cols/ger_cols.dpr index c3e1633..01c1154 100755 --- a/ger_cols/ger_cols.dpr +++ b/ger_cols/ger_cols.dpr @@ -1748,6 +1748,69 @@ begin if ChecaAgente(p_path_cacic + 'modulos', 'ini_cols.exe') then g_oCacic.createSampleProcess( p_path_cacic + 'modulos\ini_cols.exe /p_CipherKey=' + v_CipherKey + ' /p_ModulosOpcoes=col_patr,wait,user#', CACIC_PROCESS_WAIT ); + + if (FileExists(p_path_cacic + 'Temp\col_patr.dat')) then + Begin + log_DEBUG('Indicador '+p_path_cacic + 'Temp\col_patr.dat encontrado.'); + v_acao_gercols := '* Preparando envio de informações de Patrimônio.'; + v_tstrCipherOpened1 := CipherOpen(p_path_cacic + 'Temp\col_patr.dat'); + + // Armazeno dados para informações de coletas na data, via menu popup do Systray + SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+'#Informações Patrimoniais', v_tstrCipherOpened); + + // Armazeno as horas de início e fim das coletas + SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+','+GetValorDatMemoria('Col_Patr.Inicio',v_tstrCipherOpened1), v_tstrCipherOpened); + SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+','+GetValorDatMemoria('Col_Patr.Fim',v_tstrCipherOpened1), v_tstrCipherOpened); + + if (GetValorDatMemoria('Col_Patr.nada',v_tstrCipherOpened1)='') then + Begin + // Preparação para envio... + Request_Ger_Cols.Values['id_unid_organizacional_nivel1'] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Patr.id_unid_organizacional_nivel1' ,v_tstrCipherOpened1),l_cs_compress),'+','',[rfReplaceAll]); + Request_Ger_Cols.Values['id_unid_organizacional_nivel1a'] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Patr.id_unid_organizacional_nivel1a' ,v_tstrCipherOpened1),l_cs_compress),'+','',[rfReplaceAll]); + Request_Ger_Cols.Values['id_unid_organizacional_nivel2'] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Patr.id_unid_organizacional_nivel2' ,v_tstrCipherOpened1),l_cs_compress),'+','',[rfReplaceAll]); + Request_Ger_Cols.Values['te_localizacao_complementar' ] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Patr.te_localizacao_complementar' ,v_tstrCipherOpened1),l_cs_compress),'+','',[rfReplaceAll]); + Request_Ger_Cols.Values['te_info_patrimonio1' ] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Patr.te_info_patrimonio1' ,v_tstrCipherOpened1),l_cs_compress),'+','',[rfReplaceAll]); + Request_Ger_Cols.Values['te_info_patrimonio2' ] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Patr.te_info_patrimonio2' ,v_tstrCipherOpened1),l_cs_compress),'+','',[rfReplaceAll]); + Request_Ger_Cols.Values['te_info_patrimonio3' ] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Patr.te_info_patrimonio3' ,v_tstrCipherOpened1),l_cs_compress),'+','',[rfReplaceAll]); + Request_Ger_Cols.Values['te_info_patrimonio4' ] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Patr.te_info_patrimonio4' ,v_tstrCipherOpened1),l_cs_compress),'+','',[rfReplaceAll]); + Request_Ger_Cols.Values['te_info_patrimonio5' ] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Patr.te_info_patrimonio5' ,v_tstrCipherOpened1),l_cs_compress),'+','',[rfReplaceAll]); + Request_Ger_Cols.Values['te_info_patrimonio6' ] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Patr.te_info_patrimonio6' ,v_tstrCipherOpened1),l_cs_compress),'+','',[rfReplaceAll]); + + if v_Debugs then + For intLoop := 0 to Request_Ger_Cols.Count-1 do + log_DEBUG('Item "'+Request_Ger_Cols.Names[intLoop]+'" de Col_Patr: '+Request_Ger_Cols.ValueFromIndex[intLoop]); + + if (ComunicaServidor('set_patrimonio.php', Request_Ger_Cols, '>> Enviando informações de Patrimônio para o Gerente WEB.') <> '0') Then + Begin + // Armazeno o Status Positivo de Envio + SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+',1', v_tstrCipherOpened); + + // Somente atualizo o registro caso não tenha havido nenhum erro durante o envio das informações para o BD + //Sobreponho a informação no registro para posterior comparação, na próxima execução. + SetValorDatMemoria('Patrimonio.id_unid_organizacional_nivel1' , GetValorDatMemoria('Col_Patr.id_unid_organizacional_nivel1',v_tstrCipherOpened1), v_tstrCipherOpened); + SetValorDatMemoria('Patrimonio.id_unid_organizacional_nivel1a', GetValorDatMemoria('Col_Patr.id_unid_organizacional_nivel1a',v_tstrCipherOpened1), v_tstrCipherOpened); + SetValorDatMemoria('Patrimonio.id_unid_organizacional_nivel2' , GetValorDatMemoria('Col_Patr.id_unid_organizacional_nivel2',v_tstrCipherOpened1), v_tstrCipherOpened); + SetValorDatMemoria('Patrimonio.te_localizacao_complementar' , GetValorDatMemoria('Col_Patr.te_localizacao_complementar' ,v_tstrCipherOpened1), v_tstrCipherOpened); + SetValorDatMemoria('Patrimonio.te_info_patrimonio1' , GetValorDatMemoria('Col_Patr.te_info_patrimonio1' ,v_tstrCipherOpened1), v_tstrCipherOpened); + SetValorDatMemoria('Patrimonio.te_info_patrimonio2' , GetValorDatMemoria('Col_Patr.te_info_patrimonio2' ,v_tstrCipherOpened1), v_tstrCipherOpened); + SetValorDatMemoria('Patrimonio.te_info_patrimonio3' , GetValorDatMemoria('Col_Patr.te_info_patrimonio3' ,v_tstrCipherOpened1), v_tstrCipherOpened); + SetValorDatMemoria('Patrimonio.te_info_patrimonio4' , GetValorDatMemoria('Col_Patr.te_info_patrimonio4' ,v_tstrCipherOpened1), v_tstrCipherOpened); + SetValorDatMemoria('Patrimonio.te_info_patrimonio5' , GetValorDatMemoria('Col_Patr.te_info_patrimonio5' ,v_tstrCipherOpened1), v_tstrCipherOpened); + SetValorDatMemoria('Patrimonio.te_info_patrimonio6' , GetValorDatMemoria('Col_Patr.te_info_patrimonio6' ,v_tstrCipherOpened1), v_tstrCipherOpened); + SetValorDatMemoria('Patrimonio.ultima_rede_obtida' , GetValorDatMemoria('TcpIp.ID_IP_REDE' ,v_tstrCipherOpened) , v_tstrCipherOpened); + intAux := 1; + End + else + // Armazeno o Status Negativo de Envio + SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+',-1', v_tstrCipherOpened); + End + else + // Armazeno o Status Nulo de Envio + SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+',0', v_tstrCipherOpened); + + Request_Ger_Cols.Clear; + Matar(p_path_cacic+'Temp\','col_patr.dat'); + End; end; procedure ChecaCipher; diff --git a/ini_cols/ini_cols.dpr b/ini_cols/ini_cols.dpr index 4bd8118..b593240 100755 --- a/ini_cols/ini_cols.dpr +++ b/ini_cols/ini_cols.dpr @@ -181,66 +181,6 @@ Begin Explode := ListaAuxUTILS; end; - -function GetWinVer: Integer; -const - { operating system (OS)constants } - cOsUnknown = 0; - cOsWin95 = 1; - cOsWin95OSR2 = 2; // Não implementado. - cOsWin98 = 3; - cOsWin98SE = 4; - cOsWinME = 5; - cOsWinNT = 6; - cOsWin2000 = 7; - cOsXP = 8; -var - osVerInfo: TOSVersionInfo; - majorVer, minorVer: Integer; -begin - Result := cOsUnknown; - { set operating system type flag } - osVerInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfo); - if GetVersionEx(osVerInfo) then - begin - majorVer := osVerInfo.dwMajorVersion; - minorVer := osVerInfo.dwMinorVersion; - case osVerInfo.dwPlatformId of - VER_PLATFORM_WIN32_NT: { Windows NT/2000 } - begin - if majorVer <= 4 then - Result := cOsWinNT - else if (majorVer = 5) and (minorVer = 0) then - Result := cOsWin2000 - else if (majorVer = 5) and (minorVer = 1) then - Result := cOsXP - else - Result := cOsUnknown; - end; - VER_PLATFORM_WIN32_WINDOWS: { Windows 9x/ME } - begin - if (majorVer = 4) and (minorVer = 0) then - Result := cOsWin95 - else if (majorVer = 4) and (minorVer = 10) then - begin - if osVerInfo.szCSDVersion[1] = 'A' then - Result := cOsWin98SE - else - Result := cOsWin98; - end - else if (majorVer = 4) and (minorVer = 90) then - Result := cOsWinME - else - Result := cOsUnknown; - end; - else - Result := cOsUnknown; - end; - end - else - Result := cOsUnknown; -end; - Function GetValorDatMemoria(p_Chave : String) : String; begin if (v_tstrCipherOpened.IndexOf(p_Chave)<>-1) then @@ -337,8 +277,9 @@ Function CipherOpen(p_DatFileName : string) : TStrings; var v_DatFile : TextFile; v_strCipherOpened, v_strCipherClosed : string; -// intLoop : integer; + oCacic : TCACIC; begin + oCacic := TCACIC.Create(); v_strCipherOpened := ''; if FileExists(p_DatFileName) then begin @@ -358,10 +299,11 @@ begin v_strCipherOpened:= DeCrypt(v_strCipherClosed); log_DEBUG('Rotina de Abertura do cacic2.dat RESTAURANDO estado da criptografia.'); end; + if (trim(v_strCipherOpened)<>'') then Result := explode(v_strCipherOpened,v_SeparatorKey) else - Result := explode('Configs.ID_SO'+v_SeparatorKey+inttostr(GetWinVer)+v_SeparatorKey+'Configs.Endereco_WS'+v_SeparatorKey+'/cacic2/ws/',v_SeparatorKey); + Result := explode('Configs.ID_SO'+v_SeparatorKey+ oCacic.getWindowsStrId() +v_SeparatorKey+'Configs.Endereco_WS'+v_SeparatorKey+'/cacic2/ws/',v_SeparatorKey); if Result.Count mod 2 <> 0 then @@ -369,14 +311,8 @@ begin log_DEBUG('Vetor MemoryDAT com tamanho IMPAR... Ajustando.'); Result.Add(''); End; - - { - log_DEBUG(v_DatFileName+' aberto com sucesso!'); - if v_Debugs then - for intLoop := 0 to (Result.Count-1) do - log_DEBUG('Posição ['+inttostr(intLoop)+'] do MemoryDAT: '+Result[intLoop]); - } - + + oCacic.Free(); end; Function FTP(p_Host : String; p_Port : String; p_Username : String; p_Password : String; p_PathServer : String; p_File : String; p_Dest : String) : Boolean; diff --git a/main.pas b/main.pas index f143915..384e2be 100755 --- a/main.pas +++ b/main.pas @@ -63,6 +63,9 @@ var p_path_cacic, boolCrypt, boolDebugs : Boolean; +var + g_oCacic: TCACIC; + type TFormularioGeral = class(TForm) Pn_InfosGerais: TPanel; @@ -179,7 +182,6 @@ type Procedure DelValorReg(Chave: String); function GetRootKey(strRootKey: String): HKEY; - function GetWinVer: Integer; function FindWindowByTitle(WindowTitle: string): Hwnd; function GetValorChaveRegIni(p_SectionName, p_KeyName, p_IniFileName : String) : String; Function RemoveZerosFimString(Texto : String) : String; @@ -187,7 +189,6 @@ type procedure Bt_Fechar_InfosGeraisClick(Sender: TObject); function Get_File_Size(sFileToExamine: string; bInKBytes: Boolean): string; function Posso_Rodar : boolean; - function abstraiCSD(p_te_so : String) : integer; { procedure IdHTTPServerCACICCommandGet(AThread: TIdPeerThread; ARequestInfo: TIdHTTPRequestInfo; @@ -792,7 +793,7 @@ begin v_tstrCipherOpened := explode(v_strCipherOpened,v_SeparatorKey) else Begin - v_tstrCipherOpened := explode('Configs.ID_SO'+v_SeparatorKey+inttostr(GetWinVer)+v_SeparatorKey+ + v_tstrCipherOpened := explode('Configs.ID_SO'+v_SeparatorKey+ g_oCacic.getWindowsStrId() +v_SeparatorKey+ 'Configs.Endereco_WS'+v_SeparatorKey+'/cacic2/ws/',v_SeparatorKey); log_DEBUG(v_DatFileName+' Inexistente. Criado o DAT em memória.'); End; @@ -1141,85 +1142,6 @@ var log_DEBUG('Resgatei '+p_SectionName+'/'+p_KeyName+' de '+p_IniFileName+' => "'+Result+'"'); end; - -function TFormularioGeral.GetWinVer: Integer; -const - { operating system (OS)constants } - cOsUnknown = 0; - cOsWin95 = 1; - cOsWin95OSR2 = 2; // Não implementado. - cOsWin98 = 3; - cOsWin98SE = 4; - cOsWinME = 5; - cOsWinNT = 6; - cOsWin2000 = 7; - cOsXP = 8; -var - osVerInfo: TOSVersionInfo; - platformID, - majorVer, - minorVer : Integer; - CSDVersion : String; -begin - Result := cOsUnknown; - { set operating system type flag } - osVerInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfo); - if GetVersionEx(osVerInfo) then - begin - platformId := osVerInfo.dwPlatformId; - majorVer := osVerInfo.dwMajorVersion; - minorVer := osVerInfo.dwMinorVersion; - CSDVersion := trim(osVerInfo.szCSDVersion); - case osVerInfo.dwPlatformId of - VER_PLATFORM_WIN32_NT: { Windows NT/2000 } - begin - if majorVer <= 4 then - Result := cOsWinNT - else if (majorVer = 5) and (minorVer = 0) then - Result := cOsWin2000 - else if (majorVer = 5) and (minorVer = 1) then - Result := cOsXP - else - Result := cOsUnknown; - end; - VER_PLATFORM_WIN32_WINDOWS: { Windows 9x/ME } - begin - if (majorVer = 4) and (minorVer = 0) then - Result := cOsWin95 - else if (majorVer = 4) and (minorVer = 10) then - begin - if osVerInfo.szCSDVersion[1] = 'A' then - Result := cOsWin98SE - else - Result := cOsWin98; - end - else if (majorVer = 4) and (minorVer = 90) then - Result := cOsWinME - else - Result := cOsUnknown; - end; - else - Result := cOsUnknown; - end; - end - else - Result := cOsUnknown; - // A partir da versão 2.2.0.24, defino o valor da ID Interna e atribuo-a sem o CSDVersion à versão externa - v_te_so := IntToStr(platformId) + '.' + - IntToStr(majorVer) + '.' + - IntToStr(minorVer) + - IfThen(CSDVersion='','','.'+CSDVersion); - if (Result = 0) then - Result := abstraiCSD(v_te_so); - -end; -function TFormularioGeral.abstraiCSD(p_te_so : String) : integer; - var tstrTe_so : tstrings; - Begin - tstrTe_so := Explode(p_te_so, '.'); - Result := StrToInt(tstrTe_so[0] + tstrTe_so[1] + tstrTe_so[2]); - End; - procedure TFormularioGeral.log_DEBUG(p_msg:string); Begin if boolDebugs then log_diario('(v.'+getVersionInfo(ParamStr(0))+') DEBUG - '+p_msg); @@ -1258,17 +1180,16 @@ var strAux, intAux : integer; v_Aguarde : TextFile; v_SystemDrive : TStrings; - oCacic : TCACIC; begin // Não mostrar o formulário... Application.ShowMainForm:=false; - oCacic := TCACIC.Create; - oCacic.showTrayIcon(false); + g_oCacic := TCACIC.Create; + g_oCacic.showTrayIcon(false); boolCrypt := true; Try // De acordo com a versão do OS, determino o ShellCommand para chamadas externas. - if (oCacic.isWindowsNTPlataform()) then //Se NT/2K/XP... then + if (g_oCacic.isWindowsNTPlataform()) then //Se NT/2K/XP... then Begin p_Shell_Path := HomeDrive + '\system32\'; //NT/2K/XP p_Shell_Command := 'cmd.exe'; //NT/2K/XP @@ -1420,23 +1341,12 @@ begin Begin log_DEBUG('Agente finalizado devido a concomitância de sessões...'); - // Libera memoria referente ao objeto oCacic - try - oCacic.Free; - except - end; - Finaliza; End; Except log_diario('PROBLEMAS NA INICIALIZAÇÃO (2)'); End; - // Libera memoria referente ao objeto oCacic - try - oCacic.Free; - except - end; end; procedure TFormularioGeral.SetaVariaveisGlobais; @@ -1533,8 +1443,8 @@ Begin Except log_diario('PROBLEMAS NA FINALIZAÇÃO'); End; + g_oCacic.Free(); FreeMemory(0); - Halt(0); Application.Terminate; End; @@ -1601,7 +1511,7 @@ var intAux, v_Repete : boolean; begin - log_DEBUG('Execução - Resgate de possíveis novos valores no DAT.'); + log_DEBUG('Execução - Resgate de possíveis novos valores no DAT.' + g_oCacic.getWindowsStrId()); CipherOpen; -- libgit2 0.21.2