News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Hard times are coming for me.

Started by xandaz, December 05, 2021, 05:14:08 AM

Previous topic - Next topic

xandaz

   This simple lines of code crash on ShellExecuteA. invoke ClearMemory,addr TempBuffer,sizeof TempBuffer
invoke SendMessage,hMdi,WM_MDIGETACTIVE,0,0
invoke GetWindowTextA,eax,addr TempBuffer,sizeof TempBuffer
invoke ExtractFileNameA,addr TempBuffer
              invoke  GetCurrentDirectoryA,sizeof szInitialDir,addr szInitialDir
invoke ShellExecuteA,hWnd,addr szShellOpenA,addr szObj2DllA,addr TempBuffer,\
addr szInitialDir,SW_SHOWNORMAL

   I've tried UNICODE and ANSI versions of it but it just usually crashes. I know the code presented isn't enough to undertand what error is happening but turns out the code has gone long and complex to post. Just wondering if someone here been through a similar issue. Thanks in advance!

xandaz

   This code, when not executed allows the application to run ok.BuildBatchLink PROC

local hBatch:DWORD

invoke CreateFileA,addr szObj2DllA,GENERIC_WRITE,\
FILE_SHARE_WRITE,0,CREATE_ALWAYS,\
FILE_ATTRIBUTE_NORMAL,0
mov hBatch,eax
invoke LocalAlloc,2048,LPTR
mov lpMemBatch,eax
mov edi,eax
lea esi,szPreBatchLink
cld
loop_0:
lodsb
or al,al
jz next_0
stosb
jmp loop_0
next_0:
lea esi,szLinkExe
loop_1:
lodsb
or al,al
jz next_1
stosb
jmp loop_1
next_1:
lea esi,LinkParams
loop_2:
lodsb
or al,al
jz next_2
stosb
jmp loop_2
next_2:
lea esi,WildCard
loop_21:
lodsb
or al,al
jz next_21
stosb
jmp loop_21
next_21:
mov al,13
stosb
mov al,10
stosb
lea esi,szDirLink
loop_3:
lodsb
or al,al
jz next_3
stosb
jmp loop_3
next_3:
mov al,0
stosb
invoke CountBytes,lpMemBatch
push ecx
invoke MessageBox,0,ustr$(ecx),0,MB_OK
pop ecx
invoke WriteFile,hBatch,lpMemBatch,ecx,addr noBytesWritten,0
invoke CloseHandle,hBatch
invoke LocalFree,lpMemBatch
ret

BuildBatchLink endp

   Hope someone has better eyes than me, cause i'm tired of looking into it.

wjr

Windows expects certain registers such as ESI and EDI to be preserved in functions used during a call-back, so try BuildBatchLink PROC USES esi edi

xandaz

    Thanks. I already tried pushing and poping all registers. Looked also if stack was missaligned. it all seems ok but nope. Thanks anyway for the effort.

xandaz

    It was a swap error. I coded LocalAlloc,2048,LPTR and it's LPTR,2048. Problem solved.