ReactOS  0.4.11-dev-946-g431643b
main.c File Reference
#include <windows.h>
#include <advpub.h>
#include <ole2.h>
#include <rpcproxy.h>
#include "wine/unicode.h"
#include "wine/debug.h"
Include dependency graph for main.c:

Go to the source code of this file.

Functions

DWORD WINAPI IEWinMain (const WCHAR *, int)
 
static BOOL check_native_ie (void)
 
static DWORD register_iexplore (BOOL doregister)
 
int WINAPI wWinMain (HINSTANCE hInstance, HINSTANCE prev, WCHAR *cmdline, int show)
 

Function Documentation

◆ check_native_ie()

static BOOL check_native_ie ( void  )
static

Definition at line 31 of file main.c.

Referenced by register_iexplore().

32 {
33  DWORD handle, size;
35  UINT bytes;
36  void* buf;
37  BOOL ret = TRUE;
38  LPWORD translation;
39 
40  static const WCHAR browseui_dllW[] = {'b','r','o','w','s','e','u','i','.','d','l','l',0};
41  static const WCHAR wineW[] = {'W','i','n','e',0};
42  static const WCHAR translationW[] =
43  {'\\','V','a','r','F','i','l','e','I','n','f','o',
44  '\\','T','r','a','n','s','l','a','t','i','o','n',0};
45  static const WCHAR file_desc_fmtW[] =
46  {'\\','S','t','r','i','n','g','F','i','l','e','I','n','f','o',
47  '\\','%','0','4','x','%','0','4','x',
48  '\\','F','i','l','e','D','e','s','c','r','i','p','t','i','o','n',0};
49  WCHAR file_desc_strW[48];
50 
51  size = GetFileVersionInfoSizeW(browseui_dllW, &handle);
52  if(!size)
53  return TRUE;
54 
55  buf = HeapAlloc(GetProcessHeap(), 0, size);
56  GetFileVersionInfoW(browseui_dllW, 0, size,buf);
57  if (VerQueryValueW(buf, translationW, (void **)&translation, &bytes))
58  {
59  wsprintfW(file_desc_strW, file_desc_fmtW, translation[0], translation[1]);
60  ret = !VerQueryValueW(buf, file_desc_strW, (void**)&file_desc, &bytes) || !strstrW(file_desc, wineW);
61  }
62 
63  HeapFree(GetProcessHeap(), 0, buf);
64  return ret;
65 }
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)
namespace GUID const ADDRINFOEXW ADDRINFOEXW struct timeval OVERLAPPED LPLOOKUPSERVICE_COMPLETION_ROUTINE HANDLE * handle
Definition: sock.c:82
#define TRUE
Definition: types.h:120
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const WCHAR * strstrW(const WCHAR *str, const WCHAR *sub)
Definition: main.c:29
static unsigned char bytes[4]
Definition: adnsresfilter.c:74
static WCHAR wineW[]
Definition: localmon.c:116
unsigned int BOOL
Definition: ntddk_ex.h:94
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned int UINT
Definition: ndis.h:50
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
DWORD WINAPI GetFileVersionInfoSizeW(LPCWSTR filename, LPDWORD handle)
Definition: version.c:616
uint16_t * LPWORD
Definition: typedefs.h:54
BOOL WINAPI GetFileVersionInfoW(LPCWSTR filename, DWORD handle, DWORD datasize, LPVOID data)
Definition: version.c:850
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define HeapFree(x, y, z)
Definition: compat.h:394
_Ret_z_ WCHAR * file_desc(_In_ PFILE_OBJECT FileObject)
Definition: btrfs.c:1309
BOOL WINAPI VerQueryValueW(LPCVOID pBlock, LPCWSTR lpSubBlock, LPVOID *lplpBuffer, PUINT puLen)
Definition: version.c:1054

◆ IEWinMain()

DWORD WINAPI IEWinMain ( const WCHAR ,
int   
)

Definition at line 1139 of file iexplore.c.

Referenced by wWinMain().

1140 {
1141  MSG msg;
1142  HRESULT hres;
1143  BOOL embedding = FALSE, nohome = FALSE, manager = FALSE;
1144  DWORD reg_cookie;
1145 
1146  static const WCHAR embeddingW[] = {'-','e','m','b','e','d','d','i','n','g',0};
1147  static const WCHAR nohomeW[] = {'-','n','o','h','o','m','e',0};
1148  static const WCHAR startmanagerW[] = {'-','s','t','a','r','t','m','a','n','a','g','e','r',0};
1149 
1150  TRACE("%s %d\n", debugstr_w(cmdline), nShowWindow);
1151 
1152  CoInitialize(NULL);
1153 
1154  init_dde();
1155 
1156  while (*cmdline)
1157  {
1158  int length = 0;
1159 
1160  while (*cmdline == ' ' || *cmdline == '\t') cmdline++;
1161  if (!*cmdline) break;
1162 
1163  while (cmdline[length] && cmdline[length] != ' ' && cmdline[length] != '\t') length++;
1164 
1165  if (!strncmpiW(cmdline, embeddingW, length))
1166  embedding = TRUE;
1167  else if (!strncmpiW(cmdline, nohomeW, length))
1168  nohome = TRUE;
1169  else if (!strncmpiW(cmdline, startmanagerW, length))
1170  manager = TRUE;
1171  else
1172  break;
1173 
1174  cmdline += length;
1175  }
1176 
1177  if (manager)
1178  hres = CoRegisterClassObject(&CLSID_InternetExplorerManager,
1179  (IUnknown*)&InternetExplorerManagerFactory, CLSCTX_SERVER,
1180  REGCLS_SINGLEUSE, &reg_cookie);
1181  else
1182  hres = CoRegisterClassObject(&CLSID_InternetExplorer,
1183  (IUnknown*)&InternetExplorerFactory, CLSCTX_SERVER,
1184  REGCLS_MULTIPLEUSE, &reg_cookie);
1185 
1186  if (FAILED(hres))
1187  {
1188  ERR("failed to register CLSID_InternetExplorer%s: %08x\n", manager ? "Manager" : "", hres);
1189  CoUninitialize();
1190  ExitProcess(1);
1191  }
1192 
1193  if (!embedding)
1194  {
1195  if(!create_ie_window(nohome, cmdline))
1196  {
1197  CoUninitialize();
1198  ExitProcess(1);
1199  }
1200  }
1201 
1202  /* run the message loop for this thread */
1203  while (GetMessageW(&msg, 0, 0, 0))
1204  {
1205  TranslateMessage(&msg);
1206  DispatchMessageW(&msg);
1207  }
1208 
1209  CoRevokeClassObject(reg_cookie);
1210  release_dde();
1211 
1212  CoUninitialize();
1213 
1214  ExitProcess(0);
1215  return 0;
1216 }
IClassFactory InternetExplorerManagerFactory
Definition: ieframe_main.c:253
BOOL WINAPI TranslateMessage(_In_ const MSG *)
#define TRUE
Definition: types.h:120
__wchar_t WCHAR
Definition: xmlstorage.h:180
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
VOID WINAPI ExitProcess(IN UINT uExitCode)
Definition: proc.c:1517
TCHAR * cmdline
Definition: stretchblt.cpp:32
#define strncmpiW(s1, s2, n)
Definition: unicode.h:40
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)
static BOOL create_ie_window(BOOL nohome, const WCHAR *cmdline)
Definition: iexplore.c:952
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
HRESULT WINAPI DECLSPEC_HOTPATCH CoRevokeClassObject(DWORD dwRegister)
Definition: compobj.c:1089
#define TRACE(s)
Definition: solgame.cpp:4
unsigned int BOOL
Definition: ntddk_ex.h:94
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ERR(fmt,...)
Definition: debug.h:109
IClassFactory InternetExplorerFactory
Definition: ieframe_main.c:243
HRESULT WINAPI CoRegisterClassObject(REFCLSID rclsid, LPUNKNOWN pUnk, DWORD dwClsContext, DWORD flags, LPDWORD lpdwRegister)
Definition: compobj.c:2809
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:1994
static void release_dde(void)
Definition: iexplore.c:1123
BOOL WINAPI GetMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT)
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1900
#define msg(x)
Definition: auth_time.c:54
static void init_dde(void)
Definition: iexplore.c:1098

◆ register_iexplore()

static DWORD register_iexplore ( BOOL  doregister)
static

Definition at line 67 of file main.c.

Referenced by wWinMain().

68 {
69  HRESULT hres;
70 
71  if (check_native_ie()) {
72  WINE_MESSAGE("Native IE detected, not doing registration\n");
73  return 0;
74  }
75 
76  hres = RegInstallA(NULL, doregister ? "RegisterIE" : "UnregisterIE", NULL);
77  return FAILED(hres);
78 }
#define WINE_MESSAGE
Definition: debug.h:386
static BOOL check_native_ie(void)
Definition: main.c:31
smooth NULL
Definition: ftsmooth.c:416
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
HRESULT WINAPI RegInstallA(HMODULE hm, LPCSTR pszSection, const STRTABLEA *pstTable)
Definition: reg.c:148

◆ wWinMain()

int WINAPI wWinMain ( HINSTANCE  hInstance,
HINSTANCE  prev,
WCHAR cmdline,
int  show 
)

Definition at line 80 of file main.c.

81 {
82  static const WCHAR regserverW[] = {'r','e','g','s','e','r','v','e','r',0};
83  static const WCHAR unregserverW[] = {'u','n','r','e','g','s','e','r','v','e','r',0};
84 
85  if(*cmdline == '-' || *cmdline == '/') {
86  if(!strcmpiW(cmdline+1, regserverW))
87  return register_iexplore(TRUE);
88  if(!strcmpiW(cmdline+1, unregserverW))
89  return register_iexplore(FALSE);
90  }
91 
92  return IEWinMain(cmdline, show);
93 }
#define TRUE
Definition: types.h:120
__wchar_t WCHAR
Definition: xmlstorage.h:180
TCHAR * cmdline
Definition: stretchblt.cpp:32
DWORD WINAPI IEWinMain(const WCHAR *, int)
Definition: iexplore.c:1139
#define strcmpiW(s1, s2)
Definition: unicode.h:39
static DWORD register_iexplore(BOOL doregister)
Definition: main.c:67