flat assembler
Message board for the users of flat assembler.

Index > Windows > Windows 8 DLL Bad Image error

Goto page Previous  1, 2
Author
Thread Post new topic Reply to topic
Alphonso



Joined: 16 Jan 2007
Posts: 294
Alphonso
typedef wrote:
It seems like Win8 changed maybe? Maybe it requires something else that's missing or some PE field that is not ignored anymore(if there was any that was ignored in previous versions of Windows).
FASM changed too, above code works with ver 1.68 but I guess once the DLL charateristics field was changed (1.69?) to movable then reloc needs to be set to readable, at least for W8..
Post 02 Jun 2012, 02:43
View user's profile Send private message Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
so now they acknowledge/require the read attribute. Very Happy
Post 02 Jun 2012, 03:23
View user's profile Send private message Reply with quote
ogo



Joined: 26 Jan 2012
Posts: 2
ogo
Tomasz Grysztar wrote:
I have just tested it and it appears that Windows 8 doesn't like .reloc section to not have "readable" attribute. So the correction should be to replace the last line with:
Code:
section '.reloc' fixups data readable discardable    

I will update the official example with this fix soon.


Hello Tomasz,

I have tried this, but it does not help.

I am not able to load the DLL with LoadLibrary. The function call returns always NULL.

When I'am using

Code:
format PE DLL at 0x01400000    


it works!


When I'am using

Code:
format PE DLL    


it does NOT work.


What's wrong with it?


Here's my code of the DLL...


Code:
;format PE DLL at 0x01400000
;format PE DLL
format PE GUI 4.0 DLL


entry DllEntry

include 'win32a.inc'


section '.text' code readable executable


  DllEntry:
    ;hinstDLL,fdwReason,lpvReserved
    .hInstance=8
    .dwReason=12
    .lpvReverved=16
    ;enter
    push ebp
    mov ebp,esp
    sub esp,4
    push ebx
    push esi
    push edi
    ;body
    mov eax,TRUE
  .leave:
    pop edi
    pop esi
    pop ebx
    mov esp,ebp
    pop ebp
    ret 0


    db 0x90
    align 16



  GetProperty:
    ;enter
    push ebp
    mov ebp,esp
    sub esp,0
    push ebx
    push esi
    push edi
    ;body
    mov eax,[Property]
  .leave:
    pop edi
    pop esi
    pop ebx
    mov esp,ebp
    pop ebp
    ret 0


    db 0x90
    align 16



  SetProperty:
    ;parameter
    .value=8
    ;enter
    push ebp
    mov ebp,esp
    sub esp,0
    push ebx
    push esi
    push edi
    ;body
    mov eax,[ebp+.value]
    mov [Property],eax
  .leave:
    pop edi
    pop esi
    pop ebx
    mov esp,ebp
    pop ebp
    ret 0


    db 0x90
    align 16





section '.data' data readable writeable

    dd 0,0,0,0
    Property dd 0x12345678


section '.const' data readable

    dd 0,0,0,0



section '.edata' export data readable

  export 'dlltest.dll',\
         GetProperty,'GetProperty',\
         SetProperty,'SetProperty'



;section '.reloc' fixups data readable discardable

;    dd 0,0,0,0     
    



there is no effect with or without reloc section!?
Post 02 Jun 2013, 08:31
View user's profile Send private message Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1137
Location: Russian Federation
comrade
In the future, to debug DLL loading related issues, use gflags.exe (part of the SDK and the debugger kit) and enable "Show loader snaps".

Then start the .exe under a debugger such as ntsd/cdb/windbg, and watch the debug spew printed to the console.

Reference:
http://msdn.microsoft.com/en-us/library/windows/hardware/ff556886%28v=vs.85%29.aspx
Post 01 Aug 2013, 09:24
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.