Results 1 to 10 of 10

Thread: pointer to function

  1. #1

    Thread Starter
    Hyperactive Member Cmdr0Sunburn's Avatar
    Join Date
    May 2001
    Location
    g0t r00t?
    Posts
    461

    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 {
    }

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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.

  3. #3

    Thread Starter
    Hyperactive Member Cmdr0Sunburn's Avatar
    Join Date
    May 2001
    Location
    g0t r00t?
    Posts
    461
    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 {
    }

  4. #4
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    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.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  5. #5

    Thread Starter
    Hyperactive Member Cmdr0Sunburn's Avatar
    Join Date
    May 2001
    Location
    g0t r00t?
    Posts
    461
    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 {
    }

  6. #6
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  7. #7
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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.

  8. #8

    Thread Starter
    Hyperactive Member Cmdr0Sunburn's Avatar
    Join Date
    May 2001
    Location
    g0t r00t?
    Posts
    461
    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 {
    }

  9. #9
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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.

  10. #10

    Thread Starter
    Hyperactive Member Cmdr0Sunburn's Avatar
    Join Date
    May 2001
    Location
    g0t r00t?
    Posts
    461
    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
  •  



Click Here to Expand Forum to Full Width