.:: Bots United ::.  
filebase forums discord server github wiki web
cubebot epodbot fritzbot gravebot grogbot hpbbot ivpbot jkbotti joebot
meanmod podbotmm racc rcbot realbot sandbot shrikebot soulfathermaps yapb

Go Back   .:: Bots United ::. > Developer's Farm > General Programming
General Programming Help others and get yourself helped here!

Reply
 
Thread Tools
Re: loading a dll
Old
  (#11)
@$3.1415rin
Council Member, Author of JoeBOT
 
@$3.1415rin's Avatar
 
Status: Offline
Posts: 1,381
Join Date: Nov 2003
Location: Germany
Default Re: loading a dll - 17-12-2004

I guess sockets would be still the way to go ... since you can load plugins into the server without any problems, why try to do some other stuff, which might be prevented or causing other problems.


  
Reply With Quote
Re: loading a dll
Old
  (#12)
Lazy
Member
 
Lazy's Avatar
 
Status: Offline
Posts: 236
Join Date: Jan 2004
Location: Toronto, Ontario, Canada
Default Re: loading a dll - 17-12-2004

Quote:
Originally Posted by stefanhendriks
Lazy, why aren't you a heck of a bot-coder? You seem to have some pretty good knowledge about this stuff!
I can't remain focused enough unfortunately, I have ideas and always wanted to make a bot to teach people Natural Selection but keep getting lost in bloated frameworks.
Although the one I'm making now isn't bad I just have re-design parts of it.
And my math is terrible too

As for using sockets, make sure you use non-blocking sockets so the server won't have to wait for calls to recv and send to return.
  
Reply With Quote
Re: loading a dll
Old
  (#13)
dub
Member
 
dub's Avatar
 
Status: Offline
Posts: 89
Join Date: Aug 2004
Location: UK
Default Re: loading a dll - 22-12-2004

here a way windows only using CreateToolhelpSnapshot Then Module32First
& Module32Next.

Code:
class CProcess  
{
public:
	CProcess () : dwProcessID(NULL), dwThreadId(NULL), iStrLen(0) { }
	virtual	~CProcess () { }
	DWORD	GetProcessIDFromExeName (LPSTR lpExecutableName);
	MODULEENTRY32 GetModuleEntryForDll (LPSTR lpExeName, LPSTR lpDllName);
	
	HANDLE		hSnapshot;
	PROCESSENTRY32  pe32;
	MODULEENTRY32	me32;
private:
	DWORD		dwProcessID;
	DWORD		dwThreadId;
	int			iStrLen;
	char		        szExeName[64];
};

DWORD CProcess::GetProcessIDFromExeName (LPSTR lpExecutableName)
{
	if ((hSnapshot = CreateToolhelp32Snapshot (TH32CS_SNAPALL, NULL)) == INVALID_HANDLE_VALUE)
		return NULL;

	pe32.dwSize = sizeof (pe32);

	if (!Process32First(hSnapshot, &pe32))
	{
		CloseHandle (hSnapshot);
		return NULL;
	}

	// scan all the open process`s on the computer
	do
	{
		iStrLen = strlen (pe32.szExeFile);

		strcpy (szExeName, &pe32.szExeFile[iStrLen]);
		
		// skip the backward slash and get just the exe name
		// if it returns the full path name doesn`t seem to do
		// it in XP just the exe name.
		if (strstr (pe32.szExeFile, "/") != NULL)
		{
			while ((iStrLen) && (pe32.szExeFile[iStrLen-1] != '/'))
				iStrLen--;
			strcpy (szExeName, &pe32.szExeFile[iStrLen]);
		}

		// some reason break didn`t seem to work
		if (strcmpi (lpExecutableName, szExeName) == 0)
			goto done;
		
	} while (Process32Next (hSnapshot, &pe32) != 0);

done:
	CloseHandle (hSnapshot);
	return (pe32.th32ProcessID);
}

MODULEENTRY32 CProcess::GetModuleEntryForDll (LPSTR lpExeName, LPSTR lpDllName)
{
	if ((hSnapshot = CreateToolhelp32Snapshot (TH32CS_SNAPMODULE, GetProcessIDFromExeName (lpExeName))) == INVALID_HANDLE_VALUE)
	{
		ZeroMemory (&me32, sizeof (me32));
		return me32;
	}

	me32.dwSize = sizeof (me32);

	if (!Module32First (hSnapshot, &me32))
	{
		CloseHandle (hSnapshot);
		ZeroMemory (&me32, sizeof (me32));
		return me32;
	}

	// scan all the open process`s on the computer
	do
	{
		// some reason break didn`t seem to work
		if (strcmpi (lpDllName, me32.szModule) == 0)
			goto done;
		
	} while (Module32Next (hSnapshot, &me32) != 0);

done:
	CloseHandle (hSnapshot);
	return (me32);
}
after you will have full access for the dll.

Last edited by dub; 22-12-2004 at 22:29..
  
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com