Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alias for function

I want to import some functions from kernel32.dll, but I want to use different names. Example function:

[DllImport("kernel32.dll")] private static extern bool ReadProcessMemoryProc64 (...);

private static bool BetterReadableAndWriteableName (...) {
    ReadProcessMemoryProc64(...);
}

Wrapping the function is what I actually don't want, if there is another way.

like image 889
Cubi73 Avatar asked Jan 08 '14 19:01

Cubi73


People also ask

What is an alias function?

alias is a simple wrapper for the function builtin, which creates a function wrapping a command. It has similar syntax to POSIX shell alias . For other uses, it is recommended to define a function.

How do you write an alias function?

To create an alias, we need to create a file called bash_profile or bashrc. This file needs to be in the root directory and should be hidden to avoid mishandling of its contents. Inside of this file, we create an alias which is basically a map of commands and the sets of commands/functions to be executed as a shortcut.

How do you assign an alias to a function in Python?

In contrast to a normal Python method, an alias method accesses an original method via a different name—mostly for programming convenience. An example is the iterable method __next__() that can also be accessed with next() . You can define your own alias method by adding the statement a = b to your class definition.

What is the difference between an alias and a function?

Functions can be used in scripts or in the console, but are more often used in scripts. Contrary to aliases, which are just replaced by their value, a function will be interpreted by the bash shell. Functions are much more powerful than aliases. They can be used to build very complex programs.


1 Answers

Use the EntryPoint property of DllImportAttribute.

[DllImport("kernel32.dll", EntryPoint="ReadProcessMemoryProc64")]
private static extern bool BetterReadableAndWriteableName (...);
like image 165
Michael Gunter Avatar answered Oct 22 '22 14:10

Michael Gunter