![]() |
How to fix these three RadASM compile errors?
1 Attachment(s)
I'm working on an asm file, now seems only 3 errors, I don't understand it, anyone can give help? Many thanks.
K:\testasm\_tolower.asm(18) : error A2008: syntax error : _SYSTEM_INFO K:\testasm\_tolower.asm(38) : error A2008: syntax error : type K:\testasm\_tolower.asm(498) : error A2081: missing operand after unary operator |
First Error:
first field of _SYSTEM_INFO struc cannot refer itself. In Windows it is an union union { DWORD dwOemId; struct { WORD wProcessorArchitecture; WORD wReserved; }; }; but you can replace the line anonymous_0 _SYSTEM_INFO::$1593C2ABA4C275C0FBEC2498FA3B0937 ? with dwOemId dd ? without problems Second and third error: "Type" name is a reserved word: simply replace it with _Type, for example Best regards, bilbo |
Quote:
After generate the .obj file and do LINK with VC, it reports errors below, any lib file I need add when do LINK? ; Imports from KERNEL32.dll ; HMODULE __stdcall GetModuleHandleA(LPCSTR lpModuleName) externdef GetModuleHandleA:dword error LNK2019: Unresolved external symbol _GetModuleHandleA ...... error LNK2019: Unresolved external symbol _LeaveCriticalSection |
you should link with kernel32.lib
|
Quote:
Below is the options I used: LINK /nologo /NODEFAULTLIB /OPT:NOREF /out:test.exe test.obj lmgr.lib libsb.lib libcrvs.lib .\activation\lib\libnoact.lib oldnames.lib kernel32.lib user32.lib netapi32.lib advapi32.lib gdi32.lib comdlg32.lib comctl32.lib wsock32.lib libcmt.lib _tolower.obj |
you need to set environment variable or include path for those libs in link parameters /LIBPATH, IIRC
|
Quote:
I do the VC setting as below, is this enough or still something missing? Thank you for your help on check. @set MYPATH=C:\Program Files\VC2008 @set PATH=%MYPATH%\bin @set INCLUDE=%MYPATH%\include;%MYPATH%\PlatformSDK\Include;%MYPATH%\atlmfc\include;%MYPATH%\DirectX_SDK\Include; @set LIB=%MYPATH%\lib;%MYPATH%\PlatformSDK\Lib;%MYPATH%\atlmfc\lib;%MYPATH%\DirectX_SDK\Lib\x86; |
kernel32.lib does not export GetModuleHandleA, but _imp__GetModuleHandleA
So you need to replace Code:
externdef GetModuleHandleA:dwordCode:
pr1 typedef PROTO :DWORDbilbo |
Quote:
|
Quote:
|
Hi Bilbo,
Seems I can't simply copy/paste and just rename the function name as solution for other Unresolved external symbols. I modify GetLastError as below, but don't works. pr2 typedef PROTO ��DWORD externdef _imp__GetLastError@4:PTR pr2 GetLastError equ <_imp__GetLastError@4> Is there easy way can work it out for all Unresolved external symbols below? _GetLastError _MultiByteToWideChar _WideCharToMultiByte _GetCurrentProcess _VirtualAlloc _VirtualFree _SetLastError _WriteFile _GetModuleFileNameA _GetSystemInfo _VirtualProtect _GetCPInfo _GetLocaleInfoA _VirtualQuery _InterlockedExchange _InitializeCriticalSection _GetStringTypeW _GetStringTypeA _LoadLibraryA _GetProcAddress _GetStdHandle _GetCurrentThreadId _LCMapStringW _LCMapStringA _ExitProcess _TerminateProcess _HeapReAlloc _HeapAlloc _HeapFree |
Quote:
Quote:
Quote:
ms_exc = CPPEH_RECORD ptr -18h in _tolower.asm? Best regards bilbo |
Quote:
Quote:
Quote:
Many many thanks, bilbo, you help me a lots, very appreciated. :) |
Hi
Radasm set standart the environment variable or include path You must only add in the source include the Lib Include kernel32.inc Includelib kernel32.lib Or use a macro called "uselib" uselib kernel,gdi32,..... |
Quote:
I have done that way, but seems doesn't work, would you give more suggestion whether others need check? Thanks. |
1 Attachment(s)
it's strange that you cannot go to the provided link: it is up...
anyway here is the program, from vortex.masmcode.com and thanks for the /Zm tip I was unaware of... bilbo |
Quote:
|
@ Av0id, ragdog
I think our importing problems are related to the calling convention adopted, which is supposedly != stdcall @ bridgeic it sounds like you are a very unluck man... I tried the program on all masm32 libs without problems... Best regards, bilbo |
Quote:
I don't know why I can't download your attachement in exetools forum. Not sure whether the file lib2inc I used is same with yours, I download it from http://www.winasm.net/library-to-include.html Anyway, based on your guide below, I wrote a perl script to solve it as workround. @4 means the total number of bytes required by function arguments Thanks, bridgeic |
Quote:
|
.686
.model flat, stdcall ;32 bit memory model option casemap :none ;case sensitive include windows.inc include kernel32.inc includelib kernel32.lib |
Quote:
When I set it as your suggestion, RadASM give error below when compile, would you help check why? D:\RadASM_2.2.1.9\Masm32\Include\windows.inc(11326) : error A2005: symbol redefinition : Red D:\RadASM_2.2.1.9\Masm32\Include\windows.inc(11327) : error A2005: symbol redefinition : Green D:\RadASM_2.2.1.9\Masm32\Include\windows.inc(11328) : error A2005: symbol redefinition : Blue D:\RadASM_2.2.1.9\Masm32\Include\windows.inc(12224) : error A2005: symbol redefinition : fReserved D:\RadASM_2.2.1.9\Masm32\Include\windows.inc(18572) : error A2005: symbol redefinition : Type1 D:\RadASM_2.2.1.9\Masm32\Include\windows.inc(18617) : error A2005: symbol redefinition : Type1 D:\RadASM_2.2.1.9\Masm32\Include\windows.inc(18621) : error A2005: symbol redefinition : Type1 D:\RadASM_2.2.1.9\Masm32\Include\windows.inc(18624) : fatal error A1010: unmatched block nesting Thanks, bridgeic |
Quote:
question1: When I set it as your suggestion, RadASM give error below when compile, would you help check why? D:\RadASM_2.2.1.9\Masm32\Include\windows.inc(11326) : error A2005: symbol redefinition : Red D:\RadASM_2.2.1.9\Masm32\Include\windows.inc(11327) : error A2005: symbol redefinition : Green D:\RadASM_2.2.1.9\Masm32\Include\windows.inc(11328) : error A2005: symbol redefinition : Blue D:\RadASM_2.2.1.9\Masm32\Include\windows.inc(12224) : error A2005: symbol redefinition : fReserved D:\RadASM_2.2.1.9\Masm32\Include\windows.inc(18572) : error A2005: symbol redefinition : Type1 D:\RadASM_2.2.1.9\Masm32\Include\windows.inc(18617) : error A2005: symbol redefinition : Type1 D:\RadASM_2.2.1.9\Masm32\Include\windows.inc(18621) : error A2005: symbol redefinition : Type1 D:\RadASM_2.2.1.9\Masm32\Include\windows.inc(18624) : fatal error A1010: unmatched block nesting question 2: after remove "include windows.inc", it can be compiled succesfully, but when do LINK in VC, it still reports errors below, how to solve this issue? error LNK2019: Unresolved external symbol _GetModuleHandleA Thanks, bridgeic |
Send me you Project
I look into |
Quote:
Would you help me have a look on question 1 first? I'll try to upload the test case for question 2 tomorrow, it's a little big. In fact, it's FlexLM SDK 11.4, if you have it already, I need only share two files then. Thanks, bridgeic |
I cannot answer your questions without see your source ;-)
But i think your have trouble with the includes |
1 Attachment(s)
Quote:
For question 1, please get the asm source code as attached, thank you. |
Hi ragdog,
Another help please, can you run the program lib2inc22.exe that bilbo shared succesfully? Thanks, bridgeic |
Hi ragdog,
Question 1. seems the errors caused by /Zm option Question 2. Sorry, the test case upload always failed for the slow network speed. Thanks, bridgeic |
To convert it to compile it with masm is to many works
What make _tolower convert it uppercase letter to lower? Example ABCD to abcd? Or what make this source? /Zm option Enables M510 option for maximum compatibility with MASM 5.1. |
Quote:
Yes, just convert it uppercase letter to lower. In fact, we can set this whole function as library function instead of including the code of this function in the ASM code. I study it just want to learn more thing. By your opinion, with right definition of including kernel32.lib, setting below is not must, right? pr1 typedef PROTO : DWORD externdef _imp__GetModuleHandleA@4:PTR pr1 GetModuleHandleA equ <_imp__GetModuleHandleA@4> With this way, I have passed the LINK steps, but the results is not right, I'm still checking what's wrong. I'll try to build up a small test case, hope you can help me to have a check, many thanks. By the way, may I check with you whether you can run lib2inc22.exe succesfully? |
Why use you not the apis crt__tolower or CharLower
|
Quote:
|
1 Attachment(s)
Hi ragdog,
Would you help check this small test case, Why failed when do LINK? ( I use the include based on your suggestion) 1. compile newtolower.asm to get newtolower.obj 2. run build.cmd to get newtest.exe(not succesful, can't find newtolower function) Thanks, bridgeic |
1 Attachment(s)
Quote:
newtolower proc near ,argv1: DWORD |
Quote:
again a problem of calling conventions... newtolower() must be CDECL since the stack is adjusted on return by the caller.. Please google for calling conventions... In first newtolower.asm you will obtain a decorated name _newtolower@0: that's not ok, it is a STDCALL decoration with 0 bytes as arguments In second newtolower.asm you will obtain a decorated name _newtolower@4: that's not ok, it is a STDCALL decoration with 4 bytes as arguments (it gots linked because the function declaration is coherent in both files, but the stack will be corrupted). So the correct ASM must be: Code:
newtolower proc near cCode:
extern int newtolower(int);Code:
call dword_57E704Best regards, bilbo |
Dear bilbo,
Thank you so much for your warm help, seems "call dword_57E704" will be a Gordian knot��do you have any suggestion how to solve this issue? |
Quote:
Trace with ollydbg, seems the value is assigned outside the newtolower function, I'm not sure whether it is this way, still studying. dword_57E704 dd 7C8097D0h ; kernel32.TlsGetValue |
In fact, the trap in your EXE is no more related to that call...
To debug the trap: run it with your preferred debugger... It will break at Code:
004699E0 mov byte ptr [esi],dlIf you look at program memory map (for example through Process Hacker), you will see that memory 514000-51D000 (presumably allocated by LMCRYPT, look at memory content in the debugger) is read-only! Hence the trap due to Access Violation. Best regards, bilbo |
Quote:
I guess I may understand your means, test with ollydbg, if give parameters as "-i input.txt -o output.txt", then it won't run to 004699E0. Seems it will be bottleneck here. :-) |
| All times are GMT +8. The time now is 14:43. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2026, vBulletin Solutions, Inc.
Always Your Best Friend: Aaron, JMI, ahmadmansoor, ZeNiX