diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2020-08-24 21:26:53 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2020-08-24 21:26:53 +0200 |
commit | df247efec654e512242e4f4f1b0212034f9e01fe (patch) | |
tree | 25c02e16957f3aa613af30c140fd8e8a3d52fda6 /app/wlib/mswlib/mswchksm.c | |
parent | d0b6a8a4ec298024f14f704f9e40a6f9d324ccf3 (diff) | |
parent | a5ade52caa489cf0a713e0f02b764000d203140e (diff) |
Merge branch 'release/debian/1%5.2.0Beta2.1-1' into masterHEADdebian/1%5.2.0Beta2.1-1master
Diffstat (limited to 'app/wlib/mswlib/mswchksm.c')
-rw-r--r-- | app/wlib/mswlib/mswchksm.c | 125 |
1 files changed, 0 insertions, 125 deletions
diff --git a/app/wlib/mswlib/mswchksm.c b/app/wlib/mswlib/mswchksm.c deleted file mode 100644 index 602c204..0000000 --- a/app/wlib/mswlib/mswchksm.c +++ /dev/null @@ -1,125 +0,0 @@ -#include <stdio.h> -#include <sys/stat.h> -#include "../include/wlib.h" -#ifdef WINDOWS -#include <windows.h> -#include "mswint.h" -#endif - -#define HEWHDROFFSET (0x3C) - -static FILE * openfile( const char * fn, const char * mode, long * fileSize ) -{ - unsigned short PageCnt; - long FileSize; - FILE *fp; - struct stat Stat; - fp = fopen( fn, mode ); - if (fp == NULL) { - perror( "fopen" ); - return NULL; - } - fread( &PageCnt, sizeof(PageCnt), 1, fp ); /* Read past signature */ - fread( &PageCnt, sizeof(PageCnt), 1, fp ); /* Read past pagesize */ - FileSize = PageCnt; - fread( &PageCnt, sizeof(PageCnt), 1, fp ); /* Read past pagesize */ - if ( FileSize == 0L ) - FileSize = PageCnt * 512L; - else - FileSize += (PageCnt - 1) * 512L; - *fileSize = FileSize; - stat( fn, &Stat ); - *fileSize = (long)Stat.st_size; - fprintf( stderr, "size1 = %ld, size2 = %ld\n", FileSize, (long)Stat.st_size ); - return fp; -} - - -static unsigned short mswCheck16( FILE * fp, long FileSize, unsigned short * sum16stored ) -{ - unsigned short int sum16, NxtInt; - long x; - unsigned char NxtChar; - sum16 = 0; - fseek(fp, 0, SEEK_SET); - - for (x=0L; x<FileSize/2L; x++) { - fread( &NxtInt, sizeof NxtInt, 1, fp ); - if (x == 9) - *sum16stored = NxtInt; - else - sum16 += NxtInt; - } - if (FileSize%2) { - fread( &NxtChar, sizeof NxtChar, 1, fp ); - sum16 += (unsigned int)NxtChar; - } - return sum16; -} - - -static int mswCheck32( FILE * fp, long FileSize, long * sum32off, unsigned long * sum32computed, unsigned long * sum32stored ) -{ - unsigned long sum32, NxtLong; - long x; - long NewHdrOffset; - unsigned char NxtByte, y; - - fseek( fp, HEWHDROFFSET, SEEK_SET ); - fread( &NewHdrOffset, sizeof NewHdrOffset, 1, fp ); - if (NewHdrOffset == 0) { - fprintf( stderr, "NewHdrOffset == 0\n" ); - return 0; - } - NewHdrOffset = (NewHdrOffset/4)*4; - *sum32off = NewHdrOffset + 8; - sum32 = 0L; - fseek( fp, 0, SEEK_SET ); - for (x = ( NewHdrOffset + 8 ) / 4; x; x-- ) { - fread( &NxtLong, sizeof NxtLong, 1, fp ); - sum32 += NxtLong; - } - fread( sum32stored, sizeof sum32stored, 1, fp ); - - for (x=0; x<(FileSize-NewHdrOffset - 12)/4; x++) { - fread( &NxtLong, sizeof NxtLong, 1, fp ); - sum32 += NxtLong; - } - if ( 0L != (x=FileSize%4L) ) { - NxtLong = 0L; - for (y=0; y<x; y++ ) { - fread( &NxtByte, sizeof NxtByte, 1, fp ); - NxtLong += (unsigned long)NxtByte << (8*y); - } - sum32 += NxtLong; - } - *sum32computed = sum32; - return 1; -} - - -#ifdef WINDOWS -wBool_t wCheckExecutable( void ) -{ - char fileName[1024]; - FILE * fp; - long FileSize; - GetModuleFileName( mswHInst, fileName, sizeof fileName ); - fp = openfile( fileName, "rb", &FileSize ); -#ifdef LATER - { - unsigned long int sum32offset, sum32computed, sum32stored; - if ( ! mswCheck32( fp, FileSize, &sum32offset, &sum32computed, &sum32stored ) ) - return FALSE; - return sum32computed == sum32stored; - } -#else - { - unsigned short int sum16computed, sum16stored; - sum16computed = mswCheck16( fp, FileSize, &sum16stored ); - sum16computed += sum16stored; - return sum16computed == 0xFFFF; - } -#endif -} -#endif |