Skip to content

Commit

Permalink
Add icon to exe file in windows export
Browse files Browse the repository at this point in the history
add version_info and icon sections in "export to windows platform".
add version_info and icon to godot exe file (editor & template exe).
fix an problem in image class.
change all default icons to android export icon (a little more rounded).
create an python script for convert file to cpp byte array for use in
'splash.h'.
  • Loading branch information
masoudbh3 committed Nov 8, 2015
1 parent 3fcfdfe commit 24f3f43
Show file tree
Hide file tree
Showing 103 changed files with 17,091 additions and 11 deletions.
2 changes: 1 addition & 1 deletion core/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ void Image::set_pallete(const DVector<uint8_t>& p_data) {
DVector<uint8_t>::Write wp = data.write();
unsigned char *dst=wp.ptr() + pal_ofs;

DVector<uint8_t>::Read r = data.read();
DVector<uint8_t>::Read r = p_data.read();
const unsigned char *src=r.ptr();

copymem(dst, src, len);
Expand Down
1 change: 1 addition & 0 deletions drivers/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ if (env["opus"]=="yes"):
SConscript('opus/SCsub');
if (env["tools"]=="yes"):
SConscript("convex_decomp/SCsub");
SConscript('pe_bliss/SCsub');

#if env["theora"]=="yes":
# SConscript("theoraplayer/SCsub")
Expand Down
61 changes: 61 additions & 0 deletions drivers/pe_bliss/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
Открытая бесплатная библиотека для работы с PE-файлами PE Bliss.
Бесплатна к использованию, модификации и распространению.
Автор: DX
(c) DX 2011-2012, kaimi.ru

Совместимость: Windows, Linux

Возможности:
[+] Создание PE или PE+ файла с нуля
[+] Чтение 32-разрядных и 64-разрядных PE-файлов (PE, PE+) и единообразная работа с ними
[+] Пересборка 32-разрядных и 64-разрядных PE-файлов
[+] Работа с директориями и заголовками
[+] Конвертирование адресов
[+] Чтение и редактирование секций PE-файла
[+] Чтение и редактирование таблицы импортов
[+] Чтение и редактирование таблицы экспортов
[+] Чтение и редактирование таблиц релокаций
[+] Чтение и редактирование ресурсов
[+] Чтение и редактирование TLS
[+] Чтение и редактирование конфигурации образа (image config)
[+] Чтение базовой информации .NET
[+] Чтение и редактирование информации о привязанном импорте
[+] Чтение директории исключений (только PE+)
[+] Чтение отладочной директории с расширенной информацией
[+] Вычисление энтропии
[+] Изменение файлового выравнивания
[+] Изменение базового адреса загрузки
[+] Работа с DOS Stub'ом и Rich overlay
[+] Высокоуровневое чтение ресурсов: картинки, иконки, курсоры, информация о версии, строковые таблицы, таблицы сообщений
[+] Высокоуровневое редактирование ресурсов: картинки, иконки, курсоры, информация о версии

[English]
Open a free library for working with PE-file PE Bliss.
Free to use, modify, and distribute.
Author: DX
(c) DX 2011-2012, kaimi.ru
Compatibility: Windows, Linux

### Capabilities:
[+] Creation of PE or PE + file from scratch
[+] Reading the 32-bit and 64-bit PE-file (PE, PE +) and uniform working with them
[+] Rebuild 32-bit and 64-bit PE-files
[+] Working with the directors and titles
[+] Converting addresses
[+] Reading and editing sections of PE-file
[+] Reading and editing the import table
[+] Reading and editing tables exports
[+] Reading and editing tables relocations
[+] Reading and editing resources
[+] Reading and editing TLS
[+] Reading and editing the configuration of the image (image config)
[+] Reading data base .NET
[+] Reading and editing information about tethered import
[+] Read the directory exceptions (only PE +)
[+] Read debug directories with extended information
[+] The calculation of entropy
[+] Changing file alignment
[+] Change the base load address
[+] Support of DOS Stub'om and Rich overlay
[+] High-level reading resources: images, icons, cursors, version information, string tables, message table
[+] High-level editing resources: images, icons, cursors, version information
5 changes: 5 additions & 0 deletions drivers/pe_bliss/SCsub
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Import('env')

env.add_source_files(env.drivers_sources,"*.cpp")

Export('env')
90 changes: 90 additions & 0 deletions drivers/pe_bliss/entropy.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#include <cmath>
#include "entropy.h"
#include "utils.h"

namespace pe_bliss
{
//Calculates entropy for PE image section
double entropy_calculator::calculate_entropy(const section& s)
{
if(s.get_raw_data().empty()) //Don't count entropy for empty sections
throw pe_exception("Section is empty", pe_exception::section_is_empty);

return calculate_entropy(s.get_raw_data().data(), s.get_raw_data().length());
}

//Calculates entropy for istream (from current position of stream)
double entropy_calculator::calculate_entropy(std::istream& file)
{
uint32_t byte_count[256] = {0}; //Byte count for each of 255 bytes

if(file.bad())
throw pe_exception("Stream is bad", pe_exception::stream_is_bad);

std::streamoff pos = file.tellg();

std::streamoff length = pe_utils::get_file_size(file);
length -= file.tellg();

if(!length) //Don't calculate entropy for empty buffers
throw pe_exception("Data length is zero", pe_exception::data_is_empty);

//Count bytes
for(std::streamoff i = 0; i != length; ++i)
++byte_count[static_cast<unsigned char>(file.get())];

file.seekg(pos);

return calculate_entropy(byte_count, length);
}

//Calculates entropy for data block
double entropy_calculator::calculate_entropy(const char* data, size_t length)
{
uint32_t byte_count[256] = {0}; //Byte count for each of 255 bytes

if(!length) //Don't calculate entropy for empty buffers
throw pe_exception("Data length is zero", pe_exception::data_is_empty);

//Count bytes
for(size_t i = 0; i != length; ++i)
++byte_count[static_cast<unsigned char>(data[i])];

return calculate_entropy(byte_count, length);
}

//Calculates entropy for this PE file (only section data)
double entropy_calculator::calculate_entropy(const pe_base& pe)
{
uint32_t byte_count[256] = {0}; //Byte count for each of 255 bytes

size_t total_data_length = 0;

//Count bytes for each section
for(section_list::const_iterator it = pe.get_image_sections().begin(); it != pe.get_image_sections().end(); ++it)
{
const std::string& data = (*it).get_raw_data();
size_t length = data.length();
total_data_length += length;
for(size_t i = 0; i != length; ++i)
++byte_count[static_cast<unsigned char>(data[i])];
}

return calculate_entropy(byte_count, total_data_length);
}

//Calculates entropy from bytes count
double entropy_calculator::calculate_entropy(const uint32_t byte_count[256], std::streamoff total_length)
{
double entropy = 0.; //Entropy result value
//Calculate entropy
for(uint32_t i = 0; i < 256; ++i)
{
double temp = static_cast<double>(byte_count[i]) / total_length;
if(temp > 0.)
entropy += std::abs(temp * (std::log(temp) * pe_utils::log_2));
}

return entropy;
}
}
30 changes: 30 additions & 0 deletions drivers/pe_bliss/entropy.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#pragma once
#include <istream>
#include "pe_base.h"

namespace pe_bliss
{
class entropy_calculator
{
public:
//Calculates entropy for PE image section
static double calculate_entropy(const section& s);

//Calculates entropy for istream (from current position of stream)
static double calculate_entropy(std::istream& file);

//Calculates entropy for data block
static double calculate_entropy(const char* data, size_t length);

//Calculates entropy for this PE file (only section data)
static double calculate_entropy(const pe_base& pe);

private:
entropy_calculator();
entropy_calculator(const entropy_calculator&);
entropy_calculator& operator=(const entropy_calculator&);

//Calculates entropy from bytes count
static double calculate_entropy(const uint32_t byte_count[256], std::streamoff total_length);
};
}
Loading

0 comments on commit 24f3f43

Please sign in to comment.