Trying to Image address menu

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    Flushie's Avatar Master Sergeant
    Reputation
    -13
    Join Date
    May 2010
    Posts
    72
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Trying to Image address

    #include <windows.h> #include <Psapi.h> #include, hModular is returning error 6 which is Invalid Handle, I cant figure out whats going on

    Trying to Image address
  2. #2
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1358
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/6
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There is so much wrong with that code I don't even know where to start... Did you even TRY to read the documentation on MSDN??

    Grab the book "Windows via C/C++" and learn the basics of unmanaged Windows programming. Right now you're WAAAAAY out of your depth.

    P.S. You're lucky the Australian Open is on tonight and I'm in a good mood.

    P.P.S. You don't need to flush the output stream that often. Prefer '\n' to std::endl when you have the option. It's a LOT faster. The only reason I use std::endl in my code so much is that I often use my logging class which timestamps lines after a buffer flush. Unless you have a good reason like that, just use '\n'.
    Last edited by Cypher; 01-22-2011 at 06:59 AM.

  3. #3
    ejt's Avatar Contributor
    Reputation
    210
    Join Date
    Mar 2008
    Posts
    166
    Thanks G/R
    3/112
    Trade Feedback
    0 (0%)
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Trying to print a HANDLE, seriously?

    Seems like you are NOT ready for such programming, try going in small steps instead of jumping to the end, you wont learn anything by it.

  4. #4
    Azzie2k8's Avatar Member
    Reputation
    11
    Join Date
    Apr 2009
    Posts
    190
    Thanks G/R
    0/0
    Trade Feedback
    1 (100%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by ejt View Post
    Trying to print a HANDLE, seriously?

    Seems like you are NOT ready for such programming, try going in small steps instead of jumping to the end, you wont learn anything by it.
    I didn't look at his code but what it is the issue with printing a handle ? I mean it is just an advanced pointer and therefore should be able to print out the address ? Obviously it is not gonna tell you much about anything but you can at least see if it could be valid ?

  5. #5
    Bananenbrot's Avatar Contributor
    Reputation
    153
    Join Date
    Nov 2009
    Posts
    384
    Thanks G/R
    1/3
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think it's a matter of taste... a handle's value is nothing important for the programmer, as long as it is not invalid (NULL in this case).
    That's why I normally prefer error handling code like

    Code:
    HANDLE hProc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwProcessId);
    if (!hProc)
    {
        std::cout << "Process handle is invalid.\n";
        std::cout << "ErrorCode: " << std::hex << GetLastError() << std::endl;
    }

  6. #6
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1358
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/6
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Bananenbrot View Post
    I think it's a matter of taste... a handle's value is nothing important for the programmer, as long as it is not invalid (NULL in this case).
    That's why I normally prefer error handling code like

    Code:
    HANDLE hProc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwProcessId);
    if (!hProc)
    {
        std::cout << "Process handle is invalid.\n";
        std::cout << "ErrorCode: " << std::hex << GetLastError() << std::endl;
    }
    That could give you an invalid error code.

    You should call GetLastError DIRECTLY after you call the API (well, it doesn't necessarily have to be directly after, but it does need to be before any other statements with side-effects that could affect its value).

    Think about it... What happens if an internal API that std::cout uses fails somewhere (or even succeeds! as some APIs reset the LastError value to ERROR_SUCCESS when they succeed)?? The error code you want will be lost!

    This is how you should be doing it:
    Code:
    HANDLE hProc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwProcessId);
    if (!hProc)
    {
      DWORD const LastError = GetLastError();
      std::cout << "Process couldn't be opened.\nErrorCode: " << LastError << std::endl;
    }
    Last edited by Cypher; 01-23-2011 at 06:45 AM.

  7. #7
    Azzie2k8's Avatar Member
    Reputation
    11
    Join Date
    Apr 2009
    Posts
    190
    Thanks G/R
    0/0
    Trade Feedback
    1 (100%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Bananenbrot View Post
    I think it's a matter of taste... a handle's value is nothing important for the programmer, as long as it is not invalid (NULL in this case).
    That's why I normally prefer error handling code like

    Code:
    HANDLE hProc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwProcessId);
    if (!hProc)
    {
        std::cout << "Process handle is invalid.\n";
        std::cout << "ErrorCode: " << std::hex << GetLastError() << std::endl;
    }
    Yeah okay but I don't think that he was wrong printing it for testing reasons. This code looks nothing like a full program so as long as he is in this testing and finding out phase it isn't wrong to print a Handle so flaming him like ejt did is kinda useless since he is not doing anything wrong by printing the handle.

    Even though I agree with the rest of his statement to some extend. I know I am pointing out something small but I dunno I want to fight for the newbs since I am one myself and flaming something that is not necessarily wrong when there are other things that deserve flaming is kinda strange to me.

    Not trying to offend anyone, just saying.

  8. #8
    ramey's Avatar Member
    Reputation
    45
    Join Date
    Jan 2008
    Posts
    320
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Cypher View Post
    That could give you an invalid error code.

    You should call GetLastError DIRECTLY after you call the API (well, it doesn't necessarily have to be directly after, but it does need to be before any other statements with side-effects that could affect its value).

    Think about it... What happens if an internal API that std::cout uses fails somewhere (or even succeeds! as some APIs reset the LastError value to ERROR_SUCCESS when they succeed)?? The error code you want will be lost!

    This is how you should be doing it:
    Code:
    HANDLE hProc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwProcessId);
    if (!hProc)
    {
      DWORD const LastError = GetLastError();
      std::cout << "Process couldn't be opened.\nErrorCode: " << GetLastError() << std::endl;
    }
    On the rare occasion I get to correct Cypher, don't you mean

    Code:
    std::cout << "Process couldn't be opened.\nErrorCode: " << LastError << std::endl;
    ?

    trollface.jpg

  9. #9
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1358
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/6
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by ramey View Post
    On the rare occasion I get to correct Cypher, don't you mean

    Code:
    std::cout << "Process couldn't be opened.\nErrorCode: " << LastError << std::endl;
    ?

    trollface.jpg
    Sigh, yes.

    Kiddies, this is why you shouldn't drink and code. If you must abuse substances while you code, try smoking the reefer, I find that helps sometimes when I'm stuck on a problem.

    Corrected in my original post. Thanks.

  10. #10
    galpha's Avatar Member
    Reputation
    5
    Join Date
    Nov 2007
    Posts
    48
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Cypher View Post
    Sigh, yes.

    Kiddies, this is why you shouldn't drink and code. If you must abuse substances while you code, try smoking the reefer, I find that helps sometimes when I'm stuck on a problem.

    Corrected in my original post. Thanks.

  11. #11
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1358
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/6
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by galpha View Post
    Reddit ftw.

  12. #12
    Flushie's Avatar Master Sergeant
    Reputation
    -13
    Join Date
    May 2010
    Posts
    72
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Did I hear someone yell at me for printing a handle, hey ******* I was seeing if the Handle was properly being assigned.

    ---------- Post added at 08:26 PM ---------- Previous post was at 08:24 PM ----------

    Originally Posted by Cypher View Post
    There is so much wrong with that code I don't even know where to start... Did you even TRY to read the documentation on MSDN??

    Grab the book "Windows via C/C++" and learn the basics of unmanaged Windows programming. Right now you're WAAAAAY out of your depth.

    P.S. You're lucky the Australian Open is on tonight and I'm in a good mood.

    P.P.S. You don't need to flush the output stream that often. Prefer '\n' to std::endl when you have the option. It's a LOT faster. The only reason I use std::endl in my code so much is that I often use my logging class which timestamps lines after a buffer flush. Unless you have a good reason like that, just use '\n'.
    Yeah, I just wanted to see if I could accomplish something. Oh yeah and im reading the Windows System Programming books, they give you some pretty ****ing Epic shit.

  13. #13
    amadmonk's Avatar Active Member
    Reputation
    124
    Join Date
    Apr 2008
    Posts
    772
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Cypher View Post
    Sigh, yes.

    Kiddies, this is why you shouldn't drink and code. If you must abuse substances while you code, try smoking the reefer, I find that helps sometimes when I'm stuck on a problem.

    Corrected in my original post. Thanks.
    I find your second listed substance just makes me stupid and forgetful and I keep staring at the same three lines of code for an hour until I get confused and go watch TV. Not productive at all...
    Don't believe everything you think.

  14. #14
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1358
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/6
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by amadmonk View Post
    I find your second listed substance just makes me stupid and forgetful and I keep staring at the same three lines of code for an hour until I get confused and go watch TV. Not productive at all...
    Quality is key.

  15. #15
    suicidity's Avatar Contributor
    Reputation
    207
    Join Date
    Oct 2006
    Posts
    1,439
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by amadmonk View Post
    I find your second listed substance just makes me stupid and forgetful and I keep staring at the same three lines of code for an hour until I get confused and go watch TV. Not productive at all...
    I just go to sleep, I don't have the willpower to code or game at that point.


Page 1 of 2 12 LastLast

Similar Threads

  1. lol well, heres my try
    By Fishy80 in forum World of Warcraft Model Editing
    Replies: 14
    Last Post: 07-10-2007, 04:19 PM
  2. (Another) How to Record Your On WoW Videos. - Full Guide + Images
    By impulse102 in forum World of Warcraft Guides
    Replies: 9
    Last Post: 11-26-2006, 03:08 AM
  3. My try with editing
    By Saph in forum World of Warcraft Model Editing
    Replies: 18
    Last Post: 08-14-2006, 11:30 PM
  4. Get rid of the nocopy.jpg images
    By jaymunee80 in forum Suggestions
    Replies: 2
    Last Post: 06-28-2006, 03:12 PM
  5. Your Favorite Image Editing Programs
    By LightWave in forum Community Chat
    Replies: 5
    Last Post: 06-15-2006, 08:02 PM
All times are GMT -5. The time now is 12:03 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search