61
Using NASM / Re: windows x86 64bit help
« Last post by hockey97 on August 31, 2024, 04:47:54 PM »Nevermind... I got it working. It was looking for the files but couldn't access them due to permission issues. I fixed it and it now works.
you cannot just convert the 32-bit source to 64-bit by just switching the assembler's command-line.
just notice the difference between the Hello World samples in 32-bit assembly and a 64-bit assembly.
32-bit are more into pushes when feeding data into an API that you wanna run..
64-bit is somehow similar to DOS..
cd "$(CURRENT_DIRECTORY)"
nasm -fwin32 $(FILE_NAME) -o $(NAME_PART).o
ld -mi386pe $(NAME_PART).o C:\Windows\SysWOW64\user32.dll
ld -mi386pe $(NAME_PART).o C:\Windows\SysWOW64\Kernel32.dll
gcc -m32 $(NAME_PART).o -o $(NAME_PART).exe
$(NAME_PART).exe
/* main.c */
#include <windows.h>
/* Protótipo do procedimento de janela */
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain(HINSTANCE hInst,
HINSTANCE hPrevInst,
LPSTR lpszCmdLine,
int nCmdShow)
{
const static LPCSTR szClassName = "SimpleAppClass";
HWND hWnd;
MSG msg;
WNDCLASS wc =
{
.style = CS_HREDRAW | CS_VREDRAW,
.lpfnWndProc = WndProc,
.hInstance = hInst,
.hIcon = LoadIcon(NULL, IDI_APPLICATION),
.hCursor = LoadCursor(NULL, IDC_ARROW),
.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1),
.lpszClassName = szClassName
};
RegisterClass(&wc);
/* Este estilo criará uma janela "normal" que não pode
ser maximizada ou ter seu tamanho alterado. */
#define WINDOW_STYLE WS_OVERLAPPED | \
WS_SYSMENU | \
WS_VISIBLE | \
WS_BORDER | \
WS_MINIMIZEBOX | \
WS_CAPTION
hWnd = CreateWindowEx( 0,
szClassName,
"My Simple App",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT,
320, 100,
NULL, NULL,
hInst,
NULL );
if ( ! hWnd )
{
/* Trata erro se não conseguiu criar a janela. */
MessageBox( NULL,
"Erro ao tentar criar a janela da aplicação.",
"Erro",
MB_OK | MB_ICONERROR);
return 0;
}
UpdateWindow( hWnd );
ShowWindow( hWnd, SW_SHOW ); /* Sempre mostra! */
while ( GetMessage( &msg, NULL, 0, 0 ) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
return msg.wParam;
}// winproc.c
#include <windows.h>
LRESULT CALLBACK WndProc( HWND hWnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam )
{
PAINTSTRUCT ps;
RECT rc;
// Processa mensagens...
switch (uMsg)
{
// Ao destruir a janela...
case WM_DESTROY:
PostQuitMessage(0);
return 0;
case WM_PAINT:
GetClientRect( hWnd, &rc );
BeginPaint( hWnd, &ps );
DrawText( ps.hdc, "Hello, world!", -1, &rc, DT_CENTER | DT_VCENTER );
EndPaint( hWnd, &ps );
return 0;
}
// Trata todas as outras mensagens.
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}Surely it's better to learn the Windows 64-bit API for 64-bit Windows apps? Does the Win32 API even still exist in Windows 11?Yes, for windows api you can write 32 bit programs and 64 bit programs.
[quote author=fredericopissarra link=topic=3932.msg16182#msg16182 date=1724765437]
There is NO Win64 API on Windows. There is MS ABI for x86-64 (there's a subtle difference).
[/quote]
There's a 64bit version. I know it's not a 64bit version but I am asking for what you said. x86-64.
They will have to have one in the future though because Intel is ditching backwards capability their future cpus will have a 64BIT ISA.
but I am talking what you said.
I know this works for 32 bit programs:
[[removed]
this is the cmd commands. This works with no issues.
However, don't know how I can do this for a 64 bit program.
I know the WOW64 is for 32 bit programs for the windows api files.
The 64 bit files reside in System32 folder.
My point is what commands would be used to do the same exact thing but for 64bit programs?