Results 1 to 40 of 172

Thread: using VbTrickThreading-master examples without the typelibs for Callback and Marshal

Hybrid View

  1. #1
    PowerPoster
    Join Date
    Jan 2020
    Posts
    5,538

    Re: using VbTrickThreading-master examples without the typelibs for Callback and Mar

    mabe it's good,I saw this piece of code earlier, but I don't know what it's for.I'll test it tomorrow.
    The best method is still inseparable from the assembly code support. After all, the programming tools are upgraded, and finally they run as assembly code.
    Use createthread to directly call the function address, and add vb initialization inside the function process, which is equivalent to the cdecl mode dll, which requires the user to initialize and reclaim memory and unload the com object.
    vbcreatethread is a simple wrapper that handles automatically, equivalent to stdcall calls
    chinese:最好的方法还是离不开汇编代码支持,毕竟编程工具升级,最后还是变成汇编代码运行。
    直接用createthread调用函数地址,函数过程里面加vb初始化,相当于cdecl方式dll,需要用户初始化和回收内存,卸载com对象。
    vbcreatethread 是一个简易包装,自动处理,相当于stdcall调用

  2. #2
    PowerPoster
    Join Date
    Jan 2020
    Posts
    5,538

    Re: using VbTrickThreading-master examples without the typelibs for Callback and Mar

    question 1:how to run createthread in vb6 ide,for support show form1
    i run createthread in vb6 ide,it's successful,but can't show form
    (how to fix?),maybe use not the same "NewVBHeader_Heap"
    NewVBHeader_Heap=HeapAlloc(hHeadersHeap, HEAP_ZERO_MEMORY, lSizeOfHeaders)
    we need new lSizeOfHeaders?
    or need other way?

    for test,it's support com object like "adodb.stream"

    question2: how to debug thread in ide?
    it's can suspended, how to run on?
    use f5 or f8 or can't run
    Quest3:if i use "end " in thread,APPCATION WILL BE collapse(ERR),WHY?

    Code:
    Dim f As Form1
    Set f = New Form1
    f.Show 1
    VBDllGetClassObject  VarPtr(App.hInstance), 0, VBHeader, 0&, Iid, 0       '
    VBDllGetClassObject VarPtrHModule, 0, NewVBHeader_Heap, 0&, Iid, 0 '[/CODE]
    error from "VBDllGetClassObject":
    Signature of question:
    Problem event name: APPCRASH
    Application name: vb6.exe
    Application version: 6.0.97.82
    Application timestamp: 403acf6c
    Fault module name: msvbvm60. DLL
    Fault module version: 6.0.98.15
    Fault module timestamp: 49b01fc3
    Exception code: c0000005
    Exception offset: 000044da
    OS version: 6.3.9600.2.0.0.256.4

    Locale ID: 2052
    Other information 1: ac05
    Other information: 2 ac0507478d1c5bd693cfc4fe3987e900
    Other information 3: ac05
    Other information 4: ac0507478d1c5bd693cfc4fe3987e900
    '===========
    chinese:问题签名:
    问题事件名称: APPCRASH
    应用程序名: VB6.EXE
    应用程序版本: 6.0.97.82
    应用程序时间戳: 403acf6c
    故障模块名称: MSVBVM60.DLL
    故障模块版本: 6.0.98.15
    故障模块时间戳: 49b01fc3
    异常代码: c0000005
    异常偏移: 000044da
    OS 版本: 6.3.9600.2.0.0.256.4
    区域设置 ID: 2052
    其他信息 1: ac05
    其他信息 2: ac0507478d1c5bd693cfc4fe3987e900
    其他信息 3: ac05
    其他信息 4: ac0507478d1c5bd693cfc4fe3987e900
    Attached Images Attached Images  
    Last edited by xiaoyao; Jan 30th, 2020 at 09:19 PM.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2015
    Posts
    356

    Re: using VbTrickThreading-master examples without the typelibs for Callback and Mar

    Quote Originally Posted by xiaoyao View Post
    question 1:how to run createthread in vb6 ide,for support show form1
    i run createthread in vb6 ide,it's successful,but can't show form
    (how to fix?),maybe use not the same "NewVBHeader_Heap"
    NewVBHeader_Heap=HeapAlloc(hHeadersHeap, HEAP_ZERO_MEMORY, lSizeOfHeaders)
    we need new lSizeOfHeaders?
    or need other way?

    for test,it's support com object like "adodb.stream"

    question2: how to debug thread in ide?
    it's can suspended, how to run on?
    use f5 or f8 or can't run
    Quest3:if i use "end " in thread,APPCATION WILL BE collapse(ERR),WHY?

    Code:
    Dim f As Form1
    Set f = New Form1
    f.Show 1
    VBDllGetClassObject  VarPtr(App.hInstance), 0, VBHeader, 0&, Iid, 0       '
    VBDllGetClassObject VarPtrHModule, 0, NewVBHeader_Heap, 0&, Iid, 0 '[/CODE]
    error from "VBDllGetClassObject":
    Signature of question:
    Problem event name: APPCRASH
    Application name: vb6.exe
    Application version: 6.0.97.82
    Application timestamp: 403acf6c
    Fault module name: msvbvm60. DLL
    Fault module version: 6.0.98.15
    Fault module timestamp: 49b01fc3
    Exception code: c0000005
    Exception offset: 000044da
    OS version: 6.3.9600.2.0.0.256.4

    Locale ID: 2052
    Other information 1: ac05
    Other information: 2 ac0507478d1c5bd693cfc4fe3987e900
    Other information 3: ac05
    Other information 4: ac0507478d1c5bd693cfc4fe3987e900
    '===========
    chinese:问题签名:
    问题事件名称: APPCRASH
    应用程序名: VB6.EXE
    应用程序版本: 6.0.97.82
    应用程序时间戳: 403acf6c
    故障模块名称: MSVBVM60.DLL
    故障模块版本: 6.0.98.15
    故障模块时间戳: 49b01fc3
    异常代码: c0000005
    异常偏移: 000044da
    OS 版本: 6.3.9600.2.0.0.256.4
    区域设置 ID: 2052
    其他信息 1: ac05
    其他信息 2: ac0507478d1c5bd693cfc4fe3987e900
    其他信息 3: ac05
    其他信息 4: ac0507478d1c5bd693cfc4fe3987e900
    Dear xiaoyao,

    Displaying form also works in IDE.But it is displayed in the main Thread.
    You can check this by running your 03_Edit-usercontrol_FormGood project in IDE and click on Create Thread button on the displayed form.
    You can put break points and debug the project.

    regards,
    JSVenu

  4. #4
    PowerPoster
    Join Date
    Jan 2020
    Posts
    5,538

    Re: using VbTrickThreading-master examples without the typelibs for Callback and Mar

    I TEST createthread in vb6 ide,need new thread,not run in main thread.(it's only for test this api,no need debug)
    if can debug part,like break ,and run on again,Wouldn't that be better?

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2015
    Posts
    356

    Re: using VbTrickThreading-master examples without the typelibs for Callback and Mar

    Quote Originally Posted by xiaoyao View Post
    I TEST createthread in vb6 ide,need new thread,not run in main thread.(it's only for test this api,no need debug)
    if can debug part,like break ,and run on again,Wouldn't that be better?
    Dear xiaoyao,

    I understood that you require attaching to a running application at runtime debug it and then detach from it so that it runs again standalone.
    This dynamic runtime attach and detach to a running application are not available in vb6 IDE.They are available in vc++ 6.0 IDE but here also while detaching the application terminates.
    If you want to run perfectly you have to use .Net IDE with which you can attach debug and detach and continue run again without problems.Trick has also suggested me ollydbg.

    As an alternative if you want to change control paths in vb6 IDE itself you can use set next statement while debugging using break points.
    You can also use DebugBreak api in vb6.
    regards,
    JSVenu
    Last edited by jsvenu; Jan 31st, 2020 at 01:27 AM.

  6. #6
    PowerPoster
    Join Date
    Jan 2020
    Posts
    5,538

    Re: using VbTrickThreading-master examples without the typelibs for Callback and Mar

    Quote Originally Posted by jsvenu View Post
    Dear xiaoyao,

    I understood that you require attaching to a running application at runtime debug it and then detach from it so that it runs again standalone.
    This dynamic runtime attach and detach to a running application are not available in vb6 IDE.They are available in vc++ 6.0 IDE but here also while detaching the application terminates.
    If you want to run perfectly you have to use .Net IDE with which you can attach debug and detach and continue run again without problems.Trick has also suggested me ollydbg.

    As an alternative if you want to change control paths in vb6 IDE itself you can use set next statement while debugging using break points.
    You can also use DebugBreak api in vb6.
    regards,
    JSVenu
    if i open 4 Foms in thread,i saved the formobject to Array "Public FormArr(1 to 4) As Form"
    when "DLL_THREAD_ATTACH",i close these windows,why i close formarr(4),it's crash?
    close window 1-3 is very good.

    I create multiple threads in the DLL file, each with multiple forms.

    Is there any way to close all form objects when the DLL exits?

    How about this method? Send handle WM_CLOSE? Then loop through all window handles until they all fail.

    What's a safe way to end a thread without causing a memory leak?

    chinese:我在DLL文件里创建多线程,每个线程有多个窗体。
    有什么办法可以在DLL要退出时,直接关闭所有窗体对象?
    这个方法怎么样?发送句柄WM_CLOSE?然后循环检测所有窗口句柄,直到全部失效为止?
    有什么安全的方法结束线程,又不会造成内存泄露?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width