ShootBlues.Win32.GetProcAddress C# (CSharp) Méthode

GetProcAddress() private méthode

private GetProcAddress ( IntPtr hModule, string procName ) : UInt32
hModule System.IntPtr
procName string
Résultat System.UInt32
        public static extern UInt32 GetProcAddress(IntPtr hModule, string procName);

Usage Example

Exemple #1
0
        public void ResolveImports()
        {
            int numImports = 0;

            foreach (var import in Imports)
            {
                var hModule = Win32.LoadLibrary(import.ModuleName);
                if (hModule == IntPtr.Zero)
                {
                    throw new Exception(String.Format("Module load failed: {0}", import.ModuleName));
                }

                try {
                    var procAddress = Win32.GetProcAddress(hModule, import.FunctionName);
                    if (procAddress == 0)
                    {
                        throw new Exception(String.Format("Unresolved import: {0}:{1}", import.ModuleName, import.FunctionName));
                    }

                    var section = SectionFromVirtualAddress(import.FunctionAddressDestination);
                    var offset  = import.FunctionAddressDestination - section.VirtualAddress;
                    var bytes   = BitConverter.GetBytes(procAddress);
                    Array.Copy(bytes, 0, section.RawData, offset, bytes.Length);

                    numImports += 1;
                } finally {
                    Win32.FreeLibrary(hModule);
                }
            }
        }
All Usage Examples Of ShootBlues.Win32::GetProcAddress