Skip to content

Instantly share code, notes, and snippets.

@trevorsaudi
Last active October 16, 2023 16:07
Show Gist options
  • Select an option

  • Save trevorsaudi/6563be9c36ad135289d2e2872b67c59c to your computer and use it in GitHub Desktop.

Select an option

Save trevorsaudi/6563be9c36ad135289d2e2872b67c59c to your computer and use it in GitHub Desktop.
#include <windows.h>
#include <iostream>
int main() {
// Load the user32.dll library
HMODULE user32Dll = GetModuleHandle(L"user32.dll");
// Define a function pointer for MessageBoxW
typedef int (WINAPI* MessageBoxWFunc)(
HWND hwnd,
LPCWSTR lpText,
LPCWSTR lpCaption,
UINT uType
);
MessageBoxWFunc pMessageBoxW = (MessageBoxWFunc)GetProcAddress(user32Dll, "MessageBoxW");
// Ensure the texts are wide character strings using the 'L' notation
LPCWSTR Text = L"Hello hackers!";
LPCWSTR Title = L"Title";
// Invoke the function
int result = pMessageBoxW(nullptr, Text, Title, MB_OK);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment