Commit e33fca21a94522da706047b17539beadeff531a6

Authored by Adriano Vieira
1 parent 649c5d42
Exists in master

- merge de branch (2.4) revisão [751:730]

git-svn-id: http://svn.softwarepublico.gov.br/svn/cacic/cacic/trunk/agente-windows@757 fecfc0c7-e812-0410-ae72-849f08638ee7
col_anvi/col_anvi.dpr
... ... @@ -42,6 +42,9 @@ var v_Debugs : boolean;
42 42 var v_tstrCipherOpened,
43 43 v_tstrCipherOpened1 : TStrings;
44 44  
  45 +var
  46 + g_oCacic : TCACIC;
  47 +
45 48 // Some constants that are dependant on the cipher being used
46 49 // Assuming MCRYPT_RIJNDAEL_128 (i.e., 128bit blocksize, 256bit keysize)
47 50 const KeySize = 32; // 32 bytes = 256 bits
... ... @@ -235,64 +238,6 @@ begin
235 238 end;
236 239 end;
237 240  
238   -function GetWinVer: Integer;
239   -const
240   - { operating system (OS)constants }
241   - cOsUnknown = 0;
242   - cOsWin95 = 1;
243   - cOsWin95OSR2 = 2; // Não implementado.
244   - cOsWin98 = 3;
245   - cOsWin98SE = 4;
246   - cOsWinME = 5;
247   - cOsWinNT = 6;
248   - cOsWin2000 = 7;
249   - cOsXP = 8;
250   -var
251   - osVerInfo: TOSVersionInfo;
252   - majorVer, minorVer: Integer;
253   -begin
254   - Result := cOsUnknown;
255   - { set operating system type flag }
256   - osVerInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);
257   - if GetVersionEx(osVerInfo) then
258   - begin
259   - majorVer := osVerInfo.dwMajorVersion;
260   - minorVer := osVerInfo.dwMinorVersion;
261   - case osVerInfo.dwPlatformId of
262   - VER_PLATFORM_WIN32_NT: { Windows NT/2000 }
263   - begin
264   - if majorVer <= 4 then
265   - Result := cOsWinNT
266   - else if (majorVer = 5) and (minorVer = 0) then
267   - Result := cOsWin2000
268   - else if (majorVer = 5) and (minorVer = 1) then
269   - Result := cOsXP
270   - else
271   - Result := cOsUnknown;
272   - end;
273   - VER_PLATFORM_WIN32_WINDOWS: { Windows 9x/ME }
274   - begin
275   - if (majorVer = 4) and (minorVer = 0) then
276   - Result := cOsWin95
277   - else if (majorVer = 4) and (minorVer = 10) then
278   - begin
279   - if osVerInfo.szCSDVersion[1] = 'A' then
280   - Result := cOsWin98SE
281   - else
282   - Result := cOsWin98;
283   - end
284   - else if (majorVer = 4) and (minorVer = 90) then
285   - Result := cOsWinME
286   - else
287   - Result := cOsUnknown;
288   - end;
289   - else
290   - Result := cOsUnknown;
291   - end;
292   - end
293   - else
294   - Result := cOsUnknown;
295   -end;
296 241 Function Explode(Texto, Separador : String) : TStrings;
297 242 var
298 243 strItem : String;
... ... @@ -350,7 +295,7 @@ begin
350 295 if (trim(v_strCipherOpened)<>'') then
351 296 Result := explode(v_strCipherOpened,'=CacicIsFree=')
352 297 else
353   - Result := explode('Configs.ID_SO=CacicIsFree='+inttostr(GetWinVer)+'=CacicIsFree=Configs.Endereco_WS=CacicIsFree=/cacic2/ws/','=CacicIsFree=');
  298 + Result := explode('Configs.ID_SO=CacicIsFree='+ g_oCacic.getWindowsStrId() +'=CacicIsFree=Configs.Endereco_WS=CacicIsFree=/cacic2/ws/','=CacicIsFree=');
354 299  
355 300 if Result.Count mod 2 <> 0 then
356 301 Result.Add('');
... ... @@ -499,7 +444,7 @@ begin
499 444 nu_versao_engine := '';
500 445 nu_versao_pattern := '';
501 446 log_diario('Coletando informações de Antivírus OfficeScan.');
502   - If Win32Platform = VER_PLATFORM_WIN32_WINDOWS Then { Windows 9x/ME }
  447 + If g_oCacic.isWindows9xME() Then { Windows 9x/ME }
503 448 Begin
504 449 ChaveRegistro := 'HKEY_LOCAL_MACHINE\Software\TrendMicro\OfficeScanCorp\CurrentVersion';
505 450 NomeExecutavel := 'pccwin97.exe';
... ... @@ -593,13 +538,10 @@ var tstrTripa1 : TStrings;
593 538 const
594 539 CACIC_APP_NAME = 'col_anvi';
595 540  
596   -var
597   - oCacic : TCACIC;
598   -
599 541 begin
600   - oCacic := TCACIC.Create();
  542 + g_oCacic := TCACIC.Create();
601 543  
602   - if( not oCacic.isAppRunning( CACIC_APP_NAME ) ) then
  544 + if( not g_oCacic.isAppRunning( CACIC_APP_NAME ) ) then
603 545 if (ParamCount>0) then
604 546 Begin
605 547 For intAux := 1 to ParamCount do
... ... @@ -645,8 +587,7 @@ begin
645 587 CipherClose(p_path_cacic + 'temp\col_anvi.dat', v_tstrCipherOpened1);
646 588 End;
647 589 End;
648   - Halt(0);
649 590 End;
650 591 End;
651   - oCacic.Free();
  592 + g_oCacic.Free();
652 593 end.
... ...
col_anvi/main_anvi.ddp
No preview for this file type
col_anvi/main_anvi.dfm
... ... @@ -1,21 +0,0 @@
1   -object frm_col_anvi: Tfrm_col_anvi
2   - Left = 911
3   - Top = 713
4   - Width = 112
5   - Height = 27
6   - Caption = 'CACIC - Coletor AntiV'#237'rus'
7   - Color = clBtnFace
8   - TransparentColor = True
9   - Font.Charset = DEFAULT_CHARSET
10   - Font.Color = clWindowText
11   - Font.Height = -11
12   - Font.Name = 'MS Sans Serif'
13   - Font.Style = []
14   - OldCreateOrder = False
15   - OnCreate = FormCreate
16   - PixelsPerInch = 96
17   - TextHeight = 13
18   - object PJVersionInfo1: TPJVersionInfo
19   - Left = 40
20   - end
21   -end
col_anvi/main_anvi.pas
... ... @@ -1,461 +0,0 @@
1   -(**
2   ----------------------------------------------------------------------------------------------------------------------------------------------------------------
3   -Copyright 2000, 2001, 2002, 2003, 2004, 2005 Dataprev - Empresa de Tecnologia e Informações da Previdência Social, Brasil
4   -
5   -Este arquivo é parte do programa CACIC - Configurador Automático e Coletor de Informações Computacionais
6   -
7   -O CACIC é um software livre; você pode redistribui-lo e/ou modifica-lo dentro dos termos da Licença Pública Geral GNU como
8   -publicada pela Fundação do Software Livre (FSF); na versão 2 da Licença, ou (na sua opinião) qualquer versão.
9   -
10   -Este programa é distribuido na esperança que possa ser util, mas SEM NENHUMA GARANTIA; sem uma garantia implicita de ADEQUAÇÂO a qualquer
11   -MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU para maiores detalhes.
12   -
13   -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
14   -Livre(FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15   ----------------------------------------------------------------------------------------------------------------------------------------------------------------
16   -*)
17   -
18   -unit main_anvi;
19   -
20   -interface
21   -
22   -uses Windows, Forms, classes, sysutils, inifiles, Registry, TLHELP32, ShellAPI,
23   - PJVersionInfo;
24   -var p_path_cacic, p_path_cacic_ini : string;
25   -
26   -type
27   - Tfrm_col_anvi = class(TForm)
28   - PJVersionInfo1: TPJVersionInfo;
29   - procedure Executa_Col_Anvi;
30   - procedure Log_Historico(strMsg : String);
31   - Function Crip(PNome: String): String;
32   - Function DesCrip(PNome: String): String;
33   - function SetValorChaveRegIni(p_Secao: String; p_Chave: String; p_Valor: String; p_Path : String): String;
34   -// function GetValorChaveRegIni(p_Secao: String; p_Chave : String; p_Path : String): String;
35   - function GetValorChaveRegIni(p_SectionName, p_KeyName, p_IniFileName : String) : String;
36   - function GetValorChaveRegEdit(Chave: String): Variant;
37   - function GetRootKey(strRootKey: String): HKEY;
38   - Function Explode(Texto, Separador : String) : TStrings;
39   - Function RemoveCaracteresEspeciais(Texto : String) : String;
40   - function GetVersionInfo(p_File: string):string;
41   - function VerFmt(const MS, LS: DWORD): string;
42   - function ProgramaRodando(NomePrograma: String): Boolean;
43   - procedure FormCreate(Sender: TObject);
44   - private
45   - { Private declarations }
46   - public
47   - { Public declarations }
48   - end;
49   -var
50   - frm_col_anvi: Tfrm_col_anvi;
51   -
52   -
53   -implementation
54   -
55   -{$R *.dfm}
56   -function Tfrm_col_anvi.VerFmt(const MS, LS: DWORD): string;
57   - // Format the version number from the given DWORDs containing the info
58   -begin
59   - Result := Format('%d.%d.%d.%d',
60   - [HiWord(MS), LoWord(MS), HiWord(LS), LoWord(LS)])
61   -end;
62   -
63   -{ TMainForm }
64   -
65   -function Tfrm_col_anvi.GetVersionInfo(p_File: string):string;
66   -begin
67   - PJVersionInfo1.FileName := PChar(p_File);
68   - Result := VerFmt(PJVersionInfo1.FixedFileInfo.dwFileVersionMS, PJVersionInfo1.FixedFileInfo.dwFileVersionLS);
69   -end;
70   -
71   -//Para gravar no Arquivo INI...
72   -function Tfrm_col_anvi.SetValorChaveRegIni(p_Secao: String; p_Chave: String; p_Valor: String; p_Path : String): String;
73   -var Reg_Ini : TIniFile;
74   -begin
75   - FileSetAttr (p_Path,0);
76   - Reg_Ini := TIniFile.Create(p_Path);
77   -// Reg_Ini.WriteString(frm_col_anvi.Crip(p_Secao), frm_col_anvi.Crip(p_Chave), frm_col_anvi.Crip(p_Valor));
78   - Reg_Ini.WriteString(p_Secao, p_Chave, p_Valor);
79   - Reg_Ini.Free;
80   -end;
81   -
82   -//Para buscar do Arquivo INI...
83   -//function Tfrm_col_anvi.GetValorChaveRegIni(p_Secao: String; p_Chave : String; p_Path : String): String;
84   -//var Reg_Ini: TIniFile;
85   -//begin
86   -// FileSetAttr (p_Path,0);
87   -// Reg_Ini := TIniFile.Create(p_Path);
88   -//// Result := frm_col_anvi.DesCrip(Reg_Ini.ReadString(frm_col_anvi.Crip(p_Secao), frm_col_anvi.Crip(p_Chave), ''));
89   -// Result := Reg_Ini.ReadString(p_Secao, p_Chave, '');
90   -// Reg_Ini.Free;
91   -//end;
92   -function Tfrm_col_anvi.GetValorChaveRegIni(p_SectionName, p_KeyName, p_IniFileName : String) : String;
93   -var
94   - FileText : TStringList;
95   - i, j, v_Size_Section, v_Size_Key : integer;
96   - v_SectionName, v_KeyName : string;
97   - begin
98   - Result := '';
99   - v_SectionName := '[' + p_SectionName + ']';
100   - v_Size_Section := strLen(PChar(v_SectionName));
101   - v_KeyName := p_KeyName + '=';
102   - v_Size_Key := strLen(PChar(v_KeyName));
103   - FileText := TStringList.Create;
104   - try
105   - FileText.LoadFromFile(p_IniFileName);
106   - For i := 0 To FileText.Count - 1 Do
107   - Begin
108   - if (LowerCase(Trim(PChar(Copy(FileText[i],1,v_Size_Section)))) = LowerCase(Trim(PChar(v_SectionName)))) then
109   - Begin
110   - For j := i to FileText.Count - 1 Do
111   - Begin
112   - if (LowerCase(Trim(PChar(Copy(FileText[j],1,v_Size_Key)))) = LowerCase(Trim(PChar(v_KeyName)))) then
113   - Begin
114   - Result := PChar(Copy(FileText[j],v_Size_Key + 1,strLen(PChar(FileText[j]))-v_Size_Key));
115   - Break;
116   - End;
117   - End;
118   - End;
119   - if (Result <> '') then break;
120   - End;
121   - finally
122   - FileText.Free;
123   - end;
124   - end;
125   -
126   -
127   -Function Tfrm_col_anvi.Explode(Texto, Separador : String) : TStrings;
128   -var
129   - strItem : String;
130   - ListaAuxUTILS : TStrings;
131   - NumCaracteres, I : Integer;
132   -Begin
133   - ListaAuxUTILS := TStringList.Create;
134   - strItem := '';
135   - NumCaracteres := Length(Texto);
136   - For I := 0 To NumCaracteres Do
137   - If (Texto[I] = Separador) or (I = NumCaracteres) Then
138   - Begin
139   - If (I = NumCaracteres) then strItem := strItem + Texto[I];
140   - ListaAuxUTILS.Add(Trim(strItem));
141   - strItem := '';
142   - end
143   - Else strItem := strItem + Texto[I];
144   - Explode := ListaAuxUTILS;
145   -end;
146   -
147   -function Tfrm_col_anvi.GetRootKey(strRootKey: String): HKEY;
148   -begin
149   - /// Encontrar uma maneira mais elegante de fazer esses testes.
150   - if Trim(strRootKey) = 'HKEY_LOCAL_MACHINE' Then Result := HKEY_LOCAL_MACHINE
151   - else if Trim(strRootKey) = 'HKEY_CLASSES_ROOT' Then Result := HKEY_CLASSES_ROOT
152   - else if Trim(strRootKey) = 'HKEY_CURRENT_USER' Then Result := HKEY_CURRENT_USER
153   - else if Trim(strRootKey) = 'HKEY_USERS' Then Result := HKEY_USERS
154   - else if Trim(strRootKey) = 'HKEY_CURRENT_CONFIG' Then Result := HKEY_CURRENT_CONFIG
155   - else if Trim(strRootKey) = 'HKEY_DYN_DATA' Then Result := HKEY_DYN_DATA;
156   -end;
157   -
158   -Function Tfrm_col_anvi.RemoveCaracteresEspeciais(Texto : String) : String;
159   -var I : Integer;
160   - strAux : String;
161   -Begin
162   - For I := 0 To Length(Texto) Do
163   - if ord(Texto[I]) in [32..126] Then
164   - strAux := strAux + Texto[I]
165   - else strAux := strAux + ' '; // Coloca um espaço onde houver caracteres especiais
166   - Result := strAux;
167   -end;
168   -
169   -function Tfrm_col_anvi.GetValorChaveRegEdit(Chave: String): Variant;
170   -var RegEditGet: TRegistry;
171   - RegDataType: TRegDataType;
172   - strRootKey, strKey, strValue, s: String;
173   - ListaAuxGet : TStrings;
174   - DataSize, Len, I : Integer;
175   -begin
176   - try
177   - Result := '';
178   - ListaAuxGet := frm_col_anvi.Explode(Chave, '\');
179   -
180   - strRootKey := ListaAuxGet[0];
181   - For I := 1 To ListaAuxGet.Count - 2 Do strKey := strKey + ListaAuxGet[I] + '\';
182   - strValue := ListaAuxGet[ListaAuxGet.Count - 1];
183   - if (strValue = '(Padrão)') then strValue := ''; //Para os casos de se querer buscar o valor default (Padrão)
184   - RegEditGet := TRegistry.Create;
185   -
186   - RegEditGet.Access := KEY_READ;
187   - RegEditGet.Rootkey := GetRootKey(strRootKey);
188   - if RegEditGet.OpenKeyReadOnly(strKey) then //teste
189   - Begin
190   - RegDataType := RegEditGet.GetDataType(strValue);
191   - if (RegDataType = rdString) or (RegDataType = rdExpandString) then Result := RegEditGet.ReadString(strValue)
192   - else if RegDataType = rdInteger then Result := RegEditGet.ReadInteger(strValue)
193   - else if (RegDataType = rdBinary) or (RegDataType = rdUnknown)
194   - then
195   - begin
196   - DataSize := RegEditGet.GetDataSize(strValue);
197   - if DataSize = -1 then exit;
198   - SetLength(s, DataSize);
199   - Len := RegEditGet.ReadBinaryData(strValue, PChar(s)^, DataSize);
200   - if Len <> DataSize then exit;
201   - Result := frm_col_anvi.RemoveCaracteresEspeciais(s);
202   - end
203   - end;
204   - finally
205   - RegEditGet.CloseKey;
206   - RegEditGet.Free;
207   - ListaAuxGet.Free;
208   -
209   - end;
210   -end;
211   -
212   -
213   -// Simples rotinas de Criptografação e Descriptografação
214   -// Baixadas de http://www.costaweb.com.br/forum/delphi/474.shtml
215   -Function Tfrm_col_anvi.Crip(PNome: String): String;
216   -Var
217   - TamI, TamF: Integer;
218   - SenA, SenM, SenD: String;
219   -Begin
220   - SenA := Trim(PNome);
221   - TamF := Length(SenA);
222   - if (TamF > 1) then
223   - begin
224   - SenM := '';
225   - SenD := '';
226   - For TamI := TamF Downto 1 do
227   - Begin
228   - SenM := SenM + Copy(SenA,TamI,1);
229   - End;
230   - SenD := Chr(TamF+95)+Copy(SenM,1,1)+Copy(SenA,1,1)+Copy(SenM,2,TamF-2)+Chr(75+TamF);
231   - end
232   - else SenD := SenA;
233   - Result := SenD;
234   -End;
235   -
236   -Function Tfrm_col_anvi.DesCrip(PNome: String): String;
237   -Var
238   - TamI, TamF: Integer;
239   - SenA, SenM, SenD: String;
240   -Begin
241   - SenA := Trim(PNome);
242   - TamF := Length(SenA) - 2;
243   - if (TamF > 1) then
244   - begin
245   - SenM := '';
246   - SenD := '';
247   - SenA := Copy(SenA,2,TamF);
248   - SenM := Copy(SenA,1,1)+Copy(SenA,3,TamF)+Copy(SenA,2,1);
249   - For TamI := TamF Downto 1 do
250   - Begin
251   - SenD := SenD + Copy(SenM,TamI,1);
252   - End;
253   - end
254   - else SenD := SenA;
255   - Result := SenD;
256   -End;
257   -
258   -procedure Tfrm_col_anvi.Log_Historico(strMsg : String);
259   -var
260   - HistoricoLog : TextFile;
261   - strDataArqLocal, strDataAtual : string;
262   -begin
263   - try
264   - FileSetAttr (p_path_cacic + 'cacic2.log',0); // Retira os atributos do arquivo para evitar o erro FILE ACCESS DENIED em máquinas 2000
265   - AssignFile(HistoricoLog,p_path_cacic + 'cacic2.log'); {Associa o arquivo a uma variável do tipo TextFile}
266   - {$IOChecks off}
267   - Reset(HistoricoLog); {Abre o arquivo texto}
268   - {$IOChecks on}
269   - if (IOResult <> 0) then // Arquivo não existe, será recriado.
270   - begin
271   - Rewrite (HistoricoLog);
272   - Append(HistoricoLog);
273   - Writeln(HistoricoLog,FormatDateTime('dd/mm hh:nn:ss : ', Now) + '======================> Iniciando o Log do CACIC <=======================');
274   - end;
275   - DateTimeToString(strDataArqLocal, 'yyyymmdd', FileDateToDateTime(Fileage(p_path_cacic + 'cacic2.log')));
276   - DateTimeToString(strDataAtual , 'yyyymmdd', Date);
277   - if (strDataAtual <> strDataArqLocal) then // Se o arquivo INI não é da data atual...
278   - begin
279   - Rewrite (HistoricoLog); //Cria/Recria o arquivo
280   - Append(HistoricoLog);
281   - Writeln(HistoricoLog,FormatDateTime('dd/mm hh:nn:ss : ', Now) + '======================> Iniciando o Log do CACIC <=======================');
282   - end;
283   - Append(HistoricoLog);
284   - Writeln(HistoricoLog,FormatDateTime('dd/mm hh:nn:ss : ', Now) + strMsg); {Grava a string Texto no arquivo texto}
285   - CloseFile(HistoricoLog); {Fecha o arquivo texto}
286   -// FileSetAttr (ExtractFilePath(Application.Exename) + '\cacic2.log',6); // Muda o atributo para arquivo de SISTEMA e OCULTO
287   -
288   - except
289   - Log_Historico('Erro na gravação do log!');
290   - end;
291   -end;
292   -
293   -{
294   -function Tfrm_col_anvi.getVersionInfo(Arquivo : String) : String;
295   -var
296   - VerInfoSize, VerValueSize, Dummy : DWORD;
297   - VerInfo : Pointer;
298   - VerValue : PVSFixedFileInfo;
299   - V1, // Major Version
300   - V2, // Minor Version
301   - V3, // Release
302   - V4: Word; // Build Number
303   -begin
304   - Try
305   - messagedlg('Passo 1...',mtConfirmation,[mbok],0);
306   - VerInfoSize := GetFileVersionInfoSize(PChar(ParamStr(0)), Dummy);
307   - messagedlg('Passo 2...',mtConfirmation,[mbok],0);
308   - GetMem(VerInfo, VerInfoSize);
309   - messagedlg('Passo 3...',mtConfirmation,[mbok],0);
310   - GetFileVersionInfo(PChar(Arquivo), 0, VerInfoSize, VerInfo);
311   - messagedlg('Passo 4...',mtConfirmation,[mbok],0);
312   - VerQueryValue(VerInfo, '\', Pointer(VerValue), VerValueSize);
313   - messagedlg('Passo 5...',mtConfirmation,[mbok],0);
314   - With VerValue^ do
315   - begin
316   - messagedlg('Passo 6...',mtConfirmation,[mbok],0);
317   - V1 := dwFileVersionMS shr 16;
318   - messagedlg('Passo 7...',mtConfirmation,[mbok],0);
319   - V2 := dwFileVersionMS and $FFFF;
320   - messagedlg('Passo 8...',mtConfirmation,[mbok],0);
321   - V3 := dwFileVersionLS shr 16;
322   - messagedlg('Passo 9...',mtConfirmation,[mbok],0);
323   - V4 := dwFileVersionLS and $FFFF;
324   - messagedlg('Passo 10...',mtConfirmation,[mbok],0);
325   - end;
326   - messagedlg('Passo 11...',mtConfirmation,[mbok],0);
327   - FreeMem(VerInfo, VerInfoSize);
328   - messagedlg('Passo 12...',mtConfirmation,[mbok],0);
329   - Result := IntToStr(V1) + '.' + IntToStr(V2) + '.' + IntToStr(V3) + '.' + IntToStr(V4);
330   - messagedlg('Passo 13...',mtConfirmation,[mbok],0);
331   - Except
332   - messagedlg('Passo 14...',mtConfirmation,[mbok],0);
333   - Result := '?.?.?.?';
334   - End;
335   -end;
336   -}
337   -
338   -
339   -function Tfrm_col_anvi.ProgramaRodando(NomePrograma: String): Boolean;
340   -var
341   - IsRunning, ContinueTest: Boolean;
342   - FSnapshotHandle: THandle;
343   - FProcessEntry32: TProcessEntry32;
344   -begin
345   - IsRunning := False;
346   - FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
347   - FProcessEntry32.dwSize := Sizeof(FProcessEntry32);
348   - ContinueTest := Process32First(FSnapshotHandle, FProcessEntry32);
349   - while ContinueTest do
350   - begin
351   - IsRunning := UpperCase(ExtractFileName(FProcessEntry32.szExeFile)) = UpperCase(NomePrograma);
352   - if IsRunning then ContinueTest := False
353   - else ContinueTest := Process32Next(FSnapshotHandle, FProcessEntry32);
354   - end;
355   - CloseHandle(FSnapshotHandle);
356   - Result := IsRunning;
357   -end;
358   -
359   -
360   -procedure Tfrm_col_anvi.Executa_Col_Anvi;
361   -var Lista1_RCO : TStringList;
362   - Lista2_RCO : TStrings;
363   - nu_versao_engine, dt_hr_instalacao, nu_versao_pattern, ChaveRegistro, te_servidor, in_ativo,
364   - NomeExecutavel, ValorChaveColetado, ValorChaveRegistro, strAux, strDirTrend : String;
365   - searchResult : TSearchRec; // Necessário apenas para Win9x
366   -begin
367   - Try
368   - nu_versao_engine := '';
369   - nu_versao_pattern := '';
370   - Log_Historico('* Coletando informações de Antivírus OfficeScan.');
371   - If Win32Platform = VER_PLATFORM_WIN32_WINDOWS Then { Windows 9x/ME }
372   - Begin
373   - ChaveRegistro := 'HKEY_LOCAL_MACHINE\Software\TrendMicro\OfficeScanCorp\CurrentVersion';
374   - NomeExecutavel := 'pccwin97.exe';
375   - dt_hr_instalacao := frm_col_anvi.GetValorChaveRegEdit(ChaveRegistro + '\Install Date') + frm_col_anvi.GetValorChaveRegEdit(ChaveRegistro + '\Install Time');
376   - strDirTrend := frm_col_anvi.GetValorChaveRegEdit(ChaveRegistro + '\Application Path');
377   - If FileExists(strDirTrend + '\filter32.vxd') Then
378   - Begin
379   - // 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.
380   - 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.
381   - nu_versao_engine := Lista2_RCO[0] + '.' + Lista2_RCO[1];
382   - Lista2_RCO.Free;
383   - end
384   - Else nu_versao_engine := '0';
385   - // A gambiarra para coletar a versão do pattern é obter a maior extensão do arquivo lpt$vpn
386   - if FindFirst(strDirTrend + '\lpt$vpn.*', faAnyFile, searchResult) = 0 then
387   - begin
388   - Lista1_RCO := TStringList.Create;
389   - repeat Lista1_RCO.Add(ExtractFileExt(searchResult.Name));
390   - until FindNext(searchResult) <> 0;
391   - Sysutils.FindClose(searchResult);
392   - Lista1_RCO.Sort; // Ordeno, para, em seguida, obter o último.
393   - strAux := Lista1_RCO[Lista1_RCO.Count - 1];
394   - Lista1_RCO.Free;
395   - nu_versao_pattern := Copy(strAux, 2, Length(strAux)); // Removo o '.' da extensão.
396   - end;
397   - end
398   - Else
399   - Begin // NT a XP
400   - ChaveRegistro := 'HKEY_LOCAL_MACHINE\Software\TrendMicro\PC-cillinNTCorp\CurrentVersion';
401   - NomeExecutavel := 'ntrtscan.exe';
402   - dt_hr_instalacao := frm_col_anvi.GetValorChaveRegEdit(ChaveRegistro + '\InstDate') + frm_col_anvi.GetValorChaveRegEdit(ChaveRegistro + '\InstTime');
403   - nu_versao_engine := frm_col_anvi.GetValorChaveRegEdit(ChaveRegistro + '\Misc.\EngineZipVer');
404   - nu_versao_pattern := frm_col_anvi.GetValorChaveRegEdit(ChaveRegistro + '\Misc.\PatternVer');
405   - nu_versao_pattern := Copy(nu_versao_pattern, 2, Length(nu_versao_pattern)-3);
406   - end;
407   - te_servidor := frm_col_anvi.GetValorChaveRegEdit(ChaveRegistro + '\Server');
408   - If (frm_col_anvi.ProgramaRodando(NomeExecutavel)) Then in_ativo := '1' Else in_ativo := '0';
409   - // Monto a string que será comparada com o valor armazenado no registro.
410   - ValorChaveColetado := Trim(nu_versao_engine + ';' +
411   - nu_versao_pattern + ';' +
412   - te_servidor + ';' +
413   - dt_hr_instalacao + ';' +
414   - in_ativo);
415   - // Obtenho do registro o valor que foi previamente armazenado
416   - ValorChaveRegistro := Trim(GetValorChaveRegIni('Coleta','OfficeScan',p_path_cacic_ini));
417   -
418   - // Se essas informações forem diferentes significa que houve alguma alteração
419   - // na configuração. Nesse caso, gravo as informações no BD Central
420   - // e, se não houver problemas durante esse procedimento, atualizo as
421   - // informações no registro.
422   -
423   - If (GetValorChaveRegIni('Configs','IN_COLETA_FORCADA_ANVI',p_path_cacic_ini)='S') or (ValorChaveColetado <> ValorChaveRegistro) Then
424   - Begin
425   - 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');
426   - 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');
427   - 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');
428   - 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');
429   - 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');
430   - 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');
431   - end
432   - 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');
433   - application.Terminate;
434   - Except
435   - 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');
436   - application.Terminate;
437   - End;
438   -end;
439   -procedure Tfrm_col_anvi.FormCreate(Sender: TObject);
440   -var tstrTripa1 : TStrings;
441   - intAux : integer;
442   -begin
443   - //Pegarei o nível anterior do diretório, que deve ser, por exemplo \Cacic, para leitura do cacic2.ini
444   - tstrTripa1 := explode(ExtractFilePath(Application.Exename),'\');
445   - p_path_cacic := '';
446   - For intAux := 0 to tstrTripa1.Count -2 do
447   - begin
448   - p_path_cacic := p_path_cacic + tstrTripa1[intAux] + '\';
449   - end;
450   - p_path_cacic_ini := p_path_cacic + 'cacic2.ini';
451   - Application.ShowMainForm := false;
452   -
453   - Try
454   - Executa_Col_Anvi;
455   - Except
456   - 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');
457   - application.Terminate;
458   - End;
459   -end;
460   -
461   -end.
col_anvi/utils.pas
... ... @@ -1,153 +0,0 @@
1   -unit utils;
2   -
3   -interface
4   -
5   -Uses Classes, SysUtils, Windows, TLHELP32, dialogs, main;
6   -
7   -Function Explode(Texto, Separador : String) : TStrings;
8   -Function RemoveCaracteresEspeciais(Texto : String) : String;
9   -function ProgramaRodando(NomePrograma: String): Boolean;
10   -function API_GetEnvironmentVariable(EnVar : string) : string;
11   -Function getVersionInfo(Arquivo : String): String;
12   -function LastPos(SubStr, S: string): Integer;
13   -function LetrasDrives : string;
14   -
15   -
16   -implementation
17   -
18   -function LetrasDrives : string;
19   -var i:integer;
20   -strAux : string;
21   - begin
22   - frmmain.MSystemInfo.Disk.GetInfo;
23   - with main.frmMain.MSystemInfo.Disk do
24   - begin
25   - for i:=1 to length(AvailableDisks) do
26   - begin
27   - Drive := UpperCase(Copy(AvailableDisks,i,1)) + ':';
28   - if (UpperCase(GetMediaTypeStr(MediaType)) = 'FIXED') then
29   - Begin
30   - strAux := strAux + UpperCase(Copy(Drive,1,1));
31   - end;
32   - end;
33   - end;
34   - Result := strAux;
35   - end;
36   -
37   -
38   -function LastPos(SubStr, S: string): Integer;
39   -var
40   - Found, Len, Pos: integer;
41   -begin
42   - Pos := Length(S);
43   - Len := Length(SubStr);
44   - Found := 0;
45   - while (Pos > 0) and (Found = 0) do
46   - begin
47   - if Copy(S, Pos, Len) = SubStr then
48   - Found := Pos;
49   - Dec(Pos);
50   - end;
51   - LastPos := Found;
52   -end;
53   -Function Explode(Texto, Separador : String) : TStrings;
54   -var
55   - strItem : String;
56   - ListaAuxUTILS : TStrings;
57   - NumCaracteres, I : Integer;
58   -Begin
59   - ListaAuxUTILS := TStringList.Create;
60   - strItem := '';
61   - NumCaracteres := Length(Texto);
62   - For I := 0 To NumCaracteres Do
63   - If (Texto[I] = Separador) or (I = NumCaracteres) Then
64   - Begin
65   - If (I = NumCaracteres) then strItem := strItem + Texto[I];
66   - ListaAuxUTILS.Add(Trim(strItem));
67   - strItem := '';
68   - end
69   - Else strItem := strItem + Texto[I];
70   - Explode := ListaAuxUTILS;
71   -//Não estava sendo liberado
72   -// ListaAuxUTILS.Free;
73   -//Ao ativar esta liberação tomei uma baita surra!!!! 11/05/2004 - 20:30h - Uma noite muito escura! :) Anderson Peterle
74   -end;
75   -
76   -
77   -Function RemoveCaracteresEspeciais(Texto : String) : String;
78   -var I : Integer;
79   - strAux : String;
80   -Begin
81   - For I := 0 To Length(Texto) Do
82   - if ord(Texto[I]) in [32..126] Then
83   - strAux := strAux + Texto[I]
84   - else strAux := strAux + ' '; // Coloca um espaço onde houver caracteres especiais
85   - Result := strAux;
86   -end;
87   -
88   -
89   -function ProgramaRodando(NomePrograma: String): Boolean;
90   -var
91   - IsRunning, ContinueTest: Boolean;
92   - FSnapshotHandle: THandle;
93   - FProcessEntry32: TProcessEntry32;
94   -begin
95   - IsRunning := False;
96   - FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
97   - FProcessEntry32.dwSize := Sizeof(FProcessEntry32);
98   - ContinueTest := Process32First(FSnapshotHandle, FProcessEntry32);
99   - while ContinueTest do
100   - begin
101   - IsRunning := UpperCase(ExtractFileName(FProcessEntry32.szExeFile)) = UpperCase(NomePrograma);
102   - if IsRunning then ContinueTest := False
103   - else ContinueTest := Process32Next(FSnapshotHandle, FProcessEntry32);
104   - end;
105   - CloseHandle(FSnapshotHandle);
106   - Result := IsRunning;
107   -end;
108   -
109   -function API_GetEnvironmentVariable(EnVar : string) : string;
110   -//
111   -// Retorna informações sobre uma variável do ambiente
112   -//
113   -var
114   -pEnvStrings : pointer;
115   -begin
116   -pEnvStrings := GetEnvironmentStrings;
117   -SetLength(Result, 256);
118   -SetLength(Result, GetEnvironmentVariable(pchar(EnVar), pchar(Result),256));
119   -FreeEnvironmentStrings(pEnvStrings);
120   -end;
121   -
122   -function getVersionInfo(Arquivo : String) : String;
123   -var
124   - VerInfoSize, VerValueSize, Dummy : DWORD;
125   - VerInfo : Pointer;
126   - VerValue : PVSFixedFileInfo;
127   - V1, // Major Version
128   - V2, // Minor Version
129   - V3, // Release
130   - V4: Word; // Build Number
131   -begin
132   - Try
133   - VerInfoSize := GetFileVersionInfoSize(PChar(ParamStr(0)), Dummy);
134   - GetMem(VerInfo, VerInfoSize);
135   - GetFileVersionInfo(PChar(Arquivo), 0, VerInfoSize, VerInfo);
136   - VerQueryValue(VerInfo, '\', Pointer(VerValue), VerValueSize);
137   - With VerValue^ do
138   - begin
139   - V1 := dwFileVersionMS shr 16;
140   - V2 := dwFileVersionMS and $FFFF;
141   - V3 := dwFileVersionLS shr 16;
142   - V4 := dwFileVersionLS and $FFFF;
143   - end;
144   - FreeMem(VerInfo, VerInfoSize);
145   - Result := IntToStr(V1) + '.' + IntToStr(V2) + '.' + IntToStr(V3) + '.' + IntToStr(V4);
146   - Except
147   - Result := '';
148   - End;
149   -end;
150   -
151   -
152   -
153   -end.
col_hard/col_hard.dpr
... ... @@ -936,18 +936,24 @@ begin
936 936 v_te_mem_ram_desc := v_te_mem_ram_desc + ' - ';
937 937 v_te_mem_ram_desc := v_te_mem_ram_desc + 'Slot '+ inttostr(i) + ': '
938 938 + v_SMBIOS.MemoryDevice[i].Manufacturer + ' '
939   - //+ v_SMBIOS.MemoryDevice[i].Device + ' '
940 939 + inttostr(v_SMBIOS.MemoryModule[i].Size) + 'Mb '
941 940 + '(' + v_te_mem_ram_tipo +')';
942 941 end;
943 942 end;
944 943 end;
945 944  
946   - if (trim(v_te_placa_mae_fabricante)='') then
947   - v_te_placa_mae_fabricante := v_SMBIOS.MainBoardManufacturer;
  945 + if (trim(v_te_placa_mae_fabricante)='') then begin
  946 + v_te_placa_mae_fabricante := v_SMBIOS.MainBoardManufacturer;
  947 + if (trim(v_te_placa_mae_fabricante)='') then
  948 + v_te_placa_mae_fabricante := v_SMBIOS.SystemManufacturer;
  949 + end;
  950 +
  951 + if (trim(v_te_placa_mae_desc)='') then begin
  952 + v_te_placa_mae_desc := v_SMBIOS.MainBoardModel;
  953 + if (trim(v_te_placa_mae_desc)='') then
  954 + v_te_placa_mae_desc := v_SMBIOS.SystemModel;
  955 + end;
948 956  
949   - if (trim(v_te_placa_mae_desc)='') then
950   - v_te_placa_mae_desc := v_SMBIOS.MainBoardModel;
951 957  
952 958 v_te_bios_data := v_SMBIOS.BIOSDate;
953 959 v_te_bios_fabricante := v_SMBIOS.BIOSVendor;
... ...
col_patr/main_col_patr.pas
... ... @@ -35,7 +35,8 @@ uses IniFiles,
35 35 DCPrijndael,
36 36 DCPbase64,
37 37 ExtCtrls,
38   - Math;
  38 + Math,
  39 + CACIC_Library;
39 40  
40 41 var p_path_cacic : String;
41 42 v_Dados_Patrimonio : TStrings;
... ... @@ -51,6 +52,9 @@ var p_path_cacic : String;
51 52 var v_tstrCipherOpened,
52 53 v_tstrCipherOpened1 : TStrings;
53 54  
  55 +var
  56 + g_oCacic : TCACIC;
  57 +
54 58 // Some constants that are dependant on the cipher being used
55 59 // Assuming MCRYPT_RIJNDAEL_128 (i.e., 128bit blocksize, 256bit keysize)
56 60 const KeySize = 32; // 32 bytes = 256 bits
... ... @@ -93,7 +97,6 @@ type
93 97 function HomeDrive : string;
94 98 Function Implode(p_Array : TStrings ; p_Separador : String) : String;
95 99 Function CipherClose(p_DatFileName : string; p_tstrCipherOpened : TStrings) : String;
96   - function GetWinVer: Integer;
97 100 Function Explode(Texto, Separador : String) : TStrings;
98 101 Function CipherOpen(p_DatFileName : string) : TStrings;
99 102 Function GetValorDatMemoria(p_Chave : String; p_tstrCipherOpened : TStrings) : String;
... ... @@ -344,64 +347,7 @@ begin
344 347 except
345 348 end;
346 349 end;
347   -function TFormPatrimonio.GetWinVer: Integer;
348   -const
349   - { operating system (OS)constants }
350   - cOsUnknown = 0;
351   - cOsWin95 = 1;
352   - cOsWin95OSR2 = 2; // Não implementado.
353   - cOsWin98 = 3;
354   - cOsWin98SE = 4;
355   - cOsWinME = 5;
356   - cOsWinNT = 6;
357   - cOsWin2000 = 7;
358   - cOsXP = 8;
359   -var
360   - osVerInfo: TOSVersionInfo;
361   - majorVer, minorVer: Integer;
362   -begin
363   - Result := cOsUnknown;
364   - { set operating system type flag }
365   - osVerInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);
366   - if GetVersionEx(osVerInfo) then
367   - begin
368   - majorVer := osVerInfo.dwMajorVersion;
369   - minorVer := osVerInfo.dwMinorVersion;
370   - case osVerInfo.dwPlatformId of
371   - VER_PLATFORM_WIN32_NT: { Windows NT/2000 }
372   - begin
373   - if majorVer <= 4 then
374   - Result := cOsWinNT
375   - else if (majorVer = 5) and (minorVer = 0) then
376   - Result := cOsWin2000
377   - else if (majorVer = 5) and (minorVer = 1) then
378   - Result := cOsXP
379   - else
380   - Result := cOsUnknown;
381   - end;
382   - VER_PLATFORM_WIN32_WINDOWS: { Windows 9x/ME }
383   - begin
384   - if (majorVer = 4) and (minorVer = 0) then
385   - Result := cOsWin95
386   - else if (majorVer = 4) and (minorVer = 10) then
387   - begin
388   - if osVerInfo.szCSDVersion[1] = 'A' then
389   - Result := cOsWin98SE
390   - else
391   - Result := cOsWin98;
392   - end
393   - else if (majorVer = 4) and (minorVer = 90) then
394   - Result := cOsWinME
395   - else
396   - Result := cOsUnknown;
397   - end;
398   - else
399   - Result := cOsUnknown;
400   - end;
401   - end
402   - else
403   - Result := cOsUnknown;
404   -end;
  350 +
405 351 Function TFormPatrimonio.Explode(Texto, Separador : String) : TStrings;
406 352 var
407 353 strItem : String;
... ... @@ -466,7 +412,7 @@ begin
466 412 if (trim(v_strCipherOpened)<>'') then
467 413 Result := explode(v_strCipherOpened,'=CacicIsFree=')
468 414 else
469   - Result := explode('Configs.ID_SO=CacicIsFree='+inttostr(GetWinVer)+'=CacicIsFree=Configs.Endereco_WS=CacicIsFree=/cacic2/ws/','=CacicIsFree=');
  415 + Result := explode('Configs.ID_SO=CacicIsFree='+ g_oCacic.getWindowsStrId() +'=CacicIsFree=Configs.Endereco_WS=CacicIsFree=/cacic2/ws/','=CacicIsFree=');
470 416  
471 417 if Result.Count mod 2 = 0 then
472 418 Result.Add('');
... ... @@ -1128,6 +1074,7 @@ var boolColeta : boolean;
1128 1074 i,intAux : integer;
1129 1075 v_Aux : String;
1130 1076 Begin
  1077 + g_oCacic := TCACIC.Create();
1131 1078  
1132 1079 if (ParamCount>0) then
1133 1080 Begin
... ... @@ -1216,6 +1163,7 @@ Begin
1216 1163 SetValorDatMemoria('Col_Patr.nada','nada', v_tstrCipherOpened1);
1217 1164 SetValorDatMemoria('Col_Patr.Fim', '99999999', v_tstrCipherOpened1);
1218 1165 CipherClose(p_path_cacic + 'temp\col_patr.dat', v_tstrCipherOpened1);
  1166 + g_oCacic.Free();
1219 1167 Application.Terminate;
1220 1168 End;
1221 1169 End;
... ...
ger_cols/ger_cols.dpr
... ... @@ -1748,6 +1748,69 @@ begin
1748 1748 if ChecaAgente(p_path_cacic + 'modulos', 'ini_cols.exe') then
1749 1749 g_oCacic.createSampleProcess( p_path_cacic + 'modulos\ini_cols.exe /p_CipherKey=' + v_CipherKey +
1750 1750 ' /p_ModulosOpcoes=col_patr,wait,user#', CACIC_PROCESS_WAIT );
  1751 +
  1752 + if (FileExists(p_path_cacic + 'Temp\col_patr.dat')) then
  1753 + Begin
  1754 + log_DEBUG('Indicador '+p_path_cacic + 'Temp\col_patr.dat encontrado.');
  1755 + v_acao_gercols := '* Preparando envio de informações de Patrimônio.';
  1756 + v_tstrCipherOpened1 := CipherOpen(p_path_cacic + 'Temp\col_patr.dat');
  1757 +
  1758 + // Armazeno dados para informações de coletas na data, via menu popup do Systray
  1759 + SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+'#Informações Patrimoniais', v_tstrCipherOpened);
  1760 +
  1761 + // Armazeno as horas de início e fim das coletas
  1762 + SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+','+GetValorDatMemoria('Col_Patr.Inicio',v_tstrCipherOpened1), v_tstrCipherOpened);
  1763 + SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+','+GetValorDatMemoria('Col_Patr.Fim',v_tstrCipherOpened1), v_tstrCipherOpened);
  1764 +
  1765 + if (GetValorDatMemoria('Col_Patr.nada',v_tstrCipherOpened1)='') then
  1766 + Begin
  1767 + // Preparação para envio...
  1768 + Request_Ger_Cols.Values['id_unid_organizacional_nivel1'] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Patr.id_unid_organizacional_nivel1' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
  1769 + Request_Ger_Cols.Values['id_unid_organizacional_nivel1a'] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Patr.id_unid_organizacional_nivel1a' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
  1770 + Request_Ger_Cols.Values['id_unid_organizacional_nivel2'] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Patr.id_unid_organizacional_nivel2' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
  1771 + Request_Ger_Cols.Values['te_localizacao_complementar' ] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Patr.te_localizacao_complementar' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
  1772 + Request_Ger_Cols.Values['te_info_patrimonio1' ] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Patr.te_info_patrimonio1' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
  1773 + Request_Ger_Cols.Values['te_info_patrimonio2' ] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Patr.te_info_patrimonio2' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
  1774 + Request_Ger_Cols.Values['te_info_patrimonio3' ] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Patr.te_info_patrimonio3' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
  1775 + Request_Ger_Cols.Values['te_info_patrimonio4' ] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Patr.te_info_patrimonio4' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
  1776 + Request_Ger_Cols.Values['te_info_patrimonio5' ] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Patr.te_info_patrimonio5' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
  1777 + Request_Ger_Cols.Values['te_info_patrimonio6' ] := StringReplace(EnCrypt(GetValorDatMemoria('Col_Patr.te_info_patrimonio6' ,v_tstrCipherOpened1),l_cs_compress),'+','<MAIS>',[rfReplaceAll]);
  1778 +
  1779 + if v_Debugs then
  1780 + For intLoop := 0 to Request_Ger_Cols.Count-1 do
  1781 + log_DEBUG('Item "'+Request_Ger_Cols.Names[intLoop]+'" de Col_Patr: '+Request_Ger_Cols.ValueFromIndex[intLoop]);
  1782 +
  1783 + if (ComunicaServidor('set_patrimonio.php', Request_Ger_Cols, '>> Enviando informações de Patrimônio para o Gerente WEB.') <> '0') Then
  1784 + Begin
  1785 + // Armazeno o Status Positivo de Envio
  1786 + SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+',1', v_tstrCipherOpened);
  1787 +
  1788 + // Somente atualizo o registro caso não tenha havido nenhum erro durante o envio das informações para o BD
  1789 + //Sobreponho a informação no registro para posterior comparação, na próxima execução.
  1790 + SetValorDatMemoria('Patrimonio.id_unid_organizacional_nivel1' , GetValorDatMemoria('Col_Patr.id_unid_organizacional_nivel1',v_tstrCipherOpened1), v_tstrCipherOpened);
  1791 + SetValorDatMemoria('Patrimonio.id_unid_organizacional_nivel1a', GetValorDatMemoria('Col_Patr.id_unid_organizacional_nivel1a',v_tstrCipherOpened1), v_tstrCipherOpened);
  1792 + SetValorDatMemoria('Patrimonio.id_unid_organizacional_nivel2' , GetValorDatMemoria('Col_Patr.id_unid_organizacional_nivel2',v_tstrCipherOpened1), v_tstrCipherOpened);
  1793 + SetValorDatMemoria('Patrimonio.te_localizacao_complementar' , GetValorDatMemoria('Col_Patr.te_localizacao_complementar' ,v_tstrCipherOpened1), v_tstrCipherOpened);
  1794 + SetValorDatMemoria('Patrimonio.te_info_patrimonio1' , GetValorDatMemoria('Col_Patr.te_info_patrimonio1' ,v_tstrCipherOpened1), v_tstrCipherOpened);
  1795 + SetValorDatMemoria('Patrimonio.te_info_patrimonio2' , GetValorDatMemoria('Col_Patr.te_info_patrimonio2' ,v_tstrCipherOpened1), v_tstrCipherOpened);
  1796 + SetValorDatMemoria('Patrimonio.te_info_patrimonio3' , GetValorDatMemoria('Col_Patr.te_info_patrimonio3' ,v_tstrCipherOpened1), v_tstrCipherOpened);
  1797 + SetValorDatMemoria('Patrimonio.te_info_patrimonio4' , GetValorDatMemoria('Col_Patr.te_info_patrimonio4' ,v_tstrCipherOpened1), v_tstrCipherOpened);
  1798 + SetValorDatMemoria('Patrimonio.te_info_patrimonio5' , GetValorDatMemoria('Col_Patr.te_info_patrimonio5' ,v_tstrCipherOpened1), v_tstrCipherOpened);
  1799 + SetValorDatMemoria('Patrimonio.te_info_patrimonio6' , GetValorDatMemoria('Col_Patr.te_info_patrimonio6' ,v_tstrCipherOpened1), v_tstrCipherOpened);
  1800 + SetValorDatMemoria('Patrimonio.ultima_rede_obtida' , GetValorDatMemoria('TcpIp.ID_IP_REDE' ,v_tstrCipherOpened) , v_tstrCipherOpened);
  1801 + intAux := 1;
  1802 + End
  1803 + else
  1804 + // Armazeno o Status Negativo de Envio
  1805 + SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+',-1', v_tstrCipherOpened);
  1806 + End
  1807 + else
  1808 + // Armazeno o Status Nulo de Envio
  1809 + SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+',0', v_tstrCipherOpened);
  1810 +
  1811 + Request_Ger_Cols.Clear;
  1812 + Matar(p_path_cacic+'Temp\','col_patr.dat');
  1813 + End;
1751 1814 end;
1752 1815  
1753 1816 procedure ChecaCipher;
... ...
ini_cols/ini_cols.dpr
... ... @@ -181,66 +181,6 @@ Begin
181 181 Explode := ListaAuxUTILS;
182 182 end;
183 183  
184   -
185   -function GetWinVer: Integer;
186   -const
187   - { operating system (OS)constants }
188   - cOsUnknown = 0;
189   - cOsWin95 = 1;
190   - cOsWin95OSR2 = 2; // Não implementado.
191   - cOsWin98 = 3;
192   - cOsWin98SE = 4;
193   - cOsWinME = 5;
194   - cOsWinNT = 6;
195   - cOsWin2000 = 7;
196   - cOsXP = 8;
197   -var
198   - osVerInfo: TOSVersionInfo;
199   - majorVer, minorVer: Integer;
200   -begin
201   - Result := cOsUnknown;
202   - { set operating system type flag }
203   - osVerInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);
204   - if GetVersionEx(osVerInfo) then
205   - begin
206   - majorVer := osVerInfo.dwMajorVersion;
207   - minorVer := osVerInfo.dwMinorVersion;
208   - case osVerInfo.dwPlatformId of
209   - VER_PLATFORM_WIN32_NT: { Windows NT/2000 }
210   - begin
211   - if majorVer <= 4 then
212   - Result := cOsWinNT
213   - else if (majorVer = 5) and (minorVer = 0) then
214   - Result := cOsWin2000
215   - else if (majorVer = 5) and (minorVer = 1) then
216   - Result := cOsXP
217   - else
218   - Result := cOsUnknown;
219   - end;
220   - VER_PLATFORM_WIN32_WINDOWS: { Windows 9x/ME }
221   - begin
222   - if (majorVer = 4) and (minorVer = 0) then
223   - Result := cOsWin95
224   - else if (majorVer = 4) and (minorVer = 10) then
225   - begin
226   - if osVerInfo.szCSDVersion[1] = 'A' then
227   - Result := cOsWin98SE
228   - else
229   - Result := cOsWin98;
230   - end
231   - else if (majorVer = 4) and (minorVer = 90) then
232   - Result := cOsWinME
233   - else
234   - Result := cOsUnknown;
235   - end;
236   - else
237   - Result := cOsUnknown;
238   - end;
239   - end
240   - else
241   - Result := cOsUnknown;
242   -end;
243   -
244 184 Function GetValorDatMemoria(p_Chave : String) : String;
245 185 begin
246 186 if (v_tstrCipherOpened.IndexOf(p_Chave)<>-1) then
... ... @@ -337,8 +277,9 @@ Function CipherOpen(p_DatFileName : string) : TStrings;
337 277 var v_DatFile : TextFile;
338 278 v_strCipherOpened,
339 279 v_strCipherClosed : string;
340   -// intLoop : integer;
  280 + oCacic : TCACIC;
341 281 begin
  282 + oCacic := TCACIC.Create();
342 283 v_strCipherOpened := '';
343 284 if FileExists(p_DatFileName) then
344 285 begin
... ... @@ -358,10 +299,11 @@ begin
358 299 v_strCipherOpened:= DeCrypt(v_strCipherClosed);
359 300 log_DEBUG('Rotina de Abertura do cacic2.dat RESTAURANDO estado da criptografia.');
360 301 end;
  302 +
361 303 if (trim(v_strCipherOpened)<>'') then
362 304 Result := explode(v_strCipherOpened,v_SeparatorKey)
363 305 else
364   - Result := explode('Configs.ID_SO'+v_SeparatorKey+inttostr(GetWinVer)+v_SeparatorKey+'Configs.Endereco_WS'+v_SeparatorKey+'/cacic2/ws/',v_SeparatorKey);
  306 + Result := explode('Configs.ID_SO'+v_SeparatorKey+ oCacic.getWindowsStrId() +v_SeparatorKey+'Configs.Endereco_WS'+v_SeparatorKey+'/cacic2/ws/',v_SeparatorKey);
365 307  
366 308  
367 309 if Result.Count mod 2 <> 0 then
... ... @@ -369,14 +311,8 @@ begin
369 311 log_DEBUG('Vetor MemoryDAT com tamanho IMPAR... Ajustando.');
370 312 Result.Add('');
371 313 End;
372   -
373   - {
374   - log_DEBUG(v_DatFileName+' aberto com sucesso!');
375   - if v_Debugs then
376   - for intLoop := 0 to (Result.Count-1) do
377   - log_DEBUG('Posição ['+inttostr(intLoop)+'] do MemoryDAT: '+Result[intLoop]);
378   - }
379   -
  314 +
  315 + oCacic.Free();
380 316 end;
381 317  
382 318 Function FTP(p_Host : String; p_Port : String; p_Username : String; p_Password : String; p_PathServer : String; p_File : String; p_Dest : String) : Boolean;
... ...
main.pas
... ... @@ -63,6 +63,9 @@ var p_path_cacic,
63 63 boolCrypt,
64 64 boolDebugs : Boolean;
65 65  
  66 +var
  67 + g_oCacic: TCACIC;
  68 +
66 69 type
67 70 TFormularioGeral = class(TForm)
68 71 Pn_InfosGerais: TPanel;
... ... @@ -179,7 +182,6 @@ type
179 182 Procedure DelValorReg(Chave: String);
180 183  
181 184 function GetRootKey(strRootKey: String): HKEY;
182   - function GetWinVer: Integer;
183 185 function FindWindowByTitle(WindowTitle: string): Hwnd;
184 186 function GetValorChaveRegIni(p_SectionName, p_KeyName, p_IniFileName : String) : String;
185 187 Function RemoveZerosFimString(Texto : String) : String;
... ... @@ -187,7 +189,6 @@ type
187 189 procedure Bt_Fechar_InfosGeraisClick(Sender: TObject);
188 190 function Get_File_Size(sFileToExamine: string; bInKBytes: Boolean): string;
189 191 function Posso_Rodar : boolean;
190   - function abstraiCSD(p_te_so : String) : integer;
191 192 {
192 193 procedure IdHTTPServerCACICCommandGet(AThread: TIdPeerThread;
193 194 ARequestInfo: TIdHTTPRequestInfo;
... ... @@ -792,7 +793,7 @@ begin
792 793 v_tstrCipherOpened := explode(v_strCipherOpened,v_SeparatorKey)
793 794 else
794 795 Begin
795   - v_tstrCipherOpened := explode('Configs.ID_SO'+v_SeparatorKey+inttostr(GetWinVer)+v_SeparatorKey+
  796 + v_tstrCipherOpened := explode('Configs.ID_SO'+v_SeparatorKey+ g_oCacic.getWindowsStrId() +v_SeparatorKey+
796 797 'Configs.Endereco_WS'+v_SeparatorKey+'/cacic2/ws/',v_SeparatorKey);
797 798 log_DEBUG(v_DatFileName+' Inexistente. Criado o DAT em memória.');
798 799 End;
... ... @@ -1141,85 +1142,6 @@ var
1141 1142 log_DEBUG('Resgatei '+p_SectionName+'/'+p_KeyName+' de '+p_IniFileName+' => "'+Result+'"');
1142 1143 end;
1143 1144  
1144   -
1145   -function TFormularioGeral.GetWinVer: Integer;
1146   -const
1147   - { operating system (OS)constants }
1148   - cOsUnknown = 0;
1149   - cOsWin95 = 1;
1150   - cOsWin95OSR2 = 2; // Não implementado.
1151   - cOsWin98 = 3;
1152   - cOsWin98SE = 4;
1153   - cOsWinME = 5;
1154   - cOsWinNT = 6;
1155   - cOsWin2000 = 7;
1156   - cOsXP = 8;
1157   -var
1158   - osVerInfo: TOSVersionInfo;
1159   - platformID,
1160   - majorVer,
1161   - minorVer : Integer;
1162   - CSDVersion : String;
1163   -begin
1164   - Result := cOsUnknown;
1165   - { set operating system type flag }
1166   - osVerInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);
1167   - if GetVersionEx(osVerInfo) then
1168   - begin
1169   - platformId := osVerInfo.dwPlatformId;
1170   - majorVer := osVerInfo.dwMajorVersion;
1171   - minorVer := osVerInfo.dwMinorVersion;
1172   - CSDVersion := trim(osVerInfo.szCSDVersion);
1173   - case osVerInfo.dwPlatformId of
1174   - VER_PLATFORM_WIN32_NT: { Windows NT/2000 }
1175   - begin
1176   - if majorVer <= 4 then
1177   - Result := cOsWinNT
1178   - else if (majorVer = 5) and (minorVer = 0) then
1179   - Result := cOsWin2000
1180   - else if (majorVer = 5) and (minorVer = 1) then
1181   - Result := cOsXP
1182   - else
1183   - Result := cOsUnknown;
1184   - end;
1185   - VER_PLATFORM_WIN32_WINDOWS: { Windows 9x/ME }
1186   - begin
1187   - if (majorVer = 4) and (minorVer = 0) then
1188   - Result := cOsWin95
1189   - else if (majorVer = 4) and (minorVer = 10) then
1190   - begin
1191   - if osVerInfo.szCSDVersion[1] = 'A' then
1192   - Result := cOsWin98SE
1193   - else
1194   - Result := cOsWin98;
1195   - end
1196   - else if (majorVer = 4) and (minorVer = 90) then
1197   - Result := cOsWinME
1198   - else
1199   - Result := cOsUnknown;
1200   - end;
1201   - else
1202   - Result := cOsUnknown;
1203   - end;
1204   - end
1205   - else
1206   - Result := cOsUnknown;
1207   - // A partir da versão 2.2.0.24, defino o valor da ID Interna e atribuo-a sem o CSDVersion à versão externa
1208   - v_te_so := IntToStr(platformId) + '.' +
1209   - IntToStr(majorVer) + '.' +
1210   - IntToStr(minorVer) +
1211   - IfThen(CSDVersion='','','.'+CSDVersion);
1212   - if (Result = 0) then
1213   - Result := abstraiCSD(v_te_so);
1214   -
1215   -end;
1216   -function TFormularioGeral.abstraiCSD(p_te_so : String) : integer;
1217   - var tstrTe_so : tstrings;
1218   - Begin
1219   - tstrTe_so := Explode(p_te_so, '.');
1220   - Result := StrToInt(tstrTe_so[0] + tstrTe_so[1] + tstrTe_so[2]);
1221   - End;
1222   -
1223 1145 procedure TFormularioGeral.log_DEBUG(p_msg:string);
1224 1146 Begin
1225 1147 if boolDebugs then log_diario('(v.'+getVersionInfo(ParamStr(0))+') DEBUG - '+p_msg);
... ... @@ -1258,17 +1180,16 @@ var strAux,
1258 1180 intAux : integer;
1259 1181 v_Aguarde : TextFile;
1260 1182 v_SystemDrive : TStrings;
1261   - oCacic : TCACIC;
1262 1183 begin
1263 1184 // Não mostrar o formulário...
1264 1185 Application.ShowMainForm:=false;
1265   - oCacic := TCACIC.Create;
1266   - oCacic.showTrayIcon(false);
  1186 + g_oCacic := TCACIC.Create;
  1187 + g_oCacic.showTrayIcon(false);
1267 1188 boolCrypt := true;
1268 1189  
1269 1190 Try
1270 1191 // De acordo com a versão do OS, determino o ShellCommand para chamadas externas.
1271   - if (oCacic.isWindowsNTPlataform()) then //Se NT/2K/XP... then
  1192 + if (g_oCacic.isWindowsNTPlataform()) then //Se NT/2K/XP... then
1272 1193 Begin
1273 1194 p_Shell_Path := HomeDrive + '\system32\'; //NT/2K/XP
1274 1195 p_Shell_Command := 'cmd.exe'; //NT/2K/XP
... ... @@ -1420,23 +1341,12 @@ begin
1420 1341 Begin
1421 1342 log_DEBUG('Agente finalizado devido a concomitância de sessões...');
1422 1343  
1423   - // Libera memoria referente ao objeto oCacic
1424   - try
1425   - oCacic.Free;
1426   - except
1427   - end;
1428   -
1429 1344 Finaliza;
1430 1345 End;
1431 1346 Except
1432 1347 log_diario('PROBLEMAS NA INICIALIZAÇÃO (2)');
1433 1348 End;
1434 1349  
1435   - // Libera memoria referente ao objeto oCacic
1436   - try
1437   - oCacic.Free;
1438   - except
1439   - end;
1440 1350 end;
1441 1351  
1442 1352 procedure TFormularioGeral.SetaVariaveisGlobais;
... ... @@ -1533,8 +1443,8 @@ Begin
1533 1443 Except
1534 1444 log_diario('PROBLEMAS NA FINALIZAÇÃO');
1535 1445 End;
  1446 + g_oCacic.Free();
1536 1447 FreeMemory(0);
1537   - Halt(0);
1538 1448 Application.Terminate;
1539 1449 End;
1540 1450  
... ... @@ -1601,7 +1511,7 @@ var intAux,
1601 1511 v_Repete : boolean;
1602 1512 begin
1603 1513  
1604   - log_DEBUG('Execução - Resgate de possíveis novos valores no DAT.');
  1514 + log_DEBUG('Execução - Resgate de possíveis novos valores no DAT.' + g_oCacic.getWindowsStrId());
1605 1515  
1606 1516 CipherOpen;
1607 1517  
... ...