Hev Value at Pointer

How do I do it?

This won't work:

char buf[255];
wsprintf(buf,"HEX VALUE  == %x",*p);

MessageBox(NULL,buf,"Error",MB_OK);
LVL 1
edvinsonAsked:
Who is Participating?
 
jkrCommented:
So you mean that it works for you? Well, that code does for me *g*
0
 
AxterCommented:
You're using wsprintf with a ANSI buffer.
If p is a pointer, try the following instead:
sprintf(buf,"HEX VALUE  == %x", p); //Don't dereference p
0
 
edvinsonAuthor Commented:
Getting this error:

Error      1      error C2664: 'wsprintfW' : cannot convert parameter 1 from 'char [255]' to 'LPWSTR'


0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
jkrCommented:
It seems that you have "UNICODE" defined somewhere in your code which uses the wide character version. Just use the exact line Axter has posted

sprintf(buf,"HEX VALUE  == %x", p); //Don't dereference p

or

wsprintfA(buf,"HEX VALUE  == %x", p); //Don't dereference p

explicitly.
0
 
edvinsonAuthor Commented:
IMO, I don't think I am using UNICODE anywhere.

My project settings:

Character set:         Not Set


Here is my entire function: (JKR you should know this by heart by now) :)

bool CheckNag()

{
     char * p;  
     p = (char *)  &Nag;
     p += fudge;  

      // Messagebox the value
      // Print first hex values

      char buf[255];
        sprintf(buf,"HEX VALUE  == %x", p); //Don't dereference p
        MessageBox(NULL,buf,"Error",MB_OK);
      
        if( *p != 0xFF )
            return false;

        return true;
}
0
 
jkrCommented:
Aaah, I see, you want to see the hex value that 'p' points to as in your other Q - try

bool CheckNag()

{
     char * p;  
     p = (char *)  &Nag;
     p += fudge;  

     // Messagebox the value
     // Print first hex values

     char buf[255];
     char c = *((char*) p);
     int val = (int) c;
        wsprintfA(buf,"HEX VALUE  == 0x%2.2x", val)
        MessageBox(NULL,buf,"Error",MB_OK);
     
        if( *p != 0xFF )
            return false;

        return true;
}
0
 
edvinsonAuthor Commented:
cool, thanks jkr.

I am being returned this in the message box:

0xffffffff

so what's the problem now?

Are my variable types off?

I am checking the value 0xFF against 0xffffffff

What needs to be done? Ugh... I am so close I can feel it! :)

0
 
jkrCommented:
How are you using that? As I told you, that doesn't make sense for inline functions.

BTW - the format string is "0x%2.2x", isn't it?
0
 
edvinsonAuthor Commented:
Ok, lol, here is the whole ball of wax:

#include <windows.h>


void Nag()
{  

      MessageBox(NULL, TEXT("Please Pay!"), TEXT("Note"), MB_OK);

}

#define fudge  14;


bool CheckNag()

{
     char * p;  
     p = (char *)  &Nag;
     p += fudge;  

     // Messagebox the value
     // Print first hex values

     char buf[255];
     char c = *((char*) p);
     int val = (int) c;
        wsprintfA(buf,"HEX VALUE  == 0x%2.2x", val);
        MessageBox(NULL,buf,"Error",MB_OK);
     
        if( *p != 0xFF )
            return false;

        return true;
}


int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
    LPSTR lpCmdLine, int nCmdShow)
{

     if(CheckNag()){

      // Program runs normal. The messagebox is in tact
        MessageBox(NULL, TEXT("NO PATCH"), TEXT("Not tampered with."), MB_OK);

    } else {

     // You should be ashamed of yourself! Patching this little program!

     MessageBox(NULL, TEXT("PATCH DETECTED!"), TEXT("Program has been tampered with"), MB_OK);

   }

    return 0;
}



You know what I am trying to do by now!  This is almost all your code   :)    :)    :)

I just want to see if the call is being patched. For some reason, I am being returned a wrong result, so I am trying to MessageBox the Hev value at the location to see what exactly is being returned.

<crowd chants> JRK </crowd>
0
 
edvinsonAuthor Commented:
Are you referring to the "specifics" of this question?

If so, yes. Points awarded.


But not my problem.  I am being returned wrong results. The program is telling me it's patched, when in fact it is not.


jkr, I will give you 500 points all day long.... not concerned with points. I just want to learn, and get this working.

Do I need to begin another question? If so, how do I get a hold of you to let you know the link?

Regards,

Ed Vinson's employee, John.
0
 
edvinsonAuthor Commented:
points to jkr for the specifics stipulated.
0
 
jkrCommented:
>>jkr, I will give you 500 points all day long.... not concerned with points. I just want to learn, and get
>>this working.

That's not the point - if I have a solution for you, I'll be happy to contribute it.

>>Do I need to begin another question? If so, how do I get a hold of you to let you know the link?

If you have a new Q, just ask it. If I see that one right in time, I'll be happy to chime in, but please don't post Qs exclusively for me unless absolutely neccesary, there are a lot of great guys around here to help you.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.