C++ :: Parse Executable Files - Registering Types To Be Used At Runtime

Jul 30, 2014

I'm writing a program that needs to parse executable files. I've got an "executable" base-class, and currently an "elf" class which inherits from it for parsing ELF files, and I will add more parsers (COM, MZ, PE, a.out, MACH-O, whatever) later on.

I want the program to automatically detect which kind of executable it's loading at runtime. It should be easy because every executable format I'm aware of/plan to support starts with a magic number. But because I can't have the parsers not check the file type (what if I re-use the code?), and I don't want to check each file twice (not just for performance, but also because only the ELF parser should know that ELF files start with "x7fELF", etc.) so I've come up with a pretty lazy solution: just try to parse the file with each known parser and have them throw an exception ("exe_type_error") if they can't parse it. If that exception gets thrown, try the next parser; if not, stop.

The remaining problem is how, at runtime, my program will know what parsers are available. I don't want to hard-code it in the main function; instead, I'd like the parsers to "register" themselves as available. That way, if I decide to go down the route of adding new parsers via dynamic linking, I will only have to add an API for dynamic libraries to register their parser, without recompiling any of the main program's code. I also want to do the same thing for another key part of the program (it's a static executable optimizer; it will run a series of "tests" (e.g. "is xor eax, eax faster than mov eax, 0 on this machine?") and optimizations ("if yes, change all mov eax, 0 to xor eax, eax") and I want to load those at runtime too).

View 11 Replies


ADVERTISEMENT

C++ :: Sharing A Program - Sending Executable Files

May 22, 2013

I am just wondering if it is possible to send a project to someone via email - In a simple way, almost like you would install software from the internet, maybe a setup file, or something. The compiler I use "Dev C++" creates a .cpp file and an executable. Unfortunately, I cannot send that .exe file. How would you recommend sharing a program?

View 5 Replies View Related

C :: Read Enormous Binary Files (10-100GB) And Parse Their Contents Bit At A Time

Dec 5, 2013

I am trying to read enormous binary files (10-100GB) and parse their contents a bit at a time. As part of the process I need to get the size of the file in bytes. The simple solution

Code: fseek(file,0,SEEK_END);
size=ftell(file);

fails because the file size overflows the long int type returned by ftell. I need a long long int.

Is there a reasonably efficient way to do this? The good news is that it only needs to be done once. I suppose I could read it one character at a time until I hit the end and keep count, but that just seems inelegant...

View 12 Replies View Related

C++ :: Program Needs To Compile Various Source Files At Runtime

Oct 30, 2014

My program needs to compile various source files at runtime.What is the most elegant way to compile cross platform with g++ from within my program? Is there a gcc-library I can use? I know that I could use popen() to open a Unix pipe and call g++ as command line tool. But first it isn't really cross platform and second it doesn't seem elegant to me.

View 10 Replies View Related

Visual C++ :: Adding Header And Lib Files At Runtime?

Feb 4, 2013

I was created a dynamic library (Used win32 App) & compiled with no error.

Then i was created my main application (MFC) & paste the .h,.lib,.dll files from the source path(dll App Path) to destination path(Main App Path). If i used the below command in my app means the project working good.

Code:
#include "Alg.h"
#Progma Command(lib, "VTAlg.lib")
& also paste the VTAlg.dll in my app path.

here Alg.h contains the some methods , In future i will edit the function like below for my client requirement but no function name & Arguments change. The changes made in inside function(Logically changed) only.

My client contains only .exe file + .dll file.

My requirement, So after change the method i will send only .dll file to my client

If i change my lib file name VTAlg2.lib instead of VTAlg1.lib (But Same Function name & Arg type)means how can i edit the code below

Code:
#include "Alg.h"
#Progma Command(lib, "VTAlg.lib")

& How to run my application at client place.

View 14 Replies View Related

C++ :: Naming Files And Making File Types?

May 12, 2013

How to deal with files and I wanted to make a way for the user to make his own file name and then I want it to be a .txt file, so I take the fileName variable after the user has created a name for it then add ".txt" for the file type then convert the string to a constant char for the open method.

#include <iostream>
#include <fstream>
#include <sstream>
using namespace std;
int main() {

ofstream fileObject; // ofstream object to read/write to and from file

[Code] ....

View 2 Replies View Related

C++ :: How To Create Unique Types Like That Of Boost Files

Apr 5, 2013

I've been studying metaprogramming and reviewing many documents and code regarding boost files. What I've been trying to understand and accomplish is creating various types using typedef, template and struct, similar to that of the boost files themselves, to create comparators. Ultimately, I want to be able to create a type that has sub-properties which can be further compared and classified.

Informal example:

create type
typedef int coordinate[3];
create standards - "typeless prototypes"
static const coordinate _x = {1,0,0};
static const coordinate _y = {0,1,0};
static const coordinate _z = {0,0,1};

We "now have" three variables under one unique type. Now I want to wrap this further to work with other types (int, float, etc.).

create special cases

template<class ty, coordinate c> struct coord_type;
typedef coord_type<int,x> x_i;
typedef coord_type<float,x> x_f;
typedef coord_type<int,y> y_i;
typedef coord_type<float,y> y_f;
typedef coord_type<int,z> z_i;
typedef coord_type<float,z> z_f;

declare more standards

const x_i i_i;
const x_f i_f;
const y_i j_i;
const y_f j_f;
const z_i k_i;
const z_f k_f;

Where other variables can be represented based off this i,j,k standard and written in a more direct vector form.

And so on...

What I essentially would like to do is have x,y,z variables act as standards for an i,j,k system that classify arbitrary variables of the coordinate type: Is the arbitrary variable i, j, or k? Is it defined as an int or float type?

Where arguments such as sum_y = var1 + var2; are valid, provided:
sum_y is outputted as 6j, and var1 and var2 are 2j and 4j, respectively.

View 9 Replies View Related

Visual C++ :: Using COM Without Registering?

Mar 5, 2013

In a C++ project, I need to call a C# created COM object (as a .dll)

Is there a way to use such a COM object without having it be registered in the registry?

The C# COM dll is just a "go between" our C++ code and a .NET library, there's no "COM contract" of any kind, the COM interfaces change each version. The fact it's COM and needs registration is annoying because it makes it hard to have multiple versions of our software installed (needed under some circumstances) and running at the same time.

I'd like a way to not have any registration at all. And just be able to do a LoadLibrary("c:TheRightPathcom.dll") of the right dll and then get going from there.

View 14 Replies View Related

C++ :: Creating Events And Registering To Them

Mar 16, 2014

I want to build a library using c++ which will serve as an abstraction layer between applications and low-level process. The library will provide some APIs for the applications for some purposes.

For example the low-level process, may send an indication to the library i.e. raise an event, and the library in turns send it to all the applications, which have their registered callbacks to this library.

Any example for the previous scenario in c++ using boost library or the standard library will be perfect in Linux environment? The example that I want is: Generate event from a process and pass it to the library, then let an application register callback to the library.

Initially I know in Linux, I may use signal to send events, but my plan is to have a something more general not tighten to a specific OS.

View 1 Replies View Related

C :: Parameter Names Without Types And Conflicting Types In Fgets

Jan 22, 2014

I have this

Code:

#include<stdio.h>
#include<ctype.h>
#include<string.h>

int check_up(char string[]);
int check_low(char string[]);
void to_up(char string[]);
void to_low(char string[]);

[Code] .....

When I compile this I have the following problems: warning: data definition has no type or storage class [enabled by default] in 'to_up(word)'conflicting types in 'to_up' function and to_low function warning: data definition has no type or storage class [enabled by default] into_up function error: unknown type name "word" in line 'printf("All uppercase %s. ", word):;'warning: parameter names (without types) in function declaration [enabled by default] in 'to_up(word)'and 'to_low(word)' 'note: previous declaration of "to_up" was here in function declaration of to_up function

View 7 Replies View Related

C++ :: Print All Usernames After Registering With Text

Oct 28, 2013

this is my code, the program has to ask for the number of usernames I want to create, then you type the username and password. after you do it 4 times (maximum) it prints (make a button to print the list) the username and password of each

#include <iostream>
#include <fstream>
#include <string>

[Code].....

View 1 Replies View Related

Visual C++ :: Error In Registering Windows Class

Jan 28, 2013

The following code it taken from msdn library but it is failing to compile.

the following code has a header where all the variables used here are stored in header App.h.

The following lines are giving trouble:

Code:
DialogBox(pApp->getInstance(), MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, pApp->About);
error: 'App::About': function call missing argument list; use '&App::About' to create a pointer to member

Code:
wcex.lpfnWndProc= &App::WndProc;
error: '=' : cannot convert from 'LRESULT (__stdcall App::* )(HWND,UINT,WPARAM,LPARAM)' to 'WNDPROC'

There is no context in which this conversion is possible

Here is the complete code:

#include "stdafx.h"
#include "App.h"
App::App(void) {
}
App::~App(void) {

[Code] .....

View 4 Replies View Related

Visual C++ :: Shell (Namespace) Extension Not Registering?

Dec 13, 2012

I have created a Namespace Extension (I hope so) by creating a ATL Project with MFC support as dll in Visual Studio 2010.

Now I have a Implementation of IShellFolder:

Code:
// ILCShellFolder.h: Deklaration von CILCShellFolder
#pragma once
#include "resource.h" // Hauptsymbole
#include "NewNSE_i.h"
#if defined(_WIN32_WCE) && !defined(_CE_DCOM) && !defined(_CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA)

[Code] ....

Not any of those IShellFolder Methods is being called... When I attach the explorer.exe process (which I know I can use to debug on other projects, just in case to exclude errors) it tells me that the DLL is not loaded by the explorer.exe process.

View 1 Replies View Related

C++ :: Using Resources In Executable?

Sep 8, 2014

i have seen a lot of programs that have images inside their exe, dont use external ones. I tried to add image in my codeblocks project, but trying to use it failed. It seems that to use a resource i have to add some kind of header file, but how to do this???

View 2 Replies View Related

C/C++ :: Executable Performance When Using TCHAR

Aug 16, 2014

I have started to move over to using Unicode, wide character null-terminated strings in my Windows programmes. Accordingly I set the Use Unicode Character Set Visual C++ compiler option. It is my understanding that once you do that the many macros which determine whether you transparently call ...A() or ...W() API functions automatically shift over to calling the wide character variants. As this is a compiler directive, all the choices are made and hardcoded in to the resultant executable at compile/link-time BEFORE it is ever run. Therefore using for example the macro OpenFileName() in the source code instead of specifically calling OpenFileNameW() has no impact on run-time performance.

The next logical step, instead of explicitly using wchar_t is to declare null-terminated string character arrays as TCHAR*. Then, so long as I also employ the tcn... variants of CRT string functions and call TEXT() or _T() macros to create string literals the preprocessor will chose, again transparently whether to create an executable using standard multibyte or unicode wide characters - and their associated functions - all determined by the Use Unicode Character Set switch. That way I can cover both eventualities with the same source code.

So, with all that - I THINK!!! - properly under by belt, I am fairly sure that using TCHAR and its friends will not effect run-time performance at all. However, in his otherwise excellent article the author makes it sound as if using Unicode EXPLICITLY through wchar_t, ...W() API functions and tcn... CRT calls is faster than the TCHAR alternative.

At the end of the day my question is - have I got the right end of the stick; TCHAR makes no difference to executable performance?

View 4 Replies View Related

C/C++ :: Debug Executable That Needs Flags

Mar 20, 2015

I'm trying to step through the machine instructions of a c program. This program needs to be run with a -t flag.

This is what I tried
gdbtui
file prog
layout asm
start
stepi

When I try 'file prog -t' it doesn't work.

View 4 Replies View Related

C++ :: GUI That Will Allow User To Conveniently Invoke Executable

Feb 12, 2013

I use g++ compiler and need some tips on how to get started with making a c++ GUI. The project I have will need a gui that will allow the user to conveniently invoke executable (the command-line args they take are long and inconvenient to enter manually) and basically print their output streams into a control (e.g. read only textbox). There will be a few graphics involved too (the input for those graphics will be from a file), so I'll need a library that will allow drawLine methods (nothing too fancy, I don't need a gaming library).

Making a GUI in c++. In Java the ability to make a GUI is a part of the native library, so the c++ way seems foreign to me.

View 2 Replies View Related

Visual C++ :: Prevent Executable From Running?

Aug 30, 2013

I would like to programmatically monitor a directory for new files, and if the file happens to be an executable, I want to prevent it from running. Something like a AV program.

However, I don't know where to start. Simple is best.

View 9 Replies View Related

C/C++ :: Eclipse Terminating Executable After Adding A Bit Of Code

Feb 3, 2014

I have the following code

#include "../header/FileIO.hpp"
#include <fstream>
#include <stdexcept>
#include <iostream>
std::string FileIO::ReadTXT(std::string filePath){
std::ifstream input(filePath.c_str());

[Code] ....

When I run it in Eclipse, it does not open an SDL window, and simply says <Terminated> Test.exe [C/C++ Application]. I can build the project successfully, but it simply won't run. There are no errors displayed.

HOWEVER, if I replace the above code with the code below, it runs fine, and creates an SDL window.

#include "../header/FileIO.hpp"
#include <fstream>
#include <stdexcept>
#include <iostream>
std::string FileIO::ReadTXT(std::string filePath) {
std::string output;
return output;
}

To make things weirder, if I run it in debug mode, even with the first piece of code, it will run and open an SDL window.

On an unrelated note, what does " Can't find a source file at "e:pgiawsrcpkgmingwrt-4.0.3-1-mingw32-srcld/../mingwrt-4.0.3-1-mingw32-src/src/libcrt/crt/main.c"

Locate the file or edit the source lookup path to include its location." mean? I am using Windows 8, MinGW, GDB 7.6.1-1, G++ 4.8.1-4, and MSYS 1.0.1 with Eclipse CDT.

View 3 Replies View Related

C++ :: How To Create Final Executable File That Can Upload For Users

Feb 16, 2013

I develop a software using QT 5 open source IDE. Now my question is two-fold:

1. How can I create the final executable file that I can upload for my users? I understand that runtime DLLs shall be required and I have tried Enigma Virtual Box software for bundling runtime files. It does create the file that I can execute from any folder in my PC. However, surprisingly when I transfer that "boxed" file to another PC, it does not run. Both the PCs have Windows 7 installed on them.

2. Secondly, I see possible future issues with Antivirus Softwares. Apparently when I try to run the boxed exe file, it gets rejected by the Antivirus Software on my PC. Is there a way in which I can get my exe file verified/checked/registered by the Antivirus Softwares so that my users don't face any problems in executing the program.

I cannot afford the QT commercial licence, but I am prepared to buy any economical "setup file generating" software (if it exists).

View 1 Replies View Related

C++ :: ReadFile Function Cannot Read Entire Executable File

Mar 30, 2014

I am writing a program which compresses files into .zip files.

Here's my problem: Whenever I want to compress an executable file, my readFile function does not read the entire file. When I extract the .exe I get a very tiny and incomplete file.

Here's the function I use to read files:

std::string miniz_wrapper::readFile(FILE* f, int MAX_FILEBUFFER)
//MAX_FILEBUFFER has a default value of 65536 {
char* tmp;
std::string tmp_s;
int count = 0;

[Code] .....

Prior to reading, every file is opened using fopen with the mode "rb".

View 6 Replies View Related

C++ :: Reducing The Size Of A Compiled Executable For Easier Distribution?

Jun 19, 2014

I am looking at reducing the size of a compiled executable for easier distribution.

What factors affect the size of an output executable?

Would literally having defined and implemented less functions, would make the exec. smaller? Meaning that instead of have a DLL ( yes im on windows ), I would download the source code of a library and comment out the functions ( and code ) that I am not using -- Would this process decrease the size of my exec.?

View 2 Replies View Related

C++ :: Sending Dynamic Allocated 2D Array Over Named Pipe Between 2 Executable

Oct 6, 2014

Im writing a scientific software where I like to sent a 2D array (5x4) over a named pipe from a server to a client. When im sending a static array (i.e., double res[5][4];), all goes fine and it works perfect, but when I allocate a dynamic array, it provides some nonsense numbers at the client side. I feel it might be caused because I point to a memory that cannot be shared through a pipe. Am I right and how can I pass the dynamic allocated array itself over the pipe.

//Server program

// Create a pipe to send/receive data
HANDLE pipe = CreateNamedPipe(
"\.pipemy_pipe", // name of the pipe
PIPE_ACCESS_DUPLEX, // 2-way pipe -- send and read
PIPE_TYPE_BYTE, // send data as a byte stream
1, // only allow 1 instance of this pipe
0, // no outbound buffer

[Code] .....

View 2 Replies View Related

C++ :: Turn Binary File Data Into Unsigned Character Array For Inclusion In Executable

Jul 10, 2013

So I wrote a program to turn a binary file's data into an unsigned character array for inclusion in an executable. It works just super.

I'm wondering how I can write a program that will perform this operation on every file in a directory and all it's sub-directories so that I can I can include everything I need all at ounce.

View 9 Replies View Related

C++ :: How To Parse EML File

Aug 28, 2014

I am doing a project processing emails in EML format. I searched for a library doing eml file parsing and got no hits. I really dont want to code the parser myself. I just want to get the project done with minimize cost. Which library should I use?

View 4 Replies View Related

C :: Parse Error / What Value Does Get Assigned

Dec 10, 2013

I get the following parsing error for the code

Code:

#include <stdio.h>

int main()
{
int i=3,4;
printf("%d",i);
return 0;
}

what is wrong with the code? I have put initialize value as 3,4 just to understand what value does i gets assigned.

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved