Author Topic: Miscellaneous snippets  (Read 4014 times)

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 8455
  • Assembler is fun ;-)
    • MasmBasic
Create a temp web page to save a link
« Reply #45 on: May 14, 2018, 06:37:05 AM »
Sometimes I need to save a webpage but don't want to open it. So I copy the URL and run this proggie (source+exe attached):

include \masm32\MasmBasic\MasmBasic.inc         ; download
  Init
  Let esi=Clip$()               ; get URL from clipboard, e.g. http://masm32.com/board/index.php?action=unread
  .if Instr_(esi, "://")
        FileWrite "SaveLinkAsTemp.html", Cat$(Chr$("<html><head><title>Temporary link</title></head>", 13, 10, "<body>", 60, "a href=", 34)+esi+Chr$(34, 62, "Right-click here and choose 'Save Link as...' to download ")+esi+Chr$(60, "/a", 62, "</body></html>"))
        ShEx "SaveLinkAsTemp.html"      ; launch the browser
  .else
        MsgBox 0, esi, "No URL found:", MB_OK
  .endif
EndOfCode



jj2007

  • Moderator
  • Member
  • *****
  • Posts: 8455
  • Assembler is fun ;-)
    • MasmBasic
Check a file for http:// and friends
« Reply #46 on: May 18, 2018, 11:59:07 AM »
Attached a little file DownloadMasm32.exe that does something entirely harmless:
Code: [Select]
include \masm32\MasmBasic\MasmBasic.inc
  Init
  Let esi="0.75=draob?php.xedni/draob/moc.23msam//:ptth"
  PrintLine esi
  Let edi=FileRead$(Mirror$(esi))
  Inkey NoTag$(edi)
EndOfCode

In addition, the attachment contains a project that finds http:// and https:// in files, even if they are mirrored; just drag a file over SpyWareScanMB.exe 8)

Warning: While SpyWareScanMB.exe finds interesting http:// and https:// matches in exes and dlls, it is not a replacement for an AntiVirus. Malware writers use more sophisticated tricks to hide their URLs.

jj2007

  • Moderator
  • Member
  • *****
  • Posts: 8455
  • Assembler is fun ;-)
    • MasmBasic
Print formatted text
« Reply #47 on: Today at 03:55:17 AM »
This snippet
- reads a text file into a RichEdit control (its name is supplied by the commandline)
- formats the first line in bold
- on request via the menu, prints the text.

To test it, extract all files to a temporary folder and drag the text file over the exe (the *.asc file is the source as RTF).

If needed, the whole process can be automated, i.e. eliminate the Event Menu step and just run the exe with the commandline argument, then exit automatically. See PrintRtf for printer dialog handling options.


GuiMenu equ @File, &Open, &Print, E&xit
GuiParas equ "Print formatted text demo", x100, y100, w400, h200; , cblack, b00FFFFD0h
include \masm32\MasmBasic\Res\MbGui.asm

  MakeFont hMyFont, Height:20, "Lucida Handwriting"
  GuiControl MyEdit, "RichEdit", font hMyFont
  SetGlobals f$, charfmt:CHARFORMAT2
  Let f$=FileRead$(CL$())               ; read the text file passed in the commandline
  SetWin$ hMyEdit=f$
  .if Instr_(f$, CrLf$)
       dec edx                         ; index of CrLf-1
       invoke SendMessage, hMyEdit, EM_SETSEL, 0, edx
       m2m charfmt.cbSize, CHARFORMAT2
       m2m charfmt.dwMask, CFM_BOLD            ; CharFtMask
       m2m charfmt.dwEffects, CFE_BOLD         ; Character effects
       invoke SendMessage, hMyEdit, EM_SETCHARFORMAT, SCF_SELECTION, ADDR charfmt
       invoke SendMessage, hMyEdit, EM_SETSEL, 0, 0
  .endif

Event Menu
  .if MenuID==1
        void PrintRtf(hMyEdit, 1)     ; 0=use default printer, 1=ask for printer dialog
  .endif
GuiEnd