News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

error_proc_not_found

Started by gelatine1, October 09, 2015, 07:32:31 AM

Previous topic - Next topic

gelatine1

When my program calls the ChoosePixelFormat procedure it gets error 0x7F: ERROR_PROC_NOT_FOUND.
I did include the gdi.Inc and gdi.lib into the program though so I don't really know why this is happening. Also Choosepixelformat returns and invalid pixelformat. (obviously)
Anyone knows what's going on?
Thanks in advance

dedndave

without seeing any code, we are guessing - lol

but....
ChoosePixelFormat is in gdi32.dll
so
        INCLUDE     \masm32\include\gdi32.inc
        INCLUDELIB  \masm32\lib\gdi32.lib


however, it also appears in the OpenGL files

if you have this line, it adds gdi32 (inc and lib)
        INCLUDE     \masm32\include\masm32rt.inc

all that aside, i don't know how you got that specific error
normally, the assembler or linker will bark if something is missing

gelatine1

Quote from: dedndave on October 09, 2015, 09:00:40 AM
all that aside, i don't know how you got that specific error
normally, the assembler or linker will bark if something is missing

Yep I was thinking the same... I'll try to use gdi32 when I get back on my pc later

gelatine1

Okay I checked now and gdi32 was already included. I'll show you part of the code below:
The call to ChoosePixelFormat is in the CreateGLWindow proc. Anyone who knows why this is happening?


.386
.model flat,stdcall
option casemap:none


include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\kernel32.lib
include \masm32\include\user32.inc
includelib \masm32\lib\user32.lib
include \masm32\include\gdi32.inc
includelib \masm32\lib\gdi32.lib
include \masm32\include\msvcrt.inc
includelib \masm32\lib\msvcrt.lib

include ..\OpenGL\def\gl.def
include ..\OpenGL\def\glu.def
include ..\OpenGL\def\winextra.def
include ..\OpenGL\def\include.def
includelib ..\OpenGL\opengl32.lib
includelib ..\OpenGL\glu32.lib

.data?
hrc dd ?
hdc dd ?
hInst dd ?
hwnd dd ?

pfd PIXELFORMATDESCRIPTOR <>

.code
start:
invoke WinMain,0,0,0,SW_SHOWDEFAULT
invoke ExitProcess, eax

CreateGLWindow proc ttle:DWORD,wid:DWORD,hei:DWORD, its:DWORD, fullscreenflag:DWORD
LOCAL PixelFormat:GLuint
LOCAL wc:WNDCLASSEX
LOCAL dwExStyle:DWORD
LOCAL dwStyle:DWORD
LOCAL WindowRect:RECT
LOCAL dmScreenSettings:DEVMODE

mov WindowRect.left,0
push wid
pop WindowRect.right
mov WindowRect.top,0
push hei
pop WindowRect.bottom
push fullscreenflag
pop fullscreen

mov     wc.cbSize,sizeof WNDCLASSEX
mov     wc.style,CS_HREDRAW or CS_VREDRAW or CS_OWNDC
mov     wc.lpfnWndProc,WndProc
mov     wc.cbClsExtra,0
mov     wc.cbWndExtra,0
invoke GetModuleHandle,0
mov     wc.hInstance,eax
invoke  LoadIcon,NULL,IDI_WINLOGO
mov     wc.hIcon,0
invoke  LoadCursor,NULL,IDC_ARROW
mov     wc.hCursor,eax
;invoke CreateSolidBrush,0055FF33h
mov     wc.hbrBackground,0
mov     wc.lpszMenuName,0
mov     wc.lpszClassName,offset OpenGL
mov     wc.hIconSm,0

invoke RegisterClassEx,addr wc
cmp eax,0
jnz @F
invoke MessageBox,0,addr error6,addr error6t,MB_OK or MB_ICONINFORMATION
xor eax,eax


;initialising the PIXELFORMATDESCRIPTO
mov pfd.nSize,sizeof PIXELFORMATDESCRIPTOR
mov pfd.nVersion,1
mov pfd.dwFlags,PFD_DRAW_TO_WINDOW or PFD_SUPPORT_OPENGL or PFD_DOUBLEBUFFER
mov pfd.iPixelType,PFD_TYPE_RGBA
mov al,byte ptr [its]
mov pfd.cColorBits,al
mov pfd.cRedBits,0
mov pfd.cRedShift,0
mov pfd.cGreenBits,0
mov pfd.cGreenShift,0
mov pfd.cBlueBits,0
mov pfd.cBlueShift,0
mov pfd.cAlphaBits,0
mov pfd.cAlphaShift,0
mov pfd.cAccumBits,0
mov pfd.cAccumRedBits,0
mov pfd.cAccumGreenBits,0
mov pfd.cAccumBlueBits,0
mov pfd.cAccumAlphaBits,0
mov pfd.cDepthBits,16
mov pfd.cStencilBits,0
mov pfd.cAuxBuffers,0
mov pfd.iLayerType,PFD_MAIN_PLANE
mov pfd.bReserved,0
mov pfd.dwLayerMask,0
mov pfd.dwVisibleMask,0
mov pfd.dwDamageMask,0

invoke GetDC,hwnd
mov hdc,eax
cmp eax,0
jnz @F
invoke KillGLWindow
invoke MessageBox,0,addr error10,addr error6t,MB_OK or MB_ICONEXCLAMATION
xor eax,eax
ret
@@:
invoke ChoosePixelFormat,hdc,addr pfd ;returns 4 in eax and gives last error 0x7F
mov PixelFormat,eax
cmp eax,0
jnz @F
invoke KillGLWindow
invoke MessageBox,0,addr error11,addr error6t,MB_OK or MB_ICONEXCLAMATION
xor eax,eax
ret

CreateGLWindow endp

WinMain proc hInstance:HINSTANCE,hPrevInstance:HINSTANCE,lpCmdLine:LPSTR,nCmdShow:DWORD
LOCAL msg:MSG
LOCAL done:DWORD
mov done,0 ;make sure done is initialised to zero

invoke MessageBox,0,addr q1,addr q1t,MB_YESNO or MB_ICONQUESTION
cmp eax,IDNO
jnz @F
mov fullscreen,0
@@:
invoke CreateGLWindow,addr OpenGL,640,480,16,fullscreen
cmp eax,0
jnz @F
xor eax,eax
ret

;messageloop...

@done:  ;end of loop
invoke KillGLWindow ;Kill the window
mov eax,msg.wParam
ret
WinMain endp



jj2007

So your program assembles fine, and then crashes. I'd be surprised if it did NOT crash, actually...:

   invoke ChoosePixelFormat,hdc,addr pfd ;returns 4 in eax and gives last error 0x7F
   mov PixelFormat,eax
   cmp eax,0
   jnz @F
   invoke KillGLWindow
   invoke MessageBox,0,addr error11,addr error6t,MB_OK or MB_ICONEXCLAMATION
   xor eax,eax
   ret

CreateGLWindow endp

WinMain proc hInstance:HINSTANCE,hPrevInstance:HINSTANCE,lpCmdLine:LPSTR,nCmdShow:DWORD
   LOCAL msg:MSG
   LOCAL done:DWORD
   mov done,0 ;make sure done is initialised to zero
   
   invoke MessageBox,0,addr q1,addr q1t,MB_YESNO or MB_ICONQUESTION
   cmp eax,IDNO
   jnz @F
   mov fullscreen,0
@@:

gelatine1

Whoops that's just a tiny bug created by leaving some parts out... in my full code there's a @@: right after the ret...
And no the program doesn't crash. It simply doesn't work because it doesn't get a valid PixelFormat. When I opened up odbg I saw that ChoosePixelFormat raises the error_proc_not_found...

the following call which comes after that gives me the error (in odbg) ERROR_INVALID_ID_PIXEL_FORMAT (0x7D0)

invoke wglCreateContext,hdc

qWord

Is the program and it's code confidential? If not, it might be helpful to see if the problem also occurs on other machines.
MREAL macros - when you need floating point arithmetic while assembling!

rrr314159

@jj, It's nit-picking but actually if you reference @F without an @@: label down there, it won't assemble either

@gelatine1, did you remember to disable AV?

It should definitely find the proc ChoosePixelFormat, with gdi32.inc and .lib included. Unless ... there is one problem that can occur, you can get an invisible character in, for instance, the text string ChoosePixelFormat. qEditor doesn't indicate it, but the assembler reads the wrong name. Can happen when copy-and-pasting from rich text source. Just a wild guess, doubt it applies here
I am NaN ;)

adeyblue

Quote from: gelatine1 on October 10, 2015, 06:59:43 AM
It simply doesn't work because it doesn't get a valid PixelFormat.the following call which comes after that gives me the error (in odbg) ERROR_INVALID_ID_PIXEL_FORMAT (0x7D0)

invoke wglCreateContext,hdc


The likely reason for that is because there's no SetPixelFormat between the ChoosePixelFormat and the wglCreateContext. Since it wasn't set, it probably defaults to index 0 -  which is invalid since its the failure return of ChoosePixelFormat.

jj2007

Quote from: rrr314159 on October 10, 2015, 10:46:35 AM@jj, It's nit-picking but actually if you reference @F without an @@: label down there, it won't assemble either

Correct. It would work with global labels as shown below, but @@ is a local label. Btw it's a really bad habit to post untested partial code, hoping that other members have plenty of time to add the missing parts for testing.

include \masm32\include\masm32rt.inc

.code
p1 proc arg1
  jmp @F0
  ret
p1 endp

p2 proc arg2
@F0::
  MsgBox 0, arg2, "Hi", MB_OK
  ret
p2 endp

start: invoke p1, chr$("holy crap")
exit

end start


gelatine1

Quote from: jj2007 on October 10, 2015, 12:45:19 PM
Btw it's a really bad habit to post untested partial code, hoping that other members have plenty of time to add the missing parts for testing.

Alright, sorry, full (possible messy) code below in attachment. I thought i shouldn't post the full code because it would give you much more code to read through which are not so relevant...

gelatine1

Quote from: adeyblue on October 10, 2015, 12:27:43 PM
The likely reason for that is because there's no SetPixelFormat between the ChoosePixelFormat and the wglCreateContext. Since it wasn't set, it probably defaults to index 0 -  which is invalid since its the failure return of ChoosePixelFormat.

:greenclp: Thank you. This solved my problem now the call to wglCreateContext does work properly. Although I checked in odbg the ChoosePixelFormat does still raise the ERROR_PROC_NOT_FOUND but I guess I'll just ignore that...

dedndave

the only thing that comes to mind is that the device doesn't support that format
however, i think it will return a different error for that
which suggests there is something wrong with the structure contents
verify that the structure, as defined in the windows.inc file, matches the one in MSDN documentation
otherwise, perhaps there is a flag missing or something
i wouldn't give up on it, because there has to be a good reason why it's not working