Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

compile errors

Status
Not open for further replies.

ADoozer

Programmer
Dec 15, 2002
3,487
AU
im getting 100+ errors such as these

Code:
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\../include/sstream(22) : error C2504: 'basic_streambuf' : base class undefined
        C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\../include/sstream(196) : see reference to class template instantiation 'std::basic_stringbuf<_E,_Tr,_A>' being compiled
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\../include/sstream(22) : error C2143: syntax error : missing ',' before '<'
        C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\../include/sstream(196) : see reference to class template instantiation 'std::basic_stringbuf<_E,_Tr,_A>' being compiled
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\../include/sstream(22) : error C2059: syntax error : '<'
        C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\../include/sstream(196) : see reference to class template instantiation 'std::basic_stringbuf<_E,_Tr,_A>' being compiled
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\../include/sstream(24) : error C2143: syntax error : missing ';' before '<'
        C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\../include/sstream(196) : see reference to class template instantiation 'std::basic_stringbuf<_E,_Tr,_A>' being compiled

whenever i add my file to a project i am working on.

the files being added work perfectly fine when used in other projects.

can anyone shed some light on the situation.

antihacktest.cpp code
Code:
// AntiHackTest.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "ClientAntiHack.h"

int main(int argc, char* argv[])
{
	CClientAntiHack myAntiHack;
	int i=0;
	while(i<24)
	{
		myAntiHack.RunCheck();
		bool resultant=myAntiHack.GetHackStatus();
		Sleep(10000);
		i++;
	}
	return 0;
}

ClientAntiHack.cpp
Code:
// ClientAntiHack.cpp: implementation of the CClientAntiHack class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "ClientAntiHack.h"
#include <sstream>
#include <iomanip>

#pragma comment(lib, "version.lib")

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CClientAntiHack::CClientAntiHack()
{
	AntiHackRunning=true;
	if(!GetWindowsVersion()) FlagAntiHackFail();
	HackingDetected=false;
	if(AntiHackRunning) SearchProcess();
}

CClientAntiHack::~CClientAntiHack()
{
}

bool CClientAntiHack::GetWindowsVersion()
{
	OSVersion.dwOSVersionInfoSize=sizeof(OSVERSIONINFO);
	if(!GetVersionEx(&OSVersion)) return false;
	return true;
}

bool CClientAntiHack::SearchProcess()
{
	if(OSVersion.dwPlatformId==VER_PLATFORM_WIN32_NT)// NT based OS
    {
		//load the DLL
		HINSTANCE hiDLL=LoadLibrary("PSAPI.DLL");

		if(hiDLL==NULL) 
		{
			FlagAntiHackFail();
			return false;
		}

		// PSAPI Function Pointers.
        typedef BOOL (WINAPI *LPENUMPROCESSES)(DWORD *,DWORD,DWORD *);
        typedef BOOL (WINAPI *LPENUMPROCESSMODULES)( HANDLE,HMODULE *,DWORD,LPDWORD);
        typedef DWORD (WINAPI *LPGETMODULEFILENAMEEX)( HANDLE,HMODULE,LPTSTR,DWORD);

		LPENUMPROCESSES lpfEnumProcesses = (LPENUMPROCESSES)GetProcAddress(hiDLL,"EnumProcesses");
        LPENUMPROCESSMODULES lpfEnumProcessModules = (LPENUMPROCESSMODULES)GetProcAddress(hiDLL,"EnumProcessModules");
        LPGETMODULEFILENAMEEX lpfGetModuleFileNameEx = (LPGETMODULEFILENAMEEX)GetProcAddress(hiDLL,"GetModuleFileNameExA");

		//make sure we have function pointers
		if(!lpfEnumProcesses||!lpfEnumProcessModules||!lpfGetModuleFileNameEx)
		{
			FlagAntiHackFail();
			FreeLibrary(hiDLL);
			return false;
		}

		//create a massive list, TODO, loop for specific list size
		DWORD ProcessIDList[400],dwCb=400,dwCbNeeded,cbRet;

		//fill the list with pID's
		if(!lpfEnumProcesses(ProcessIDList,dwCb,&dwCbNeeded))
        {
			FlagAntiHackFail();
			FreeLibrary(hiDLL);
			return false;
		}

		HANDLE hProcess;
		HMODULE hModule[50];
        char ModuleFileName[256];
		DWORD i=0;

		while(i<dwCbNeeded/sizeof(DWORD))
        {	
			hProcess=OpenProcess(PROCESS_QUERY_INFORMATION|PROCESS_VM_READ|PROCESS_TERMINATE,0,ProcessIDList[i++]);
			if(hProcess)
            {	
				//we have a valid process handle
				if(!lpfEnumProcessModules(hProcess,hModule,50,&cbRet)) 
				{
					//an error do something
				}
				if(!lpfGetModuleFileNameEx(hProcess,hModule[0],ModuleFileName,256))
				{
					//an error do something
				}
				
				//we have made it this far, lets see if the original filename is on the ban list
				if(CheckFilters(ModuleFileName))
				{
					//name is recognised, close process and report error
					TerminateProcess(hProcess,0);
					HackingDetected=true;
				}
				CloseHandle(hProcess);
			}
		}
		FreeLibrary(hiDLL);
		if(HackingDetected) return true;
	}
	else if(OSVersion.dwPlatformId==VER_PLATFORM_WIN32_WINDOWS)// Win 9x 
    {
	}
	else
	{
		//should never come here
	}
	return false;
}

void CClientAntiHack::FlagAntiHackFail()
{
	AntiHackRunning=false;
}

bool CClientAntiHack::CheckFilters(char *FileName)
{
	unsigned char          *resource_data_;
	version_nmsp::language *language_information_;

	std::string app_name=FileName;
	TCHAR buf[MAX_PATH] = "";

	// Get version info
    DWORD h = 0;

    DWORD resource_size = ::GetFileVersionInfoSize(const_cast<char*>(app_name.c_str()), &h);

	if(resource_size)
    {
		resource_data_ = new unsigned char[resource_size];
		if(resource_data_)
        {
			if(::GetFileVersionInfo(const_cast<char*>(app_name.c_str()),0,resource_size,static_cast<LPVOID>(resource_data_)) != FALSE)
			{
				UINT size = 0;

				// Get language information
				::VerQueryValue(static_cast<LPVOID>(resource_data_),"\\VarFileInfo\\Translation",reinterpret_cast<LPVOID*>(&language_information_),&size);

				std::stringstream t;
				LPVOID            value  = 0;

				// Build query string
				t << "\\StringFileInfo\\" << std::setw(4) << std::setfill('0') << std::hex
					<< language_information_->language_ << std::setw(4) << std::hex
					<< language_information_->code_page_ << "\\InternalName";

				::VerQueryValue(static_cast<LPVOID>(resource_data_), const_cast<LPTSTR>(t.str().c_str()),static_cast<LPVOID*>(&value),&size);
				sprintf(buf,static_cast<LPTSTR>(value));
				if(!_strnicmp(buf,"tsearch",8) || !_strnicmp(buf,"artmoney",8))
				{
					delete [] resource_data_; 
					return true;
				}
			}
		}
		delete [] resource_data_; 
	}
	return false;
}

void CClientAntiHack::RunCheck()
{
	//reset the variable
	HackingDetected=false;
	//do search
	if(AntiHackRunning) SearchProcess();
}

bool CClientAntiHack::GetHackStatus()
{
	if(HackingDetected) return true;

	return false;
}

ClientAntiHack.h
Code:
// ClientAntiHack.h: interface for the CClientAntiHack class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_CLIENTANTIHACK_H__7E4D60C9_07AF_49AC_A06B_E536C4B4D051__INCLUDED_)
#define AFX_CLIENTANTIHACK_H__7E4D60C9_07AF_49AC_A06B_E536C4B4D051__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "windows.h"

namespace version_nmsp
{
  struct language
  {
    WORD language_;
    WORD code_page_;

    language()
    {
      language_  = 0;
      code_page_ = 0;
    }
  };
}

class CClientAntiHack  
{
public:
	bool GetHackStatus();
	void RunCheck();
	bool HackingDetected;
	bool CheckFilters(char *FileName);
	void FlagAntiHackFail();
	bool SearchProcess();
	bool AntiHackRunning;
	OSVERSIONINFO OSVersion;
	bool GetWindowsVersion();
	CClientAntiHack();
	virtual ~CClientAntiHack();

};

#endif // !defined(AFX_CLIENTANTIHACK_H__7E4D60C9_07AF_49AC_A06B_E536C4B4D051__INCLUDED_)


thanks in advance.

If somethings hard to do, its not worth doing - Homer Simpson
 
Insert
Code:
#include <sstream>
#include <strstream>
in your project StdAfx.h file (remove them from ClientAntiHack.cpp source file), then compile StdAfx.h (by hand). Insert #include "StdAfx.h" in all your source files (.cpp).
I think the best approach is: insert all system headers (C++ standard headers <...> and sacramental <windows.h> too)in StdAfx.h, don't forget to compile it after every new header and don't forget to add #include "StdsAfx.h" in every cpp. So (for standard VS project settings) you can use all advantages of VS precompiled headers.
Install (or check up if it's installed) VS 6.0 SP5.

May be it helps...
 
ive tried moving the include to stdafx and recompiling.

again it works in my test app, but when i try and include it into my other project i get the 100+ errors.

any more ideas?

If somethings hard to do, its not worth doing - Homer Simpson
 
i have a bit more information about the project im trying to insert the code into.

there seems to be a shared version of sstream (D:\proj\LT2\lithshared\stl\sstream) could that cause conflicts?

ive tried commenting out my #include in the stdafx file, but got 17 errors saying that string wasnt a member of std and so on.

i got similar errors when i used the exact path to the existing sstream file (about string not being a member of std etc)

the code in the project is written in C not C++ (or looks to use more C conventions at least)

im still baffled. thnx in advance

If somethings hard to do, its not worth doing - Homer Simpson
 
never mind, i modified the code to not use sstream at all

Code:
bool CClientAntiHack::CheckFilters(char *FileName)
{
	unsigned char          *resource_data_;
	version_nmsp::language *language_information_;

	TCHAR buf[MAX_PATH] = "";

	// Get version info
    DWORD h = 0;

    DWORD resource_size = ::GetFileVersionInfoSize(const_cast <char*>(FileName), &h);

	if(resource_size)
    {
		resource_data_ = new unsigned char[resource_size];
		if(resource_data_)
        {
			if(::GetFileVersionInfo(const_cast <char*>(FileName),0,resource_size,static_cast<LPVOID>(resource_data_)) != FALSE)
			{
				UINT size = 0;

				// Get language information
				::VerQueryValue(static_cast<LPVOID>(resource_data_),"\\VarFileInfo\\Translation",reinterpret_cast<LPVOID*>(&language_information_),&size);

				TCHAR queryString[MAX_PATH]="";
				LPVOID            value  = 0;

				// Build query string
				sprintf(queryString,"\\StringFileInfo\\%04x%04x\\InternalName",language_information_->language_,language_information_->code_page_);

				::VerQueryValue(static_cast<LPVOID>(resource_data_), const_cast<LPTSTR>(queryString),static_cast<LPVOID*>(&value),&size);
				sprintf(buf,static_cast<LPTSTR>(value));
				if(!_strnicmp(buf,"tsearch",8) || !_strnicmp(buf,"artmoney",8))
				{
					delete [] resource_data_; 
					return true;
				}
			}
		}
		delete [] resource_data_; 
	}
	return false;
}

If somethings hard to do, its not worth doing - Homer Simpson
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top