Which Module Implements Createwindoww on Windows?

I just came across issue in my application where i need to get static address of CreateWindowW function. Just like this:

&ShowWindow;

However, when doing the same trick with CreateWindowW, i get compiler error Identifier "CreateWindowW" is undefined (it's a macro). I actually cannot find where this function is defined (which DLL) and even pinvoke.net does not mention this.

On some website there is a mention it is user32.dll, but GetProcAddress for my function inside it returns null pointer. I am lost, which module on Windows is linked for this function?

If i try to connect debugger and trace call to this function, Visual Studio makes "Step over" it so i cannot understand where the call goes to..

My build is UNICODE. WinUser.h text i can see:

#define CreateWindowA(lpClassName, lpWindowName, dwStyle, x, y,\
nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)\
CreateWindowExA(0L, lpClassName, lpWindowName, dwStyle, x, y,\
nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)
#define CreateWindowW(lpClassName, lpWindowName, dwStyle, x, y,\
nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)\
CreateWindowExW(0L, lpClassName, lpWindowName, dwStyle, x, y,\
nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)
#ifdef UNICODE
#define CreateWindow  CreateWindowW
#else
#define CreateWindow  CreateWindowA
#endif // !UNICODE
3

2 Answers

CreateWindowExW is exported by user32.dll. You can just check the documentation. Or you can check the exports via e.g. Microsoft's dumpbin tool.

> dumpbin /exports c:\windows\system32\user32.dll | find /i "CreateWindow"

       1618   6D 0000A230 CreateWindowExA
       1619   6E 000107B8 CreateWindowExW
       1620   6F 00041530 CreateWindowStationA
       1621   70 000014D0 CreateWindowStationW

CreateWindowW is a thin wrapper implemented as a macro, according to its documentation:

” CreateWindow is implemented as a call to the CreateWindowEx function, as shown below.

#define CreateWindowA(lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)\
CreateWindowExA(0L, lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)

#define CreateWindowW(lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)\
CreateWindowExW(0L, lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)

#ifdef UNICODE
#define CreateWindow  CreateWindowW
#else
#define CreateWindow  CreateWindowA
#endif

You can also check that by e.g. “Go to definition” in Visual Studio.

0

If you open the CreateWindow documentation on MSDN and scroll down, you will see that it is implemented as a wrapper around CreateWindowEx. And if you open the CreateWindowEx doc and scroll down, you'll see this:

So it's implemented in User32.dll.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Marcus Vance

Marcus Vance

Cybersecurity & Digital Privacy Researcher

Marcus Vance is a cybersecurity auditor and technology writer dedicated to educating the public about online safety, data privacy regulations, enterprise security, and emerging cyber threats.

Share this article
Twitter Facebook Pinterest