Stworzyłam w visualu projekt c++ w którym próbuję załadować bibliotekę dll z kodem w asemblerze. Bibliotekę ładuje, ale z jakiegoś powodu nie widzi funkcji którą próbuję eksportować.
Kod w c++:
typedef int(*myType)(unsigned int, unsigned int);
typedef int(__stdcall* myTypeASM)(int, int);
int main(void)
{
HINSTANCE hinstASM = LoadLibrary(L"E:\\JA\\DllProj\\Debug\\DLLPROJ.dll");
if (!hinstASM) {
std::cout << "could not load the dynamic library in asm" << std::endl;
return EXIT_FAILURE;
}
myTypeASM functionASM = (myTypeASM)GetProcAddress(hinstASM, "count");
if (!functionASM) {
cout << "could not locate the function in asm" << std::endl;
return EXIT_FAILURE;
}
Kod asm (Prosty algorytm Euklidesa przez dzielenie):
.model flat, stdcall
.code
count proc a: DWORD, b: DWORD
mov edx, b
mov ecx, a
petla:
cmp b, 0h
jle fin
mov esp, b
xor edx, edx
mov esp, ecx
idiv b
mov b, edx
mov ecx, esp
jmp petla
fin:
mov eax, ecx
ret
count endp
end
I plik .def w projekcie z asemblerem:
LIBRARY DllProj
EXPORTS
count
Projekt w asm builduje się normalnie, gdy próbuję zrunować ten z c++ wyskakuje: "could not locate the function in asm". Nie mam pojęcia co może być tego powodem.