Pelles C forum

Assembly language => Assembly discussions => Topic started by: Vortex on October 26, 2024, 08:39:06 PM

Title: Image viewer
Post by: Vortex on October 26, 2024, 08:39:06 PM
A quick example of running the image viewer to display an image :

include     ImageView.inc
include     CstrMacro.asm       

.data?

CurDir      db 64 dup(?)
buffer      db 200 dup(?)
hLib        dd ?
hModule     dd ?

.code

start:

    invoke  GetModuleHandle,0
    mov     hModule,eax
   
    invoke  GetCurrentDirectory,64,ADDR CurDir
    invoke  lstrcat,ADDR CurDir,@Cstr("\ForumLogo.png")

    invoke  UnicodeStr,ADDR CurDir,ADDR buffer

    invoke  LoadLibrary,@Cstr("shimgvw.dll")
    mov     hLib,eax

    invoke  GetProcAddress,eax,\
            @Cstr("ImageView_Fullscreen")

    push    SW_NORMAL
    push    OFFSET buffer
    push    hModule
    push    0
    call    eax

    invoke  FreeLibrary,hLib

    invoke  ExitProcess,0

UnicodeStr  PROC USES esi src:DWORD,dest:DWORD

    mov     esi,src
    mov     edx,dest
    xor     eax,eax
    sub     eax,1
@@:
    add     eax,1
    movzx   ecx,BYTE PTR [esi+eax]
    mov     WORD PTR [edx+eax*2],cx
    test    ecx,ecx
    jnz     @b
    ret

UnicodeStr  ENDP

END start
Title: Re: Image viewer
Post by: HellOfMice on October 29, 2024, 04:04:16 AM
Hi Vortex,


Where can I find shimgvw.dll. The program launch the MS Photo viewer!
Title: Re: Image viewer
Post by: TimoVJL on October 29, 2024, 08:16:38 AM
Windows\system32 or SysWOW64
Same with C and ANSI version
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
void __stdcall ImageView_Fullscreen(HWND, HINSTANCE, const wchar_t*, int);

void __cdecl WinMainCRTStartup(void)
{
char szBuf[MAX_PATH];
int nLen = GetCurrentDirectory(MAX_PATH, szBuf);
lstrcpy(szBuf + nLen, "\\ForumLogo.png");
HMODULE hMod = GetModuleHandle(NULL);
HMODULE hLib = LoadLibrary("shimgvw.dll");
PROC ImageView_Fullscreen = GetProcAddress(hLib, "ImageView_FullscreenA");
ImageView_Fullscreen(0, hMod, szBuf, SW_NORMAL);
ExitProcess(0);
}
Title: Re: Image viewer
Post by: Vortex on October 29, 2024, 09:37:05 AM
Hi HellOfMice,

This DLL is a component of Windows installation :

C:\Windows\System32\shimgvw.dll


shimgvw.dll is the MS Photo viewer application.

Hi Timo,

Thanks for your code.

Title: Re: Image viewer
Post by: John Z on October 29, 2024, 10:09:00 AM
Hi all,

Looks like shimgvw.dll is mainly a shell for GDIPLus and some OLE. plus a whole lot a static linkings.
:) maybe that's what the SH in "shimgvw.dll" means  ;D

The attached doc has some details but is rather dated.

John Z
Title: Re: Image viewer
Post by: HellOfMice on October 29, 2024, 10:26:40 AM
Thank you everybody.