Click to See Complete Forum and Search --> : About ASPI GetASPI32Buffer Question


Pechi
July 28th, 2003, 11:38 PM
typedef BOOL (*FUNC)(PASPI32BUFF);
//...
FUNC pfnGetASPI32Buffer;
pfnGetASPI32Buffer = (FUNC)GetProcAddress(hinstWNASPI32,"GetASPI32Buffer");

// Allocation 128KB Buffer
ASPI32BUFF ab;
memset(&ab,0,sizeof(ASPI32BUFF));
ab.AB_BufLen=131072lu;
ab.AB_ZeroFill=1;
//ab.AB_Reserved=0;
if(!GetASPI32Buffer(&ab))
{/*GetASPI32Buffer Fail*/}

I want Allocates 128KB Buffer for use with ASPI.
But Link error....
--------------------Configuration: x1 - Win32 Debug--------------------
Compiling...
x1.cpp
Linking...
x1.obj : error LNK2001: unresolved external symbol _GetASPI32Buffer
Debug/x1.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

x1.exe - 2 error(s), 0 warning(s)


I need DMA transfer Data,so i use ASPI Function
(GetASPI32Buffer),but VC++ display "unresolved
external symbol GetASPI32Buffer"..........

it's ment my WNASPI32.LIB no GetASPI32Buffer Function?
where can get WNASPI32.LIB have GetASPI32Buffer Function?


if no need get NEW WNASPI32.LIB ,
who can teach me experience of ASPI GetASPI32Buffer?
thx~
Peichi Hung


:confused:

Paul McKenzie
July 29th, 2003, 05:33 AM
Originally posted by Pechi
typedef BOOL (*FUNC)(PASPI32BUFF);
//...
FUNC pfnGetASPI32Buffer;
pfnGetASPI32Buffer = (FUNC)GetProcAddress(hinstWNASPI32,"GetASPI32Buffer");
if(!GetASPI32Buffer(&ab)) // Wrong!!!
Why are you calling GetASPI32Buffer() when you should be using the function pointer called pfnGetASPI32Buffer? You set up the function pointer, but you never use it. Here is the correction:

if(!pfnGetASPI32Buffer(&ab)) // Use the function pointer!!


who can teach me experience of ASPI GetASPI32Buffer?
The problem is not GetASPI32Buffer, but your misunderstanding of how to use function pointers. Please read up on general function pointer usage in your favorite C or C++ book.

Regards,

Paul McKenzie

Pechi
July 29th, 2003, 07:16 AM
thanks Paul McKenzie... :)

I used...
if(!pfnGetASPI32Buffer(&ab)) // Use the function pointer!!

but VC++ show Application Error
The instruction at "0x00000000" referenced memory at "0x00000000". The memory could not be "read".


and I used the former way...,it's have the same problem
VC++ show Application Error
The instruction at "0x00000000" referenced memory at "0x00000000". The memory could not be "read".


My Application Code:
(In .h)
typedef struct
{
LPBYTE AB_BufPointer;
DWORD AB_BufLen;
DWORD AB_ZeroFill;
DWORD AB_Reserved;
} ASPI32BUFF, *PASPI32BUFF;

BOOL (*GetASPI32Buffer) (PASPI32BUFF);

(In .Cpp)
ASPI32BUFF ab;
memset(&ab,0,sizeof(ASPI32BUFF));
ab.AB_BufLen=0x2000;
ab.AB_ZeroFill=1;
if(!GetASPI32Buffer(&ab))
{....}


Peichi Hung
:confused:

Paul McKenzie
July 29th, 2003, 09:26 AM
Originally posted by Pechi
thanks Paul McKenzie... :)

I used...
if(!pfnGetASPI32Buffer(&ab)) // Use the function pointer!!

Did you check to see if GetProcAddress returned a valid pointer? If there is an error in GetProcAddress, it returns a NULL.

BOOL (*GetASPI32Buffer) (PASPI32BUFF);

(In .Cpp)
ASPI32BUFF ab;
memset(&ab,0,sizeof(ASPI32BUFF));
ab.AB_BufLen=0x2000;
ab.AB_ZeroFill=1;
if(!GetASPI32Buffer(&ab))
How can this work? GetASPI32Buffer is a pointer, but doesn't point to a valid function -- it is uninitialized.

It would also help if you post your real code -- do not type it in -- copy and paste the code within "code" "/code" blocks.

Also, do not leave out any lines of code, it just adds to the confusion. In none of your examples do you call LoadLibrary, which must be called to get a valid HMODULE handle. Did you check the return for the LoadLibrary() function? Again, all of these questions wouldn't need to be asked if you posted your real code.

Regards,

Paul McKenzie