|
-
Oct 18th, 2002, 05:44 PM
#1
Thread Starter
Hyperactive Member
pointer to function
hi, im reading a boox that explayed pointers to functions. but my compiler gets "error C2064: term does not evaluate to a function"
void Initialize()
{
SYSTEM_TIME_INFORMATION SysTimeInfo ;
SYSTEM_PERFORMANCE_INFORMATION SysPerfInfo ;
int retr;
HINSTANCE__ *retrh;
;
retrh = LoadLibrary("NTDLL.DLL");
GetProcAddress(retrh,"NtQuerySystemInformation");
__asm {
mov NtQuerySystemInformation,eax
}
retr = NtQuerySystemInformation(SYSTEM_TIMEINFORMATION, *SysTimeInfo, sizeof(SysTimeInfo), 0);
return;
}
I know a lot oF Vb, expert in C++, and i think in assembly.
MSVC++6.NET
vb6
masm
Windowz Xp
I find my self using this a lot in C++
__asm {
}
-
Oct 19th, 2002, 10:37 AM
#2
Uh, how did you define NtQuerySystemInformation?
If you define it correctly you can just do
NtQuerySystemInformation = GetProcAddress(...)
The first parameter to GetProcAddress should be a HMODULE, not int. On 64-bit HMODULE will be 8 bytes but int will stay 4 bytes, so you're heading into trouble.
And you call is invalid:
SYSTEM_TIMEINFORMATION
You can't pass a type as argument.
*SysTimeInfo
SysTimeInfo is not a pointer you can dereference. Do you want to pass the address of SysTimeInfo? The you must do
&SysTimeInfo
The return at the end is not necessary. You don't return a value and it is the last instruction.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Oct 19th, 2002, 06:05 PM
#3
Thread Starter
Hyperactive Member
if you would read the code you sould see that i am passing a HINSTANCE__ to the getprocaddress. thats what my compiler said it needed to be.if i NtQuerySystemInformation = GetProcAddress(...) i get a huge list of errors, my compiler doesnt like that.NtQuerySystemInformation is a int. and i do need to return at the end or my function will fall through. i dont need to return a value.
I know a lot oF Vb, expert in C++, and i think in assembly.
MSVC++6.NET
vb6
masm
Windowz Xp
I find my self using this a lot in C++
__asm {
}
-
Oct 19th, 2002, 10:45 PM
#4
Stuck in the 80s
Originally posted by Cmdr0Sunburn
if you would read the code you sould see that i am passing a HINSTANCE__ to the getprocaddress. thats what my compiler said it needed to be.if i NtQuerySystemInformation = GetProcAddress(...) i get a huge list of errors, my compiler doesnt like that.NtQuerySystemInformation is a int. and i do need to return at the end or my function will fall through. i dont need to return a value.
Your function will return at the end automatically if it was not instructed to do so before the end. Your code is just redundant.
-
Oct 19th, 2002, 11:26 PM
#5
Thread Starter
Hyperactive Member
Originally posted by The Hobo
Your function will return at the end automatically if it was not instructed to do so before the end. Your code is just redundant.
thats not what i was told in this c++ book, if you dont put a return, it will fall throught to the next block or function.
I know a lot oF Vb, expert in C++, and i think in assembly.
MSVC++6.NET
vb6
masm
Windowz Xp
I find my self using this a lot in C++
__asm {
}
-
Oct 20th, 2002, 04:00 AM
#6
Monday Morning Lunatic
No, it'll fall through to the next block within a function. Once it hits the end of the function it will automatically return anyway.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Oct 20th, 2002, 04:53 AM
#7
Sorry, I confused retr and retrh
HINSTANCE and HMODULE are both typedefs of HINSTANCE__ *, use them instead as HINSTANCE__ is just a helper construct to guarantee type safety for handles (and is unavailable if you #define NOSTRICT before you include <windows.h>)
And you NtQuerySystemInformation call reamins invalid.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Oct 20th, 2002, 03:21 PM
#8
Thread Starter
Hyperactive Member
Originally posted by CornedBee
Sorry, I confused retr and retrh
HINSTANCE and HMODULE are both typedefs of HINSTANCE__ *, use them instead as HINSTANCE__ is just a helper construct to guarantee type safety for handles (and is unavailable if you #define NOSTRICT before you include <windows.h>)
And you NtQuerySystemInformation call reamins invalid.
i know its invalid, ill deal with that later as soon as i get it to say thats its invalid function, right now it saz it isnt one at all.
Last edited by Cmdr0Sunburn; Oct 20th, 2002 at 03:25 PM.
I know a lot oF Vb, expert in C++, and i think in assembly.
MSVC++6.NET
vb6
masm
Windowz Xp
I find my self using this a lot in C++
__asm {
}
-
Oct 20th, 2002, 04:35 PM
#9
Ok, so again, how do you define NtQuerySystemInformation?
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Oct 20th, 2002, 10:18 PM
#10
Thread Starter
Hyperactive Member
thanks all, thanks a lot.!!!!!!!!!!!!!!!!!!!!!!!!!!! i got it to work. i found a c++ project that egts the cpu time.
I know a lot oF Vb, expert in C++, and i think in assembly.
MSVC++6.NET
vb6
masm
Windowz Xp
I find my self using this a lot in C++
__asm {
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|