GetProcAddress() private method

private GetProcAddress ( SafeLibraryHandle hModule, string procName ) : IntPtr
hModule SafeLibraryHandle
procName string
return System.IntPtr
示例#1
0
        public static IntPtr FindOffset(string moduleName, string function)
        {
            IntPtr num = Kernel32.LoadLibraryEx(moduleName, LoadLibraryFlags.LoadAsDataFile);

            if (!(num != IntPtr.Zero))
            {
                return(IntPtr.Zero);
            }
            IntPtr procAddress = Kernel32.GetProcAddress(num, function);

            Kernel32.FreeLibrary(num);
            return((IntPtr)(procAddress.ToInt32() - num.ToInt32()));
        }
示例#2
0
        public static bool CallRemoteFunction(int pid, string module, string function, IntPtr param)
        {
            IntPtr hModule     = Kernel32.LoadLibraryEx(module, LoadLibraryFlags.LoadAsDataFile);
            IntPtr procAddress = Kernel32.GetProcAddress(hModule, function);

            if (hModule == IntPtr.Zero || procAddress == IntPtr.Zero)
            {
                return(false);
            }
            IntPtr remoteThread = Kernel32.CreateRemoteThread(pid, procAddress, param, CreateThreadFlags.RunImmediately);

            if (remoteThread != IntPtr.Zero)
            {
                int num = (int)Kernel32.WaitForSingleObject(remoteThread, uint.MaxValue);
            }
            return(remoteThread != IntPtr.Zero);
        }