Vista Late Binding Security Problem

Y

Yusuf Incekara

I am using an old 3'rd party dll written by using Borland C++.
It is vital for my application and there 's no newer version.
When it 's fired it is writing some files to Windows\System32 folder.

I am using late binding, loading this dll and invoke it.
It works fine on XP. It also works fine on Vista when UAC is turned
off. But if UAC is turned on it fails. Returned error code is
insufficient privileges ...

It is somehow possible me to elevate this process or give appropriate
rights before i invoke ? And if this is possible i also don 't want
any user interaction.

IntPtr pDll = LoadLibrary(path + @"\" + "xxx.dll");
IntPtr pAddressOfFunctionToCall = GetProcAddress(pDll, "methodindll");
MD md =
(MD)Marshal.GetDelegateForFunctionPointer(pAddressOfFunctionToCall,
typeof(MD));
int anint=3;
short result = md(anint );
 
Y

Yusuf Incekara

actual code is :
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate short MD(int xxx);

[DllImport("kernel32.dll")]
internal static extern IntPtr LoadLibrary(string dllToLoad);

[DllImport("kernel32.dll")]
internal static extern IntPtr GetProcAddress(IntPtr hModule, string
procedureName);

private static void lateBindingVistaTest()
{
string path = @"c:\";
IntPtr pDll = LoadLibrary(path + @"\" + "xxx.dll");
IntPtr pAddressOfFunctionToCall = GetProcAddress(pDll,
"methodindll");
MD md =
(MD)Marshal.GetDelegateForFunctionPointer(pAddressOfFunctionToCall,
typeof(MD));
int anInt = 3;
short result = md(anint);
}




(c#, Visual Studio 2005, .net 2.0 )
 
M

Mr. Arnold

Yusuf Incekara said:
I am using an old 3'rd party dll written by using Borland C++.
It is vital for my application and there 's no newer version.
When it 's fired it is writing some files to Windows\System32 folder.

I am using late binding, loading this dll and invoke it.
It works fine on XP. It also works fine on Vista when UAC is turned
off. But if UAC is turned on it fails. Returned error code is
insufficient privileges ...

It is somehow possible me to elevate this process or give appropriate
rights before i invoke ? And if this is possible i also don 't want
any user interaction.

IntPtr pDll = LoadLibrary(path + @"\" + "xxx.dll");
IntPtr pAddressOfFunctionToCall = GetProcAddress(pDll, "methodindll");
MD md =
(MD)Marshal.GetDelegateForFunctionPointer(pAddressOfFunctionToCall,
typeof(MD));
int anint=3;
short result = md(anint );


You do know about the Vista UAC manifest. The UAC manifest must be used by a
program to escalate the program's privileges.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top