-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmain.cpp
More file actions
32 lines (30 loc) · 905 Bytes
/
Copy pathmain.cpp
File metadata and controls
32 lines (30 loc) · 905 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "pe_parser.h"
#include <locale.h>
int main( int argc, char** argv )
{
UINT codePage = GetConsoleOutputCP( );
SetConsoleOutputCP( CYRILLIC_CODE_PAGE ); // set code page to display russian symbols
setlocale( LC_ALL, "Russian" );
HANDLE fileHandle = GetFileFromArguments( argc, argv );
if( NULL != fileHandle )
{
DWORD fileSize = CheckFileSizeForCorrectness( GetFileSize( fileHandle, NULL ) );
if( INVALID_FILE_SIZE != fileSize )
{
char* buffer = ( char* ) malloc( fileSize );
int readSize = ReadFileToBuffer( fileHandle, buffer, fileSize );
if( readSize != fileSize )
{
printf( CAN_NOT_READ_ENTIRE_FILE );
}
else
{
ChangeEntryPoint( buffer, fileSize, argv[ 0x01 ] );
}
free( buffer );
}
CloseHandle( fileHandle );
}
SetConsoleOutputCP( codePage ); // restore code page
return 0x00;
}