Page 1 of 2 12 LastLast
Results 1 to 15 of 21
  1. #1
    BlackShawarma's Avatar
    Join Date
    Nov 2009
    Gender
    male
    Location
    israel :)
    Posts
    34
    Reputation
    10
    Thanks
    1

    Code For MessageBox [Solved]

    hello, im very newibe at c++ coding im requesting for simple messagebox pop up after i injected a dll, i just need it for test it my work is working,
    im compiling with Dev-C c++,
    thanks.

  2. #2
    Hassan's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    System.Threading.Tasks
    Posts
    4,764
    Reputation
    495
    Thanks
    2,137
    My Mood
    Dead
    First include this header file:
    [highlight=c]#include <Windows.h>[/highlight]

    Then you can call the MessageBox function to create a message box at runtime, like this:

    [highlight=c]MessageBox(NULL,(LPCWSTR)L"Injected DLL successfully.",(LPCWSTR)L"Information",MB_OK);[/highlight]

    A little explanation:

    MessageBox function takes 4 parameters. The first one, which is NULL here, defines a handle to the owner window of the Message Box. By setting this parameter to NULL, this MessageBox has no owner window and is displayed independently.
    The second parameter, which is (LPCWSTR)L"Injected DLL successfully." here, defines what will be the body of the MessageBox.
    The third parameters, which is (LPCWSTR)L"Information" here, defines the title of the MessageBox dialog.
    The last parameter, which is MB_OK here, defines the behavior of the MessageBox. MB_OK will display the MessageBox with only a single Button captioned "OK".

    You can define more than 1 behaviors for the MessageBox.
    For Example:
    [highlight=c]
    MB_OK
    MB_OKCANCEL
    MB_YESNO
    MB_YESNOCANCEL
    MB_ABORTRETRYIGNORE
    MB_CANCELTRYCONTINUE
    MB_HELP
    MB_RETRYCANCEL
    [/highlight]

    You can also use them in parallel like this:
    [highlight=c]MessageBox(NULL,(LPCWSTR)L"Injected DLL successfully.",(LPCWSTR)L"Information",MB_OKCANCEL | MB_YESNO);[/highlight]

    You can also specify the icon of the MessageBox explicitly. Supported constants for setting Icons are:
    [highlight=c]
    MB_ICONEXCLAMATION
    MB_ICONWARNING
    MB_ICONINFORMATION
    MB_ICONASTERISK
    MB_ICONQUESTION
    MB_ICONSTOP
    MB_ICONERROR
    MB_ICONHAND
    [/highlight]

    Here's how to use these constants:
    [highlight=c]MessageBox(NULL,(LPCWSTR)L"DLL not injected successfully.",(LPCWSTR)L"Error Injecting DLL",MB_OK | MB_ICONEXCLAMATION);[/highlight]

    If you don't understand something, feel free to ask. Hope this helps.
    Last edited by Hassan; 08-23-2011 at 07:27 PM.

  3. #3
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,704
    Reputation
    918
    Thanks
    7,682
    My Mood
    Mellow
    Quote Originally Posted by Hassan View Post
    First include this header file:
    [highlight=c]#include <Windows.h>[/highlight]

    Then you can call the MessageBox function to create a message box at runtime, like this:

    [highlight=c]MessageBox(NULL,(LPCWSTR)L"Injected DLL successfully.",(LPCWSTR)L"Information",MB_OK);[/highlight]

    A little explanation:

    MessageBox function takes 4 parameters. The first one, which is NULL here, defines a handle to the owner window of the Message Box. By setting this parameter to NULL, this MessageBox has no owner window and is displayed independently.
    The second parameter, which is (LPCWSTR)L"Injected DLL successfully." here, defines what will be the body of the MessageBox.
    The third parameters, which is (LPCWSTR)L"Information" here, defines the title of the MessageBox dialog.
    The last parameter, which is MB_OK here, defines the behavior of the MessageBox. MB_OK will display the MessageBox with only a single Button captioned "OK".

    You can define more than 1 behaviors for the MessageBox.
    For Example:
    [highlight=c]
    MB_OK
    MB_OKCANCEL
    MB_YESNO
    MB_YESNOCANCEL
    MB_ABORTRETRYIGNORE
    MB_CANCELTRYCONTINUE
    MB_HELP
    MB_RETRYCANCEL
    [/highlight]

    You can also use them in parallel like this:
    [highlight=c]MessageBox(NULL,(LPCWSTR)L"Injected DLL successfully.",(LPCWSTR)L"Information",MB_OKCANCEL | MB_YESNO);[/highlight]

    You can also specify the icon of the MessageBox explicitly. Supported constants for setting Icons are:
    [highlight=c]
    MB_ICONEXCLAMATION
    MB_ICONWARNING
    MB_ICONINFORMATION
    MB_ICONASTERISK
    MB_ICONQUESTION
    MB_ICONSTOP
    MB_ICONERROR
    MB_ICONHAND
    [/highlight]

    Here's how to use these constants:
    [highlight=c]MessageBox(NULL,(LPCWSTR)L"DLL not injected successfully.",(LPCWSTR)L"Error Injecting DLL",MB_OK | MB_ICONEXCLAMATION);[/highlight]

    If you don't understand something, feel free to ask. Hope this helps.
    WOW you went overboard. The guy is clearly a leecher, why bother with that, he just wants:

    Code:
    MessageBoxA(NULL, "OMG IM A SPOONFED LITTLE FUCK", "GG BRO", MB_OK);

    Quote Originally Posted by Jeremy S. Anderson
    There are only two things to come out of Berkley, Unix and LSD,
    and I don’t think this is a coincidence
    You can win the rat race,
    But you're still nothing but a fucking RAT.


    ++Latest Projects++
    [Open Source] Injection Library
    Simple PE Cipher
    FilthyHooker - Simple Hooking Class
    CLR Injector - Inject .NET dlls with ease
    Simple Injection - An in-depth look
    MPGH's .NET SDK
    eJect - Simple Injector
    Basic PE Explorer (BETA)

  4. #4
    Hassan's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    System.Threading.Tasks
    Posts
    4,764
    Reputation
    495
    Thanks
    2,137
    My Mood
    Dead
    Quote Originally Posted by Jason View Post


    WOW you went overboard. The guy is clearly a leecher, why bother with that, he just wants:

    Code:
    MessageBoxA(NULL, "OMG IM A SPOONFED LITTLE FUCK", "GG BRO", MB_OK);
    LOL. I didn't wrote this for him only. Maybe some guy opens a thread, and is not a leecher, and finds this information useful ?

  5. #5
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,704
    Reputation
    918
    Thanks
    7,682
    My Mood
    Mellow
    Quote Originally Posted by Hassan View Post


    LOL. I didn't wrote this for him only. Maybe some guy opens a thread, and is not a leecher, and finds this information useful ?
    Another person that is having trouble making a messagebox for their hack is NOT going to be a leecher?

    Quote Originally Posted by Jeremy S. Anderson
    There are only two things to come out of Berkley, Unix and LSD,
    and I don’t think this is a coincidence
    You can win the rat race,
    But you're still nothing but a fucking RAT.


    ++Latest Projects++
    [Open Source] Injection Library
    Simple PE Cipher
    FilthyHooker - Simple Hooking Class
    CLR Injector - Inject .NET dlls with ease
    Simple Injection - An in-depth look
    MPGH's .NET SDK
    eJect - Simple Injector
    Basic PE Explorer (BETA)

  6. #6
    Hassan's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    System.Threading.Tasks
    Posts
    4,764
    Reputation
    495
    Thanks
    2,137
    My Mood
    Dead
    Quote Originally Posted by Jason View Post


    Another person that is having trouble making a messagebox for their hack is NOT going to be a leecher?
    .

  7. #7
    BlackShawarma's Avatar
    Join Date
    Nov 2009
    Gender
    male
    Location
    israel :)
    Posts
    34
    Reputation
    10
    Thanks
    1
    thank you so much.
    but its not working, its not
    thats the code i did,


    #include "dll.h"
    #include <windows.h>

    main()
    {
    MessageBoxA(NULL, "MSG", "MSG", MB_OK);
    return 0;
    }
    Last edited by BlackShawarma; 08-24-2011 at 05:43 AM.

  8. #8
    Hassan's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    System.Threading.Tasks
    Posts
    4,764
    Reputation
    495
    Thanks
    2,137
    My Mood
    Dead
    Quote Originally Posted by BlackShawarma View Post
    thank you so much.
    but its not working, its not
    thats the code i did,


    #include "dll.h"
    #include <windows.h>

    main()
    {
    MessageBoxA(NULL, "MSG", "MSG", MB_OK);
    return 0;
    }
    Did you read my post ? I used this MessageBox, not MessageBoxA and there is a conversion required for the strings:

    [highlight=c]MessageBox(NULL,(LPCWSTR)L"Injected DLL successfully.",(LPCWSTR)L"Information",MB_OKCANCEL | MB_YESNO);[/highlight]

    Marked Solved.
    Last edited by Hassan; 08-24-2011 at 07:43 AM.

  9. #9
    BlackShawarma's Avatar
    Join Date
    Nov 2009
    Gender
    male
    Location
    israel :)
    Posts
    34
    Reputation
    10
    Thanks
    1
    omgsh, still not working and now its shows me an error:
    D:\antihack\dllmain.cpp In function `int main()':
    D:\antihack\dllmain.cpp cannot convert `const WCHAR*' to `const CHAR*' for argument `2' to `int MessageBoxA(HWND__*, const CHAR*, const CHAR*, UINT)'
    D:\antihack\Makefile.win [Build Error] [dllmain.o] Error 1

    please some one can make the full code work? thanks.

  10. #10
    Hassan's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    System.Threading.Tasks
    Posts
    4,764
    Reputation
    495
    Thanks
    2,137
    My Mood
    Dead
    Quote Originally Posted by BlackShawarma View Post
    omgsh, still not working and now its shows me an error:
    D:\antihack\dllmain.cpp In function `int main()':
    D:\antihack\dllmain.cpp cannot convert `const WCHAR*' to `const CHAR*' for argument `2' to `int MessageBoxA(HWND__*, const CHAR*, const CHAR*, UINT)'
    D:\antihack\Makefile.win [Build Error] [dllmain.o] Error 1

    please some one can make the full code work? thanks.
    Post your code of dllmain.cpp file here. I'll post it after modification.

  11. #11
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,704
    Reputation
    918
    Thanks
    7,682
    My Mood
    Mellow
    Leechers going to leech. Learn to fucking code.

    Quote Originally Posted by Jeremy S. Anderson
    There are only two things to come out of Berkley, Unix and LSD,
    and I don’t think this is a coincidence
    You can win the rat race,
    But you're still nothing but a fucking RAT.


    ++Latest Projects++
    [Open Source] Injection Library
    Simple PE Cipher
    FilthyHooker - Simple Hooking Class
    CLR Injector - Inject .NET dlls with ease
    Simple Injection - An in-depth look
    MPGH's .NET SDK
    eJect - Simple Injector
    Basic PE Explorer (BETA)

  12. The Following User Says Thank You to Jason For This Useful Post:

    Hassan (08-24-2011)

  13. #12
    BlackShawarma's Avatar
    Join Date
    Nov 2009
    Gender
    male
    Location
    israel :)
    Posts
    34
    Reputation
    10
    Thanks
    1
    @[MPGH]Jason; what ever you say, i don't care, if you can't help so be quiet.
    @[MPGH]Hassan; thanks for your support,
    there is the code.

    [html]#include "dll.h"
    #include <windows.h>

    main()
    {
    MessageBox(NULL,(LPCWSTR)L"Injected DLL successfully.",(LPCWSTR)L"Information",MB_OKCANCEL | MB_YESNO);

    return 0;
    }[/html]
    Last edited by BlackShawarma; 08-24-2011 at 09:29 AM.

  14. #13
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,704
    Reputation
    918
    Thanks
    7,682
    My Mood
    Mellow
    Quote Originally Posted by BlackShawarma View Post
    @[MPGH]Jason; what ever you say, i don't care, if you can't help so be quiet.
    @[MPGH]Hassan; thanks for your support,
    there is the code.

    [html]#include "dll.h"
    #include <windows.h>

    main()
    {
    MessageBox(NULL,(LPCWSTR)L"Injected DLL successfully.",(LPCWSTR)L"Information",MB_OKCANCEL | MB_YESNO);

    return 0;
    }[/html]
    I already helped, you just want even more goddam spoonfeeding.

    Change your goddam Character Set to "Multi-Byte"
    Last edited by Jason; 08-24-2011 at 09:35 AM.

    Quote Originally Posted by Jeremy S. Anderson
    There are only two things to come out of Berkley, Unix and LSD,
    and I don’t think this is a coincidence
    You can win the rat race,
    But you're still nothing but a fucking RAT.


    ++Latest Projects++
    [Open Source] Injection Library
    Simple PE Cipher
    FilthyHooker - Simple Hooking Class
    CLR Injector - Inject .NET dlls with ease
    Simple Injection - An in-depth look
    MPGH's .NET SDK
    eJect - Simple Injector
    Basic PE Explorer (BETA)

  15. #14
    Hassan's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    System.Threading.Tasks
    Posts
    4,764
    Reputation
    495
    Thanks
    2,137
    My Mood
    Dead
    Quote Originally Posted by BlackShawarma View Post
    @[MPGH]Jason; what ever you say, i don't care, if you can't help so be quiet.
    @[MPGH]Hassan; thanks for your support,
    there is the code.

    [html]#include "dll.h"
    #include <windows.h>

    main()
    {
    MessageBox(NULL,(LPCWSTR)L"Injected DLL successfully.",(LPCWSTR)L"Information",MB_OKCANCEL | MB_YESNO);

    return 0;
    }[/html]
    This code looks fine. It works perfectly on Visual Studio. I don't know if Dev C++'s compiler supports (LPCWSTR)L, so as Jason said, changing character set to Multi-Byte, might help. Don't know how to do it in Dev C++, but it must be in Project properties (In Visual Studio, it is in Project Properties -> Configuration Properties -> General. There you'll see Character Set property. Change it to "Use Multi-Byte Character Set". By default, it is "Use Unicode Character Set".)

    Edit: Damn, I totally forgot about it. Unicode characters require the suffix L before the string or character. If using the suffix, character set doesn't need to change. Try this:

    [highlight=c]MessageBox(NULL, L"Injected DLL successfully.", L"Information", MB_OK);[/highlight]
    Last edited by Hassan; 08-24-2011 at 09:54 AM.

  16. #15
    BlackShawarma's Avatar
    Join Date
    Nov 2009
    Gender
    male
    Location
    israel :)
    Posts
    34
    Reputation
    10
    Thanks
    1
    still not working. and i tryed on visual studio c++ not working else.

Page 1 of 2 12 LastLast

Similar Threads

  1. [Help] Codes for Downloading Progress[Solved]
    By karldeovbnet in forum Visual Basic Programming
    Replies: 5
    Last Post: 02-27-2011, 04:50 AM
  2. [Solved] Can someone fix this code for me? Or tell me what I'm doing wrong?
    By shanesurk500 in forum Call of Duty Black Ops GSC Modding Help & Discussion
    Replies: 5
    Last Post: 02-26-2011, 02:43 PM
  3. [Help] Codes for adding sites to be blocked in Host File [Solved]
    By karldeovbnet in forum Visual Basic Programming
    Replies: 7
    Last Post: 02-26-2011, 09:30 AM
  4. [SOLVED] « I need New code for Registry Booster »
    By [P]rof-[H] in forum CrossFire Help
    Replies: 12
    Last Post: 08-27-2010, 02:52 AM
  5. [SOLVED]question| codes for console
    By xloyer in forum Call of Duty Modern Warfare 2 Help
    Replies: 6
    Last Post: 06-12-2010, 06:20 AM