![]() |
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 00041 int __stdcall winx_get_proc_address(short *libname,char *funcname,PVOID *proc_addr) 00042 { 00043 UNICODE_STRING uStr; 00044 ANSI_STRING aStr; 00045 NTSTATUS Status; 00046 HMODULE base_addr; 00047 00048 /* never call winx_dbg_print_ex() from this function! */ 00049 DbgCheck3(libname,funcname,proc_addr,"winx_get_proc_address",-1); 00050 00051 RtlInitUnicodeString(&uStr,libname); 00052 Status = LdrGetDllHandle(0,0,&uStr,(HMODULE *)&base_addr); 00053 if(!NT_SUCCESS(Status)){ 00054 DebugPrint("Cannot get %ls handle: %x!",libname,(UINT)Status); 00055 return (-1); 00056 } 00057 RtlInitAnsiString(&aStr,funcname); 00058 Status = LdrGetProcedureAddress(base_addr,&aStr,0,proc_addr); 00059 if(!NT_SUCCESS(Status)){ 00060 DebugPrint("Cannot get address for %s: %x!",funcname,(UINT)Status); 00061 *proc_addr = NULL; 00062 return (-1); 00063 } 00064 return 0; 00065 } 00066