Thread: Weird compiling error?

  1. #1
    60% Braindead
    Join Date
    Dec 2005

    Question Weird compiling error?

    I'm getting a really weird compiler error, I can guess what it means but I have absolutely no idea how to fix this.

    Compiler/OS: Borland BCC55 compiler, WinXP Prof.

    Warning W8012 C:\\Memsearch.cpp 38: Comparing signed and unsigned values in function Search(int)
    Error E2453 C:\\Memsearch.cpp 48: Size of the type 'void' is unknown or zero in
    function Search(int)
     VOID* LPMem;
      LPMem = mbi.BaseAddress + mbi.RegionSize; //Problem line
    I don't get why it's trying to get the size... This error is just random -,-.

    Thanks for any help in advance .

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Rishon LeZion, Israel
    what is VOID? should't it be void?

    if mbi.BaseAddress is of the type void* and you want to increment it on mbi.RegionSize elements compiler has no way to know what is the size of element the pointer points...
    if you want to skip bytes - cast it to (char*) before incrementing, if you want to skip WORDS - to WORD*, etc
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    David J. Wheeler

  3. #3
    Captain - Lover of the C
    Join Date
    May 2005
    What void is not:
    void is not a datatype
    void cannot be used for a variable declaration

    What good is void:
    void tells the compiler that a function has no return value
    void tells the compiler that a function has no parameters

    What VOID* is not:
    VOID* is not a pointer in the since that you would think of a pointer such as int* or float*
    VOID* does not have a size

    What VOID* is:
    VOID* is used to return a memory address
    VOID* is used to accept pointers of any variable type as parameters
    VOID* can point to an int, a float, a char, etc...
    VOID* can be cast to an int, float, char, etc...
    Because an int, short, char have different sizes, you would have to make a separate function for each if you wanted to return an array that could be any of them. Using VOID* allows you to return whatever array you want. It must then be cast back into the correct variable type if you want to do anything with it.
    Don't quote me on that... ...seriously

  4. #4
    60% Braindead
    Join Date
    Dec 2005
    Erm... I'm trying to skip the number of bytes equivalent to the sizeof mbi.RegionSize... Soo

      LPMem = (char*)mbi.BaseAddress + mbi.RegionSize;
    Right? It works too, wahoo!

    But I have one other issue. I'm currently comparing addresses, which is incorrect:
     LPCVOID dwAdress;
     int o = 4;
     if(dwAdress == &o)
    Correct me if I'm wrong, but this compares the adress of dwAdress and o, right? But what I actualy want, is to compare the value; But I don't get how to pull the actual value from this pointer ?

    Thank you very much for you help so far

  5. #5
    60% Braindead
    Join Date
    Dec 2005
    Ahk! What's with this? I just realized how wrong this output was:



    (Skipping in totaly weird address increments)

    Looking at my code... I really don't have any idea WHAT THE HELL I'M DOING WITH RANDOM CONVERSION EVERYWHERE >.<. Seriously, this code is a mess, it was all going well until I started with the random converting. It doesn't even convert correctly. Attempting to derefence an ojbect that you can't by doing something stupid = bad idea. -,-

    #include <iostream>
    #include <Windows.h>
    using namespace std;
    HWND subjWINDOW = FindWindow(NULL, "Calculator");
    DWORD wTP = GetWindowThreadProcessId(subjWINDOW, &dwPROCESSID);
    DWORD dwINFO = 0;
    VOID *dwAdress;
    LONG mem;
    void* LPMem;
    void Search(int o) {
     int a;
     char* buffer;
     cout << "Process ID: " << dwPROCESSID << endl; 
     LPMem = lpSYS.lpMinimumApplicationAddress;
     dwAdress = lpSYS.lpMinimumApplicationAddress;
     while(LPMem < lpSYS.lpMaximumApplicationAddress) {
      mbi.RegionSize = 0;
      mem = VirtualQueryEx(hWIN, LPMem, &mbi, sizeof(mbi));
      if(mem == sizeof(mbi)) {
        if(mbi.RegionSize > 0) {
         ReadProcessMemory(hWIN, mbi.BaseAddress, (VOID*)&buffer, mbi.RegionSize, NULL);
         if((int)*buffer == o)
          goto next;
         cout << (char*)&mbi.BaseAddress << endl;
      LPMem = (char*)mbi.BaseAddress + mbi.RegionSize;
     cout << (int)*buffer << endl;
    void main(void){
     if(subjWINDOW == NULL) {
      cout << "?No window found?" << endl;
      goto end;
     } else
     hWIN = OpenProcess(PROCESS_ALL_ACCESS, 0, dwPROCESSID);
    I'm trying to salvage it atm, but seriously, I just started converting crap everywhere without realising what I was doing -,-.

    What this should do is read the memory of (calculator) for the value of (1). Simple. What it does? Uhh, display a bunch of address's, then return a totaly irrelevant number.

  6. #6
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Hannover, Germany
    I would suggest you print your code for reference, delete the file and start totally from scratch. You aren't that far from success, but you seem confused at some points.

    Don't use global variables. You won't need a single one. Make them local to your main function and pass them as parameters when you need them. This way, aside from being correct, you will also learn what parts of your program need the information.

    main returns an int, not void.

    If you have an LPCVOID ( const void* ) do not name it dwSomething. dw is for double word, which might be correct on your platform, maybe even on others, but hungarian notation is for clarity. If it's a const void pointer, name it like a const void pointer or drop that hungarian naming scheme.

    goto. Drop it. It's not even remotely useful here. There are exceptions where one would trade an ettiquette breach using goto for multi-page codeblock, but this is not the case here. Use an if/else construct.

    You might want to read this article on dumping memory of a specific process, you are right on target.

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  7. #7
    60% Braindead
    Join Date
    Dec 2005
    Tyvm! That's precisely what I'm trying to do!

    But I have two last questions,
    LPVMOBJECT lpList;

    It gives me a compiling error (Undefined symbol 'LPVMOBJECT' ) if I try to add it, but it's in the source from the link. (Is it neccesary? I can't really see what it's for, but in the source it increments like this
    lpMem = (LPVOID)((DWORD)lpList->mbi.BaseAddress +
    which just confuses me completely (Why use lpList->mbi.Member?)

    Also, it still increments in weird values of



    I can't see a patern from this, doesn't seem to be static. -It should be incrementing staticaly, right? But I just don't see that here.

    Once again, thank you so much nvoight, I've been debugging this thing for 3 days staight without any luck, that link told me everything I needed.

  8. #8
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    You've been spending 3 days trying to hack Microsoft's calculator program?

  9. #9
    60% Braindead
    Join Date
    Dec 2005
    Yes. And it will be worth it damnit! :P.

  10. #10
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    I hope your end goal is appropriate and worthy of the effort expended thus far and possibly what you will expend in the future for it.

  11. #11
    60% Braindead
    Join Date
    Dec 2005
    Who needs a goal when you're doing something enjoyable?

    On the code side; I think I set my flags wrong though, GetLastError is returning 299 (Quote msdn: "Only part of a ReadProcessMemory or WriteProcessMemory request was completed.") Probably my tokens;

     HANDLE tProc;
     HWND tWND;
     DWORD ProcessId;
     HANDLE TokenHandle;
     LUID debugid;
     HANDLE CURRENTPROCESS = GetCurrentProcess();
     tWND = FindWindow(NULL, "Calculator");
     GetWindowThreadProcessId(tWND, &ProcessId);
     tProc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, ProcessId);
     OpenProcessToken(CURRENTPROCESS, TOKEN_QUERY, &TokenHandle);
     LookupPrivilegeValue(NULL, "SeDebugPrivilege", &debugid);
     tp.Privileges[0].Luid = debugid;
     tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
     AdjustTokenPrivileges(TokenHandle, FALSE, &tp, NULL, NULL, NULL);
    Meh... Why wont you work damn you!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Testing some code, lots of errors...
    By Sparrowhawk in forum C Programming
    Replies: 48
    Last Post: 12-15-2008, 04:09 AM
  2. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  3. Quantum Random Bit Generator
    By shawnt in forum C++ Programming
    Replies: 62
    Last Post: 06-18-2008, 10:17 AM
  4. Using VC Toolkit 2003
    By Noobwaker in forum Windows Programming
    Replies: 8
    Last Post: 03-13-2006, 07:33 AM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM