Commit 77874aea5389a577d635e56ead26abf521b1f86d
1 parent
33a1a634
Exists in
master
Exclusão para posterior reposição com versão 2.6-Beta-2
git-svn-id: http://svn.softwarepublico.gov.br/svn/cacic/cacic/trunk/agente-windows@974 fecfc0c7-e812-0410-ae72-849f08638ee7
Showing
11 changed files
with
0 additions
and
1269 deletions
Show diff stats
CACIC_Library.pas
| ... | ... | @@ -1,929 +0,0 @@ |
| 1 | -{*------------------------------------------------------------------------------ | |
| 2 | - Package of both methods/properties to be used by CACIC Clients | |
| 3 | - | |
| 4 | - @version CACIC_Library 2009-01-07 23:00 harpiain | |
| 5 | - @package CACIC_Agente | |
| 6 | - @subpackage CACIC_Library | |
| 7 | - @author Adriano dos Santos Vieira <harpiain at gmail.com> | |
| 8 | - @copyright Copyright (C) Adriano dos Santos Vieira. All rights reserved. | |
| 9 | - @license GNU/GPL, see LICENSE.php | |
| 10 | - CACIC_Library is free software and parts of it may contain or be derived from | |
| 11 | - the GNU General Public License or other free or open source software license. | |
| 12 | - See COPYRIGHT.php for copyright notices and details. | |
| 13 | - | |
| 14 | - CACIC_Library - Coding style | |
| 15 | - for Constants | |
| 16 | - - characters always in uppercase | |
| 17 | - - use underscore for long name | |
| 18 | - e.g. | |
| 19 | - const CACIC_VERSION = '2.4.0'; | |
| 20 | - | |
| 21 | - for Variables | |
| 22 | - - characters always in lowercase | |
| 23 | - - start with "g" character for global | |
| 24 | - - start with "v" character for local | |
| 25 | - - start with "p" character for methods parameters | |
| 26 | - - start with "P" character for pointers | |
| 27 | - - use underscore for better read | |
| 28 | - e.g. | |
| 29 | - var g_global : string; | |
| 30 | - var v_local : string; | |
| 31 | - | |
| 32 | - for Objects | |
| 33 | - - start with "o" character | |
| 34 | - e.g. | |
| 35 | - oCacicObject : TCACIC_Common; | |
| 36 | - | |
| 37 | - for Methods | |
| 38 | - - start with lowercase word | |
| 39 | - - next words start with capital letter | |
| 40 | - e.g. | |
| 41 | - function getCacicPath() : string; | |
| 42 | - procedure setCacicPath( pPath: string ); | |
| 43 | --------------------------------------------------------------------------------} | |
| 44 | - | |
| 45 | -unit CACIC_Library; | |
| 46 | - | |
| 47 | -interface | |
| 48 | - | |
| 49 | -uses | |
| 50 | - Windows, | |
| 51 | - Classes, | |
| 52 | - SysUtils, | |
| 53 | - StrUtils, | |
| 54 | - MD5, | |
| 55 | - DCPcrypt2, | |
| 56 | - DCPrijndael, | |
| 57 | - DCPbase64, | |
| 58 | - ActiveX, | |
| 59 | - ComObj; | |
| 60 | -type | |
| 61 | - | |
| 62 | -{ ------------------------------------------------------------------------------ | |
| 63 | - Tipo de dados para obter informacoes extendidas dos Sistema Operacional | |
| 64 | - ver MSDN: http://msdn.microsoft.com/en-us/library/ms724833(VS.85).aspx | |
| 65 | --------------------------------------------------------------------------------} | |
| 66 | - TOSVersionInfoEx = packed record | |
| 67 | - dwOSVersionInfoSize: DWORD; | |
| 68 | - dwMajorVersion: DWORD; | |
| 69 | - dwMinorVersion: DWORD; | |
| 70 | - dwBuildNumber: DWORD; | |
| 71 | - dwPlatformId: DWORD; | |
| 72 | - szCSDVersion: array[0..127] of AnsiChar; | |
| 73 | - wServicePackMajor: WORD; | |
| 74 | - wServicePackMinor: WORD; | |
| 75 | - wSuiteMask: WORD; | |
| 76 | - wProductType: Byte; | |
| 77 | - wReserved: Byte; | |
| 78 | - end; | |
| 79 | - | |
| 80 | -{*------------------------------------------------------------------------------ | |
| 81 | - Classe para obter informações do sistema windows | |
| 82 | --------------------------------------------------------------------------------} | |
| 83 | - TCACIC_Windows = class | |
| 84 | - private | |
| 85 | - | |
| 86 | - protected | |
| 87 | - /// Mantem a identificação do sistema operacional | |
| 88 | - g_osVersionInfo: TOSVersionInfo; | |
| 89 | - /// Mantem a identificação extendida do sistema operacional | |
| 90 | - g_osVersionInfoEx: TOSVersionInfoEx; | |
| 91 | - /// TRUE se houver informação extendida do SO, FALSE caso contrário | |
| 92 | - g_osVersionInfoExtended: boolean; | |
| 93 | - | |
| 94 | - public | |
| 95 | - function isWindowsVista() : boolean; | |
| 96 | - function isWindowsGEVista() : boolean; | |
| 97 | - function isWindowsXP() : boolean; | |
| 98 | - function isWindowsGEXP() : boolean; | |
| 99 | - function isWindowsNTPlataform() : boolean; | |
| 100 | - function isWindows2000() : boolean; | |
| 101 | - function isWindowsNT() : boolean; | |
| 102 | - function isWindows9xME() : boolean; | |
| 103 | - function getWindowsStrId() : string; | |
| 104 | - function getWinDir() : string; | |
| 105 | - function getHomeDrive() : string; | |
| 106 | - function isWindowsAdmin() : boolean; | |
| 107 | - function createSampleProcess(p_cmd: string; p_wait: boolean; p_showWindow : word = SW_HIDE): boolean; | |
| 108 | - procedure showTrayIcon(p_visible:boolean); | |
| 109 | - procedure addApplicationToFirewall(p_EntryName:string;p_ApplicationPathAndExe:string; p_Enabled : boolean); | |
| 110 | - end; | |
| 111 | - | |
| 112 | -{*------------------------------------------------------------------------------ | |
| 113 | - Classe para tratamento de debug | |
| 114 | --------------------------------------------------------------------------------} | |
| 115 | - TCACIC_Debug = class | |
| 116 | - private | |
| 117 | - | |
| 118 | - protected | |
| 119 | - /// TRUE se em mode de debug, FALSE caso contrário | |
| 120 | - g_debug: boolean; | |
| 121 | - | |
| 122 | - public | |
| 123 | - procedure debugOn(); | |
| 124 | - procedure debugOff(); | |
| 125 | - function inDebugMode() : boolean; | |
| 126 | - end; | |
| 127 | -{*------------------------------------------------------------------------------ | |
| 128 | - Classe geral da biblioteca | |
| 129 | --------------------------------------------------------------------------------} | |
| 130 | - TCACIC = class(TCACIC_Windows) | |
| 131 | - constructor Create(); | |
| 132 | - destructor Destroy; override; | |
| 133 | - private | |
| 134 | - | |
| 135 | - protected | |
| 136 | - /// Mantem o caminho físico de instalação do agente cacic | |
| 137 | - g_cacic_path: string; | |
| 138 | - g_boolCipher : boolean; | |
| 139 | - | |
| 140 | - public | |
| 141 | - Windows : TCACIC_Windows; /// objeto de informacoes de windows | |
| 142 | - Debug : TCACIC_Debug; /// objeto de tratamento de debug | |
| 143 | - procedure setCacicPath(p_cacic_path: string); | |
| 144 | - procedure setBoolCipher(p_boolCipher : boolean); | |
| 145 | - function deCrypt(p_Data : String) : String; | |
| 146 | - function enCrypt(p_Data : String) : String; | |
| 147 | - function explode(p_String, p_Separador : String) : TStrings; | |
| 148 | - function implode(p_Array : TStrings ; p_Separador : String) : String; | |
| 149 | - function getCacicPath() : String; | |
| 150 | - function getCipherKey() : String; | |
| 151 | - function getBoolCipher() : boolean; | |
| 152 | - function getIV() : String; | |
| 153 | - function getKeySize() : integer; | |
| 154 | - function getBlockSize() : integer; | |
| 155 | - function getDatFileName() : String; | |
| 156 | - function getSeparatorKey() : String; | |
| 157 | - function getFileHash(strFileName : String) : String; | |
| 158 | - function isAppRunning( p_app_name: PAnsiChar ) : boolean; | |
| 159 | - function padWithZeros(const str : string; size : integer) : String; | |
| 160 | - function trimEspacosExcedentes(p_str: string) : String; | |
| 161 | - | |
| 162 | - end; | |
| 163 | - | |
| 164 | -// Declaração de constantes para a biblioteca | |
| 165 | -const | |
| 166 | - CACIC_PROCESS_WAIT = true; // aguardar fim do processo | |
| 167 | - CACIC_PROCESS_NOWAIT = false; // não aguardar o fim do processo | |
| 168 | - | |
| 169 | -// Some constants that are dependant on the cipher being used | |
| 170 | -// Assuming MCRYPT_RIJNDAEL_128 (i.e., 128bit blocksize, 256bit keysize) | |
| 171 | -const | |
| 172 | - CACIC_KEYSIZE = 32; // 32 bytes = 256 bits | |
| 173 | - CACIC_BLOCKSIZE = 16; // 16 bytes = 128 bits | |
| 174 | - | |
| 175 | -// Chave AES. Recomenda-se que cada empresa altere a sua chave. | |
| 176 | -// Esta chave é passada como parâmetro para o Gerente de Coletas que, por sua vez, | |
| 177 | -// passa para o Inicializador de Coletas e este passa para os coletores... | |
| 178 | -const | |
| 179 | - CACIC_CIPHERKEY = 'CacicBrasil'; | |
| 180 | - CACIC_IV = 'abcdefghijklmnop'; | |
| 181 | - CACIC_SEPARATORKEY = '=CacicIsFree='; // Usada apenas para o cacic2.dat | |
| 182 | - | |
| 183 | -// Arquivo local para armazenamento de configurações e informações coletadas | |
| 184 | -const | |
| 185 | - CACIC_DATFILENAME = 'cacic2.dat'; | |
| 186 | - | |
| 187 | - | |
| 188 | -{ | |
| 189 | - Controle de prioridade de processo | |
| 190 | - http://msdn.microsoft.com/en-us/library/ms683211(VS.85).aspx | |
| 191 | -} | |
| 192 | -const BELOW_NORMAL_PRIORITY_CLASS = $00004000; | |
| 193 | - {$EXTERNALSYM BELOW_NORMAL_PRIORITY_CLASS} | |
| 194 | - | |
| 195 | -var | |
| 196 | - P_OSVersionInfo: POSVersionInfo; | |
| 197 | - | |
| 198 | -implementation | |
| 199 | - | |
| 200 | -{*------------------------------------------------------------------------------ | |
| 201 | - Construtor para a classe | |
| 202 | - | |
| 203 | - Objetiva inicializar valores a serem usados pelos objetos da | |
| 204 | - classe. | |
| 205 | --------------------------------------------------------------------------------} | |
| 206 | -constructor TCACIC.Create(); | |
| 207 | -begin | |
| 208 | - FillChar(Self.g_osVersionInfoEx, SizeOf(Self.g_osVersionInfoEx), 0); | |
| 209 | - {$TYPEDADDRESS OFF} | |
| 210 | - P_OSVersionInfo := @Self.g_osVersionInfoEx; | |
| 211 | - {$TYPEDADDRESS ON} | |
| 212 | - | |
| 213 | - Self.g_osVersionInfoEx.dwOSVersionInfoSize:= SizeOf(TOSVersionInfoEx); | |
| 214 | - Self.g_osVersionInfoExtended := GetVersionEx(P_OSVersionInfo^); | |
| 215 | - if (not Self.g_osVersionInfoExtended) then begin | |
| 216 | - Self.g_osVersionInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfo); | |
| 217 | - GetVersionEx(Self.g_osVersionInfo); | |
| 218 | - end; | |
| 219 | - Self.Windows := TCACIC_Windows.Create(); | |
| 220 | - Self.Debug := TCACIC_Debug.Create(); | |
| 221 | -end; | |
| 222 | - | |
| 223 | -{*------------------------------------------------------------------------------ | |
| 224 | - Destrutor para a classe | |
| 225 | - | |
| 226 | - Objetiva finalizar valores usados pelos objetos da classe. | |
| 227 | --------------------------------------------------------------------------------} | |
| 228 | -destructor TCACIC.Destroy(); | |
| 229 | -begin | |
| 230 | - FreeMemory(P_OSVersionInfo); | |
| 231 | - inherited; | |
| 232 | -end; | |
| 233 | - | |
| 234 | -{*------------------------------------------------------------------------------ | |
| 235 | - Retorna a pasta de instalação do MS-Windows | |
| 236 | --------------------------------------------------------------------------------} | |
| 237 | -function TCACIC_Windows.getWinDir : string; | |
| 238 | -var | |
| 239 | - WinPath: array[0..MAX_PATH + 1] of char; | |
| 240 | -begin | |
| 241 | - GetWindowsDirectory(WinPath,MAX_PATH); | |
| 242 | - Result := StrPas(WinPath)+'\'; | |
| 243 | -end; | |
| 244 | - | |
| 245 | -{*------------------------------------------------------------------------------ | |
| 246 | - Retorna a unidade de instalação do MS-Windows | |
| 247 | --------------------------------------------------------------------------------} | |
| 248 | -function TCACIC_Windows.getHomeDrive() : string; | |
| 249 | -begin | |
| 250 | - Result := MidStr(getWinDir,1,3); //x:\ | |
| 251 | -end; | |
| 252 | - | |
| 253 | -{*------------------------------------------------------------------------------ | |
| 254 | - Insere exceção na FireWall nativa do MS-Windows | |
| 255 | - | |
| 256 | - @param p_EntryName String Nome da exceção | |
| 257 | - @param p_ApplicationPathAndExe String Caminho e nome da aplicação | |
| 258 | - @param p_Enabled Boolean Estado da exceção | |
| 259 | --------------------------------------------------------------------------------} | |
| 260 | -procedure TCACIC_Windows.addApplicationToFirewall(p_EntryName:string;p_ApplicationPathAndExe:string; p_Enabled : boolean); | |
| 261 | -var fwMgr,app:OleVariant; | |
| 262 | - profile:OleVariant; | |
| 263 | -Const NET_FW_PROFILE_DOMAIN = 0; | |
| 264 | - NET_FW_PROFILE_STANDARD = 1; | |
| 265 | - NET_FW_IP_VERSION_ANY = 2; | |
| 266 | - NET_FW_IP_PROTOCOL_UDP = 17; | |
| 267 | - NET_FW_IP_PROTOCOL_TCP = 6; | |
| 268 | - NET_FW_SCOPE_ALL = 0; | |
| 269 | - NET_FW_SCOPE_LOCAL_SUBNET = 1; | |
| 270 | -begin | |
| 271 | - CoInitialize(nil); | |
| 272 | - | |
| 273 | - fwMgr := CreateOLEObject('HNetCfg.FwMgr'); | |
| 274 | - profile := fwMgr.LocalPolicy.CurrentProfile; | |
| 275 | - app := CreateOLEObject('HNetCfg.FwAuthorizedApplication'); | |
| 276 | - app.ProcessImageFileName := p_ApplicationPathAndExe; | |
| 277 | - app.Name := p_EntryName; | |
| 278 | - app.Scope := NET_FW_SCOPE_ALL; | |
| 279 | - app.IpVersion := NET_FW_IP_VERSION_ANY; | |
| 280 | - app.Enabled := p_Enabled; | |
| 281 | - profile.AuthorizedApplications.Add(app); | |
| 282 | - | |
| 283 | - CoUninitialize; | |
| 284 | -end; | |
| 285 | - | |
| 286 | -{*------------------------------------------------------------------------------ | |
| 287 | - Retorna array de elementos com base em separador | |
| 288 | - | |
| 289 | - @param p_String String contendo campos e valores separados por caracter ou string | |
| 290 | - @param p_Separador String separadora de campos e valores | |
| 291 | --------------------------------------------------------------------------------} | |
| 292 | -Function TCACIC.explode(p_String, p_Separador : String) : TStrings; | |
| 293 | -var | |
| 294 | - strItem : String; | |
| 295 | - ListaAuxUTILS : TStrings; | |
| 296 | - NumCaracteres, | |
| 297 | - TamanhoSeparador, | |
| 298 | - I : Integer; | |
| 299 | -Begin | |
| 300 | - ListaAuxUTILS := TStringList.Create; | |
| 301 | - strItem := ''; | |
| 302 | - NumCaracteres := Length(p_String); | |
| 303 | - TamanhoSeparador := Length(p_Separador); | |
| 304 | - I := 1; | |
| 305 | - While I <= NumCaracteres Do | |
| 306 | - Begin | |
| 307 | - If (Copy(p_String,I,TamanhoSeparador) = p_Separador) or (I = NumCaracteres) Then | |
| 308 | - Begin | |
| 309 | - if (I = NumCaracteres) then strItem := strItem + p_String[I]; | |
| 310 | - ListaAuxUTILS.Add(trim(strItem)); | |
| 311 | - strItem := ''; | |
| 312 | - I := I + (TamanhoSeparador-1); | |
| 313 | - end | |
| 314 | - Else | |
| 315 | - strItem := strItem + p_String[I]; | |
| 316 | - | |
| 317 | - I := I + 1; | |
| 318 | - End; | |
| 319 | - Explode := ListaAuxUTILS; | |
| 320 | -end; | |
| 321 | - | |
| 322 | -{*------------------------------------------------------------------------------ | |
| 323 | - Retorna string com campos e valores separados por caracter ou string | |
| 324 | - | |
| 325 | - @param p_Array Array contendo campos e valores | |
| 326 | - @param p_Separador String separadora de campos e valores | |
| 327 | --------------------------------------------------------------------------------} | |
| 328 | -Function TCACIC.implode(p_Array : TStrings ; p_Separador : String) : String; | |
| 329 | -var intAux : integer; | |
| 330 | - strAux : string; | |
| 331 | -Begin | |
| 332 | - strAux := ''; | |
| 333 | - For intAux := 0 To p_Array.Count -1 do | |
| 334 | - Begin | |
| 335 | - if (strAux<>'') then strAux := strAux + p_Separador; | |
| 336 | - strAux := strAux + p_Array[intAux]; | |
| 337 | - End; | |
| 338 | - Implode := strAux; | |
| 339 | -end; | |
| 340 | - | |
| 341 | -{*------------------------------------------------------------------------------ | |
| 342 | - Elimina espacos excedentes na string | |
| 343 | - | |
| 344 | - @param p_str String a excluir espacos | |
| 345 | --------------------------------------------------------------------------------} | |
| 346 | -function TCACIC.trimEspacosExcedentes(p_str: String): String; | |
| 347 | -begin | |
| 348 | - if(ansipos(' ', p_str ) <> 0 ) then | |
| 349 | - repeat | |
| 350 | - p_str := StringReplace( p_str, ' ', ' ', [rfReplaceAll] ); | |
| 351 | - until ( ansipos( ' ', p_str ) = 0 ); | |
| 352 | - | |
| 353 | - Result := p_str; | |
| 354 | -end; | |
| 355 | - | |
| 356 | -{*------------------------------------------------------------------------------ | |
| 357 | - Atribui valor booleano à variável indicadora do status da criptografia | |
| 358 | - | |
| 359 | - @param p_boolCipher Valor booleano para atribuição à variável para status da | |
| 360 | - criptografia. | |
| 361 | --------------------------------------------------------------------------------} | |
| 362 | -procedure TCACIC.setBoolCipher(p_boolCipher : boolean); | |
| 363 | -Begin | |
| 364 | - Self.g_boolCipher := p_boolCipher; | |
| 365 | -End; | |
| 366 | -{*------------------------------------------------------------------------------ | |
| 367 | - Obtém o status da criptografia (TRUE -> Ligada / FALSE -> Desligada) | |
| 368 | - | |
| 369 | - @return boolean contendo o status para a criptografia | |
| 370 | --------------------------------------------------------------------------------} | |
| 371 | -function TCACIC.getBoolCipher() : boolean; | |
| 372 | -Begin | |
| 373 | - Result := Self.g_boolCipher; | |
| 374 | -End; | |
| 375 | - | |
| 376 | -{*------------------------------------------------------------------------------ | |
| 377 | - Atribui o caminho físico de instalação do agente cacic | |
| 378 | - | |
| 379 | - @param p_cacic_path Caminho físico de instalação do agente cacic | |
| 380 | --------------------------------------------------------------------------------} | |
| 381 | -procedure TCACIC.setCacicPath(p_cacic_path: string); | |
| 382 | -begin | |
| 383 | - Self.g_cacic_path := p_cacic_path; | |
| 384 | -end; | |
| 385 | - | |
| 386 | -{*------------------------------------------------------------------------------ | |
| 387 | - Obter o caminho fisico de instalacao do agente cacic | |
| 388 | - | |
| 389 | - @return String contendo o caminho físico | |
| 390 | --------------------------------------------------------------------------------} | |
| 391 | -function TCACIC.getCacicPath(): string; | |
| 392 | -begin | |
| 393 | - Result := Self.g_cacic_path; | |
| 394 | -end; | |
| 395 | - | |
| 396 | -{*------------------------------------------------------------------------------ | |
| 397 | - Verifica se a aplicação está em execução | |
| 398 | - | |
| 399 | - @param p_app_name Nome da aplicação a ser verificada | |
| 400 | - @return TRUE se em execução, FALSE caso contrário | |
| 401 | --------------------------------------------------------------------------------} | |
| 402 | -function TCACIC.isAppRunning( p_app_name: PAnsiChar ): boolean; | |
| 403 | -var | |
| 404 | - MutexHandle: THandle; | |
| 405 | - | |
| 406 | -begin | |
| 407 | - MutexHandle := CreateMutex(nil, TRUE, p_app_name); | |
| 408 | - if (MutexHandle = 0) OR (GetLastError = ERROR_ALREADY_EXISTS) | |
| 409 | - then Result := true | |
| 410 | - else Result := false; | |
| 411 | -end; | |
| 412 | - | |
| 413 | -{*------------------------------------------------------------------------------ | |
| 414 | - Coloca o sistema em modo de debug | |
| 415 | - | |
| 416 | --------------------------------------------------------------------------------} | |
| 417 | -procedure TCACIC_Debug.debugOn(); | |
| 418 | -begin | |
| 419 | - Self.g_debug := true; | |
| 420 | -end; | |
| 421 | - | |
| 422 | -{*------------------------------------------------------------------------------ | |
| 423 | - Desliga o modo de debug do sistema | |
| 424 | - | |
| 425 | --------------------------------------------------------------------------------} | |
| 426 | -procedure TCACIC_Debug.debugOff(); | |
| 427 | -begin | |
| 428 | - Self.g_debug := false; | |
| 429 | -end; | |
| 430 | - | |
| 431 | -{*------------------------------------------------------------------------------ | |
| 432 | - Coloca o sistema em modo de debug | |
| 433 | - | |
| 434 | - @return String contendo o caminho físico | |
| 435 | --------------------------------------------------------------------------------} | |
| 436 | -function TCACIC_Debug.inDebugMode() : boolean; | |
| 437 | -begin | |
| 438 | - Result := Self.g_debug; | |
| 439 | -end; | |
| 440 | - | |
| 441 | -{*------------------------------------------------------------------------------ | |
| 442 | - Verifica se é Windows Vista ou superior | |
| 443 | - | |
| 444 | - @return TRUE se Windows Vista ou superior, FALSE caso contrário | |
| 445 | - @see isWindowsNTPlataform, isWindows9xME, isWindowsNT, isWindows2000 | |
| 446 | - @see isWindowsXP, isWindowsVista, isWindowsGEVista | |
| 447 | --------------------------------------------------------------------------------} | |
| 448 | -function TCACIC_Windows.isWindowsGEVista() : boolean; | |
| 449 | -begin | |
| 450 | - Result := false; | |
| 451 | - if(Self.g_osVersionInfoExtended) then begin | |
| 452 | - if((g_osVersionInfoEx.dwMajorVersion >= 6) and (g_osVersionInfoEx.dwMinorVersion >= 0)) then | |
| 453 | - Result := true; | |
| 454 | - end | |
| 455 | - else | |
| 456 | - if((g_osVersionInfo.dwMajorVersion >= 6) and (g_osVersionInfo.dwMinorVersion >= 0)) then | |
| 457 | - Result := true; | |
| 458 | -end; | |
| 459 | - | |
| 460 | -{*------------------------------------------------------------------------------ | |
| 461 | - Verifica se é Windows Vista | |
| 462 | - | |
| 463 | - @return TRUE se Windows Vista, FALSE caso contrário | |
| 464 | - @see isWindowsNTPlataform, isWindows9xME, isWindowsNT, isWindows2000 | |
| 465 | - @see isWindowsXP, isWindowsVista | |
| 466 | --------------------------------------------------------------------------------} | |
| 467 | -function TCACIC_Windows.isWindowsVista() : boolean; | |
| 468 | -begin | |
| 469 | - Result := false; | |
| 470 | - if(Self.g_osVersionInfoExtended) then begin | |
| 471 | - if((g_osVersionInfoEx.dwMajorVersion = 6) and (g_osVersionInfoEx.dwMinorVersion = 0)) then | |
| 472 | - Result := true; | |
| 473 | - end | |
| 474 | - else | |
| 475 | - if((g_osVersionInfo.dwMajorVersion = 6) and (g_osVersionInfo.dwMinorVersion = 0)) then | |
| 476 | - Result := true; | |
| 477 | -end; | |
| 478 | - | |
| 479 | -{*------------------------------------------------------------------------------ | |
| 480 | - Verifica se é Windows XP ou superior | |
| 481 | - | |
| 482 | - @return TRUE se Windows XP ou superior, FALSE caso contrário | |
| 483 | - @see isWindowsNTPlataform, isWindows9xME, isWindowsNT, isWindows2000 | |
| 484 | - @see isWindowsXP, isWindowsVista | |
| 485 | --------------------------------------------------------------------------------} | |
| 486 | -function TCACIC_Windows.isWindowsGEXP() : boolean; | |
| 487 | -begin | |
| 488 | - Result := false; | |
| 489 | - if(Self.g_osVersionInfoExtended) then begin | |
| 490 | - if((g_osVersionInfoEx.dwMajorVersion >= 5) and (g_osVersionInfoEx.dwMinorVersion >= 1)) then | |
| 491 | - Result := true; | |
| 492 | - end | |
| 493 | - else | |
| 494 | - if((g_osVersionInfo.dwMajorVersion >= 5) and (g_osVersionInfo.dwMinorVersion >= 1)) then | |
| 495 | - Result := true; | |
| 496 | -end; | |
| 497 | - | |
| 498 | -{*------------------------------------------------------------------------------ | |
| 499 | - Verifica se é Windows XP | |
| 500 | - | |
| 501 | - @return TRUE se Windows XP, FALSE caso contrário | |
| 502 | - @see isWindowsNTPlataform, isWindows9xME, isWindowsNT, isWindows2000 | |
| 503 | - @see isWindowsXP, isWindowsVista | |
| 504 | --------------------------------------------------------------------------------} | |
| 505 | -function TCACIC_Windows.isWindowsXP() : boolean; | |
| 506 | -begin | |
| 507 | - Result := false; | |
| 508 | - if(Self.g_osVersionInfoExtended) then begin | |
| 509 | - if((g_osVersionInfoEx.dwMajorVersion = 5) and (g_osVersionInfoEx.dwMinorVersion = 1)) then | |
| 510 | - Result := true; | |
| 511 | - end | |
| 512 | - else | |
| 513 | - if((g_osVersionInfo.dwMajorVersion = 5) and (g_osVersionInfo.dwMinorVersion = 1)) then | |
| 514 | - Result := true; | |
| 515 | -end; | |
| 516 | - | |
| 517 | -{*------------------------------------------------------------------------------ | |
| 518 | - Verifica se é Windows 2000 | |
| 519 | - | |
| 520 | - @return TRUE se Windows 2000, FALSE caso contrário | |
| 521 | - @see isWindowsNTPlataform, isWindows9xME, isWindowsNT, isWindows2000 | |
| 522 | - @see isWindowsXP, isWindowsVista | |
| 523 | --------------------------------------------------------------------------------} | |
| 524 | -function TCACIC_Windows.isWindows2000() : boolean; | |
| 525 | -begin | |
| 526 | - Result := false; | |
| 527 | - if(Self.g_osVersionInfoExtended) then begin | |
| 528 | - if((g_osVersionInfoEx.dwMajorVersion = 5) and (g_osVersionInfoEx.dwMinorVersion = 0)) then | |
| 529 | - Result := true; | |
| 530 | - end | |
| 531 | - else | |
| 532 | - if((g_osVersionInfo.dwMajorVersion = 5) and (g_osVersionInfo.dwMinorVersion = 0)) then | |
| 533 | - Result := true; | |
| 534 | -end; | |
| 535 | - | |
| 536 | -{*------------------------------------------------------------------------------ | |
| 537 | - Verifica se é Windows NT | |
| 538 | - | |
| 539 | - @return TRUE se Windows NT, FALSE caso contrário | |
| 540 | - @see isWindowsNTPlataform, isWindows9xME, isWindowsNT, isWindows2000 | |
| 541 | - @see isWindowsXP, isWindowsVista | |
| 542 | --------------------------------------------------------------------------------} | |
| 543 | -function TCACIC_Windows.isWindowsNT() : boolean; | |
| 544 | -begin | |
| 545 | - Result := false; | |
| 546 | - if(Self.g_osVersionInfoExtended) then begin | |
| 547 | - if((g_osVersionInfoEx.dwMajorVersion = 4) and (g_osVersionInfoEx.dwMinorVersion = 0)) then | |
| 548 | - Result := true; | |
| 549 | - end | |
| 550 | - else | |
| 551 | - if((g_osVersionInfo.dwMajorVersion = 4) and (g_osVersionInfo.dwMinorVersion = 0)) then | |
| 552 | - Result := true; | |
| 553 | -end; | |
| 554 | - | |
| 555 | -{*------------------------------------------------------------------------------ | |
| 556 | - Verifica se a plataforma do sistema é de windows 9x ou ME | |
| 557 | - | |
| 558 | - @return TRUE se plataforma de Windows 9x/ME, FALSE caso contrário | |
| 559 | - @see isWindowsNTPlataform, isWindows9xME, isWindowsNT, isWindows2000 | |
| 560 | - @see isWindowsXP, isWindowsVista | |
| 561 | --------------------------------------------------------------------------------} | |
| 562 | -function TCACIC_Windows.isWindows9xME() : boolean; | |
| 563 | -begin | |
| 564 | - if (Self.g_osVersionInfoExtended) then | |
| 565 | - Result := (Self.g_osVersionInfoEx.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS) | |
| 566 | - else | |
| 567 | - Result := (Self.g_osVersionInfo.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS); | |
| 568 | -end; | |
| 569 | - | |
| 570 | -{*------------------------------------------------------------------------------ | |
| 571 | - Obter identificação extensa do sistema operacional | |
| 572 | - | |
| 573 | - @return String de identificação do sistema operacional | |
| 574 | - @example 1.4.10.A | |
| 575 | --------------------------------------------------------------------------------} | |
| 576 | -function TCACIC_Windows.getWindowsStrId() : string; | |
| 577 | -var | |
| 578 | - v_version_id: string; | |
| 579 | -begin | |
| 580 | - v_version_id := 'S.O.unknown'; | |
| 581 | - try | |
| 582 | - if (Self.g_osVersionInfoExtended) then | |
| 583 | - if(Self.isWindows9xME) then | |
| 584 | - v_version_id := IntToStr(Self.g_osVersionInfoEx.dwPlatformId) + '.' + | |
| 585 | - IntToStr(Self.g_osVersionInfoEx.dwMajorVersion) + '.' + | |
| 586 | - IntToStr(Self.g_osVersionInfoEx.dwMinorVersion) + | |
| 587 | - ifThen(trim(Self.g_osVersionInfoEx.szCSDVersion)='', | |
| 588 | - '', | |
| 589 | - '.'+trim(Self.g_osVersionInfoEx.szCSDVersion)) | |
| 590 | - else | |
| 591 | - v_version_id := IntToStr(Self.g_osVersionInfoEx.dwPlatformId) + '.' + | |
| 592 | - IntToStr(Self.g_osVersionInfoEx.dwMajorVersion) + '.' + | |
| 593 | - IntToStr(Self.g_osVersionInfoEx.dwMinorVersion) + '.' + | |
| 594 | - IntToStr(Self.g_osVersionInfoEx.wProductType) + '.' + | |
| 595 | - IntToStr(Self.g_osVersionInfoEx.wSuiteMask) | |
| 596 | - else | |
| 597 | - v_version_id := IntToStr(Self.g_osVersionInfo.dwPlatformId) + '.' + | |
| 598 | - IntToStr(Self.g_osVersionInfo.dwMajorVersion) + '.' + | |
| 599 | - IntToStr(Self.g_osVersionInfo.dwMinorVersion) + | |
| 600 | - ifThen(trim(Self.g_osVersionInfo.szCSDVersion)='', | |
| 601 | - '', | |
| 602 | - '.'+trim(Self.g_osVersionInfo.szCSDVersion)); | |
| 603 | - except | |
| 604 | - end; | |
| 605 | - Result := v_version_id; | |
| 606 | - | |
| 607 | -end; | |
| 608 | - | |
| 609 | -{*------------------------------------------------------------------------------ | |
| 610 | - Verifica se a plataforma do sistema é de Windows NT | |
| 611 | - | |
| 612 | - @return TRUE se plataforma de Windows NT, FALSE caso contrário | |
| 613 | - @see isWindows9xME, isWindowsVista | |
| 614 | --------------------------------------------------------------------------------} | |
| 615 | -function TCACIC_Windows.isWindowsNTPlataform() : boolean; | |
| 616 | -begin | |
| 617 | - if(Self.g_osVersionInfoExtended) | |
| 618 | - then Result := (Self.g_osVersionInfoEx.dwPlatformId = VER_PLATFORM_WIN32_NT) | |
| 619 | - else Result := (Self.g_osVersionInfo.dwPlatformId = VER_PLATFORM_WIN32_NT); | |
| 620 | -end; | |
| 621 | - | |
| 622 | -{*------------------------------------------------------------------------------ | |
| 623 | - Verifica se é administrador do sistema operacional se em plataforma NT | |
| 624 | - | |
| 625 | - @return TRUE se administrador do sistema, FALSE caso contrário | |
| 626 | --------------------------------------------------------------------------------} | |
| 627 | -function TCACIC_Windows.isWindowsAdmin(): Boolean; | |
| 628 | - | |
| 629 | -const | |
| 630 | - constSECURITY_NT_AUTHORITY: TSIDIdentifierAuthority = (Value: (0, 0, 0, 0, 0, 5)); | |
| 631 | - constSECURITY_BUILTIN_DOMAIN_RID = $00000020; | |
| 632 | - constDOMAIN_ALIAS_RID_ADMINS = $00000220; | |
| 633 | - | |
| 634 | -var | |
| 635 | - hAccessToken: THandle; | |
| 636 | - ptgGroups: PTokenGroups; | |
| 637 | - dwInfoBufferSize: DWORD; | |
| 638 | - psidAdministrators: PSID; | |
| 639 | - x: Integer; | |
| 640 | - bSuccess: BOOL; | |
| 641 | - | |
| 642 | -begin | |
| 643 | - if (not Self.isWindowsNTPlataform()) then // Se nao NT (ex: Win95/98) | |
| 644 | - // Se nao eh NT nao tem ''admin'' | |
| 645 | - Result := True | |
| 646 | - else begin | |
| 647 | - Result := False; | |
| 648 | - bSuccess := OpenThreadToken(GetCurrentThread, TOKEN_QUERY, True, hAccessToken); | |
| 649 | - if not bSuccess then begin | |
| 650 | - if GetLastError = ERROR_NO_TOKEN then | |
| 651 | - bSuccess := OpenProcessToken(GetCurrentProcess, TOKEN_QUERY, hAccessToken); | |
| 652 | - end; | |
| 653 | - if bSuccess then begin | |
| 654 | - GetMem(ptgGroups, 1024); | |
| 655 | - bSuccess := GetTokenInformation(hAccessToken, TokenGroups, ptgGroups, 1024, dwInfoBufferSize); | |
| 656 | - CloseHandle(hAccessToken); | |
| 657 | - if bSuccess then begin | |
| 658 | - AllocateAndInitializeSid(constSECURITY_NT_AUTHORITY, 2, | |
| 659 | - constSECURITY_BUILTIN_DOMAIN_RID, | |
| 660 | - constDOMAIN_ALIAS_RID_ADMINS, | |
| 661 | - 0, 0, 0, 0, 0, 0, psidAdministrators); | |
| 662 | - {$R-} | |
| 663 | - for x := 0 to ptgGroups.GroupCount - 1 do | |
| 664 | - if EqualSid(psidAdministrators, ptgGroups.Groups[x].Sid) then begin | |
| 665 | - Result := True; | |
| 666 | - Break; | |
| 667 | - end; | |
| 668 | - {$R+} | |
| 669 | - FreeSid(psidAdministrators); | |
| 670 | - end; | |
| 671 | - FreeMemory(ptgGroups); | |
| 672 | - end; | |
| 673 | - end; | |
| 674 | -end; | |
| 675 | - | |
| 676 | -{*------------------------------------------------------------------------------ | |
| 677 | - Executa commandos, substitui o WinExec | |
| 678 | - | |
| 679 | - @autor: Marcos Dell Antonio | |
| 680 | - @param p_cmd Comando a ser executado | |
| 681 | - @param p_wait TRUE se deve aguardar término da excução, FALSE caso contrário | |
| 682 | --------------------------------------------------------------------------------} | |
| 683 | -{function TCACIC_Windows.createSampleProcess(p_cmd: string; p_wait: boolean ): boolean; | |
| 684 | -begin | |
| 685 | -end; | |
| 686 | -} | |
| 687 | -{*------------------------------------------------------------------------------ | |
| 688 | - Executa commandos, substitui o WinExec | |
| 689 | - | |
| 690 | - @autor: Marcos Dell Antonio | |
| 691 | - @param p_cmd Comando a ser executado | |
| 692 | - @param p_wait TRUE se deve aguardar término da excução, FALSE caso contrário | |
| 693 | - @param p_showWindow Constante que define o tipo de exibição da janela do aplicativo | |
| 694 | --------------------------------------------------------------------------------} | |
| 695 | -function TCACIC_Windows.createSampleProcess(p_cmd: string; p_wait: boolean; p_showWindow : word = SW_HIDE): boolean; | |
| 696 | -var | |
| 697 | - SUInfo: TStartupInfo; | |
| 698 | - ProcInfo: TProcessInformation; | |
| 699 | -begin | |
| 700 | - FillChar(SUInfo, SizeOf(SUInfo), #0); | |
| 701 | - SUInfo.cb := SizeOf(SUInfo); | |
| 702 | - SUInfo.dwFlags := STARTF_USESHOWWINDOW; | |
| 703 | - SUInfo.wShowWindow := p_showWindow; | |
| 704 | - | |
| 705 | - Result := CreateProcess(nil, | |
| 706 | - PChar(p_cmd), | |
| 707 | - nil, | |
| 708 | - nil, | |
| 709 | - false, | |
| 710 | - CREATE_NEW_CONSOLE or | |
| 711 | - BELOW_NORMAL_PRIORITY_CLASS, | |
| 712 | - nil, | |
| 713 | - nil, | |
| 714 | - SUInfo, | |
| 715 | - ProcInfo); | |
| 716 | - | |
| 717 | - if (Result) then | |
| 718 | - begin | |
| 719 | - if(p_wait) then begin | |
| 720 | - WaitForSingleObject(ProcInfo.hProcess, INFINITE); | |
| 721 | - CloseHandle(ProcInfo.hProcess); | |
| 722 | - CloseHandle(ProcInfo.hThread); | |
| 723 | - end; | |
| 724 | - end; | |
| 725 | -end; | |
| 726 | - | |
| 727 | -{*------------------------------------------------------------------------------ | |
| 728 | - Para cálculo de HASH de determinado arquivo. | |
| 729 | - | |
| 730 | - @autor: Anderson Peterle | |
| 731 | - @param p_strFileName - Nome do arquivo para extração do HashCode | |
| 732 | --------------------------------------------------------------------------------} | |
| 733 | -function TCACIC.GetFileHash(strFileName : String) : String; | |
| 734 | -Begin | |
| 735 | - Result := 'Arquivo "'+strFileName+'" Inexistente!'; | |
| 736 | - if (FileExists(strFileName)) then | |
| 737 | - Result := MD5Print(MD5File(strFileName)); | |
| 738 | -End; | |
| 739 | - | |
| 740 | -{*------------------------------------------------------------------------------ | |
| 741 | - Mostra ou oculta o cacic na "systray" do windows | |
| 742 | - | |
| 743 | - @autor: Diversos - compilado de vários exemplos obtidos na internet | |
| 744 | - @param p_visible TRUE se deve mostrar na systray, FALSE caso contrário | |
| 745 | --------------------------------------------------------------------------------} | |
| 746 | -procedure TCACIC_Windows.showTrayIcon(p_visible:boolean); | |
| 747 | - Var | |
| 748 | - v_tray, v_child : hWnd; | |
| 749 | - v_char : Array[0..127] of Char; | |
| 750 | - v_string : String; | |
| 751 | - | |
| 752 | - Begin | |
| 753 | - v_tray := FindWindow('Shell_TrayWnd', NIL); | |
| 754 | - v_child := GetWindow(v_tray, GW_CHILD); | |
| 755 | - While v_child <> 0 | |
| 756 | - do Begin | |
| 757 | - If GetClassName(v_child, v_char, SizeOf(v_char)) > 0 | |
| 758 | - Then Begin | |
| 759 | - v_string := StrPAS(v_char); | |
| 760 | - If UpperCase(v_string) = 'TRAYNOTIFYWND' | |
| 761 | - then begin | |
| 762 | - If p_visible | |
| 763 | - then ShowWindow(v_child, 1) | |
| 764 | - else ShowWindow(v_child, 0); | |
| 765 | - end; | |
| 766 | - End; | |
| 767 | - v_child := GetWindow(v_child, GW_HWNDNEXT); | |
| 768 | - End; | |
| 769 | - End; | |
| 770 | - | |
| 771 | -{*------------------------------------------------------------------------------ | |
| 772 | - Obter a chave para criptografia simétrica | |
| 773 | - | |
| 774 | - @return String contendo a chave simétrica | |
| 775 | --------------------------------------------------------------------------------} | |
| 776 | -function TCACIC.getCipherKey(): string; | |
| 777 | -begin | |
| 778 | - Result := CACIC_CIPHERKEY; | |
| 779 | -end; | |
| 780 | - | |
| 781 | -{*------------------------------------------------------------------------------ | |
| 782 | - Obter o vetor de inicialização para criptografia | |
| 783 | - | |
| 784 | - @return String contendo o vetor de inicialização | |
| 785 | --------------------------------------------------------------------------------} | |
| 786 | -function TCACIC.getIV(): string; | |
| 787 | -begin | |
| 788 | - Result := CACIC_IV; | |
| 789 | -end; | |
| 790 | - | |
| 791 | -{*------------------------------------------------------------------------------ | |
| 792 | - Obter o valor para tamanho da chave de criptografia | |
| 793 | - | |
| 794 | - @return Integer contendo o tamanho para chave de criptografia | |
| 795 | --------------------------------------------------------------------------------} | |
| 796 | -function TCACIC.getKeySize(): Integer; | |
| 797 | -begin | |
| 798 | - Result := CACIC_KEYSIZE; | |
| 799 | -end; | |
| 800 | - | |
| 801 | -{*------------------------------------------------------------------------------ | |
| 802 | - Obter o valor para tamanho do bloco de criptografia | |
| 803 | - | |
| 804 | - @return Integer contendo o tamanho para bloco de criptografia | |
| 805 | --------------------------------------------------------------------------------} | |
| 806 | -function TCACIC.getBlockSize(): Integer; | |
| 807 | -begin | |
| 808 | - Result := CACIC_BLOCKSIZE; | |
| 809 | -end; | |
| 810 | - | |
| 811 | -{*------------------------------------------------------------------------------ | |
| 812 | - Obter o nome do arquivo de informações de configurações e dados locais | |
| 813 | - | |
| 814 | - @return String contendo o nome do arquivo de configurações e dados locais | |
| 815 | --------------------------------------------------------------------------------} | |
| 816 | -function TCACIC.getDatFileName(): string; | |
| 817 | -begin | |
| 818 | - Result := CACIC_DATFILENAME; | |
| 819 | -end; | |
| 820 | - | |
| 821 | -{*------------------------------------------------------------------------------ | |
| 822 | - Obter o separador para criação de listas locais | |
| 823 | - | |
| 824 | - @return String contendo o separador de campos e valores | |
| 825 | --------------------------------------------------------------------------------} | |
| 826 | -function TCACIC.getSeparatorKey(): string; | |
| 827 | -begin | |
| 828 | - Result := CACIC_SEPARATORKEY; | |
| 829 | -end; | |
| 830 | - | |
| 831 | -// Encrypt a string and return the Base64 encoded result | |
| 832 | -function TCACIC.enCrypt(p_Data : String) : String; | |
| 833 | -var | |
| 834 | - l_Cipher : TDCP_rijndael; | |
| 835 | - l_Data, l_Key, l_IV : string; | |
| 836 | -begin | |
| 837 | - Try | |
| 838 | - if self.g_boolCipher then | |
| 839 | - Begin | |
| 840 | - // Pad Key, IV and Data with zeros as appropriate | |
| 841 | - l_Key := PadWithZeros(CACIC_CIPHERKEY,CACIC_KEYSIZE); | |
| 842 | - l_IV := PadWithZeros(CACIC_IV,CACIC_BLOCKSIZE); | |
| 843 | - l_Data := PadWithZeros(p_Data,CACIC_BLOCKSIZE); | |
| 844 | - | |
| 845 | - // Create the cipher and initialise according to the key length | |
| 846 | - l_Cipher := TDCP_rijndael.Create(nil); | |
| 847 | - if Length(CACIC_CIPHERKEY) <= 16 then | |
| 848 | - l_Cipher.Init(l_Key[1],128,@l_IV[1]) | |
| 849 | - else if Length(CACIC_CIPHERKEY) <= 24 then | |
| 850 | - l_Cipher.Init(l_Key[1],192,@l_IV[1]) | |
| 851 | - else | |
| 852 | - l_Cipher.Init(l_Key[1],256,@l_IV[1]); | |
| 853 | - | |
| 854 | - // Encrypt the data | |
| 855 | - l_Cipher.EncryptCBC(l_Data[1],l_Data[1],Length(l_Data)); | |
| 856 | - | |
| 857 | - // Free the cipher and clear sensitive information | |
| 858 | - l_Cipher.Free; | |
| 859 | - FillChar(l_Key[1],Length(l_Key),0); | |
| 860 | - | |
| 861 | - // Return the Base64 encoded result | |
| 862 | - Result := Base64EncodeStr(l_Data); | |
| 863 | - End | |
| 864 | - Else | |
| 865 | - // Return the original value | |
| 866 | - Result := p_Data; | |
| 867 | - Except | |
| 868 | -// LogDiario('Erro no Processo de Criptografia'); | |
| 869 | - End; | |
| 870 | -end; | |
| 871 | - | |
| 872 | -function TCACIC.deCrypt(p_Data : String) : String; | |
| 873 | -var | |
| 874 | - l_Cipher : TDCP_rijndael; | |
| 875 | - l_Data, l_Key, l_IV : string; | |
| 876 | -begin | |
| 877 | - Try | |
| 878 | - if self.g_boolCipher then | |
| 879 | - Begin | |
| 880 | - // Pad Key and IV with zeros as appropriate | |
| 881 | - l_Key := PadWithZeros(CACIC_CIPHERKEY,CACIC_KEYSIZE); | |
| 882 | - l_IV := PadWithZeros(CACIC_IV,CACIC_BLOCKSIZE); | |
| 883 | - | |
| 884 | - // Decode the Base64 encoded string | |
| 885 | - l_Data := Base64DecodeStr(p_Data); | |
| 886 | - | |
| 887 | - // Create the cipher and initialise according to the key length | |
| 888 | - l_Cipher := TDCP_rijndael.Create(nil); | |
| 889 | - if Length(CACIC_CIPHERKEY) <= 16 then | |
| 890 | - l_Cipher.Init(l_Key[1],128,@l_IV[1]) | |
| 891 | - else if Length(CACIC_CIPHERKEY) <= 24 then | |
| 892 | - l_Cipher.Init(l_Key[1],192,@l_IV[1]) | |
| 893 | - else | |
| 894 | - l_Cipher.Init(l_Key[1],256,@l_IV[1]); | |
| 895 | - | |
| 896 | - // Decrypt the data | |
| 897 | - l_Cipher.DecryptCBC(l_Data[1],l_Data[1],Length(l_Data)); | |
| 898 | - | |
| 899 | - // Free the cipher and clear sensitive information | |
| 900 | - l_Cipher.Free; | |
| 901 | - FillChar(l_Key[1],Length(l_Key),0); | |
| 902 | - | |
| 903 | - // Return the result (unCrypted) | |
| 904 | - Result := trim(l_Data); | |
| 905 | - End | |
| 906 | - Else | |
| 907 | - // Return the original value | |
| 908 | - Result := p_Data | |
| 909 | - Except | |
| 910 | -// LogDiario('Erro no Processo de Decriptografia'); | |
| 911 | - End; | |
| 912 | -end; | |
| 913 | - | |
| 914 | -// Pad a string with zeros so that it is a multiple of size | |
| 915 | -function TCACIC.padWithZeros(const str : string; size : integer) : string; | |
| 916 | -var origsize, i : integer; | |
| 917 | -begin | |
| 918 | - Result := str; | |
| 919 | - origsize := Length(Result); | |
| 920 | - if ((origsize mod size) <> 0) or (origsize = 0) then | |
| 921 | - begin | |
| 922 | - SetLength(Result,((origsize div size)+1)*size); | |
| 923 | - for i := origsize+1 to Length(Result) do | |
| 924 | - Result[i] := #0; | |
| 925 | - end; | |
| 926 | -end; | |
| 927 | - | |
| 928 | -end. | |
| 929 | - |
cacic2.bpg
| ... | ... | @@ -1,67 +0,0 @@ |
| 1 | -#------------------------------------------------------------------------------ | |
| 2 | -VERSION = BWS.01 | |
| 3 | -#------------------------------------------------------------------------------ | |
| 4 | -!ifndef ROOT | |
| 5 | -ROOT = $(MAKEDIR)\.. | |
| 6 | -!endif | |
| 7 | -#------------------------------------------------------------------------------ | |
| 8 | -MAKE = $(ROOT)\bin\make.exe -$(MAKEFLAGS) -f$** | |
| 9 | -DCC = $(ROOT)\bin\dcc32.exe $** | |
| 10 | -BRCC = $(ROOT)\bin\brcc32.exe $** | |
| 11 | -#------------------------------------------------------------------------------ | |
| 12 | -PROJECTS = cacic2.exe chkcacic.exe chksis.exe col_anvi.exe col_comp.exe \ | |
| 13 | - col_hard.exe col_moni.exe col_patr.exe col_soft.exe col_undi.exe ger_cols.exe \ | |
| 14 | - ini_cols.exe mapacacic.exe vaca.exe vacon.exe CACICsvc.exe | |
| 15 | -#------------------------------------------------------------------------------ | |
| 16 | -default: $(PROJECTS) | |
| 17 | -#------------------------------------------------------------------------------ | |
| 18 | - | |
| 19 | -cacic2.exe: cacic2.dpr | |
| 20 | - $(DCC) | |
| 21 | - | |
| 22 | -chkcacic.exe: chkcacic\chkcacic.dpr | |
| 23 | - $(DCC) | |
| 24 | - | |
| 25 | -chksis.exe: chksis\chksis.dpr | |
| 26 | - $(DCC) | |
| 27 | - | |
| 28 | -col_anvi.exe: col_anvi\col_anvi.dpr | |
| 29 | - $(DCC) | |
| 30 | - | |
| 31 | -col_comp.exe: col_comp\col_comp.dpr | |
| 32 | - $(DCC) | |
| 33 | - | |
| 34 | -col_hard.exe: col_hard\col_hard.dpr | |
| 35 | - $(DCC) | |
| 36 | - | |
| 37 | -col_moni.exe: col_moni\col_moni.dpr | |
| 38 | - $(DCC) | |
| 39 | - | |
| 40 | -col_patr.exe: col_patr\col_patr.dpr | |
| 41 | - $(DCC) | |
| 42 | - | |
| 43 | -col_soft.exe: col_soft\col_soft.dpr | |
| 44 | - $(DCC) | |
| 45 | - | |
| 46 | -col_undi.exe: col_undi\col_undi.dpr | |
| 47 | - $(DCC) | |
| 48 | - | |
| 49 | -ger_cols.exe: ger_cols\ger_cols.dpr | |
| 50 | - $(DCC) | |
| 51 | - | |
| 52 | -ini_cols.exe: ini_cols\ini_cols.dpr | |
| 53 | - $(DCC) | |
| 54 | - | |
| 55 | -mapacacic.exe: mapa\mapacacic.dpr | |
| 56 | - $(DCC) | |
| 57 | - | |
| 58 | -vaca.exe: vaca\vaca.dpr | |
| 59 | - $(DCC) | |
| 60 | - | |
| 61 | -vacon.exe: vacon\vacon.dpr | |
| 62 | - $(DCC) | |
| 63 | - | |
| 64 | -CACICsvc.exe: cacicservice\CACICsvc.dpr | |
| 65 | - $(DCC) | |
| 66 | - | |
| 67 | - |
cacic2.dof
| ... | ... | @@ -1,135 +0,0 @@ |
| 1 | -[FileVersion] | |
| 2 | -Version=7.0 | |
| 3 | -[Compiler] | |
| 4 | -A=8 | |
| 5 | -B=0 | |
| 6 | -C=1 | |
| 7 | -D=1 | |
| 8 | -E=0 | |
| 9 | -F=0 | |
| 10 | -G=1 | |
| 11 | -H=1 | |
| 12 | -I=1 | |
| 13 | -J=0 | |
| 14 | -K=0 | |
| 15 | -L=1 | |
| 16 | -M=0 | |
| 17 | -N=1 | |
| 18 | -O=1 | |
| 19 | -P=1 | |
| 20 | -Q=0 | |
| 21 | -R=0 | |
| 22 | -S=0 | |
| 23 | -T=0 | |
| 24 | -U=0 | |
| 25 | -V=1 | |
| 26 | -W=0 | |
| 27 | -X=1 | |
| 28 | -Y=1 | |
| 29 | -Z=1 | |
| 30 | -ShowHints=1 | |
| 31 | -ShowWarnings=1 | |
| 32 | -UnitAliases=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; | |
| 33 | -NamespacePrefix= | |
| 34 | -SymbolDeprecated=1 | |
| 35 | -SymbolLibrary=1 | |
| 36 | -SymbolPlatform=1 | |
| 37 | -UnitLibrary=1 | |
| 38 | -UnitPlatform=1 | |
| 39 | -UnitDeprecated=1 | |
| 40 | -HResultCompat=1 | |
| 41 | -HidingMember=1 | |
| 42 | -HiddenVirtual=1 | |
| 43 | -Garbage=1 | |
| 44 | -BoundsError=1 | |
| 45 | -ZeroNilCompat=1 | |
| 46 | -StringConstTruncated=1 | |
| 47 | -ForLoopVarVarPar=1 | |
| 48 | -TypedConstVarPar=1 | |
| 49 | -AsgToTypedConst=1 | |
| 50 | -CaseLabelRange=1 | |
| 51 | -ForVariable=1 | |
| 52 | -ConstructingAbstract=1 | |
| 53 | -ComparisonFalse=1 | |
| 54 | -ComparisonTrue=1 | |
| 55 | -ComparingSignedUnsigned=1 | |
| 56 | -CombiningSignedUnsigned=1 | |
| 57 | -UnsupportedConstruct=1 | |
| 58 | -FileOpen=1 | |
| 59 | -FileOpenUnitSrc=1 | |
| 60 | -BadGlobalSymbol=1 | |
| 61 | -DuplicateConstructorDestructor=1 | |
| 62 | -InvalidDirective=1 | |
| 63 | -PackageNoLink=1 | |
| 64 | -PackageThreadVar=1 | |
| 65 | -ImplicitImport=1 | |
| 66 | -HPPEMITIgnored=1 | |
| 67 | -NoRetVal=1 | |
| 68 | -UseBeforeDef=1 | |
| 69 | -ForLoopVarUndef=1 | |
| 70 | -UnitNameMismatch=1 | |
| 71 | -NoCFGFileFound=1 | |
| 72 | -MessageDirective=1 | |
| 73 | -ImplicitVariants=1 | |
| 74 | -UnicodeToLocale=1 | |
| 75 | -LocaleToUnicode=1 | |
| 76 | -ImagebaseMultiple=1 | |
| 77 | -SuspiciousTypecast=1 | |
| 78 | -PrivatePropAccessor=1 | |
| 79 | -UnsafeType=0 | |
| 80 | -UnsafeCode=0 | |
| 81 | -UnsafeCast=0 | |
| 82 | -[Linker] | |
| 83 | -MapFile=0 | |
| 84 | -OutputObjs=0 | |
| 85 | -ConsoleApp=1 | |
| 86 | -DebugInfo=0 | |
| 87 | -RemoteSymbols=0 | |
| 88 | -MinStackSize=16384 | |
| 89 | -MaxStackSize=1048576 | |
| 90 | -ImageBase=4194304 | |
| 91 | -ExeDescription= | |
| 92 | -[Directories] | |
| 93 | -OutputDir= | |
| 94 | -UnitOutputDir= | |
| 95 | -PackageDLLOutputDir= | |
| 96 | -PackageDCPOutputDir= | |
| 97 | -SearchPath= | |
| 98 | -Packages=vcl;rtl;vclx;indy;inet;xmlrtl;vclie;inetdbbde;inetdbxpress;dbrtl;dsnap;dsnapcon;vcldb;soaprtl;VclSmp;dbexpress;dbxcds;inetdb;bdertl;vcldbx;webdsnap;websnap;adortl;ibxpress;teeui;teedb;tee;dss;visualclx;visualdbclx;vclactnband;vclshlctrls;IntrawebDB_50_70;Intraweb_50_70;Rave50CLX;Rave50VCL;dclOffice2k | |
| 99 | -Conditionals= | |
| 100 | -DebugSourceDirs= | |
| 101 | -UsePackages=0 | |
| 102 | -[Parameters] | |
| 103 | -RunParams= | |
| 104 | -HostApplication= | |
| 105 | -Launcher= | |
| 106 | -UseLauncher=0 | |
| 107 | -DebugCWD= | |
| 108 | -[Language] | |
| 109 | -ActiveLang= | |
| 110 | -ProjectLang= | |
| 111 | -RootDir=Y:\arariboia_mod\ | |
| 112 | -[Version Info] | |
| 113 | -IncludeVerInfo=1 | |
| 114 | -AutoIncBuild=0 | |
| 115 | -MajorVer=2 | |
| 116 | -MinorVer=5 | |
| 117 | -Release=0 | |
| 118 | -Build=787 | |
| 119 | -Debug=0 | |
| 120 | -PreRelease=0 | |
| 121 | -Special=0 | |
| 122 | -Private=0 | |
| 123 | -DLL=0 | |
| 124 | -Locale=1046 | |
| 125 | -CodePage=1252 | |
| 126 | -[Version Info Keys] | |
| 127 | -CompanyName=Dataprev - Emp. de TI da Prev.Social - URES | |
| 128 | -FileDescription=Módulo Agente Principal do Sistema CACIC | |
| 129 | -FileVersion=2.5.0.787 | |
| 130 | -InternalName= | |
| 131 | -LegalCopyright=Baseado na licença GPL (General Public License) | |
| 132 | -LegalTrademarks= | |
| 133 | -OriginalFilename= | |
| 134 | -ProductName=Cacic - Configurador Automático e Coletor de Informações Computacionais | |
| 135 | -ProductVersion=2.6 |
cacic_icon_WithoutServer.ico
No preview for this file type
cacic_icon_raio.ico
No preview for this file type
cacic_service_32x32.ico
No preview for this file type
del-svnignore.bat
frmConfiguracoes.pas
| ... | ... | @@ -1,137 +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 frmConfiguracoes; | |
| 19 | - | |
| 20 | -interface | |
| 21 | - | |
| 22 | -uses | |
| 23 | - Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, | |
| 24 | - Buttons, StdCtrls, ExtCtrls, main, dialogs; | |
| 25 | - | |
| 26 | -type | |
| 27 | - TFormConfiguracoes = class(TForm) | |
| 28 | - Lb_End_Serv_Aplicacao: TLabel; | |
| 29 | - EditEnderecoServidorAplicacao: TEdit; | |
| 30 | - BtN_Confirmar: TButton; | |
| 31 | - Btn_Desinstalar: TButton; | |
| 32 | - Bv1_Configuracoes: TBevel; | |
| 33 | - Btn_Cancelar: TButton; | |
| 34 | - Btn_OK: TButton; | |
| 35 | - Lb_End_Serv_Updates: TLabel; | |
| 36 | - EditEnderecoServidorUpdates: TEdit; | |
| 37 | - procedure pro_Btn_OK(Sender: TObject); | |
| 38 | - procedure pro_Btn_Cancelar(Sender: TObject); | |
| 39 | - procedure FormClose(Sender: TObject; var Action: TCloseAction); | |
| 40 | - procedure FormCreate(Sender: TObject); | |
| 41 | - procedure pro_Btn_Confirmar(Sender: TObject); | |
| 42 | - procedure pro_Btn_Desinstalar(Sender: TObject); | |
| 43 | - procedure AtualizaConfiguracoes(Chave, Valor : String); | |
| 44 | - private | |
| 45 | - { Private declarations } | |
| 46 | - public | |
| 47 | - { Public declarations } | |
| 48 | - end; | |
| 49 | - | |
| 50 | -var | |
| 51 | - FormConfiguracoes: TFormConfiguracoes; | |
| 52 | - | |
| 53 | -implementation | |
| 54 | - | |
| 55 | - | |
| 56 | -{$R *.dfm} | |
| 57 | - | |
| 58 | -procedure TFormConfiguracoes.AtualizaConfiguracoes(Chave, Valor: String); | |
| 59 | -begin | |
| 60 | - ///Falta validar se o endereco é valido. E se for nome? | |
| 61 | - FormularioGeral.SetValorDatMemoria(Chave, Valor, v_tstrCipherOpened); | |
| 62 | -end; | |
| 63 | - | |
| 64 | -procedure TFormConfiguracoes.pro_Btn_OK(Sender: TObject); | |
| 65 | -begin | |
| 66 | - AtualizaConfiguracoes('Configs.EnderecoServidor',EditEnderecoServidorAplicacao.Text); | |
| 67 | - AtualizaConfiguracoes('Configs.TE_SERV_UPDATES' ,EditEnderecoServidorUpdates.Text); | |
| 68 | - FormularioGeral.CipherClose; | |
| 69 | - release; | |
| 70 | - Close; | |
| 71 | -end; | |
| 72 | - | |
| 73 | -procedure TFormConfiguracoes.pro_Btn_Cancelar(Sender: TObject); | |
| 74 | -begin | |
| 75 | - release; | |
| 76 | - Close; | |
| 77 | -end; | |
| 78 | - | |
| 79 | - | |
| 80 | -procedure TFormConfiguracoes.FormClose(Sender: TObject; var Action: TCloseAction); | |
| 81 | -begin | |
| 82 | - Release; | |
| 83 | - close; | |
| 84 | -end; | |
| 85 | - | |
| 86 | - | |
| 87 | -procedure TFormConfiguracoes.FormCreate(Sender: TObject); | |
| 88 | -var v_ID_SO : String; | |
| 89 | -begin | |
| 90 | - EditEnderecoServidorAplicacao.Text := FormularioGeral.GetValorDatMemoria('Configs.EnderecoServidor',v_tstrCipherOpened); | |
| 91 | - EditEnderecoServidorUpdates.Text := FormularioGeral.GetValorDatMemoria('Configs.TE_SERV_UPDATES',v_tstrCipherOpened); | |
| 92 | - v_ID_SO := trim(FormularioGeral.GetValorDatMemoria('Configs.ID_SO',v_tstrCipherOpened)); | |
| 93 | - Btn_Desinstalar.Visible := FALSE; | |
| 94 | - If (v_ID_SO <> '') and (g_oCacic.isWindows9xME()) then | |
| 95 | - begin | |
| 96 | - //Se for Win9x/ME | |
| 97 | - Btn_Desinstalar.Visible := TRUE; | |
| 98 | - end; | |
| 99 | -end; | |
| 100 | - | |
| 101 | -procedure TFormConfiguracoes.pro_Btn_Confirmar(Sender: TObject); | |
| 102 | -Begin | |
| 103 | - If Trim(EditEnderecoServidorAplicacao.Text) = '' Then | |
| 104 | - Begin | |
| 105 | - MessageDlg('Erro na instalação: ' + #13#10 + 'Não foi especificado o endereço do servidor do CACIC.', mtInformation, [mbOk], 0); | |
| 106 | - Exit; | |
| 107 | - end; | |
| 108 | - If Trim(EditEnderecoServidorUpdates.Text) = '' Then | |
| 109 | - Begin | |
| 110 | - MessageDlg('Erro na instalação: ' + #13#10 + 'Não foi especificado o endereço do servidor de Updates do CACIC.', mtInformation, [mbOk], 0); | |
| 111 | - Exit; | |
| 112 | - end; | |
| 113 | - | |
| 114 | - try | |
| 115 | - FormConfiguracoes.AtualizaConfiguracoes('Configs.EnderecoServidor',Trim(EditEnderecoServidorAplicacao.Text)); | |
| 116 | - finally | |
| 117 | - end; | |
| 118 | - try | |
| 119 | - FormConfiguracoes.AtualizaConfiguracoes('Configs.TE_SERV_UPDATES',Trim(EditEnderecoServidorUpdates.Text)); | |
| 120 | - finally | |
| 121 | - end; | |
| 122 | - FormularioGeral.CipherClose; | |
| 123 | - release; | |
| 124 | - close; | |
| 125 | -end; | |
| 126 | - | |
| 127 | - | |
| 128 | - | |
| 129 | - | |
| 130 | -procedure TFormConfiguracoes.pro_Btn_Desinstalar(Sender: TObject); | |
| 131 | -begin | |
| 132 | - FormularioGeral.DelValorReg('HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run\cacic2'); | |
| 133 | - FormConfiguracoes.Visible := false; | |
| 134 | - MessageDlg('O CACIC não será mais executado automaticamente durante a inicialização do Windows. O arquivo ' + Application.ExeName + ' não será removido do seu computador, permitindo que seja realizada a instalação novamente.', mtInformation, [mbOk], 10); | |
| 135 | - close; | |
| 136 | -end; | |
| 137 | -end. |
imgFechar.bmp
No preview for this file type
raio.ico
No preview for this file type
raio.psd
No preview for this file type