News:

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

Main Menu

A guide to the RichMasm editor

Started by jj2007, April 28, 2016, 10:09:34 PM

Previous topic - Next topic

jj2007

Quote from: TimoVJL on January 07, 2024, 06:43:30 AMC it this way
Code Select Expand
pSchema = pCon->lpVtbl->OpenSchema(pSchema, adSchemaTables);

Thanks, Timo. The problem here is that you can find three versions of OpenSchema on the web:
- with one argument
- with two args (most frequent)
- with 36 bytes on the stack, like two VARIANTs by value plus one DWORD

The first two crash in Assembly, simply because the stack is not balanced. The third one returns "invalid parameter". Apparently, it needs a SAFEARRAY as second argument, in which VARIANTs are embedded. But passing a SAFEARRAY by value is no good for the stack balance, ditto for passing it byref :cool: 

TimoVJL

#76
OpenSchema method (ADO)C++ don't always need all parameters, as some can be default


EDIT:
Visual C++ ADO programming

from Pelles C compiled code:
73:            hr = pCon->lpVtbl->OpenSchema(pCon, adSchemaTables, vtCriteria, vtMissing, &pRst);
  [0000014B] 8D45F8                lea              eax,[ebp-8]
  [0000014E] 50                    push              eax
  [0000014F] 8D4DD8                lea              ecx,[ebp-28]
  [00000152] 83EC10                sub              esp,10
  [00000155] 8B01                  mov              eax,dword ptr [ecx]
  [00000157] 890424                mov              dword ptr [esp],eax
  [0000015A] 8B4104                mov              eax,dword ptr [ecx+4]
  [0000015D] 89442404              mov              dword ptr [esp+4],eax
  [00000161] 8B4108                mov              eax,dword ptr [ecx+8]
  [00000164] 89442408              mov              dword ptr [esp+8],eax
  [00000168] 8B410C                mov              eax,dword ptr [ecx+C]
  [0000016B] 8944240C              mov              dword ptr [esp+C],eax
  [0000016F] 8D4DB8                lea              ecx,[ebp-48]
  [00000172] 83EC10                sub              esp,10
  [00000175] 8B01                  mov              eax,dword ptr [ecx]
  [00000177] 890424                mov              dword ptr [esp],eax
  [0000017A] 8B4104                mov              eax,dword ptr [ecx+4]
  [0000017D] 89442404              mov              dword ptr [esp+4],eax
  [00000181] 8B4108                mov              eax,dword ptr [ecx+8]
  [00000184] 89442408              mov              dword ptr [esp+8],eax
  [00000188] 8B410C                mov              eax,dword ptr [ecx+C]
  [0000018B] 8944240C              mov              dword ptr [esp+C],eax
  [0000018F] 6A14                  push              14
  [00000191] FF75FC                push              dword ptr [ebp-4]
  [00000194] 8B45FC                mov              eax,dword ptr [ebp-4]
  [00000197] 8B00                  mov              eax,dword ptr [eax]
  [00000199] FF908C000000          call              dword ptr [eax+8C]
73:            hr = pCon->lpVtbl->OpenSchema(pCon, adSchemaTables, vtCriteria, vtMissing, &pRst);
  [00000000000001FD] 488D8424B8000000            lea              rax,[rsp+B8]
  [0000000000000205] 4889442420                  mov              qword ptr [rsp+20],rax
  [000000000000020A] 488D7C2440                  lea              rdi,[rsp+40]
  [000000000000020F] 488DB42488000000            lea              rsi,[rsp+88]
  [0000000000000217] B918000000                  mov              ecx,18
  [000000000000021C] F3A4                        rep movsb       
  [000000000000021E] 488D7C2428                  lea              rdi,[rsp+28]
  [0000000000000223] 488D742458                  lea              rsi,[rsp+58]
  [0000000000000228] B918000000                  mov              ecx,18
  [000000000000022D] F3A4                        rep movsb       
  [000000000000022F] 488B8C24C0000000            mov              rcx,qword ptr [rsp+C0]
  [0000000000000237] BA14000000                  mov              edx,14
  [000000000000023C] 4C8D442428                  lea              r8,[rsp+28]
  [0000000000000241] 4C8D4C2440                  lea              r9,[rsp+40]
  [0000000000000246] 488B8424C0000000            mov              rax,qword ptr [rsp+C0]
  [000000000000024E] 488B00                      mov              rax,qword ptr [rax]
  [0000000000000251] FF9018010000                call              qword ptr [rax+118]
May the source be with you

jj2007

Quote from: TimoVJL on January 07, 2024, 07:10:33 AMOpenSchema method (ADO)C++ don't always need all parameters, as some can be default

OpenSchema is only happy with 9 DWORDs on the stack :cool: