Re-Release - Source of a Dll loader.

Joined
Jun 23, 2006
Messages
782
Reaction score
399
Made by Sun aka Kealy(Published in NWK source).
"Modified" by meeeeh.

Code:
class IPlugins
{
public:
IPlugins();
void Load();
}
IPlugins Plugins;
IPlugins::IPlugins()
{
	this->Load();
}

void IPlugins::Load()
{
	// Loading modules in ./dlls/

	std::wstring Path = L"./dlls/";
	WIN32_FIND_DATA DataFound;
	HANDLE hFind = INVALID_HANDLE_VALUE;

	CreateDirectory(Path.c_str(), NULL);

	Path += L"*.dll";
	hFind = FindFirstFile(Path.c_str(), &DataFound);

	if (hFind != INVALID_HANDLE_VALUE)
	{
		do 
		{
			if (!(DataFound.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
			{
				// found a dll, let's load it.
				std::wstring FullName = L"./dlls/" + (std::wstring)DataFound.cFileName;
				LoadLibrary(FullName.c_str());
			}
		} while (FindNextFile(hFind, &DataFound));
	}
	FindClose(hFind);
}

This is by far better as to use a dll which is 400 kb big and has just these few lines...
You can also create a simple proxy dll and just copy the function IPlugins::Load...
 
Last edited:
Elite Diviner
Joined
Feb 8, 2012
Messages
439
Reaction score
867
Thx for your "great" work ^^


The Original compare with Strikers:
Code:
void IPlugins::Load()
{
    // Loading modules in ./Plugins/




[B]    [COLOR=#333333]std::wstring Path = L"./dlls/"; 
[/COLOR][/B]        //std::wstring Path = L"./Plugins/";
    WIN32_FIND_DATA DataFound;
    HANDLE hFind = INVALID_HANDLE_VALUE;


    CreateDirectory(Path.c_str(), NULL);


    Path += L"*.dll";
    hFind = FindFirstFile(Path.c_str(), &DataFound);


    if (hFind != INVALID_HANDLE_VALUE)
    {
        do 
        {
            if (!(DataFound.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
            {
                // found a dll, let's load it.
                std::wstring FullName = L"./[B]dlls[/B]/" + (std::wstring)DataFound.cFileName;
[B]                                 LoadLibrary(FullName.c_str());[/B]
                //Module *Plugin = new Module(FullName);
                //if (Plugin->GetModule()) this->m_Plugins.push_back(Plugin);
                //else delete Plugin;
            }
        } while (FindNextFile(hFind, &DataFound));
    }
    FindClose(hFind);
}

I think people who can compile a DLL Loader and use it for their projects, are even be able to change 2-3 lines in Kealys Source :p

You have 20x times more interesting code you could post :)
 
Joined
Jun 23, 2006
Messages
782
Reaction score
399
Yup, but I released this because I know what sirix said to us.
And that's why I'd never use any of his dlls, so I try to help people, with easy stuff like a dll loader.

And no. It's easy to compile something, but if you don't know what Plugin->GetModule(), this->m_Plugins.push_back(Plugin); do, you can't change it to LoadLibrary(FullName.c_str());, cause you don't know, what these functions do.
My sources wouldn't help people who can code... Everything I did is easy.
BUT it would help leecher and people who claim rights for my sources then...
You can find it in many releases, people build stuff based on other sources and they claim the rights that they did it >.>. Yeah, these people did it, they could copy 90% of someone else, add 10% of themself and release it as their own.
Also please use
this keeps the thread small :p
 
Last edited:
Elite Diviner
Joined
Feb 8, 2012
Messages
439
Reaction score
867
Okay but you could post library functions like, Player / Item / Monster / Summon and so on.
I respect the work of others. But without reading source from others i wouldnt never get into Kal Dev Coding, because it helps to understand how things work. C++ is the basic, but to use it for Kal Development is another thing.

Nearly all my Code Releases are not Projectfiles, wich can be loaded directly in Visual Studio.
You can see the Code and then you can learn from it, how things can be done, but you cant open my Project edit 5 lines and press compile^^

If i wouldnt have Kealys Source or some old Sources from DeathArt + many other snippets, i wouldnt be at the point where i am now. And reinventing the wheel is also wrong i think.

I hope i never forgot to credit someone and i never saw that someone used my Code, recompiled it and said that it is his own.
It is your good right to keep your sources private, its just an thought.
Ty for the hint, i will try to use Spoiler in the future if the Post will be too long otherwise :)
 
Joined
Jun 23, 2006
Messages
782
Reaction score
399
You can create them by yourself.. I told you how to, so do it :p. Once I gave you a part of mine icchar. ..
 
Skilled Illusionist
Joined
Mar 20, 2009
Messages
374
Reaction score
378
i tryed that but keep getting this error
Code:
1>DllLoader.cpp(19): error C2664: 'CreateDirectoryA': Konvertierung des Parameters 1 von 'const wchar_t *' in 'LPCSTR' nicht möglich
1>          Die Typen, auf die verwiesen wird, sind nicht verknüpft; die Konvertierung erfordert einen reinterpret_cast-Operator oder eine Typumwandlung im C- oder Funktionsformat.
1>DllLoader.cpp(22): error C2664: 'FindFirstFileA': Konvertierung des Parameters 1 von 'const wchar_t *' in 'LPCSTR' nicht möglich
1>          Die Typen, auf die verwiesen wird, sind nicht verknüpft; die Konvertierung erfordert einen reinterpret_cast-Operator oder eine Typumwandlung im C- oder Funktionsformat.
1>DllLoader.cpp(31): error C2440: 'Typumwandlung': 'CHAR [260]' kann nicht in 'std::wstring' konvertiert werden
1>          Quelltyp konnte von keinem Konstruktor angenommen werden, oder die Überladungsauflösung des Konstruktors ist mehrdeutig
1>DllLoader.cpp(32): error C2664: 'LoadLibraryA': Konvertierung des Parameters 1 von 'const wchar_t *' in 'LPCSTR' nicht möglich
1>          Die Typen, auf die verwiesen wird, sind nicht verknüpft; die Konvertierung erfordert einen reinterpret_cast-Operator oder eine Typumwandlung im C- oder Funktionsformat.

Code:
error C2664: 'CreateDirectoryA': Can not convert parameter 1 from 'const wchar_t *' to 'LPCSTR'
error C2664: 'FindFirstFileA': can not convert parameter 1 from 'const wchar_t *' to 'LPCSTR'
error C2440: 'Type cast': 'CHAR [260]' can not be converted to 'std :: wstring'
error C2664: 'LoadLibraryA': can not convert parameter 1 from 'const wchar_t *' to 'LPCSTR'


maybe anyone know what im doing wrong?

nvm.
sloved the problem.
 
Last edited:
Elite Diviner
Joined
Feb 28, 2013
Messages
400
Reaction score
145
Can Anyone reupload the DLLloader please not the source i want the .dll please

Thanks ,
TaP
 
Back
Top