__declspec(dllexport) int testint = 12345;
####
#include
#include
int main( int argc, char **argv ) {
HMODULE hm = (HMODULE)LoadLibrary( "test.dll" );
int *ptestint = (int *)GetProcAddress( hm, "testint" );
printf( "Addr: %x Value: %d\n", ptestint, *ptestint );
return 1;
}
####
#! perl -slw
use strict;
use Win32;
my $dll = Win32::LoadLibrary(
'test'
) or die $^E;
my $proc = Win32::GetProcAddress(
$dll, 'testint'
) or die $^E;
print unpack 'V', unpack 'P4', pack 'L!', $proc;
__END__
C:\test>\perl32\bin\perl.exe 773754.pl
12345