flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
LocoDelAssembly 20 Jun 2008, 18:18
A qué llamas "split"? Separar qué cosas?
What do you call "split"? Split what things? |
|||
![]() |
|
AlexP 20 Jun 2008, 22:21
Could he mean a split between the raw assembler and the text parsar?
|
|||
![]() |
|
krackwar 20 Jun 2008, 22:42
LocoDelAssembly wrote: A qué llamas "split"? Separar qué cosas? si tengo "hola|mundo".hago que el caracter separador sea "|" y el resultado final en visual basic seria : variable(1) = hola variable(2)= mundo Gracias por contestar |
|||
![]() |
|
LocoDelAssembly 20 Jun 2008, 23:30
Acabo de mover el thread a la sección de Windows porque me parece que lo que necesitas es una función escrita en Assembly más que una macro que haga esto. De todos modos sería posible una macro pero luego esta no podría trabajar con strings generados en tiempo de ejecución, seguro qué eso es lo que quieres?
I've just moved the thread to the Windows section because I think that what you need is a function written in Assembly rather than a macro that do this. Anyway, it would be possible to make a macro but then it couldn't work on strings generated at run-time, are you sure that this is what you want? Por favor confirma lo que quieres y vere si te puedo escribir el algoritmo. Ya he escrito en inglés lo que has dicho así todos pueden tratar de ayudarte. Please confirm what do you want and I'll see if I can write the algorithm for you. I've already written in English what you said so everybody can try help you. krackwar (not a 1:1 translation so don't try to learn Spanish from this ![]()
|
|||
![]() |
|
krackwar 20 Jun 2008, 23:45
Thank you very much for it translating to Spanish.
You know have reason a macro not me sirviria since I want to occupy it when the this program in functioning. It(he,she) looks it seems to me that this code does what I love this one in C pasaria to asm but not C. http://foro.elhacker.net/programacion_cc/source_split_en_c_100_funcional-t155151.0.html in spanish: Muchas gracias por traducirlo a español . Sabes tienes razón una macro no me sirviria ya que lo quiero ocupar cuando el programa este en funcionamiento.Mira me parece que este code hace lo que quiero esta en C yo lo pasaria a asm pero no se C. http://foro.elhacker.net/programacion_cc/source_split_en_c_100_funcional-t155151.0.html;msg731004#msg731004 |
|||
![]() |
|
LocoDelAssembly 21 Jun 2008, 14:25
Hacia tiempo que no programaba en Assembly así que no te aseguro que esté sin errores. Esto es un programa que obtiene el path de si mismo y luego lo separa por el caracter '\' usando el proc split. Después un bucle muestra string por string mediante un MessageBox y en cada uno verás el string completo en la barra de título y un string del arreglo debajo.
It's been a while that I didn't program in Assembly so I can't assure you that the program is error free. This is a program that gets the path of itself and later split it by the '\' character using the split proc. Later a loop shows string by string via a MessageBox and in each one you'll see the complete string in the title bar and one string of the array below. Code: include 'win32axp.inc' SEPARATOR equ '\' ARRAY_SIZE = 16 BUFF_SIZE = 4096 .data array rd ARRAY_SIZE buff rb BUFF_SIZE .code start: invoke GetModuleFileName, NULL, buff, BUFF_SIZE stdcall split, array, ARRAY_SIZE, buff, (SEPARATOR) ; Parenthesis needed because the stdcall macro will pass a pointer to a ; NULL terminated string otherwise (also fixable using "SEPARATOR = '\'" instead of equ) mov ebx, array mov esi, ARRAY_SIZE jmp .next_entry .output_loop: cmp dword [ebx], NULL je .exit invoke MessageBox, 0, dword [ebx], buff, 0 add ebx, 4 .next_entry: dec esi jns .output_loop .exit: invoke ExitProcess, 0 proc split, aStrPointerArray, arraySize, aString, aSeparator:BYTE push ebx esi edi mov ebx, [aStrPointerArray] mov esi, [aString] jmp .nextString .loop: lodsb cmp al, dl je .addString cmp al, 0 jne .loop .addString: sub esi, edi invoke LocalAlloc, LMEM_FIXED, esi mov [ebx], eax add ebx, 4 mov ecx, esi mov esi, edi mov edi, eax rep movsb cmp byte [edi-1], 0 je .fillRemainderWithNulls mov byte [edi-1], 0 .nextString: mov dl, [aSeparator] mov edi, esi dec [arraySize] jns .loop jmp .exit .storeNull: mov dword [ebx], NULL add ebx, 4 .fillRemainderWithNulls: dec [arraySize] jns .storeNull .exit: pop edi esi ebx ret endp .end start El código de elhacker.net es C++, si no sabes C plano tal vez deberías aprenderlo aunque sea la parte de como se manipulan los tipos de datos porque lo que has visto en Visual Basic no es demasiado útil como base para Assembly. Puedes empezar con Assembly derecho si quieres, pero cuando programes en Assembly no trates de pensar en términos de VB porque esto es un mundo totalmente nuevo. The code from elhacker.net is C++, if you don't know plain C maybe you should learn it, at least how the data types are manipulated because what you have seen in Visual Basic is not very useful as a base for Assembly. You can start straight with Assembly if you want, but when you program in Assembly don't try to think in terms of VB because this is a whole new world. [edit]Removed a check that was unneded and in fact was preventing the addition of zero-sized strings to the array provided them were located at the end of the string to split[/edit] Last edited by LocoDelAssembly on 30 Jun 2008, 17:19; edited 1 time in total |
|||
![]() |
|
krackwar 21 Jun 2008, 21:24
LocoDelAssembly wrote: Hacia tiempo que no programaba en Assembly así que no te aseguro que esté sin errores. Esto es un programa que obtiene el path de si mismo y luego lo separa por el caracter '\' usando el proc split. Después un bucle muestra string por string mediante un MessageBox y en cada uno verás el string completo en la barra de título y un string del arreglo debajo. gracias , me sirvio mucho ,esta 100 porciento funcional . Tu conoces algun manual de asm en español que sea bueno???? in english: Graces(Thanks), this one functional. Your do you know manual of asm in Spanish who is good???? |
|||
![]() |
|
krackwar 22 Jun 2008, 03:17
Hola , nuevamente quiero hacer una pregunta
![]() Encapsulador(el otro programa que no es el stub): Code: format pe gui 4.0 ;Este programa fue codeado por el lab de www.eduhack.es ;mas info en : WWW.eduhack.es/foro ;Se le agradece es especialmente a : ;-Krackwar include 'macro/proc32.inc' ;Incluimos la macro proc32 macro struct name { fields@struct equ name match child parent, name \{ fields@struct equ child,fields@\#parent \} sub@struct equ struc db [val] \{ \common define field@struct .,db,<val> fields@struct equ fields@struct,field@struct \} struc dw [val] \{ \common define field@struct .,dw,<val> fields@struct equ fields@struct,field@struct \} struc dd [val] \{ \common define field@struct .,dd,<val> fields@struct equ fields@struct,field@struct \} struc rb count \{ define field@struct .,db,count dup (?) fields@struct equ fields@struct,field@struct \} struc rd count \{ define field@struct .,dd,count dup (?) fields@struct equ fields@struct,field@struct \} macro db [val] \{ \common \local anonymous define field@struct anonymous,db,<val> fields@struct equ fields@struct,field@struct \} macro dw [val] \{ \common \local anonymous define field@struct anonymous,dw,<val> fields@struct equ fields@struct,field@struct \} macro dd [val] \{ \common \local anonymous define field@struct anonymous,dd,<val> fields@struct equ fields@struct,field@struct \} macro rb count \{ \local anonymous define field@struct anonymous,db,count dup (?) fields@struct equ fields@struct,field@struct \} macro rd count \{ \local anonymous define field@struct anonymous,dd,count dup (?) fields@struct equ fields@struct,field@struct \} macro rp count \{ \local anonymous define field@struct anonymous,dp,count dup (?) fields@struct equ fields@struct,field@struct \} macro struct \{ fields@struct equ fields@struct,,substruct,< sub@struct equ substruct \} virtual at 0 } macro ends { match , sub@struct \{ restruc db,dw,dd restruc rb,rd,rp purge db,dw,dd purge rb,rw,rd purge union,struct match name=,fields,fields@struct \\{ fields@struct equ make@struct name,fields define fields@\\#name fields \\} end virtual \} match any, sub@struct \{ fields@struct equ fields@struct> \} restore sub@struct } macro make@struct name,[field,type,def] { common if $ display 'Error: definition of ',`name,' contains illegal instructions.',0Dh,0Ah err end if local define define equ name forward local sub match , field \{ make@substruct type,name,sub def define equ define,.,sub, \} match any, field \{ define equ define,.#field,type,<def> \} common match fields, define \{ define@struct fields \} } macro define@struct name,[field,type,def] { common local list list equ forward if ~ field eq . name#field type def sizeof.#name#field = $ - name#field else label name#.#type rb sizeof.#type end if local value match any, list \{ list equ list, \} list equ list <value> common sizeof.#name = $ restruc name match values, list \{ struc name value \\{ match any, fields@struct \\\{ fields@struct equ fields@struct,.,name,<values> \\\} match , fields@struct \\\{ label . forward match , value \\\\{ field type def \\\\} match any, value \\\\{ field type value if ~ field eq . rb sizeof.#name#field - ($-field) end if \\\\} common \\\} \\} macro name value \\{ forward match , value \\\{ type def \\\} match any, value \\\{ \\\local ..field ..field = $ type value if ~ field eq . rb sizeof.#name#field - ($-..field) end if \\\} common \\} \} } macro libreria [name,string] { forward local _label if defined name#.redundant if ~ name#.redundant dd RVA name#.lookup,0,0,RVA _label,RVA name#.address end if end if name#.referred = 1 common dd 0,0,0,0,0 forward if defined name#.redundant if ~ name#.redundant _label db string,0 rb RVA $ and 1 end if end if } macro importar name,[label,string] { common if defined name#.referred name#.lookup: forward if used label if string eqtype '' local _label dd RVA _label else dd 80000000h + string end if end if common if $ > name#.lookup name#.redundant = 0 dd 0 else name#.redundant = 1 end if name#.address: forward if used label if string eqtype '' label dd RVA _label else label dd 80000000h + string end if end if common if ~ name#.redundant dd 0 end if forward if used label & string eqtype '' _label dw 0 db string,0 rb RVA $ and 1 end if common end if } macro directory [type,label] { common local max,count count = 0 max = 0 forward count = count + 1 if type > max max = type end if common root@resource dd 0,%t,0,count shl 16 repeat max forward if % = type dd type,80000000h+label-root@resource end if common end repeat } macro resource dir,[id,lang,label] { common dir: local min,max,count,current forward min = id max = id common count = 0 forward count = count + 1 if id < min min = id else if id > max max = id end if common dd 0,%t,0,count shl 16 repeat max-min+1 current = $ forward if min+%-1 = id if current = $ dd id,80000000h+label#.directory-root@resource end if end if common end repeat repeat max-min+1 current = $ forward if min+%-1 = id if current = $ label#.directory dd 0,%t,0,10000h,lang,label-root@resource count = 1 else dd lang,label-root@resource count = count + 1 end if end if label#.resid = id common local x,y,z,v1,v2 if count > 1 store word count at current+0Eh x = count shr 1 while x > 0 y = x while y < count z = y while z-x >= 0 load v1 dword from current+10h+z*8 load v2 dword from current+10h+(z-x)*8 if v1<v2 store dword v1 at current+10h+(z-x)*8 store dword v2 at current+10h+z*8 load v1 dword from current+10h+z*8+4 load v2 dword from current+10h+(z-x)*8+4 store dword v1 at current+10h+(z-x)*8+4 store dword v2 at current+10h+z*8+4 else break end if z = z-x end while y = y+1 end while x = x shr 1 end while end if end repeat } macro dialogo label,title,x,y,cx,cy,style,exstyle,menu,fontname,fontsize { local data,size,items label dd RVA data,size,0,0 data dd style or 0040h ,exstyle +0 dw items,x,y,cx,cy if menu+0 <> 0 dw 0FFFFh end if du menu+0,0,title,0 if fontname eq du 8,'MS Sans Serif',0 else du fontsize+0,fontname,0 end if align 4 dialog_size equ size = $ - data dialog_items equ items = dialog_items_counter dialog_items_counter = 0 } macro objetosdeldialogo class,title,id,x,y,cx,cy,style,exstyle { dd style or WS_CHILD,exstyle +0 dw x,y,cx,cy,id if class eq 'boton' dw 0FFFFh,80h else if class eq 'texto' dw 0FFFFh,81h else if class eq 'estatico' dw 0FFFFh,82h else du class,0' end if if title eqtype 0 dw 0FFFFh,title else du title,0 end if dw 0 align 4 dialog_items_counter = dialog_items_counter + 1 } macro resdata label { local data,size label dd RVA data,size,0,0 data = $ ressize equ size = $ - data} macro api [name] { if used name label name dword at name#A end if } WS_CHILD = 040000000h struct OPENFILENAME lStructSize dd ? hwndOwner dd ? hInstance dd ? lpstrFilter dd ? lpstrCustomFilter dd ? nMaxCustFilter dd ? nFilterIndex dd ? lpstrFile dd ? nMaxFile dd ? lpstrFileTitle dd ? nMaxFileTitle dd ? lpstrInitialDir dd ? lpstrTitle dd ? Flags dd ? nFileOffset dw ? nFileExtension dw ? lpstrDefExt dd ? lCustData dd ? lpfnHook dd ? lpTemplateName dd ? ends IDOK = 100 Archivo = 101 invoke GetModuleHandle,0 invoke DialogBoxParam,eax,37,0,DialogProc1,0 invoke InitCommonControls proc DialogProc1 hwnddlg,msg,wparam,l push ebx esi edi cmp [msg],0110h je .processed cmp [msg],0010h je .wmclose cmp [msg],0111h je .comparar xor eax,eax jmp .finish .comparar: mov eax,[wparam] cmp eax,IDOK je .eliminar cmp eax,IDAB je .About cmp eax,IDCRE je .Crear jmp .finish .Crear: invoke GetDlgItemText,[hwnddlg],Archivo,Truta,100h cmp eax,0 jne .Sitext invoke MessageBox,0,mensaje3,0,000010h jmp .finish .Sitext: invoke MessageBox,0,mensaje4,tituloM,000004h cmp eax,6 jne .no .si: mov [Coculta],'1' jmp .SiB .no: mov [Coculta],'0' .SiB: invoke MessageBox,0,Mensaje1,0x000,0 mov [CD.lStructSize], 76 mov [CD.lpstrFilter], Filtro2 mov [CD.lpstrFile], rutaSTUB mov [CD.nMaxFile], 256 invoke GetOpenFileName, CD cmp eax, 0 jne .sistub invoke MessageBox,0,mensaje3,0,000010h jmp .finish .sistub: invoke MessageBox,0,Mensaje2,0,0 mov [CD.lStructSize], 76 mov [CD.lpstrFilter], Filtro2 mov [CD.lpstrFile], archG mov [CD.nMaxFile], 256 invoke GetSaveFileNameA,CD cmp eax,0 jne .Siarchg invoke MessageBox,0,mensaje3,0,000010h jmp .finish .Siarchg: invoke CreateFile,rutaSTUB, 80000000h, 0, 0, 3, 0, 0 mov [handleS],eax invoke GetFileSize, [handleS], 0 mov [tamS], eax invoke LocalAlloc, 0000h + 0040h, [tamS] mov [stub], eax invoke ReadFile, [handleS], [stub], [tamS], bUsados, 0 invoke CloseHandle, [handleS] invoke CreateFile,Truta, 80000000h, 0, 0, 3, 0, 0 mov [handle1],eax invoke GetFileSize, [handle1], 0 mov [tamarch1], eax invoke LocalAlloc, 0000h + 0040h, [tamarch1] mov [BuffAr1], eax invoke ReadFile, [handle1], [BuffAr1], [tamarch1], bUsados, 0 invoke CloseHandle, [handle1] invoke CreateFileA,archG, 40000000h, 0, 0,2, 0, 0 mov [handle2], eax invoke lstrlen, Firma mov [tamañoF],eax ;Escibimos el archivo invoke WriteFile, [handle2], [stub], [tamS], bEscritos,0 invoke WriteFile, [handle2], Firma, [tamañoF], bEscritos, 0 invoke lstrlen, [Coculta] invoke WriteFile, [handle2], [Coculta],eax, bEscritos, 0 invoke WriteFile, [handle2], Firma, [tamañoF], bEscritos, 0 invoke WriteFile, [handle2], [BuffAr1], [tamarch1], bEscritos, 0 ; "Cerramos" el archivo creado invoke CloseHandle, [handle2] jmp .finish jmp .processed .About: invoke GetModuleHandle,0 invoke DialogBoxParam,eax,38,0,DialogProc2,0 jmp .processed .eliminar: mov [CD.lStructSize], 76 mov [CD.lpstrFilter], Filtro mov [CD.lpstrFile], buffRuta mov [CD.nMaxFile], 256 invoke GetOpenFileName, CD call [GetForegroundWindow] invoke GetDlgItem,eax,Archivo invoke SendMessage,eax,000Ch,0,buffRuta jmp .processed .wmclose: invoke EndDialog,[hwnddlg],0 invoke ExitProcess,0 .processed: mov eax,1 .finish: pop edi esi ebx ret endp ;About proc DialogProc2 hwnddlg,msg,wparam,l push ebx esi edi cmp [msg],0110h je .processed cmp [msg],0010h je .wmclose xor eax,eax jmp .finish .wmclose: invoke EndDialog,[hwnddlg],0 .processed: mov eax,1 .finish: pop edi esi ebx ret endp ;---------------------------------------------------------------------- ;variables mensaje4 db 'Deseas que el bat se ejecute con la consola oculta?' ,0 mensaje3 db 'Elige algun archivo',0 Mensaje1 db 'Seleccione la ruta del stub' , 0 Mensaje2 db 'Seleccione la ruta donde generar el .exe' , 0 bUsados dd ? BuffAr1 dd ? tituloM db '????',0 BuffAr2 dd ? tamarch1 dd ? tamarch2 dd ? handle2 dd ? handle1 dd ? rutaSTUB rb 260 handleS dd ? tamS dd ? stub dd ? buffRuta rb 260 archG rb 260 tamañoF dd ? Firma dd 'ª' bEscritos dd ? aRcH rd 100h Coculta dd ? CD OPENFILENAME ? Filtro db 'Archivos por lotes (*.bat)',0, '*.bat',0 Filtro2 db 'Archivos Ejecutables (*.exe)',0, '*.exe',0 Truta rd 90h data import libreria kernel32,'KERNEL32.DLL',\ user32,'USER32.DLL',\ estiloXP,'comctl32.DLL',\ comdlg32,'COMDLG32.DLL' importar kernel32 ,\ CreateFileA,'CreateFileA',\ CreateFileW,'CreateFileW',\ GetModuleHandleA,'GetModuleHandleA',\ GetModuleHandleW,'GetModuleHandleW',\ lstrlenA,'lstrlenA',\ lstrlenW,'lstrlenW',\ LocalAlloc,'LocalAlloc',\ ReadFile,'ReadFile',\ GetFileSize,'GetFileSize',\ CloseHandle,'CloseHandle',\ WriteFile,'WriteFile',\ ExitProcess,'ExitProcess' api CreateFile,\ GetModuleHandle ,\ lstrlen importar user32,\ MessageBoxA,'MessageBoxA',\ MessageBoxW,'MessageBoxW' ,\ DialogBoxParamA,'DialogBoxParamA',\ DialogBoxParamW,'DialogBoxParamW' ,\ GetDlgItemTextA,'GetDlgItemTextA',\ GetDlgItemTextW,'GetDlgItemTextW' ,\ SendMessageA,'SendMessageA',\ SendMessageW,'SendMessageW',\ GetForegroundWindow,'GetForegroundWindow',\ EndDialog,'EndDialog',\ GetDlgItem,'GetDlgItem' api MessageBox,\ DialogBoxParam,\ GetDlgItemText,\ SendMessage importar comdlg32,\ GetOpenFileNameA,'GetOpenFileNameA',\ GetOpenFileNameW,'GetOpenFileNameW',\ GetSaveFileNameA,'GetSaveFileNameA',\ GetSaveFileNameW,'GetSaveFileNameW' api GetOpenFileName,\ GetSaveFileName importar estiloXP,InitCommonControls,'InitCommonControls' end data data resource ;Empesamos el data resource ID_LOGO = 11 IDAB = 7 IDCRE = 8 directory 5,dialogs,\ 24,manifest resource manifest,\ 1, 00h, winxp resource dialogs,\ 37,0Ah+01h shl 10,VENTANA,\ 38,0Ah+01h shl 10,VENTANA2 ;Resource de la ventana principal dialogo VENTANA,'SHNI BATTOEXE 2.0 - by www.eduhack.es',200,100,230,45,000C00000h+080000000h+000080000h+0080h+000020000h objetosdeldialogo 'texto','',Archivo,20,1,160,13,010000000h+000800000h+000010000h+0080h objetosdeldialogo 'boton','Examinar',IDOK,20,15,80,15,010000000h+000010000h+0001h objetosdeldialogo 'boton' ,'&Crear',IDCRE,100,15,80,15,010000000h+000010000h+0001h objetosdeldialogo 'boton','&About',IDAB,60,29,80,15,010000000h+000010000h+0001h dialog_items dialog_size ;Resource de la ventana del about dialogo VENTANA2,'Acerca de : ',200,90,240,50,000C00000h+080000000h +000080000h objetosdeldialogo 'estatico','&Este programa fue fabricado en asm(fasm) &por www.eduhack.es en su lab',1,1,1,400,8,010000000h objetosdeldialogo 'estatico','Con especial colaboración de :',1,-1,20,100,8,010000000h objetosdeldialogo 'estatico','-Krackwar',70,1,30,148,8,010000000h dialog_items dialog_size resdata winxp db '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>',13,10 db '<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">',13,10 db '<assemblyIdentity',13,10 db 'version="2.0.0.0"',13,10 db 'processorArchitecture="X86"',13,10 db 'name="CompanyName.ProductName.Application"',13,10 db 'type="win32"',13,10 db '/>',13,10 db '<description>Esta aplicacion comvierte un .bat a .exe</description>',13,10 db '<dependency>',13,10 db '<dependentAssembly>',13,10 db '<assemblyIdentity',13,10 db 'type="win32"',13,10 db 'name="Microsoft.Windows.Common-Controls"',13,10 db 'version="6.0.0.0"',13,10 db 'processorArchitecture="X86"',13,10 db 'publicKeyToken="6595b64144ccf1df"',13,10 db 'language="*"',13,10 db '/>',13,10 db '</dependentAssembly>',13,10 db '</dependency>',13,10 db '</assembly>' ressize align 4 end data Stub: Code: format PE gui include 'win32a.inc' SEPARATOR equ 'ª' ARRAY_SIZE = 16 BUFF_SIZE = 4096 ;-------------------------------------------------------------------------------------------------------------------------------------------------- stdcall Obtener_ruta ;Llamamos a la función Obtener_ruta para obtener nuestra ruta mov [Miruta],eax ; Nuestra ruta la guardamos en [Miruta] ;------------------------------------------------------------------------- invoke CreateFile, [Miruta],80000000h, 0, 0, 3, 0, 0 mov [Mihandle],eax ;Nuestro handle lo guardamos en [Mihandle] ;--------------------------------------------------------------------------- invoke GetFileSize,[Mihandle], 0 mov [Mitamaño],eax;Guardamos el tamaño de nuestro archivo en [Mitamaño] ;--------------------------------------------------------------------------- invoke GlobalAlloc, 0000h + 0040h, [Mitamaño] mov [Mibuffer],eax invoke ReadFile, [Mihandle], [Mibuffer], [Mitamaño], bytesLeidos, 0 invoke CloseHandle, [Mihandle] ;--------------------------------------------------------------------------- stdcall split, array, ARRAY_SIZE,dword[Mibuffer], (SEPARATOR) ; Parenthesis needed because the stdcall macro will pass a pointer to a ; NULL terminated string otherwise (also fixable using "SEPARATOR = '\'" instead of equ) mov ebx, array mov esi, ARRAY_SIZE add ebx, 4 add ebx, 4 invoke CreateFile,Miruta2, 40000000h, 0, 0,2, 0, 0 mov [handle2], eax ;Escibimos el archivo invoke WriteFile, [handle2],dword[ebx],[Mitamaño] , bEscritos,0 ; "Cerramos" el archivo creado invoke CloseHandle, [handle2] ;--------------------------------------------------------------------------- ccall salir array rd ARRAY_SIZE Miruta dd ? ;Variable donde se guardara nuestra ruta Mihandle dd ? ;Variable donde se guardara nuestro handle Mitamaño dd ? ;Variable donde se guardara nuestro tamaño Mibuffer dd ? ;Variable donde se guardara nuestro buffer bytesLeidos dd ? bEscritos dd ? handle2 dd ? Miruta2 db 'c:\archivocreado.bat',0 proc salir invoke ExitProcess,0 endp proc Obtener_ruta ;Función para obtener nuestra ruta invoke GlobalAlloc, 0000h + 0040h, 260 push eax invoke GetModuleFileName, 0, eax, 260 pop eax ret endp proc split, aStrPointerArray, arraySize, aString, aSeparator:BYTE push ebx esi edi mov ebx, [aStrPointerArray] mov esi, [aString] jmp .nextString .loop: lodsb cmp al, dl je .addString cmp al, 0 jne .loop lea eax, [esi-1] cmp eax, edi je .fillRemainderWithNulls .addString: sub esi, edi invoke LocalAlloc, LMEM_FIXED, esi mov ecx, esi mov esi, edi mov edi, eax mov [ebx], eax add ebx, 4 rep movsb cmp byte [edi-1], 0 je .fillRemainderWithNulls mov byte [edi-1], 0 .nextString: mov dl, [aSeparator] mov edi, esi dec [arraySize] jns .loop jmp .exit .storeNull: mov dword [ebx], NULL add ebx, 4 .fillRemainderWithNulls: dec [arraySize] jns .storeNull .exit: pop edi esi ebx ret endp data import library kernel32,'KERNEL32.DLL',\ user32,'USER32.dll' import kernel32 ,\ GetModuleFileNameA,'GetModuleFileNameA',\ GetModuleFileNameW,'GetModuleFileNameW',\ CreateFileA,'CreateFileA',\ CreateFileW,'CreateFileW',\ ReadFile,'ReadFile',\ WriteFile,'WriteFile',\ ExitProcess,'ExitProcess',\ GetFileSize,'GetFileSize',\ CloseHandle,'CloseHandle',\ LocalAlloc,'LocalAlloc' ,\ GlobalAlloc,'GlobalAlloc' api GetModuleFileName,\ CreateFile import user32,MessageBox,'MessageBoxA' end data |
|||
![]() |
|
LocoDelAssembly 30 Jun 2008, 17:36
Code: stdcall split, array, ARRAY_SIZE,dword[Mibuffer], (SEPARATOR) ; Parenthesis needed because the stdcall macro will pass a pointer to a ; NULL terminated string otherwise (also fixable using "SEPARATOR = '\'" instead of equ) mov ebx, array mov esi, ARRAY_SIZE add ebx, 4 add ebx, 4 invoke CreateFile,Miruta2, 40000000h, 0, 0,2, 0, 0 mov [handle2], eax ;Escibimos el archivo invoke WriteFile, [handle2],dword[ebx],[Mitamaño] , bEscritos,0 ; "Cerramos" el archivo creado invoke CloseHandle, [handle2] Estás accediendo al tercer string del array sin ver primero si este existe realmente y en el WriteFile estás mandando a escribir [MiTamaño] bytes cuando debería ser el tamaño del tercer string del array. You're accessing the third string of the array without looking first if it actually exists and in the WriteFile you are specifying [MiTamaño] bytes to write when it should be the size of the third string of the array. Otro error es que split espera que le envies un string terminado en NULL pero tu le envias algo leído de disco lo cual tal vez no termina en NULL con lo cual el string quedó abierto (o cerrado prematuramente si el archivo contiene más de un cero o el cero no está al final del archivo). Another mistake is that split expects that you send to it a NULL terminated string but you send something read from disk instead which maybe is not NULL terminated so the string ended up open (or closed prematurely if the file contains more than a zero or the zero is not at the end of file). |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.