initial
This commit is contained in:
16
utils/newdat/_vpc_/manifest_newdat/win32/manifest.txt
Normal file
16
utils/newdat/_vpc_/manifest_newdat/win32/manifest.txt
Normal file
@@ -0,0 +1,16 @@
|
||||
// ----------------------------------------- //
|
||||
// File generated by VPC //
|
||||
// ----------------------------------------- //
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\public\tier0\memoverride.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\public\tier0\memoverride.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\public\tier0\memoverride.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
Source file: F:\csgo_64\cstrike15_src\utils\newdat\newdat.cpp
|
||||
Debug output file: F:\csgo_64\cstrike15_src\utils\newdat\newdat.cpp
|
||||
Release output file: F:\csgo_64\cstrike15_src\utils\newdat\newdat.cpp
|
||||
Containing unity file:
|
||||
PCH file:
|
||||
|
||||
183
utils/newdat/newdat.cpp
Normal file
183
utils/newdat/newdat.cpp
Normal file
@@ -0,0 +1,183 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Makes .DAT files
|
||||
//
|
||||
// $Workfile: $
|
||||
// $Date: $
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
// $Log: $
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include "basetypes.h"
|
||||
#include "checksum_md5.h"
|
||||
#include "tier1/strtools.h"
|
||||
|
||||
void Sys_Error( char *fmt, ... );
|
||||
extern void Con_Printf( char *fmt, ... );
|
||||
|
||||
// So we can link CRC
|
||||
int LittleLongFn( int l );
|
||||
|
||||
|
||||
// So we can link CRC
|
||||
void Sys_Error( char *fmt, ... )
|
||||
{
|
||||
va_list args;
|
||||
va_start( args, fmt );
|
||||
vprintf( fmt, args );
|
||||
exit(0);
|
||||
}
|
||||
|
||||
// So we can link CRC
|
||||
int COM_FindFile( char *filename, FILE **file )
|
||||
{
|
||||
if ( file )
|
||||
{
|
||||
*file = fopen( filename, "rb" );
|
||||
if ( *file )
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// So we can link CRC
|
||||
int LittleLongFn( int l )
|
||||
{
|
||||
return l;
|
||||
}
|
||||
|
||||
// So we can link CRC
|
||||
void Con_Printf( char *fmt, ... )
|
||||
{
|
||||
va_list args;
|
||||
va_start( args, fmt );
|
||||
vprintf( fmt, args );
|
||||
}
|
||||
|
||||
bool MD5_Hash_File(unsigned char digest[16], char *pszFileName, bool bUsefopen /* = FALSE */, bool bSeed /* = FALSE */, unsigned int seed[4] /* = NULL */)
|
||||
{
|
||||
FILE *fp;
|
||||
byte chunk[1024];
|
||||
int nBytesRead;
|
||||
MD5Context_t ctx;
|
||||
|
||||
int nSize;
|
||||
|
||||
if (!bUsefopen)
|
||||
{
|
||||
nSize = COM_FindFile(pszFileName, &fp);
|
||||
if ( !fp || ( nSize == -1 ) )
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
fp = fopen( pszFileName, "rb" );
|
||||
if ( !fp )
|
||||
return false;
|
||||
|
||||
fseek ( fp, 0, SEEK_END );
|
||||
nSize = ftell ( fp );
|
||||
fseek ( fp, 0, SEEK_SET );
|
||||
|
||||
if ( nSize <= 0 )
|
||||
{
|
||||
fclose ( fp );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
memset(&ctx, 0, sizeof(MD5Context_t));
|
||||
|
||||
MD5Init(&ctx);
|
||||
|
||||
if (bSeed)
|
||||
{
|
||||
// Seed the hash with the seed value
|
||||
MD5Update( &ctx, (const unsigned char *)&seed[0], 16 );
|
||||
}
|
||||
|
||||
// Now read in 1K chunks
|
||||
while (nSize > 0)
|
||||
{
|
||||
if (nSize > 1024)
|
||||
nBytesRead = fread(chunk, 1, 1024, fp);
|
||||
else
|
||||
nBytesRead = fread(chunk, 1, nSize, fp);
|
||||
|
||||
// If any data was received, CRC it.
|
||||
if (nBytesRead > 0)
|
||||
{
|
||||
nSize -= nBytesRead;
|
||||
MD5Update(&ctx, chunk, nBytesRead);
|
||||
}
|
||||
|
||||
// We we are end of file, break loop and return
|
||||
if ( feof( fp ) )
|
||||
{
|
||||
fclose( fp );
|
||||
fp = NULL;
|
||||
break;
|
||||
}
|
||||
// If there was a disk error, indicate failure.
|
||||
else if ( ferror(fp) )
|
||||
{
|
||||
if ( fp )
|
||||
fclose(fp);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if ( fp )
|
||||
fclose(fp);
|
||||
|
||||
MD5Final(digest, &ctx);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: newdat.exe - makes the .DAT signature for file / virus checking
|
||||
// Input : argc - std args
|
||||
// *argv[] -
|
||||
// Output : int 0 == success. 1 == failure
|
||||
//-----------------------------------------------------------------------------
|
||||
int main( int argc, char *argv[] )
|
||||
{
|
||||
char out[512], datFile[512];
|
||||
unsigned char digest[16];
|
||||
|
||||
if ( argc < 2 )
|
||||
{
|
||||
printf("USAGE: newdat <filename>\n" );
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
// Get the filename without the extension
|
||||
Q_StripExtension( argv[1], out, sizeof( out ) );
|
||||
sprintf( datFile, "%s.dat", out );
|
||||
|
||||
// Build the MD5 hash for the .EXE file
|
||||
MD5_Hash_File( digest, argv[1], TRUE, FALSE, NULL );
|
||||
|
||||
// Write the first 4 bytes of the MD5 hash as the signature ".dat" file
|
||||
FILE *fp = fopen( datFile, "wb" );
|
||||
if ( fp )
|
||||
{
|
||||
fwrite( digest, sizeof(int), 1, fp );
|
||||
fclose( fp );
|
||||
printf("Wrote %s\n", datFile );
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
printf("Can't open %s\n", datFile );
|
||||
|
||||
return 1;
|
||||
}
|
||||
32
utils/newdat/newdat.vpc
Normal file
32
utils/newdat/newdat.vpc
Normal file
@@ -0,0 +1,32 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// NEWDAT.VPC
|
||||
//
|
||||
// Project Script
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
$Macro SRCDIR "..\.."
|
||||
$Macro OUTBINDIR "$SRCDIR\..\game\bin"
|
||||
|
||||
$Include "$SRCDIR\vpc_scripts\source_exe_con_win32_base.vpc"
|
||||
|
||||
$Configuration
|
||||
{
|
||||
$Compiler
|
||||
{
|
||||
$PreprocessorDefinitions "$BASE;PROTECTED_THINGS_DISABLE"
|
||||
}
|
||||
}
|
||||
|
||||
$Project "Newdat"
|
||||
{
|
||||
$Folder "Source Files"
|
||||
{
|
||||
$File "newdat.cpp"
|
||||
}
|
||||
|
||||
$Folder "Header Files"
|
||||
{
|
||||
$File "$SRCDIR\public\tier0\basetypes.h"
|
||||
$File "$SRCDIR\public\tier1\checksum_md5.h"
|
||||
}
|
||||
}
|
||||
13
utils/newdat/newdat.vpc.vpc_cache
Normal file
13
utils/newdat/newdat.vpc.vpc_cache
Normal file
@@ -0,0 +1,13 @@
|
||||
"vpc_cache"
|
||||
{
|
||||
"CacheVersion" "1"
|
||||
"win32"
|
||||
{
|
||||
"CRCFile" "newdat.vcxproj.vpc_crc"
|
||||
"OutputFiles"
|
||||
{
|
||||
"0" "newdat.vcxproj"
|
||||
"1" "newdat.vcxproj.filters"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user