Code For MessageBox [Solved]

Posts 115 of 21 · Page 1 of 2
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.
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.
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 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 ?
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 Jason View Post


Another person that is having trouble making a messagebox for their hack is NOT going to be a leecher?
.
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;
}
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.
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.
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.
Leechers going to leech. Learn to fucking code.
@[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]
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"
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]
still not working. and i tryed on visual studio c++ not working else.
Posts 115 of 21 · Page 1 of 2
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?