|
How to import a file into PE header of an exe then load that file from within modified exe
i searched CP about this but found nothing relevant
the articles i found were mostly code injection based
simply i want to import a file ( ex: BMP) into PE header of a compiled exe
then read this file through a predefined function from within compiled exe
is it possible , if possible could you show me how to do
thanks
|
|
|
|
|
only_jack wrote: simply i want to import a file ( ex: BMP) into PE header of a compiled exe
If you mean do this at run time then, no it is not possible. Perhaps you are thinking of embedding a file in your program's resources, in which case see here[^].MVP 2010 - are they mad?
|
|
|
|
|
no , i will compile exe and then create another program to import specified file to compiled exe , target exe will not work at this time
i want to implement a simple compiler for my own use
i have a program that parses a custom file format
currently i am importing files to resource section already
through another program that i made
so select file and import into resource section of target exe
then i run modified exe it will load that file from resource and execute
resource method works very well but i do not find it secured enough
i want to implement some thing with PE headers
now i want to import file into PE header of a precompiled exe and then read at runtime , through functions i wrote before compile target exe
|
|
|
|
|
only_jack wrote: resource method works very well but i do not find it secured enough
The BMP file you want to insert is that sensitive?
Once you replace the PE headers with some other file, that modified file will no longer function. So what purpose does it serve?
The cynic in me smells a Trojan horse (i.e., trying to hide the nefarious file from AV software by wrapping it with some other legitimate file)."One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
DavidCrow wrote: The cynic in me smells a Trojan horse (i.e., trying to hide the nefarious file from AV software by wrapping it with some other legitimate file).
Bingo.L u n a t i c F r i n g e
|
|
|
|
|
why are you getting all wrong
DavidCrow wrote: The BMP file you want to insert is that sensitive?
BMP was an example i will use something else , maybe you forget to do your glasses while reading my question
DavidCrow wrote: Once you replace the PE headers with some other file, that modified file will no longer function. So what purpose does it serve?
i never said that i want to replace
i want to replace nothing , i want to import a new section
DavidCrow wrote: The cynic in me smells a Trojan horse (i.e., trying to hide the nefarious file from AV software by wrapping it with some other legitimate file).
why i will do this for a malicious purpose , all of AVs can scan PE headers you should know this as a MVP ,
if i want to hide a file from user or AVs , i can easily import it to a
NTFS portion as a ADS but i am killing my hours against them
if i was looking for some malicious resources trust me i can find them on the net in few seconds , even in codeproject site
there are lots of articles like how to inject your code to another process maybe first you should check those articles firs which you approved and publised
finally , i will explain it a bit more
the compiled exe uses a %80 modified Lua interpreter do you know Lua
and i am importing some modified Lua scripts in to compiled exe's resources
and then i am getting these scripts through resource API functions
then redirect the file buffer to luaL_loadbuffer() function of LUA C API
interpreter parses this file and generates some reports
so i am uploading this file to FTP and users download it priodically and run to get some report about a main program ,and it will edit some portions of main installition if necessary with user's permission (i hope now you do not get this like i am making a pacher)
finally it will generate a report like below and present some options to user
-------------------------------------------------
your installition needs an update
x database is absolete , y file needs a update ,
the purpose that you having trouble to understand was the automation of some report procedures
do you know an idiot who spends hours to do above to make a simple damn trojan , whereas it can be done within minutes
|
|
|
|
|
only_jack wrote: the purpose that you having trouble to understand was the automation of some report procedures
We are having trouble understanding it because you are not explaining it! Your original post mentioned nothing about automated reports, it merely said you wanted to modify an exe file by importing a bitmap resource - hence the suspicion that you were trying something illegal. Your description above still confuses me, if a program needs runtime parameters that are not compiled into its resources then why not just read some sort of parameter or config file, as does just about every commercial application in the world?MVP 2010 - are they mad?
|
|
|
|
|
Despite your comments I can see a) no way to do this and b) no purpose for it. But if you ever solve the problem do please write an article about it. MVP 2010 - are they mad?
|
|
|
|
|
Hi
I did following:
struct BaseFactory
{
typedef std::map<std::string, CBaseClass*(*)()> map_type;
...
protected:
static map_type * getMap()
{
if(!map) { map = new map_type; }
return map;
}
private:
static map_type * map;
};
template<typename T>
struct RegisterUserClass : BaseFactory
{
RegisterUserClass( std::string const& s )
{
getMap()->insert(std::make_pair(s, &createT<T>));
};
};
myCode.h
class CMyCode
{
...
private:
RegisterUserClass<CMyCode> reg;
}
myCode.cpp
RegisterUserClass<CMyCode> reg("CMyCode");
I got a link error. I know the "map" did not get initialized. How can "map" be initialized for my case?
Thanks,
|
|
|
|
|
The linker is complaining that the static member:
private:
static map_type * map;
doesn't have a definition. Try adding this to your basefactory.cpp file:
BaseFactory::map_type* BaseFactory::map = NULL;
|
|
|
|
|
Hi all,
I do hope somebody has some experience in this field... We are trying to port a project that we have taken over from another party from Visual Studio 6 to Studio 2008 (since we need to migrate to a 64bit platform). Part of the project uses type libraries. In itself this works fine (except for al the warnings that we need to tackle of course) The problem is that we have a dll A that is #imported into project B. This generates another dll (and type library) We then make a project C in which we #import both dll A and dll B. However, when importing dll B, the linker complains about not being able to find types from dll A (it replaces them with _unknown_ or something)
This all worked fine in studio 6. Has anyone got any idea as to how to tackle this issue. I do assume there is something trivial that needs to be defined, the question is ---what---??
Thanks in advance.
William
|
|
|
|
|
|
CString.Format can help in this! "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Could you explain how i can insert it into my sql query to show how it works?
|
|
|
|
|
try
char* NewTitle = "Monaco";
char* NumofShows = "2"; Failure is Success If we learn from it!!
|
|
|
|
|
Sorry, i do not get u? i mean, how do we insert the variables "NewTitle" and "NumofShows" into the sql statement so it can read the varaibles..
|
|
|
|
|
mysql_query(connection, "INSERT INTO main (NumofShows , Title) VALUES('12', 'Home')")
<br />
char* NewTitle = "Monaco";<br />
char* NumofShows = "2";<br />
<br />
CString InsertQuery= "INSERT INTO main (" + (CString)NumofShows +","+(CString) NewTitle +") VALUES('12', 'Home')";<br />
<br />
mysql_query(connection,InsertQuery);
before that change your project properties unicode into multibyte ..i hope this ll work ..if any error comes send it !!! Failure is Success If we learn from it!!
|
|
|
|
|
mysql_query(connection, "INSERT INTO main (NumofShows , Title) VALUES('12', 'Home')")
Sorry i think you misunderstood what i meant. Normally, for the values, it has to be hardcoded in, for example, having to put 12 and home inside.
What i meant is, for example, if the values to be inserted are in a variable , like ..
string NewShowName = "Danger"
int NewNumberofShow = "2"
How do i put in this variables (NewShowName, NewNumberofShow) into the sql statements at VALUES so the program can read the values inside this variables and then save them in the database
|
|
|
|
|
Might I suggest you will probably get a better response in the Database forum for this question. MVP 2010 - are they mad?
|
|
|
|
|
If you are using MFC, try:
CString strQuery;
strQuery.Format("INSERT INTO main (NumofShows , Title) VALUES('%d', '%s')", number, title); If not, you can use the same format with sprintf() ;"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
What is MFC and what does "%d" and "%s" stands for?
|
|
|
|
|
gregarion wrote: What is MFC...
See here and here.
gregarion wrote: ...what does "%d" and "%s" stands for?
See here."One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Im using netbeans. i dont think there are such libraries
|
|
|
|
|
gregarion wrote: Im using netbeans.
So do you have a C or C++ question?"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|