;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

;     include files
;     ~~~~~~~~~~~~~
      include \MASM32V1\INCLUDE\windows.inc
      include \MASM32V1\INCLUDE\gdi32.inc
      include \MASM32V1\INCLUDE\user32.inc
      include \MASM32V1\INCLUDE\kernel32.inc
      include \MASM32V1\INCLUDE\Comctl32.inc
      include \MASM32V1\INCLUDE\comdlg32.inc
      include \MASM32V1\INCLUDE\shell32.inc
      include \MASM32V1\INCLUDE\oleaut32.inc
;      include \MASM32V1\INCLUDE\vmm.inc
include  \MASM32V1\include\DSPMACRO.asm

;     libraries
;     ~~~~~~~~~
      includelib \MASM32V1\LIB\gdi32.lib
      includelib \MASM32V1\LIB\user32.lib
      includelib \MASM32V1\LIB\kernel32.lib
      includelib \MASM32V1\LIB\Comctl32.lib
      includelib \MASM32V1\LIB\comdlg32.lib
      includelib \MASM32V1\LIB\shell32.lib
      includelib \MASM32V1\LIB\oleaut32.lib

;=================
; Local prototypes
;=================
WinMain       PROTO :DWORD,:DWORD,:DWORD,:DWORD
WndProc       PROTO :DWORD,:DWORD,:DWORD,:DWORD
FrameProc     PROTO :DWORD,:DWORD,:DWORD,:DWORD
ChildProc     PROTO :DWORD,:DWORD,:DWORD,:DWORD
CreateWin     PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
FillBuffer    PROTO :DWORD, :DWORD, :BYTE
ReadEM        PROTO :DWORD,:DWORD
Confirmation  PROTO :DWORD
WriteEM       PROTO :DWORD,:DWORD
Find          PROTO :DWORD,:DWORD,:DWORD,:DWORD
ScrollProc    PROTO :DWORD,:DWORD,:DWORD,:DWORD
REditProc     PROTO :DWORD,:DWORD,:DWORD,:DWORD
ConvertDlg    PROTO :DWORD,:DWORD,:DWORD,:DWORD
ControlEdit   PROTO :DWORD,:DWORD,:DWORD,:DWORD
SplitProc     PROTO :DWORD,:DWORD,:DWORD,:DWORD
TabCtlDlg     PROTO :DWORD,:DWORD,:DWORD,:DWORD
ViewDlg       PROTO :DWORD,:DWORD,:DWORD,:DWORD
ColorFontDlg  PROTO :DWORD,:DWORD,:DWORD,:DWORD
CompareFiles  PROTO :DWORD,:DWORD,:DWORD,:DWORD
ExtractImg    PROTO :DWORD,:DWORD,:DWORD,:DWORD
ViewBMPDlg    PROTO :DWORD,:DWORD,:DWORD,:DWORD
GoToOff       PROTO :DWORD,:DWORD,:DWORD,:DWORD
FindReplace   PROTO :DWORD,:DWORD,:DWORD,:DWORD
AsciiBase     PROTO :DWORD,:DWORD,:DWORD
BaseAscii     PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
SizeEM        PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
SwapHexDec    PROTO :DWORD,:DWORD,:DWORD,:DWORD
ValHexDec     PROTO :DWORD,:DWORD,:DWORD,:DWORD
FillEdit      PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD
BuildCurIco   PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
BuildBmp      PROTO :DWORD,:DWORD

wsprintfA     PROTO C :DWORD,:VARARG
wsprintf      equ <wsprintfA>

;VMM_Service  MACRO Get_Machine_Info
;call     Get_Machine_Info
;          ENDM

;=============
; Local macros
;=============

MOVmd    MACRO Var1, Var2
          push     Var2
           pop     Var1
          ENDM

TBSep    MACRO hTool
           mov     tbb.iBitmap, 0
           mov     tbb.idCommand, 0
           mov     tbb.fsState, TBSTATE_ENABLED
           mov     tbb.fsStyle, TBSTYLE_SEP
        INVOKE     SendMessage, hTool, TB_ADDBUTTONS, 1, addr tbb
          ENDM

TBButt   MACRO hTool, bID, cID, Text
           mov     tbb.iBitmap, bID    ; Button image number
           mov     tbb.idCommand, cID  ; Command ID number
           mov     tbb.fsState, TBSTATE_ENABLED
           mov     tbb.fsStyle, TBSTYLE_BUTTON
           mov     tbb.dwData, 0
           mov     tbb.iString, Text
        INVOKE     SendMessage, hTool, TB_ADDBUTTONS, 1, addr tbb
          ENDM


.const

MemSize        equ 2000000

.data

CommandLine    dd  0
hWnd           dd  0
hInst          dd  0
hAccel         dd  0
hIcon          dd  0
hMenu          dd  0
hSubMenu       dd  0
hTab           dd  0
hTabSeL        equ $
hTabSeL1       dd  0
hTabSeL2       dd  0
hTabSeL3       dd  0
hTabSeL4       dd  0
Wwd            dd  0 
Wht            dd  0
wHth           dd  0
Refresh        dd  0
hMem           dd  0
pMem           dd  0
hMemS          dd  0
pMemS          dd  0
hMemT          dd  0
pMemT          dd  0
hMemL          dd  0
pMemL          dd  0
hMemI          dd  0
pMemI          dd  0
hMemID         dd  0
pMemID         dd  0
hMap           dd  0
pMap           dd  0
hFile          dd  0
hFont          dd  0
hSFont         dd  0
hwndStat       dd  0
hwndTool       dd  0
hwndFrame      dd  0
hwndClient     dd  0
hFrameMenu     dd  0
hChildMenu     dd  0
hwndChild1     dd  0
hwndChild2     dd  0
hEdit1         dd  0
hEdit2         dd  0
hTbBmp         dd  0
hStatM         dd  0
hSplit1        dd  0
hSplit3        dd  0
hScroll        dd  0
hScrollSub     dd  0
hFind          dd  0
hReplace       dd  0
hEditSub       dd  0
hREdit         dd  0
hREditSub      dd  0
hSplitSub      dd  0
hWorkC         dd  0
hWorkN         dd  0
hConvert       dd  0
hInput         dd  0
hFRDlg         dd  0
hVDlg          dd  0
hFSize         dd  0
hDC            dd  0
hIC            dd  0
bSize          dd  0
sbParts        dd  4  dup(?)
ImgArray       dd  31 dup(0)   
fSize          dd  200
Ltot           dd  0
NScrL          dd  0
Lmax           dd  0
HexDec         dd  16
bytesread      dd  0
BytesOut       dd  0
BytesS         dd  0
BytesT         dd  0
TextLen        dd  0
WxPos          dd  0
WyPos          dd  0
SavPos         dd  0
xCur           dd  0
xPos           dd  0
yPos           dd  0
sMin           dd  0
sMax           dd  0
sxPos          dd  0
syPos          dd  0
cyChar         dd  16
PPC            dd  0
Space          dd  0
Hold           dd  0
NoSize         dd  1
SizeWork       dd  1
InsNotify      dd  0 ;1
DelNotify      dd  0 ;1
Split1         dd  0
sw1            dd  0
sw2            dd  0
sw3            dd  0
w4             dd  0
Lnum           dd  0
Len            dd  0
FileOff        dd  0
LineOff        dd  0
FileOffS       dd  0
LineOffS       dd  0
SavOff         dd  0
LastLine       dd  0
Flag           dd  0
UD             dd  0
Hex            dd  1
HexView        dd  4
LineCnt        dd  40
Test4          dd  0
FR             dd  0
Match          dd  0
Match0         dd  0
MatchCase      dd  1
w1W            dd  0
w2W            dd  0
w3W            dd  0
w4W            dd  0
CustClrs       dd  16 dup(?)
c1T            dd  000000ffh
c1B            dd  00f4fff4h
c2T            dd  00004000h
c2B            dd  00ffffffh
c3T            dd  00600000h
c3B            dd  00fffff4h
TabSelect      dd  0
OnlyRead       dd  0
PE             dd  0
NumOfSections  dw  0 
NumOfIDs       dd  0
NumOfMatchIDs  dd  0
SavStart       dd  0
hCur           dd  0
hBmp           dd  0
hIco           dd  0
ID             dd  0

R10       REAL10  0.0
PixPC     REAL10  0.0
;Rnd       REAL10  0.55
;PageInc   REAL10  0.0
;ThumbInc  REAL10  0.0
;TestS     REAL10  9.0

ReDLL          db  'RICHED32.DLL',0
EditRT         db  'RichEdit',0
richedit       db  'RichEdit20A',0
RichEdDLL      db  'RICHED20.DLL',0 ;Version 2\3

FontName1      db  '8514oem',0
FontName2      db  'System',0
FontName3      db  'Terminal',0
FontName4      db  'Courier New',0
FontMS         db  'MS Sans Serif',0
szHexEdit      db  'HexEdit.exe',0
szCalc         db  'EWCalc.exe',0
szHelp         db  'HexEdit.HLP',0

szTest         db  '0123456789ABCDEFGHIJKLMNOPQRSTYVWXYZ012345678901234', 0
szSize         db  '8,9,10,11,12,',0
ScrollClass    db  'SCROLLBAR',0
StatClass      db  'STATIC',0
EditClass      db  'EDIT',0
ToolClass      db  'ToolbarWindow32',0
ComboClass     db  'COMBOBOX',0
MDIClientClass db  'MDICLIENT',0
MDIFrameClass  db  'Win32asmMDIFrame',0
MDIChildClass  db  'Win32asmMDIChild',0

szFileOff      db  'FileOffset: ',0
szLineOff      db  'LineOffset: ',0
szClassName    db  'HexEdit_Class',0
szDisplayName  db  'HexEdit',0
szUntitled     db  'Untitled',0
szTitleO       db  'Read File',0
szTitleS       db  'Write File',0
szFilter       db  'All files',0,'*.*',0,'Text files',0,'*.txt',0,0
szPE           db  'PE Files (*.exe), (*.dll), (*.ocx), (*.scr)',0,'*.exe;*.dll;*.ocx;*.scr',0,
                  'All Files',0,'*.*',0,0
szFilterI      db  'Cursor (*.cur), Bitmap(*.bmp), Icon(*.ico)',0,'*.cur;*.bmp;*.ico',0,
                  'All Files',0,'*.*',0,0
szCur          db  '*.cur',0
szBmp          db  '*.bmp',0
szIco          db  '*.ico',0

ConfirmMsg     db  'File not saved, save it now ?',0
AboutMsg       db  'Hex Editor', 13, 10, 'Copyright © 2000 Ewayne Wagner',0
szOpenedAt     db  'File opened size: ',0
szSavedAt      db  'File saved size: ',0
buttxt1        db  'Goto Offset',0
bytes          db  ' bytes',0
szInsert       db  'Are you sure you want to INSERT !',0
szDelete       db  'Are you sure you want to DELETE !',0
szError1       db  'The Clipboard has non Hex characters.',0
szError2       db  'The Clipboard input is not byte aligned.',0
szError3       db  'The Find and or Replace'
               db  0Dh,0Ah
               db  'Field Length is Invalid.',0
szError4       db  'The Following Field Is Invalid:'
               db  0Dh,0Ah
szHexDec       db  12 dup(0),0
szError5       db  'You Have a Mismatch:'
               db  0Dh,0Ah,0Dh,0Ah
               db  'At Source Offset:  '
szSource       db  12 dup(' ')
               db  0Dh,0Ah
               db  'At Target  Offset:  '
szTarget       db  12 dup(0),0
szError6       db  'The Compare Was Successful !',0
szError7       db  'Error Opening The File.',0
szError8       db  'There are no resource images'
               db  0Dh,0Ah
               db  'for the requested file.',0
szError9       db  'If you are running NT or Win2k'
               db  0Dh,0Ah
               db  'you will need to press compare again.',0
szCompFiles    db  'Compare Files Results',0
szAccess       db  'This program is in use.'
               db  0Dh,0Ah
               db  'Would you like to open it as read only ?',0
szFR           db  'Find And Replace',0
FindEnd        db  'There Are No More Matches.'
               db  0Dh,0Ah
               db  'Would You Like To Restart From The'
TopBot         db  ' Top? '
               db  0
Top            db  ' Top? '
Bot            db  ' Bot? '
szSpace        db  ' ',0
szText         db  'Text:',0
szHex          db  ' Hex:',0
TabTitle1      db  'Views',0
TabTitle2      db  'Font/Color',0
TabTitle3      db  'Compare',0
TabTitle4      db  'Extract',0
TabTitle5      db  'Reserved',0
szComb         db  'comb',0
szCRLF         db  0Dh,0Ah,0
szStat         db  30 dup(?)
szImage        db  60 dup(0)
szPathName     db  128 dup(?)
szFileName     db  260 dup(0)
szFind         db  260 dup(0)
;szBuff         db  260 dup(0)
szBuff         db  1048 dup(0)
;szWork         db  260 dup(0)
szWork         db  1048 dup(0)

tbb           TBBUTTON        <>
tbab          TBADDBITMAP     <>
ofn           OPENFILENAME    <>
lf            LOGFONT         <>
sci           SCROLLINFO      <>
ft            FINDTEXT        <>
stxt          SETTEXTEX       <>
tci           TC_ITEM         <?>
cr            CHARRANGE       <?>
charF         CHARFORMAT2     <?>
fr            FORMATRANGE     <?>
cc            CHOOSECOLOR     <?>
mdicreate     MDICREATESTRUCT <>

