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

📄 unifiedkernel-0.2.0-w0.9.11.diff

📁 该项目主要是将wingdows程序直接运行在linux上
💻 DIFF
📖 第 1 页 / 共 5 页
字号:
+	__ENDTRY;++	ExitThread(uExitCode);+}++extern NTSTATUS +RtlRosCreateUserThread(IN HANDLE ProcessHandle,+		IN POBJECT_ATTRIBUTES ObjectAttributes,+		IN BOOLEAN CreateSuspended,+		IN LONG StackZeroBits,+		IN OUT PULONG StackReserve OPTIONAL,+		IN OUT PULONG StackCommit OPTIONAL,+		IN PVOID BaseStartAddress,+		OUT PHANDLE ThreadHandle OPTIONAL,+		OUT PCLIENT_ID ClientId OPTIONAL,+		IN ULONG_PTR StartAddress,+		IN ULONG_PTR Parameter);++HANDLE WINAPI +CreateRemoteThread(HANDLE hProcess,+		LPSECURITY_ATTRIBUTES lpThreadAttributes,+		DWORD dwStackSize,+		LPTHREAD_START_ROUTINE lpStartAddress,+		LPVOID lpParameter,+		DWORD dwCreationFlags,+		LPDWORD lpThreadId)+{+	HANDLE hThread;+	CLIENT_ID cidClientId;+	NTSTATUS nErrCode;+	ULONG_PTR nStackReserve;+	ULONG_PTR nStackCommit;+	OBJECT_ATTRIBUTES oaThreadAttribs;+	PIMAGE_NT_HEADERS pinhHeader = RtlImageNtHeader(NtCurrentTeb()->Peb->ImageBaseAddress);++	/* FIXME: do more checks - e.g. the image may not have an optional header */+	if(pinhHeader == NULL) {+		nStackReserve = 0x100000;/* FIXME */+		nStackCommit = PAGE_SIZE;+	} else {+		nStackReserve = pinhHeader->OptionalHeader.SizeOfStackReserve;+		nStackCommit = pinhHeader->OptionalHeader.SizeOfStackCommit;+	}++	/* use defaults */+	if(dwStackSize == 0);+	/* dwStackSize specifies the size to reserve */+	else if(dwCreationFlags & STACK_SIZE_PARAM_IS_A_RESERVATION)+		nStackReserve = dwStackSize;+	/* dwStackSize specifies the size to commit */+	else+		nStackCommit = dwStackSize;++	/* fix the stack reserve size */+	if(nStackCommit > nStackReserve)+		nStackReserve = ROUNDUP(nStackCommit, 0x100000);++	/* initialize the attributes for the thread object */+	InitializeObjectAttributes(&oaThreadAttribs,+			NULL,+			0,+			NULL,+			NULL);++	if(lpThreadAttributes) {+		/* make the handle inheritable */+		if(lpThreadAttributes->bInheritHandle)+			oaThreadAttribs.Attributes |= OBJ_INHERIT;++		/* user-defined security descriptor */+		oaThreadAttribs.SecurityDescriptor = lpThreadAttributes->lpSecurityDescriptor;+	}++	/* create the thread */+	nErrCode = RtlRosCreateUserThread(hProcess,+			&oaThreadAttribs,+			dwCreationFlags & CREATE_SUSPENDED,+			0,+			&nStackReserve,+			&nStackCommit,+			(LPTHREAD_START_ROUTINE)ThreadStartup,+			&hThread,+			&cidClientId,+			(ULONG_PTR)lpStartAddress,+			(ULONG_PTR)lpParameter);+	/* failure */+	if(nErrCode) {+		SetLastError(nErrCode);+		return NULL;+	}++	/* success */+	if(lpThreadId) +		*lpThreadId = (DWORD)cidClientId.UniqueThread; +	return hThread;+}+#endif  /***********************************************************************  * OpenThread  [KERNEL32.@]   Retrieves a handle to a thread from its thread iddiff -Nru wine-0.9.11.ori/dlls/Makedll.rules.in wine-0.9.11/dlls/Makedll.rules.in--- wine-0.9.11.ori/dlls/Makedll.rules.in	2006-03-31 20:38:24.000000000 +0800+++ wine-0.9.11/dlls/Makedll.rules.in	2007-03-23 09:53:02.000000000 +0800@@ -9,12 +9,17 @@ # plus all variables required by the global Make.rules.in # +SLIBDIR	    = /lib+KERNELVER   = `uname -r | awk -F. '{print $$1}'`+ DLLDEFS     = @DLLDEFS@ DLLFLAGS    = @DLLFLAGS@ DLLEXT      = @DLLEXT@ IMPLIBEXT   = @IMPLIBEXT@ LDRPATH     = @LDDLLRPATH@-DEFS        = -D__WINESRC__ $(DLLDEFS) $(EXTRADEFS)+DEFS        = -D__WINESRC__ $(DLLDEFS) $(EXTRADEFS) \+	      -DRUNTIME_LINKER=\"$(SLIBDIR)/ld-linux.so.$(KERNELVER)\" \+	      -DUNIFIED_KERNEL BASEMODULE  = $(MODULE:%.dll=%) MAINSPEC    = $(BASEMODULE).spec SPEC_DEF    = lib$(BASEMODULE).defdiff -Nru wine-0.9.11.ori/dlls/ntdll/file.c wine-0.9.11/dlls/ntdll/file.c--- wine-0.9.11.ori/dlls/ntdll/file.c	2006-03-31 20:38:27.000000000 +0800+++ wine-0.9.11/dlls/ntdll/file.c	2007-03-23 09:54:09.000000000 +0800@@ -107,6 +107,27 @@                          sharing, FILE_OPEN, options, NULL, 0 ); } +#ifdef UNIFIED_KERNEL+/*+ * 	UkOpenFile+ * We use UkOpenFile with the system call NtOpenFile interface to do the same things,+ * but NtOpenFile in wine is used.+ */+NTSTATUS WINAPI UkOpenFile( PHANDLE handle, ACCESS_MASK access,+                            POBJECT_ATTRIBUTES attr, PIO_STATUS_BLOCK io,+                            ULONG sharing, ULONG options )+{+	NTSTATUS ret;+	__asm__ __volatile__ (+			"movl $0x58,%%eax\n\t"+			"lea 8(%%ebp),%%edx\n\t"+			"int $0x2E\n\t"+			:"=a" (ret)+	       );+	return ret;+}+#endif+ /**************************************************************************  *		NtCreateFile				[NTDLL.@]  *		ZwCreateFile				[NTDLL.@]diff -Nru wine-0.9.11.ori/dlls/ntdll/init.c wine-0.9.11/dlls/ntdll/init.c--- wine-0.9.11.ori/dlls/ntdll/init.c	1970-01-01 08:00:00.000000000 +0800+++ wine-0.9.11/dlls/ntdll/init.c	2007-03-23 09:54:13.000000000 +0800@@ -0,0 +1,457 @@+/*+ * init.c+ *+ * Copyright (C) 2006  Insigme Co., Ltd+ *+ * Authors: + * - Chenzhan Hu, Lixing Chu+ *+ * This software has been developed while working on the Linux Unified Kernel+ * project (http://linux.insigma.com.cn) in the Insigma Reaserch Institute,  + * which is a subdivision of Insigma Co., Ltd (http://www.insigma.com.cn).+ * + * The project is sponsored by Insigma Co., Ltd.+ *+ * The authors can be reached at linux@insigma.com.cn.+ *+ * This program is free software; you can redistribute it and/or modify it+ * under the terms of  the GNU General  Public License as published by the+ * Free Software Foundation; either version 2 of the  License, or (at your+ * option) any later version.+ *+ * Revision History:+ *   Jan 2006 - Created.+ */+ +/*+ * init.c: initialize all that should be done before LdrInitializThunk+ */++#ifdef UNIFIED_KERNEL+#include <stdio.h>+#include <stdlib.h>+#include <unistd.h>+#include <link.h>+#include <elf.h>+#include <sys/types.h>+#include <sys/stat.h>+#include <stdarg.h>++#include "windef.h"+#include "winnt.h"+#include "winternl.h"+#include "wine/library.h"+#include "wine/unicode.h"+#include "wine/server.h"+#include "wine/debug.h"++#include "ntdll_misc.h"++WINE_DEFAULT_DEBUG_CHANNEL(apc);++#define	AT_BAK		1005+typedef struct _wine_modref+{+    LDR_MODULE            ldr;+    int                   nDeps;+    struct _wine_modref **deps;+} WINE_MODREF;+const char __dynamic_linker__[] __attribute__ ((section (".interp"))) = RUNTIME_LINKER;++static PEB_LDR_DATA ldr;+static RTL_BITMAP _tls_bitmap;+static RTL_BITMAP _tls_expansion_bitmap;+extern int __wine_main_argc;+extern char **__wine_main_argv;+extern char **__wine_main_environ;+extern unsigned long BaseProcessStartEntry;+extern LIST_ENTRY tls_links;++extern void debug_usage(void);+extern void parse_options(const char *str);+extern WINE_MODREF *alloc_module(HMODULE hModule, LPCWSTR filename);+extern void server_init_process(void);+extern size_t server_init_thread(int unix_pid, int unix_tid, void *entry_point);+extern int __cxa_atexit (void (*func) (void *), void *arg, void *d);+extern void build_dll_path(void);+void _init(void);+void StartInterp(PIO_APC_ROUTINE ApcRoutine, void *stack,+		void *interp_start, unsigned long bak_addr, void *Context);+extern void __wine_init_codepages(const union cptable *ansi, const union cptable *oem,+		const union cptable *ucp);+extern const union cptable *wine_cp_get_table(unsigned int codepage);+extern NTSTATUS create_pe_sec_view(HANDLE hmodule);+typedef void (*BaseProcessStartFunc)(unsigned long, void *);++int mywrite(int fd, char *buf, int len)+{+	int	ret;+	asm volatile ("mov %%esi, %%ebx\n"+			"mov $0x4, %%eax\n"+			"int $0x80\n"+			: "=&a"(ret)+			: "c" (buf), "d" (len), "S" (fd)+			);+	return ret;+}++NTSTATUS  WINAPI NtContinue(PCONTEXT param0, BOOLEAN param1) +{+	NTSTATUS ret;+	__asm__ __volatile__ (+			"movl $0x15, %%eax\n\t"+			"lea 8(%%ebp), %%edx\n\t"+			"int $0x2E\n\t"+			:"=a" (ret)+	       );+	return ret;+}+++void ProcessStartForward(unsigned long start_address, void *peb)+{+	BaseProcessStartFunc	BaseProcessStart;++	BaseProcessStart = (BaseProcessStartFunc)BaseProcessStartEntry;+	BaseProcessStart(start_address, peb);+}++/*+ * StartInterp+ *+ * The linux interpreter here is used to link .so such as libwine.so for built-in dlls.+ * ALl the dlls will be linked by ntdll.dll.so+ */+__asm__ (+		".globl StartInterp\n"+		"StartInterp:\n\t"+		"pusha\n\t"+		"mov 0x28(%esp), %ecx\n\t"	/* stack top used for linux arg */+		"sub %esp, %ecx\n\t"		/* stack size need backup */+		"mov %esp, %esi\n\t"+		"mov 0x30(%esp), %edi\n\t"+		"mov %ecx, (%edi)\n\t"		/* backup the size */+		"add $0x4, %edi\n\t"+		"shr $2, %ecx\n\t"+		"rep movsl\n\t"+		"mov 0x28(%esp), %ecx\n\t"+		"mov 0x2c(%esp), %esi\n\t"	/* Iosb, here in interpreter */+		"mov %ecx, %esp\n\t"+		"jmp *%esi\n"				/* _start in interpreter */+		/* finally jmp to AT_ENTRY */++		".globl StartThunk\n"		/* set StartThunk to AT_ENTRY in kernel */+		"StartThunk:\n\t"+		"xorl %ebp, %ebp\n\t"		/* ABI need */+		"movl (%esp), %esi\n\t"		/* Pop the argument count.  */+		"leal 0x4(%esp), %ecx\n\t"		/* argv starts just at the current stack top.*/+		"movl %esp, %ebp\n\t"+		/* Before pushing the arguments align the stack to a 16-byte+		   (SSE needs 16-byte alignment) boundary to avoid penalties from+		   misaligned accesses. */+		"andl $0xfffffff0, %esp\n\t"+		"pushl %eax\n\t"	  /* push garbage */+		"pushl %eax\n\t"	  /* push garbage */+		"pushl %eax\n\t"	  /* push garbage */+		"pushl %ebp\n\t"+		"pushl %edx\n\t"      /* Push address of the shared library termination function. */+		"pushl $0x0\n\t"      /* __libc_csu_init */+		"pushl %ecx\n\t"      /* Push second argument: argv.  */+		"pushl %esi\n\t"      /* Push first argument: argc.  */+		"call PrepareThunk\n\t"+		"movl (%esp), %esp\n\t"		/* restore %esp */+		"movl (%eax), %ecx\n\t"		/* stack size backuped */+		"leal 0x4(%eax), %esi\n\t"	/* stack data backuped in %esi */+		"subl %ecx, %esp\n\t"		/* restore %esp */+		"movl %esp, %edi\n\t"+		"shrl $0x2, %ecx\n\t"+		"rep movsl\n\t"				/* restore stack */+		"popa\n\t"+		"ret\n"						/* return from StartInterp */+);++static unsigned long extra_page = 0;++void __attribute__((stdcall))+KiUserApcDispatcher(PIO_APC_ROUTINE ApcRoutine, void *ApcContext,+		void *Iosb, unsigned long Reserved, void *Context)+{+	if (Reserved) {+		extra_page = Reserved;+		StartInterp(ApcRoutine, ApcContext, Iosb, Reserved, Context);+	}++	ApcRoutine(ApcContext, Iosb, Reserved);++	/* switch back to the interrupted context */+	NtContinue((PCONTEXT)Context, 1);+}++char *get_wine_bindir()+{+	char *wine_path, *bin_dir, *p, *temp;+	char *paths = getenv("PATH");+	char wine[] = "/wine";+	struct stat st;+	int path_len;+	+	wine_path = malloc(MAX_PATH + sizeof(wine));+	if (paths) {+		paths = strdup(paths);+		temp = paths;+		for (p = paths; *p != 0; p++) {+			while (*p != ':' && *p)+				p++;+			*p = 0;+			strcpy(wine_path, temp);+			strcat(wine_path, wine);++			if (!stat(wine_path, &st))+				if (S_ISREG(st.st_mode)) {+					path_len = strrchr(wine_path, '/') - wine_path;+					bin_dir = malloc((path_len + 1) * sizeof(char));+					memcpy(bin_dir, wine_path, path_len);+					bin_dir[path_len] = 0;+					free(paths);+					free(wine_path);+					return bin_dir;+				}+			temp = p + 1;+		}+		free(paths);+	}+	free(wine_path);+	return NULL;+}++/*+ * get_native_fullname+ *+ * Getting full name(include path) of a native dll+ */+static WCHAR *get_native_fullname(UNICODE_STRING *abs_dir, UNICODE_STRING *filename)+{+	WCHAR *fullname = NULL;+	WCHAR *p;+	size_t len;+	int unix_path = 1;+	+	if (abs_dir->Buffer) {+		p = filename->Buffer;+		if ((p = strrchrW(filename->Buffer, '/')))+			p++;+		else +			if ((p = strrchrW(filename->Buffer, '\\'))) {+				p++;+				unix_path = 0;+			}+			else+				p = filename->Buffer;++		len = strlenW(p) + (abs_dir->Length) / sizeof(WCHAR) + 1;+		if ((fullname = RtlAllocateHeap(GetProcessHeap(), 0 ,(len + 1) * sizeof(WCHAR)))) {+			memcpy(fullname, abs_dir->Buffer, abs_dir->Length);+			if (unix_path)+				fullname[(abs_dir->Length) / sizeof(WCHAR)] = '/';+			else+				fullname[(abs_dir->Length) / sizeof(WCHAR)] = '\\';+			fullname[(abs_dir->Length) / sizeof(WCHAR) + 1] = 0;+			strcatW(fullname, p);+			fullname[len] = 0;+		}+	}++	return fullname;+}++/* initialize all options at startup for Unified Kernel */+void __debug_init(void)+{+    char *wine_debug;++    if ((wine_debug = getenv("WINEDEBUG")))+    {+        if (!strcmp(wine_debug, "help")) debug_usage();+        parse_options(wine_debug);+    }+}++/*+ * init_for_load+ * + * Initializing all the parts that are done by wine-preloader+ * All this initialization should be done before LdrInitializeThunk+ */+#define NORMALIZE(x, addr)   if (x) x = (typeof(x))((unsigned long)(x) + (unsigned long)(addr))+#define NORMALIZE_PARAMS(params) \+{ \

⌨️ 快捷键说明

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