#include <stdio.h>
#include <windows.h>
__declspec(dllexport) void Demo ()
{
#define PASSWORD_SIZE 100
#define PASSWORD "myGOODpassword\n"
int count=0;
char buff[PASSWORD_SIZE]="";
for (;;)
{
printf("Enter password:");
fgets (&buff[0],PASSWORD_SIZE-1,stdin);
if (strcmp(&buff[0],PASSWORD))
printf ("Wrong password\n");
else break;
if (++count>2) return -1;
}
printf ("Password OK\n");
}
main()
{
HMODULE hmod;
void (*zzz) ();
if ((hmod=LoadLibrary("crack0~1.exe"))
&& (zzz=(void (*) ())GetProcAddress (h,"Demo")))
zzz();
}
Podczas kompilacji w/w kodu Visual zwraca:
Compiling...
C:\kurs\ : warning C4098: 'Demo' : 'void' function returning a value
C:\kurs\ : error C2065: 'h' : undeclared identifier
C:\kurs\ : warning C4047: 'function' : 'struct HINSTANCE__ *' differs in levels of indirection from 'int '
C:\kurs\ : warning C4024: 'GetProcAddress' : different types for formal and actual parameter 1
Error executing cl.exe.