home *** CD-ROM | disk | FTP | other *** search
/ ftp.sberbank.sumy.ua / 2014.11.ftp.sberbank.sumy.ua.tar / ftp.sberbank.sumy.ua / incoming / 1 / KEM2SQT1.asm < prev    next >
Assembly Source File  |  2014-02-08  |  10KB  |  477 lines

  1.       .386
  2.       .model flat, stdcall  ; 32 bit memory model
  3.       option casemap :none  ; case sensitive
  4.  
  5.  
  6.       include \masm32\include\windows.inc
  7.       include \masm32\include\user32.inc
  8.       include \masm32\include\kernel32.inc
  9.       include \masm32\include\gdi32.inc
  10.       
  11.       includelib \masm32\lib\user32.lib
  12.       includelib \masm32\lib\kernel32.lib
  13.       includelib \masm32\lib\gdi32.lib
  14.  
  15.       return MACRO arg
  16.         mov eax, arg
  17.         ret
  18.       ENDM
  19.  
  20.  
  21.   WinMain PROTO :DWORD,:DWORD,:DWORD,:DWORD
  22.   WndProc PROTO :DWORD,:DWORD,:DWORD,:DWORD
  23.   AnsiToInt PROTO :DWORD
  24.   Display24BitDib PROTO :DWORD
  25.   Display24BitBmp PROTO :DWORD
  26.   MakeWay PROTO :DWORD, :DWORD
  27.   GetFileTimeNameFormat PROTO
  28.   
  29.  
  30.  
  31. .data
  32.  
  33.  szClassName   db "666666666666666666666666666666666666666",0
  34.  szDisplayName db "<>",0
  35.  strWprintfNum db "%08d%s",0
  36.  strTxt        db ".txt",0 
  37.  strBmp        db ".bmp",0
  38.  
  39.  cFileName     db 256 dup(0)
  40.  dTable        dd 640 dup(0)      
  41.  
  42.  number        dd 0  
  43.  
  44.  CommandLine   dd 0
  45.  hWnd          dd 0
  46.  hInstance     dd 0
  47.  hIcon         dd 0 
  48.  hFindFile     dd 0 
  49.  Sign          dd 0 
  50.  Min           dd 0
  51.  Max           dd 0
  52.  date          dd 0
  53.  
  54.  picWidth      dd 640
  55.  picHeight     dd 480 
  56.  
  57.  strFindFile   WIN32_FIND_DATA <0>
  58.  
  59.  sysTime  SYSTEMTIME <0>
  60.  
  61. .code
  62.  
  63. start:
  64.       invoke GetModuleHandle, NULL
  65.       mov hInstance, eax
  66.  
  67.       invoke GetCommandLine
  68.       mov CommandLine, eax
  69.  
  70.       invoke WinMain, hInstance,NULL,CommandLine,SW_SHOWDEFAULT
  71.       invoke ExitProcess,eax
  72.  
  73. WinMain proc hInst     :DWORD, hPrevInst :DWORD, CmdLine   :DWORD, CmdShow   :DWORD
  74.  
  75.       LOCAL wc   :WNDCLASSEX
  76.       LOCAL msg  :MSG
  77.  
  78.       mov wc.cbSize,          sizeof WNDCLASSEX
  79.       mov wc.style,           CS_HREDRAW or CS_VREDRAW \
  80.                               or CS_BYTEALIGNWINDOW
  81.       mov  wc.lpfnWndProc,    offset WndProc
  82.       mov  wc.cbClsExtra,     NULL
  83.       mov  wc.cbWndExtra,     NULL
  84.       push hInst
  85.       pop  wc.hInstance
  86.       mov  wc.hbrBackground,  COLOR_WINDOW
  87.       mov  wc.lpszMenuName,   NULL
  88.       mov  wc.lpszClassName,  offset szClassName
  89.       push hIcon
  90.       pop  wc.hIcon
  91.       invoke LoadCursor,NULL,IDC_ARROW
  92.       mov  wc.hCursor,        eax
  93.       push hIcon 
  94.       pop  wc.hIconSm
  95.  
  96.       invoke RegisterClassEx, ADDR wc
  97.  
  98.  
  99.       invoke CreateWindowEx, 0,
  100.                             ADDR szClassName,
  101.                             ADDR szDisplayName,
  102.                             WS_OVERLAPPEDWINDOW,
  103.                             0,0,650,520,
  104.                             NULL,NULL,
  105.                             hInst,NULL
  106.       mov   hWnd,eax
  107.  
  108.       invoke ShowWindow,hWnd,SW_SHOWNORMAL
  109.       invoke UpdateWindow,hWnd
  110.  
  111.     StartLoop:
  112.       invoke GetMessage,ADDR msg,NULL,0,0
  113.       cmp eax, 0
  114.       je ExitLoop
  115.       invoke TranslateMessage, ADDR msg
  116.       invoke DispatchMessage,  ADDR msg
  117.       jmp StartLoop
  118.     ExitLoop:
  119.  
  120.       return msg.wParam
  121.  
  122. WinMain endp
  123.  
  124.  
  125. WndProc proc hWin   :DWORD, uMsg   :DWORD, wParam :DWORD, lParam :DWORD
  126.  
  127.     LOCAL Ps   :PAINTSTRUCT
  128.     LOCAL hDC  :DWORD
  129.     LOCAL hTextFile :DWORD
  130.     LOCAL dwBytesRead :DWORD 
  131.     
  132.  
  133.     .if uMsg == WM_CREATE
  134.         
  135.        push edi
  136.        push esi
  137.  
  138.        cld 
  139.        mov ecx, 39
  140.        lea esi, szClassName
  141.        lea edi, cFileName
  142.        rep movsb          
  143.  
  144.        pop  esi
  145.        pop  edi 
  146.  
  147. WndProc_FindFile:
  148.  
  149.        cmp number, 0fffffh
  150.        ja  WndProc_Exit_Read_File 
  151.           
  152.        invoke wsprintf, addr cFileName, addr strWprintfNum, number, addr strTxt
  153.        inc  number  
  154.  
  155.        invoke FindFirstFile, addr cFileName, addr strFindFile
  156.        mov    hFindFile, eax
  157.        cmp eax, INVALID_HANDLE_VALUE
  158.        je  WndProc_Invalid_Handle 
  159.        mov Sign, 0ffh 
  160.         
  161.  
  162.        ; invoke MessageBox, hWin, addr cFileName, addr cFileName, 0 
  163.        
  164.       invoke CreateFile, addr cFileName, GENERIC_READ,\
  165.               0, NULL, OPEN_EXISTING,\
  166.               FILE_ATTRIBUTE_NORMAL, NULL
  167.       mov hTextFile, eax
  168.      
  169.         mov picWidth, 640
  170.         mov picHeight, 480 
  171.  
  172.         invoke ReadFile, hTextFile, addr cFileName, 1, addr dwBytesRead, NULL
  173.         cmp BYTE PTR cFileName, "1"
  174.         jne WndProc_File_X_Y
  175.         
  176.         mov picWidth, 320
  177.         mov picHeight, 240 
  178.  
  179. WndProc_File_X_Y: 
  180.         
  181.         push   edi
  182.         cld 
  183.         mov  ecx, 20
  184.         lea    edi, cFileName 
  185.         mov    eax,0
  186.         rep    stosd
  187.         pop    edi 
  188.  
  189.         invoke    ReadFile, hTextFile, addr cFileName, 8, addr dwBytesRead, NULL
  190.         invoke    AnsiToInt, addr cFileName 
  191.         mov Min, eax      
  192.  
  193.         push   edi
  194.         cld 
  195.         mov  ecx, 20
  196.         lea    edi, cFileName 
  197.         mov    eax,0
  198.         rep    stosd
  199.         pop    edi 
  200.  
  201.         invoke    ReadFile, hTextFile, addr cFileName, 8, addr dwBytesRead, NULL
  202.         invoke    AnsiToInt, addr cFileName 
  203.         mov Max, eax
  204.  
  205.       ;  invoke wsprintf, addr cFileName, addr strWprintfNum, eax, 0
  206.       ;  invoke MessageBox, hWnd, addr cFileName, addr cFileName,0     
  207.  
  208.         invoke    CloseHandle, hTextFile
  209.         
  210.         invoke  FindClose, hFindFile 
  211.         jmp     WndProc_FindFile     
  212.         
  213. WndProc_Invalid_Handle:
  214.         cmp  Sign, 0
  215.         je   WndProc_FindFile        
  216.  
  217. WndProc_Exit_Read_File:
  218.  
  219.         return 0
  220.  
  221.     .elseif uMsg == WM_TIMECHANGE
  222.  
  223.         invoke InvalidateRect, hWin,0,0
  224.         return 0
  225.  
  226.     .elseif uMsg == WM_PAINT
  227.         invoke BeginPaint,hWin,ADDR Ps
  228.         mov hDC, eax
  229.   
  230.         invoke Display24BitDib, hDC
  231.         invoke Display24BitBmp, hDC        
  232.         invoke GetFileTimeNameFormat
  233.  
  234.         invoke EndPaint,hWin,ADDR Ps
  235.         return 0
  236.  
  237.     .elseif uMsg == WM_DESTROY
  238.         invoke PostQuitMessage,NULL
  239.         return 0 
  240.     .endif
  241.  
  242.     invoke DefWindowProc,hWin,uMsg,wParam,lParam
  243.  
  244.     ret
  245.  
  246. WndProc endp
  247.  
  248. GetFileTimeNameFormat proc
  249.     invoke GetLocalTime, addr sysTime
  250.     mov ax, sysTime.wYear
  251.     and eax, 0ffffh
  252.     sub ax, 2000
  253.     mov date, eax
  254.     xor edx, edx
  255.     mov ecx, 10
  256.     div ecx
  257.     mov date, edx
  258.     mov edx, 100
  259.     mul edx
  260.     add date, eax
  261.  
  262.     mov ax, sysTime.wMonth
  263.     and eax, 0ffffh
  264.     mov ecx, 10
  265.     mul ecx
  266.     add date, eax
  267.  
  268.     mov ax, sysTime.wDay
  269.     and eax, 0ffffh
  270.     mov ecx, 1000
  271.     mul ecx
  272.     add date, eax
  273.  
  274.     mov eax, date
  275.     mov ecx, 1000
  276.     mul ecx
  277.  
  278.     mov Min, eax
  279.     add eax, 999
  280.     mov Max, eax
  281.  
  282.    ; invoke wsprintf, addr cFileName, addr strWprintfNum, eax, 0
  283.    ; invoke MessageBox, hWnd, addr cFileName, addr cFileName,0     
  284.  
  285.     ret
  286. GetFileTimeNameFormat endp
  287.  
  288. MakeWay proc Pos:DWORD, Col:DWORD
  289.     push esi
  290.     push edi
  291.  
  292.     push   edi
  293.     cld 
  294.     mov  ecx, 640
  295.     lea    edi, dTable 
  296.     mov    eax,0
  297.     rep    stosb
  298.     pop    edi 
  299.  
  300.     mov ecx, Col  
  301.     mov eax, Pos
  302.     shl eax, 2    
  303.     mov DWORD PTR dTable[eax], ecx 
  304.  
  305.     pop  edi
  306.     pop  esi
  307.  
  308.     ret
  309. MakeWay endp
  310.  
  311. Display24BitDib proc hDC:DWORD
  312.   LOCAL X,Y:DWORD
  313.   LOCAL hFile:DWORD
  314.   LOCAL RGB:DWORD
  315.   LOCAL wBytesRead:DWORD
  316.  
  317.     push edi
  318.     push esi
  319.     push ebx
  320.  
  321.     push Min
  322.     pop  number
  323.  
  324. Display24BitDib_Number:
  325.     invoke    wsprintf, addr cFileName, addr strWprintfNum, number, addr strBmp
  326.    
  327.     invoke CreateFile, addr cFileName, GENERIC_READ,\
  328.               0, NULL, OPEN_EXISTING,\
  329.               FILE_ATTRIBUTE_NORMAL, NULL
  330.     cmp eax, INVALID_HANDLE_VALUE
  331.     je  Display24BitDib_No_File
  332.     mov hFile, eax
  333.  
  334.     invoke SetFilePointer, hFile, 54, 0, FILE_BEGIN
  335.  
  336.     mov eax, picHeight
  337.     dec eax 
  338.     mov Y, eax
  339. Display24BitDib_Y:
  340.     mov X, 0
  341. Display24BitDib_X:
  342.     lea ecx, RGB
  343.     lea eax, wBytesRead
  344.     invoke ReadFile, hFile, ecx, 3, eax, NULL
  345.     and RGB, 0ffffffh
  346.  
  347.     invoke MakeWay, X, RGB
  348.  
  349.     invoke SetPixel, hDC, X, Y, RGB
  350.     inc X
  351.     mov eax, X
  352.     cmp eax, picWidth
  353.     jne Display24BitDib_X
  354.     dec Y
  355.     cmp Y,0
  356.     jns Display24BitDib_Y
  357.  
  358.     invoke CloseHandle, hFile
  359.  
  360. Display24BitDib_No_File:
  361.     inc number
  362.     mov eax, Max
  363.     cmp number, eax
  364.     jbe Display24BitDib_Number
  365.  
  366.     pop ebx
  367.     pop esi
  368.     pop edi
  369.  
  370.     ret
  371. Display24BitDib endp
  372.  
  373. Display24BitBmp proc hDC:DWORD
  374.   LOCAL X,Y:DWORD
  375.   LOCAL hFile:DWORD
  376.   LOCAL RGB:DWORD
  377.   LOCAL wBytesRead:DWORD
  378.  
  379.     push edi
  380.     push esi
  381.     push ebx
  382.  
  383.     push Min
  384.     pop  number
  385.  
  386. Display24BitBmp_Number:
  387.     invoke    wsprintf, addr cFileName, addr strWprintfNum, number, addr strBmp
  388.    
  389.     invoke CreateFile, addr cFileName, GENERIC_READ,\
  390.               0, NULL, OPEN_EXISTING,\
  391.               FILE_ATTRIBUTE_NORMAL, NULL
  392.     cmp eax, INVALID_HANDLE_VALUE
  393.     je  Display24BitBmp_No_File
  394.     mov hFile, eax
  395.  
  396.     invoke SetFilePointer, hFile, 54, 0, FILE_BEGIN
  397.  
  398.     mov Y, 0
  399. Display24BitBmp_Y:
  400.     mov X, 0
  401. Display24BitBmp_X:
  402.     lea ecx, RGB
  403.     lea eax, wBytesRead
  404.     invoke ReadFile, hFile, ecx, 3, eax, NULL
  405.     and RGB, 0ffffffh
  406.  
  407.     invoke MakeWay, X, RGB
  408.  
  409.     invoke SetPixel, hDC, X, Y, RGB
  410.     inc X
  411.     mov eax, X
  412.     cmp eax, picWidth 
  413.     jne Display24BitBmp_X
  414.     inc Y
  415.     mov eax, Y
  416.     cmp eax, picHeight
  417.     jb  Display24BitBmp_Y
  418.  
  419.     invoke CloseHandle, hFile
  420.  
  421. Display24BitBmp_No_File:
  422.     inc number
  423.     mov eax, Max
  424.     cmp number, eax
  425.     jbe Display24BitBmp_Number
  426.  
  427.     pop ebx
  428.     pop esi
  429.     pop edi
  430.  
  431.     ret
  432. Display24BitBmp endp
  433.  
  434. AnsiToInt  proc lpStr:DWORD 
  435.  
  436.     push   edi 
  437.  
  438.     mov  ecx, 64  
  439.     mov  edi, lpStr   
  440.     mov  al, 0
  441.     repne scasb
  442.     mov eax, 63   
  443.     sub eax, ecx 
  444.  
  445.     mov ecx, eax
  446.     mov edi, lpStr
  447.     add edi, eax
  448.     dec edi  
  449.  
  450.     push ebx
  451.     push esi
  452.     mov  esi, 0
  453.     mov  ebx, 1
  454. AnsiToInt_Cycle:
  455.     mov al, [edi]
  456.     dec edi 
  457.     sub al, "0" 
  458.     and eax, 0ffh
  459.     
  460.     mul ebx
  461.     add esi, eax
  462.  
  463.     mov eax, 10 
  464.     mul ebx
  465.     push eax
  466.     pop  ebx
  467.  
  468.     loop AnsiToInt_Cycle
  469.     mov  eax, esi
  470.     pop  esi
  471.     pop  ebx
  472.  
  473.     pop    edi   
  474.     ret
  475. AnsiToInt endp
  476. end start
  477.