- 积分
- 213
- 实力分
- 点
- 金钱数
- 两
- 技术分
- 分
- 贡献分
- 分
|
发表于 2006-3-14 15:50:34
|
显示全部楼层
Seklth 已开发出 MMC卡菜单里增加“复制”菜单补丁,即文件复制功能,发表在其集成版里。
如下为源码,请移植!
(好像是要改“使用提示”为“复制”)
In menu:
dw sof(_menu_move), seg(_menu_move) ;"Move"
dw sof(_menu_rename), seg(_menu_rename);"Rename" dw sof(_menu_copy), seg(_menu_copy)
_menu_move:
extp #pag(_CopyFlag),#1
mov pof(_CopyFlag), ZEROS ;std
jmps 0D8h,0786Ah ;Move dialog
_menu_rename:
extp #pag(_CopyFlag),#1
mov pof(_CopyFlag), ZEROS ;std
jmps 0D8h,07BD0h ;Rename
_menu_copy:
extp #pag(_CopyFlag),#1
mov pof(_CopyFlag), ONES
jmps 0D8h,0786Ah ;Move dialog
patch:
PATCHRENAME SECTION CODE WORD AT 0E4A9D2h ;rename call patch
PROCRENAME PROC
calls _My_Rename
PROCRENAME ENDP
PATCHRENAME ENDS
source on c:以下是C语言的Code:
int My_Rename(char far* source, char far* dest)
{
char far* buff;
int fs, fd, sz;
if (!CopyFlag) return(Rename(source,dest));
fs=FileOpen(source,_O_RDONLY,0);
if (fs==-1) return(0);//Error
fd=FileOpen(dest,_O_CREAT+_O_WRONLY+_O_TRUNC,_S_IREAD);
if (fd==-1) { FileClose(fs); return(0); }//Error
buff=EX_heap_malloc_with_lock(0x2000);
if (buff==0) { FileClose(fs); FileClose(fd); return(0); }//Error
do {
sz=FileRead(fs,buff,0x2000); //8kb buff
FileWrite(fd,buff,sz);
} while (sz!=0);
FileClose(fs);
FileClose(fd);
EX_heap_free_with_lock(buff);
return(1); //Success
}
上面是C语言的,这里是ASM的源码,可用sfe:
@EQUP(_EX_heap_malloc_with_lock,0D7D374h)
@EQUP(_EX_heap_free_with_lock,0D7D3B0h)
@EQUP(_FileOpen,0DFA73Eh)
@EQUP(_FileRead,0DFABAEh)
@EQUP(_FileWrite,0DFB0FEh)
@EQUP(_FileClose,0DFC570h)
extern void* EX_heap_malloc_with_lock(unsigned int siz);
extern void EX_heap_free_with_lock(void far *mem);
extern int FileOpen(char far *name,int flag1,int flag2);
extern int FileRead(int handle,void far *buf, int bnum);
extern int FileWrite(int handle,void far *buf, int bnum);
extern int FileClose(int handle);
//oflag is an Integer constant combinations defined in FCNTL.H:
#define _O_RDONLY 0x0000 /* open for reading only */
#define _O_WRONLY 0x0001 /* open for writing only */
#define _O_RDWR 0x0002 /* open for reading and writing */
#define _O_APPEND 0x0008 /* writes done at eof */
#define _O_CREAT 0x0100 /* create and open file */
#define _O_TRUNC 0x0200 /* open and truncate */
#define _O_EXCL 0x0400 /* open only if file doesn't already exist */
#define _O_TEXT 0x4000 /* file mode is text (translated) */
#define _O_BINARY 0x8000 /* file mode is binary (untranslated) */
#define _O_NOINHERIT 0x0080 /* child process doesn't inherit file */
#define _O_TEMPORARY 0x0040 /* temporary file bit */
#define _O_SHORT_LIVED 0x1000 /* temporary storage file, try not to flush */
#define _O_SEQUENTIAL 0x0020 /* file access is primarily sequential */
#define _O_RANDOM 0x0010 /* file access is primarily random */
//The pmode argument is required only when _O_CREAT is specified.
//If the file already exists, pmode is ignored.
//Otherwise, pmode specifies the file permission settings,
//which are set when the new file is closed the first time.
#define _S_IREAD 0000400 /* read permission, owner */
#define _S_IWRITE 0000200 /* write permission, owner */
#define _S_IEXEC 0000100 /* execute/search permission, owner */
; files.c 4
FILES_1_PR SECTION CODE WORD PUBLIC 'CPROGRAM'
PUBLIC _My_Rename
_My_Rename PROC FAR
MOV [-R0],R9
MOV [-R0],R8
MOV [-R0],R7
MOV [-R0],R6
; Locals:
;
; Statics:
;
; CSEs:
; fs = R8
; fd = R9
; buff = R6R7
; sz = R12
; source = R12R13
; dest = R14R15
;
; files.c 7 char far* buff;
; files.c 8 int fs, fd, sz;
; files.c 9 if (!CopyFlag) return(Rename(source,dest));
EXTP #PAG _CopyFlag,#01h
MOV R1,POF _CopyFlag
JMPR cc_NZ,_12
CALLS SEG _Rename,_Rename
JMPA cc_UC,_19
_12:
; files.c 10
; files.c 11 fs=FileOpen(source,_O_RDONLY,0);
MOV R9,R15
MOV R6,R14
MOV R14,#00h
MOV R15,#00h
CALLS SEG _FileOpen,_FileOpen
MOV R8,R4
MOV R14,R6
MOV R15,R9
; files.c 12 if (fs==-1) return(0);//Error
CMP R8,#0FFFFh
JMPR cc_EQ,_15
; files.c 13 fd=FileOpen(dest,_O_CREAT+_O_WRONLY+_O_TRUNC,_S_IREAD);
MOV R12,R14
MOV R13,R15
MOV R14,#0301h
MOV R15,#0100h
CALLS SEG _FileOpen,_FileOpen
MOV R9,R4
; files.c 14 if (fd==-1) { FileClose(fs); return(0); }//Error
CMP R9,#0FFFFh
JMPR cc_NE,_13
MOV R12,R8
CALLS SEG _FileClose,_FileClose
JMPR cc_UC,_15
_13:
; files.c 15 buff=EX_heap_malloc_with_lock(0x2000);
MOV R12,#02000h
CALLS SEG _EX_heap_malloc_with_lock,_EX_heap_malloc_with_lock
MOV R6,R4
MOV R7,R5
; files.c 16 if (buff==0) { FileClose(fs); FileClose(fd); return(0); }//Error
MOV R12,R7
OR R12,R6
JMPR cc_NZ,_16
MOV R12,R8
CALLS SEG _FileClose,_FileClose
MOV R12,R9
CALLS SEG _FileClose,_FileClose
_15:
MOV R4,#00h
JMPR cc_UC,_19
; files.c 17 do {
_16:
_17:
; files.c 18 sz=FileRead(fs,buff,0x2000); //8kb buff
MOV R12,R8
MOV R13,R6
MOV R14,R7
MOV R15,#02000h
CALLS SEG _FileRead,_FileRead
MOV R12,R4
; files.c 19 FileWrite(fd,buff,sz);
MOV [-R0],R12
MOV R12,R9
MOV R13,R6
MOV R14,R7
MOV R15,[R0]
CALLS SEG _FileWrite,_FileWrite
MOV R12,[R0+]
; files.c 20 } while (sz!=0);
JMPR cc_NZ,_17
; files.c 21 FileClose(fs);
MOV R12,R8
CALLS SEG _FileClose,_FileClose
; files.c 22 FileClose(fd);
MOV R12,R9
CALLS SEG _FileClose,_FileClose
; files.c 23 EX_heap_free_with_lock(buff);
MOV R12,R6
MOV R13,R7
CALLS SEG _EX_heap_free_with_lock,_EX_heap_free_with_lock
; files.c 24 return(1); //Success
MOV R4,#01h
; files.c 25 }
_19:
MOV R6,[R0+]
MOV R7,[R0+]
MOV R8,[R0+]
MOV R9,[R0+]
RETS
_My_Rename ENDP
复制程序补丁如下:
(MMC菜单里可能要改某个选项的call为调用这个复制功能, 因为原补丁的菜单补丁很复杂,可能移植不了。比如,将“使用提示”改为“复制”)
004164CC: FFFFFFFFFFFFFFFFFFFF 8890888088708860F06F
004164D6: FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
F09ED7502B00F2FE560572FE54053D06F0E9F0F6DADF40E0EA00B065F07CF08D
004164F6: FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
F0E9F0F6DAC77885F0C7F0D848402D27E00EE00FDADF3EA7F08446F8FFFF2D1F
00416516: FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
F0C9F0D6E6FE0103E6FF0001DADF3EA7F09446F9FFFF3D04F0C8DADF70C50D0F
00416536: FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
E6FC0020DAD774D3F064F075F0C770C63D08F0C8DADF70C5F0C9DADF70C5E004
00416556: FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
0D2CF0C8F0D6F0E7E6FF0020DADFAEABF0C488C0F0C9F0D6F0E7A8F0DADFFEB0
00416576: FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
98C0F0DCF0EDBCFED7502B0004FD5C0514FE5E0548C03DE5F0C8DADF70C5F0C9
00416596: FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
DADF70C5F0C6F0D7DAD7B0D3D7502B00048F5405148F5605E014986098709880
004165B6: FFFFFFFF 9890DB00
[ 本帖最后由 Xinshou 于 2006-3-31 16:08 编辑 ] |
|