Hi Biterider,
I was using my mdi64.exe to fix headers pointers with asterix "*" to INT_PTR before I would use x2incx.exe
to convert file. here is subroutine for that:
FixPointers proc FRAME USES rsi rdi rbx RawText:LPSTR, FixedText:LPSTR,pszFileName :LPCTSTR, fSize:DWORD
local szName [MAX_PATH] :BYTE
local szVar [MAX_PATH] :BYTE
mov rsi,rcx
mov rdi,rdx
mov rbx,rcx
add rbx,r9
.while rsi < rbx
;search for "proto" and transform data
xor rcx,rcx
mov r8,rsi
.while BYTE PTR[r8]!= 10
next: mov al,[r8]
.if al =='('
jmp transfer
.elseif al =='*'
jmp found
.endif
inc ecx
inc r8
.if r8>rbx
jmp finish
.endif
.endw
found:
.if (BYTE PTR [r8]== '*' && BYTE PTR [r8-1] == '/')
.repeat
.if (BYTE PTR[r8] == 0)
jmp finish
.endif
mov al,[r8]
inc r8
.until (al == '/' && BYTE PTR[r8-2] == '*')
mov rsi,r8
jmp next
.endif
.if ecx < 32
.if BYTE PTR [r8-1] == ' ' || BYTE PTR [r8-1] == 9
mov WORD PTR[rdi],909h
add rdi,2
mov rax," RTP_TNI"
mov [rdi],rax
add rdi,8
mov rsi,r8
inc rsi
.endif
.endif
transfer:
.repeat
mov al,[rsi]
mov [rdi],al
inc rsi
inc rdi
.until al == 10
.endw
finish:
mov byte ptr[rdi],0
xor rax,rax
ret
FixPointers endp
Than after conversion to .inc with h2incx.exe, I was using another routine to convert to x64:
HeadersTo64bits proc FRAME USES rsi rdi rbx r12 RawText:LPSTR, FixedText:LPSTR,pszFileName :LPCTSTR, fSize:DWORD
local szName [MAX_PATH] :BYTE
local szVar [MAX_PATH] :BYTE
mov rsi,rcx
mov rdi,rdx
mov r12,rcx
add r12,r9
invoke lstrcpy,addr szName, pszFileName
invoke PathRemoveExtension,addr szName
invoke PathStripPath, addr szName
invoke CharUpper,addr szName
invoke lstrcat,addr szName, addr szApi
invoke lstrcpy,ADDR szVar,ADDR szWin
invoke lstrcat,ADDR szVar,ADDR szName
.while rsi < r12
;search for "proto" and transform data
.while BYTE PTR[rsi]!= "p"
next: mov al,[rsi]
mov [rdi],al
inc rsi
inc rdi
.if rsi>r12
jmp finish
.endif
.endw
.if dword ptr[rsi+1]=="otor" && byte ptr[rsi-1]==10
add rsi,5
invoke wsprintf,rdi,addr szDef
add rdi,rax
invoke wsprintf,rdi,addr szVar
add rdi,rax
.if byte ptr[rsi]=="_"
inc rsi
.endif
.while byte ptr[rsi] != " "
mov al,[rsi]
mov [rdi],al
inc rdi
inc rsi
.endw
mov byte ptr[rdi],","
inc rdi
mov al,[rsi]
mov [rdi],al
inc rsi
inc rdi
invoke wsprintf,rdi,addr szStdcall
add rdi,rax
.while byte ptr[rsi]!= 13
mov al,[rsi]
inc rsi
.if al==":"
jmp vars
.endif
.endw
;dec rsi
jmp endline
vars: invoke wsprintf,rdi,addr szComas
add rdi,rax
dec rsi
xor rdx,rdx
.while byte ptr[rsi]!= 13
mov al,[rsi]
.if al==":"
inc rdx
.endif
mov [rdi],al
inc rsi
inc rdi
.endw
mov byte ptr[rdi],">"
inc rdi
mov byte ptr[rdi],","
inc rdi
shl rdx,2
invoke wsprintf,rdi,CSTR("%i"), rdx
add rdi,rax
mov al,13
endline: mov [rdi],al
inc rdi
inc rsi
mov al,[rsi]
mov [rdi],al
inc rsi
inc rdi
mov rax,"ednretxe"
.if qword ptr[rsi]==rax
.while byte ptr [rsi] != 10
inc rsi
.endw
inc rsi
.while byte ptr [rsi] != 10
inc rsi
.endw
inc rsi
.endif
.else
jmp next
.endif
.endw
finish:
mov byte ptr[rdi],0
xor rax,rax
ret
HeadersTo64bits endp
where .data is:
szDef db '@DefProto ',0
szStdcall db 'stdcall',0
szComas db ', , <',0
szApi db 'API, ',0
szWin db 'WIN',0
I hope it will give you some clue how to do that
I was planing to work on h2incx source to make it work, as well as use some C/C++ compiler to create perfect .inc files, however, at this moment I have taken some brake from UASM and programming for several months.
I would appreciate if you can upgrade h2incx
best regards