⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unifiedkernel-0.2.0-w0.9.11.diff

📁 该项目主要是将wingdows程序直接运行在linux上
💻 DIFF
📖 第 1 页 / 共 5 页
字号:
+	PVOID ProcSecurity = NULL;+	PVOID ImageBaseAddress;+	+	WCHAR* TidyCmdLine;+	WCHAR Name[MAX_PATH];+	WCHAR* TempCurrentDirectory;+	WCHAR TempApplicationName[256];+	WCHAR* tmp;+	WCHAR dotExe[] = {'.','e','x','e', 0};++	UNICODE_STRING ImagePathName_U;+	UNICODE_STRING CmdLine_U;+	UNICODE_STRING CurrentDirectory_U;+	UNICODE_STRING RuntimeInfo_U;+	SECTION_IMAGE_INFORMATION Sii;+	OBJECT_ATTRIBUTES ProcObjectAttributes;+	PROCESS_PRIORITY_CLASS PriorityClass;+	PRTL_USER_PROCESS_PARAMETERS ppb;+	PROCESS_BASIC_INFORMATION ProcessBasicInfo;+	+	NTSTATUS Status;++	TRACE("CreateProcessW(1:%p,2:%p,3:%p,4:%p,5:%d,6:%ld,7:%p,8:%p,9:%p,10:%p)\n",+			lpApplicationName,+			lpCommandLine,+			lpProcessAttributes,+			lpThreadAttributes,+			bInheritHandles,+			dwCreationFlags,+			lpEnvironment,+			lpCurrentDirectory,+			lpStartupInfo,+			lpProcessInformation);++	/* get file name */+	if (!(TidyCmdLine = GetFileName(lpCurrentDirectory, lpApplicationName, lpCommandLine, +				Name, sizeof(Name)/sizeof(WCHAR))))+		return FALSE;+	+	/* deal with file name */+	if (lpApplicationName && lpApplicationName[0])+		strcpyW(TempApplicationName, lpApplicationName);+	else {+		if (L'"' == TidyCmdLine[0]) {+		       	/* command line: "*.exe" */+			strcpyW(TempApplicationName, TidyCmdLine + 1);+			tmp = strchrW(TempApplicationName, L'"');+			if (tmp)+				*tmp = L'\0';+		} else {+			/* command line: *.exe */+			strcpyW(TempApplicationName, TidyCmdLine);+			tmp = strchrW(TempApplicationName, L' ');+			/* the command line with '"' and followed by ' ' is invalid*/+			if (tmp) *tmp = L'\0';+			else if ((tmp = strchrW(TempApplicationName, L'"'))) *tmp = L'\0';+		}+	}+	tmp = max(strchrW(TempApplicationName, L'\\'), strchrW(TempApplicationName, L'/'));+	if (!tmp)+		tmp = TempApplicationName;+	if (!strchrW(TempApplicationName, L'.'))+		strcatW(TempApplicationName, dotExe);++        /*TODO: search path*/+#if 0+        if (!SearchPathW(NULL, TempApplicationName, NULL, sizeof(ImagePathName) / sizeof(WCHAR),+                                ImagePathName, NULL)) {+                return FALSE;+        }+#endif++	RtlInitUnicodeString(&ImagePathName_U, TempApplicationName);+	RtlInitUnicodeString(&CmdLine_U, TidyCmdLine);++	if (lpCurrentDirectory != NULL)+		RtlInitUnicodeString(&CurrentDirectory_U,lpCurrentDirectory);+	else {+		if(!(TempCurrentDirectory = RtlAllocateHeap(GetProcessHeap(), 0, 256)))+			return FALSE;+		GetCurrentDirectoryW(256, TempCurrentDirectory);+		RtlInitUnicodeString(&CurrentDirectory_U, TempCurrentDirectory);+		RtlFreeHeap(GetProcessHeap(), 0, TempCurrentDirectory);+	}++	/* FIXME: .cmd and .bat will not be processed */++	/* map executable file */+	hSection = KlMapFile(TempApplicationName);++	/* TODO: 16bit applications +	 * if (!hSection)+	 * ...+	 */+	/* query section infomation */+	Status = NtQuerySection(hSection, SectionImageInformation, &Sii, sizeof(Sii), NULL);+	if (Status) {+		UkClose(hSection);+		WARN("NtQuerySection() failed(Status %lx)\n", Status);+		return FALSE;+	}+	+	if (0 != (Sii.ImageCharacteristics & IMAGE_FILE_DLL)) {+		UkClose(hSection);+		WARN("Can't execute a DLL\n");+		return FALSE;+	}+	+	if (IMAGE_SUBSYSTEM_WINDOWS_GUI != Sii.ImageSubsystem +			&& IMAGE_SUBSYSTEM_WINDOWS_CUI != Sii.ImageSubsystem) {+		UkClose(hSection);+		WARN("Invalid subsystem %ld\n", Sii.ImageSubsystem);+		return FALSE;+	}++	/* initialize object */+	if(lpProcessAttributes) {+		if(lpProcessAttributes->bInheritHandle)+			ProcAttributes |= OBJ_INHERIT;+		ProcSecurity = lpProcessAttributes->lpSecurityDescriptor;+	}+	InitializeObjectAttributes(&ProcObjectAttributes, NULL, ProcAttributes, NULL, ProcSecurity);++	/* initialize priority */+	PriorityClass.Foreground = FALSE;++	if(dwCreationFlags & IDLE_PRIORITY_CLASS)+		PriorityClass.PriorityClass = PROCESS_PRIOCLASS_IDLE;+	else if(dwCreationFlags & BELOW_NORMAL_PRIORITY_CLASS)+		PriorityClass.PriorityClass = PROCESS_PRIOCLASS_BELOW_NORMAL;+	else if(dwCreationFlags & NORMAL_PRIORITY_CLASS)+		PriorityClass.PriorityClass = PROCESS_PRIOCLASS_NORMAL;+	else if(dwCreationFlags & ABOVE_NORMAL_PRIORITY_CLASS)+		PriorityClass.PriorityClass = PROCESS_PRIOCLASS_ABOVE_NORMAL;+	else if(dwCreationFlags & HIGH_PRIORITY_CLASS)+		PriorityClass.PriorityClass = PROCESS_PRIOCLASS_HIGH;+	else if(dwCreationFlags & REALTIME_PRIORITY_CLASS)+		/* FIXME - This is a privileged operation. If we don't have the privilege we should+		   rather use PROCESS_PRIOCLASS_HIGH. */+		PriorityClass.PriorityClass = PROCESS_PRIOCLASS_REALTIME;+	else+		/* FIXME - what to do in this case? */+		PriorityClass.PriorityClass = PROCESS_PRIOCLASS_NORMAL;+	+	/* NtCreateProcess*/+	NtCreateProcess(&hProcess,+			PROCESS_ALL_ACCESS,+			&ProcObjectAttributes,+			NtCurrentProcess(),+			bInheritHandles,+			hSection,+			NULL,+			NULL);+	+	NtSetInformationProcess(hProcess,+			ProcessPriorityClass,+			&PriorityClass,+			sizeof(PROCESS_PRIORITY_CLASS));+	+	/* TODO: send set information message */+	+	/* creat ppb */+	if (lpStartupInfo) {+		if (lpStartupInfo->lpReserved2) {+			/* FIXME:+			 *    ROUND_UP(xxx,2) + 2 is a dirty hack. RtlCreateProcessParameters +			 *    assumes that the runtimeinfo is a unicode string and +			 *    use RtlCopyUnicodeString for duplication.+			 *    If is possible that this function overwrite the last information +			 *    in runtimeinfo with the null terminator for the unicode string.+			 */+			RuntimeInfo_U.Length = (lpStartupInfo->cbReserved2 + 1) & ~1; +			RuntimeInfo_U.MaximumLength = (lpStartupInfo->cbReserved2 + 1) & ~1;+			RuntimeInfo_U.Buffer = RtlAllocateHeap(GetProcessHeap(), 0, +					RuntimeInfo_U.Length);+			memcpy(RuntimeInfo_U.Buffer, lpStartupInfo->lpReserved2, +					lpStartupInfo->cbReserved2);+		}+	}++	RtlCreateProcessParameters(&ppb, +			&ImagePathName_U, +			NULL, +			lpCurrentDirectory ? &CurrentDirectory_U : NULL,+			&CmdLine_U,+			lpEnvironment,+			NULL,+			NULL,+			NULL,+			lpStartupInfo && lpStartupInfo->lpReserved2 ? &RuntimeInfo_U : NULL);+	+	if (lpStartupInfo && lpStartupInfo->lpReserved2)+		RtlFreeHeap(GetProcessHeap(), 0, RuntimeInfo_U.Buffer);+	+	/* copy ppb->CurrentDirectoryHandle */+	if (ppb->CurrentDirectory.Handle)+	{+		NtDuplicateObject(NtCurrentProcess(),+				ppb->CurrentDirectory.Handle,+				hProcess,+				&ppb->CurrentDirectory.Handle,+				0,+				TRUE,+				DUPLICATE_SAME_ACCESS);+	}+	+	/* close section */+	UkClose(hSection);+	+	/* initialize data to send to wine server */ +	NtQueryInformationProcess(hProcess,+			ProcessBasicInformation,+			&ProcessBasicInfo,+			sizeof(ProcessBasicInfo),+			NULL);+	+	lpProcessInformation->dwProcessId = (DWORD) ProcessBasicInfo.UniqueProcessId;+	+	if (Sii.ImageSubsystem == IMAGE_SUBSYSTEM_WINDOWS_GUI) {+		/* do not create a console for GUI applications */+		dwCreationFlags &= ~CREATE_NEW_CONSOLE;+		dwCreationFlags |= DETACHED_PROCESS;+	} else if (Sii.ImageSubsystem == IMAGE_SUBSYSTEM_WINDOWS_CUI) {+		if (!ppb->ConsoleHandle) /* FIXME: see dwCreationFlags */+			dwCreationFlags |= CREATE_NEW_CONSOLE;+	}+	+	/* wine server */+	SERVER_START_REQ(new_process)+	{+		req->inherit_all = bInheritHandles;+		req->create_flags = dwCreationFlags;+		req->unix_pid = (int) ProcessBasicInfo.UniqueProcessId;+		req->exe_file = NULL;+		if (lpStartupInfo && lpStartupInfo->dwFlags & STARTF_USESTDHANDLES) {+			req->hstdin = lpStartupInfo->hStdInput;+			req->hstdout = lpStartupInfo->hStdOutput;+			req->hstderr = lpStartupInfo->hStdError;+		} else {+			req->hstdin = NtCurrentTeb()->Peb->ProcessParameters->hStdInput;+			req->hstdout = NtCurrentTeb()->Peb->ProcessParameters->hStdOutput;+			req->hstderr = NtCurrentTeb()->Peb->ProcessParameters->hStdError;+		}+		+		if (dwCreationFlags & CREATE_NEW_CONSOLE) {+			/* TODO: handles for new console can't be control temporarily  */+			if (is_console_handle(req->hstdin))+				req->hstdin = INVALID_HANDLE_VALUE;+			if (is_console_handle(req->hstdout))+				req->hstdout = INVALID_HANDLE_VALUE;+			if (is_console_handle(req->hstderr))+				req->hstderr = INVALID_HANDLE_VALUE;+		}++		hStdIn = req->hstdin;+		hStdOut = req->hstdout;+		hStdErr = req->hstderr;+		+		Status = wine_server_call_err(req);+		process_info = reply->info;+	}+	SERVER_END_REQ;+	+	if(Status)+		return FALSE;++	/* set handle, FIXME: no duplication is done */+	ppb->hStdInput = hStdIn;+	ppb->hStdOutput = hStdOut;+	ppb->hStdError = hStdErr;++#if 0+        SERVER_START_REQ( get_new_process_info )+        {+                req->info           = process_info;+                req->process_access = PROCESS_ALL_ACCESS;+                req->process_attr   = (lpProcessAttributes+                                && (lpProcessAttributes->nLength >= sizeof(*lpProcessAttributes))+                                && lpProcessAttributes->bInheritHandle) ? OBJ_INHERIT : 0;+                req->thread_access  = THREAD_ALL_ACCESS;+                req->thread_attr    = (lpThreadAttributes+                                && (lpThreadAttributes->nLength >= sizeof(*lpThreadAttributes))+                                && lpThreadAttributes->bInheritHandle) ? OBJ_INHERIT : 0;+                if ((Status = !wine_server_call_err( req )))+                {+                        lpProcessInformation->dwProcessId = (DWORD)reply->pid;+                        lpProcessInformation->dwThreadId  = (DWORD)reply->tid;+                        lpProcessInformation->hProcess    = reply->phandle;+                        lpProcessInformation->hThread     = reply->thandle;+                        success           = reply->success;+                }+        }+        SERVER_END_REQ;++        if(Status && !success) {+                DWORD exitcode;+                if(GetExitCodeProcess(lpProcessInformation->hProcess, &exitcode))+                        SetLastError(exitcode);+                CloseHandle(lpProcessInformation->hThread);+                CloseHandle(lpProcessInformation->hProcess);+                UkClose(hProcess);+                Status = FALSE;+        }+#endif+	+	CloseHandle(process_info);++	/* copy ppb */+	if (lpStartupInfo) {+		ppb->dwFlags = lpStartupInfo->dwFlags;+		if (ppb->dwFlags & STARTF_USESHOWWINDOW)+			ppb->wShowWindow = lpStartupInfo->wShowWindow;+		else+			ppb->wShowWindow = SW_SHOWDEFAULT;+		ppb->dwX = lpStartupInfo->dwX;+		ppb->dwY = lpStartupInfo->dwY;+		ppb->dwXSize = lpStartupInfo->dwXSize;+		ppb->dwYSize = lpStartupInfo->dwYSize;+		ppb->dwFillAttribute = lpStartupInfo->dwFillAttribute;+	} else+		ppb->Flags = 0;++	KlInitPeb(hProcess, ppb, &ImageBaseAddress, Sii.ImageSubsystem);++	RtlDestroyProcessParameters(ppb);+	+	/* create first thread */+	hThread = KlCreateFirstThread(hProcess,+			lpThreadAttributes,+			&Sii,+			(PVOID)((ULONG_PTR)ImageBaseAddress + (ULONG)Sii.EntryPoint),+			dwCreationFlags,+			&lpProcessInformation->dwThreadId);+	if (!hThread)+		return FALSE;+	/* FIXME:+	 * We use handles returned from system calls to do some stuff in CreateProcessW  +	 * But process and thread handles are temporarily set from wine server +	 * for other uses outside.+	 */+#if 0+        /* set process and thread handles*/+        lpProcessInformation->hProcess = hProcess;+        lpProcessInformation->hThread = hThread;+#endif+	return TRUE;+}+#endif  /***********************************************************************  *           wait_input_idle@@ -2764,3 +3476,24 @@     FIXME("%d\n", bBatchRunning);     return FALSE; }++#ifdef UNIFIED_KERNEL+void BaseProcessStart(unsigned long start_address, void *param)+{+	unsigned long   exit_code;+	LPTHREAD_START_ROUTINE  entry;++	__TRY+	{+		entry = (LPTHREAD_START_ROUTINE)start_address;+		exit_code = entry(param);+	}+	__EXCEPT(UnhandledExceptionFilter)+	{+		exit_code = GetExceptionCode();+	}+	__ENDTRY;++	ExitProcess(exit_code);+}+#endifdiff -Nru wine-0.9.11.ori/dlls/kernel/thread.c wine-0.9.11/dlls/kernel/thread.c--- wine-0.9.11.ori/dlls/kernel/thread.c	2006-03-31 20:38:26.000000000 +0800+++ wine-0.9.11/dlls/kernel/thread.c	2007-03-23 09:53:02.000000000 +0800@@ -45,8 +45,9 @@ #include "kernel_private.h"  WINE_DEFAULT_DEBUG_CHANNEL(thread);+#ifndef UNIFIED_KERNEL WINE_DECLARE_DEBUG_CHANNEL(relay);-+#endif  struct new_thread_info {@@ -54,7 +55,7 @@     void                  *arg; }; -+#ifndef UNIFIED_KERNEL /***********************************************************************  *           THREAD_Start  *@@ -81,7 +82,7 @@     }     __ENDTRY }-+#endif  /***********************************************************************  *           CreateThread   (KERNEL32.@)@@ -90,11 +91,15 @@                             LPTHREAD_START_ROUTINE start, LPVOID param,                             DWORD flags, LPDWORD id ) {+#ifdef UNIFIED_KERNEL+     return 0;+#else      return CreateRemoteThread( GetCurrentProcess(),                                 sa, stack, start, param, flags, id );+#endif } -+#ifndef UNIFIED_KERNEL /***************************************************************************  *                  CreateRemoteThread   (KERNEL32.@)  *@@ -161,7 +166,120 @@     }     return handle; }+#else+#define PAGE_SIZE	0x1000+#define ROUNDUP(a, b) ((((a) + (b) - 1)/(b))*(b))++void ThreadStartup(LPTHREAD_START_ROUTINE lpStartAddress, LPVOID lpParameter)+{+	volatile UINT uExitCode = 0;++	__TRY+	{+		uExitCode = (lpStartAddress)((PVOID)lpParameter);+	}+	__EXCEPT(UnhandledExceptionFilter)+	{+		uExitCode = GetExceptionCode();+	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -