ReactOS 0.4.15-dev-7934-g1dc8d80
main.c File Reference
#include <windef.h>
#include <winbase.h>
#include <strsafe.h>
Include dependency graph for main.c:

Go to the source code of this file.

Functions

int run_rapps (LPWSTR cmdline)
 
int wmain (int argc, wchar_t *argv[])
 

Function Documentation

◆ run_rapps()

int run_rapps ( LPWSTR  cmdline)

Definition at line 12 of file main.c.

13{
14 DWORD dwExit;
15 STARTUPINFOW si = { sizeof(si) };
16 PROCESS_INFORMATION pi = { 0 };
17
18 SetLastError(0);
19 if (!CreateProcessW(NULL, cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
20 {
21 fprintf(stderr, "Unable to create rapps.exe process...\n");
22 return -1;
23 }
24 CloseHandle(pi.hThread);
26 GetExitCodeProcess(pi.hProcess, &dwExit);
27 CloseHandle(pi.hProcess);
28 return (int)dwExit;
29}
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define CloseHandle
Definition: compat.h:739
#define SetLastError(x)
Definition: compat.h:752
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessW(LPCWSTR lpApplicationName, LPWSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCWSTR lpCurrentDirectory, LPSTARTUPINFOW lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
Definition: proc.c:4592
BOOL WINAPI GetExitCodeProcess(IN HANDLE hProcess, IN LPDWORD lpExitCode)
Definition: proc.c:1168
#define INFINITE
Definition: serial.h:102
unsigned long DWORD
Definition: ntddk_ex.h:95
#define stderr
Definition: stdio.h:100
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
static refpint_t pi[]
Definition: server.c:96
TCHAR * cmdline
Definition: stretchblt.cpp:32
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82

Referenced by wmain().

◆ wmain()

int wmain ( int  argc,
wchar_t argv[] 
)

Definition at line 31 of file main.c.

32{
33 int iRet;
34 int n;
35 size_t arglen;
36 WCHAR RappsExe[MAX_PATH] = { 0 };
37 wchar_t* cmdline;
38
39 GetModuleFileNameW(NULL, RappsExe, ARRAYSIZE(RappsExe));
40 arglen = wcslen(RappsExe);
41 if (arglen > 4 && !wcsicmp(RappsExe + arglen - 4, L".com"))
42 {
43 wcscpy(RappsExe + arglen - 4, L".exe");
44 }
45 else
46 {
47 fprintf(stderr, "Unable to build rapps.exe path...\n");
48 return -1;
49 }
50
51 arglen += (1 + 2); // NULL terminator + 2 quotes
52
53 for (n = 1; n < argc; ++n)
54 {
55 arglen += wcslen(argv[n]);
56 arglen += 3; // Surrounding quotes + space
57 }
58
60 if (cmdline)
61 {
62 wchar_t* ptr = cmdline;
63 size_t cchRemaining = arglen;
64
65 StringCchPrintfExW(ptr, cchRemaining, &ptr, &cchRemaining, 0, L"\"%s\"", RappsExe);
66
67 for (n = 1; n < argc; ++n)
68 {
69 StringCchPrintfExW(ptr, cchRemaining, &ptr, &cchRemaining, 0, L" \"%s\"", argv[n]);
70 }
71 }
72
73 iRet = run_rapps(cmdline);
74 if (cmdline)
76 return iRet;
77}
static int argc
Definition: ServiceArgs.c:12
int run_rapps(LPWSTR cmdline)
Definition: main.c:12
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define MAX_PATH
Definition: compat.h:34
#define HeapFree(x, y, z)
Definition: compat.h:735
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
#define wcsicmp
Definition: compat.h:15
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:600
GLdouble n
Definition: glext.h:7729
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
static PVOID ptr
Definition: dispmode.c:27
#define argv
Definition: mplay32.c:18
#define L(x)
Definition: ntvdm.h:50
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
STRSAFEAPI StringCchPrintfExW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPWSTR *ppszDestEnd, size_t *pcchRemaining, STRSAFE_DWORD dwFlags, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:585
__wchar_t WCHAR
Definition: xmlstorage.h:180