News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

help understanding dll call from ready code

Started by HobbyCoder, February 10, 2011, 10:10:06 PM

Previous topic - Next topic

HobbyCoder

hello all,
i hope im right here, plz correct me if not.
would be nice if not, if you can direct me to the right place for my question :)

id like to know if some one can please explain me how the dll is called.
is it possible to get the hex readable as string ?

SUB_L00401710:
  push esi
  mov esi,ecx
  push SSZ004210D8_pxd32d5_dll
  call [KERNEL32.dll!LoadLibraryA]
  test eax,eax
  jnz L00401735
  push eax
  push eax
  push SSZ004210C0_can_t_find_pxd32d5_dll
  call SUB_L00418367
  push 00000000h
  call SUB_L00402D33
L00401735:
  mov eax,10022624h
  mov dword ptr [esi+60h],10022624h
  mov dword ptr [esi+64h],10022645h
  mov dword ptr [esi+5Ch],1001A2DAh
  call eax
  mov dword ptr [10099D08h],00000004h
  mov eax,00000001h
  pop esi
  retn


how looks this with stings ?

mov   eax,10022624h
mov   dword ptr [esi+60h],10022624h
mov   dword ptr [esi+64h],10022645h
mov   dword ptr [esi+5Ch],1001A2DAh
call   eax


should look like this:
call "dll handle", "funktion name", "input.pxd", "output.wav"

im writing a little tool to convert pxd audio files to wav with a dll.
since i found a tool wo did it allready but crash under windows and run only under safe mode fine,
id like to code a new tool to use under windows.

if needed i can upload the program from where the snipet is, the dll and a test pxd audio file ?

thanks for reading :)



dedndave

you have to initialize the DLL
use the forum search tool - there are a few examples
i suggest using advanced options - as i recall, Hutch gave directions (hutch--)

HobbyCoder

thx, maybe you misunderstand me.
how i call a dll i know, i not know how the commands from the snippet are.

like:
dword ptr [esi+5Ch],1001A2DAh <-- lets say this is a strg "W2P"  i cant read/understand this numbers

what function to call in the dll ?
what commands send ?

hutch--

HobbyCoder,

It looks like you need to get the specs on the DLL function you want to call. The snippet you posted shows a LoadLibrary() API call but you need to do more to dynamically load a DLL.


LoadLibrary()
GetProcAddress()

call you function here

FreeLibrary()


Now looking at the pseudo code you posted it appears to be 3 strings so I would guess its 3 zero terminated string passed to the DLL function address something like this.


push arg3
push arg2
push arg1
call DLLfunc
mov your_ret_val, eax


Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

dedndave

#4
those values look like WAV file header values
i think they are taking raw audio data from pxd>dll and adding the WAV header to create a WAV file

HobbyCoder

thx for reply :)

i got some help from another board, some decompile the dll and show me the function:
Code:
int __cdecl W2P(int numberGreaterEqualThree, char **fromTo)
{
  return W2P_0(numberGreaterEqualThree, fromTo);
}

int __cdecl W2P_0(int numberGreaterEqualThree, char **stringTable)
{
  int result; // eax@4
  int v3; // [sp+0h] [bp-1Ch]@1
  int *v4; // [sp+Ch] [bp-10h]@1
  int v5; // [sp+18h] [bp-4h]@5

  v4 = &v3;
  if ( numberGreaterEqualThree >= 3 && **(stringTable + 1) && **(stringTable + 2) )
  {
    printf("PXD2Wav Konvertierung: %s -> %s", *(stringTable + 1), *(stringTable + 2));
    v5 = 0;
    strcpy(globalStringArray, *(stringTable + 1));
    strcpyOffset260(globalStringArray, *(stringTable + 2));
    result = convertPxdToWave_1000F8C5(globalStringArray);
  }
  else
  {
    result = printf("PXD2Wav Konvertierung: pxd -> wav");
  }
  return result;
}


arg1 is the call to function in dll
arg2 is a number, so function know what to do..in my case 3
arg3 is a array: 1 wav header, 2 inputfile, 3 outputfile

now i dont know how to send a array to the dll.
read something in the web that i send a pointer to memory were array is created.
but must say, sounds to hard for me.

im not happy about, but i think its better to give up on this.
any way, much thanks to you two for reading and taking time to help  :U