2012-11-26 19:26:15 +04:00
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
// strcmp( ESI, EDI)
|
|
|
|
|
// strlen( EDI)
|
2012-12-15 04:16:06 +04:00
|
|
|
|
// strcpy( EDI, ESI) --- 0 if ==
|
2012-11-26 19:26:15 +04:00
|
|
|
|
// strcat( EDI, ESI)
|
2013-03-11 22:16:24 +04:00
|
|
|
|
// strchr( ESI,BL) --- find first BL
|
|
|
|
|
// strrchr( ESI,BL) --- find last BL
|
2012-11-26 19:26:15 +04:00
|
|
|
|
// strstr( EBX, EDX)
|
|
|
|
|
// itoa( ESI)
|
|
|
|
|
// atoi( EAX)
|
|
|
|
|
// strupr( ESI)
|
2012-12-15 04:16:06 +04:00
|
|
|
|
// strlwr( ESI) --- kyrillic symbols may not work
|
2012-11-26 19:26:15 +04:00
|
|
|
|
// strttl( EDX)
|
|
|
|
|
// strtok( ESI)
|
2013-04-05 09:35:28 +04:00
|
|
|
|
// strtrim( ESI) --- removes "blank" characters (\r, \n and space)
|
2013-04-04 21:07:38 +04:00
|
|
|
|
// chrnum(dword searchin, char symbol)
|
2012-12-15 04:16:06 +04:00
|
|
|
|
// strcpyb(dword searchin, copyin, startstr, endstr) --- copy string between strings
|
2012-12-19 21:37:24 +04:00
|
|
|
|
// strnumb(dword searchin, startstr, endstr) --- get number between strings
|
2012-11-26 19:26:15 +04:00
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
inline fastcall signed int strcmp( ESI, EDI)
|
|
|
|
|
{
|
|
|
|
|
loop()
|
|
|
|
|
{
|
|
|
|
|
IF (DSBYTE[ESI]<DSBYTE[EDI]) RETURN -1;
|
|
|
|
|
IF (DSBYTE[ESI]>DSBYTE[EDI]) RETURN 1;
|
|
|
|
|
IF (DSBYTE[ESI]=='\0') RETURN 0;
|
|
|
|
|
ESI++;
|
|
|
|
|
EDI++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline fastcall signed int strncmp( ESI, EDI, ECX)
|
|
|
|
|
{
|
|
|
|
|
asm {
|
|
|
|
|
MOV EBX, EDI
|
|
|
|
|
XOR EAX, EAX
|
|
|
|
|
MOV EDX, ECX
|
|
|
|
|
OR ECX, ECX
|
|
|
|
|
JE L1
|
|
|
|
|
REPNE SCASB
|
|
|
|
|
SUB EDX, ECX
|
|
|
|
|
MOV ECX, EDX
|
|
|
|
|
MOV EDI, EBX
|
|
|
|
|
XOR EBX, EBX
|
|
|
|
|
REPE CMPSB
|
|
|
|
|
MOV AL, DSBYTE[ ESI-1]
|
|
|
|
|
MOV BL, DSBYTE[ EDI-1]
|
|
|
|
|
SUB EAX, EBX
|
|
|
|
|
L1:
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline fastcall unsigned int strlen( EDI)
|
|
|
|
|
{
|
|
|
|
|
$xor eax, eax
|
|
|
|
|
$mov ecx, -1
|
|
|
|
|
$REPNE $SCASB
|
|
|
|
|
EAX-=2+ECX;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2013-03-11 22:16:24 +04:00
|
|
|
|
inline fastcall void strcpy( EDI, ESI)
|
2012-11-26 19:26:15 +04:00
|
|
|
|
{
|
|
|
|
|
$cld
|
2012-12-15 04:16:06 +04:00
|
|
|
|
L2:
|
2012-11-26 19:26:15 +04:00
|
|
|
|
$lodsb
|
|
|
|
|
$stosb
|
|
|
|
|
$test al,al
|
2012-12-15 04:16:06 +04:00
|
|
|
|
$jnz L2
|
2012-11-26 19:26:15 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2012-12-19 21:37:24 +04:00
|
|
|
|
inline fastcall int strlcpy(dword ESI, EDI, EBX)
|
|
|
|
|
{
|
|
|
|
|
EDX=0;
|
|
|
|
|
do {
|
|
|
|
|
DSBYTE[ESI]=DSBYTE[EDI];
|
|
|
|
|
ESI++;
|
|
|
|
|
EDI++;
|
|
|
|
|
EDX++;
|
|
|
|
|
if (EDX==EBX) { DSBYTE[ESI]='\0'; return -1;}
|
|
|
|
|
} while(DSBYTE[EDI-1]!='\0');
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-05 09:35:28 +04:00
|
|
|
|
inline fastcall strtrim( ESI)
|
|
|
|
|
{
|
|
|
|
|
EDI = ESI;
|
|
|
|
|
do{
|
|
|
|
|
AL=DSBYTE[EDI];
|
|
|
|
|
if (AL != '\32') && (AL != '\13') && (AL != '\10')
|
|
|
|
|
{
|
|
|
|
|
DSBYTE[ESI]=AL;
|
|
|
|
|
ESI++;
|
|
|
|
|
}
|
|
|
|
|
EDI++;
|
|
|
|
|
}while(AL!=0);
|
|
|
|
|
DSBYTE[ESI] = '\0';
|
|
|
|
|
}
|
2012-12-19 21:37:24 +04:00
|
|
|
|
|
|
|
|
|
|
2013-03-11 22:16:24 +04:00
|
|
|
|
inline fastcall void strcat( EDI, ESI)
|
2012-11-26 19:26:15 +04:00
|
|
|
|
{
|
|
|
|
|
asm {
|
|
|
|
|
mov ebx, edi
|
|
|
|
|
xor ecx, ecx
|
|
|
|
|
xor eax, eax
|
|
|
|
|
dec ecx
|
|
|
|
|
repne scasb
|
|
|
|
|
dec edi
|
|
|
|
|
mov edx, edi
|
|
|
|
|
mov edi, esi
|
|
|
|
|
xor ecx, ecx
|
|
|
|
|
xor eax, eax
|
|
|
|
|
dec ecx
|
|
|
|
|
repne scasb
|
|
|
|
|
xor ecx, 0ffffffffh
|
|
|
|
|
mov edi, edx
|
|
|
|
|
mov edx, ecx
|
|
|
|
|
mov eax, edi
|
|
|
|
|
shr ecx, 2
|
|
|
|
|
rep movsd
|
|
|
|
|
mov ecx, edx
|
|
|
|
|
and ecx, 3
|
|
|
|
|
rep movsb
|
|
|
|
|
mov eax, ebx
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-11 22:16:24 +04:00
|
|
|
|
inline fastcall void chrcat(ESI, BL)
|
|
|
|
|
{
|
|
|
|
|
EDI = strlen(ESI);
|
|
|
|
|
ESBYTE[ESI+EDI] = BL;
|
|
|
|
|
ESBYTE[ESI+EDI+1] = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2012-12-19 21:37:24 +04:00
|
|
|
|
|
|
|
|
|
inline fastcall signed int strchr( ESI,BL)
|
|
|
|
|
{
|
|
|
|
|
int jj=0;
|
|
|
|
|
do{
|
|
|
|
|
jj++;
|
|
|
|
|
$lodsb
|
|
|
|
|
IF(AL==BL) return jj;
|
|
|
|
|
} while(AL!=0);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline fastcall signed int strrchr( ESI,BL)
|
|
|
|
|
{
|
|
|
|
|
int jj=0, last=0;
|
|
|
|
|
do{
|
|
|
|
|
jj++;
|
|
|
|
|
$lodsb
|
|
|
|
|
IF(AL==BL) last=jj;
|
|
|
|
|
} while(AL!=0);
|
|
|
|
|
return last;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int chrnum(dword searchin, char symbol)
|
|
|
|
|
{
|
|
|
|
|
int num = 0;
|
|
|
|
|
while(DSBYTE[searchin])
|
|
|
|
|
{
|
|
|
|
|
if (DSBYTE[searchin] == symbol) num++;
|
|
|
|
|
searchin++;
|
|
|
|
|
}
|
|
|
|
|
return num;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2013-03-11 22:16:24 +04:00
|
|
|
|
inline fastcall signed int strstr( EBX, EDX)
|
2012-12-19 21:37:24 +04:00
|
|
|
|
{
|
|
|
|
|
asm {
|
|
|
|
|
MOV EDI, EDX
|
|
|
|
|
XOR ECX, ECX
|
|
|
|
|
XOR EAX, EAX
|
|
|
|
|
DEC ECX
|
|
|
|
|
REPNE SCASB
|
|
|
|
|
NOT ECX
|
|
|
|
|
DEC ECX
|
|
|
|
|
JE LS2
|
|
|
|
|
MOV ESI, ECX
|
|
|
|
|
XOR ECX, ECX
|
|
|
|
|
MOV EDI, EBX
|
|
|
|
|
DEC ECX
|
|
|
|
|
REPNE SCASB
|
|
|
|
|
NOT ECX
|
|
|
|
|
SUB ECX, ESI
|
|
|
|
|
JBE LS2
|
|
|
|
|
MOV EDI, EBX
|
|
|
|
|
LEA EBX, DSDWORD[ ESI-1]
|
|
|
|
|
LS1: MOV ESI, EDX
|
|
|
|
|
LODSB
|
|
|
|
|
REPNE SCASB
|
|
|
|
|
JNE LS2
|
|
|
|
|
MOV EAX, ECX
|
|
|
|
|
PUSH EDI
|
|
|
|
|
MOV ECX, EBX
|
|
|
|
|
REPE CMPSB
|
|
|
|
|
POP EDI
|
|
|
|
|
MOV ECX, EAX
|
|
|
|
|
JNE LS1
|
|
|
|
|
LEA EAX, DSDWORD[ EDI-1]
|
|
|
|
|
JMP SHORT LS3
|
|
|
|
|
LS2: XOR EAX, EAX
|
|
|
|
|
LS3:
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dword strstri(dword searchin, usestr_s)
|
|
|
|
|
{
|
|
|
|
|
dword usestr_e = usestr_s;
|
|
|
|
|
char si, ue;
|
|
|
|
|
|
|
|
|
|
while(DSBYTE[searchin])
|
|
|
|
|
{
|
|
|
|
|
si = DSBYTE[searchin];
|
|
|
|
|
ue = DSBYTE[usestr_e];
|
|
|
|
|
if (si>='A') && (si<='Z') si +=32;
|
|
|
|
|
if (ue>='A') && (ue<='Z') ue +=32;
|
|
|
|
|
if (si == ue) usestr_e++; else usestr_e = usestr_s;
|
|
|
|
|
searchin++;
|
|
|
|
|
if (DSBYTE[usestr_e]=='\0') return searchin;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2013-02-04 17:15:13 +04:00
|
|
|
|
void strcpyb(dword search_in, copyin, startstr, endstr)
|
2012-12-19 21:37:24 +04:00
|
|
|
|
{
|
|
|
|
|
dword startp, endp;
|
2013-02-04 17:15:13 +04:00
|
|
|
|
startp = strstr(search_in, startstr) + strlen(startstr);
|
|
|
|
|
endp = strstri(startp, endstr);
|
2012-12-19 21:37:24 +04:00
|
|
|
|
if (startp==endp) return;
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
DSBYTE[copyin] = DSBYTE[startp];
|
|
|
|
|
copyin++;
|
|
|
|
|
startp++;
|
|
|
|
|
}
|
|
|
|
|
while (startp<endp);
|
|
|
|
|
DSBYTE[copyin] = '\0';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2012-12-06 11:49:06 +04:00
|
|
|
|
/*void strcat(char *to, char *from) //<2F><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
while(*to) to++;
|
|
|
|
|
while(*from)
|
|
|
|
|
{
|
|
|
|
|
*to = *from;
|
|
|
|
|
to++;
|
|
|
|
|
from++;
|
|
|
|
|
}
|
|
|
|
|
*to = '\0';
|
|
|
|
|
}*/
|
|
|
|
|
|
2012-11-26 19:26:15 +04:00
|
|
|
|
dword itoa( ESI)
|
|
|
|
|
{
|
|
|
|
|
unsigned char buffer[11];
|
2012-12-15 19:56:24 +04:00
|
|
|
|
$pusha
|
|
|
|
|
|
2012-11-26 19:26:15 +04:00
|
|
|
|
EDI = #buffer;
|
|
|
|
|
ECX = 10;
|
|
|
|
|
if (ESI < 0)
|
|
|
|
|
{
|
|
|
|
|
$mov al, '-'
|
|
|
|
|
$stosb
|
|
|
|
|
$neg esi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$mov eax, esi
|
|
|
|
|
$push -'0'
|
2012-12-15 04:16:06 +04:00
|
|
|
|
F2:
|
2012-11-26 19:26:15 +04:00
|
|
|
|
$xor edx, edx
|
|
|
|
|
$div ecx
|
|
|
|
|
$push edx
|
|
|
|
|
$test eax, eax
|
2012-12-15 04:16:06 +04:00
|
|
|
|
$jnz F2
|
|
|
|
|
F3:
|
2012-11-26 19:26:15 +04:00
|
|
|
|
$pop eax
|
|
|
|
|
$add al, '0'
|
|
|
|
|
$stosb
|
2012-12-15 04:16:06 +04:00
|
|
|
|
$jnz F3
|
2012-11-26 19:26:15 +04:00
|
|
|
|
|
|
|
|
|
$mov al, '\0'
|
|
|
|
|
$stosb
|
2012-12-19 21:37:24 +04:00
|
|
|
|
|
|
|
|
|
$popa
|
2012-12-15 19:56:24 +04:00
|
|
|
|
return #buffer;
|
2012-11-26 19:26:15 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline fastcall dword atoi( EDI)
|
|
|
|
|
{
|
2012-12-19 21:37:24 +04:00
|
|
|
|
$push ebx
|
|
|
|
|
$push esi
|
2012-11-26 19:26:15 +04:00
|
|
|
|
ESI=EDI;
|
2012-12-19 21:37:24 +04:00
|
|
|
|
while (DSBYTE[ESI]==' ') ESI++;
|
|
|
|
|
if (DSBYTE[ESI]=='-') ESI++;
|
2012-11-26 19:26:15 +04:00
|
|
|
|
EAX=0;
|
2012-12-19 21:37:24 +04:00
|
|
|
|
while (DSBYTE[ESI]>='0') && (DSBYTE[ESI]<='9')
|
|
|
|
|
{
|
|
|
|
|
$xor ebx, ebx
|
|
|
|
|
EBX = DSBYTE[ESI]-'0';
|
|
|
|
|
EAX *= 10;
|
|
|
|
|
EAX += EBX;
|
2012-11-26 19:26:15 +04:00
|
|
|
|
ESI++;
|
2012-12-19 21:37:24 +04:00
|
|
|
|
}
|
|
|
|
|
IF (DSBYTE[EDI]=='-') -EAX;
|
|
|
|
|
$pop esi
|
|
|
|
|
$pop ebx
|
2012-11-26 19:26:15 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline fastcall strupr( ESI)
|
|
|
|
|
{
|
|
|
|
|
do{
|
|
|
|
|
AL=DSBYTE[ESI];
|
|
|
|
|
IF(AL>='a')IF(AL<='z')DSBYTE[ESI]=AL&0x5f;
|
|
|
|
|
IF (AL>=160) && (AL<=175) DSBYTE[ESI] = AL - 32; //<2F>-<2D>
|
|
|
|
|
IF (AL>=224) && (AL<=239) DSBYTE[ESI] = AL - 80; //<2F>-<2D>
|
|
|
|
|
ESI++;
|
|
|
|
|
}while(AL!=0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline fastcall strlwr( ESI)
|
|
|
|
|
{
|
|
|
|
|
do{
|
|
|
|
|
$LODSB
|
|
|
|
|
IF(AL>='A')&&(AL<='Z'){
|
|
|
|
|
AL+=0x20;
|
|
|
|
|
DSBYTE[ESI-1]=AL;
|
|
|
|
|
CONTINUE;
|
|
|
|
|
}
|
|
|
|
|
}while(AL!=0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline fastcall strttl( EDX)
|
|
|
|
|
{
|
|
|
|
|
AL=DSBYTE[EDX];
|
|
|
|
|
IF(AL>='a')&&(AL<='z')DSBYTE[EDX]=AL&0x5f;
|
|
|
|
|
IF (AL>=160) && (AL<=175) DSBYTE[EDX] = AL - 32; //<2F>-<2D>
|
|
|
|
|
IF (AL>=224) && (AL<=239) DSBYTE[EDX] = AL - 80; //<2F>-<2D>
|
|
|
|
|
do{
|
|
|
|
|
EDX++;
|
|
|
|
|
AL=DSBYTE[EDX];
|
|
|
|
|
IF(AL>='A')&&(AL<='Z'){DSBYTE[EDX]=AL|0x20; CONTINUE;}
|
|
|
|
|
IF(AL>='<EFBFBD>')&&(AL<='<EFBFBD>')DSBYTE[EDX]=AL|0x20; //<2F>-<2D>
|
|
|
|
|
IF (AL>=144) && (AL<=159) DSBYTE[EDX] = AL + 80; //<2F>-<2D>
|
|
|
|
|
}while(AL!=0);
|
|
|
|
|
}
|
|
|
|
|
|
2012-12-19 21:37:24 +04:00
|
|
|
|
void debugi(dword d_int)
|
2012-12-15 04:16:06 +04:00
|
|
|
|
{
|
2012-12-19 21:37:24 +04:00
|
|
|
|
char tmpch[11];
|
|
|
|
|
strcpy(#tmpch, itoa(d_int));
|
|
|
|
|
debug(#tmpch);
|
2012-12-15 04:16:06 +04:00
|
|
|
|
}
|
|
|
|
|
|
2013-03-11 22:16:24 +04:00
|
|
|
|
|
2012-11-26 19:26:15 +04:00
|
|
|
|
|
|
|
|
|
#define strncpy strcpyn
|
|
|
|
|
#define strnmov strmovn
|
|
|
|
|
#define stricmp strcmpi
|
|
|
|
|
#define strcmpn strncmp
|
2013-04-12 04:15:39 +04:00
|
|
|
|
|