无忧启动论坛

 找回密码
 注册
搜索
系统gho:最纯净好用系统下载站广告联系 微信:wuyouceo QQ:184822951
查看: 5930|回复: 18
打印 上一主题 下一主题

[求助] 如何将VC程序标准库添加到PE中

[复制链接]
跳转到指定楼层
1#
发表于 2016-3-24 11:27:15 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
自己编写了一个VC程序,需要用到VC的标准库,但是PE环境中没有这些库,请问如何可以把这些库添加到PE中?
2#
发表于 2016-3-24 12:44:33 | 只看该作者
不使用.net,不使用MFC,纯WIN32程序的话,/MT编译就可以直接PE用。
回复

使用道具 举报

3#
 楼主| 发表于 2016-3-24 14:14:43 | 只看该作者
slore 发表于 2016-3-24 12:44
不使用.net,不使用MFC,纯WIN32程序的话,/MT编译就可以直接PE用。

自己写的那个程序没有使用.net,也没有使用MFC,而且也改成/MT编译了,但是在PE运行时,还是0xC0150002错误。网上说这个错误,表示库文件缺失。因此我想把VC下的库文件都加入到PE中,看看能不能解决这个问题。

点评

下载procmon监控看在PE下调用缺少文件,另外用资源编辑软件查看调用哪些dll是非系统内核的,补充就可以的启动必需文件一般在导入表看看见  发表于 2016-3-24 17:41
如果这样,你知道要那些库,头文件已一一列出  详情 回复 发表于 2016-3-24 16:50
回复

使用道具 举报

4#
发表于 2016-3-24 16:50:16 来自手机 | 只看该作者
cnpirate 发表于 2016-3-24 14:14
自己写的那个程序没有使用.net,也没有使用MFC,而且也改成/MT编译了,但是在PE运行时,还是0xC0150002错 ...

如果这样,你知道要那些库,头文件已一一列出

点评

请问老师的RcData压缩资源工具可以分享吗?compress.exe吗?如果那个文件不可单独运行,还请带上附属文件,谢谢  详情 回复 发表于 2016-3-24 17:38
回复

使用道具 举报

5#
发表于 2016-3-24 19:39:54 来自手机 | 只看该作者
frg521 发表于 2016-3-24 17:38
请问老师的RcData压缩资源工具可以分享吗?compress.exe吗?如果那个文件不可单独运行,还请带上附属文件,谢 ...

压缩/解压,代码都是PECMD内置的,就是LZMA命令的代码,这个代码网上有,以前我在时空论坛发过类似的代码。另一个是自己如何读取资源数据,网上也有代码——PE文件头格式。

点评

几乎找遍那个帖子,没有看到繁体化译者与你提到如何解压,倒是你提到,还有截图是无图标的compress.exe 是你提供给工具的吧? 否则lzma.exe或7z解压不了,用pecmd.exe如何压缩呢,90多条命令也没找到,最后就是不会使用vc6  详情 回复 发表于 2016-3-25 05:42
回复

使用道具 举报

6#
 楼主| 发表于 2016-3-25 15:07:00 | 只看该作者
本帖最后由 cnpirate 于 2016-3-25 16:11 编辑
lxl1638 发表于 2016-3-24 16:50
如果这样,你知道要那些库,头文件已一一列出


我把这个程序在正常Windows 7操作系统上运行时的Resource Monitor工具看到的使用资源截图了,这里面有个
C:\Windows\winsxs\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.6161_none_08e61857a83bc251
我把这个放到了PE环境中对应的目录下,再执行GantryBoard_while.exe这个程序,依然是0xC0150002这个错误

再补充一下,使用Dependency Walker分析GantryBoard_while.exe,发现程序调用了下面三个dll:LIBSEMA.DLL
KERNEL32.DLLws2_32.DLL

LIBSEMA.DLL    这个我已经将其和exe放到了同一个目录下;
KERNEL32.DLL  这个在PE环境下的\Windows\System32\下面有;
ws2_32.DLL      这个将本机的dll放到了PE环境下的\Windows\System32\中

但是这样做完以后,在PE环境下执行GantryBoard_while.exe依然报0xC0150002错误

ResourceMonitor.png (47.95 KB, 下载次数: 70)

ResourceMonitor.png
回复

使用道具 举报

7#
发表于 2016-3-25 18:49:32 | 只看该作者
本帖最后由 2012tzyx 于 2016-3-25 18:58 编辑

vc2008还需要注册表的吧。要么就还得加几个manifest文件。
试试用dependency walker找找依赖。
回复

使用道具 举报

8#
发表于 2016-3-25 20:30:30 | 只看该作者
本帖最后由 yfwang0798 于 2016-3-25 20:34 编辑

以前在pe3 x86集成vc相关文件和注册表设置,用于适用active password changer  6.01,64位应该类似:
要添加的文件位置
Windows\winsxs 下所有包含 x86 和 vc 字符的文件夹,如
x86_microsoft-windows-vcm-core-codecs_31bf3856ad364e35_6.1.7601.17514_none_6eaa2afd36b1e303
等几个文件夹
Windows\winsxs\manifests 文件夹下包含 x86 和vc名字的文件。例如x86_microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.4940_none_d08cc06a442b34fc.manif  等文件。


要添加的注册表位置
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\Winners
下所有包含 x86和vc的注册表。



点评

添加文件和导入注册表后,在PE环境下,打开文本文件,提示: The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log or use the comma  详情 回复 发表于 2016-3-29 11:26

评分

参与人数 1无忧币 +5 收起 理由
cnpirate + 5 很给力!

查看全部评分

回复

使用道具 举报

9#
 楼主| 发表于 2016-3-28 16:21:04 | 只看该作者
yfwang0798 发表于 2016-3-25 20:30
以前在pe3 x86集成vc相关文件和注册表设置,用于适用active password changer  6.01,64位应该类似:
要添 ...

按照你说的方法,我把Windows\winsxs下所有包含amd64和vc字符的文件,以及Windows\winsxs\manifests文件下包含amd64和vc字符的文件导入到PE中,并且将注册表也导入,我的程序可以在PE环境下运行了。

非常感谢,谢谢
回复

使用道具 举报

10#
 楼主| 发表于 2016-3-29 11:26:08 | 只看该作者
yfwang0798 发表于 2016-3-25 20:30
以前在pe3 x86集成vc相关文件和注册表设置,用于适用active password changer  6.01,64位应该类似:
要添 ...

添加文件和导入注册表后,在PE环境下,打开文本文件,提示:
The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log or use the command-line sxstrace.exe tool for more detail.
起初,我以为是注册表导入的不对,但是换一个机器的注册表,还是一样的错误

使用sxstrace.exe获得log文件如下:

=================
Begin Activation Context Generation.
Input Parameter:
        Flags = 0
        ProcessorArchitecture = AMD64
        CultureFallBacks = en-US;en
        ManifestPath = X:\windows\system32\NOTEPAD.EXE
        AssemblyDirectory = X:\windows\system32\
        Application Config File =
-----------------
INFO: Parsing Manifest File X:\windows\system32\NOTEPAD.EXE.
        INFO: Manifest Definition Identity is Notepad2,type="win32",version="5.1.0.0".
        INFO: Reference: Microsoft.Windows.Common-Controls,language="*",processorArchitecture="*",publicKeyToken="6595b64144ccf1df",type="win32",version="6.0.0.0"
INFO: Resolving reference Microsoft.Windows.Common-Controls,language="*",processorArchitecture="*",publicKeyToken="6595b64144ccf1df",type="win32",version="6.0.0.0".
        INFO: Resolving reference for ProcessorArchitecture AMD64.
                INFO: Resolving reference for culture en-US.
                        INFO: Applying Binding Policy.
                                INFO: No publisher policy found.
                                INFO: No binding policy redirect found.
                        INFO: Begin assembly probing.
                                INFO: Did not find the assembly in WinSxS.
                                INFO: Attempt to probe manifest at X:\windows\assembly\GAC_64\Microsoft.Windows.Common-Controls\6.0.0.0_en-US_6595b64144ccf1df\Microsoft.Windows.Common-Controls.DLL.
                                INFO: Attempt to probe manifest at X:\windows\system32\en-US\Microsoft.Windows.Common-Controls.DLL.
                                INFO: Attempt to probe manifest at X:\windows\system32\en-US\Microsoft.Windows.Common-Controls.MANIFEST.
                                INFO: Attempt to probe manifest at X:\windows\system32\en-US\Microsoft.Windows.Common-Controls\Microsoft.Windows.Common-Controls.DLL.
                                INFO: Attempt to probe manifest at X:\windows\system32\en-US\Microsoft.Windows.Common-Controls\Microsoft.Windows.Common-Controls.MANIFEST.
                                INFO: Did not find manifest for culture en-US.
                        INFO: End assembly probing.
                INFO: Resolving reference for culture en.
                        INFO: Applying Binding Policy.
                                INFO: No publisher policy found.
                                INFO: No binding policy redirect found.
                        INFO: Begin assembly probing.
                                INFO: Did not find the assembly in WinSxS.
                                INFO: Attempt to probe manifest at X:\windows\assembly\GAC_64\Microsoft.Windows.Common-Controls\6.0.0.0_en_6595b64144ccf1df\Microsoft.Windows.Common-Controls.DLL.
                                INFO: Did not find manifest for culture en.
                        INFO: End assembly probing.
                INFO: Resolving reference for culture Neutral.
                        INFO: Applying Binding Policy.
                                INFO: Auto Servicing Policy redirected assembly version.
                                INFO: Post policy assembly identity is Microsoft.Windows.Common-Controls,processorArchitecture="AMD64",publicKeyToken="6595b64144ccf1df",type="win32",version="6.0.7601.18837".
                        INFO: Begin assembly probing.
                                INFO: Attempt to probe manifest at X:\windows\WinSxS\manifests\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.7601.18837_none_fa3b1e3d17594757.manifest.
                                INFO: Attempt to probe manifest at X:\windows\assembly\GAC_64\Microsoft.Windows.Common-Controls\6.0.7601.18837__6595b64144ccf1df\Microsoft.Windows.Common-Controls.DLL.
                                INFO: Attempt to probe manifest at X:\windows\system32\Microsoft.Windows.Common-Controls.DLL.
                                INFO: Attempt to probe manifest at X:\windows\system32\Microsoft.Windows.Common-Controls.MANIFEST.
                                INFO: Attempt to probe manifest at X:\windows\system32\Microsoft.Windows.Common-Controls\Microsoft.Windows.Common-Controls.DLL.
                                INFO: Attempt to probe manifest at X:\windows\system32\Microsoft.Windows.Common-Controls\Microsoft.Windows.Common-Controls.MANIFEST.
                                INFO: Did not find manifest for culture Neutral.
                        INFO: End assembly probing.
        INFO: Resolving reference for ProcessorArchitecture MSIL.
                INFO: Resolving reference for culture en-US.
                        INFO: Applying Binding Policy.
                                INFO: No publisher policy found.
                                INFO: No binding policy redirect found.
                        INFO: Begin assembly probing.
                                INFO: Did not find the assembly in WinSxS.
                                INFO: Attempt to probe manifest at X:\windows\assembly\GAC_MSIL\Microsoft.Windows.Common-Controls\6.0.7601.18837_en-US_6595b64144ccf1df\Microsoft.Windows.Common-Controls.DLL.
                                INFO: Did not find manifest for culture en-US.
                        INFO: End assembly probing.
                INFO: Resolving reference for culture en.
                        INFO: Applying Binding Policy.
                                INFO: No publisher policy found.
                                INFO: No binding policy redirect found.
                        INFO: Begin assembly probing.
                                INFO: Did not find the assembly in WinSxS.
                                INFO: Attempt to probe manifest at X:\windows\assembly\GAC_MSIL\Microsoft.Windows.Common-Controls\6.0.7601.18837_en_6595b64144ccf1df\Microsoft.Windows.Common-Controls.DLL.
                                INFO: Did not find manifest for culture en.
                        INFO: End assembly probing.
                INFO: Resolving reference for culture Neutral.
                        INFO: Applying Binding Policy.
                                INFO: No publisher policy found.
                                INFO: No binding policy redirect found.
                        INFO: Begin assembly probing.
                                INFO: Did not find the assembly in WinSxS.
                                INFO: Attempt to probe manifest at X:\windows\assembly\GAC_MSIL\Microsoft.Windows.Common-Controls\6.0.7601.18837__6595b64144ccf1df\Microsoft.Windows.Common-Controls.DLL.
                                INFO: Did not find manifest for culture Neutral.
                        INFO: End assembly probing.
        INFO: Resolving reference for ProcessorArchitecture Data.
                INFO: Resolving reference for culture en-US.
                        INFO: Applying Binding Policy.
                                INFO: No publisher policy found.
                                INFO: No binding policy redirect found.
                        INFO: Begin assembly probing.
                                INFO: Did not find the assembly in WinSxS.
                                INFO: Attempt to probe manifest at X:\windows\assembly\GAC\Microsoft.Windows.Common-Controls\6.0.7601.18837_en-US_6595b64144ccf1df\Microsoft.Windows.Common-Controls.DLL.
                                INFO: Did not find manifest for culture en-US.
                        INFO: End assembly probing.
                INFO: Resolving reference for culture en.
                        INFO: Applying Binding Policy.
                                INFO: No publisher policy found.
                                INFO: No binding policy redirect found.
                        INFO: Begin assembly probing.
                                INFO: Did not find the assembly in WinSxS.
                                INFO: Attempt to probe manifest at X:\windows\assembly\GAC\Microsoft.Windows.Common-Controls\6.0.7601.18837_en_6595b64144ccf1df\Microsoft.Windows.Common-Controls.DLL.
                                INFO: Did not find manifest for culture en.
                        INFO: End assembly probing.
                INFO: Resolving reference for culture Neutral.
                        INFO: Applying Binding Policy.
                                INFO: No publisher policy found.
                                INFO: No binding policy redirect found.
                        INFO: Begin assembly probing.
                                INFO: Did not find the assembly in WinSxS.
                                INFO: Attempt to probe manifest at X:\windows\assembly\GAC\Microsoft.Windows.Common-Controls\6.0.7601.18837__6595b64144ccf1df\Microsoft.Windows.Common-Controls.DLL.
                                INFO: Did not find manifest for culture Neutral.
                        INFO: End assembly probing.
        ERROR: Cannot resolve reference Microsoft.Windows.Common-Controls,language="*",processorArchitecture="*",publicKeyToken="6595b64144ccf1df",type="win32",version="6.0.0.0".
ERROR: Activation Context generation failed.
End Activation Context Generation.

=================
Begin Activation Context Generation.
Input Parameter:
        Flags = 0
        ProcessorArchitecture = AMD64
        CultureFallBacks = en-US;en
        ManifestPath = X:\windows\system32\ndfapi.dll
        AssemblyDirectory = X:\windows\system32\
        Application Config File =
-----------------
INFO: Parsing Manifest File X:\windows\system32\ndfapi.dll.
        INFO: Manifest Definition Identity is ndfapi,processorArchitecture="amd64",type="win32",version="1.0.0.0".
        INFO: Reference: Microsoft.Windows.Common-Controls,language="*",processorArchitecture="amd64",publicKeyToken="6595b64144ccf1df",type="win32",version="6.0.0.0"
INFO: Resolving reference Microsoft.Windows.Common-Controls,language="*",processorArchitecture="amd64",publicKeyToken="6595b64144ccf1df",type="win32",version="6.0.0.0".
        INFO: Resolving reference for ProcessorArchitecture amd64.
                INFO: Resolving reference for culture en-US.
                        INFO: Applying Binding Policy.
                                INFO: No publisher policy found.
                                INFO: No binding policy redirect found.
                        INFO: Begin assembly probing.
                                INFO: Did not find the assembly in WinSxS.
                                INFO: Attempt to probe manifest at X:\windows\assembly\GAC_64\Microsoft.Windows.Common-Controls\6.0.0.0_en-US_6595b64144ccf1df\Microsoft.Windows.Common-Controls.DLL.
                                INFO: Attempt to probe manifest at X:\windows\system32\en-US\Microsoft.Windows.Common-Controls.DLL.
                                INFO: Attempt to probe manifest at X:\windows\system32\en-US\Microsoft.Windows.Common-Controls.MANIFEST.
                                INFO: Attempt to probe manifest at X:\windows\system32\en-US\Microsoft.Windows.Common-Controls\Microsoft.Windows.Common-Controls.DLL.
                                INFO: Attempt to probe manifest at X:\windows\system32\en-US\Microsoft.Windows.Common-Controls\Microsoft.Windows.Common-Controls.MANIFEST.
                                INFO: Did not find manifest for culture en-US.
                        INFO: End assembly probing.
                INFO: Resolving reference for culture en.
                        INFO: Applying Binding Policy.
                                INFO: No publisher policy found.
                                INFO: No binding policy redirect found.
                        INFO: Begin assembly probing.
                                INFO: Did not find the assembly in WinSxS.
                                INFO: Attempt to probe manifest at X:\windows\assembly\GAC_64\Microsoft.Windows.Common-Controls\6.0.0.0_en_6595b64144ccf1df\Microsoft.Windows.Common-Controls.DLL.
                                INFO: Did not find manifest for culture en.
                        INFO: End assembly probing.
                INFO: Resolving reference for culture Neutral.
                        INFO: Applying Binding Policy.
                                INFO: Auto Servicing Policy redirected assembly version.
                                INFO: Post policy assembly identity is Microsoft.Windows.Common-Controls,processorArchitecture="amd64",publicKeyToken="6595b64144ccf1df",type="win32",version="6.0.7601.18837".
                        INFO: Begin assembly probing.
                                INFO: Attempt to probe manifest at X:\windows\WinSxS\manifests\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.7601.18837_none_fa3b1e3d17594757.manifest.
                                INFO: Attempt to probe manifest at X:\windows\assembly\GAC_64\Microsoft.Windows.Common-Controls\6.0.7601.18837__6595b64144ccf1df\Microsoft.Windows.Common-Controls.DLL.
                                INFO: Attempt to probe manifest at X:\windows\system32\Microsoft.Windows.Common-Controls.DLL.
                                INFO: Attempt to probe manifest at X:\windows\system32\Microsoft.Windows.Common-Controls.MANIFEST.
                                INFO: Attempt to probe manifest at X:\windows\system32\Microsoft.Windows.Common-Controls\Microsoft.Windows.Common-Controls.DLL.
                                INFO: Attempt to probe manifest at X:\windows\system32\Microsoft.Windows.Common-Controls\Microsoft.Windows.Common-Controls.MANIFEST.
                                INFO: Did not find manifest for culture Neutral.
                        INFO: End assembly probing.
        ERROR: Cannot resolve reference Microsoft.Windows.Common-Controls,language="*",processorArchitecture="amd64",publicKeyToken="6595b64144ccf1df",type="win32",version="6.0.0.0".
ERROR: Activation Context generation failed.

End Activation Context Generation.



点评

你确定你的/MT设定到release|x64的配置上了么? /MT的话运行库是直接编译到exe程序里面的。  详情 回复 发表于 2016-3-29 11:30
回复

使用道具 举报

11#
发表于 2016-3-29 11:30:03 | 只看该作者
cnpirate 发表于 2016-3-29 11:26
添加文件和导入注册表后,在PE环境下,打开文本文件,提示:
The application has failed to start beca ...

你确定你的/MT设定到release|x64的配置上了么?
/MT的话运行库是直接编译到exe程序里面的。

点评

嗯嗯,我确认,因为我把程序中某些代码注释掉,程序可以正确执行的。  详情 回复 发表于 2016-3-29 12:06
回复

使用道具 举报

12#
 楼主| 发表于 2016-3-29 12:06:10 | 只看该作者
slore 发表于 2016-3-29 11:30
你确定你的/MT设定到release|x64的配置上了么?
/MT的话运行库是直接编译到exe程序里面的。

嗯嗯,我确认,因为我把程序中某些代码注释掉,程序可以正确执行的。
回复

使用道具 举报

13#
发表于 2016-3-29 17:23:08 | 只看该作者
国外这个网站有现成的软件,包含notepad等组件。

http://theoven.org/index.php?PHP ... c490083859460d7efa;

它提供的notepad,没有数字签名,不是微软的,但是可以在pe中运行。只要会winbuilder语法,就可以自己定制pe。

点评

能提供学习winbuilder语法的资料么,嘿嘿,^_^  详情 回复 发表于 2016-3-30 09:53
回复

使用道具 举报

14#
 楼主| 发表于 2016-3-30 09:53:18 | 只看该作者
yfwang0798 发表于 2016-3-29 17:23
国外这个网站有现成的软件,包含notepad等组件。

http://theoven.org/index.php?PHPSESSID=c2e332fdd9 ...

能提供学习winbuilder语法的资料么,嘿嘿,^_^
回复

使用道具 举报

15#
发表于 2016-3-30 13:09:05 | 只看该作者
前面介绍的网站下载软件包中有帮助文件,最简单的语法
http://reboot.pro/topic/4424-app ... g-a-new-app-script/

也可以参考别人制作的脚本学习。

点评

非常感谢啊  详情 回复 发表于 2016-3-30 14:16
回复

使用道具 举报

16#
 楼主| 发表于 2016-3-30 14:16:44 | 只看该作者
yfwang0798 发表于 2016-3-30 13:09
前面介绍的网站下载软件包中有帮助文件,最简单的语法
http://reboot.pro/topic/4424-app-scripts-guide-c ...

非常感谢啊
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|捐助支持|无忧启动 ( 闽ICP备05002490号-1 )

闽公网安备 35020302032614号

GMT+8, 2024-5-12 06:08

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表