c++ dll exportierte varaiblen

06/10/2010 17:41 nkkk#1
c++ dll konnen ja neben Funktionen auch variablen Exportieren.
an die adressen der funktionen komme cih mittels GetProcAddress, wie bekomme ich die adressen von Exportieren Varablen?
genauso?

hie ein beispiel von GetProcAddress aus einem meiner programme

c++ code:
PHP Code:
void ThisCall(char * modName, char * funcName, int * params, int paramsAnz, void* thisPionter)
{

    
HMODULE hMod = GetModuleHandleA(modName);
    if(
hMod == 0){
        
MessageBox(0,L"Module nicht gefunden",L"FAIL",0);
        
MessageBoxA(0,modName,"Module Name:",0);
        return;
    }
    
unsigned int FuncP =  (unsigned int)GetProcAddress(hMod, funcName);
    if(
FuncP == 0){
        
MessageBox(0,L"Function nicht gefunden",L"FAIL",0);
        
MessageBoxA(0,funcName,"Function Name:",0);
        return;
    }
    
paramsAnz;
    
int* lastPlus1 = &params[paramsAnz];
    
_asm
    
{
        
push eax
        push ebx
        push ecx
        push edx

        mov ebx
, params
        mov ecx
, lastPlus1
startLoop
:
        
cmp ebx, ecx
        je end
        sub ecx
,4
        mov eax
, [ecx]
        
push eax
        jmp startLoop
end
:
        
mov ecx, thisPionter
        call FuncP


        pop edx
        pop ecx
        pop ebx
        pop eax
    
}
} 
06/12/2010 13:46 schlurmann#2
Code:
#include <windows.h>

extern "C" __declspec(dllexport) int glob = 1337;

BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
	return TRUE;
}
Code:
#include <windows.h>
#include <iostream>

int main()
{
	HMODULE dll = LoadLibraryA("dll.dll");
	int* test = (int*)GetProcAddress(dll, "glob");
	std::cout<<*test;
	return 0;
}