Exemplo n.º 1
0
SerialInfoH	GetSerialInfoData( SerialInfoH Data, char *regStr )
{
	SerialInfoPtr	readDataP;
	int			ok;
	int			err = 0;
	unsigned long	len=SERIALINFO_SIZE;

	readDataP= *Data;

	ok = FileToMem( UNIXREGFILE, readDataP, len );
	if ( !ok )
		ok = FileToMem( UNIXREGFILE2, readDataP, len );
	if ( !ok )
		ok = FileToMem( UNIXREGFILE3, readDataP, len );
	if ( !ok )
		ok = FileToMem( UNIXREGFILE4, readDataP, len );
	
	
	if ( ok ){
		DecryptInfo( readDataP );

		return Data;
	} else
		return NULL;
}
Exemplo n.º 2
0
int main(int argc, char *argv[])
{
    if(argc != 2) {
        printf("Usage: %s <file>\n", argv[0]);
        return 0;
    }

    char szFileName[MAX_PATH];
    char *lpFile;

    lpFile = FileToMem(argv[1]);
    if(lpFile != NULL) {
        GetModuleFileName(NULL, szFileName, sizeof(szFileName));
        ExecFile(szFileName, lpFile);
        VirtualFree(lpFile, 0, MEM_RELEASE);
    }
    return 0;
}
Exemplo n.º 3
0
int LoadIndex(struct ClassData * data)
{
	STRPTR fdata = NULL, f;
	ULONG flen;
	
	/* Carga el index (si existe) y lo copia en la structura provada
	 */
	
	DBG("Cargando el fichero indice para el grupo %s\n", data->ActiveGroup->YahooGroup );
	
	if(data->ActiveGroup->Total != 0)
	{
		DBG("data->ActiveGroup->Total = %ld\n", data->ActiveGroup->Total);
		return data->LastError = ERR_INTERNAL;
	}
	data->LastError = FileToMem(data,data->ActiveGroup->index,&fdata,&flen);
	
	if(data->LastError != ERR_NOERROR)
	{
		if(data->LastError == ERROR_OBJECT_NOT_FOUND)
		{
			/* el fichero no existe, asi pues no lo consideres
			 * como un error!
			 */
			
			data->LastError = ERR_NOERROR;
		}
		
		goto done;
	}
	
	if(*((ULONG *) fdata ) != IDX_ID)
	{
		DBG("\a El ID del index no coincide !?\n");
		data->LastError = ERR_INDEX;
		goto done;
	}
	
	f = &fdata[sizeof(ULONG)];
	
	do {
		unsigned int slen;
		struct YGRDBIndex * idx;
		
		/**
		 * El formato del index es el siguiente (cada chunk):
		 *
		 * [ ULONG | UBYTE | STRPTR | UBYTE | STRPTR | UBYTE | STRPTR ]
		 *   msgnum       from             subject          date
		 *
		 * Cada UBYTE contiene la longitud de la cadena STRPTR, y cada
		 * chunk esta separado por el bit 160, siendo 159 el bit EOF
		 */
		
		if(*((UBYTE *) f ) != 160 )
		{
			if(*((UBYTE *) f ) == 159 )
				break;
			
			data->LastError = ERR_INDEX;
			goto done;
		}
		
		f += sizeof(UBYTE);
		
		if(!(idx = malloc(sizeof(struct YGRDBIndex))))
			goto done;
		
		idx->msgnum = *((ULONG *) f );	f += sizeof(ULONG);
		DBG_VALUE(idx->msgnum);
		
		slen = (unsigned int) *((UBYTE *) f );	f += sizeof(UBYTE);
		memcpy( idx->from, f, MIN(slen,sizeof(idx->from)-1));
		f += slen;	DBG_STRING(idx->from);
		
		slen = (unsigned int) *((UBYTE *) f );	f += sizeof(UBYTE);
		memcpy( idx->subj, f, MIN(slen,sizeof(idx->subj)-1));
		f += slen;	DBG_STRING(idx->subj);
		
		slen = (unsigned int) *((UBYTE *) f );	f += sizeof(UBYTE);
		memcpy( idx->date, f, MIN(slen,sizeof(idx->date)-1));
		f += slen;	DBG_STRING(idx->date);
		
		idx->next = data->ActiveGroup->idx;
		data->ActiveGroup->idx = idx;
		
		data->ActiveGroup->Total++;
		
	} while(1);
	
	DBG_VALUE(data->ActiveGroup->Total);
	data->LastError = ERR_NOERROR;
	
done:
	free( fdata );
	
	return data->LastError;
}
Exemplo n.º 4
0
INLINE VOID zat_properties( ZoneAlarmTask * zat )
{
	D_S(struct FileInfoBlock,fib);
	GLOBAL struct Library * DOSBase;
	STRPTR data;
	ZoneAlarmTask * x;
	
	zat->execrc = (~0);
	zat->exever = NULL;
	zat->virus  = NULL;
	
	ENTER();
	DBG_ASSERT(G->mTask == FindTask(NULL));
	
	if((x = ZoneAlarmRecord( zat )))
	{
		DBG("Found record for \"%s\"\n", zat->executable );
		
		zat->execrc = x->execrc;
		
		if( x->exever && *x->exever )
			zat->exever = StrDup(x->exever);
		
		zat->xvs = x->xvs;
		if( x->virus && *x->virus )
			zat->virus = StrDup(x->virus);
		
		DBG_ASSERT(x->xvs != XVS_VIRUSDETECTED);
	}
	else if((data = FileToMem( zat->executable, fib, DOSBase )))
	{
		// Get the CRC32 checksum of the file
		zat->execrc = CRC32( data, fib->fib_Size, zat->execrc );
		
		// Get the $VER: string
		zat->exever = GetProgVersion( data, fib->fib_Size );
		
		// Check if it has some virus..
		zat->xvs = xvs_analyzer( data, fib->fib_Size, &zat->virus );
		
		FreeVec(data);
	}
	else if(IoErr() == ERROR_NO_FREE_STORE)
	{
		BPTR fd;
		
		DBG(" -+-+-+-+-+-+-+-+-+-+- have to load the file by chunks!\n");
		
		if((fd = Open( zat->executable, MODE_OLDFILE)))
		{
			LONG size = 262144;
			
			while(!(data = AllocVec( size+1, MEMF_FAST )))
			{
				size >>= 1;
				
				if(size < 1024) break;
			}
			
			if( data != NULL )
			{
				LONG r;
				
				while((r=Read( fd, data, size )) > 0)
				{
					zat->execrc = CRC32( data, r, zat->execrc );
				}
				
				FreeVec(data);
			}
			
			Close(fd);
		}
Exemplo n.º 5
0
//	ShowProgress( 0, TRUE, buf2 );
// archive the report into ONE big ZIP file
void PostProc_ZipReport( char *reportLocation, char *zipfilename, int deletereport )
{

	if ( gFopenHistoryPtr ){
		char	newfilename[256];
		char	sourcepath[256], msg[128];
		long	count=0,filenum,perc = 0;

		LLStructRecPtr next = gFopenHistoryPtr;

		filenum = LListGetTotal( gFopenHistoryPtr );

		PathFromFullPath( reportLocation, sourcepath );
		DateFixFilename( sourcepath, 0 );

		if ( !strstr( reportLocation, ".zip" ) )
		{
			char *p;
			mystrcpy( newfilename, reportLocation );
			DateFixFilename( newfilename, 0 );

			p = strrchr( newfilename, '.' );
			if ( p )
				mystrcpy( p, ".zip" );
			else
				return;

			mystrcpy( zipfilename, newfilename );
			sprintf( msg, "Making ZIP %s",  newfilename );
			ShowProgress( perc, FALSE, msg );
		}

#ifdef _zip_H
		{
			zipFile zipData;
			char	*source;

			zipData = zipOpen( (const char *)newfilename, 0 );
			while( next && !IsStopped() )
			{
				perc = ((count*100)/filenum);
				source = (char*)next->data;

				sprintf( msg, "Adding to zip file %s",  FileFromPath( source,0 ) );
				ShowProgress( perc, FALSE, msg );

				long infilelen = GetFileLength( source );
				char *ram = (char*)malloc( infilelen+1 );
				if ( ram )
				{
					zip_fileinfo zinfo;

					memset( &zinfo, 0, sizeof(zip_fileinfo) );
					FileToMem( source, ram, infilelen );

					zipOpenNewFileInZip( zipData, source, &zinfo, 0, 0, 0, 0, NULL, Z_DEFLATED, Z_DEFAULT_COMPRESSION );
					zipWriteInFileInZip( zipData, ram , infilelen );
					zipCloseFileInZip( zipData );
					free( ram );
				}

				if( deletereport )
					remove( source );
				next = next->next;
				count++;
			}

			zipClose( zipData, NULL );
		}

#endif

#if DEF_WINZIP
		{
			ZCL		zipData;
			char	*source;

			memset( &zipData, 0, sizeof(ZCL) );
			zipData.Stdout = stdout;
			zipData.fQuiet = TRUE;
			zipData.fUpdate = TRUE;
			zipData.lpszZipFN = newfilename;		//"C:\install\test.zip";
			zipData.fLevel = 1;
			zipData.FNV = &source;
			zipData.argc = 1;
			while( next && !IsStopped() ){
				perc = ((count*100)/filenum);
				source = (char*)next->data;

				sprintf( msg, "Adding to zip file %s",  FileFromPath( source,0 ) );
				ShowProgress( perc, FALSE, msg );

				ZipUpFiles( &zipData );
				if( deletereport )
					remove( source );
				next = next->next;
				count++;
			}
		}
#endif
	}
}
Exemplo n.º 6
0
INLINE BOOL LoadTaskRegDatabase( VOID )
{
	D_S(struct FileInfoBlock,fib);
	BOOL rc = TRUE;
	STRPTR file;
	
	ENTER();
	
	if((file = FileToMem( DATABASE_FILE, fib, DOSBase )))
		transcode( file, fib->fib_Size );
	
	if(file == NULL)
	{
		LONG ioerr;
		
		if((ioerr = IoErr()) != ERROR_OBJECT_NOT_FOUND)
		{
			ShowIoErrMessage("cannot load database");
			rc = FALSE;
		}
	}
	else if(fib->fib_Size < (LONG)sizeof(ULONG) || *((ULONG *)file) != DATABASE_ID)
	{
		if((rc=CorruptDatabase()))
		{
			FreeVec( file );
			file = NULL;
		}
	}
	
	if( rc == TRUE && file != NULL )
	{
		STRPTR ptr=&file[sizeof(ULONG)];
		LONG size=(fib->fib_Size)-sizeof(ULONG), error = 0;
		
		// this is version 1, hence no more code here atm
		DBG_ASSERT(*((ULONG *)ptr)==DATABASE_VERSION);
		ptr += sizeof(ULONG);
		size -= sizeof(ULONG);
		
		/**
		 * NOTE that since memory pools are being used, I free nothing
		 * when a error happens, hence there is no problem on this code
		 */
		while(!error)
		{
			TaskReg * entry;
			
			if(size < (LONG)sizeof(ULONG)) {
				error = TRUE; break;
			}
			
			if(*((ULONG *) ptr ) == DATABASE_EOFID) break;
			
			if((entry = Malloc(sizeof(TaskReg))))
			{
				GetV( entry->TaskNameLength, UWORD );
				if(error) break;
				
				if((entry->TaskName = Malloc(entry->TaskNameLength+1)))
				{
					GetX( entry->TaskName, entry->TaskNameLength);
					if(error) break;
					
					GetV( entry->allow,    BYTE );
					GetV( entry->remember, BYTE );
					if(error) break;
					
					GetV( entry->RegTime.ds_Days,   ULONG );
					GetV( entry->RegTime.ds_Minute, ULONG );
					GetV( entry->RegTime.ds_Tick,   ULONG );
					GetV( entry->ModTime.ds_Days,   ULONG );
					GetV( entry->ModTime.ds_Minute, ULONG );
					GetV( entry->ModTime.ds_Tick,   ULONG );
					
					GetV( entry->accesses,   ULONG );
					GetV( entry->FileCRC,    ULONG );
					GetV( entry->CRCMods,    UWORD );
					GetV( entry->AlertFlags, UWORD );
					GetV( entry->ServerPort, UWORD );
					if(error) break;
					
					AddTail((struct List *) G->TaskRegList, (struct Node *) entry );
					
					#if DATABASE_RESERVED
					ptr += DATABASE_RESERVED;
					size -= DATABASE_RESERVED;
					#endif
				}
				else error = IoErr();
			}
			else error = IoErr();
		}
		
		if( error != 0 )
		{
			if(error == ERROR_NO_FREE_STORE)
			{
				OutOfMemory("loading database");
				rc = FALSE;
			}
			else if((rc = CorruptDatabase()))
			{
				TaskReg * entry;
				
				entry = (TaskReg *)((struct List *)G->TaskRegList)->lh_Head;
				while(TRUE)
				{
					struct MinNode * succ;
					
					if(entry == NULL) break;
					if(!(succ = ((struct MinNode *)entry)->mln_Succ))
						break;
					
					Remove((struct Node *)entry);
					Free(entry->TaskName);
					Free(entry);
					
					entry = (TaskReg *) succ;
				}
				
				NewList((struct List *) G->TaskRegList );
			}
		}
	}
	
	if( file != NULL )
		FreeVec( file );
	
	RETURN(rc);
	return(rc);
}