ReactOS 0.4.16-dev-292-gbbdcc14
rundll32.c File Reference
#include <stdarg.h>
#include <stdlib.h>
#include <windef.h>
#include <winbase.h>
#include <winnls.h>
#include <winuser.h>
#include <tchar.h>
#include <undocuser.h>
#include "resource.h"
Include dependency graph for rundll32.c:

Go to the source code of this file.

Classes

struct  FIND_OWNED
 

Macros

#define WIN32_NO_STATUS
 
#define FreeConvertedWideChar(lpwString)   free(lpwString)
 
#define ConvertToMultiByte(lptString)   (lptString)
 
#define FreeConvertedMultiByte(lpaString)
 

Typedefs

typedef int(WINAPIDllWinMainW) (HWND hWnd, HINSTANCE hInstance, LPWSTR lpwCmdLine, int nCmdShow)
 
typedef int(WINAPIDllWinMainA) (HWND hWnd, HINSTANCE hInstance, LPSTR lpCmdLine, int nCmdShow)
 
typedef struct FIND_OWNEDPFIND_OWNED
 

Functions

LPTSTR *WINAPI CommandLineToArgv (LPCTSTR lpCmdLine, int *lpArgc)
 
void GetModuleTitle (void)
 
LPWSTR ConvertToWideChar (LPCSTR lpString)
 
LPSTR DuplicateToMultiByte (LPCTSTR lptString, size_t nBufferSize)
 
static BOOL CALLBACK EnumWindowsProc (HWND hwnd, LPARAM lParam)
 
LRESULT CALLBACK EmptyWindowProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
BOOL RegisterBlankClass (HINSTANCE hInstance, HINSTANCE hPrevInstance)
 
int WINAPI _tWinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
 

Variables

LPCTSTR rundll32_wtitle = _T("rundll32")
 
LPCTSTR rundll32_wclass = _T("RunDLL")
 
TCHAR ModuleFileName [MAX_PATH+1]
 
LPTSTR ModuleTitle
 

Macro Definition Documentation

◆ ConvertToMultiByte

#define ConvertToMultiByte (   lptString)    (lptString)

Definition at line 275 of file rundll32.c.

◆ FreeConvertedMultiByte

#define FreeConvertedMultiByte (   lpaString)

Definition at line 276 of file rundll32.c.

◆ FreeConvertedWideChar

#define FreeConvertedWideChar (   lpwString)    free(lpwString)

Definition at line 262 of file rundll32.c.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 24 of file rundll32.c.

Typedef Documentation

◆ DllWinMainA

typedef int(WINAPI * DllWinMainA) (HWND hWnd, HINSTANCE hInstance, LPSTR lpCmdLine, int nCmdShow)

Definition at line 42 of file rundll32.c.

◆ DllWinMainW

typedef int(WINAPI * DllWinMainW) (HWND hWnd, HINSTANCE hInstance, LPWSTR lpwCmdLine, int nCmdShow)

Definition at line 36 of file rundll32.c.

◆ PFIND_OWNED

Function Documentation

◆ _tWinMain()

int WINAPI _tWinMain ( HINSTANCE  hInstance,
HINSTANCE  hPrevInstance,
LPTSTR  lpCmdLine,
int  nCmdShow 
)

Definition at line 377 of file rundll32.c.

383{
384 int argc;
386
387 LPTSTR *argv;
388 LPTSTR lptCmdLine,lptDllName,lptFuncName,lptMsgBuffer;
389 WCHAR ResolvedFile[MAX_PATH + 1] = {0}, *lpManifestName;
390 LPSTR lpFuncName,lpaCmdLine;
391 LPWSTR lpwCmdLine;
392 HMODULE hDll;
393 DllWinMainW fnDllWinMainW;
394 DllWinMainA fnDllWinMainA;
395 HWND hWindow;
396 int i;
397 size_t nStrLen;
398
399 ACTCTXW ActCtx = {sizeof(ACTCTX), ACTCTX_FLAG_RESOURCE_NAME_VALID};
400 HANDLE hActCtx;
402 BOOL bActivated;
403
404 // Get command-line in argc-argv format
406
407 // Skip all beginning arguments starting with a slash (/)
408 for (i = 1; i < argc; i++)
409 if (*argv[i] != _T('/')) break;
410
411 // If no dll was specified, there is nothing to do
412 if (i >= argc) {
413 if (argv) free(argv);
414 return 0;
415 }
416
417 lptDllName = argv[i++];
418
419 // The next argument, which specifies the name of the dll function,
420 // can either have a comma between it and the dll filename or a space.
421 // Using a comma here is the preferred method
422 if (i < argc)
423 lptFuncName = argv[i++];
424 else
425 lptFuncName = _T("");
426
427 // If no function name was specified, nothing needs to be done
428 if (!*lptFuncName) {
429 if (argv) free(argv);
430 return 0;
431 }
432
433 // The rest of the arguments will be passed to dll function
434 if (i < argc)
435 lptCmdLine = argv[i];
436 else
437 lptCmdLine = _T("");
438
439 lpManifestName = lptDllName;
441 {
442 LPWSTR FilePart = NULL;
443 if (SearchPathW(NULL, lptDllName, NULL, _countof(ResolvedFile) - 1, ResolvedFile, &FilePart))
444 {
445 lpManifestName = ResolvedFile;
446 }
447 }
448
449 // FIXME: If there is a .manifest file next to the input file, we should use that instead!
450 ActCtx.lpSource = lpManifestName;
451 ActCtx.lpResourceName = (LPCWSTR)123;
452 hActCtx = CreateActCtx(&ActCtx);
453 bActivated = (hActCtx != INVALID_HANDLE_VALUE ? ActivateActCtx(hActCtx, &cookie) : FALSE);
454
455 // Everything is all setup, so load the dll now
456 hDll = LoadLibrary(lptDllName);
457 if (hDll) {
458 nStrLen = _tcslen(lptFuncName);
459 // Make a non-unicode version of the function name,
460 // since that is all GetProcAddress accepts
461 lpFuncName = DuplicateToMultiByte(lptFuncName,nStrLen + 2);
462
463#ifdef UNICODE
464 lpFuncName[nStrLen] = 'W';
465 lpFuncName[nStrLen+1] = 0;
466 // Get address of unicode version of the dll function if it exists
467 fnDllWinMainW = (DllWinMainW)GetProcAddress(hDll,lpFuncName);
468 fnDllWinMainA = 0;
469 if (!fnDllWinMainW) {
470 // If no unicode function was found, get the address of the non-unicode function
471 lpFuncName[nStrLen] = 'A';
472 fnDllWinMainA = (DllWinMainA)GetProcAddress(hDll,lpFuncName);
473 if (!fnDllWinMainA) {
474 // If first non-unicode function was not found, get the address
475 // of the other non-unicode function
476 lpFuncName[nStrLen] = 0;
477 fnDllWinMainA = (DllWinMainA)GetProcAddress(hDll,lpFuncName);
478 }
479 }
480#else
481 // Get address of non-unicode version of the dll function if it exists
482 fnDllWinMainA = (DllWinMainA)GetProcAddress(hDll,lpFuncName);
483 fnDllWinMainW = 0;
484 if (!fnDllWinMainA) {
485 // If first non-unicode function was not found, get the address
486 // of the other non-unicode function
487 lpFuncName[nStrLen] = 'A';
488 lpFuncName[nStrLen+1] = 0;
489 fnDllWinMainA = (DllWinMainA)GetProcAddress(hDll,lpFuncName);
490 if (!fnDllWinMainA) {
491 // If non-unicode function was not found, get the address of the unicode function
492 lpFuncName[nStrLen] = 'W';
493 fnDllWinMainW = (DllWinMainW)GetProcAddress(hDll,lpFuncName);
494 }
495 }
496#endif
497
498 free(lpFuncName);
499
500 if (!RegisterBlankClass(hInstance, hPrevInstance))
501 {
502 FreeLibrary(hDll);
503 if (bActivated)
505 return 0;
506 }
507 // Create a window so we can pass a window handle to
508 // the dll function; this is required
510
511 if (fnDllWinMainW) {
512 // Convert the command-line string to unicode and call the dll function
513 lpwCmdLine = ConvertToWideChar(lptCmdLine);
514 fnDllWinMainW(hWindow,hInstance,lpwCmdLine,nCmdShow);
515 FreeConvertedWideChar(lpwCmdLine);
516 }
517 else if (fnDllWinMainA) {
518 // Convert the command-line string to ansi and call the dll function
519 lpaCmdLine = ConvertToMultiByte(lptCmdLine);
520 fnDllWinMainA(hWindow,hInstance,lpaCmdLine,nCmdShow);
521 FreeConvertedMultiByte(lpaCmdLine);
522 }
523 else {
524 // The specified dll function was not found; display an error message
527
528 lptMsgBuffer = (LPTSTR)malloc((_tcslen(szMsg) - 4 + _tcslen(lptFuncName) + _tcslen(lptDllName) + 1) * sizeof(TCHAR));
529 _stprintf(lptMsgBuffer,szMsg,lptFuncName,lptDllName);
530 MessageBox(0,lptMsgBuffer,ModuleTitle,MB_ICONERROR);
531 free(lptMsgBuffer);
532 }
533
534 DestroyWindow(hWindow);
536
537 // The dll function has finished executing, so unload it
538 FreeLibrary(hDll);
539 }
540 else {
541 // The dll could not be loaded; display an error message
544
545 lptMsgBuffer = (LPTSTR)malloc((_tcslen(szMsg) - 2 + _tcslen(lptDllName) + 1) * sizeof(TCHAR));
546 _stprintf(lptMsgBuffer,szMsg,lptDllName);
547
548 MessageBox(0,lptMsgBuffer,ModuleTitle,MB_ICONERROR);
549 free(lptMsgBuffer);
550 }
551
552 if (bActivated)
554
555 if (argv) free(argv);
556 return 0; /* rundll32 always returns 0! */
557}
static int argc
Definition: ServiceArgs.c:12
#define RC_STRING_MAX_SIZE
Definition: resource.h:3
#define IDS_DllNotLoaded
Definition: resource.h:8
#define IDS_MissingEntry
Definition: resource.h:9
HINSTANCE hInstance
Definition: charmap.c:19
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define GetProcAddress(x, y)
Definition: compat.h:753
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define FreeLibrary(x)
Definition: compat.h:748
#define MAX_PATH
Definition: compat.h:34
BOOL WINAPI DeactivateActCtx(IN DWORD dwFlags, IN ULONG_PTR ulCookie)
Definition: actctx.c:268
BOOL WINAPI ActivateActCtx(IN HANDLE hActCtx, OUT PULONG_PTR ulCookie)
Definition: actctx.c:237
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:652
DWORD WINAPI SearchPathW(IN LPCWSTR lpPath OPTIONAL, IN LPCWSTR lpFileName, IN LPCWSTR lpExtension OPTIONAL, IN DWORD nBufferLength, OUT LPWSTR lpBuffer, OUT LPWSTR *lpFilePart OPTIONAL)
Definition: path.c:1298
unsigned int BOOL
Definition: ntddk_ex.h:94
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_In_ PCWSTR _Out_ PVOID * ActCtx
Definition: ldrtypes.h:247
#define _stprintf
Definition: utility.h:124
#define argv
Definition: mplay32.c:18
#define CommandLineToArgv
Definition: regsvr32.c:78
LPCTSTR rundll32_wtitle
Definition: rundll32.c:53
int(WINAPI * DllWinMainA)(HWND hWnd, HINSTANCE hInstance, LPSTR lpCmdLine, int nCmdShow)
Definition: rundll32.c:42
#define FreeConvertedWideChar(lpwString)
Definition: rundll32.c:262
int(WINAPI * DllWinMainW)(HWND hWnd, HINSTANCE hInstance, LPWSTR lpwCmdLine, int nCmdShow)
Definition: rundll32.c:36
BOOL RegisterBlankClass(HINSTANCE hInstance, HINSTANCE hPrevInstance)
Definition: rundll32.c:357
LPSTR DuplicateToMultiByte(LPCTSTR lptString, size_t nBufferSize)
Definition: rundll32.c:285
LPWSTR ConvertToWideChar(LPCSTR lpString)
Definition: rundll32.c:249
LPCTSTR rundll32_wclass
Definition: rundll32.c:54
void GetModuleTitle(void)
Definition: rundll32.c:218
#define ConvertToMultiByte(lptString)
Definition: rundll32.c:275
LPTSTR ModuleTitle
Definition: rundll32.c:57
#define FreeConvertedMultiByte(lpaString)
Definition: rundll32.c:276
#define _countof(array)
Definition: sndvol32.h:70
Definition: cookie.c:34
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
#define _T(x)
Definition: vfdio.h:22
#define LoadLibrary
Definition: winbase.h:3887
#define GetCommandLine
Definition: winbase.h:3824
#define GetModuleHandle
Definition: winbase.h:3852
#define CreateWindowEx
Definition: winuser.h:5767
#define UnregisterClass
Definition: winuser.h:5873
#define MB_ICONERROR
Definition: winuser.h:790
#define CW_USEDEFAULT
Definition: winuser.h:225
#define LoadString
Definition: winuser.h:5831
#define MessageBox
Definition: winuser.h:5834
BOOL WINAPI DestroyWindow(_In_ HWND)
char TCHAR
Definition: xmlstorage.h:189
char * LPSTR
Definition: xmlstorage.h:182
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
CHAR * LPTSTR
Definition: xmlstorage.h:192
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define _tcslen
Definition: xmlstorage.h:198

◆ CommandLineToArgv()

LPTSTR *WINAPI CommandLineToArgv ( LPCTSTR  lpCmdLine,
int lpArgc 
)

Definition at line 64 of file rundll32.c.

65{
66 LPTSTR *argv, lpSrc, lpDest, lpArg;
67 int argc, nBSlash, nNames;
68 BOOL bInQuotes, bFirstChar;
69
70 // If null was passed in for lpCmdLine, there are no arguments
71 if (!lpCmdLine) {
72 if (lpArgc)
73 *lpArgc = 0;
74 return 0;
75 }
76
77 lpSrc = (LPTSTR)lpCmdLine;
78 // Skip spaces at beginning
79 while (*lpSrc == _T(' ') || *lpSrc == _T('\t'))
80 lpSrc++;
81
82 // If command-line starts with null, there are no arguments
83 if (*lpSrc == 0) {
84 if (lpArgc)
85 *lpArgc = 0;
86 return 0;
87 }
88
89 lpArg = lpSrc;
90 argc = 0;
91 nBSlash = 0;
92 bInQuotes = FALSE;
93 bFirstChar = TRUE;
94 nNames = 0;
95
96 // Count the number of arguments
97 while (nNames < 4) {
98 if (*lpSrc == 0 || (*lpSrc == _T(',') && nNames == 2) || ((*lpSrc == _T(' ') || *lpSrc == _T('\t')) && !bInQuotes)) {
99 // Whitespace not enclosed in quotes signals the start of another argument
100 argc++;
101
102 // Skip whitespace between arguments
103 while (*lpSrc == _T(' ') || *lpSrc == _T('\t') || (*lpSrc == _T(',') && nNames == 2))
104 lpSrc++;
105 if (*lpSrc == 0)
106 break;
107 if (nNames >= 3) {
108 // Increment the count for the last argument
109 argc++;
110 break;
111 }
112 nBSlash = 0;
113 bFirstChar = TRUE;
114 continue;
115 }
116 else if (*lpSrc == _T('\\')) {
117 // Count consecutive backslashes
118 nBSlash++;
119 bFirstChar = FALSE;
120 }
121 else if (*lpSrc == _T('\"') && !(nBSlash & 1)) {
122 // Open or close quotes
123 bInQuotes = !bInQuotes;
124 nBSlash = 0;
125 }
126 else {
127 // Some other character
128 nBSlash = 0;
129 if (bFirstChar && ((*lpSrc != _T('/') && nNames <= 1) || nNames > 1))
130 nNames++;
131 bFirstChar = FALSE;
132 }
133 lpSrc++;
134 }
135
136 // Allocate space for the pointers in argv and the strings in one block
137 argv = (LPTSTR *)malloc(argc * sizeof(LPTSTR) + (_tcslen(lpArg) + 1) * sizeof(TCHAR));
138
139 if (!argv) {
140 // Memory allocation failed
141 if (lpArgc)
142 *lpArgc = 0;
143 return 0;
144 }
145
146 lpSrc = lpArg;
147 lpDest = lpArg = (LPTSTR)(argv + argc);
148 argc = 0;
149 nBSlash = 0;
150 bInQuotes = FALSE;
151 bFirstChar = TRUE;
152 nNames = 0;
153
154 // Fill the argument array
155 while (nNames < 4) {
156 if (*lpSrc == 0 || (*lpSrc == _T(',') && nNames == 2) || ((*lpSrc == _T(' ') || *lpSrc == _T('\t')) && !bInQuotes)) {
157 // Whitespace not enclosed in quotes signals the start of another argument
158 // Null-terminate argument
159 *lpDest++ = 0;
160 argv[argc++] = lpArg;
161
162 // Skip whitespace between arguments
163 while (*lpSrc == _T(' ') || *lpSrc == _T('\t') || (*lpSrc == _T(',') && nNames == 2))
164 lpSrc++;
165 if (*lpSrc == 0)
166 break;
167 lpArg = lpDest;
168 if (nNames >= 3) {
169 // Copy the rest of the command-line to the last argument
170 argv[argc++] = lpArg;
171 _tcscpy(lpArg,lpSrc);
172 break;
173 }
174 nBSlash = 0;
175 bFirstChar = TRUE;
176 continue;
177 }
178 else if (*lpSrc == _T('\\')) {
179 *lpDest++ = _T('\\');
180 lpSrc++;
181
182 // Count consecutive backslashes
183 nBSlash++;
184 bFirstChar = FALSE;
185 }
186 else if (*lpSrc == _T('\"')) {
187 if (!(nBSlash & 1)) {
188 // If an even number of backslashes are before the quotes,
189 // the quotes don't go in the output
190 lpDest -= nBSlash / 2;
191 bInQuotes = !bInQuotes;
192 }
193 else {
194 // If an odd number of backslashes are before the quotes,
195 // output a quote
196 lpDest -= (nBSlash + 1) / 2;
197 *lpDest++ = _T('\"');
198 bFirstChar = FALSE;
199 }
200 lpSrc++;
201 nBSlash = 0;
202 }
203 else {
204 // Copy other characters
205 if (bFirstChar && ((*lpSrc != _T('/') && nNames <= 1) || nNames > 1))
206 nNames++;
207 *lpDest++ = *lpSrc++;
208 nBSlash = 0;
209 bFirstChar = FALSE;
210 }
211 }
212
213 if (lpArgc)
214 *lpArgc = argc;
215 return argv;
216}
#define TRUE
Definition: types.h:120
#define _tcscpy
Definition: tchar.h:623

◆ ConvertToWideChar()

LPWSTR ConvertToWideChar ( LPCSTR  lpString)

Definition at line 249 of file rundll32.c.

250{
251 LPWSTR lpwString;
252 size_t nStrLen;
253
254 nStrLen = strlen(lpString) + 1;
255
256 lpwString = (LPWSTR)malloc(nStrLen * sizeof(WCHAR));
257 MultiByteToWideChar(0,0,lpString,nStrLen,lpwString,nStrLen);
258
259 return lpwString;
260}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define MultiByteToWideChar
Definition: compat.h:110

Referenced by _tWinMain().

◆ DuplicateToMultiByte()

LPSTR DuplicateToMultiByte ( LPCTSTR  lptString,
size_t  nBufferSize 
)

Definition at line 285 of file rundll32.c.

286{
287 LPSTR lpString;
288 size_t nStrLen;
289
290 nStrLen = _tcslen(lptString) + 1;
291 if (nBufferSize == 0) nBufferSize = nStrLen;
292
293 lpString = (LPSTR)malloc(nBufferSize);
294#ifdef UNICODE
295 WideCharToMultiByte(0,0,lptString,nStrLen,lpString,nBufferSize,0,0);
296#else
297 strncpy(lpString,lptString,nBufferSize);
298#endif
299
300 return lpString;
301}
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
Definition: utclib.c:427
#define WideCharToMultiByte
Definition: compat.h:111

Referenced by _tWinMain().

◆ EmptyWindowProc()

LRESULT CALLBACK EmptyWindowProc ( HWND  hWnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 320 of file rundll32.c.

321{
322 switch (uMsg)
323 {
325 case WM_SYSCOMMAND:
326 {
327 /* Find the owned window */
328 FIND_OWNED FindOwned = { hWnd, NULL };
329 EnumWindows(EnumWindowsProc, (LPARAM)&FindOwned);
330 /* Forward message */
331 if (FindOwned.hwndTarget)
332 PostMessageW(FindOwned.hwndTarget, uMsg, wParam, lParam);
333 break;
334 }
335 case WM_ACTIVATE:
336 {
337 /* Find the owned window */
338 FIND_OWNED FindOwned = { hWnd, NULL };
339 EnumWindows(EnumWindowsProc, (LPARAM)&FindOwned);
340 if (FindOwned.hwndTarget)
341 {
342 if (LOWORD(wParam) != WA_INACTIVE) /* To be activated */
343 {
344 SetActiveWindow(FindOwned.hwndTarget);
345 return 0;
346 }
347 }
348 /* Fall through */
349 }
350 default:
351 return DefWindowProc(hWnd, uMsg, wParam, lParam);
352 }
353 return 0;
354}
HWND hWnd
Definition: settings.c:17
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define DefWindowProc
Definition: ros2win.h:31
static BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
Definition: rundll32.c:309
HWND hwndTarget
Definition: rundll32.c:306
#define WM_POPUPSYSTEMMENU
Definition: undocuser.h:61
LONG_PTR LPARAM
Definition: windef.h:208
#define WM_SYSCOMMAND
Definition: winuser.h:1744
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WA_INACTIVE
Definition: winuser.h:2625
#define WM_ACTIVATE
Definition: winuser.h:1615
BOOL WINAPI EnumWindows(_In_ WNDENUMPROC lpEnumFunc, _In_ LPARAM lParam)
HWND WINAPI SetActiveWindow(_In_ HWND)

Referenced by RegisterBlankClass().

◆ EnumWindowsProc()

static BOOL CALLBACK EnumWindowsProc ( HWND  hwnd,
LPARAM  lParam 
)
static

Definition at line 309 of file rundll32.c.

310{
311 PFIND_OWNED pFindOwned = (PFIND_OWNED)lParam;
312 if (pFindOwned->hwndOwner == GetWindow(hwnd, GW_OWNER))
313 {
314 pFindOwned->hwndTarget = hwnd;
315 return FALSE;
316 }
317 return TRUE;
318}
struct FIND_OWNED * PFIND_OWNED
HWND hwndOwner
Definition: rundll32.c:305
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define GW_OWNER
Definition: winuser.h:769
HWND WINAPI GetWindow(_In_ HWND, _In_ UINT)

Referenced by EmptyWindowProc().

◆ GetModuleTitle()

void GetModuleTitle ( void  )

Definition at line 218 of file rundll32.c.

219{
220 LPTSTR lpStr;
221
224
225 for (lpStr = ModuleFileName;*lpStr;lpStr++) {
226 if (*lpStr == _T('\\'))
227 ModuleTitle = lpStr+1;
228 }
229
230 for (lpStr = ModuleTitle;*lpStr;lpStr++) {
231 if (_tcsicmp(lpStr,_T(".exe"))==0)
232 break;
233 }
234
235 *lpStr = 0;
236}
TCHAR ModuleFileName[MAX_PATH+1]
Definition: rundll32.c:56
#define GetModuleFileName
Definition: winbase.h:3856
#define _tcsicmp
Definition: xmlstorage.h:205

Referenced by _tWinMain().

◆ RegisterBlankClass()

BOOL RegisterBlankClass ( HINSTANCE  hInstance,
HINSTANCE  hPrevInstance 
)

Definition at line 357 of file rundll32.c.

358{
359 WNDCLASSEX wcex;
360
361 wcex.cbSize = sizeof(WNDCLASSEX);
362 wcex.style = 0;
364 wcex.cbClsExtra = 0;
365 wcex.cbWndExtra = 0;
366 wcex.hInstance = hInstance;
367 wcex.hIcon = 0;
368 wcex.hCursor = 0;
369 wcex.hbrBackground = 0;
370 wcex.lpszMenuName = 0;
372 wcex.hIconSm = 0;
373
374 return (RegisterClassEx(&wcex) != (ATOM)0);
375}
WORD ATOM
Definition: dimm.idl:113
LRESULT CALLBACK EmptyWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: rundll32.c:320
int cbClsExtra
Definition: winuser.h:3207
HINSTANCE hInstance
Definition: winuser.h:3209
HCURSOR hCursor
Definition: winuser.h:3211
LPCSTR lpszMenuName
Definition: winuser.h:3213
HICON hIconSm
Definition: winuser.h:3215
UINT style
Definition: winuser.h:3205
int cbWndExtra
Definition: winuser.h:3208
UINT cbSize
Definition: winuser.h:3204
WNDPROC lpfnWndProc
Definition: winuser.h:3206
LPCSTR lpszClassName
Definition: winuser.h:3214
HICON hIcon
Definition: winuser.h:3210
HBRUSH hbrBackground
Definition: winuser.h:3212
#define RegisterClassEx
Definition: winuser.h:5849
WNDCLASSEXA WNDCLASSEX
Definition: winuser.h:5731

Referenced by _tWinMain().

Variable Documentation

◆ ModuleFileName

TCHAR ModuleFileName[MAX_PATH+1]

Definition at line 56 of file rundll32.c.

Referenced by GetModuleTitle(), and MiQueryMemorySectionName().

◆ ModuleTitle

LPTSTR ModuleTitle

Definition at line 57 of file rundll32.c.

Referenced by _tWinMain(), and GetModuleTitle().

◆ rundll32_wclass

LPCTSTR rundll32_wclass = _T("RunDLL")

Definition at line 54 of file rundll32.c.

Referenced by _tWinMain(), and RegisterBlankClass().

◆ rundll32_wtitle

LPCTSTR rundll32_wtitle = _T("rundll32")

Definition at line 53 of file rundll32.c.

Referenced by _tWinMain().