Author Topic: ObjAsm64  (Read 4244 times)

Biterider

  • Moderator
  • Member
  • *****
  • Posts: 222
  • ObjAsm32 - ObjAsm64
    • ObjAsm64
Re: ObjAsm64
« Reply #15 on: March 05, 2018, 06:20:02 AM »
Hi
In recent weeks we have seen customization examples for the classic GetOpenFileName, GetSaveFileName and co. APIs.
There is, however, an alternative that MS recommends. COM programmers designed a way to reduce the complexity of the customization. The core idea is to get access to the file dialogs and their customization using COM interfaces.
In the following example, I only examined the IFileOpenDialog interface defined in the ShObjIDL.inc file. There are interfaces for IFileSaveDialog, IFileOperationProgressSink and many more. I will complete the translation in the next few days, but for this example, it contains all the necessary definitions.
The following code snippet shows how to redefine the Open File dialog box.
 
Code: [Select]
COMDLG_FILTERSPEC struc
    pszName LPCWSTR     ?
    pszSpec     LPCWSTR ?
COMDLG_FILTERSPEC ends
 
MultiFileSpec struc
  FS0 COMDLG_FILTERSPEC {}
  FS1 COMDLG_FILTERSPEC {}
  FS2 COMDLG_FILTERSPEC {}
  FS3 COMDLG_FILTERSPEC {}
MultiFileSpec ends
 
Method Application.OnCommand, uses rbx rsi, wParam:WPARAM, lParam:LPARAM
    local pIFODlg: POINTER, MFS:MultiFileSpec
    local pISIArr:POINTER, dCount:DWORD, pIShellItem:POINTER, pDisplayName:POINTER
 
    SetObject rsi
    mov rax, wParam
    .if ax == IDM_OPEN
      invoke CoCreateInstance, offset CLSID_FileOpenDialog, NULL, CLSCTX_INPROC_SERVER, \
                               offset IID_IFileOpenDialog, addr pIFODlg
     
      m2m MFS.FS0.pszName, $OfsCStr("All")
      m2m MFS.FS0.pszSpec, $OfsCStr("*.*")
      m2m MFS.FS1.pszName, $OfsCStr("Assembly")
      m2m MFS.FS1.pszSpec, $OfsCStr("*.asm")
      m2m MFS.FS2.pszName, $OfsCStr("Include")
      m2m MFS.FS2.pszSpec, $OfsCStr("*.inc")
      m2m MFS.FS3.pszName, $OfsCStr("Text")
      m2m MFS.FS3.pszSpec, $OfsCStr("*.txt")
 
      ICall pIFODlg::IFileOpenDialog.SetFileTypes, MultiFileSpec/COMDLG_FILTERSPEC, addr MFS
      ICall pIFODlg::IFileOpenDialog.SetFileTypeIndex, 2
      ICall pIFODlg::IFileOpenDialog.SetOptions, FOS_ALLOWMULTISELECT
      ICall pIFODlg::IFileOpenDialog.SetTitle, $OfsCStr("Select a file...")
      ICall pIFODlg::IFileOpenDialog.SetOkButtonLabel, $OfsCStr("Select")
      ICall pIFODlg::IFileOpenDialog.SetFileNameLabel, $OfsCStr("Selected file name: ")
      ICall pIFODlg::IFileOpenDialog.Show, [rsi].hWnd
      .if SUCCEEDED(eax)
        ICall pIFODlg::IFileOpenDialog.GetResults, addr pISIArr
        ICall pISIArr::IShellItemArray.GetCount, addr dCount
        xor ebx, ebx
        .while ebx < dCount
          ICall pISIArr::IShellItemArray.GetItemAt, ebx, addr pIShellItem
          ICall pIShellItem::IShellItem.GetDisplayName, SIGDN_NORMALDISPLAY, addr pDisplayName
          mov rax, pDisplayName
          DbgStr rax
          inc ebx
        .endw
      .endif
 
      …

                                 
The attachment contains the executable version of the demo.
 
Regards, Biterider

Biterider

  • Moderator
  • Member
  • *****
  • Posts: 222
  • ObjAsm32 - ObjAsm64
    • ObjAsm64
Re: ObjAsm64
« Reply #16 on: March 11, 2018, 09:04:55 PM »
Hi

Quote
Software that is capable of having a skin applied is referred to as being skinnable, and the process of writing or applying such a skin is known as skinning. Applying a skin changes a piece of software's look and feel—some skins merely make the program more aesthetically pleasing, but others can rearrange elements of the interface, potentially making the program easier to use.
https://en.wikipedia.org/wiki/Skin_(computing)

One of the best known skinnable software is Windows Media Player.

I would like to introduce a basic approach of a skinned application using ObjAsm64.
I've integrated some elements, such as buttons, dialogs, gifplayer, tooltip, XMenu, etc. to create this application. The largest application payload are of course the bitmap resources.

Note:
  • To display the context menu, right-click on the client area of the application. A XMenu with 2 elements is displayed.
  • To move the application, drag the title bar.
So far, most of the old objects in the repository are running as their 64-bit counterparts.
In the coming weeks, I will focus on troubleshooting to release the first OA64 beta.
I hope for feedback when someone finds a bug.  :t


Regards, Biterider
« Last Edit: March 11, 2018, 11:03:18 PM by Biterider »

jj2007

  • Member
  • *****
  • Posts: 8728
  • Assembler is fun ;-)
    • MasmBasic
Re: ObjAsm64
« Reply #17 on: March 11, 2018, 09:57:23 PM »
Very, very cute :t

Biterider

  • Moderator
  • Member
  • *****
  • Posts: 222
  • ObjAsm32 - ObjAsm64
    • ObjAsm64
Re: ObjAsm64
« Reply #18 on: March 19, 2018, 03:13:21 AM »
Hi

While I was finishing some functional parts of the ObjAsm64 framework, I came to Object Explorer. This application is a very efficient way to quickly show important information about objects. This information is read using PCRE from the source code by using the structured information ahead object, method or procedure definitions. Whole directories are scanned to get this information. Knowing how to read these definitions, a whole tree of relationships is created that allows us to visually browse through parent and descendant objects.

The Object Explorer application is divided into two panels. On the left side, a tree (XTreeView) displays all object dependencies. On the right side, an OCX_Container manages a Web Browser instance that is fed with HTML code to represent the previously collected information of the shown object selected on the left side. This information panel displays first the object header information followed by the object inheritance path. Thereafter, all object related files are displayed. The icons on the left (Actions) can be used to start the File Explorer or the standard editor. To create or update a precompiled object, a special additional button is provided.

Finally, 2 sections are shown: Methods and Variables.

Methods: this section displays all method members of the current object. In gray, you can see the inherited methods, while in black you can see the object new defined and implemented methods. A plus sign in front of each line can be used to popup the method heading information.

Variables: this section displays in a similar way variable members, their type and initial value (template value). In case of an embedded object, the icon in front of the line changes to indicate this and you can navigate to the corresponding object by clicking on “Type”.

Since I haven’t found the time to port the last PCRE 8.41 to x64, Object Explorer remains at the moment a 32 bit application.

Regards, Biterider

fearless

  • Member
  • ***
  • Posts: 356
    • LetTheLightIn
Re: ObjAsm64
« Reply #19 on: March 19, 2018, 05:57:59 AM »
looks pretty good.

Just in case you didnt notice but the links on ObjAsm64 dont point to valid files:

Quote
Not Found The requested URL /DwnFiles/ObjAsm64.zip was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
fearless

CM690II Case, HX1000 PSU, Asus Z97, Intel i7-4790K, Seidon 120v Cooler, 16GB DDR3, MSI GTX 980TI

www.LetTheLight.in  My Github  Twitter

HSE

  • Member
  • ****
  • Posts: 803
  • <AMD>< 7-32>
Re: ObjAsm64
« Reply #20 on: March 19, 2018, 11:03:34 AM »
Is posible to change colors?

Biterider

  • Moderator
  • Member
  • *****
  • Posts: 222
  • ObjAsm32 - ObjAsm64
    • ObjAsm64
Re: ObjAsm64
« Reply #21 on: March 19, 2018, 05:56:38 PM »
Hi
@ fearless: Thank you. I am aware that the files are missing. They will be available for download in a few days. I'll inform accordingly.

@ HSE: Currently, no such feature is implemented, but I can if necessary.

Biterider


Biterider

  • Moderator
  • Member
  • *****
  • Posts: 222
  • ObjAsm32 - ObjAsm64
    • ObjAsm64
Re: ObjAsm64
« Reply #22 on: March 26, 2018, 02:35:22 AM »
Hi
The TreeView is one of the most useful controls of Windows.
But it is also known that the customization is not easy time consuming. Therefore, some time ago, I wrote this control from the ground up with the goal of providing a higher level of flexibility. It has become a difficult task as the code has become very long. But I have used this for debugging the x64 migration.
Fortunately I managed to revive the control and in fact a few bugs showed up.  :redface:

This will be the last code before the ObjAsm64 release in the next few days.  ;)

Regards, Biterider


Biterider

  • Moderator
  • Member
  • *****
  • Posts: 222
  • ObjAsm32 - ObjAsm64
    • ObjAsm64
PCRE - RegEx
« Reply #23 on: March 29, 2018, 06:01:57 PM »
Hi
I would like to draw attention to a really great project "PCRE", which stands for "Perl Compatible Regular Expressions". It can be found here https://www.pcre.org/. I've used it in the past to create RegEx objects to parse text. At the time of the ObjAsm32 there was only the ANSI version, but in the current version this restriction has been removed.  :t

I've been able to compile the current version (8.41) of the project and create a static library out of the 3 available character widths (8, 16 and 32 bits). I also translated a complete .inc file to use with the .lib. Unfortunately, this .zip file containing the files is too big to post here (~ 1.3 MB). Therefore it can be downloaded from here http://objasm.x10host.com/DwnFiles/PCRE_8.41.zip. In this .zip file contains the 3 single .lib, the merged .lib, the .inc file and 2 ObjAsm64 RegEx objects.

Since Unicode characters can now also be processed, I have created two variants of the RegEx object RegExA and RegExW for the ObjAsm64 project. These can be loaded neutral with the character width.

Regards, Biterider


Biterider

  • Moderator
  • Member
  • *****
  • Posts: 222
  • ObjAsm32 - ObjAsm64
    • ObjAsm64
Re: ObjAsm64
« Reply #24 on: April 02, 2018, 04:56:32 PM »
Hi
Today I want to announce the first beta release of ObjAsm64   :P

The complete package can be downloaded from the homepage: http://objasm.x10host.com
I put the installation instructions here: http://objasm.x10host.com/DwnFiles/Instructions.txt

Since the code certainly contains some bugs, I ask kindly for feedback  :t

Regards, Biterider

Biterider

  • Moderator
  • Member
  • *****
  • Posts: 222
  • ObjAsm32 - ObjAsm64
    • ObjAsm64
ObjAsm64 learns Exception Handling
« Reply #25 on: April 07, 2018, 05:16:30 AM »
Hi
Exception handling in x64 world is a little different than in the x86 world.
The topic is described here by Microsoft https://msdn.microsoft.com/en-us/library/1eyas8tf.aspx. I found an article that discusses the topic very well: http://www.nynaeve.net/? p = 113. There are also some contributions to "Code Project" that are worth reading.

Essentially for the normal assembler user, exception handling is reduced to using some macros and a language-specific handler. The macro names are similar to the C syntax: __TRY, __EXCEPT, & __FINALLY. These macros perform the basic bookkeeping of the protected code areas. The exception handler performs the stack unrolling and forwarding to the code in the save area after an exception. This handler can be customized for any procedure or globally for all procedures. In ObjAsm64, the latter is called EHandler and is placed in the ObjMem64 library.

The exception handler is always specified after the FAME keyword of a procedure.

Basically a protected code area looks like:

Code: [Select]
start proc FRAME:EHandler
  SysInit
  DbgClear
 
__TRY
  xor eax, eax
  mov rcx, [rax]
 
__EXCEPT
  DbgWarning "Exception"
  DbgHex ExceptRecord.ExceptionCode
  DbgHex ExceptRecord.ExceptionAddress
 
__FINALLY
  DbgLine2
 
  SysDone
  invoke ExitProcess, 0
start endp

The instruction mov rcx, [rax] raises an exception and causes the execution of the code after the macro __EXCEPT. The code following the __FINALLY macro is always executed.
The code save area can be completely skipped. In this case, after the exception, the code will continue after __FINALLY.

This little exception framework is not limited to ObjAsm64. It can also be used for any normal asm code.  8)
 
Regards, Biterider

Biterider

  • Moderator
  • Member
  • *****
  • Posts: 222
  • ObjAsm32 - ObjAsm64
    • ObjAsm64
ObjAsm64 quality tool
« Reply #26 on: April 15, 2018, 12:04:51 AM »
Hi
I've been working on a revival of an old tool to improve the coding quality.

Windows x64 ABI is very clear and indicates what volatile and non-volatile registers are. Preserving the non-volatile registers is important as it can lead to random crashes that are hard to find when calling routines from the OS. It is a good practice to adopt the same rules for your own code as it will improve the robustness of your application. Because the underlying operating system code has changed from version to version, non-compliant code may have worked for an older operating system version, but it suddenly stops working with a newer version of it.

I worked with this quality tool to check my own code for common mistakes. Using a variation of the same scanning algorithm, we are able to detect the oposit, an unnecessary register preservation. Unused locals can also be detected to unclutter the code. The quality tool works for OA64 methods and also for x64 procedures.

Since the execution is relatively fast, I implemented a batch mode to scan entire libraries or repositories searching for the above mentioned situations.

Now, there are situations where you deliberately do not want to follow the Windows x64 ABI specification. In these cases, to avoid an unnecessary error or warning message, you can insert a hint for the tool immediately after the method or procedure declaration. The hint is a simple macro that does not generate any code. It is a simple annotation in the code read by the quality tool to get additional information about the intention of the coder.
This quality tool is by far not ready, but it can be used in its present form. I’ll keep working on it as it is required.

Note: this version is intended only for x64 code, but it is a 32 bit application  :icon_exclaim:
 
Regards, Biterider
« Last Edit: April 15, 2018, 01:06:30 AM by Biterider »

HSE

  • Member
  • ****
  • Posts: 803
  • <AMD>< 7-32>
Re: ObjAsm64
« Reply #27 on: April 15, 2018, 12:29:26 AM »
Hi Biterider!!

Between today and tomorrow I will try to install the package!  :t

But in ObjAsm32 the tool have a little problem because requiere entire procedures in same file, and I have a lot of procedures that result from including several files.

In theory is not very difficult to solve that, but just now I'm making little things with parsers.

Regards.

Biterider

  • Moderator
  • Member
  • *****
  • Posts: 222
  • ObjAsm32 - ObjAsm64
    • ObjAsm64
Re: ObjAsm64
« Reply #28 on: April 15, 2018, 12:59:37 AM »
Hi HSE
I am glad to hear that you are also involved with OA64.  :t
Please let me know how it went with the installation.


Regards, Biterider

HSE

  • Member
  • ****
  • Posts: 803
  • <AMD>< 7-32>
Re: ObjAsm64
« Reply #29 on: April 15, 2018, 03:46:35 AM »
Here in 7-64.

No problem with ObjMem64.
Some errors assembling objects.