; *** FTA v2.1. No Case Sensitive ***
; *** File Type Association v2.0 ***
; Copiright(C)2005 by Rst7/CBSIE
;
; Need FAM3.2 & ESI patch. Undo all FAM2 stuff
; and patches, used FAM2 (JSTV and other)
;
; Patch use text file A:\execute.ext as
;
; ...
; file_extention:full_path_and_name_of_binfile
; ...
;
; One line - one extention. Without spaces!
; If extention not found, run
; last binfile defined in execute.ext
;
; For coders: full path and name of openfile
; passed to binfile trows R12/R13 as far pointer
; to ASCIIZ string
;
; Check R13 (_pof(commandline)) for 0x35 - if equ
; then run from FTA, else run from BFA
;
; Version 2.1->Use any case of chars in file extention and record in execute.ext
;
; Необходим FAM3.2 и ESI, откатить все барахло
; FAM2 и кто его пользует (JSTV и остальное).
;
; Использует текстовый файл A:\execute.ext в виде
;
; ...
; расширение:полный_путь_и_имя_бинарника
; ...
;
; Одна строка - одно расширение. Без пробелов!
; Для неизвестных расширений - запуск
; бинарника в последней записи
;
; Для кодеров: полный путь и имя открываемого
; файла передается в бинарник через R12/R13 как
; far-указатель на ASCIIZ строку.
;
; Сравнить R13 (_pof(commandline)) с 0x35 - если равно,
; то запущен через FTA, иначе через BFA.
;
; Версия 2.1->Не зависима от регистра символов расширения и записи в execute.ext
;使用方式,在mmc根目录新建文本文件execute.ext,内容格式如下
;org:A:/bin/fileorg.bin >>意为关联org文件到A:\fileorg.bin
;txt:A:/bin/ted.bin >>关联txt文件到A:\bin\ted.bin
;sie:A:/bin/null.bin
;注意!!!sie:A:/bin/null.bin必须在最后(该文件只需要4个16进制的字符就行db00)
;否则它会将未知文件关联到定义的最后一个bin上
;Memory Function
Memchr EQU 0C78360h ;Finds characters in a buffer. R12 = Offset R13 = Page R14 = Char R15 = Size
Memcmp EQU 0C78388h ;[R0] = Size.
Memcpy_Src_LT_Dst EQU 0C77430h ;Memory copy. R4 = SrcOff R5 = SrcPag R10 = DstOff R11 = DstPag R3 = Size
Memcpy EQU 0C783DCh ;[r0] = size r12 = Dstoff r13 = Dstpag r14 = Srcoff r15 = Srcpag
;String Function
Strcat EQU 0C784A6h ;Append a string. r12 = Dstoff r13 = Dstpag r14 = Srcoff r15 = Srcpag
Strchr EQU 0C784CCh ;Find a character in a string. R12 = Offset R13 = Page R14 = Char
Strrchr EQU 0C785CCh ;Scan a string for the last occurrence of a character.
Strcmp EQU 0C784EEh ;Compare strings. r12 = Dstoff r13 = Dstpag r14 = Srcoff r15 = Srcpag
Strcmp_Size EQU 0C78578h ;Compare strings. [R0] = Size
Strcpy EQU 0C78516h ;Copy a string. r12 = Dstoff r13 = Dstpag r14 = Srcoff r15 = Srcpag
Strcpy_FillSize EQU 0C7859Eh ;Copy a string,Fill #FF1Ch. [R0] = Size
Strcspn EQU 0C785F0h ;Find a substring in a string.r12 = Setoff r13 = Setpag r14 = SubSrcoff r15 = SubSrcpag
Strset EQU 0C78416h ;Set characters of a string to a character.R12 = Offset R13 = Page R14 = Char R15 = Size
GetLength EQU 0C78536h ;R12 = Offset R13 = Page R4 = Length
;AT Function
SendATCommand EQU 0CC9DCCh ;Send reply string.
;Address for Patch Data
Patch_Address EQU 1F8000h ;Free Space in Flash (CHANGE THIS)
Patch Section Code Word At Patch_address ; Start Patch at Patch_Address
;-------------------------------------------------------------------------------;
main proc far ; start main of patch
;///////////////////////////////////////
;ToDo,补充被修改的位置的指令
;///////////////////////////////////////
MOV [-R0],R12
MOV [-R0],R13
MOV [-R0],R14
MOV [-R0],R15
MOV R14,R12 ;需要Dump内存的offset
MOV R15,R13 ;需要Dump内存的Page
MOV R12,#400H ;Dump的内存数量
MOV [-R0],R12
MOV R12,#1000H ;Dump到0c:1000,有大段空间(约A00),如果是多次Dump,需递增地址
MOV R13,#0CH
CALLS SEG(Memcpy),SOF(Memcpy)
ADD R0,#2
MOV R15,[R0+]
MOV R14,[R0+]
MOV R13,[R0+]
MOV R12,[R0+]
;///////////////////////////////////////
;ToDo,补充被修改的位置的指令
;///////////////////////////////////////
RETS
main endp
;-------------------------------------------------------------------------------;
Patch EndS
CHANGEBYTE Section Code Word At 0x35622A ; Start Patch at Patch_Address
CHANGE PROC FAR
CALLS SEG(Patch_address+0xA00000),SOF(Patch_address+0xA00000)
CHANGE ENDP
CHANGEBYTE ENDS
END
;Address for Patch Data
Patch_Address EQU 1F8000h ;Free Space in Flash (CHANGE THIS)
Patch Section Code Word At Patch_address ; Start Patch at Patch_Address
main proc far ; start main of patch
mov [-r0],r12
mov [-r0],r13
mov [-r0],r14
mov [-r0],r15
mov r4,#8 ;Dump栈的深度
[ 本帖最后由 JunFeng 于 2006-4-21 19:10 编辑 ]作者: JunFeng 时间: 2006-2-15 14:31
These two bytes lie among other - this is the table of passages on the contents of register with the base for address off_.A9BDBA. The table thus appears:
Code:
Further go all these loc _... from the table - i.e., branch, where is accomplished passage in the dependence on the contents r12. As a rule, all branches converge then in one place - restoration of registers of the stack and reset from p \p. T.e., in such cases simply you search for instruction jmpi. Questions?[/code
here nakovyryal another pair of functions more exactly found che they make, clog into the bases
C7:8032 longtohexstr - Convert HEX number lenght [ r0 ] bytes from pag-r15 pof-r14 to HEX String to pag-r13 pof-r12
and
C7:7430 cpyBufferToStack - Copy buffer from pag-r5 pof-r4?? stack r3-bytes
by the way by all who digs lay out syubda also that they found simpler will be
a question to the diggers: to ktonit' did attempt to vkurit' as they do work file functions? more accurate as to determine loaded file or not, and the yesterday stalknulsya with this paradox that
for example we have two regions Filebuff and Membuff the first is filled 00 second FF, on MMS we also have a file with the symbols in the standard coding we further make progu of the type
calls loadfile
copy mem from filebuff to membuff
rets
loadfile: fileopen
fileread to filebuff
fileclose
rets
in this by the case into Membuff we will obtain zero, although the file will load in Filebuff, yeslizhe to make thus
calls loadfile
rets
loadfile: fileopen
fileread to filebuff
fileclose
copy mem from filebuff to membuff
rets
Vatchdog like in Mamaicha in patche to the on-line- piercing was disconnected.
On the motive of your old idea of hours on the turned-off tele-: try this
225461: 25 da
or this
225461: 25 c2; is still possible ce, e0 - this quite strange version,
and on off. by tele- press red briefly.
Even on the theme of loaded ringtonov:
; at the input: r12=1,2,3 - number indiv. the melody
CsegDC:12DC SelectAndLoadIndividualMelody:
selection from the list and loading indiv.melody 1..3, truth to select necessary by knobs, but somewhere there converter midi- Bean must be!
;
; Open file
;
Dialog1_proc3:
mov r12,#pof(GBSS_buf)
mov r13,#pag(GBSS_buf)
mov [-r0],r13
mov [-r0],r12
mov r12,#pof(FileName)
mov r13,#pag(FileName)
mov r14,#102h
mov r15,#100h
calls GBSS_po_open
add r0,#4
extp #pag(FileHandle),#1
mov pof(FileHandle),r4
mov r12,#pof(text3)
mov r13,#pag(text3)
calls r4_.to_.hex; This is printing r4 into the line
mov r14,#y2*2
jmpa cc_.UC,drawtxt; Printing line on the screen
text3:
db '0000 - Open',0
FileName:
db 'A:\upor',0
FileHandle:
dw 0
GBSS_buf:
dw 0
With the pressure on 1 must print "FHND - Open", FHND - khandler, which returned GBSS_.po_.open. By the way, before the passage to this code stands printing the code of symbol in another line.
As a result we have - we start binarnik (by the way, work with the dialogue of podsmotrenna in vibra.bin), dialogue comes, we press 2,3,4 - it is normal, we print 32,33,34, we press 1 - nothing is printed (here here 4 and ofigel, occurs drawString - this is another task!), telephone is turned off.
How to be butted?
PS Funkitsii fileopen and t.d. to treat not hunting, judging by everything, they must be caused only in flow MMC_.FILESYSTEM_.proc
Thus far it sat it was investigated, what thought into the head arrived: can binarnik it is executed in some flow not such, made printing PidAct with the start of binarnika (more exact, only it is memorized with the start, it is printed in onCreate) and in function onCreate of dialogue, as a result it was explained this is what:
1. With the first starting (menyu+ #, the selection of file, to open) control to address 80000 is transmitted from flow MMC_.FILE_.SYSTEM, up
struct DIALOG
{
void huge *onKeyPress;
void huge *onDummy1;
void huge *onDummy2;
void huge *onDummy3;
void huge *onCreate;
void huge *onRun;
};
extern void pShowDialog(const struct DIALOG far *,char far *);
extern void pDialogOnRun(void);
extern void doBack0A(void);
extern void DrawString(int x,int y,int w,int h,const char far *str,int font);
extern void FillRect(int x,int y,int w,int h,int color);
extern char keybQueneIdx;
extern char keybQueneBuf[];
extern int GbsLock_ifNZ;
extern int GbsLock_ifZ;
typedef char far * STR;
STR nibble(STR s, char b)
{
b&=0x0F;
if (b>9) b+='A'-10-'0';
b+='0';
*s++=b;
return(s);
}
void hexbyte(STR s, char b)
{
s=nibble(s,b>>4);
s=nibble(s,b);
}
void hexint(STR s, int b)
{
s=nibble(s,b>>12);
s=nibble(s,b>>;
s=nibble(s,b>>4);
s=nibble(s,b);
}
AllHeapsPointers+6, //This is indicator to the heap, in which we will reserve variables, I use FarHeap8 = > +6 there is a reference to it in file AllHeapsPointers - it also extern cm. sl45.h (my)
Sizeof(.struct VARS), //The overall size of all our variables
"FOOPATCH"//But this name, on which is carried out the search for the already created buffers
};
IMHO the way is:
0. Find place for variable CopyFlag. Don't use Java memory! Better of all is using PMM patch, but u must relocate it.
1. Add menu option "Copy" and code:
CopyFlag=1;
jmp 0D8786Ah
2. Change this:
csegE4:A9D2 DA DF 40 E0 calls 0DFh, rename
to call MyRename
3. Do: (source R12:R13, dest R14:R15)
int MyRename(char far *s, char far *d)
{
if (CopyFlag)
{
....
copy file from s to d, use direct call to FileOpen etc, coz there r
context of MMC_FILE_SYSTEM_proc
....
return(0); //Success or
rerurn(1); //Error
}
else
{
return(rename(s,d));
}
}
While you copy file, use MMCEXPL_HeapMalloc (D7D374) and EX_heap_free_with_lock (D7D3B0) for allocate and free memory for file buffer. Don't use Java or other unknown memory - it's a way to make unstable patch!!!!
AllHeapsPointers+6, //This is indicator to the heap, in which we will reserve variables, I use FarHeap8 = > +6 there is a reference to it in file AllHeapsPointers - it also extern cm. sl45.h (my)
Sizeof(.struct VARS), //The overall size of all our variables
"FOOPATCH"//But this name, on which is carried out the search for the already created buffers
};
static const struct PVARD
{
struct _heap_ far ** pp_heap;
unsigned int siz;
char name[8];
} VARD=
{
AllHeapsPointers+6, //This is indicator to the heap, in which we will reserve variables, I use FarHeap8 = > +6 there is a reference to it in file AllHeapsPointers - it also extern cm. sl45.h (my)
Sizeof(.struct VARS), //The overall size of all our variables
"FOOPATCH"//But this name, on which is carried out the search for the already created buffers
};
//Procedures in patche PMM
//To obtain indicator to the variables, if yet not zarezervirovanno, we reserve and clear 0
extern struct VARS far * GetVars(.const struct PVARD far * p);
//To free the variables
Void FreeVars(.const Struct PVARD Far * p);
//Now our programpatch - for example, it consists of the pair of the functions caused from the different places
void foo1(void)
{
struct VARS far *VP=GetVars(&VARD); //Indicator to the variables was obtained
....
VP->var1++; ///For example....
if (VP->var1==100) VP->var2="Upor";
....
}
void foo2(void)
{
struct VARS far *VP=GetVars(&VARD); //Indicator to the variables was obtained
if (VP->var2)
{
DrawString(0,0,101,80,VP->var2);
FreeVars(&VARD);
}
}
Example, it is certainly sucked out of x$я.
For example is caused procedure foo1. For the first time variables are reserved also with all following calls are used precisely they, respectively var1 increases by 1 with each call, when it became 100, in var2 is written the indicator to the line (it also in ROM).
Now when we cause foo2 and to eat an indicator to the line, it is printed, and variables are freed. Only if we use ourselves release, is desirable still critical sections to organize through AcquireGbsLock() and FreeGbsLock().
For example, patch CDR in connection with this competently must appear thus:
Code:
//Our variables - for the program they will be global, but where it is convenient
Struct VARS
{
char str_.to_.write[100 ];
}; //Note, this is only description, the code not it generitsya
//Description of data, note const - it is stored in PZU, some or are more to patch/program - here this already generitsya in the stage of the compilation
static const struct PVARD
{
struct _heap_ far ** pp_heap;
unsigned int siz;
char name[8];
} VARD=
{
AllHeapsPointers+6, //This is indicator to the heap, in which we will reserve variables, I use FarHeap8 = > +6 there is a reference to it in file AllHeapsPointers - it also extern cm. sl45.h (my)
Sizeof(.struct VARS), //The overall size of all our variables
"CDR vX.X"//But this name, on which is carried out the search for the already created buffers
};
//Procedures in patche PMM
//To obtain indicator to the variables, if yet not zarezervirovanno, we reserve and clear 0
extern struct VARS far * GetVars(.const struct PVARD far * p);
//To free the variables
Void FreeVars(.const Struct PVARD Far * p);
void WriteToLogFile(void)
{
int f;
struct VARS far *VP=GetVars(&VARD);
f=FileOpen("A:\\cdr.log",_O_CREAT+_O_RDWR+_O_APPEND,_S_IREAD);
if (f!=-1)
{
FileWrite(f,VP->str_to_write,strlen(VP->str_to_write));
FileClose(f);
}
FreeVars(&VARD);
}
void IncomingCall(void)
{
struct VARS far *VP=GetVars(&VARD); //Indicator to the variables was obtained
.....
sprinf(VP->str_to_write,"Incoming at %02d:%02d",_hour,_minute);
FilesysICall(WriteToLogFile);
}
void IncomingSMS(void)
{
_ VARD LABEL WORD
DPPTR (_ AllHeapsPointers+24); This is indicator to that, what heap will use, in particular FarHeap8
DW 106; How many bytes of the brain to us are must
DB "PatchNam '; Unique name
...It is analogous...
}
There are no here critical sections, t.k. by itself FILE_.SYSTEM_.PROC - this critical section is still that....
Voobshchem, went 4 patch PMM to bodyazhit', and the entire raspal'tseval, and there is no patcha itself, more exact it is fixed in binarnike, it is necessary it to alter in ROM. Through the pair of hours to zababakhayu.
#define _AllHeapsPointers 039DCEh
_ VARD LABEL WORD
DPPTR (_ AllHeapsPointers+24); This is indicator to that, what heap will use, in particular FarHeap8
DW 106; How many bytes of the brain to us are must
DB "PatchNam '; Unique name
;Displacement of variables from the beginning of the buffer
Var1 equ 0; Variable 1 - 2 bytes
Var2 equ 2; Variable 2 - 100 bytes
Var3 equ 102; Variable 3 - 4 bytes
my_.str: db ' Upor!',0
......
Now the function
Foo1:
MOV R12,#POF _VARD
MOV R13,#PAG _VARD
CALLS SEG _GetVars,_GetVars
MOV R8,R4
MOV R9,R5
; Now in R8/R9 - indicator to our storage, after the first rotation it will be cleared by zero.
EXTP # 1,R9
MOV [ R8+#.Var1 ],#y2eya; Now the variable Var1=1
MOV R14,# POF(.my_.str)
MOV R15,# PAG(.my_.str); R14/R15 - from where
MOV R12,R8
ADD R12,# Var2
MOV R13,R9; R12/R13 - where
CALLS strcpy; We copy line from ROM into our storage
; But now we cause procedure in the context of the file system
mov R12,SOF(DoFileWrite)
mov R13,SEG(DoFileWrite)
calls FilesysICall
rets
filename: db 'A:\file.file',0
DoFileWrite:
MOV [-R0],R9
MOV [-R0],R8
MOV [-R0],R6
MOV R12,#POF _VARD
MOV R13,#PAG _VARD
CALLS SEG _GetVars,_GetVars ; Is discovered file for final writing
MOV R8,R4
MOV R9,R5
MOV R12,#POF filename
MOV R13,#PAG filename
MOV R14,#010Ah
MOV R15,#0100h
CALLS SEG _FileOpen,_FileOpen ; Открываем файл для дописывания
MOV R6,R4
CMP R6,#0FFFFh
JMPR cc_EQ,_35 ; If it did not grow together itself with the file - nakhuy
MOV R12,R8
MOV R13,R9
ADD R12,#Var2 ; Это наша переменная Var2
CALLS SEG _strlen,_strlen ; We obtain the length of the line
MOV R15,R4
MOV R12,R6
MOV R13,R8
MOV R14,R9
ADD R13,#Var2
CALLS SEG _FileWrite,_FileWrite ; And we write in file Var2
MOV R12,R6
CALLS SEG _FileClose,_FileClose ; We shut
_35:
MOV R12,#POF _VARD
MOV R13,#PAG _VARD
CALLS SEG _FreeVars,_FreeVars ; For example, we free the variables
MOV R6,[R0+]
MOV R8,[R0+]
MOV R9,[R0+]
RETS
For those, who wants to popechatat' on the screen
Code:
//In asm the file of the address of the functions
@EQUP(_STRtoWSTRP,0F19EA0h)
@EQUP(_DrawObject,0C1400Ah)
@EQUP(_PrepDrawObj_type01,0C14A4Ch)
//В си
struct rectXYXY
{
unsigned int X1;
unsigned int Y1;
unsigned int X2;
unsigned int Y2;
};
typedef char far * STR;
typedef unsigned int far * WSTR;
extern STRtoWSTRP(WSTR *,STR);
extern DrawObject(void far *);
extern PrepDrawObj_type01(
void far *drwobj,
struct rectXYXY far *,
unsigned int flag1,
WSTR *,
unsigned int font,
unsigned int flag2);
struct VARS
{
{
WSTR up; //Indicator on unicode the line
unsigned int us[40 ]; //Line itself in unicode, the first word - it is long
char dobj[.0x1A ]; //Object for the drawing
}
//Strictly the printing
{
struct rectXYXY rc;
rc.X1=0; //Rectangle, note, X2 Y2 And not height and the width
rc.Y1=40;
rc.X2=100;
rc.Y2=48;
VP->.up=.VP->.us;
STRtoWSTRP(&.VP->.up,(STR)".Upor"); //Instead of (STR)".Upor" - there can be your line or indicator
//Flag 1 - to pozhozhe, it relates to the rectangle, in which it is sketched
//.0kh20 - inversion
//.0khya0 - to erase everything
//Flag 2 - relates already to the output of the text
//0 - not to center
//1 - to center
//2 - to even on the right edge
//4 - underlining
//8 -????
//.0khy0 - inversion of fonta
//.0kh20:?????
//.0khya0 - strange zhopa
//.0kh80 - not to formatirovat' the text
//.0khy00 - again the inversion
PrepDrawObj_.type01(.VP->.dobj,&.rch,VP->.flag1,&.VP->.up, 0,VP->.flag2); //0 - number of type 0... 11
DrawObject(.VP->.dobj);
}
}
There is this function - CreateDialogWithSoftKeys(.DIALOG_.WSK *, data_.area *,int flag), where E
struct DIALOG_WSK
{
void huge *onKeyPress; //Message handler
void huge *onCreate; //as is
void huge *onClose; //as is
unsigned int datasize; //Min 0x2C
unsigned int tablesize; //Usialy 1
const unsigned int far *table; //&(0xFFF5)
};
Different thing, the caused menu from procedure onKey does not kill my dialogue, voobshchem all very in a cultured way. But there is one but: prompt analog doBack0A for this dialogue. Therefore as I can thus far only by long red button shoot down it.
Yes, another usefulness, approximately each second this dialogue obtains communication Msg==.0xB8, it will go well instead of the timer
int md_onKey(void *data, struct MSG far *Msg)
{
if ((Msg->Msg==KEY_DOWN))
{
switch(Msg->Param[0])
{
case RED_BUTTON:
CloseDialogWithSoftKeys(((int far *)data)[6]); //0EE13D0h
break;
}
}
return(1);
}
struct StatOfFile
{
unsigned int flag1;//=8081 - file, =8041 - folder
unsigned int Zero;
unsigned long filesize;
char Unk[20]; // Dates?
};
extern int GetFileStat(char far* fname, struct StatOfFile far*); //0DFF720h //from MMC_FILE_SYSTEM_proc
extern int FileStat(int file_hndl, struct StatOfFile far*); //0DFF6AAh