提交 9dce7154 创建 作者: 赵鹏翀's avatar 赵鹏翀

Initial commit

上级
/*.img
/bochs
/Debug
/Release
*.bak
*.lst
*.o
\ No newline at end of file
#include "EOSApp.h"
//
// main 函数参数的意义:
// argc - argv 数组的长度,大小至少为 1,argc - 1 为命令行参数的数量。
// argv - 字符串指针数组,数组长度为命令行参数个数 + 1。其中 argv[0] 固定指向当前
// 进程所执行的可执行文件的路径字符串,argv[1] 及其后面的指针指向各个命令行
// 参数。
// 例如通过命令行内容 "a:\hello.exe -a -b" 启动进程后,hello.exe 的 main 函
// 数的参数 argc 的值为 3,argv[0] 指向字符串 "a:\hello.exe",argv[1] 指向
// 参数字符串 "-a",argv[2] 指向参数字符串 "-b"。
//
int main(int argc, char* argv[])
{
//
// 如果需要在调试应用程序时能够调试进入内核并显示对应的源码,
// 必须使用 EOS 内核项目编译生成完全版本的 SDK 文件夹,然
// 后使用刚刚生成的 SDK 文件夹覆盖此应用程序项目中的 SDK 文件
// 夹,并且 EOS 内核项目在磁盘上的位置不能改变。
//
/* TODO: 在此处添加自己的代码 */
printf("Hello world!\n");
return 0;
}
#ifndef _EOSAPP_
#define _EOSAPP_
// 包含 EOS 操作系统相关头文件
#include <eos.h>
// 包含 C 运行时库相关头文件
#include <stdio.h>
#endif // _EOSAPP_
EOS 核心源代码协议
允许所有人复制和发布本协议文件的完整版本,但不允许对它进行任何修改。
该协议用于控制与之配套的软件,并且管理您使用遵守该协议软件的方法。下面授予
您的各项权利受限于该协议。只有当您是合格的教育机构并且从北京英真时代科技有限
公司购买了该软件授权时才能够享有这些权利。
在您的教育机构中,您可以为了任何非商业的目的来使用、修改该软件,包括制作合理
数量的拷贝。非商业的目的可以是教学、科研以及个人的实验行为。您可以将拷贝发布
到机构内部安全的服务器上,并且可以在合格用户的个人主机上安装。
您可以在研究论文、书籍或者其他教育资料中使用该软件的代码片断,或者在以教学和
研究为目的的网站、在线公共论坛中发布该软件的代码片断。在您使用的单个代码片断
中源代码的数量不能超过 50 行。如您想使用该软件中的大量源代码,
请联系 support@tevation.com。
您不能为了商业目的使用或者分发该软件以及从该软件衍生出的任何形式的任何产品。
商业目的可以是经营、许可、出售该软件或者为了在商业产品中使用该软件而分发该软件。
如果您希望将您的与该软件有关的产品商业化,或者希望与工业伙伴合作研究,您需要
联系 sales@tevation.com 来咨询商业授权协议。
您可以为了非商业的目的分发该软件并且修改该软件,但是只能是对于其他该软件的合法
用户(例如,将修改的版本分发给其他大学的学生或者教授进行联合学术研究)。只有从
北京英真时代科技有限公司购买了该软件授权的合格教育机构,才是合法用户。您不能为
该软件或者该软件的衍生产品授予比该协议所提供的更加广泛的权利。
您还必须遵守下面的条款:
1. 您不会从该软件中移除任何版权信息或者布告,也不会对该软件中的二进制部分进行
逆向工程或者反编译。
2. 无论您以任何形式分发该软件,您都必须同时分发该协议。
3. 如果您修改了该软件或者创造了该软件的衍生产品,并且分发了修改后的版本或者衍生
产品,您需要在被修改文件中的显著位置添加布告来说明您修改的内容和修改日期,这样
接收者就会知道他们收到的不是原始的软件。
4. 该软件没有任何担保,包括明示的、暗喻的。在适用法律所允许的最大范围
内,北京英真时代科技有限公司或其供应商绝不就因使用或不能使用本“软件”所引起的或
有关的任何间接的、意外的、直接的、非直接的、特殊的、惩罚性的或其它任何损害赔偿
(包括但不限于因人身伤害或财产损坏而造成的损害赔偿,因利润损失、营业中断、商业
信息的遗失而造成的损害赔偿,因未能履行包括诚信或相当注意在内的任何责任致使隐私
泄露而造成的损害赔偿,因疏忽而造成的损害赔偿,或因任何金钱上的损失或任何其它损失
而造成的损害赔偿)承担赔偿责任,即使北京英真时代科技有限公司或其任何供应商事先被
告知该损害发生的可能性。即使补救措施未能达到预定目的,本损害赔偿排除条款将仍然有
效。
5. 您不能使用该软件来帮助开发任何为下列目的而设计的软件程序: (a) 对计算机系统有害
的或者故意干扰操作的,包括计算机系统中的任何数据和信息;(b) 秘密获取或者维持对计算
机系统高级访问权限,有自我繁殖能力,能够在不被发现的情况下执行,包括但不限于所谓
的 "rootkit" 软件程序,病毒或者蠕虫。
6. 如果您以任何方式违背了此协议,此协议赋予您的权利就会立即终止。
7. 北京英真时代科技有限公司保留在此协议中明确授予您的权利之外的所有权利。
版本: 2008.09.16
(C) 2008 北京英真时代科技有限公司(http://www.engintime.com)。保留所有权利。
/***
Copyright (c) 2008 北京英真时代科技有限公司。保留所有权利。
只有您接受 EOS 核心源代码协议(参见 License.txt)中的条款才能使用这些代码。
如果您不接受,不能使用这些代码。
文件名: stdarg.h
描述: C 运行时库 stdarg 模块的头文件。
*******************************************************************************/
#ifndef _STDARG_
#define _STDARG_
typedef char* va_list;
#define _INTSIZEOF(n) ((sizeof(n) + sizeof(int) - 1) & ~(sizeof(int) - 1))
#define va_arg(ap,t) (*(t *)((ap += _INTSIZEOF(t)) - _INTSIZEOF(t)))
#define va_start(ap,v) (ap = (va_list)&v + _INTSIZEOF(v))
#define va_end(ap) ( ap = (va_list)0 )
#endif // _STDARG_
/***
Copyright (c) 2008 北京英真时代科技有限公司。保留所有权利。
只有您接受 EOS 核心源代码协议(参见 License.txt)中的条款才能使用这些代码。
如果您不接受,不能使用这些代码。
文件名: stdio.h
描述: C 运行时库 stdio 模块的头文件。
*******************************************************************************/
#ifndef _STDIO_
#define _STDIO_
#include "stdarg.h"
#ifdef __cplusplus
extern "C"
{
#endif
#define EOF (-1);
int getchar();
char *gets(char *buffer);
int putchar(int c);
int printf(const char *format, ...);
int sprintf(char *buffer, const char *format, ...);
int vsprintf(char *buffer, const char *format, va_list argptr);
#ifdef __cplusplus
}
#endif
#endif // _STDIO_
/***
Copyright (c) 2008 北京英真时代科技有限公司。保留所有权利。
只有您接受 EOS 核心源代码协议(参见 License.txt)中的条款才能使用这些代码。
如果您不接受,不能使用这些代码。
文件名: stdlib.h
描述: C 运行时库 stdlib 模块的头文件。
*******************************************************************************/
#ifndef _STDLIB_
#define _STDLIB_
char* itoa(int value, char *str, int radix);
#endif // _STDLIB_
/***
Copyright (c) 2008 北京英真时代科技有限公司。保留所有权利。
只有您接受 EOS 核心源代码协议(参见 License.txt)中的条款才能使用这些代码。
如果您不接受,不能使用这些代码。
文件名: string.h
描述: C 运行时库 sting 模块的头文件。
*******************************************************************************/
#ifndef _STRING_
#define _STRING_
#ifndef __cplusplus
typedef unsigned long size_t;
#endif
int stricmp( const char *, const char *);
int strcmp( const char *, const char *);
int strncmp( const char *, const char *s, size_t);
int strnicmp( const char *, const char *s, size_t);
char* strcpy( char *, const char *);
char* strncpy( char *, const char *, size_t);
size_t strlen( const char *);
char* strcat( char *, const char *);
char* strncat( char *, const char *, size_t);
int memcmp(const void *, const void *, size_t);
void *memcpy(void *, const void *, size_t);
void *memccpy (void *, const void *, int, size_t);
void *memset(void *, int, size_t);
void *memmove (void *, const void *, size_t);
#endif // _STRING_
;***
;
; Copyright (c) 2008 北京英真时代科技有限公司。保留所有权利。
;
; 只有您接受 EOS 核心源代码协议(参见 License.txt)中的条款才能使用这些代码。
; 如果您不接受,不能使用这些代码。
;
; 文件名: __alloca.asm
;
; 描述: __alloca
;
;
;
;*******************************************************************************/
global __alloca
[section .text]
__alloca:
;{
sub eax, 1
and eax, ~3
sub esp, eax
push dword [esp + eax]
mov eax, esp
add eax, 4
ret
;}
/***
Copyright (c) 2008 北京英真时代科技有限公司。保留所有权利。
只有您接受 EOS 核心源代码协议(参见 License.txt)中的条款才能使用这些代码。
如果您不接受,不能使用这些代码。
文件名: __main.c
描述: 全局变量构造函数的调用者。
*******************************************************************************/
typedef void (*func_ptr) (void);
extern func_ptr __CTOR_LIST__[];
void __main(void)
{
unsigned long i;
i = (unsigned long) __CTOR_LIST__[0];
//
// 如果第0个元素没有指出数组的长度则统计数组的长度。
//
if (i == -1) {
for (i = 0; __CTOR_LIST__[i + 1]; i++);
}
//
// 逆序调用全局对象的构造函数。
//
while (i > 0) {
__CTOR_LIST__[i--] ();
}
}
/***
Copyright (c) 2008 北京英真时代科技有限公司。保留所有权利。
只有您接受 EOS 核心源代码协议(参见 License.txt)中的条款才能使用这些代码。
如果您不接受,不能使用这些代码。
文件名: crt0.c
描述: CRT 运行库的 CRT0 模块,负责应用程序的启动初始化。
*******************************************************************************/
#include <eos.h>
typedef void (*func_ptr) (void);
extern func_ptr __DTOR_LIST__[];
static void __do_global_dtors (void)
{
func_ptr *p;
//
// 依次调用全局对象的析构函数。
//
for (p = __DTOR_LIST__ + 1; *p; p++) {
(*(p)) ();
}
}
extern int main(int argc, char* argv[]);
void _start (void)
{
int retv;
int argc;
char *ptr;
static char ImageName[MAX_PATH];
static char CmdLine[1024];
static char* argv[512];
//
// 得到命令行参数并分割为多个字符串,传递给main函数。
//
GetImageNameAndCmdLine(ImageName, CmdLine);
argc = 1;
argv[0] = ImageName;
for (ptr = CmdLine; *ptr != 0; ) {
//
// 过滤空格。
//
while (*ptr != 0 && *ptr == ' ') {
ptr++;
}
if (*ptr == 0) {
break;
}
argv[argc++] = ptr;
while (*ptr != 0 && *ptr != ' '){
ptr++;
}
//
// 隔断字符串。
//
if (' ' == *ptr) {
*ptr++ = 0;
}
}
//
// 调用main函数。
//
retv = main(argc, argv);
//
// 调用全局对象析构函数。
//
__do_global_dtors();
//
// 退出进程。
//
ExitProcess(retv);
}
/***
Copyright (c) 2008 北京英真时代科技有限公司。保留所有权利。
只有您接受 EOS 核心源代码协议(参见 License.txt)中的条款才能使用这些代码。
如果您不接受,不能使用这些代码。
文件名: stdio.c
描述: C 运行时库的标准输入输出模块。
*******************************************************************************/
#include "stdio.h"
#include "stdarg.h"
#include <eos.h>
static int vsprintn(char *buffer, int value, char radix)
{
register char *p1;
register char *p2;
char c = 0;
int len = 0;
switch(radix) {
case 'o':
radix = 8;
break;
case 'u':
radix = 10;
break;
case 'i':
case 'd':
radix = 10;
if(value < 0) {
value = -value;
c = '-';
}
break;
case 'x':
radix = 16;
c = 'a' - '9' - 1;
break;
case 'X':
radix = 16;
c = 'A' - '9' - 1;
break;
default:
return 0;
}
p1 = buffer;
if(0 == value) {
*p1++ = '0';
} else {
while(value) {
if((*p1 = '0' + (unsigned int)value % radix) > '9') {
*p1 += c;
}
value = (unsigned int)value / radix;
p1++;
}
if('-' == c) {
*p1++ = c;
}
}
*p1 = '\0';
len = p1 - buffer;
//
// reverse
//
p2 = buffer;
while(--p1 > p2) {
c = *p1;
*p1 = *p2;
*p2 = c;
p2++;
}
return len;
}
int __cdecl vsprintf(char *buffer, const char *format, va_list argptr)
{
char *pos;
char *str;
for(pos = buffer; *format; format++) {
if (*format != '%') {
*pos++ = *format;
} else {
format++; // 跳过‘%’
if('s' == *format) {
str = va_arg(argptr, char*);
while(0 != *str) {
*pos++ = *str++;
}
} else if('c' == *format) {
*pos++ = va_arg(argptr, int);
} else {
pos += vsprintn(pos, va_arg(argptr, int), *format);
}
}
}
*pos = '\0'; // 结束字符串
va_end(argptr);
return pos - buffer;
}
int __cdecl sprintf(char *buffer, const char *format, ...)
{
va_list argptr;
va_start(argptr, format);
return vsprintf(buffer, format, argptr);
}
int __cdecl putchar(int c)
{
ULONG n;
if ('\n' == c) {
c = '\r';
if (!WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), &c, 1, &n) || n != 1) {
return EOF;
}
c = '\n';
}
if (!WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), &c, 1, &n) || n != 1) {
return EOF;
}
return c;
}
int __cdecl printf(const char *format, ...)
{
va_list argptr;
char buffer[33];
const char* ptr; // 写指针
ULONG n; // 写字节数
ULONG r; // 实际写字节数
ULONG count = 0;
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
va_start(argptr, format);
while (*format) {
if (*format != '%') {
if ('\n' == *format) {
// 将C中的换行符\n替换为EOS中的换行符\r\n
buffer[0] = '\r';
buffer[1] = '\n';
ptr = buffer;
n = 2;
} else {
ptr = format;
n = 1;
}
} else {
format++; // 跳过‘%’
if('s' == *format) {
ptr = va_arg(argptr, char*);
n = strlen(ptr);
} else if('c' == *format) {
buffer[0] = va_arg(argptr, int);
ptr = buffer;
n = 1;
} else {
ptr = buffer;
n = vsprintn(buffer, va_arg(argptr, int), *format);
}
}
if (!WriteFile(handle, (PVOID)ptr, n, &r) || n != r) {
break;
}
format++;
count += r;
}
va_end(argptr);
return count;
}
int __cdecl getchar()
{
char c;
ULONG n;
if (!ReadFile(GetStdHandle(STD_INPUT_HANDLE), &c, 1, &n) || 0 == n) {
return EOF;
}
return c;
}
char* __cdecl gets(char *buffer)
{
char *ptr;
ULONG n;
HANDLE handle = GetStdHandle(STD_INPUT_HANDLE);
for (ptr = buffer; ; ptr++) {
//
// 读取一个字符,如果读取错误或这文件结束则中止读取。
//
if (!ReadFile(handle, ptr, 1, &n) || 0 == n) {
*ptr = '\0';
return ptr == buffer ? NULL : buffer; // 如果一个字符也没有读则返回NULL。
}
//
// 如果遇到换行符\n或组合\r\n则中止读取,将\n或组合\r\n替换为\0。
//
if ('\n' == *ptr) {
if (ptr > buffer && '\r' == *(ptr - 1)) {
ptr--;
}
*ptr = '\0';
return buffer;
}
}
}
/***
Copyright (c) 2008 北京英真时代科技有限公司。保留所有权利。
只有您接受 EOS 核心源代码协议(参见 License.txt)中的条款才能使用这些代码。
如果您不接受,不能使用这些代码。
文件名: stdlib.c
描述: C 运行时库的 stdlib 模块。
*******************************************************************************/
#include "stdlib.h"
char* itoa(int value, char *str, int radix)
{
register char *p1;
register char *p2;
char c = 0;
//
// 如果基数超出范围 [2,36],则设置字符串为空串并返回。
//
if(radix < 2 || 36 < radix ) {
*str = 0;
return str;
}
p1 = str;
if(0 == value) {
*p1++ = '0';
} else {
//
// 如果以10为基负数,则暂存其符号并取其绝对值。
//
if(10 == radix && value < 0) {
c = '-';
value = -value;
}
while(value) {
if((*p1 = '0' + (unsigned int)value % radix) > '9')
*p1 += 'A' - '9' - 1;
value = (unsigned int)value / radix;
p1++;
}
if('-' == c) {
*p1++ = c;
}
}
*p1 = '\0'; // 结束字符串
//
// reverse
//
p2 = str;
while(--p1 > p2) {
c = *p1;
*p1 = *p2;
*p2 = c;
p2++;
}
return str;
}
/***
Copyright (c) 2008 北京英真时代科技有限公司。保留所有权利。
只有您接受 EOS 核心源代码协议(参见 License.txt)中的条款才能使用这些代码。
如果您不接受,不能使用这些代码。
文件名: string.c
描述: C 运行时库的 string 模块。
*******************************************************************************/
#include "string.h"
#define UPPER( c ) ( ( (c) >= 'a' && (c) <= 'z' ) ? ((c) - 'a' + 'A') : (c) )
#define LOWER( c ) ( ( (c) >= 'A' && (c) <= 'Z' ) ? ((c) - 'A' + 'a') : (c) )
int stricmp( const char *string1, const char *string2 )
{
register const char *p1 = string1;
register const char *p2 = string2;
while(UPPER(*p1) == UPPER(*p2) && 0 != *p1) {
p1++;
p2++;
}
return UPPER(*p1) - UPPER(*p2);
}
int strcmp(const char * string1, const char * string2)
{
register const char *p1 = string1;
register const char *p2 = string2;
while(*p1 == *p2 && 0 != *p1) {
p1++;
p2++;
}
return *p1 - *p2;
}
int strnicmp( const char *string1, const char *string2, size_t count)
{
register size_t i;
register const char *p1 = string1;
register const char *p2 = string2;
for (i = count; i > 0; i--) {
if (UPPER(*p1) != UPPER(*p2) || 0 == *p1) {
return UPPER(*p1) - UPPER(*p2);
}
p1++;
p2++;
}
return 0;
}
int strncmp( const char *string1, const char *string2, size_t count)
{
register size_t i;
register const char *p1 = string1;
register const char *p2 = string2;
for (i = count; i > 0; i--) {
if (*p1 != *p2 || 0 == *p1) {
return *p1 - *p2;
}
p1++;
p2++;
}
return 0;
}
char* strcpy( char *dst, const char *src )
{
register char *p1 = dst;
register const char *p2 = src;
while(0 != *p2) {
*p1++ = *p2++;
}
*p1 = 0;
return dst;
}
char* strncpy( char *dst, const char *src, size_t count )
{
register size_t i;
register char *p1 = dst;
register const char *p2 = src;
for (i = count; i > 0 && *p2 != 0; i--) {
*p1++ = *p2++;
}
*p1 = 0;
return dst;
}
size_t strlen( const char *string )
{
register const char *p = string;
while(0 != *p) {
p++;
}
return p - string;
}
char *strcat( char *dst, const char *src )
{
register char *p1 = dst;
register const char *p2 = src;
while(0 != *p1) {
p1++;
}
while(0 != *p2) {
*p1++ = *p2++;
}
*p1 = 0;
return dst;
}
char *strncat( char *dst, const char *src, size_t count )
{
register size_t i;
register char *p1 = dst;
register const char *p2 = src;
while(0 != *p1) {
p1++;
}
for (i = count; i > 0 && *p2 != 0; i--) {
*p1++ = *p2++;
}
*p1 = 0;
return dst;
}
int memcmp(const void *buf1, const void *buf2, size_t count)
{
if(!count) {
return 0;
}
while (--count && *(char *)buf1 == *(char *)buf2) {
buf1 = (char *)buf1 + 1;
buf2 = (char *)buf2 + 1;
}
return *((unsigned char *)buf1) - *((unsigned char *)buf2);
}
void * memccpy (void * dst, const void * src, int c, size_t count)
{
while ( count && (*((char *)(dst = (char *)dst + 1) - 1) =
*((char *)(src = (char *)src + 1) - 1)) != (char)c )
count--;
return count ? dst : (void*)0;
}
void* memcpy (void * dst, const void * src, size_t count)
{
void * ret = dst;
while (count--) {
*(char *)dst = *(char *)src;
dst = (char *)dst + 1;
src = (char *)src + 1;
}
return ret;
}
void * memmove (void * dst, const void * src, size_t count)
{
void * ret = dst;
if (dst <= src || (char *)dst >= ((char *)src + count)) {
while (count--) {
*(char *)dst = *(char *)src;
dst = (char *)dst + 1;
src = (char *)src + 1;
}
} else {
dst = (char *)dst + count - 1;
src = (char *)src + count - 1;
while (count--) {
*(char *)dst = *(char *)src;
dst = (char *)dst - 1;
src = (char *)src - 1;
}
}
return ret;
}
void * memset (void *dst, int val, size_t count)
{
void *start = dst;
while (count--) {
*(char *)dst = (char)val;
dst = (char *)dst + 1;
}
return start;
}
<?xml version="1.0" encoding="gb2312"?>
<OSLProject Version="1.00" Name="EOSApp" ProjectType="eosapp" SubjectID="1580a23c-aa04-4cf3-8cca-488dc577df8d" TemplatePath="eosapp\Project" IncrementalUpload="-1" ProjectID="9e09e151-1adc-4c75-b394-56ecdcd78977" IsSubmitWork="0">
<Configurations>
<Configuration Name="Debug" DebuggerFlavor="1" RemoteMachine="5" AdditionalSymbolFileLocation="sdk\bin\debug\kernel.dll;0x80011000" PreDebugCommand="echo 制作软盘镜像...&#xA;echo A:\$(TargetFileName) &gt; &quot;$(OutDir)\autorun.txt&quot;&#xA;echo 将引导扇区程序 boot.bin 写入软盘镜像...&#xA;FloppyImageEditor.exe Floppy.img /mbr &quot;sdk\bin\debug\boot.bin&quot;&#xA;echo 将加载程序 loader.bin 写入软盘镜像...&#xA;FloppyImageEditor.exe Floppy.img /copy &quot;sdk\bin\debug\loader.bin&quot; /y&#xA;echo 将 EOS 内核程序 kernel.dll 写入软盘镜像...&#xA;FloppyImageEditor.exe Floppy.img /copy &quot;sdk\bin\debug\kernel.dll&quot; /y&#xA;echo 将 EOS 应用程序 $(TargetFileName) 写入软盘镜像...&#xA;FloppyImageEditor.exe Floppy.img /copy &quot;$(TargetPath)&quot; /y&#xA;echo 将自动运行脚本 autorun.txt 写入软盘镜像...&#xA;FloppyImageEditor.exe Floppy.img /copy &quot;$(OutDir)\autorun.txt&quot; /y&#xA;">
<Tool Name="PreBuildEventTool"/>
<Tool Name="CustomBuildTool"/>
<Tool Name="GCCCompilerTool" AdditionalIncludeDirectories="sdk\inc;crt\inc" PreprocessorDefinitions="_DEBUG" GenerateDebugInformation="-1" CompileAs="1"/>
<Tool Name="NASMAssemblerTool"/>
<Tool Name="PreLinkEventTool"/>
<Tool Name="GCCLinkerTool" AdditionalLibraries="kernel" AdditionalLibraryDirectories="sdk\bin\debug" IgnoreStandardLibraries="-1" EntryPointSymbol="__start" BaseAddress="0x400000"/>
<Tool Name="PostBuildEventTool" CommandLine="sign &quot;$(TargetPath)&quot;" Description="正在对 EOS 应用程序签名..."/>
</Configuration>
<Configuration Name="Release" DebuggerFlavor="1" RemoteMachine="5" PreDebugCommand="echo 制作软盘镜像...&#xA;echo A:\$(TargetFileName) &gt; &quot;$(OutDir)\autorun.txt&quot;&#xA;echo 将引导扇区程序 boot.bin 写入软盘镜像...&#xA;FloppyImageEditor.exe Floppy.img /mbr &quot;sdk\bin\release\boot.bin&quot;&#xA;echo 将加载程序 loader.bin 写入软盘镜像...&#xA;FloppyImageEditor.exe Floppy.img /copy &quot;sdk\bin\release\loader.bin&quot; /y&#xA;echo 将 EOS 内核程序 kernel.dll 写入软盘镜像...&#xA;FloppyImageEditor.exe Floppy.img /copy &quot;sdk\bin\release\kernel.dll&quot; /y&#xA;echo 将 EOS 应用程序 $(TargetFileName) 写入软盘镜像...&#xA;FloppyImageEditor.exe Floppy.img /copy &quot;$(TargetPath)&quot; /y&#xA;echo 将自动运行脚本 autorun.txt 写入软盘镜像...&#xA;FloppyImageEditor.exe Floppy.img /copy &quot;$(OutDir)\autorun.txt&quot; /y&#xA;">
<Tool Name="PreBuildEventTool"/>
<Tool Name="CustomBuildTool"/>
<Tool Name="GCCCompilerTool" AdditionalIncludeDirectories="sdk\inc;crt\inc" CompileAs="1"/>
<Tool Name="NASMAssemblerTool"/>
<Tool Name="PreLinkEventTool"/>
<Tool Name="GCCLinkerTool" AdditionalLibraries="kernel" AdditionalLibraryDirectories="sdk\bin\release" IgnoreStandardLibraries="-1" EntryPointSymbol="__start" BaseAddress="0x400000"/>
<Tool Name="PostBuildEventTool" CommandLine="sign &quot;$(TargetPath)&quot;" Description="正在对 EOS 应用程序签名..."/>
</Configuration>
</Configurations>
<Files>
<Filter Name="bochs">
<File RelativePath=".\bochs\BIOS-bochs-latest" NoUpload="-1">
</File>
<File RelativePath=".\bochs\bochs.exe" NoUpload="-1">
</File>
<File RelativePath=".\bochs\bochsdbg.exe" NoUpload="-1">
</File>
<File RelativePath=".\bochs\bochsrc.bxrc" NoUpload="-1">
</File>
<File RelativePath=".\bochs\bochsrcdbg.bxrc" NoUpload="-1">
</File>
<File RelativePath=".\bochs\Hard Disk.vhd" NoUpload="-1">
</File>
<File RelativePath=".\bochs\VGABIOS-lgpl-latest" NoUpload="-1">
</File>
</Filter>
<Filter Name="crt">
<Filter Name="inc">
<File RelativePath=".\crt\inc\stdarg.h">
</File>
<File RelativePath=".\crt\inc\stdio.h">
</File>
<File RelativePath=".\crt\inc\stdlib.h">
</File>
<File RelativePath=".\crt\inc\string.h">
</File>
</Filter>
<Filter Name="src">
<File RelativePath=".\crt\src\__alloca.asm">
</File>
<File RelativePath=".\crt\src\__main.c">
</File>
<File RelativePath=".\crt\src\crt0.c">
</File>
<File RelativePath=".\crt\src\stdio.c">
</File>
<File RelativePath=".\crt\src\stdlib.c">
</File>
<File RelativePath=".\crt\src\string.c">
</File>
</Filter>
<File RelativePath=".\crt\License.txt">
</File>
</Filter>
<Filter Name="sdk">
<Filter Name="bin">
<Filter Name="debug">
<File RelativePath=".\sdk\bin\debug\boot.bin">
</File>
<File RelativePath=".\sdk\bin\debug\kernel.dll">
</File>
<File RelativePath=".\sdk\bin\debug\libkernel.a">
</File>
<File RelativePath=".\sdk\bin\debug\loader.bin">
</File>
</Filter>
<Filter Name="release">
<File RelativePath=".\sdk\bin\release\boot.bin">
</File>
<File RelativePath=".\sdk\bin\release\kernel.dll">
</File>
<File RelativePath=".\sdk\bin\release\libkernel.a">
</File>
<File RelativePath=".\sdk\bin\release\loader.bin">
</File>
</Filter>
</Filter>
<Filter Name="inc">
<File RelativePath=".\sdk\inc\eos.h">
</File>
<File RelativePath=".\sdk\inc\eosdef.h">
</File>
<File RelativePath=".\sdk\inc\error.h">
</File>
</Filter>
</Filter>
<Filter Name="头文件">
<File RelativePath=".\EOSApp.h">
</File>
</Filter>
<Filter Name="源文件" Filter="cpp;c;cc;cxx">
<File RelativePath=".\EOSApp.c">
</File>
</Filter>
<File RelativePath=".\Floppy.img">
</File>
</Files>
</OSLProject>
添加文件
/***
Copyright (c) 2008 北京英真时代科技有限公司。保留所有权利。
只有您接受 EOS 核心源代码协议(参见 License.txt)中的条款才能使用这些代码。
如果您不接受,不能使用这些代码。
文件名: eos.h
描述: EOS 内核导出头文件,EOS 应用程序需包含此头文件。
*******************************************************************************/
#ifndef _EOS_
#define _EOS_
#ifdef __cplusplus
extern "C"
{
#endif
#include "eosdef.h"
#include "error.h"
EOSAPI
VOID
DebugBreak(
VOID
);
EOSAPI
BOOL
CloseHandle(
IN HANDLE Handle
);
EOSAPI
PVOID
VirtualAlloc(
IN PVOID Address,
IN SIZE_T Size,
IN ULONG AllocationType
);
EOSAPI
BOOL
VirtualFree(
IN PVOID Address,
IN SIZE_T Size,
IN ULONG FreeType
);
EOSAPI
BOOL
CreateProcess(
IN PCSTR ImageName,
IN PCSTR CmdLine,
IN ULONG CreateFlags,
IN PSTARTUPINFO StartupInfo,
OUT PPROCESS_INFORMATION ProcInfo
);
EOSAPI
HANDLE
CreateThread(
IN SIZE_T StackSize,
IN PTHREAD_START_ROUTINE StartAddr,
IN PVOID ThreadParam,
IN ULONG CreateFlags,
OUT PULONG ThreadId OPTIONAL
);
EOSAPI
HANDLE
OpenProcess(
IN ULONG ProcessId
);
EOSAPI
HANDLE
OpenThread(
IN ULONG ThreadId
);
EOSAPI
BOOL
TerminateProcess(
IN HANDLE Handle,
IN ULONG ExitCode
);
EOSAPI
BOOL
TerminateThread(
IN HANDLE Handle,
IN ULONG ExitCode
);
EOSAPI
VOID
ExitProcess(
IN ULONG ExitCode
);
EOSAPI
VOID
ExitThread(
IN ULONG ExitCode
);
EOSAPI
VOID
Sleep(
IN ULONG Milliseconds
);
EOSAPI
ULONG
GetLastError(
VOID
);
EOSAPI
VOID
SetLastError(
IN ULONG ErrCode
);
EOSAPI
HANDLE
GetStdHandle(
IN ULONG StdHandle
);
EOSAPI
VOID
GetImageNameAndCmdLine(
OUT PCHAR ImageNameBuffer,
OUT PCHAR CmdLineBuffer
);
EOSAPI
BOOL
GetExitCodeProcess(
IN HANDLE ProcessHandle,
OUT PULONG ExitCode
);
EOSAPI
BOOL
GetExitCodeThread(
IN HANDLE ThreadHandle,
OUT PULONG ExitCode
);
EOSAPI
HANDLE
CreateEvent(
IN BOOL ManualReset,
IN BOOL InitialState,
IN PCSTR Name
);
EOSAPI
BOOL
SetEvent(
IN HANDLE Handle
);
EOSAPI
BOOL
ResetEvent(
IN HANDLE Handle
);
EOSAPI
HANDLE
CreateMutex(
IN BOOL InitialOwner,
IN PCSTR Name
);
EOSAPI
BOOL
ReleaseMutex(
IN HANDLE Handle
);
EOSAPI
HANDLE
CreateSemaphore(
IN LONG InitialCount,
IN LONG MaximumCount,
IN PSTR Name
);
EOSAPI
BOOL
ReleaseSemaphore(
IN HANDLE Handle,
IN LONG ReleaseCount,
IN PLONG PreviousCount
);
EOSAPI
ULONG
WaitForSingleObject(
IN HANDLE Handle,
IN ULONG Milliseconds
);
EOSAPI
HANDLE
CreateFile(
IN PCSTR FileName,
IN ULONG DesiredAccess,
IN ULONG ShareMode,
IN ULONG CreationDisposition,
IN ULONG FlagsAndAttributes
);
EOSAPI
BOOL
ReadFile(
IN HANDLE Handle,
OUT PVOID Buffer,
IN ULONG NumberOfBytesToRead,
OUT PULONG NumberOfBytesRead
);
EOSAPI
BOOL
WriteFile(
IN HANDLE Handle,
IN PVOID Buffer,
IN ULONG NumberOfBytesToWrite,
OUT PULONG NumberOfBytesWritten
);
EOSAPI
BOOL
DeleteFile(
IN PCSTR FileName
);
EOSAPI
BOOL
GetFileTime(
IN HANDLE FileHandle,
OUT PFILETIME CreationTime,
OUT PFILETIME LastAccessTime,
OUT PFILETIME LastWriteTime
);
EOSAPI
ULONG
GetFileSize(
IN HANDLE FileHandle
);
EOSAPI
ULONG
SetFilePointer(
IN HANDLE FileHandle,
IN LONG DistanceToMove,
IN ULONG MoveMethod
);
EOSAPI
ULONG
GetFileAttributes(
IN PCSTR FileName
);
EOSAPI
BOOL
SetFileAttributes(
IN PCSTR FileName,
IN ULONG FileAttributes
);
EOSAPI
BOOL
CreateDirectory(
IN PCSTR PathName
);
EOSAPI
BOOL
RemoveDirectory(
IN PCSTR PathName
);
EOSAPI
BOOL
SetConsoleCursorPosition(
IN HANDLE Handle,
IN COORD CursorPosition
);
EOSAPI
ULONG
GetCurrentThreadId(
VOID
);
EOSAPI
BOOL
SuspendThread(
IN HANDLE hThread
);
EOSAPI
BOOL
ResumeThread(
IN HANDLE hThread
);
#ifdef __cplusplus
}
#endif
#endif // _EOS_
/***
Copyright (c) 2008 北京英真时代科技有限公司。保留所有权利。
只有您接受 EOS 核心源代码协议(参见 License.txt)中的条款才能使用这些代码。
如果您不接受,不能使用这些代码。
文件名: eosdef.h
描述: EOS 数据类型、结构体、常量以及宏定义。
*******************************************************************************/
#ifndef _EOSDEF_
#define _EOSDEF_
#ifndef EOS32
#define EOS32
#endif /* EOS32 */
#ifdef __cplusplus
extern "C" {
#endif
#ifndef EOSVER
#define EOSVER 0x0500
#endif /* EOSVER */
#ifdef __cplusplus
#define NULL 0
#else
#define NULL ((void *)0)
#endif
#ifdef _KERNEL_
#define EOSAPI __declspec(dllexport)
#else
#define EOSAPI __declspec(dllimport)
#endif
#define FALSE 0
#define TRUE 1
#define VOID void
#define INFINITE 0xFFFFFFFF
#define IN
#define OUT
#define OPTIONAL
#define CONST const
#define PRIVATE static
#define PUBLIC
typedef char CHAR, *PCHAR, *PSTR;
typedef const char *PCSTR;
typedef unsigned char UCHAR, *PUCHAR;
typedef unsigned char BYTE;
typedef short SHORT, *PSHORT;
typedef unsigned short USHORT, *PUSHORT;
typedef int INT, *PINT;
typedef unsigned int UINT, *PUINT;
typedef long LONG, *PLONG;
typedef unsigned long ULONG, *PULONG;
typedef long long LONGLONG, *PLONGLONG;
typedef unsigned long long ULONGLONG, *PULONGLONG;
typedef int BOOL, *PBOOL;
typedef char BOOLEAN, *PBOOLEAN;
typedef float FLOAT, *PFLOAT;
typedef double DOUBLE, *PDOUBLE;
typedef void *PVOID;
typedef void *HANDLE;
typedef HANDLE *PHANDLE;
typedef union _LARGE_INTEGER {
struct {
ULONG LowPart;
LONG HighPart;
} u;
LONGLONG QuadPart;
} LARGE_INTEGER, *PLARGE_INTEGER;
//
// Signed long type for pointer precision. Use when casting a pointer to a long to
// perform pointer arithmetic.
//
typedef long LONG_PTR, *PLONG_PTR;
//
// Unsigned LONG_PTR.
//
typedef unsigned long ULONG_PTR, *PULONG_PTR;
//
// The maximum number of bytes to which a pointer can point. Use for a count that must
// span the full range of a pointer.
//
typedef ULONG_PTR SIZE_T, *PSIZE_T;
//
// Signed SIZE_T.
//
typedef LONG_PTR SSIZE_T, *PSSIZE_T;
//
// 32位的状态码类型。
//
typedef long STATUS, *PSTATUS;
//
// Values are 32 bit values laid out as follows:
//
// 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
// +---+---------------------------+-------------------------------+
// |Sev| Reserved | Code |
// +---+---------------------------+-------------------------------+
//
// where
//
// Sev - is the severity code
//
// 00 - Success
// 01 - Informational
// 10 - Warning
// 11 - Error
//
// Reserved - are reserved bits
//
// Code - is the facility's status code
//
//
// Generic test for success on any status value (non-negative numbers
// indicate success).
//
#define EOS_SUCCESS(Status) ((STATUS)(Status) >= 0)
//
// Generic test for information on any status value.
//
#define EOS_INFORMATION(Status) ((ULONG)(Status) >> 30 == 1)
//
// Generic test for warning on any status value.
//
#define EOS_WARNING(Status) ((ULONG)(Status) >> 30 == 2)
//
// Generic test for error on any status value.
//
#define EOS_ERROR(Status) ((ULONG)(Status) >> 30 == 3)
//
// 各种类型的最大、最小值。
//
#define MINCHAR 0x80
#define MAXCHAR 0x7f
#define MAXUCHAR 0xff
#define MINSHORT 0x8000
#define MAXSHORT 0x7fff
#define MAXUSHORT 0Xffff
#define MINLONG 0x80000000
#define MAXLONG 0x7fffffff
#define MAXULONG 0xffffffff
#define MINLONG_PTR 0x80000000
#define MAXLONG_PTR 0x7fffffff
#define MAXULONG_PTR 0xffffffff
//
// 用于8字节地址对齐的结构体。
//
typedef struct _QUAD { // QUAD 仅仅是用于8字节对齐的结构体,
double DoNotUseThisField; // 并不是一个真正的浮点变量,当你需要使用浮点
} QUAD; // 变量时请使用double类型。
//
// 大小圆整到指定尺寸的整数倍 或者 地址向上对齐到指定尺寸的边界。
//
#define ROUND_TO_SIZE(SIZE,ALIGNMENT) (((ULONG_PTR)(SIZE) + ((ULONG_PTR)(ALIGNMENT) - 1)) & ~((ULONG_PTR)(ALIGNMENT) - 1))
//
// 地址向下对齐到指定尺寸的边界。
//
#define ALIGN_TO_SIZE(VA,SIZE) ((PVOID)((ULONG_PTR)(VA) & ~((ULONG_PTR) (SIZE) - 1)))
//
// 判断是否对齐到指定尺寸的边界。
//
#define IS_ALIGNED_TO_SIZE(VA, SIZE) (0 == ((ULONG_PTR)(VA) & ((ULONG_PTR) (SIZE) - 1)))
//
// 大小圆整到双字的整数倍 或者 地址向上对齐到双字的边界。
//
#define ROUND_TO_QUAD(Size) (((ULONG_PTR)(Size) + 7) & ~7)
//
// 地址向下对齐到双字的边界。
//
#define QUAD_ALIGN(VA) ((PVOID)((ULONG_PTR)(VA) & ~7))
//
// 根据结构体某个域的地址反推结构体的地址。
//
#define CONTAINING_RECORD(address, type, field) ((type *)( \
(ULONG_PTR)(address) - \
(ULONG_PTR)(&((type *)0)->field)))
//
// 判断一个整数是否是2的幂。
//
#define IS_POWER_OF_2(a) (((a) & ((a) - 1)) == 0)
//
// 对指定位测试、置1和清零
//
#define BIT_TEST(va, offset) (va & (1 << (offset)))
#define BIT_SET(va, offset) va = va | (1 << (offset))
#define BIT_CLEAR(va, offset) va = va & (~(1 << (offset)))
#define max(a,b) (((a) > (b)) ? (a) : (b))
#define min(a,b) (((a) < (b)) ? (a) : (b))
//
// AllocationType的可用掩码。用于分配虚拟页。
//
#define MEM_COMMIT 0x1000
#define MEM_RESERVE 0x2000
//
// FreeType的可用掩码。用于释放虚拟页。
//
#define MEM_DECOMMIT 0x4000
#define MEM_RELEASE 0x8000
//
// 路径字符串最大长度。
//
#define MAX_PATH 260
#define INVALID_HANDLE_VALUE ((HANDLE)-1)
//
// 线程入口函数类型定义。
//
typedef ULONG (*PTHREAD_START_ROUTINE)(
PVOID ThreadParameter
);
//
// 进程入口函数类型定义。
//
typedef VOID (*PPROCESS_START_ROUTINE)(VOID);
//
// 进程创建标志。
//
#define DEBUG_PROCESS 0x00000001
#define DEBUG_ONLY_THIS_PROCESS 0x00000002
#define CREATE_SUSPENDED 0x00000004
//
// 进程创建参数结构体。
//
typedef struct _STARTUPINFO {
HANDLE StdInput;
HANDLE StdOutput;
HANDLE StdError;
} STARTUPINFO, *PSTARTUPINFO;
//
// 进程创建结果结构体。
//
typedef struct _PROCESS_INFORMATION {
HANDLE ProcessHandle;
HANDLE ThreadHandle;
ULONG ProcessId;
ULONG ThreadId;
} PROCESS_INFORMATION, *PPROCESS_INFORMATION;
//
// 标准输入输出句柄索引。
//
#define STD_INPUT_HANDLE 1
#define STD_OUTPUT_HANDLE 2
#define STD_ERROR_HANDLE 3
//
// 坐标结构体。
//
typedef struct _COORD {
SHORT X;
SHORT Y;
} COORD, *PCOORD;
//
// 键盘事件结构体。
//
typedef struct _KEY_EVENT_RECORD {
BOOLEAN IsKeyDown;
UCHAR VirtualKeyValue;
ULONG ControlKeyState;
} KEY_EVENT_RECORD, *PKEY_EVENT_RECORD;
//
// 控制键状态掩码。
//
#define RIGHT_ALT_PRESSED 0x0001
#define LEFT_ALT_PRESSED 0x0002
#define RIGHT_CTRL_PRESSED 0x0004
#define LEFT_CTRL_PRESSED 0x0008
#define SHIFT_PRESSED 0x0010
#define NUMLOCK_ON 0x0020
#define SCROLLLOCK_ON 0x0040
#define CAPSLOCK_ON 0x0080
#define ENHANCED_KEY 0x0100
//
// 键盘虚键值定义。
// 和扫描码一样,键盘上的每个按键都对应一个唯一的虚键值。
//
#define VK_BACK 0x08
#define VK_TAB 0x09
#define VK_CLEAR 0x0C
#define VK_RETURN 0x0D
#define VK_SHIFT 0x10
#define VK_CONTROL 0x11
#define VK_MENU 0x12
#define VK_PAUSE 0x13
#define VK_CAPITAL 0x14
#define VK_ESCAPE 0x1B
#define VK_SPACE 0x20
#define VK_PRIOR 0x21
#define VK_NEXT 0x22
#define VK_END 0x23
#define VK_HOME 0x24
#define VK_LEFT 0x25
#define VK_UP 0x26
#define VK_RIGHT 0x27
#define VK_DOWN 0x28
#define VK_SELECT 0x29
#define VK_PRINT 0x2A
#define VK_INSERT 0x2D
#define VK_DELETE 0x2E
/*
* VK_0 - VK_9 与 ASCII '0' - '9' (0x30 - 0x39) 相同
* 0x40 : 未分配
* VK_A - VK_Z 与 ASCII 'A' - 'Z' (0x41 - 0x5A) 相同
*/
#define VK_LWIN 0x5B
#define VK_RWIN 0x5C
#define VK_APPS 0x5D
#define VK_SLEEP 0x5F
#define VK_NUMPAD0 0x60
#define VK_NUMPAD1 0x61
#define VK_NUMPAD2 0x62
#define VK_NUMPAD3 0x63
#define VK_NUMPAD4 0x64
#define VK_NUMPAD5 0x65
#define VK_NUMPAD6 0x66
#define VK_NUMPAD7 0x67
#define VK_NUMPAD8 0x68
#define VK_NUMPAD9 0x69
#define VK_MULTIPLY 0x6A
#define VK_ADD 0x6B
#define VK_SEPARATOR 0x6C
#define VK_SUBTRACT 0x6D
#define VK_DECIMAL 0x6E
#define VK_DIVIDE 0x6F
#define VK_F1 0x70
#define VK_F2 0x71
#define VK_F3 0x72
#define VK_F4 0x73
#define VK_F5 0x74
#define VK_F6 0x75
#define VK_F7 0x76
#define VK_F8 0x77
#define VK_F9 0x78
#define VK_F10 0x79
#define VK_F11 0x7A
#define VK_F12 0x7B
/*
* 0x88 - 0x8F : 未分配
*/
#define VK_NUMLOCK 0x90
#define VK_SCROLL 0x91
#define VK_LSHIFT 0xA0
#define VK_RSHIFT 0xA1
#define VK_LCONTROL 0xA2
#define VK_RCONTROL 0xA3
#define VK_LMENU 0xA4
#define VK_RMENU 0xA5
#define VK_OEM_1 0xBA // ';:' for US
#define VK_OEM_PLUS 0xBB // '+' any country
#define VK_OEM_COMMA 0xBC // ',' any country
#define VK_OEM_MINUS 0xBD // '-' any country
#define VK_OEM_PERIOD 0xBE // '.' any country
#define VK_OEM_2 0xBF // '/?' for US
#define VK_OEM_3 0xC0 // '`~' for US
/*
* 0xC1 - 0xD7 : 保留
*/
/*
* 0xD8 - 0xDA : 未分配
*/
#define VK_OEM_4 0xDB // '[{' for US
#define VK_OEM_5 0xDC // '\|' for US
#define VK_OEM_6 0xDD // ']}' for US
#define VK_OEM_7 0xDE // ''"' for US
#define VK_OEM_8 0xDF
//
// 控制台字体显示属性定义。
//
#define FOREGROUND_BLUE 0x0001 // text color contains blue.
#define FOREGROUND_GREEN 0x0002 // text color contains green.
#define FOREGROUND_RED 0x0004 // text color contains red.
#define FOREGROUND_INTENSITY 0x0008 // text color is intensified.
#define BACKGROUND_BLUE 0x0010 // background color contains blue.
#define BACKGROUND_GREEN 0x0020 // background color contains green.
#define BACKGROUND_RED 0x0040 // background color contains red.
#define BACKGROUND_INTENSITY 0x0080 // background color is intensified.
//
// 文件属性定义。
//
#define GENERIC_READ 0x80000000
#define GENERIC_WRITE 0x40000000
#define FILE_SHARE_READ 0x00000001
#define FILE_SHARE_WRITE 0x00000002
#define CREATE_NEW 1
#define CREATE_ALWAYS 2
#define OPEN_EXISTING 3
#define OPEN_ALWAYS 4
#define TRUNCATE_EXISTING 5
#define FILE_ATTRIBUTE_READONLY 0x00000001
#define FILE_ATTRIBUTE_HIDDEN 0x00000002
#define FILE_ATTRIBUTE_SYSTEM 0x00000004
#define FILE_ATTRIBUTE_DIRECTORY 0x00000010
#define FILE_ATTRIBUTE_ARCHIVE 0x00000020
#define FILE_BEGIN 0
#define FILE_CURRENT 1
#define FILE_END 2
typedef struct _FILETIME {
ULONG LowDateTime;
ULONG HighDateTime;
} FILETIME, *PFILETIME;
//
// PE文件结构相关结构体和常量的定义。
//
#define IMAGE_DOS_SIGNATURE 0x5A4D // MZ
#define IMAGE_NT_SIGNATURE 0x00004550 // PE00
typedef struct _IMAGE_DOS_HEADER { // DOS .EXE header
USHORT e_magic; // Magic number
USHORT e_cblp; // Bytes on last page of file
USHORT e_cp; // Pages in file
USHORT e_crlc; // Relocations
USHORT e_cparhdr; // Size of header in paragraphs
USHORT e_minalloc; // Minimum extra paragraphs needed
USHORT e_maxalloc; // Maximum extra paragraphs needed
USHORT e_ss; // Initial (relative) SS value
USHORT e_sp; // Initial SP value
USHORT e_csum; // Checksum
USHORT e_ip; // Initial IP value
USHORT e_cs; // Initial (relative) CS value
USHORT e_lfarlc; // File address of relocation table
USHORT e_ovno; // Overlay number
USHORT e_res[4]; // Reserved words
USHORT e_oemid; // OEM identifier (for e_oeminfo)
USHORT e_oeminfo; // OEM information; e_oemid specific
USHORT e_res2[10]; // Reserved words
LONG e_lfanew; // File address of new exe header
} IMAGE_DOS_HEADER, *PIMAGE_DOS_HEADER;
//
// File header format.
//
typedef struct _IMAGE_FILE_HEADER {
USHORT Machine;
USHORT NumberOfSections;
ULONG TimeDateStamp;
ULONG PointerToSymbolTable;
ULONG NumberOfSymbols;
USHORT SizeOfOptionalHeader;
USHORT Characteristics;
} IMAGE_FILE_HEADER, *PIMAGE_FILE_HEADER;
#define IMAGE_SIZEOF_FILE_HEADER 20
#define IMAGE_FILE_RELOCS_STRIPPED 0x0001 // Relocation info stripped from file.
#define IMAGE_FILE_EXECUTABLE_IMAGE 0x0002 // File is executable (i.e. no unresolved externel references).
#define IMAGE_FILE_LINE_NUMS_STRIPPED 0x0004 // Line nunbers stripped from file.
#define IMAGE_FILE_LOCAL_SYMS_STRIPPED 0x0008 // Local symbols stripped from file.
#define IMAGE_FILE_AGGRESIVE_WS_TRIM 0x0010 // Agressively trim working set
#define IMAGE_FILE_LARGE_ADDRESS_AWARE 0x0020 // App can handle >2gb addresses
#define IMAGE_FILE_BYTES_REVERSED_LO 0x0080 // Bytes of machine word are reversed.
#define IMAGE_FILE_32BIT_MACHINE 0x0100 // 32 bit word machine.
#define IMAGE_FILE_DEBUG_STRIPPED 0x0200 // Debugging info stripped from file in .DBG file
#define IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP 0x0400 // If Image is on removable media, copy and run from the swap file.
#define IMAGE_FILE_NET_RUN_FROM_SWAP 0x0800 // If Image is on Net, copy and run from the swap file.
#define IMAGE_FILE_SYSTEM 0x1000 // System File.
#define IMAGE_FILE_DLL 0x2000 // File is a DLL.
#define IMAGE_FILE_UP_SYSTEM_ONLY 0x4000 // File should only be run on a UP machine
#define IMAGE_FILE_BYTES_REVERSED_HI 0x8000 // Bytes of machine word are reversed.
#define IMAGE_FILE_MACHINE_I386 0x014c // Intel 386.
//
// Directory format.
//
typedef struct _IMAGE_DATA_DIRECTORY {
ULONG VirtualAddress;
ULONG Size;
} IMAGE_DATA_DIRECTORY, *PIMAGE_DATA_DIRECTORY;
#define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 16
//
// Optional header format.
//
typedef struct _IMAGE_OPTIONAL_HEADER {
//
// Standard fields.
//
USHORT Magic;
UCHAR MajorLinkerVersion;
UCHAR MinorLinkerVersion;
ULONG SizeOfCode;
ULONG SizeOfInitializedData;
ULONG SizeOfUninitializedData;
ULONG AddressOfEntryPoint;
ULONG BaseOfCode;
ULONG BaseOfData;
//
// NT additional fields.
//
ULONG ImageBase;
ULONG SectionAlignment;
ULONG FileAlignment;
USHORT MajorOperatingSystemVersion;
USHORT MinorOperatingSystemVersion;
USHORT MajorImageVersion;
USHORT MinorImageVersion;
USHORT MajorSubsystemVersion;
USHORT MinorSubsystemVersion;
ULONG Win32VersionValue;
ULONG SizeOfImage;
ULONG SizeOfHeaders;
ULONG CheckSum;
USHORT Subsystem;
USHORT DllCharacteristics;
ULONG SizeOfStackReserve;
ULONG SizeOfStackCommit;
ULONG SizeOfHeapReserve;
ULONG SizeOfHeapCommit;
ULONG LoaderFlags;
ULONG NumberOfRvaAndSizes;
IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES];
} IMAGE_OPTIONAL_HEADER, *PIMAGE_OPTIONAL_HEADER;
#define IMAGE_NT_OPTIONAL_HEADER_MAGIC 0x10b
typedef struct _IMAGE_NT_HEADERS {
ULONG Signature;
IMAGE_FILE_HEADER FileHeader;
IMAGE_OPTIONAL_HEADER OptionalHeader;
} IMAGE_NT_HEADERS, *PIMAGE_NT_HEADERS;
// Subsystem Values
#define IMAGE_SUBSYSTEM_UNKNOWN 0 // Unknown subsystem.
#define IMAGE_SUBSYSTEM_NATIVE 1 // Image doesn't require a subsystem.
#define IMAGE_SUBSYSTEM_EOS_CUI 80 // Image runs in the EOS character subsystem.
// Directory Entries
#define IMAGE_DIRECTORY_ENTRY_EXPORT 0 // Export Directory
#define IMAGE_DIRECTORY_ENTRY_IMPORT 1 // Import Directory
#define IMAGE_DIRECTORY_ENTRY_RESOURCE 2 // Resource Directory
#define IMAGE_DIRECTORY_ENTRY_EXCEPTION 3 // Exception Directory
#define IMAGE_DIRECTORY_ENTRY_SECURITY 4 // Security Directory
#define IMAGE_DIRECTORY_ENTRY_BASERELOC 5 // Base Relocation Table
#define IMAGE_DIRECTORY_ENTRY_DEBUG 6 // Debug Directory
#define IMAGE_DIRECTORY_ENTRY_ARCHITECTURE 7 // Architecture Specific Data
#define IMAGE_DIRECTORY_ENTRY_GLOBALPTR 8 // RVA of GP
#define IMAGE_DIRECTORY_ENTRY_TLS 9 // TLS Directory
#define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 10 // Load Configuration Directory
#define IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT 11 // Bound Import Directory in headers
#define IMAGE_DIRECTORY_ENTRY_IAT 12 // Import Address Table
#define IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT 13 // Delay Load Import Descriptors
#define IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR 14 // COM Runtime descriptor
//
// Section header format.
//
#define IMAGE_SIZEOF_SHORT_NAME 8
typedef struct _IMAGE_SECTION_HEADER {
UCHAR Name[IMAGE_SIZEOF_SHORT_NAME];
union {
ULONG PhysicalAddress;
ULONG VirtualSize;
} Misc;
ULONG VirtualAddress;
ULONG SizeOfRawData;
ULONG PointerToRawData;
ULONG PointerToRelocations;
ULONG PointerToLinenumbers;
USHORT NumberOfRelocations;
USHORT NumberOfLinenumbers;
ULONG Characteristics;
} IMAGE_SECTION_HEADER, *PIMAGE_SECTION_HEADER;
#define IMAGE_SIZEOF_SECTION_HEADER 40
//
// Section characteristics.
//
#define IMAGE_SCN_CNT_CODE 0x00000020 // Section contains code.
#define IMAGE_SCN_CNT_INITIALIZED_DATA 0x00000040 // Section contains initialized data.
#define IMAGE_SCN_CNT_UNINITIALIZED_DATA 0x00000080 // Section contains uninitialized data.
#define IMAGE_SCN_LNK_OTHER 0x00000100 // Reserved.
#define IMAGE_SCN_LNK_INFO 0x00000200 // Section contains comments or some other type of information.
#define IMAGE_SCN_LNK_REMOVE 0x00000800 // Section contents will not become part of image.
#define IMAGE_SCN_LNK_COMDAT 0x00001000 // Section contents comdat.
#define IMAGE_SCN_NO_DEFER_SPEC_EXC 0x00004000 // Reset speculative exceptions handling bits in the TLB entries for this section.
#define IMAGE_SCN_GPREL 0x00008000 // Section content can be accessed relative to GP
#define IMAGE_SCN_MEM_FARDATA 0x00008000
#define IMAGE_SCN_MEM_PURGEABLE 0x00020000
#define IMAGE_SCN_MEM_16BIT 0x00020000
#define IMAGE_SCN_MEM_LOCKED 0x00040000
#define IMAGE_SCN_MEM_PRELOAD 0x00080000
#define IMAGE_SCN_ALIGN_1BYTES 0x00100000 //
#define IMAGE_SCN_ALIGN_2BYTES 0x00200000 //
#define IMAGE_SCN_ALIGN_4BYTES 0x00300000 //
#define IMAGE_SCN_ALIGN_8BYTES 0x00400000 //
#define IMAGE_SCN_ALIGN_16BYTES 0x00500000 // Default alignment if no others are specified.
#define IMAGE_SCN_ALIGN_32BYTES 0x00600000 //
#define IMAGE_SCN_ALIGN_64BYTES 0x00700000 //
#define IMAGE_SCN_ALIGN_128BYTES 0x00800000 //
#define IMAGE_SCN_ALIGN_256BYTES 0x00900000 //
#define IMAGE_SCN_ALIGN_512BYTES 0x00A00000 //
#define IMAGE_SCN_ALIGN_1024BYTES 0x00B00000 //
#define IMAGE_SCN_ALIGN_2048BYTES 0x00C00000 //
#define IMAGE_SCN_ALIGN_4096BYTES 0x00D00000 //
#define IMAGE_SCN_ALIGN_8192BYTES 0x00E00000 //
// Unused 0x00F00000
#define IMAGE_SCN_ALIGN_MASK 0x00F00000
#define IMAGE_SCN_LNK_NRELOC_OVFL 0x01000000 // Section contains extended relocations.
#define IMAGE_SCN_MEM_DISCARDABLE 0x02000000 // Section can be discarded.
#define IMAGE_SCN_MEM_NOT_CACHED 0x04000000 // Section is not cachable.
#define IMAGE_SCN_MEM_NOT_PAGED 0x08000000 // Section is not pageable.
#define IMAGE_SCN_MEM_SHARED 0x10000000 // Section is shareable.
#define IMAGE_SCN_MEM_EXECUTE 0x20000000 // Section is executable.
#define IMAGE_SCN_MEM_READ 0x40000000 // Section is readable.
#define IMAGE_SCN_MEM_WRITE 0x80000000 // Section is writeable.
//
// Relocation format.
//
typedef struct _IMAGE_RELOCATION {
union {
ULONG VirtualAddress;
ULONG RelocCount; // Set to the real count when IMAGE_SCN_LNK_NRELOC_OVFL is set
} u;
ULONG SymbolTableIndex;
USHORT Type;
} IMAGE_RELOCATION, *PIMAGE_RELOCATION;
//
// I386 relocation types.
//
#define IMAGE_REL_I386_ABSOLUTE 0x0000 // Reference is absolute, no relocation is necessary
#define IMAGE_REL_I386_DIR16 0x0001 // Direct 16-bit reference to the symbols virtual address
#define IMAGE_REL_I386_REL16 0x0002 // PC-relative 16-bit reference to the symbols virtual address
#define IMAGE_REL_I386_DIR32 0x0006 // Direct 32-bit reference to the symbols virtual address
#define IMAGE_REL_I386_DIR32NB 0x0007 // Direct 32-bit reference to the symbols virtual address, base not included
#define IMAGE_REL_I386_SEG12 0x0009 // Direct 16-bit reference to the segment-selector bits of a 32-bit virtual address
#define IMAGE_REL_I386_SECTION 0x000A
#define IMAGE_REL_I386_SECREL 0x000B
#define IMAGE_REL_I386_TOKEN 0x000C // clr token
#define IMAGE_REL_I386_SECREL7 0x000D // 7 bit offset from base of section containing target
#define IMAGE_REL_I386_REL32 0x0014 // PC-relative 32-bit reference to the symbols virtual address
//
// Export Format
//
typedef struct _IMAGE_EXPORT_DIRECTORY {
ULONG Characteristics;
ULONG TimeDateStamp;
USHORT MajorVersion;
USHORT MinorVersion;
ULONG Name;
ULONG Base;
ULONG NumberOfFunctions;
ULONG NumberOfNames;
ULONG AddressOfFunctions; // RVA from base of image
ULONG AddressOfNames; // RVA from base of image
ULONG AddressOfNameOrdinals; // RVA from base of image
} IMAGE_EXPORT_DIRECTORY, *PIMAGE_EXPORT_DIRECTORY;
//
// Import Format
//
typedef struct _IMAGE_IMPORT_BY_NAME {
USHORT Hint;
CHAR Name[1];
} IMAGE_IMPORT_BY_NAME, *PIMAGE_IMPORT_BY_NAME;
typedef struct _IMAGE_THUNK_DATA {
union {
ULONG ForwarderString; // PBYTE
ULONG Function; // PDWORD
ULONG Ordinal;
ULONG AddressOfData; // PIMAGE_IMPORT_BY_NAME
} u;
} IMAGE_THUNK_DATA, * PIMAGE_THUNK_DATA;
#define IMAGE_ORDINAL_FLAG 0x80000000
#define IMAGE_ORDINAL(Ordinal) (Ordinal & 0xffff)
#define IMAGE_SNAP_BY_ORDINAL(Ordinal) ((Ordinal & IMAGE_ORDINAL_FLAG) != 0)
typedef struct _IMAGE_IMPORT_DESCRIPTOR {
union {
ULONG Characteristics; // 0 for terminating null import descriptor
ULONG OriginalFirstThunk; // RVA to original unbound IAT (PIMAGE_THUNK_DATA)
} u;
ULONG TimeDateStamp; // 0 if not bound,
// -1 if bound, and real date\time stamp
// in IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT (new BIND)
// O.W. date/time stamp of DLL bound to (Old BIND)
ULONG ForwarderChain; // -1 if no forwarders
ULONG Name;
ULONG FirstThunk; // RVA to IAT (if bound this IAT has actual addresses)
} IMAGE_IMPORT_DESCRIPTOR, *PIMAGE_IMPORT_DESCRIPTOR;
#ifdef __cplusplus
}
#endif
#endif // _EOSDEF_
/***
Copyright (c) 2008 北京英真时代科技有限公司。保留所有权利。
只有您接受 EOS 核心源代码协议(参见 License.txt)中的条款才能使用这些代码。
如果您不接受,不能使用这些代码。
文件名: error.h
描述: EOS 错误码常量的定义。
*******************************************************************************/
#ifndef _ERROR_
#define _ERROR_
#define NO_ERROR 0L
#define ERROR_FILE_NOT_FOUND 2L
#define ERROR_PATH_NOT_FOUND 3L
#define ERROR_ACCESS_DENIED 5L
#define ERROR_INVALID_HANDLE 6L
#define ERROR_NOT_ENOUGH_MEMORY 8L
#define ERROR_SHARING_VIOLATION 32L
#define ERROR_WRONG_DISK 34L
#define ERROR_NOT_SUPPORTED 50L
#define ERROR_INVALID_PARAMETER 87L
#define ERROR_PROC_NOT_FOUND 127L
#define ERROR_SIGNAL_REFUSED 156L
#define ERROR_BAD_PATHNAME 161L
#define ERROR_ALREADY_EXISTS 183L
#define ERROR_BAD_EXE_FORMAT 193L
#define ERROR_FILENAME_EXCED_RANGE 206L
#define WAIT_TIMEOUT 258L
#define ERROR_NOT_OWNER 288L
#define ERROR_TOO_MANY_POSTS 298L
#define ERROR_INVALID_ADDRESS 487L
#define ERROR_IO_PENDING 997L
#define ERROR_NOACCESS 998L
#define ERROR_FLOPPY_UNKNOWN_ERROR 1124L
#define ERROR_NOT_FOUND 1168L
#define ERROR_FILE_CORRUPT 1392L
#define ERROR_TIMEOUT 1460L
#define ERROR_INVALID_COMMAND_LINE 1639L
#define ERROR_UNKNOWN 7499L
#endif // _ERROR_
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论