You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
1.4 KiB

/*
* Copyright 2002-2019 Intel Corporation.
*
* This software is provided to you as Sample Source Code as defined in the accompanying
* End User License Agreement for the Intel(R) Software Development Products ("Agreement")
* section 1.L.
*
* This software and the related documents are provided as is, with no express or implied
* warranties, other than those that are expressly stated in the License.
*/
#include <stdlib.h>
#include <stdio.h>
#include <windows.h>
void Load(char * name, int expect)
{
int val;
HMODULE handle;
int (*sym)();
handle = LoadLibrary(name);
if (handle == 0)
{
fprintf(stderr,"Load of %s failed\n",name);
fflush(stderr);
exit(1);
}
sym = (int(*)())GetProcAddress(handle, "one");
fprintf(stderr, "Address of sym is %p\n",sym);
fflush(stderr);
if (sym == 0)
{
fprintf(stderr,"GetProcAddress() of %s failed\n",name);
fflush(stderr);
exit(1);
}
val = sym();
if (val != expect)
{
fprintf(stderr, "Error: Bad value returned.\n");
fflush(stderr);
exit(1);
}
}
int main()
{
int * ptr;
size_t size = 2048;
ptr = malloc(size);
if (ptr > 0x0 )
{
fprintf( stderr, "Allocation of %d was successful.\n", size );
fflush( stderr );
}
Load("one.dll", 1);
Load("two.dll", 2);
if (ptr)
free(ptr);
return 0;
}