我挂接了CreateProcessW(),在分析原来API传入的参数LPCTSTR lpApplicationName, LPTSTR lpCommandLine,去发现有问题!
大家看看这段代码
char buf[255];
memset(buf,0,255);
strcat(buf,lpApplicationName);
strcat(buf,lpCommandLine);
strcat(buf,"是否执行该程序?");
然后用MessaegBox()显示buf里面的内容,发现MessageBox()显示的是"C是否执行该程序?"要么就是
"E是否执行该程序?"....反正就是显示不出lpApplicationName和lpCommandLine,后来我改了一下
string str="";
str+=lpApplicationName;
str+="是否执行该程序?"; OutputDebugString(lpApplicationName);
OutputDebugString(lpCommandLine);
结果还是一样!用调试器捕捉的调试输出还是一个老样子!
我觉得是Unicode编码的问题吧~~因为CreateProcessW传入的是宽字符,但我实在不会处理啊,各位高手帮帮忙~~谢谢了~~!

解决方案 »

  1.   

    用TCHAR还是不行,可能是工程设置问题,但能不能给段代码?因为挂接的是CreateProcessW().很多程序调用的是CreateProcessW(),所以挂接的是它.
      

  2.   

    CreateProcessW()改成CreateProcessA试试
      

  3.   

    换成WCHAR后
    wcscat(buf,lpApplicationName);
    wcscat(buf,lpCommandLine);
    wcscat(buf,"是否执行该程序?");
    编译不过去了.CreateProcessW()改成CreateProcessA整个程序就不能用了~我把代码发上来好了.
      

  4.   

    BOOL WINAPI proxy_CreateProcessW(
      LPCTSTR lpApplicationName,
      LPTSTR lpCommandLine,
      LPSECURITY_ATTRIBUTES lpProcessAttributes,
      LPSECURITY_ATTRIBUTES lpThreadAttributes,
      BOOL bInheritHandles,
      DWORD dwCreationFlags,
      LPVOID lpEnvironment,
      LPCTSTR lpCurrentDirectory,
      LPSTARTUPINFO lpStartupInfo,
      LPPROCESS_INFORMATION lpProcessInformation
    )
    {
    /* string str="";
    str+=lpApplicationName;
    str+="是否执行该程序?";*/
    char buf[255];
    memset(buf,0,255);
    strcat(buf,lpApplicationName);
    strcat(buf,lpCommandLine);
    strcat(buf,"是否执行该程序?");
    OutputDebugString(lpApplicationName);
    OutputDebugString(lpCommandLine); if(MessageBox(NULL,buf,"注意",MB_YESNO|MB_ICONWARNING)
    ==IDNO)
    return FALSE;

    return ((PFNCPW)(PROC)g_CreateProcessW)(
     lpApplicationName,
     lpCommandLine,
     lpProcessAttributes,
     lpThreadAttributes,
     bInheritHandles,
     dwCreationFlags,
     lpEnvironment,
     lpCurrentDirectory,
     lpStartupInfo,
     lpProcessInformation
     );

    }
    运行步骤如下,注入到taskmgr中,用taskmgr的新任务..结果显示如下"C是否执行该程序?"即使捕获的OutputDebugString(lpApplicationName);
    OutputDebugString(lpCommandLine);还是一样的结果,都不能正常显示lpApplicationName和lpCommandLine.急啊~~!晕啊@_@!我先上课去,晚上再上来,谢谢各位高手了!
      

  5.   

    忘了,这个DLL都不知道去调试,是给taskmgr等其他程序用的,我只能用OutputDebugString()跟踪程序里的变量了.
      

  6.   

    lpApplicationName,lpCommandLine都用MultiByteToWideChar转换成wchar.