?
Solved

How call win32 func using pointer?

Posted on 2002-05-23
1
Medium Priority
?
291 Views
Last Modified: 2013-12-03
I want to store the address of a win32 function (for example GetLocalTime) in a pointer var and then
use the pointer var to call GetLocalTime. While assigning the offset of GetLocalTime to pointer var,
I would like to add in an additional value like a random number, say 37, which I'll subtract back off
before calling. My C/C++ is pretty weak but in ASM it looks like:

RNDNUM    = 37
mov       [ptrGLT],offset GetLocalTime + RNDNUM
sub       [ptrGLT],RNDNUM
call      [ptrGLT],offset SystemTime
0
Comment
Question by:mortonsw
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 1

Accepted Solution

by:
RolandAZ earned 400 total points
ID: 7031548

MortonSW,


create a new type for the function pointer:
typedef void ( __stdcall *LPFUNCGETLOCALTIME) (LPSYSTEMTIME);

////
SYSTEMTIME systemTime;
LPFUNCGETLOCALTIME fPtrGETLOCALTIME;
DWORD RNDNUM = 37;
     
fPtrGETLOCALTIME = &GetLocalTime;  //get address
//your math
fPtrGETLOCALTIME = (LPFUNCGETLOCALTIME)((DWORD)
                         fPtrGETLOCALTIME + RNDNUM);
fPtrGETLOCALTIME = (LPFUNCGETLOCALTIME)((DWORD)
                        fPtrGETLOCALTIME - RNDNUM);
//---
fPtrGETLOCALTIME(&systemTime); //the function call


Works on Win2k ...
Copy and paste to try it in your program..

Have fun...
Roland
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question