Exetools  

Go Back   Exetools > General > Source Code

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 04-04-2018, 19:01
dosprog dosprog is offline
Friend
 
Join Date: Feb 2018
Posts: 114
Rept. Given: 0
Rept. Rcvd 17 Times in 16 Posts
Thanks Given: 33
Thanks Rcvd at 147 Times in 74 Posts
dosprog Reputation: 17
It's likely not a good idea.
Any of imported functions must be correctly declared individulally,
and thus must be called normally.
In addition - without of using __asm directive.
In addition2 - repeated calls will be performed much faster.
In addition3 - [less or more] universal solution for x32/x64.

..It's likely not a good idea but it works..

--Add--

Add 1st argument of function as enum {C_CALL,STD_CALL}
and produce separate __asm code for this conventions ?



--Add2--

Quote:
Originally Posted by 0xall0c View Post
Example :

Code:
DWORD dwResult = DynCall("ntdll.dll","NtUnmapViewOfSection",
					PI.hProcess,
					(LPVOID)(NtHeader->OptionalHeader.ImageBase),0xb33f
				);
Dont forget to add one extra paramater at end i.e 0xb33f
This example rewritten without of DynCall():
Quote:
DWORD(__stdcall*_NtUnmapViewOfSection)(DWORD,DWORD);

void main(void)
{
DWORD result;

if(!(_NtUnmapViewOfSection=(DWORD(__stdcall*)(DWORD,DWORD))GetProcAddress(LoadLibrary("ntdll.dll"),"NtUnmapViewOfSection")))goto dos_exit;

result=_NtUnmapViewOfSection(0,0);

dos_exit:;
}



Last edited by dosprog; 04-05-2018 at 07:24.
Reply With Quote
The Following User Says Thank You to dosprog For This Useful Post:
Indigo (07-19-2019)
  #2  
Old 04-05-2018, 16:16
0xall0c 0xall0c is offline
Friend
 
Join Date: Mar 2018
Posts: 70
Rept. Given: 0
Rept. Rcvd 4 Times in 3 Posts
Thanks Given: 28
Thanks Rcvd at 68 Times in 36 Posts
0xall0c Reputation: 4
Quote:
Originally Posted by dosprog View Post
It's likely not a good idea.
Any of imported functions must be correctly declared individulally,
and thus must be called normally.
In addition - without of using __asm directive.
In addition2 - repeated calls will be performed much faster.
In addition3 - [less or more] universal solution for x32/x64.

..It's likely not a good idea but it works..

--Add--

Add 1st argument of function as enum {C_CALL,STD_CALL}
and produce separate __asm code for this conventions ?



--Add2--


This example rewritten without of DynCall():



see the function prototype you defined, when there are lot functions to call, that's an extra headache.
Reply With Quote
The Following User Says Thank You to 0xall0c For This Useful Post:
Indigo (07-19-2019)
  #3  
Old 04-05-2018, 16:44
Pansemuckl Pansemuckl is offline
Friend
 
Join Date: Nov 2005
Posts: 40
Rept. Given: 6
Rept. Rcvd 4 Times in 2 Posts
Thanks Given: 20
Thanks Rcvd at 45 Times in 16 Posts
Pansemuckl Reputation: 4
Quote:
Originally Posted by 0xall0c View Post
see the function prototype you defined, when there are lot functions to call, that's an extra headache.
Not if you're using variadic templates (C++ 11)...
It produces even simpler, smaller and clean code.
Reply With Quote
The Following 2 Users Say Thank You to Pansemuckl For This Useful Post:
0xall0c (04-05-2018), Indigo (07-19-2019)
  #4  
Old 04-05-2018, 17:27
0xall0c 0xall0c is offline
Friend
 
Join Date: Mar 2018
Posts: 70
Rept. Given: 0
Rept. Rcvd 4 Times in 3 Posts
Thanks Given: 28
Thanks Rcvd at 68 Times in 36 Posts
0xall0c Reputation: 4
Quote:
Originally Posted by Pansemuckl View Post
Not if you're using variadic templates (C++ 11)...
It produces even simpler, smaller and clean code.
i didn't used variadic templates before. thank you for pointing out.
Reply With Quote
The Following User Says Thank You to 0xall0c For This Useful Post:
Indigo (07-19-2019)
  #5  
Old 04-06-2018, 07:08
dosprog dosprog is offline
Friend
 
Join Date: Feb 2018
Posts: 114
Rept. Given: 0
Rept. Rcvd 17 Times in 16 Posts
Thanks Given: 33
Thanks Rcvd at 147 Times in 74 Posts
dosprog Reputation: 17
Quote:
Originally Posted by 0xall0c View Post
see the function prototype you defined, when there are lot functions to call, that's an extra headache.
It's programming..

In MASM32 we can invoke function using prototype or call function without prototype.
I tend to use the invoke.
It is convenient, however it is necessary to get used to.



Last edited by dosprog; 04-06-2018 at 07:17.
Reply With Quote
The Following User Says Thank You to dosprog For This Useful Post:
Indigo (07-19-2019)
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling any function dynamically without typedef Succubus Source Code 0 10-21-2021 16:34
WinAPI: No WM_COMMAND Message? aldente General Discussion 2 07-05-2006 07:17


All times are GMT +8. The time now is 11:33.


Always Your Best Friend: Aaron, JMI, ahmadmansoor, ZeNiX, chessgod101
( Since 1998 )