Page 1 of 4 123 ... LastLast
Results 1 to 15 of 49
  1. #1
    Pixie's Avatar
    Join Date
    Apr 2009
    Gender
    male
    Location
    Pixie wird wieder steigen.
    Posts
    1,884
    Reputation
    22
    Thanks
    229
    My Mood
    Fine

    [HELP]C++ Injector error??

    I had 14 errors, then I fixed it up a bit to 12...
    Can some one please fix up my code and post it here or PM me please??

    Here is my code:
    Code:
    #include <iostream>
    #include <direct.h>
    #include <windows.h>
    #include <tlhelp32.h>
    using namespace std;
    
    
    char* GetCurrentDir()
    {
    	char* szRet = (char*)malloc(MAX_PATH);
    
    	_getcwd(szRet, MAX_PATH);
    
    	return szRet;
    
    	)
    		LPCTSTR SzToLPCTSTR(char* szString)
    	{
    		LPTSTR lpszRet;
    		size_t side = strlen(szString)+1;
    
    		lpszRet = (LPTSTR)malloc(MAX_PATH);
    		mbstowcs_s(NULL, lpszRet, size, szString, _TRUNCATE);
    
    		return lpszRet;
    
    		)
    			void WaitForProcessToAppear (LPCTSTR, lpsztProc, DWORD dwDelay)
    		{
    			HANDLE          hSnap;
    			PROCESSENTRY32  peProc;
    			BOOL            bAppeared = FALSE;
    			
    			while(!bAppeared)
    			{
    	if ((hSnap = CreateToolHelp32Snapshot(TH32CS_SNAPPROCESS, 0)) != INVALID_HANDLE_VALUE
    		(
    		peProc.dwSize = sizeof(PROCESSENTRY32);
    	if(Process32First(hSnap, &peProc))
    		while(Process32Next(hSnap, &peProc) && !bAppeared)
    			if(!lstrcmp(lpcszProc, peProc.szExeFile))
    				bAppeared = TRUE;
    			}
    			CloseHandle(hSnap);
    			Sleep(dwDelay);
    		}
    		)
    			DWORD GetProcessIdByName(LPCTSTR lpcszProc)
    		{
    			HANDLE          hSnap;
    			PROCESSENTRY32  peProc;
    			DWORD           dwRet = -1;
    			
    			if((hSnap = CreateToolHelp32Snapshot(TH32CS_SNAPPROCESS, 0)) != INVALID_HANDLE_VALUE)
    {
    	peProc.dwSize = sizeof(PROCESSENTRY32);
    	if(Process32First(hSnap, &peProc))
    		while(Process32Next(hSnap, &peProc))
    			if(!lstrcmp(lpcszProc, peProc.szExeFile))
    				dwRet = peProc.th32ProcessID;
    			}
    			CloseHandle(hSnap);
    			
    			return dwRet;
    			)
    				
    				BOOL InjectDll(DWORD dwPid, char* szDllPath)
    			{
    				DWORD       dwMemSize;
    				HANDLE      hProc;
    				LPVOID      IpRemoteMem, IpLoadLibrary;
    				BOOL        bRet = FALSE;
    				
    				if((hProc = OpenProcess(PROCESS_VM_OPERATION | PROCESS_VM_WRITE | PROCESS_CREATE_THREAD, FALSE, dwPid)) != NULL)
    				{
    					dwMemSize = strlen(szDllPath)+1;
    					if((IpRemoteMem = VirtualAllocEx(hProc, NULL, dwMemSize, MEM_COMMIT, PAGE_READWRITE) != NULL)
    						if(WriteProcessMemory(hProc, IpRemoteMem, (LPCVOID)szDllPath, dwMemSize, NULL))
    						{
    							IpLoadLibrary = GetProcAddress(GetModuleHandleA("Kernel32.dll"), "LoadLibraryA");
    							if(CreateRemoteThread(hProc, NULL, 0, (LPTHREAD_START_ROUTINE)IpLoadLibrary, IpRemoteMem, 0, NULL)!= NULL)
    								bRet = True
    								)
    						}
    						CloseHandle(hProc);
    						
    						return bRet;
    						)
    
    							int main()
    						{
    							char szProc[MAX_PATH], szDll[MAX_PATH];
    							char* szDllPath = (char*)malloc(MAX_PATH);
    							LPTSTR lpszProc = NULL;
    
    							for(;;)
    							
    							{
    								cout << "Process: ";
    								cin >> szProc;
    								cout << "DLL: ";
    								cin >> szDll;
    								szDllPath = GetCurrentDir();
    								strcat_s(szDllPath, MAX_PATH, "\\");
    								strcat_s(szDllPath, MAX_PATH, szDll);
    								cout << "Waiting for process..." << endl;
    								WaitForProcessToAppear(SzToLPCTSTR(szProc), 100);
    								if(InjectDll(GetProcessIdByName(SzToLPCTSTR(szProc)), szDllPath))
    									cout << "Injection Success!" << endl;
    								else
    									cout << "Failed to inject!" << endl;
    								cout << "\n";
    							}
    							
    							return 0;
    						}
    The Error Log:

    Code:
    ------ Build started: Project: Luigi, Configuration: Debug Win32 ------
    Compiling...
    main.cpp
    c:\documents and settings\-----\my documents\visual studio 2008\projects\luigi\luigi\main.cpp(23) : error C2065: 'size' : undeclared identifier
    c:\documents and settings\-----\my documents\visual studio 2008\projects\luigi\luigi\main.cpp(27) : error C2061: syntax error : identifier 'lpsztProc'
    c:\documents and settings\-----\my documents\visual studio 2008\projects\luigi\luigi\main.cpp(35) : error C3861: 'CreateToolHelp32Snapshot': identifier not found
    c:\documents and settings\-----\my documents\visual studio 2008\projects\luigi\luigi\main.cpp(42) : error C2065: 'lpcszProc' : undeclared identifier
    c:\documents and settings\-----\my documents\visual studio 2008\projects\luigi\luigi\main.cpp(48) : error C2065: 'dwDelay' : undeclared identifier
    c:\documents and settings\-----\my documents\visual studio 2008\projects\luigi\luigi\main.cpp(59) : error C3861: 'CreateToolHelp32Snapshot': identifier not found
    c:\documents and settings\-----\my documents\visual studio 2008\projects\luigi\luigi\main.cpp(88) : error C2440: '=' : cannot convert from 'bool' to 'LPVOID'
            Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
    c:\documents and settings\-----\my documents\visual studio 2008\projects\luigi\luigi\main.cpp(89) : error C2143: syntax error : missing ')' before '{'
    c:\documents and settings\-----\my documents\visual studio 2008\projects\luigi\luigi\main.cpp(96) : error C2065: 'True' : undeclared identifier
    c:\documents and settings\-----\my documents\visual studio 2008\projects\luigi\luigi\main.cpp(96) : error C2143: syntax error : missing ';' before '}'
    c:\documents and settings\-----\my documents\visual studio 2008\projects\luigi\luigi\main.cpp(119) : error C2660: 'WaitForProcessToAppear' : function does not take 2 arguments
    Build log was saved at "file://c:\Documents and Settings\-----\My Documents\Visual Studio 2008\Projects\Luigi\Luigi\Debug\BuildLog.htm"
    Luigi - 11 error(s), 0 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

  2. #2
    Hell_Demon's Avatar
    Join Date
    Mar 2008
    Gender
    male
    Location
    I love causing havoc
    Posts
    3,976
    Reputation
    343
    Thanks
    4,320
    My Mood
    Cheeky
    You're using ) instead of } as closing brackets o__O

  3. #3
    Pixie's Avatar
    Join Date
    Apr 2009
    Gender
    male
    Location
    Pixie wird wieder steigen.
    Posts
    1,884
    Reputation
    22
    Thanks
    229
    My Mood
    Fine
    Quote Originally Posted by Hell_Demon View Post
    You're using ) instead of } as closing brackets o__O
    So where should I put them, it's a Command Prompt Injector

  4. #4
    Hell_Demon's Avatar
    Join Date
    Mar 2008
    Gender
    male
    Location
    I love causing havoc
    Posts
    3,976
    Reputation
    343
    Thanks
    4,320
    My Mood
    Cheeky
    Code:
    #include <iostream>
    #include <direct.h>
    #include <windows.h>
    #include <tlhelp32.h>
    using namespace std;
    
    
    char* GetCurrentDir()
    {
    	char* szRet = (char*)malloc(MAX_PATH);
    
    	_getcwd(szRet, MAX_PATH);
    
    	return szRet;
    
    }
    
    LPCTSTR SzToLPCTSTR(char* szString)
    {
    	LPTSTR lpszRet;
    	size_t side = strlen(szString)+1;
    	lpszRet = (LPTSTR)malloc(MAX_PATH);
    	mbstowcs_s(NULL, lpszRet, size, szString, _TRUNCATE);
    	return lpszRet;
    }
    
    void WaitForProcessToAppear (LPCTSTR, lpsztProc, DWORD dwDelay)
    {
    	HANDLE          hSnap;
    	PROCESSENTRY32  peProc;
    	BOOL            bAppeared = FALSE;
    
    	while(!bAppeared)
    	{
    		if ((hSnap = CreateToolHelp32Snapshot(TH32CS_SNAPPROCESS, 0)) != INVALID_HANDLE_VALUE)
    		{
    			peProc.dwSize = sizeof(PROCESSENTRY32);
    			if(Process32First(hSnap, &peProc))
    			{
    				while(Process32Next(hSnap, &peProc) && !bAppeared)
    				{
    					if(!lstrcmp(lpcszProc, peProc.szExeFile))
    					{
    						bAppeared = TRUE;
    					}
    					CloseHandle(hSnap);
    				}
    				Sleep(dwDelay);
    			}
    		}
    	}
    }
    DWORD GetProcessIdByName(LPCTSTR lpcszProc)
    {
    	HANDLE          hSnap;
    	PROCESSENTRY32  peProc;
    	DWORD           dwRet = -1;
    			
    	if((hSnap = CreateToolHelp32Snapshot(TH32CS_SNAPPROCESS, 0)) != INVALID_HANDLE_VALUE)
    	{
    		peProc.dwSize = sizeof(PROCESSENTRY32);
    		if(Process32First(hSnap, &peProc))
    		{
    			while(Process32Next(hSnap, &peProc))
    			{
    				if(!lstrcmp(lpcszProc, peProc.szExeFile))
    				{
    					dwRet = peProc.th32ProcessID;
    				}
    				CloseHandle(hSnap);
    			}
    			
    		}
    		return dwRet;
    	}
    }
    				
    BOOL InjectDll(DWORD dwPid, char* szDllPath)
    {
    	DWORD       dwMemSize;
    	HANDLE      hProc;
    	LPVOID      IpRemoteMem, IpLoadLibrary;
    	BOOL        bRet = FALSE;
    	
    	if((hProc = OpenProcess(PROCESS_VM_OPERATION | PROCESS_VM_WRITE | PROCESS_CREATE_THREAD, FALSE, dwPid)) != NULL)
    	{
    		dwMemSize = strlen(szDllPath)+1;
    		if((IpRemoteMem = VirtualAllocEx(hProc, NULL, dwMemSize, MEM_COMMIT, PAGE_READWRITE) != NULL)
    		{
    			if(WriteProcessMemory(hProc, IpRemoteMem, (LPCVOID)szDllPath, dwMemSize, NULL))
    			{
    				IpLoadLibrary = GetProcAddress(GetModuleHandleA("Kernel32.dll"), "LoadLibraryA");
    				if(CreateRemoteThread(hProc, NULL, 0, (LPTHREAD_START_ROUTINE)IpLoadLibrary, IpRemoteMem, 0, NULL)!= NULL)
    				{
    					bRet = True
    				}
    				CloseHandle(hProc);
    			}					
    			return bRet;
    		}
    	}
    }
    
    int main()
    {
    	char szProc[MAX_PATH], szDll[MAX_PATH];
    	char* szDllPath = (char*)malloc(MAX_PATH);
    	LPTSTR lpszProc = NULL;
    	for(;;)
    	{
    		cout << "Process: ";
    		cin >> szProc;
    		cout << "DLL: ";
    		cin >> szDll;
    		szDllPath = GetCurrentDir();
    		strcat_s(szDllPath, MAX_PATH, "\\");
    		strcat_s(szDllPath, MAX_PATH, szDll);
    		cout << "Waiting for process..." << endl;
    		WaitForProcessToAppear(SzToLPCTSTR(szProc), 100);
    		if(InjectDll(GetProcessIdByName(SzToLPCTSTR(szProc)), szDllPath))
    		{
    			cout << "Injection Success!" << endl;
    		}
    		else
    		{
    			cout << "Failed to inject!" << endl;
    			cout << "\n";
    		}
    	}
    	return 0;
    }
    Fixed brackets and indention, no idea if it will work.
    just use s1nject(closed source) or tatnium injector(open source)

  5. #5
    Pixie's Avatar
    Join Date
    Apr 2009
    Gender
    male
    Location
    Pixie wird wieder steigen.
    Posts
    1,884
    Reputation
    22
    Thanks
    229
    My Mood
    Fine
    Quote Originally Posted by Hell_Demon View Post
    Code:
    #include <iostream>
    #include <direct.h>
    #include <windows.h>
    #include <tlhelp32.h>
    using namespace std;
    
    
    char* GetCurrentDir()
    {
    	char* szRet = (char*)malloc(MAX_PATH);
    
    	_getcwd(szRet, MAX_PATH);
    
    	return szRet;
    
    }
    
    LPCTSTR SzToLPCTSTR(char* szString)
    {
    	LPTSTR lpszRet;
    	size_t side = strlen(szString)+1;
    	lpszRet = (LPTSTR)malloc(MAX_PATH);
    	mbstowcs_s(NULL, lpszRet, size, szString, _TRUNCATE);
    	return lpszRet;
    }
    
    void WaitForProcessToAppear (LPCTSTR, lpsztProc, DWORD dwDelay)
    {
    	HANDLE          hSnap;
    	PROCESSENTRY32  peProc;
    	BOOL            bAppeared = FALSE;
    
    	while(!bAppeared)
    	{
    		if ((hSnap = CreateToolHelp32Snapshot(TH32CS_SNAPPROCESS, 0)) != INVALID_HANDLE_VALUE)
    		{
    			peProc.dwSize = sizeof(PROCESSENTRY32);
    			if(Process32First(hSnap, &peProc))
    			{
    				while(Process32Next(hSnap, &peProc) && !bAppeared)
    				{
    					if(!lstrcmp(lpcszProc, peProc.szExeFile))
    					{
    						bAppeared = TRUE;
    					}
    					CloseHandle(hSnap);
    				}
    				Sleep(dwDelay);
    			}
    		}
    	}
    }
    DWORD GetProcessIdByName(LPCTSTR lpcszProc)
    {
    	HANDLE          hSnap;
    	PROCESSENTRY32  peProc;
    	DWORD           dwRet = -1;
    			
    	if((hSnap = CreateToolHelp32Snapshot(TH32CS_SNAPPROCESS, 0)) != INVALID_HANDLE_VALUE)
    	{
    		peProc.dwSize = sizeof(PROCESSENTRY32);
    		if(Process32First(hSnap, &peProc))
    		{
    			while(Process32Next(hSnap, &peProc))
    			{
    				if(!lstrcmp(lpcszProc, peProc.szExeFile))
    				{
    					dwRet = peProc.th32ProcessID;
    				}
    				CloseHandle(hSnap);
    			}
    			
    		}
    		return dwRet;
    	}
    }
    				
    BOOL InjectDll(DWORD dwPid, char* szDllPath)
    {
    	DWORD       dwMemSize;
    	HANDLE      hProc;
    	LPVOID      IpRemoteMem, IpLoadLibrary;
    	BOOL        bRet = FALSE;
    	
    	if((hProc = OpenProcess(PROCESS_VM_OPERATION | PROCESS_VM_WRITE | PROCESS_CREATE_THREAD, FALSE, dwPid)) != NULL)
    	{
    		dwMemSize = strlen(szDllPath)+1;
    		if((IpRemoteMem = VirtualAllocEx(hProc, NULL, dwMemSize, MEM_COMMIT, PAGE_READWRITE) != NULL)
    		{
    			if(WriteProcessMemory(hProc, IpRemoteMem, (LPCVOID)szDllPath, dwMemSize, NULL))
    			{
    				IpLoadLibrary = GetProcAddress(GetModuleHandleA("Kernel32.dll"), "LoadLibraryA");
    				if(CreateRemoteThread(hProc, NULL, 0, (LPTHREAD_START_ROUTINE)IpLoadLibrary, IpRemoteMem, 0, NULL)!= NULL)
    				{
    					bRet = True
    				}
    				CloseHandle(hProc);
    			}					
    			return bRet;
    		}
    	}
    }
    
    int main()
    {
    	char szProc[MAX_PATH], szDll[MAX_PATH];
    	char* szDllPath = (char*)malloc(MAX_PATH);
    	LPTSTR lpszProc = NULL;
    	for(;;)
    	{
    		cout << "Process: ";
    		cin >> szProc;
    		cout << "DLL: ";
    		cin >> szDll;
    		szDllPath = GetCurrentDir();
    		strcat_s(szDllPath, MAX_PATH, "\\");
    		strcat_s(szDllPath, MAX_PATH, szDll);
    		cout << "Waiting for process..." << endl;
    		WaitForProcessToAppear(SzToLPCTSTR(szProc), 100);
    		if(InjectDll(GetProcessIdByName(SzToLPCTSTR(szProc)), szDllPath))
    		{
    			cout << "Injection Success!" << endl;
    		}
    		else
    		{
    			cout << "Failed to inject!" << endl;
    			cout << "\n";
    		}
    	}
    	return 0;
    }
    Fixed brackets and indention, no idea if it will work.
    just use s1nject(closed source) or tatnium injector(open source)
    Titanium injector??

    Edit: It didn't work, it only fixed one error...

  6. #6
    Micheltjuh's Avatar
    Join Date
    Sep 2008
    Gender
    male
    Location
    Holland
    Posts
    643
    Reputation
    10
    Thanks
    59
    My Mood
    Cynical
    An error log would make it a lot easier.

  7. #7
    Pixie's Avatar
    Join Date
    Apr 2009
    Gender
    male
    Location
    Pixie wird wieder steigen.
    Posts
    1,884
    Reputation
    22
    Thanks
    229
    My Mood
    Fine
    Quote Originally Posted by Micheltjuh View Post
    An error log would make it a lot easier.
    Error Log:
    Code:
    ------ Build started: Project: Luigi, Configuration: Debug Win32 ------
    Compiling...
    main.cpp
    c:\documents and settings\-----\my documents\visual studio 2008\projects\luigi\luigi\main.cpp(23) : error C2065: 'size' : undeclared identifier
    c:\documents and settings\-----\my documents\visual studio 2008\projects\luigi\luigi\main.cpp(27) : error C2061: syntax error : identifier 'lpsztProc'
    c:\documents and settings\-----\my documents\visual studio 2008\projects\luigi\luigi\main.cpp(35) : error C3861: 'CreateToolHelp32Snapshot': identifier not found
    c:\documents and settings\-----\my documents\visual studio 2008\projects\luigi\luigi\main.cpp(42) : error C2065: 'lpcszProc' : undeclared identifier
    c:\documents and settings\-----\my documents\visual studio 2008\projects\luigi\luigi\main.cpp(48) : error C2065: 'dwDelay' : undeclared identifier
    c:\documents and settings\-----\my documents\visual studio 2008\projects\luigi\luigi\main.cpp(59) : error C3861: 'CreateToolHelp32Snapshot': identifier not found
    c:\documents and settings\-----\my documents\visual studio 2008\projects\luigi\luigi\main.cpp(88) : error C2440: '=' : cannot convert from 'bool' to 'LPVOID'
            Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
    c:\documents and settings\-----\my documents\visual studio 2008\projects\luigi\luigi\main.cpp(89) : error C2143: syntax error : missing ')' before '{'
    c:\documents and settings\-----\my documents\visual studio 2008\projects\luigi\luigi\main.cpp(96) : error C2065: 'True' : undeclared identifier
    c:\documents and settings\-----\my documents\visual studio 2008\projects\luigi\luigi\main.cpp(96) : error C2143: syntax error : missing ';' before '}'
    c:\documents and settings\-----\my documents\visual studio 2008\projects\luigi\luigi\main.cpp(119) : error C2660: 'WaitForProcessToAppear' : function does not take 2 arguments
    Build log was saved at "file://c:\Documents and Settings\-----\My Documents\Visual Studio 2008\Projects\Luigi\Luigi\Debug\BuildLog.htm"
    Luigi - 11 error(s), 0 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

  8. #8
    why06's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    IBM
    Posts
    4,304
    Reputation
    170
    Thanks
    2,203
    My Mood
    Flirty
    Hmmmm... well you've got a bunch of uncdeclared identifiers from what I can see. You either need to imports some files that declare those identifiers or use unmanaged ones. Let me look into it.

    EDIT: (3 minutes after looking at code)
    Wow. There are way to many managed to unmanaged C++ conversions in there. Maybe HD or BA would have a better time understanding it. I suck with managed.



    PS: Does anyone know somewhere I could get acquainted with managed C++? A book or a web page or something. Not exactly sure what I should look for.
    Last edited by why06; 09-15-2009 at 04:25 PM.

    "Every gun that is made, every warship launched, every rocket fired signifies, in the final sense, a theft from those who hunger and are not fed, those who are cold and are not clothed. This world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children. The cost of one modern heavy bomber is this: a modern brick school in more than 30 cities. It is two electric power plants, each serving a town of 60,000 population. It is two fine, fully equipped hospitals. It is some fifty miles of concrete pavement. We pay for a single fighter plane with a half million bushels of wheat. We pay for a single destroyer with new homes that could have housed more than 8,000 people. This is, I repeat, the best way of life to be found on the road the world has been taking. This is not a way of life at all, in any true sense. Under the cloud of threatening war, it is humanity hanging from a cross of iron."
    - Dwight D. Eisenhower

  9. #9
    Pixie's Avatar
    Join Date
    Apr 2009
    Gender
    male
    Location
    Pixie wird wieder steigen.
    Posts
    1,884
    Reputation
    22
    Thanks
    229
    My Mood
    Fine
    Quote Originally Posted by why06 View Post
    Hmmmm... well you've got a bunch of uncdeclared identifiers from what I can see. You either need to imports some files that declare those identifiers or use unmanaged ones. Let me look into it.

    EDIT: (3 minutes after looking at code)
    Wow. There are way to many managed to unmanaged C++ conversions in there. Maybe HD or BA would have a better time understanding it. I suck with managed.



    PS: Does anyone know somewhere I could get acquainted with managed C++? A book or a web page or something. Not exactly sure what I should look for.
    I fixed it up a little, and changed the BOOL, and the FALSE and TRUE to undercase letters.

    Now, I only have 10 errors...

  10. #10
    B1ackAnge1's Avatar
    Join Date
    Aug 2009
    Gender
    male
    Posts
    455
    Reputation
    74
    Thanks
    344
    My Mood
    Cynical
    MSDN

    one way to approach is it to think that Managed C++ = C# using C++ syntax..


    Dont' realyl have time to go over all of this, but for instance this:

    ...\luigi\main.cpp(23) : error C2065: 'size' : undeclared identifier



    Look in that block of code
    Code:
    LPCTSTR SzToLPCTSTR(char* szString)
    {
    	LPTSTR lpszRet;
    	size_t side = strlen(szString)+1;
    	lpszRet = (LPTSTR)malloc(MAX_PATH);
    	mbstowcs_s(NULL, lpszRet, size, szString, _TRUNCATE);
    	return lpszRet;
    }
    notice anything what it probably should've been?
    Why would anyone call the length of a string 'side' instead of size ?
    I'm sure there's more like those..

  11. #11
    why06's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    IBM
    Posts
    4,304
    Reputation
    170
    Thanks
    2,203
    My Mood
    Flirty
    Quote Originally Posted by B1ackAnge1 View Post
    MSDN

    one way to approach is it to think that Managed C++ = C# using C++ syntax..
    Hmmm I had a feeling someone would say that. Basically MSDN = the manual xD.

    Oh well and looking at the small code snipet I see what you mean. whoever wrote this didn't pay much attention to what they were doing or at least didnt debug it. Anyway it also looks like they added 1 to the string length.. o_O wth?

    Meh. I'll try to figure it out. it will take a while because I have less experience, I just have to break each function down part by part. Could take about a week, but this should give me some good practice with managed.
    Last edited by why06; 09-15-2009 at 05:04 PM.

    "Every gun that is made, every warship launched, every rocket fired signifies, in the final sense, a theft from those who hunger and are not fed, those who are cold and are not clothed. This world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children. The cost of one modern heavy bomber is this: a modern brick school in more than 30 cities. It is two electric power plants, each serving a town of 60,000 population. It is two fine, fully equipped hospitals. It is some fifty miles of concrete pavement. We pay for a single fighter plane with a half million bushels of wheat. We pay for a single destroyer with new homes that could have housed more than 8,000 people. This is, I repeat, the best way of life to be found on the road the world has been taking. This is not a way of life at all, in any true sense. Under the cloud of threatening war, it is humanity hanging from a cross of iron."
    - Dwight D. Eisenhower

  12. #12
    B1ackAnge1's Avatar
    Join Date
    Aug 2009
    Gender
    male
    Posts
    455
    Reputation
    74
    Thanks
    344
    My Mood
    Cynical
    Couple of missing brackets, semi colon, few too many comma's in places they shouldn't be, variable name mis-spellings, Upper vs Lower Case ..

    And btw - no managed code in here.. just good old-fashioned Win32 C++

    Not trying to sound like an arrogant prick ('cause i'm really not) lol but but this should be beginner level to figure this stuff out, especially when running it through a compiler and it basically telling you what the problem is Perhaps now that you see what the changes are, compare and see if it make sense with what the error message was for each of the errors. Learning opportunity here


    Code:
    #include <iostream>
    #include <direct.h>
    #include <windows.h>
    #include <tlhelp32.h>
    using namespace std;
    
    
    char* GetCurrentDir()
    {
    	char* szRet = (char*)malloc(MAX_PATH);
    
    	_getcwd(szRet, MAX_PATH);
    
    	return szRet;
    
    }
    
    LPCTSTR SzToLPCTSTR(char* szString)
    {
    	LPTSTR lpszRet;
    	size_t size = strlen(szString)+1;
    	lpszRet = (LPTSTR)malloc(MAX_PATH);
    	mbstowcs_s(NULL, lpszRet, size, szString, _TRUNCATE);
    	return lpszRet;
    }
    
    void WaitForProcessToAppear(LPCTSTR lpszProc, DWORD dwDelay)
    {
    	HANDLE          hSnap;
    	PROCESSENTRY32  peProc;
    	BOOL            bAppeared = FALSE;
    
    	while(!bAppeared)
    	{
    		if ((hSnap = CreateToolhelp32Snapshot((DWORD)TH32CS_SNAPPROCESS, (DWORD)0)) != INVALID_HANDLE_VALUE)
    		{
    			peProc.dwSize = sizeof(PROCESSENTRY32);
    			if(Process32First(hSnap, &peProc))
    			{
    				while(Process32Next(hSnap, &peProc) && !bAppeared)
    				{
    					if(!lstrcmp(lpszProc, peProc.szExeFile))
    					{
    						bAppeared = TRUE;
    					}
    					CloseHandle(hSnap);
    				}
    				Sleep(dwDelay);
    			}
    		}
    	}
    }
    DWORD GetProcessIdByName(LPCTSTR lpcszProc)
    {
    	HANDLE          hSnap;
    	PROCESSENTRY32  peProc;
    	DWORD           dwRet = -1;
    			
    	if((hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)) != INVALID_HANDLE_VALUE)
    	{
    		peProc.dwSize = sizeof(PROCESSENTRY32);
    		if(Process32First(hSnap, &peProc))
    		{
    			while(Process32Next(hSnap, &peProc))
    			{
    				if(!lstrcmp(lpcszProc, peProc.szExeFile))
    				{
    					dwRet = peProc.th32ProcessID;
    				}
    				CloseHandle(hSnap);
    			}
    			
    		}
    		return dwRet;
    	}
    }
    				
    BOOL InjectDll(DWORD dwPid, char* szDllPath)
    {
    	DWORD       dwMemSize;
    	HANDLE      hProc;
    	LPVOID      IpRemoteMem, IpLoadLibrary;
    	BOOL        bRet = FALSE;
    	
    	if((hProc = OpenProcess(PROCESS_VM_OPERATION | PROCESS_VM_WRITE | PROCESS_CREATE_THREAD, FALSE, dwPid)) != NULL)
    	{
    		dwMemSize = strlen(szDllPath)+1;
    		if( (IpRemoteMem = VirtualAllocEx(hProc, NULL, dwMemSize, MEM_COMMIT, PAGE_READWRITE)) != NULL)
    		{
    			if(WriteProcessMemory(hProc, IpRemoteMem, (LPCVOID)szDllPath, dwMemSize, NULL))
    			{
    				IpLoadLibrary = GetProcAddress(GetModuleHandleA("Kernel32.dll"), "LoadLibraryA");
    				if(CreateRemoteThread(hProc, NULL, 0, (LPTHREAD_START_ROUTINE)IpLoadLibrary, IpRemoteMem, 0, NULL)!= NULL)
    				{
    					bRet = TRUE;
    				}
    				CloseHandle(hProc);
    			}					
    			return bRet;
    		}
    	}
    }
    
    int main()
    {
    	char szProc[MAX_PATH], szDll[MAX_PATH];
    	char* szDllPath = (char*)malloc(MAX_PATH);
    	LPTSTR lpszProc = NULL;
    	for(;;)
    	{
    		cout << "Process: ";
    		cin >> szProc;
    		cout << "DLL: ";
    		cin >> szDll;
    		szDllPath = GetCurrentDir();
    		strcat_s(szDllPath, MAX_PATH, "\\");
    		strcat_s(szDllPath, MAX_PATH, szDll);
    		cout << "Waiting for process..." << endl;
    		WaitForProcessToAppear(SzToLPCTSTR(szProc), 100);
    		if(InjectDll(GetProcessIdByName(SzToLPCTSTR(szProc)), szDllPath))
    		{
    			cout << "Injection Success!" << endl;
    		}
    		else
    		{
    			cout << "Failed to inject!" << endl;
    			cout << "\n";
    		}
    	}
    	return 0;
    }
    disclaimer: it BUILDS, that's it - didn't test if it runs or does what it's supposed to
    Last edited by B1ackAnge1; 09-15-2009 at 05:08 PM.

  13. #13
    Pixie's Avatar
    Join Date
    Apr 2009
    Gender
    male
    Location
    Pixie wird wieder steigen.
    Posts
    1,884
    Reputation
    22
    Thanks
    229
    My Mood
    Fine
    Quote Originally Posted by B1ackAnge1 View Post
    Couple of missing brackets, semi colon, few too many comma's in places they shouldn't be, variable name mis-spellings, Upper vs Lower Case ..

    And btw - no managed code in here.. just good old-fashioned Win32 C++

    Not trying to sound like an arrogant prick ('cause i'm really not) lol but but this should be beginner level to figure this stuff out, especially when running it through a compiler and it basically telling you what the problem is Perhaps now that you see what the changes are, compare and see if it make sense with what the error message was for each of the errors. Learning opportunity here


    Code:
    #include <iostream>
    #include <direct.h>
    #include <windows.h>
    #include <tlhelp32.h>
    using namespace std;
    
    
    char* GetCurrentDir()
    {
    	char* szRet = (char*)malloc(MAX_PATH);
    
    	_getcwd(szRet, MAX_PATH);
    
    	return szRet;
    
    }
    
    LPCTSTR SzToLPCTSTR(char* szString)
    {
    	LPTSTR lpszRet;
    	size_t size = strlen(szString)+1;
    	lpszRet = (LPTSTR)malloc(MAX_PATH);
    	mbstowcs_s(NULL, lpszRet, size, szString, _TRUNCATE);
    	return lpszRet;
    }
    
    void WaitForProcessToAppear(LPCTSTR lpszProc, DWORD dwDelay)
    {
    	HANDLE          hSnap;
    	PROCESSENTRY32  peProc;
    	BOOL            bAppeared = FALSE;
    
    	while(!bAppeared)
    	{
    		if ((hSnap = CreateToolhelp32Snapshot((DWORD)TH32CS_SNAPPROCESS, (DWORD)0)) != INVALID_HANDLE_VALUE)
    		{
    			peProc.dwSize = sizeof(PROCESSENTRY32);
    			if(Process32First(hSnap, &peProc))
    			{
    				while(Process32Next(hSnap, &peProc) && !bAppeared)
    				{
    					if(!lstrcmp(lpszProc, peProc.szExeFile))
    					{
    						bAppeared = TRUE;
    					}
    					CloseHandle(hSnap);
    				}
    				Sleep(dwDelay);
    			}
    		}
    	}
    }
    DWORD GetProcessIdByName(LPCTSTR lpcszProc)
    {
    	HANDLE          hSnap;
    	PROCESSENTRY32  peProc;
    	DWORD           dwRet = -1;
    			
    	if((hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)) != INVALID_HANDLE_VALUE)
    	{
    		peProc.dwSize = sizeof(PROCESSENTRY32);
    		if(Process32First(hSnap, &peProc))
    		{
    			while(Process32Next(hSnap, &peProc))
    			{
    				if(!lstrcmp(lpcszProc, peProc.szExeFile))
    				{
    					dwRet = peProc.th32ProcessID;
    				}
    				CloseHandle(hSnap);
    			}
    			
    		}
    		return dwRet;
    	}
    }
    				
    BOOL InjectDll(DWORD dwPid, char* szDllPath)
    {
    	DWORD       dwMemSize;
    	HANDLE      hProc;
    	LPVOID      IpRemoteMem, IpLoadLibrary;
    	BOOL        bRet = FALSE;
    	
    	if((hProc = OpenProcess(PROCESS_VM_OPERATION | PROCESS_VM_WRITE | PROCESS_CREATE_THREAD, FALSE, dwPid)) != NULL)
    	{
    		dwMemSize = strlen(szDllPath)+1;
    		if( (IpRemoteMem = VirtualAllocEx(hProc, NULL, dwMemSize, MEM_COMMIT, PAGE_READWRITE)) != NULL)
    		{
    			if(WriteProcessMemory(hProc, IpRemoteMem, (LPCVOID)szDllPath, dwMemSize, NULL))
    			{
    				IpLoadLibrary = GetProcAddress(GetModuleHandleA("Kernel32.dll"), "LoadLibraryA");
    				if(CreateRemoteThread(hProc, NULL, 0, (LPTHREAD_START_ROUTINE)IpLoadLibrary, IpRemoteMem, 0, NULL)!= NULL)
    				{
    					bRet = TRUE;
    				}
    				CloseHandle(hProc);
    			}					
    			return bRet;
    		}
    	}
    }
    
    int main()
    {
    	char szProc[MAX_PATH], szDll[MAX_PATH];
    	char* szDllPath = (char*)malloc(MAX_PATH);
    	LPTSTR lpszProc = NULL;
    	for(;;)
    	{
    		cout << "Process: ";
    		cin >> szProc;
    		cout << "DLL: ";
    		cin >> szDll;
    		szDllPath = GetCurrentDir();
    		strcat_s(szDllPath, MAX_PATH, "\\");
    		strcat_s(szDllPath, MAX_PATH, szDll);
    		cout << "Waiting for process..." << endl;
    		WaitForProcessToAppear(SzToLPCTSTR(szProc), 100);
    		if(InjectDll(GetProcessIdByName(SzToLPCTSTR(szProc)), szDllPath))
    		{
    			cout << "Injection Success!" << endl;
    		}
    		else
    		{
    			cout << "Failed to inject!" << endl;
    			cout << "\n";
    		}
    	}
    	return 0;
    }
    Is that like a major changed code?? And the Changing the side to Size brought me down by 1 error, now I'm at 9...

  14. #14
    B1ackAnge1's Avatar
    Join Date
    Aug 2009
    Gender
    male
    Posts
    455
    Reputation
    74
    Thanks
    344
    My Mood
    Cynical
    The code I pasted has 0 build errors, so copy & paste that

  15. #15
    why06's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    IBM
    Posts
    4,304
    Reputation
    170
    Thanks
    2,203
    My Mood
    Flirty
    Quote Originally Posted by B1ackAnge1 View Post
    Couple of missing brackets, semi colon, few too many comma's in places they shouldn't be, variable name mis-spellings, Upper vs Lower Case ..

    And btw - no managed code in here.. just good old-fashioned Win32 C++

    Not trying to sound like an arrogant prick ('cause i'm really not) lol but but this should be beginner level to figure this stuff out, especially when running it through a compiler and it basically telling you what the problem is Perhaps now that you see what the changes are, compare and see if it make sense with what the error message was for each of the errors. Learning opportunity here

    disclaimer: it BUILDS, that's it - didn't test if it runs or does what it's supposed to
    ok one last question. What is MAX_PATH. It comes up all throughout the code and I have no idea what it is. not even the slightest.

    "Every gun that is made, every warship launched, every rocket fired signifies, in the final sense, a theft from those who hunger and are not fed, those who are cold and are not clothed. This world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children. The cost of one modern heavy bomber is this: a modern brick school in more than 30 cities. It is two electric power plants, each serving a town of 60,000 population. It is two fine, fully equipped hospitals. It is some fifty miles of concrete pavement. We pay for a single fighter plane with a half million bushels of wheat. We pay for a single destroyer with new homes that could have housed more than 8,000 people. This is, I repeat, the best way of life to be found on the road the world has been taking. This is not a way of life at all, in any true sense. Under the cloud of threatening war, it is humanity hanging from a cross of iron."
    - Dwight D. Eisenhower

Page 1 of 4 123 ... LastLast

Similar Threads

  1. [Help] Help please injector error
    By dfjyo in forum CrossFire Spammers, Injectors and Multi Tools
    Replies: 7
    Last Post: 07-11-2011, 01:03 PM
  2. [Help Request] Help with injectors
    By dfjyo in forum CrossFire Help
    Replies: 2
    Last Post: 07-11-2011, 09:23 AM
  3. [Help Request] Help with injector
    By rubice24 in forum CrossFire Help
    Replies: 1
    Last Post: 06-14-2011, 02:56 PM
  4. [Help Request] Help quick big error
    By mitchellk9 in forum CrossFire Help
    Replies: 3
    Last Post: 05-17-2011, 03:14 PM
  5. [Help Request] help me for error visual c++
    By cheateroO in forum CrossFire Help
    Replies: 2
    Last Post: 05-01-2011, 12:42 PM

Tags for this Thread