Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Function Pointer? [modified]

Function Pointer? [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
question
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kiranin
    wrote on last edited by
    #1

    If we declare a function pointer as typedef void (*myPtr)(void); myptr NewPtr; This means that NewPtr is a function pointer of type myptr, where myptr is inturn a function pointer to a function which returns void and takes no function parameters.. then what does the below piece of code mean? Can somebody please interpret this piece of code for me? typedef NTSTATUS (NTAPI *pfnNtQueryInformationProcess)( IN HANDLE ProcessHandle, IN PROCESSINFOCLASS ProcessInformationClass, OUT PVOID ProcessInformation, IN ULONG ProcessInformationLength, OUT PULONG ReturnLength OPTIONAL ); pfnNtQueryInformationProcess gNtQueryInformationProcess; Thanx -- modified at 9:07 Thursday 4th October, 2007

    T D 2 Replies Last reply
    0
    • K kiranin

      If we declare a function pointer as typedef void (*myPtr)(void); myptr NewPtr; This means that NewPtr is a function pointer of type myptr, where myptr is inturn a function pointer to a function which returns void and takes no function parameters.. then what does the below piece of code mean? Can somebody please interpret this piece of code for me? typedef NTSTATUS (NTAPI *pfnNtQueryInformationProcess)( IN HANDLE ProcessHandle, IN PROCESSINFOCLASS ProcessInformationClass, OUT PVOID ProcessInformation, IN ULONG ProcessInformationLength, OUT PULONG ReturnLength OPTIONAL ); pfnNtQueryInformationProcess gNtQueryInformationProcess; Thanx -- modified at 9:07 Thursday 4th October, 2007

      T Offline
      T Offline
      toxcct
      wrote on last edited by
      #2

      exactly the same as your code, at the difference that the pfnNtQueryInformationProcess is a typedef to a function pointer to a function which returns a NTSTATUS and gets as parameters a HANDLE, a PROCESSINFOCLASS, a PVOID, an ULONG, and a PULONG... then you declare a variable gNtQueryInformationProcess of that type so defined... what don't you understand in this ?


      [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

      K 1 Reply Last reply
      0
      • K kiranin

        If we declare a function pointer as typedef void (*myPtr)(void); myptr NewPtr; This means that NewPtr is a function pointer of type myptr, where myptr is inturn a function pointer to a function which returns void and takes no function parameters.. then what does the below piece of code mean? Can somebody please interpret this piece of code for me? typedef NTSTATUS (NTAPI *pfnNtQueryInformationProcess)( IN HANDLE ProcessHandle, IN PROCESSINFOCLASS ProcessInformationClass, OUT PVOID ProcessInformation, IN ULONG ProcessInformationLength, OUT PULONG ReturnLength OPTIONAL ); pfnNtQueryInformationProcess gNtQueryInformationProcess; Thanx -- modified at 9:07 Thursday 4th October, 2007

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        pfnNtQueryInformationProcess is a function pointer to a function that returns NTSTATUS, has an NTAPI calling convention, and takes five arguments.


        "A good athlete is the result of a good and worthy opponent." - David Crow

        "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

        1 Reply Last reply
        0
        • T toxcct

          exactly the same as your code, at the difference that the pfnNtQueryInformationProcess is a typedef to a function pointer to a function which returns a NTSTATUS and gets as parameters a HANDLE, a PROCESSINFOCLASS, a PVOID, an ULONG, and a PULONG... then you declare a variable gNtQueryInformationProcess of that type so defined... what don't you understand in this ?


          [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

          K Offline
          K Offline
          kiranin
          wrote on last edited by
          #4

          Then it should have been declared as typedef NTSTATUS (*pfnNtQueryInformationProcess)( IN HANDLE ProcessHandle, IN PROCESSINFOCLASS ProcessInformationClass, OUT PVOID ProcessInformation, IN ULONG ProcessInformationLength, OUT PULONG ReturnLength OPTIONAL ); pfnNtQueryInformationProcess gNtQueryInformationProcess; What is this NTAPI in between? What is its signifance? Thanx

          T 1 Reply Last reply
          0
          • K kiranin

            Then it should have been declared as typedef NTSTATUS (*pfnNtQueryInformationProcess)( IN HANDLE ProcessHandle, IN PROCESSINFOCLASS ProcessInformationClass, OUT PVOID ProcessInformation, IN ULONG ProcessInformationLength, OUT PULONG ReturnLength OPTIONAL ); pfnNtQueryInformationProcess gNtQueryInformationProcess; What is this NTAPI in between? What is its signifance? Thanx

            T Offline
            T Offline
            toxcct
            wrote on last edited by
            #5

            kiranin wrote:

            What is this NTAPI in between

            it is the calling convention... see how it's defined if that interrest you, but it's probably one of these : __stdcall, __fastcall, __cdecl, __thiscall...


            [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

            K 1 Reply Last reply
            0
            • T toxcct

              kiranin wrote:

              What is this NTAPI in between

              it is the calling convention... see how it's defined if that interrest you, but it's probably one of these : __stdcall, __fastcall, __cdecl, __thiscall...


              [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

              K Offline
              K Offline
              kiranin
              wrote on last edited by
              #6

              hm.. yeah dats rite.. its a calling convention.. herez the piece of code frm winnt.h #if ((_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED)) && !defined(_M_AMD64) #define NTAPI __stdcall #else #define _cdecl #define NTAPI #endif Thanx :)

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups