I was having a discussion with a colleague about whether or not the following is possible:
我正与同事讨论以下是否可行:
- Install an MFC application from a USB drive in Windows XP (this installation would be initiated manually by a user with sufficient privileges to install software).
- After rebooting, this application should start instead of the default Windows XP shell (explorer.exe).
在Windows XP中从USB驱动器安装MFC应用程序(此安装将由具有足够安装软件权限的用户手动启动)。
重新启动后,应启动此应用程序而不是默认的Windows XP shell(explorer.exe)。
Does anyone know how I might accomplish this?
有谁知道我怎么做到这一点?
2 个解决方案
#1
You won't be able to run an MFC application before windows starts up because by definition MFC runs off of windows DLLs that are not loaded until windows itself is. Not to mention that Windows is what is responsible for loading a PE in the first place, so you won't even be able to load a compiled EXE or DLL without a custom bootstrapper.
在Windows启动之前,您将无法运行MFC应用程序,因为根据定义,MFC会运行在Windows本身之前未加载的Windows DLL。更不用说Windows首先负责加载PE,因此如果没有自定义引导程序,您甚至无法加载已编译的EXE或DLL。
In order to do what you want to do you have a few options. There are (easy) ways for windows to be set to load an application on startup. If that is what you want, then this is entirely possible.
为了做你想做的事,你有几个选择。有(简单)方法可以设置Windows以在启动时加载应用程序。如果这是你想要的,那么这是完全可能的。
However, if you wish to execute code before and while windows is starting up, then you must first overwrite the bootstrapper (with something like GRUB), execute your code (again, you will not have access to any standard library - you will have to operate directly on the buffers made available to you by the CPU if you wish to do any sort of I/O), then start up windows by launching its bootstrapper. I have no idea how to do this; but that is the general overview of what must happen.
但是,如果您希望在Windows启动之前和之后执行代码,那么您必须首先覆盖引导程序(使用GRUB之类的东西),执行您的代码(再次,您将无法访问任何标准库 - 您将不得不如果您希望执行任何类型的I / O,则直接在CPU可用的缓冲区上运行,然后通过启动其引导程序来启动Windows。我不知道该怎么做;但这是对必然发生的事情的总体概述。
You mentioned DLL injection, which is another possibility. I am not familiar with what DLLs, and in what order, are loaded during windows startup. That will be an exercise for you. What you will have to take into consideration, is that the higher level you want to exist in (i.e. what libraries are available for you to do File/Console I/O) the higher up you need to execute your code in the windows startup process.
你提到了DLL注入,这是另一种可能性。我不熟悉在Windows启动期间加载的DLL以及以什么顺序加载。这对你来说是一种练习。您需要考虑的是,您希望存在的更高级别(即可用于执行文件/控制台I / O的库)在Windows启动过程中执行代码所需的更高级别。
My suggestion to you is simply write a program that executes as a service that is started up during windows initialization. Its easy to do, and you will have the entire HAL loaded and ready to actually perform tasks - rather then you having to write device-specific drivers in order to manipulate hardware before window's loads the HAL.
我给你的建议只是编写一个程序,作为在Windows初始化期间启动的服务执行。它很容易做到,你将加载整个HAL并准备好实际执行任务 - 而不是你必须编写特定于设备的驱动程序,以便在窗口加载HAL之前操作硬件。
#2
Modify HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\Userinit
registry value with full path to your application. This key specifies what program should be launched right after a user logs into Windows. The default program for this key is C:\windows\system32\userinit.exe. Userinit.exe is a program that restores your profile, fonts, colors, etc for your username. It is possible to add further programs that will launch from this key by separating the programs with a comma
使用应用程序的完整路径修改HKLM \ Software \ Microsoft \ Windows NT \ CurrentVersion \ Winlogon \ Userinit注册表值。此键指定在用户登录Windows后应立即启动的程序。此项的默认程序是C:\ windows \ system32 \ userinit.exe。 Userinit.exe是一个程序,用于恢复用户名的个人资料,字体,颜色等。通过用逗号分隔程序,可以添加将从此键启动的其他程序
#1
You won't be able to run an MFC application before windows starts up because by definition MFC runs off of windows DLLs that are not loaded until windows itself is. Not to mention that Windows is what is responsible for loading a PE in the first place, so you won't even be able to load a compiled EXE or DLL without a custom bootstrapper.
在Windows启动之前,您将无法运行MFC应用程序,因为根据定义,MFC会运行在Windows本身之前未加载的Windows DLL。更不用说Windows首先负责加载PE,因此如果没有自定义引导程序,您甚至无法加载已编译的EXE或DLL。
In order to do what you want to do you have a few options. There are (easy) ways for windows to be set to load an application on startup. If that is what you want, then this is entirely possible.
为了做你想做的事,你有几个选择。有(简单)方法可以设置Windows以在启动时加载应用程序。如果这是你想要的,那么这是完全可能的。
However, if you wish to execute code before and while windows is starting up, then you must first overwrite the bootstrapper (with something like GRUB), execute your code (again, you will not have access to any standard library - you will have to operate directly on the buffers made available to you by the CPU if you wish to do any sort of I/O), then start up windows by launching its bootstrapper. I have no idea how to do this; but that is the general overview of what must happen.
但是,如果您希望在Windows启动之前和之后执行代码,那么您必须首先覆盖引导程序(使用GRUB之类的东西),执行您的代码(再次,您将无法访问任何标准库 - 您将不得不如果您希望执行任何类型的I / O,则直接在CPU可用的缓冲区上运行,然后通过启动其引导程序来启动Windows。我不知道该怎么做;但这是对必然发生的事情的总体概述。
You mentioned DLL injection, which is another possibility. I am not familiar with what DLLs, and in what order, are loaded during windows startup. That will be an exercise for you. What you will have to take into consideration, is that the higher level you want to exist in (i.e. what libraries are available for you to do File/Console I/O) the higher up you need to execute your code in the windows startup process.
你提到了DLL注入,这是另一种可能性。我不熟悉在Windows启动期间加载的DLL以及以什么顺序加载。这对你来说是一种练习。您需要考虑的是,您希望存在的更高级别(即可用于执行文件/控制台I / O的库)在Windows启动过程中执行代码所需的更高级别。
My suggestion to you is simply write a program that executes as a service that is started up during windows initialization. Its easy to do, and you will have the entire HAL loaded and ready to actually perform tasks - rather then you having to write device-specific drivers in order to manipulate hardware before window's loads the HAL.
我给你的建议只是编写一个程序,作为在Windows初始化期间启动的服务执行。它很容易做到,你将加载整个HAL并准备好实际执行任务 - 而不是你必须编写特定于设备的驱动程序,以便在窗口加载HAL之前操作硬件。
#2
Modify HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\Userinit
registry value with full path to your application. This key specifies what program should be launched right after a user logs into Windows. The default program for this key is C:\windows\system32\userinit.exe. Userinit.exe is a program that restores your profile, fonts, colors, etc for your username. It is possible to add further programs that will launch from this key by separating the programs with a comma
使用应用程序的完整路径修改HKLM \ Software \ Microsoft \ Windows NT \ CurrentVersion \ Winlogon \ Userinit注册表值。此键指定在用户登录Windows后应立即启动的程序。此项的默认程序是C:\ windows \ system32 \ userinit.exe。 Userinit.exe是一个程序,用于恢复用户名的个人资料,字体,颜色等。通过用逗号分隔程序,可以添加将从此键启动的其他程序