Visual studio building errors

Posts 1–6 of 6 · Page 1 of 1
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.
Change your project from unicode to multi-byte
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'
let us see Line 43, 94, 114 + 130 then we can talk about more help.
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;
			}
		}
	}
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;
}
Posts 1–6 of 6 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?