无忧启动论坛

 找回密码
 注册
搜索
系统gho:最纯净好用系统下载站投放广告、加入VIP会员,请联系 微信:wuyouceo
楼主: 2011足迹
打印 上一主题 下一主题

native版的mini pecmd测试,添加mount命令--2011-4-4

    [复制链接]
211#
发表于 2011-4-11 14:59:16 | 只看该作者
原帖由 sp_star 于 2011-4-11 09:42 发表


是的,关掉fbwf就能挂载上。目前的问题是这样:
1. 挂载到x根目录,再启动fbwf,就会蓝屏。好像有冲突。
2. 挂载到x:\windows(目录结构保持正确),fbwf好像没问题了。但是就算不启动fbwf,启动7PE时还会蓝 ...

这个不是很清楚,可能是PE1.X 的FBWF的挂X:的方式和PE3.X的不同吧
回复

使用道具 举报

212#
发表于 2011-4-11 15:00:00 | 只看该作者
原帖由 jianliulin 于 2011-4-11 12:29 发表


楼主早已经发布了!!!!

那个是PE1.X的,比较想看到PE3.X的模板,呵呵~~

目前PE3.X在挂X: 上还没进展呢
回复

使用道具 举报

213#
发表于 2011-4-11 15:02:10 | 只看该作者
我了个天,一句也没看懂
回复

使用道具 举报

214#
 楼主| 发表于 2011-4-11 23:15:37 | 只看该作者
大家好...谢谢大家关心进展...
由于native api开发难度大..最近在研究能否把reactos的kernel32和crt移植进来...
native的开发进度可能会暂停..等移植成功后再说...
native没有针对win7编译...在win7的pe上可能会有问题..最郁闷的是针对win7的编译版本反而问题更大...很费解...
回复

使用道具 举报

215#
 楼主| 发表于 2011-4-12 11:35:48 | 只看该作者

回复 #236 friend8179 的帖子

请提供以下调用方式和出错信息..
至于何时加入注册表操作..我的打算是移植完成后...
移植完成kernel和crt后准备移植reactos的cmd..估计工程两可能不小...
现在遇到一些函数类型定义的问题..
reactos中的函数定义和ddk中函数定义不大一样,丢失了部分修饰付..导致链接的时候找不到函数...郁闷啊...看来不是要对头文件动刀就是要对代码动刀了..

[ 本帖最后由 2011足迹 于 2011-4-12 11:39 编辑 ]
回复

使用道具 举报

216#
发表于 2011-4-12 11:46:33 | 只看该作者
原帖由 2011足迹 于 2011-4-12 11:35 发表
请提供以下调用方式和出错信息..
至于何时加入注册表操作..我的打算是移植完成后...
移植完成kernel和crt后准备移植reactos的cmd..估计工程两可能不小...
现在遇到一些函数类型定义的问题..
reactos中的函数 ...


如果要提高效率,解决更多的bug,建议公布源代码,并建立一个工程(如google工程)

这样会有更多的人参与进去,有些功能的实现也可以有其他网友提供

当然,我不知道这是否违背楼主的初衷
回复

使用道具 举报

217#
 楼主| 发表于 2011-4-12 11:54:20 | 只看该作者

回复 #238 NicTense 的帖子

代码在google code上..前面的楼层有地址..
至于reactos的代码..管网上有..
顺便说下..最新的svn上代码可能有些地方要修正...
相信大家能解决这些问题...
回复

使用道具 举报

218#
 楼主| 发表于 2011-4-12 12:07:06 | 只看该作者
内存分配请使用RtlAllocateHeap(RtlGetProcessHeap(), 0 BUFFER_SIZE);
内存回收请使用RtlFreeHeap(RtlGetProcessHeap(), 0, buf);

另外RtlFreeUnicodeString之类的函数会释放掉UNICODE_STRING的buffer所指向的内存
使用了RtlFreeUnicodeString就不要RtlFreeHeap了...
释放一个已经被释放的指针会造成堆损坏而引起蓝屏..
自己管理内存的时候要特表小心
回复

使用道具 举报

219#
发表于 2011-4-13 08:13:10 | 只看该作者
很久没来看了。   

这个可是好东西, 弄好的话, 对于PE 的发展可是有质的的跳跃。,。。。   支持, 在支持。
回复

使用道具 举报

220#
发表于 2011-4-14 07:39:16 | 只看该作者
2011足迹 (足迹)     你去哪了。 怎么不接着研究了, 在等着看你的成果呢 ,
回复

使用道具 举报

221#
发表于 2011-4-14 09:18:51 | 只看该作者
别急,楼主在努力ing
回复

使用道具 举报

222#
 楼主| 发表于 2011-4-14 10:14:19 | 只看该作者

回复 #244 jianliulin 的帖子

呵呵...还是你了解我...昨天刚把kernel32.dll编译成native子系统的..居然有400K调整今天调整一下...试试有没有问题...下一步就是crt了...有了这两个移植代码就方便了...
回复

使用道具 举报

223#
发表于 2011-4-14 11:02:34 | 只看该作者

回复 #245 2011足迹 的帖子

我这两天抽时间也在学着写,好难写,比写一般的C难多了。

足迹有空记得到群里,我有很多问题咨询,因为很多native API 我不会用,还有的API我找不到,比如读写磁盘扇区的,也可以直接用NtCreateFile吗?
回复

使用道具 举报

224#
 楼主| 发表于 2011-4-14 11:41:46 | 只看该作者

回复 #246 Plantsoot 的帖子

native api的函数都在 inc\ndk里面的头文件有定义...
读写扇区好像要把整个磁盘设备当做一个文件...用NtCreateFile打开...反正现代操作系统都是面向文件的...设备读写也都是用文件读写函数
等把kernel32和crt移植过来就好了...标准C就可以用了...不过可能会损失一些函数...整体体积也可能增大不少...慢慢来吧
回复

使用道具 举报

225#
发表于 2011-4-14 17:16:07 | 只看该作者
原帖由 2011足迹 于 2011-4-14 11:41 发表
native api的函数都在 inc\ndk里面的头文件有定义...
读写扇区好像要把整个磁盘设备当做一个文件...用NtCreateFile打开...反正现代操作系统都是面向文件的...设备读写也都是用文件读写函数
等把kernel32和crt ...


十分期待,到时候也许 FbinstNative版也可以面试了。
回复

使用道具 举报

226#
发表于 2011-4-14 21:51:46 | 只看该作者
原帖由 2011足迹 于 2011-4-14 11:41 发表
native api的函数都在 inc\ndk里面的头文件有定义...
读写扇区好像要把整个磁盘设备当做一个文件...用NtCreateFile打开...反正现代操作系统都是面向文件的...设备读写也都是用文件读写函数
等把kernel32和crt ...

直接用Native API和NDK不好嗎?

轉wiki

Function groups

The Native API comprises many functions. They include C runtime functions that are needed for a very basic C runtime execution, such as strlen(), sprintf() and floor(). Other common procedures like malloc(), printf(), scanf() are missing. The vast majority of other Native API routines, by convention, have a 2 or 3 letter prefix, which is:

    * Nt or Zw are system calls declared in ntdll.dll and ntoskrnl.exe. When called from ntdll.dll in user mode, these groups are almost exactly the same; they trap into kernel mode and call the equivalent function in ntoskrnl.exe via a branch table. When calling the functions directly in ntoskrnl.exe (only possible in kernel mode), the Zw variants ensure kernel mode, whereas the Nt variants do not. The Zw prefix does not stand for anything.
    * Rtl is the second largest group of ntdll calls. These comprise the (extended) C Run-Time Library, which includes many utility functions that can be used by native applications, yet don't directly involve kernel support.
    * Csr are client-server functions that are used to communicate with the Win32 subsystem process, csrss.exe (csrss stands for client/server runtime sub-system).
    * Dbg are debugging aid functions such as a software break point.
    * Ki are upcalls from kernel-mode for things like APC dispatching.
    * Ldr are loader functions for PE file handling and starting of new processes.
    * Nls for Native Language Support (similar to code pages).
    * Pfx for prefix handling.

Gdi32.dll includes several other calls that trap into kernel-mode. These were not part of the original Windows NT design, as can be seen in Windows NT 3.5. However, due to performance issues of hardware of that age, it was decided to move the graphics subsystem into kernel mode. As such, system call in the range of 0x1000-0x1FFF are satisfied by win32k.sys (instead of ntoskrnl.exe as done for 0-0x0FFF), and are declared in gdi32.dll. These functions have the Gdi prefix.

There are also many more groups exported from ntoskrnl.exe and therefore are usable only in kernel mode. These may or may not be counted for Native API, depending on whom you ask (since the Native API is not fully officially documented, there is no one answer). Such groups include Cc (cache controller), Ex (Windows Executive), FsRtl (file system runtime), Io (I/O manager), Ke (core kernel routines), Ks (kernel streaming), Lpc (Local Procedure Call), Lsa (Local Security Authority), Mm (memory management), Ob (Object Manager), Ps (Process management), Se (security), Po (power management) and others.


  Native Development Kit Guidelines

This document serves as a brief introduction to the NDK, what should go in it, what shouldn't, and how the information is organized at the file level, as well as how the syntax and formatting is done at the source level.
What is the NDK?

The NDK, or Native Development Kit, is the brainchild of Alex Ionescu, allowing Windows and ReactOS developers alike to have access to a wealth of undocumented kernel and native structures and function prototypes.

Without the NDK, Windows developers are forced to define their own "undoct.h" headers in which they copy/paste information found online, which may or may not be valid and updated. For native types, this is even harder, as sometimes the information is present in the DDK or IFS, but cannot be used in a user-mode application, nor can it be copy-pasted. The developer must re-write all the definitions he needs.

Without the NDK, ReactOS developers are forced to use a system of up to 3 kinds of duplicated headers (sometimes four) containing identical, similar, or worse, different information. Differences between these headers create compile-time problems, and fixing one header set without updating the other usually causes brekage in applications compiled with "W32API" headers versus applications compiled with "ddk" headers vesus applications compiled with "ntos" headers.

The NDK provides a unified header set for development of:

    * User mode applications which use native functions (include windows.h and the user-mode NDK)
    * Native applications (include the user-mode NDK)
    * Kernel-mode drivers which use undocumented kernel functions (include ddk and/or ifs and kernel-mode NDK)

What goes in the NDK?

Because the NDK is a triple-mode header set, care must be taken to avoid collisions. The following information should go in the NDK:

    * Kernel-Mode API Function Prototypes or Types which are undocumented in the DDK or IFS. If the information is documented in the IFS but not the DDK, a file called ifssupp.h will automatically be inserted to provide the few types which are missing. Next year, then the Longhorn WDK is publically released, the IFS will be free and part of it, so everyone should then have access to it. For Types which vary according to version information, always include the most recent version. If older versions are needed, use a compile-time macro to read the build environment (target version) and choose the correct structure.

    * Native (RTL, DBG, PFX, NT/ZW) API Function Prototypes or Types which are undocumented in the DDK, IFS or Windows Headers.
          o If the Type is documented in the DDK or IFS, make sure that it's actually accessible from user mode. If that is the case, locate the proper header where it should go (ex: pstypes.h), and add it, making sure to surround it by #ifdef NTOS_MODE_USER/#endif. This will protect it from the DDK/IFS.
          o In the rare case that you will find types defined in Windows headers but not in DDK/IFS, you must add the definition to a special protected block (ex:#ifndef NTOS_MODE_USER) so that it will be skipped by user-mode applications.

What should not go in the NDK?

    * Do not add documented information in the NDK unless it must be accessible from user-mode (which cannot include DDK or IFS), see above guidelines.
    * Do not add Native ReactOS Specific information anywhere.
    * Do not add Private ReactOS function or types.
    * Do not add User-Mode undocumented functions (like shell32, etc).
          o However, if the function is inside ntdll, you must add it to "umfuncs.h"

How is the NDK organized?

    * The NDK is organized in a main folder (include/ndk) with arch-specific subfolders (ex: include/ndk/i386).

    * The NDK is structured by NT Subsystem Component (ex: ex, ps, rtl, etc).

    * The NDK can either be included on-demand (#include <ndk/xxxxx.h>) or globally (#include <ndk/ntndk.h>). The former is recommended to reduce compile time.

    * The NDK is structured by function and type. Every Subsystem Component has an associated "xxfuncs.h" and "xxtypes.h" header, where "xx" is the Subsystem (ex: iofuncs.h, iotypes.h)

    * The NDK has a special file called "umtypes.h" which exports to User-Mode or Native-Mode Applications the basic NT types which are present in ntdef.h. This file cannot be included since it would conflict with winnt.h and/or windef.h. Thus, umtypes.h provides the missing types. This file is automatically included in a User-Mode NDK project.

    * The NDK also includes a file called "umfuncs.h" which exports to User-Mode or Native-Mode Applications undocumented functions which can only be accessed from ntdll.dll.

    * The NDK has another special file called "ifssupp.h", which exports to Kernel-Mode drivers a few types which are only documented in the IFS kit, and are part of some native definitions. It will be deprecated next year with the release of the WDK.

What is the formatting syntax in the NDK?

Types must be defined as follows:

typedef struct _TYPENAME
{
    PMEMBER_TYPE Member1;
    MEMBER_TYPE1 Member2;
    struct _TYPENAME *SelfMember;
    union
    {
        struct
        {
            UCHAR Member3:4;
            UCHAR Member4:4;
        };
        UCHAR Member5;
    }
    MEMBER_TYPE2 Member6;
} TYPENAME, *PTYPENAME;

Prototypes as follows:

RETURNTYPE
CALLING_CONVENTION
FunctionName(
    PARAM_TYPE Param1,
    PARAM_TYPE Param2
);

Similalry, function types:

typedef RETURNTYPE
(CALLING_CONVENTION *PFUNCTION_TYPE(
    PARAM_TYPE Param1,
    PARAM_TYPE Param2
);

How is the NDK Licensed?

A file called readme.txt at the root of the NDK directory describes the NDK's license. For Open-Source Projects, either the LPGL or the GPL can be used, depending on which is easiest for the project to implement. However, for closed-source projects, a special license (the "NDK License) is enforced:

    * The right to use the NDK in any commercial project without limits others then the ones below.
          o The right to make any number of derivatives of the NDK
                + However, you may not call these derivatives "NDK" anymore and must dissociate the author from them except for copyright (see below)
                      # Nevertheless, any derivative or modified version must reference the original work and author. (ie: You cannot call your derivative work 'NDK Headers 2.0, by Alex Ionescu'. They could be called, for example 'Windows Native Headers 2.0, by John Smith' and must contain a clause similar to "Based on NDK Headers 1.0, by Alex Ionescu". The same principle applies for the copyright text.
                + Additionally, it is appreciated, but not required to send any modifications back to the author. This will assure that the derivative version might re-convert into an official version.
                + It is however required that you notify the author of any publically released application which uses the NDK, and/or of any public release of the NDK that your will make. This information will not be made public at your request.
                      # You understand that by not submitting your changes, your derivative work will become 'out of sync', at which point other developers/testers will be forced to use your distribution if your application requires it. You understand that, at any time, the official NDK distribution could be manually updated to contain your changes, or might contain changes which are incompatible with yours, and that, at said point, your NDK distribution might become incompatible.
                + You must keep the same rights that this license grants, and you may not add any further limitations to it (in other words, the unchanged readme.txt file must be present along with your distribution). This implies that you may not prohibit the author from merging your changes in the official NDK, even if you do not submit them.
          o The right to re-distribute the NDK, or any derivative version of it, using any medium, technology and distribution method, including commercial.
                + However, the author retains the original copyright.
                + You must keep the same rights that this license grants, and you may not add any further limitations to it (in other words, the unchanged readme.txt file must be present along with your distribution).
          o There is no guarantee, warranty or support offerred for using the NDK. The author is not responsible for any losses or damages.
          o The author retains all copyright to the NDK.

How do I use the NDK?

    * User Mode Application requiring Native Types:

#define WIN32_NO_STATUS   /* Tell Windows headers you'll use ntstatus.s from NDK */
#include <windows.h>      /* Declare Windows Headers like you normally would */
#include <ntndk.h>        /* Declare the NDK Headers */

    * Native Mode Application:

#include <windows.h>      /* Declare Windows Headers for basic types. NEEDED UNTIL NDK 1.5 */
#include <ntndk.h>        /* Declare the NDK Headers */

    * Kernel Mode Driver:

#include <ntddk.h>       /* Declare DDK Headers like you normally would */
#include <ntndk.h>       /* Declare the NDK Headers */

You may also include only the files you need:

#define WIN32_NO_STATUS   /* Tell Windows headers you'll use ntstatus.s from NDK */
#include <windows.h>      /* Declare Windows Headers like you normally would */
#include <rtlfuncs.h>     /* Declare the Rtl* Functions */

Some caveats

    * winternl.h: This header, part of the PSDK, was released by Microsoft as part of one of the government lawsuits against it, and documents a certain (minimal) part of the Native API and/or types. Unforunately, Microsoft decided to hack the Native Types and to define them incorrectly, replacing real members by "reserved" ones. As such, you 'cannot include winternl.h in any project that uses the NDK. Note however, that the NDK fully replaces it and retains compatibility with any project that used it.
    * Native programs: Native programs must include "windows.h" until the next release of the NDK (1.5). The upcoming version will automatically detect the lack of missing types and include them. Note however that you will still need to have the PSDK installed.

[ 本帖最后由 2010roytam1 于 2011-4-14 21:54 编辑 ]
回复

使用道具 举报

227#
 楼主| 发表于 2011-4-15 08:59:39 | 只看该作者

回复 #250 2010roytam1 的帖子

你去看看ndk中的函数就知道了..ndk只是native api的头文件...
回复

使用道具 举报

228#
 楼主| 发表于 2011-4-15 09:00:45 | 只看该作者
ddk的build居然不会自动编译汇编文件...谁知道怎么配置请指导一下...
回复

使用道具 举报

229#
 楼主| 发表于 2011-4-19 09:02:10 | 只看该作者
kernel32.dll msvcrt.dll两个dll在native子系统编译成功.
cmd.exe也在native子系统编译成功..
调试出现问题...
kernel32.dll msvcrt.dll成功加载...
但是cmd.exe调用了一个设备CONOUT$
但是native子系统没有创建这个设备..
热键注册时程序直接退出了..
晚上继续测试..
就目前情况看msvcrt的printf可能是不能用了..
回复

使用道具 举报

230#
发表于 2011-4-19 09:05:53 | 只看该作者
可喜可喜,进展如此神速!!!,也要劳逸结合啊,你累坏下了native也就中风

[ 本帖最后由 jianliulin 于 2011-4-19 09:34 编辑 ]
回复

使用道具 举报

231#
发表于 2011-4-19 09:22:52 | 只看该作者

回复 #253 2011足迹 的帖子

继续等待你的成果,到时候就可以写我要写的东西了。

辛苦了……
回复

使用道具 举报

232#
 楼主| 发表于 2011-4-20 10:06:20 | 只看该作者
kenerl32.dll的初始化和cmd.exe中居然调用了csrss.exe的功能..就连console对象都是csrss.exe提供的...看来有的fix了...
回复

使用道具 举报

233#
发表于 2011-4-20 11:02:56 | 只看该作者
原帖由 Plantsoot 于 2011-4-19 09:22 发表
继续等待你的成果,到时候就可以写我要写的东西了。

辛苦了……

你要写什么? 呵呵~~
回复

使用道具 举报

234#
发表于 2011-4-23 09:00:07 | 只看该作者
足迹 有什么新的成果没有,在等待 你的成果,  改我的PE 的,   加油,    目前的进展如何, 发出来分享一下吧,
回复

使用道具 举报

235#
 楼主| 发表于 2011-4-24 10:58:50 | 只看该作者

回复 #258 wyb391 的帖子

目前是有点小成果...不过还很不成熟...甚至还不如native成熟..
现在把kernel32.dll,msvcrt.dll,cmd.exe移植到native子系统...现在编译通过了...一些命令也可以执行了...比如echo,del,if等...但是还有一些问题需要解决..
目前最主要的问题是设计console的操作..这些操作都是在kernel32.dll中实现的..kernel32.dll的win32实现是调用csr函数族..交由csrss.exe和csrss.dll处理..但是现在这个程序没有加载...估计加载了可能还是会有问题...现在必须重新去实现这些调用...数量还不少..现在正在处理中...另外...cmd.exe的一些命令还调用了其他dll的导出函数..这些需要单独实现..还有很多工作要做..如果有懂的我倒是可以发一份代码大家一起研究

kernel32.dll编译后400+K
msvcrt编译后200-K
cmd.exe编译后200+K
有点大了...有些可有可无的函数可能需要删除
回复

使用道具 举报

236#
发表于 2011-4-24 11:08:39 | 只看该作者
原帖由 2011足迹 于 2011-4-24 10:58 发表
目前是有点小成果...不过还很不成熟...甚至还不如native成熟..
现在把kernel32.dll,msvcrt.dll,cmd.exe移植到native子系统...现在编译通过了...一些命令也可以执行了...比如echo,del,if等...但是还有一些问题需 ...


还有很长的路要走啊,没有既定的目标,就象在原始森林中迷了路,离目标越走越远了。。。。。。

[ 本帖最后由 lxl1638 于 2011-4-24 11:10 编辑 ]
回复

使用道具 举报

237#
 楼主| 发表于 2011-4-24 11:37:11 | 只看该作者

回复 #261 friend8179 的帖子

现在native的架构不是很好..
另外...感觉吧kernel32移植到native有很多好处...毕竟懂native编程的还是少数..有了kernel32以后win32 api就可以使用了...移植代码页方便..说不定以后会有更多的native应用程序出现..msvcrt编译到native后就可以使用C的标准库了..对以后的开发还是很有好处的...一劳永逸的事
回复

使用道具 举报

238#
发表于 2011-4-24 11:46:52 | 只看该作者

回复 #262 2011足迹 的帖子

金山装机精灵中的系统重装似乎也是用到native
回复

使用道具 举报

239#
 楼主| 发表于 2011-4-26 09:11:16 | 只看该作者

回复 #264 friend8179 的帖子

回头在对native更新一下吧...
回复

使用道具 举报

240#
发表于 2011-4-26 19:09:33 | 只看该作者
报告一个小问题..

进入native命令行之后执行一个if命令不带任何参数就会直接蓝屏..
回复

使用道具 举报

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

本版积分规则

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

闽公网安备 35020302032614号

GMT+8, 2024-11-17 13:27

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

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