社区
C#
帖子详情
c#中如何调用CreateProcessWithLogonW函数
hunhunnowant
2008-05-27 03:43:58
查了msdn,是一个Advapi32.lib中的函数,怎么调用?
求个例子,谢谢
...全文
259
6
打赏
收藏
c#中如何调用CreateProcessWithLogonW函数
查了msdn,是一个Advapi32.lib中的函数,怎么调用? 求个例子,谢谢
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
6 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
hunhunnowant
2008-07-07
打赏
举报
回复
未处理 System.AccessViolationException
Message="尝试读取或写入受保护的内存。这通常指示其他内存已损坏。"
Source="WindowsApplication1"
StackTrace:
在 WindowsApplication1.Form1.CreateProcessWithLogonW(String lpUsername, String lpDomain, String lpPassword, Int32 dwLogonFlags, String lpApplicationName, String lpCommandLine, Int32 dwCreationFlags, IntPtr lpEnvironment, String lpCurrentDirectory, String lpStartupInfo, String lpProcessInfo)
在 WindowsApplication1.Form1.button1_Click(Object sender, EventArgs e) 位置 d:\My Documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\Form1.cs:行号 232
在 System.Windows.Forms.Control.OnClick(EventArgs e)
在 System.Windows.Forms.Button.OnClick(EventArgs e)
在 System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
在 System.Windows.Forms.Control.WndProc(Message& m)
在 System.Windows.Forms.ButtonBase.WndProc(Message& m)
在 System.Windows.Forms.Button.WndProc(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
在 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
在 System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.Run(Form mainForm)
在 WindowsApplication1.Program.Main() 位置 d:\My Documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\Program.cs:行号 17
在 System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
在 System.Threading.ThreadHelper.ThreadStart()
hunhunnowant
2008-07-07
打赏
举报
回复
我用了CreateProcessWithLogonW函数,调用过程如下
CreateProcessWithLogonW(UserName, Domain, Password, LOGON_WITH_PROFILE, Url, null, CREATE_DEFAULT_ERROR_MODE, IntPtr.Zero, "c:\\", null, null);
运行时候会catch到错误“尝试读取或写入受保护的内存。这通常指示其他内存已损坏”这是怎么回事?
IcyPlayer
2008-07-07
打赏
举报
回复
这是函数原型,你看看,和你写的有出入
CreateProcessWithLogonW(
Username, // user's name
Domain, // user's domain
PassWord, // user's password
LOGON_WITH_PROFILE, // logon option
Program, // executable module name
Parameter, // command-line string
CREATE_UNICODE_ENVIRONMENT, // creation flags
lpvEnv, // new environment block
szUserProfile, // current directory name
&si, // startup information
&pi // process information
);
c#下这样使用更好:
char[] keys = password.ToCharArray();
SecureString secureString;
fixed (char* pass = keys){
secureString = new SecureString(pass, 9);
}
Process process = new Process();
process.StartInfo.FileName = @"c:\\epm-dm.exe";
process.StartInfo.UserName = "administrator";
process.StartInfo.Password = secureString;
process.StartInfo.UseShellExecute = false;
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
process.Start();
hunhunnowant
2008-07-07
打赏
举报
回复
不行
zlkingdom
2008-07-07
打赏
举报
回复
你的C盘是不是系统盘?换一个盘符试下
hunhunnowant
2008-07-07
打赏
举报
回复
有人帮帮忙吗?
CreateProcess
AsUser和
CreateProcess
With
Log
onW
的简单案列
包括WinExec、ShellExecute、
CreateProcess
、
CreateProcess
AsUser、
CreateProcess
With
Log
onW
、
CreateProcess
WithTokenW 一、
CreateProcess
AsUser创建一个新进程及其主线程。 1、创建当前登录(活跃)用户下的...
CreateProcess
With
Log
onW
CreateProcess
With
Log
onW
Creates a new process and its primary thread. Then the new process runs the specified executable file in the security context of the specified creden...
进程创建
函数
CreateProcess
()与创建流程详解
本文由2部分组成:第一部分解析
CreateProcess
() 的进程创建流程,第二部分翻译MSDN 站点上关于
CreateProcess
() 的各种参数的解释与用法,最后给出编程实例...Kernel32.dll
中
导出的
CreateProcess
*()
函数
有:CreateP...
c#
拦截程序的运行
一.Ring3Hook: 可以写个驱动程序, 只需要在初始化代码
中
用PsSet
CreateProcess
NotifyRoutine注册一个回调
函数
就可以在接下去任何process创建时获得通知。 然后只要想办法通知ring3的前端程序就可以了。 如果想在ring...
[转]
C#
利用WinRAR (加密)压缩及解压缩 相关参数
//// 压缩包
中
的其他文件 不予解压 //strtxtPath = "c:\\freezip\\"; //Process1.StartInfo.Arguments = " x " + strzipPath + " " +" free1.txt" + " " + strtxtPath; //// 11 //// 通过 -y ...
C#
110,561
社区成员
642,566
社区内容
发帖
与我相关
我的任务
C#
.NET技术 C#
复制链接
扫一扫
分享
社区描述
.NET技术 C#
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧
+ 用AI写文章