Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax Error in Part2 #20

Closed
T35R6braPwgDJKq opened this issue Aug 31, 2021 · 1 comment
Closed

Syntax Error in Part2 #20

T35R6braPwgDJKq opened this issue Aug 31, 2021 · 1 comment

Comments

@T35R6braPwgDJKq
Copy link

#include <Windows.h>
typedef int (*_MessageBoxA)(
  HWND    hWnd,
  LPCTSTR lpText,
  LPCTSTR lpCaption,
  UINT    uType
);

int main(int argc, char** argv) {

    HMODULE hUser32 = LoadLibraryA("User32.dll");
    _MessageBoxA fMessageBoxA = (_MessageBoxA) GetProcAddress(hUser32, "MessageBoxA");
    fMessageBoxA(NULL, TEXT("Test"), TEXT("Something"), MB_OK);
    return 0;
}

LoadLibraryA returns HMODULE
fMessageBoxA needs LPCTSTR (wchar_t *, not char)

@plowsec
Copy link
Contributor

plowsec commented Sep 16, 2021

It's more complicated than than, since it depends on UNICODE being defined in your codebase. LPCSTR expands to the TEXT macro, which adapts the string type according to the UNICODE define.

@plowsec plowsec closed this as completed Sep 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants