sounds like strlcpy is not writing the null char
do not know where is the bug
A community discussion post from the original code:zIRON forum.
Replies
ok here is an other problem.
this function was inline and every thing is okay , but when i change it to be a real function
that return Dx9 interface ,the program crash.
function InitDx9(Dword Wnd,Width,Height)
{
D3DPRESENT_PARAMETERS presParams;
IDirect3DDevice9 dx_device;
m_strFill(@presParams, sizeof presParams, 0);
presParams.hDeviceWindow = Wnd;
presParams.Windowed = True;
presParams.BackBufferWidth = Width;
presParams.BackBufferHeight = Height;
presParams.BackBufferCount = 1;
presParams.BackBufferFormat = D3DFMT_A8R8G8B8;
presParams.SwapEffect = D3DSWAPEFFECT_FLIP;
presParams.AutoDepthStencilFormat = D3DFMT_D16;
presParams.EnableAutoDepthStencil = True;
IDirect3D9 dx_object = Direct3DCreate9(D3D_SDK_VERSION);
Edi = dx_object as IDirect3D9;
Eax = Edi.CreateDevice(0, D3DDEVTYPE_HAL, Wnd, 64, @presParams, @dx_device);
return dx_device;
}
does i made something wrong?
http://www.freewebs.com/ogremagic/index.htm
with some investigation , found that , this line cause the crash.
Eax = Edi.CreateDevice(0, D3DDEVTYPE_HAL, Wnd, 64, @presParams, @dx_device);
http://www.freewebs.com/ogremagic/index.htm
first problem i see is as a function you use edi but don't protect it... add uses clause at top
uses edi;
meanwhile i will find what is the other problem
I have just updated the beta download which addresses this issue, actually there is a big problem with my internal handler for classes/interfaces, i will hopefully get round to doing a whole rewrite of the assembler core over the next months, if i do, the whole backend should be much more stable and have much quicker fixes.
anyways the code i used to test with is based on the directx9 sample:
program WIN32GUI 'DX9Sample';
#include 'user32.zir';
#include 'kernel32.zir';
#include 'messages.zir';
#include 'colors.zir';
#include 'ch.zir';
#include 'directx/direct3d9.zir';
//////////////////////////////
//other variables
tagWndClassA wndClass;
tagMsg msg;
DWord hInstance = GetModuleHandleA(nil);
//
//handles
DWord hMainFRM;
//
//////////////////////////////
function WindowProc(DWord hWnd; DWord uMsg; DWord wParam; DWord lParam) {
if (uMsg == WM_COMMAND) {
eax = DefWindowProcA(hWnd, uMsg, wParam, lParam);
ret
} elseif (uMsg == WM_DESTROY) {
PostQuitMessage(0);
} else {
eax = DefWindowProcA(hWnd, uMsg, wParam, lParam);
}
}
const className = 'ZMainFRM';
wndClass.hbrBackground = COLOR_BACKGROUND;
wndClass.hInstance = hInstance;
wndClass.lpszClassName = className;
wndClass.lpfnWndProc = @WindowProc;
RegisterClassA(@wndClass);
hMainFRM = CreateWindowExA(0, className, 'Ziron DirectX9 Demo', WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 1024, 768, 0, 0, hInstance, nil);
ShowWindow(hMainFRM, SW_SHOWNORMAL);
function InitDx9(Dword Wnd,Width,Height) {
uses edi;
D3DPRESENT_PARAMETERS presParams;
IDirect3DDevice9 dx_device;
m_strFill(@presParams, sizeof presParams, 0);
presParams.hDeviceWindow = Wnd;
presParams.Windowed = True;
presParams.BackBufferWidth = Width;
presParams.BackBufferHeight = Height;
presParams.BackBufferCount = 1;
presParams.BackBufferFormat = D3DFMT_A8R8G8B8;
presParams.SwapEffect = D3DSWAPEFFECT_DISCARD;
presParams.AutoDepthStencilFormat = D3DFMT_D24X8;
presParams.EnableAutoDepthStencil = True;
IDirect3D9 dx_object = Direct3DCreate9(D3D_SDK_VERSION);
Edi = dx_object as IDirect3D9;
Eax = Edi.CreateDevice(0, D3DDEVTYPE_HAL, Wnd, 64, @presParams, @dx_device);
return dx_device;
}
edi = InitDx9(hMainFRM, 1024, 768) as IDirect3DDevice9;
// Set up message loop
while (eax <> WM_QUIT) {
edi.clear(0, nil, 3, 0xFF0000FF, 1.0, 0);
edi.BeginScene;
//
//render something here :)
//
edi.EndScene;
edi.Present(nil, nil, 0, nil);
eax = PeekMessage(@msg, 0, 0, 0, 1);
if (eax) {
TranslateMessage(@msg);
DispatchMessageA(@msg);
eax = msg.message;
}
}
ExitProcess(0);
ok it works fine now.
BTW i have just discovered a bug in plugin statement.
plugin off
program WIN32CUI 'Sprite';
#include 'user32.zir';
#include 'kernel32.zir';
#include 'messages.zir';
this was a part of my code , as you see the first line forces ziron to load no pluging at all
but when compile i found my plugin loaded and manipulate the code.!!!!!!!!!
http://www.freewebs.com/ogremagic/index.htm