Results 1 to 6 of 6
  1. #1
    SaplingHeros's Avatar
    Join Date
    Jan 2013
    Gender
    male
    Posts
    26
    Reputation
    10
    Thanks
    3

    Visual studio building errors

    I have some problems with building a code, it gives me these errors:

    1>..\..\..\..\..\..\#\documents\visual studio 2015\Projects\DLLproj\DLLproj\Mem.cpp(61): error C2664: 'int _wcsicmp(const wchar_t *,const wchar_t *)': cannot convert argument 1 from 'CHAR [260]' to 'const wchar_t *'
    1> ..\..\..\..\..\..\#\documents\visual studio 2015\Projects\DLLproj\DLLproj\Mem.cpp(61): note: Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
    1>..\..\..\..\..\..\#\documents\visual studio 2015\Projects\DLLproj\DLLproj\Mem.cpp(77): error C2664: 'int _wcsicmp(const wchar_t *,const wchar_t *)': cannot convert argument 1 from 'CHAR [260]' to 'const wchar_t *'
    1> ..\..\..\..\..\..\#\documents\visual studio 2015\Projects\DLLproj\DLLproj\Mem.cpp(77): note: Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
    1>..\..\..\..\..\..\#\documents\visual studio 2015\Projects\DLLproj\DLLproj\Mem.cpp(94): error C2601: 'Mem::m_iGetModuleAddressByName': local function definitions are illegal
    1> ..\..\..\..\..\..\#\documents\visual studio 2015\Projects\DLLproj\DLLproj\Mem.cpp(43): note: this line contains a '{' which has not yet been matched
    1>..\..\..\..\..\..\#\documents\visual studio 2015\Projects\DLLproj\DLLproj\Mem.cpp(112): error C2664: 'int _wcsicmp(const wchar_t *,const wchar_t *)': cannot convert argument 1 from 'char [256]' to 'const wchar_t *'
    1> ..\..\..\..\..\..\#\documents\visual studio 2015\Projects\DLLproj\DLLproj\Mem.cpp(112): note: Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
    1>..\..\..\..\..\..\#\documents\visual studio 2015\Projects\DLLproj\DLLproj\Mem.cpp(114): warning C4311: 'type cast': pointer truncation from 'BYTE *' to 'DWORD'
    1>..\..\..\..\..\..\#\documents\visual studio 2015\Projects\DLLproj\DLLproj\Mem.cpp(114): warning C4302: 'type cast': truncation from 'BYTE *' to 'DWORD'
    1>..\..\..\..\..\..\#\documents\visual studio 2015\Projects\DLLproj\DLLproj\Mem.cpp(128): error C2664: 'int _wcsicmp(const wchar_t *,const wchar_t *)': cannot convert argument 1 from 'char [256]' to 'const wchar_t *'
    1> ..\..\..\..\..\..\#\documents\visual studio 2015\Projects\DLLproj\DLLproj\Mem.cpp(128): note: Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
    1>..\..\..\..\..\..\#\documents\visual studio 2015\Projects\DLLproj\DLLproj\Mem.cpp(130): warning C4311: 'type cast': pointer truncation from 'BYTE *' to 'DWORD'
    1>..\..\..\..\..\..\#\documents\visual studio 2015\Projects\DLLproj\DLLproj\Mem.cpp(130): warning C4302: 'type cast': truncation from 'BYTE *' to 'DWORD'

    I have been looking around for days to fix but can't find anything that works.

  2. #2
    Biesi's Avatar
    Join Date
    Dec 2011
    Gender
    male
    Posts
    4,993
    Reputation
    374
    Thanks
    8,808
    My Mood
    Twisted
    Change your project from unicode to multi-byte

  3. #3
    SaplingHeros's Avatar
    Join Date
    Jan 2013
    Gender
    male
    Posts
    26
    Reputation
    10
    Thanks
    3
    Quote Originally Posted by Biesi View Post
    Change your project from unicode to multi-byte
    Already fixed the const errors, got some others.

    1>..\..\..\..\..\..\#\documents\visual studio 2015\Projects\DLLproj\DLLproj\Mem.cpp(94): error C2601: 'Mem::m_iGetModuleAddressByName': local function definitions are illegal
    1> ..\..\..\..\..\..\#\documents\visual studio 2015\Projects\DLLproj\DLLproj\Mem.cpp(43): note: this line contains a '{' which has not yet been matched
    1>..\..\..\..\..\..\#\documents\visual studio 2015\Projects\DLLproj\DLLproj\Mem.cpp(114): warning C4311: 'type cast': pointer truncation from 'BYTE *' to 'DWORD'
    1>..\..\..\..\..\..\#\documents\visual studio 2015\Projects\DLLproj\DLLproj\Mem.cpp(114): warning C4302: 'type cast': truncation from 'BYTE *' to 'DWORD'
    1>..\..\..\..\..\..\#\documents\visual studio 2015\Projects\DLLproj\DLLproj\Mem.cpp(130): warning C4311: 'type cast': pointer truncation from 'BYTE *' to 'DWORD'
    1>..\..\..\..\..\..\#\documents\visual studio 2015\Projects\DLLproj\DLLproj\Mem.cpp(130): warning C4302: 'type cast': truncation from 'BYTE *' to 'DWORD'

  4. #4
    MikeRohsoft's Avatar
    Join Date
    May 2013
    Gender
    male
    Location
    Los Santos
    Posts
    797
    Reputation
    593
    Thanks
    26,314
    let us see Line 43, 94, 114 + 130 then we can talk about more help.

  5. #5
    SaplingHeros's Avatar
    Join Date
    Jan 2013
    Gender
    male
    Posts
    26
    Reputation
    10
    Thanks
    3
    Quote Originally Posted by MikeRohsoft View Post
    let us see Line 43, 94, 114 + 130 then we can talk about more help.
    Fixed the errors already, got 2 more and can't find them at all.
    Error (active) expected a ';'
    Error (active) expected a declaration

    This seems like a fucking easy error to fix but I can't find it and it's frustrating.

    Code:
    #include "stdafx.h"
    
    int XMemory::m_iDetaching()
    {
    	if (!m_hndProcessHandle)
    	{
    		std::wstring wsErrorText = L"'m_iDetaching' : Invalid handle specified.";
    		Debug.m_fnAddError(wsErrorText, 1);
    		return 1;
    	}
    	if (!CloseHandle(m_hndProcessHandle))
    	{
    		std::wstring wsErrorText = L"'m_iDetaching' : Failed to close handle.";
    		Debug.m_fnAddError(wsErrorText, 2);
    		return 2;
    	}
    	return 0;
    }
    int XMemory::m_iAttaching()
    {
    	if (m_iGetProcessHandleByName(&m_hndProcessHandle, Silver.m_wXProcessName))
    	{
    		std::wstring wsErrorText = L"'m_iAttaching' : Failed to get '"; wsErrorText += Silver.m_wXProcessName; wsErrorText += L"' handle.";
    		Debug.m_fnAddError(wsErrorText, 1);
    		return 1;
    	}
    	if (m_iGetModuleAddressByName(&m_dwClientModuleBaseAddress, Silver.m_wXClientModuleName, m_hndProcessHandle))
    	{
    
    		std::wstring wsErrorText = L"'m_iAttaching' : Failed to get '"; wsErrorText += Silver.m_wXClientModuleName; wsErrorText += L"' handle.";
    		Debug.m_fnAddError(wsErrorText, 2);
    		return 2;
    	}
    	if (m_iGetModuleAddressByName(&m_dwEngineModuleBaseAddress, Silver.m_wXEngineModuleName, m_hndProcessHandle))
    	{
    		std::wstring wsErrorText = L"'m_iAttaching' : Failed to get '"; wsErrorText += Silver.m_wXEngineModuleName; wsErrorText += L"' handle.";
    		Debug.m_fnAddError(wsErrorText, 3);
    		return 3;
    	}
    	return 0;
    }
    int XMemory::m_iGetProcessHandleByName(HANDLE* phndOutput, std::wstring wXProcessName)
    {
    	if (!phndOutput)
    	{
    		std::wstring wsErrorText = L"'m_iGetProcessHandleByName' : Invalid pointer specified.";
    		Debug.m_fnAddError(wsErrorText, 1);
    		return 1;
    	}
    	PROCESSENTRY32 p32Entry;
    	p32Entry.dwSize = sizeof(PROCESSENTRY32);
    	HANDLE hndProcessHandle = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
    	if (!hndProcessHandle)
    	{
    		std::wstring wsErrorText = L"'m_iGetProcessHandleByName' : Failed to create snapshot handle.";
    		Debug.m_fnAddError(wsErrorText, 2);
    		return 2;
    	}
    	if (Process32First(hndProcessHandle, &p32Entry) == TRUE)
    	{
    		if (!_wcsicmp(p32Entry.szExeFile, wXProcessName.c_str()))
    		{
    			HANDLE hndProcessHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, p32Entry.th32ProcessID);
    			if (!hndProcessHandle)
    			{
    				std::wstring wsErrorText = L"'m_iGetProcessHandleByName' : Failed to open process handle.";
    				Debug.m_fnAddError(wsErrorText, 3);
    				return 3;
    			}
    			*phndOutput = hndProcessHandle;
    			return 0;
    		}
    		else
    		{
    			while (Process32Next(hndProcessHandle, &p32Entry) == TRUE)
    			{
    				if (!_wcsicmp(p32Entry.szExeFile, wXProcessName.c_str()))
    				{
    					HANDLE hndProcessHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, p32Entry.th32ProcessID);
    					if (!hndProcessHandle)
    					{
    						std::wstring wsErrorText = L"'m_iGetProcessHandleByName' : Failed to open process handle.";
    						Debug.m_fnAddError(wsErrorText, 4);
    						return 4;
    					}
    					*phndOutput = hndProcessHandle;
    					return 0;
    				}
    			}
    		}
    	}
    	int m_iGetProcessHandleByName(HANDLE* phndOutput, std::wstring wsProcessName)
    	{
    		if (!phndOutput)
    		{
    			std::wstring wsErrorText = L"'m_iGetProcessHandleByName' : Invalid pointer specified.";
    			Debug.m_fnAddError(wsErrorText, 1);
    			return 1;
    		}
    		PROCESSENTRY32 p32Entry;
    		p32Entry.dwSize = sizeof(PROCESSENTRY32);
    		HANDLE hndProcessHandle = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
    		if (!hndProcessHandle)
    		{
    			std::wstring wsErrorText = L"'m_iGetProcessHandleByName' : Failed to create snapshot handle.";
    			Debug.m_fnAddError(wsErrorText 2);
    			return 2;
    		}
    		if (Module32First(hndProcessHandle, &m32Entry) == TRUE)
    		{
    			if (!_wcsicmp(m32Entry.szModule, wsModuleName.c_str()))
    			{
    				DWORD dwModuleAdress = (DWORD)m32Entry.modBaseAddr;
    				if (!dwModuleAddress)
    				{
    					std::wstring wsErrorText = L"'m_iGetModuleAddressByName' : Invalid address found.";
    					Debug.m_fnAddError(wsErrorText, 3);
    					return 3;
    				}
    				*pdwOutput = dwModuleAddress;
    				return 0;
    			}
    			else {
    				while (Module32Next(hndModuleHandle, &m32Entry) == TRUE)
    				{
    					if (!_wsicmp(m32Entry.szModule, wsModuleName.c_str()))
    					{
    						DWORD dwModuleAddress = (DWORD)m32Entry.modBaseAddr;
    						if (!dwModuleAddress)
    						{
    							std::wstring wsErrorText = L"'m_iGetModuleAddressByName' : Invalid Address found.";
    							Debug.m_fnAddError(wsErrorText, 4);
    							return 4;
    						}
    						*pdwOutput = dwModuleAddress;
    						return 0;
    					}
    				}
    				CloseHandle(hndProcessHandle);
    				std::wstring wsErrorText = L"'m_iGetProcessHandleByName' : Failed to find process.";
    				Debug.m_fnAddError(wsErrorText, 5);
    				return 5;
    			}
    		}
    	}

  6. #6
    MikeRohsoft's Avatar
    Join Date
    May 2013
    Gender
    male
    Location
    Los Santos
    Posts
    797
    Reputation
    593
    Thanks
    26,314
    Quote Originally Posted by SaplingHeros View Post
    Fixed the errors already, got 2 more and can't find them at all.
    Error (active) expected a ';'
    Error (active) expected a declaration

    This seems like a fucking easy error to fix but I can't find it and it's frustrating.
    I event can't compile it, on my IDE i get more than only 2 Syntax Errors
    Maybe this helps:
    Code:
    #include "stdafx.h"
    #include <windows.h>
    #include <iostream>
    #include <stdio.h>
    #include <TlHelp32.h>
    
    
    __int64 GetModuleBaseAddress(LPCWSTR szProcessName, LPCWSTR szModuleName)
    {
    	HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
    	PROCESSENTRY32 pe32;
    
    	if (hSnap == INVALID_HANDLE_VALUE)
    	{
    		return 0;
    	}
    	pe32.dwSize = sizeof(PROCESSENTRY32);
    	if (Process32First(hSnap, &pe32) == 0)
    	{
    		CloseHandle(hSnap);
    		return 0;
    	}
    
    	do
    	{
    		if (lstrcmp(pe32.szExeFile, szProcessName) == 0)
    		{
    			int PID;
    			PID = pe32.th32ProcessID;
    
    			HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, PID);
    			MODULEENTRY32 xModule;
    
    			if (hSnap == INVALID_HANDLE_VALUE)
    			{
    				return 0;
    			}
    			xModule.dwSize = sizeof(MODULEENTRY32);
    			if (Module32First(hSnap, &xModule) == 0)
    			{
    				CloseHandle(hSnap);
    				return 0;
    			}
    
    			do
    			{
    				if (lstrcmp(xModule.szModule, szModuleName) == 0)
    				{
    					CloseHandle(hSnap);
    					return (__int64)xModule.modBaseAddr;
    				}
    			} while (Module32Next(hSnap, &xModule));
    			CloseHandle(hSnap);
    			return 0;
    		}
    	} while (Process32Next(hSnap, &pe32));
    	CloseHandle(hSnap);
    	return 0;
    }
    
    int main()
    {
    	wchar_t* wCharWindowName = L"Grand Theft Auto V";
    	wchar_t* GameTitle = L"GTA5.exe";
    	
    	HWND WindowHandle = FindWindow(NULL, wCharWindowName);
    	
    	__int64 baseaddr = GetModuleBaseAddress(GameTitle, GameTitle);
    	DWORD NamePointer = 0x23713DE;
    	DWORD PlayerInfo = 0x1B29400;
    	DWORD PlayerOffset = 0x280;
    	float value = 0; 
    	
    	DWORD pid; 
    	GetWindowThreadProcessId(WindowHandle, &pid); 
    	HANDLE phandle = OpenProcess(PROCESS_ALL_ACCESS, 0, pid); 
    	char* buffer = new char[1];
    	ReadProcessMemory(phandle, (void*)(baseaddr + 0x23713DE), &buffer[0], 10, 0);
    	std::cout << "PlayerName: " << buffer;
    	__int64  pLifeAddress = 0;
    	while (1)  
    	{
    		float Life = 0;
    		
    		ReadProcessMemory(phandle, (void*)(baseaddr + PlayerInfo), &pLifeAddress, sizeof(pLifeAddress), 0);
    		ReadProcessMemory(phandle, (void*)(pLifeAddress + PlayerOffset), &Life, sizeof(Life), 0);
    
    		std::cout << Life << "\n";
    		Sleep(1000);
    	}
    	return 0;
    }

Similar Threads

  1. errors while i reopen project in visual studio 2012 Ultimate
    By samerlol in forum Visual Basic Programming
    Replies: 0
    Last Post: 10-11-2013, 01:10 PM
  2. [Help] Compiler Error: Visual Studios 2012 Ultimate
    By iTangerine in forum C++/C Programming
    Replies: 6
    Last Post: 05-15-2013, 10:29 AM
  3. [Help Request] Visual Studios Error
    By deinemudda012345 in forum C# Programming
    Replies: 1
    Last Post: 12-27-2012, 05:41 AM
  4. [Solved] Microsoft Visual Studio 2010 Express*Error*
    By CookieMonster™ in forum Combat Arms Coding Help & Discussion
    Replies: 3
    Last Post: 04-06-2012, 03:32 PM
  5. Visual Studio Include Error [Help]
    By Shadow` in forum Combat Arms Coding Help & Discussion
    Replies: 3
    Last Post: 02-22-2012, 04:40 PM