News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

ObjAsm Tools

Started by Biterider, May 16, 2019, 05:21:01 AM

Previous topic - Next topic

Biterider

Hi
To improve the quality of the MASM code, years ago I developed a rudimentary tool that verifies the register preservation of regular procedures that follows the MS Windows ABI.

These days I needed this tool again and decided to port and update it.
Now, procedures and methods are supported for 32-bit, 64-bit, and mixed code.

I uploaded a trial version and a pdf help file here http://objasm.x10host.com/DwnFiles/OA_Tools.zip.

I would be glad, if someone would like to test the tool.  :P

Regards, Biterider

jj2007

Hi BiteRider,

In which language did you write it? VirusTotal found zero positives, so it definitely wasn't Assembly :P

What does it do? I've tried to analyse a few sources, inter alia the 20k lines of my editor, modified by some arbitrary push edi commands, and it doesn't find anything.

Biterider

#2
Hi jj
Thanks for testing the app. It is written im pure asm (MASM/ObjAsm).  :icon_mrgreen:

In the attachment are a few files I used for testing. Let the program analyse them and you will have something to play with.

Biterider

LiaoMi

Quote from: Biterider on May 16, 2019, 05:21:01 AM
Hi
To improve the quality of the MASM code, years ago I developed a rudimentary tool that verifies the register preservation of regular procedures that follows the MS Windows ABI.

These days I needed this tool again and decided to port and update it.
Now, procedures and methods are supported for 32-bit, 64-bit, and mixed code.

I uploaded a trial version and a pdf help file here http://objasm.x10host.com/DwnFiles/OA_Tools.zip.

I would be glad, if someone would like to test the tool.  :P

Regards, Biterider

Hi Biterider,

the program works fine, I have a lot of incorrect matches!  :biggrin: I am an ideal candidate for testing :greenclp:

jj2007

I wonder what I am doing wrong (Proc_Test_32.asm):
Working
Register use and preservation check ready.

Working
Variable check ready.


Biterider

Hi JJ
You should get the following result using the test file (Proc_Test_32.asm)
Working.
ERROR: unpreserved registers detected.
  Code block name: BStrCScan (27)
  Used registers:  edi
Working
Register use and preservation check ready.

Working.
Variable check ready.


What about the rest of the test files?

Biterider

jj2007

Can you explain step by step what you have to do to check a file?
Menu Checks/All, select a *.asm file, OK produces always the same window and output:

Working
Register use and preservation check ready.

Working
Variable check ready.

Biterider

Hi
This is the second round of the OA-Tools. I refactored the code to added more features:
Now you can scan for unpreserved registers, unused locals and unused arguments.
Annotations are also implemented (false positives).
Other things like high contrast settings can be changed in the color setup. Output font can also be selected. Finally I added the description of all these features in the pdf help file, that can be launched from the help menu of the application (the file must be in the same directory as the .exe file).

The download of the binary files (64 bit & wide string) is http://objasm.x10host.com/DwnFiles/OA_Tools.zip
The sources can be downloaded here http://objasm.x10host.com/DwnFiles/OA_Tools_Src.zip

For those that are fluent in other languages (implemented are EN, DE, ES), please check the .rc file. If you want to translate the string table, please let me know.  :cool:

Biterider

jj2007

Some glitches:
WARNING: possibly unused argument(s) detected.
  Code block name: MbArrayPlot2 (1028)
    - apmargins
    - xEnd1

Both are arguments, and are being used:
MbArrayPlot2 proc uses esi ebx arrID, arrTypeAndFlags, apmargins, DotCol, DotSize, xStart, xEnd1 ; setrange

  mov eax, xEnd1
  test eax, eax
  .if Sign?   ; default: -1 (0 would mean a single point, valid)
mov eax, [esi-8] ; # elements
  .endif

  mov ebx, apmargins ; apMargins in ArrayPlot macro
  .if ebx<30


WARNING: possibly unused argument(s) detected.
  Code block name: giDownload (1921)
    - private


giDownload proc private uses esi ebx giEbx

WARNING: possibly unused argument(s) detected.
  Code block name: Chkjj (3315)
    - arg


if 0
.data?
cjj dd ?
.code
Chkjj proc arg
pushad
  mov ecx, MenuTable[4*12]
  .if ecx>127
mov eax, [ecx]
.if eax!=cjj
; deb 4, "CJJ####", ecx, eax, $arg  <<<<<<<<<<<<<<<<<<<<<<<<<
mov cjj, eax
.endif
  .endif
popad
@MbRet
Chkjj endp
endif


Correctly recognised, except that the whole code is IF 0 ... ENDIF.

ERROR: possibly unpreserved register detected.
  Code block name: RepString (12486)
  Used registers:  edi esi


RepString proc uses esi edi ecx Dest, Pattern, Repl

ERROR: possibly unpreserved register detected.
  Code block name: ForceTextColP (17710)
  Used registers:  ebx

ForceTextColP proc ; arg
push ebx
mov ebx, [esp+8]
.if GetSelCol(0)!=ebx
invoke SetSelFormat, ebx, CFM_COLOR
.endif
pop ebx
retn 4
ForceTextColP endp


ERROR: possibly unpreserved register detected.
  Code block name: InsDate (22935)
  Used registers:  esi

InsDate proc
LOCAL txrg:TEXTRANGE
  GetCurSel
  .if eax<127
mov txrg.chrg.cpMin, edx
add eax, edx
mov txrg.chrg.cpMax, eax ; overwrite
push esi
mov esi, SelXXL$
invoke GetDateFormat, 0809h, DATE_LONGDATE, 0, 0, esi, 127 ; Country codes: see MSDN
invoke RepSel, addr txrg, esi ; we insert date & time separately to enable undo of time
GetCurSel
mov txrg.chrg.cpMin, edx
mov txrg.chrg.cpMax, edx ; Start=end, insert
invoke lstrcpy, esi, chr$(", ")
lea edx, [esi+Len(esi)]
invoke GetTimeFormat, 0, 0, 0, chr$("HH':'mm':'ss"), edx, 127
invoke RepSel, addr txrg, esi
pop esi
  .endif
  @MbRet
InsDate endp

Biterider

Hi JJ
Thank you for your feedback.  :thumbsup:
First and foremost, this application is a scanner and it knows nothing about program logic or about symbols and their values. This means that the code after a "if 0" statement is always evaluated.
To fix this flaw, a full functional assembler should be implemented, which is completely out of scope.
The same applies to self preserved (by the coder) registers. There is no simple way to know, if the preservation logic is correct.
Nevertheless, there are some bugs that you showed in the previous post. If possible, can you post or send it to me via a private channel the relevant source file?

What I can say atm is, that "private" before "uses" is not considered as a keyword. I will read the manual again to see out if there are other possible situations that can lead to a misrecongnition.

I'm not sure what you mean in the Chkjj procedure. "arg" is not the same as "$arg" and it is in a commented-out line. Text that is commented-out is not scanned. Maybe I'm missing here something...

I have been told that the setup dialog has some problems with the tab control in unknown circumstances. Can you please check if there is a problem on your machine. BTW, which OS do you use?

Biterider




jj2007

Quote from: Biterider on June 06, 2019, 06:14:05 AMcode after a "if 0" statement is always evaluated.
No problem at all.

QuoteThe same applies to self preserved (by the coder) registers. There is no simple way to know, if the preservation logic is correct.
Correct, but it should be mentioned in a prominent place.

QuoteNevertheless, there are some bugs that you showed in the previous post. If possible, can you post or send it to me via a private channel the relevant source file?
I will see what I can do.

QuoteWhat I can say atm is, that "private" before "uses" is not considered as a keyword.
For MASM, "private" in that position means "do not publish that symbol".

QuoteI have been told that the setup dialog has some problems with the tab control in unknown circumstances. Can you please check if there is a problem on your machine. BTW, which OS do you use?
No such problems on Win7-64 :thumbsup:

Biterider

#11
Hi
Here is the next update.
I fixed the old issues and added a new feature to scan macros. The documentation is updated accordingly.  :icon_idea:
To improve productivity, I have formatted the output slightly differently so that it can be copied and pasted directly as argument for annotations.

This version and the pdf help file can be downloaded from here http://objasm.x10host.com/DwnFiles/OA_Tools.zip.

Feedback is welcome.  :cool:

Biterider

Biterider

#12
Hi
Thanks to the support of some members of the board, I was able to bring forward this test application. The last addition was the ability to check macros for arguments and locals.  :icon_idea:

The user interface has been significantly improved and more graphics, text and languages like Chinese have been added. The user experience was unified in all dialogues.  :icon_idea:

There are many very interesting techniques used for this application that are worth discussing. They will be treated in a separate thread.
The final source code will be released shortly with ObjAsm Beta 3. The reason is that some additions had to be made and without them, the source cannot be compiled properly.

Since this is the almost final version, I would like to ask some people to re-examine the application for errors, missing features, and so on.  :cool:

The download is as usual http://objasm.x10host.com/DwnFiles/OA_Tools.zip.

Biterider

jj2007

Hi BiteRider,
This is what I get immediately in the debug centre after dragging a big source over the exe:
Object ID = 100000t (OA_OAT_App), Error Code = 536870999t (RKY_GET_DW_FAILED: Reading a DWORD failed)
Object ID = 250t (OA_RegKey), Error Code = 536870999t (RKY_GET_DW_FAILED: Reading a DWORD failed)
Object ID = 100000t (OA_OAT_App), Error Code = 536870999t (RKY_GET_DW_FAILED: Reading a DWORD failed)
Object ID = 250t (OA_RegKey), Error Code = 536870999t (RKY_GET_DW_FAILED: Reading a DWORD failed)
Object ID = 100000t (OA_OAT_App), Error Code = 536870999t (RKY_GET_DW_FAILED: Reading a DWORD failed)
Object ID = 250t (OA_RegKey), Error Code = 536870999t (RKY_GET_DW_FAILED: Reading a DWORD failed)
Object ID = 100000t (OA_OAT_App), Error Code = 536870999t (RKY_GET_DW_FAILED: Reading a DWORD failed)
Object ID = 250t (OA_RegKey), Error Code = 536870999t (RKY_GET_DW_FAILED: Reading a DWORD failed)
Object ID = 100000t (OA_OAT_App), Error Code = 536870999t (RKY_GET_DW_FAILED: Reading a DWORD failed)
Object ID = 250t (OA_RegKey), Error Code = 536870999t (RKY_GET_DW_FAILED: Reading a DWORD failed)
Object ID = 100000t (OA_OAT_App), Error Code = 536870999t (RKY_GET_DW_FAILED: Reading a DWORD failed)


Apart from this glitch, it works fine, and I have found several unused local variables. May save a few bytes :tongue:

Biterider

Hi JJ
This is the debug version. It shows that some entries in the registry are missing, which is OK.
I uploaded now the release version, that doesn't show these messages.

Biterider