0

CreateProcessAsUserを使用すると、ハードディスクのどこかに.exeファイルを呼び出すことができます。

CreateProcessAsUser(IntPtr hToken, string lpApplicationName, string lpCommandLine,
                      ref SECURITY_ATTRIBUTES lpProcessAttributes, ref SECURITY_ATTRIBUTES lpThreadAttributes,
                      bool bInheritHandle, Int32 dwCreationFlags, IntPtr lpEnvrionment,
                      string lpCurrentDirectory, ref STARTUPINFO lpStartupInfo,
                      ref PROCESS_INFORMATION lpProcessInformation);

私がWebで見つけたそれぞれの例では、lpCommandLine引数を使用してプログラムを呼び出しています。dllの関数を呼び出したいのですが。これが可能かどうか誰かが知っていますか?ある種の例があるといいでしょう...

ありがとうございました!

4

2 に答える 2

2

ユーザー/実行レベルはDLLやスレッドではなくプロセスごとであるため、DLLを別のユーザーとして直接呼び出すことはできません。DLLを呼び出す新しいプロセスを開始する必要があります。これは、COMの昇格などで使用される手法です。DLLに正しい署名がある場合は、を使用して呼び出すことができますrundll32.exe

于 2012-06-25T13:20:05.857 に答える
0

その機能では不可能だと思います。dllのメソッドを呼び出す標準的な方法は、次の例のように、 LoadLibraryandメソッドを使用することです。GetProcAddress

MSDNから取得)

// A simple program that uses LoadLibrary and 
// GetProcAddress to access myPuts from Myputs.dll. 

#include <windows.h> 
#include <stdio.h> 

typedef int (__cdecl *MYPROC)(LPWSTR); 

int main( void ) 
{ 
    HINSTANCE hinstLib; 
    MYPROC ProcAdd; 
    BOOL fFreeResult, fRunTimeLinkSuccess = FALSE; 

    // Get a handle to the DLL module.

    hinstLib = LoadLibrary(TEXT("MyPuts.dll")); 

    // If the handle is valid, try to get the function address.

    if (hinstLib != NULL) 
    { 
        ProcAdd = (MYPROC) GetProcAddress(hinstLib, "myPuts"); 

        // If the function address is valid, call the function.

        if (NULL != ProcAdd) 
        {
            fRunTimeLinkSuccess = TRUE;
            (ProcAdd) (L"Message sent to the DLL function\n"); 
        }
        // Free the DLL module.

        fFreeResult = FreeLibrary(hinstLib); 
    } 

    // If unable to call the DLL function, use an alternative.
    if (! fRunTimeLinkSuccess) 
        printf("Message printed from executable\n"); 

    return 0;

}
于 2012-06-25T12:44:15.293 に答える