![]() |
ZenWINX Architecture - Reference Manual - Guides |
|
00001 /* 00002 * ZenWINX - WIndows Native eXtended library. 00003 * Copyright (c) 2007-2010 by Dmitri Arkhangelski (dmitriar@gmail.com). 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation; either version 2 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software 00017 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00018 */ 00019 00027 #include "ntndk.h" 00028 #include "zenwinx.h" 00029 00049 int __stdcall winx_create_thread(PTHREAD_START_ROUTINE start_addr,PVOID parameter,HANDLE *phandle) 00050 { 00051 NTSTATUS Status; 00052 HANDLE hThread; 00053 HANDLE *ph; 00054 00055 DbgCheck1(start_addr,"winx_create_thread",-1); 00056 00057 /* 00058 * Implementation is very easy, because we have required call 00059 * on all of the supported versions of Windows. 00060 */ 00061 if(phandle) ph = phandle; 00062 else ph = &hThread; 00063 Status = RtlCreateUserThread(NtCurrentProcess(),NULL, 00064 0,0,0,0,start_addr,parameter,ph,NULL); 00065 if(!NT_SUCCESS(Status)){ 00066 DebugPrintEx(Status,"Cannot create thread"); 00067 //winx_printf("\nFUCKED 0x%x\n\n",(UINT)Status); 00068 return (-1); 00069 } 00070 if(phandle == NULL) NtCloseSafe(*ph); 00071 return 0; 00072 } 00073 00079 void __stdcall winx_exit_thread(void) 00080 { 00081 NTSTATUS Status = ZwTerminateThread(NtCurrentThread(),STATUS_SUCCESS); 00082 if(!NT_SUCCESS(Status)){ 00083 DebugPrintEx(Status,"Cannot terminate thread"); 00084 } 00085 } 00086