NO

Recent Posts

Pages: 1 ... 8 9 [10]
91
Beginner questions / Re: miniupnp Library
« Last post by TimoVJL on January 22, 2024, 07:11:32 AM »
for static lib
Code: [Select]
MINIUPNP_STATICLIB
Code: [Select]
WIN32_SNPRINTF_H
for x64 exclude miniupnpcmodule.c from library, as pythonconfig.h have a pid_t conflict.
92
Beginner questions / Re: miniupnp Library
« Last post by Vortex on January 22, 2024, 07:02:29 AM »
Hello,

Trying to compile the source code in the attachment  :

Code: [Select]
Building upnpc.obj.
D:\libminiupnpc\miniupnpc\upnpc.c(150): warning #2018: Undeclared function '_scprintf' (did you mean: _snprintf?); assuming 'extern' returning 'int'.
D:\libminiupnpc\miniupnpc\upnpc.c(422): warning #2018: Undeclared function '_scprintf' (did you mean: _snprintf?); assuming 'extern' returning 'int'.
D:\libminiupnpc\miniupnpc\upnpc.c(427): warning #2018: Undeclared function '_scprintf' (did you mean: _snprintf?); assuming 'extern' returning 'int'.
Building libminiupnpc.lib.
Done.

_scprintf should be offered by the MS VC run-time library :

https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/scprintf-scprintf-l-scwprintf-scwprintf-l?view=msvc-170
93
Beginner questions / miniupnp Library
« Last post by WiiLF23 on January 22, 2024, 05:42:06 AM »
Hey everyone. I have the need to use the miniupnp UPnP C library for my requirements.

https://github.com/miniupnp/miniupnp

Now, I have downloaded the source and included

ZIP path               New folder
-------------          ----------------
include\*.h   -- >  miniupnp
src\*.c         -- >  miniupnp

Now, I have the folder "miniupnp" containing the required files.

I create a new win64 static library project, and add "miniupnp.c" to my project tree. Compiles successfully.

libminiupnp.lib (25.2 KB)

Now, I copy the "miniupnp" directory to (Pelles C - Program Files) -> \Include\miniupnp

Now, in my main project requiring the library use, I added

Code: [Select]
#include <miniupnpc/miniupnpc.h>
#pragma comment(lib, "libminiupnpc.lib")

However, calling any of the functions required it does not resolve any external symbols. I do not know what to do from here.

I see on the GIT there are files (a .def file too) for building DLL, a .rc file for that too etc.

DEF file:

Code: [Select]
LIBRARY
; miniupnpc library
   miniupnpc

EXPORTS
; miniupnpc
   upnpDiscover
   upnpDiscoverDevice
   upnpDiscoverDevices
   upnpDiscoverAll
   freeUPNPDevlist
   parserootdesc
   UPNP_GetValidIGD
   UPNP_GetIGDFromUrl
   GetUPNPUrls
   FreeUPNPUrls
; miniwget
   miniwget
   miniwget_getaddr
; upnpcommands
   UPNP_GetTotalBytesSent
   UPNP_GetTotalBytesReceived
   UPNP_GetTotalPacketsSent
   UPNP_GetTotalPacketsReceived
   UPNP_GetStatusInfo
   UPNP_GetConnectionTypeInfo
   UPNP_GetExternalIPAddress
   UPNP_GetLinkLayerMaxBitRates
   UPNP_AddPortMapping
   UPNP_AddAnyPortMapping
   UPNP_DeletePortMapping
   UPNP_DeletePortMappingRange
   UPNP_GetPortMappingNumberOfEntries
   UPNP_GetSpecificPortMappingEntry
   UPNP_GetGenericPortMappingEntry
   UPNP_GetListOfPortMappings
   UPNP_AddPinhole
   UPNP_CheckPinholeWorking
   UPNP_UpdatePinhole
   UPNP_GetPinholePackets
   UPNP_DeletePinhole
   UPNP_GetFirewallStatus
   UPNP_GetOutboundPinholeTimeout
; upnperrors
   strupnperror
; portlistingparse
   ParsePortListing
   FreePortListing

But this is for a DLL. What exactly am I missing here? This is what I used for testing:

Code: [Select]
void testMiniUPnP() {
    // Discover UPnP devices on the network
    int error;
    struct UPNPDev* devlist = upnpDiscover(1000, NULL, NULL, 0, 0, 2, &error);

    if (devlist == NULL) {
        printf("No UPnP devices found. Error code: %d\n", error);
        return;
    }

    // Iterate through the list of discovered devices
    struct UPNPDev* device = devlist;
    while (device) {
        printf("Device: %s\n", device->descURL);
        // Perform additional actions if needed

        // Move to the next device in the list
        device = device->pNext;
    }

    // Free the device list
    freeUPNPDevlist(devlist);
}

Any help appreciated!  ;)

Lib project is attached for review.
94
Assembly discussions / Re: Calling a C++ function from Poasm
« Last post by Vortex on January 18, 2024, 08:31:10 PM »
Hi Timo,

Great sample, many thanks. Something new to learn for me, it's the /ALTERNATENAME:symbol=symbol option of polink.

The linker option ALTERNATENAME does the job, disassembling the object module produced by Pelles C :

Code: [Select]
public mainCRTStartup

extern ExitProcess: near
extern formula_GetResult: near
extern formula_calc: near

_text   SEGMENT PARA 'CODE'

mainCRTStartup PROC
        sub     rsp, 56
        mov     dword ptr [rsp+28H], 10
        mov     dword ptr [rsp+20H], 8                 
        xor     ecx, ecx                               
        mov     edx, 2                                 
        mov     r8d, 4                                 
        mov     r9d, 6                                 
        call    formula_calc                           
        xor     ecx, ecx                               
        mov     edx, eax                               
        call    formula_GetResult                       
        xor     ecx, ecx                               
        call    ExitProcess                             
        add     rsp, 56                                 
        ret                                             
mainCRTStartup ENDP
95
Assembly discussions / Re: Calling a C++ function from Poasm
« Last post by TimoVJL on January 18, 2024, 09:48:43 AM »
Why not with C  ;)
Code: [Select]
void __stdcall  ExitProcess( unsigned int uExitCode);
int __cdecl printf(const char * format, ...);
#pragma comment(lib, "msvcrt.lib")
// void formula::GetResult(int t)
// void ?GetResult@formula@@QEAAXH@Z(long long, long long)
#pragma comment(linker, "-alternatename:formula_GetResult=?GetResult@formula@@QEAAXH@Z")
void formula_GetResult(void* this, int t);
// int formula::calc(int a, int b, int c, int d, int e)
// int ?calc@formula@@QEAAHHHHHH@Z(int a, int b, int c, int d, int e)
int formula_calc(void* this, int a, int b, int c, int d, int e);
#pragma comment(linker, "-alternatename:formula_calc=?calc@formula@@QEAAHHHHHH@Z")
void __cdecl mainCRTStartup(void)
{
int x = formula_calc(0,2,4,6,8,10);
formula_GetResult(0,x);
ExitProcess(0);
}
96
Beginner questions / Re: GroupBox title text color
« Last post by WiiLF23 on January 18, 2024, 02:08:01 AM »
Hi WiiLF23,

Yes, it then allows one to set the text color...without needing owner draw.
No major change to the group box appearance so still looks the same.

proto is -
HRESULT SetWindowTheme(
  [in] HWND    hwnd,
  [in] LPCWSTR pszSubAppName,
  [in] LPCWSTR pszSubIdList
);

From MS:
Quote
When pszSubAppName and pszSubIdList are NULL, the theme manager removes the previously applied associations. You can prevent visual styles from being applied to a specified window by specifying an empty string, (L" "), which does not match any section entries.

So NULL removes while L"" inhibits application as I read it.  In my case both would be OK, maybe NULL is preferred in some situations though.

John Z

Interesting. I never located that documentation but it is all confirmed. I think NULL is just "best practice", same way I assign all static non-numeric primitives to NULL. I dont think it is necessary, but more preferred means of initialization. It's become a habit indeed.
97
Assembly discussions / Re: Calling a C++ function from Poasm
« Last post by Vortex on January 17, 2024, 05:31:24 PM »
Same example with function prototypes :

Code: [Select]
?calc@formula@@QEAAHHHHHH@Z PROTO :QWORD,:QWORD,:QWORD,:QWORD,:QWORD,:QWORD
calc TEXTEQU <?calc@formula@@QEAAHHHHHH@Z>

?GetResult@formula@@QEAAXH@Z PROTO :QWORD,:QWORD
GetResult TEXTEQU <?GetResult@formula@@QEAAXH@Z>

ExitProcess PROTO :QWORD

.code

start PROC PARMAREA=6*QWORD

;   rcx ->  this pointer

    invoke  calc,rcx,2,4,6,8,10

;   rcx ->  this pointer

    invoke  GetResult,rcx,rax

    invoke  ExitProcess,0

start ENDP

END start

98
Beginner questions / Re: GroupBox title text color
« Last post by John Z on January 16, 2024, 11:38:14 PM »
Hi WiiLF23,

Yes, it then allows one to set the text color...without needing owner draw.
No major change to the group box appearance so still looks the same.

proto is -
HRESULT SetWindowTheme(
  [in] HWND    hwnd,
  [in] LPCWSTR pszSubAppName,
  [in] LPCWSTR pszSubIdList
);

From MS:
Quote
When pszSubAppName and pszSubIdList are NULL, the theme manager removes the previously applied associations. You can prevent visual styles from being applied to a specified window by specifying an empty string, (L" "), which does not match any section entries.

So NULL removes while L"" inhibits application as I read it.  In my case both would be OK, maybe NULL is preferred in some situations though.

John Z
99
General discussions / Re: Pelles-C and CURL
« Last post by WiiLF23 on January 16, 2024, 11:29:03 PM »
I've developed a cURL POST login procedure that uses cJSON to pass JSON data back to application for parsing, error reporting, etc. The remote login script is a basic (can be any language) PHP file checking username and password POST parameters and echoing JSON back (which can be anything).

- Allows instantly downloading user photo - > Bitmap conversion -> show on window
- Show any of the JSON fields read back and show them in controls (labels, picture, fields, etc)

It uses this library extensively. If anyone wants me to post this, let me know - it is mighty useful ;D
100
Beginner questions / Re: GroupBox title text color
« Last post by WiiLF23 on January 16, 2024, 11:23:19 PM »
Code: [Select]
SetWindowTheme(GetDlgItem(gHWND, OptionBox1), L"", NULL);
This disables Visual Theme support for the specified handle since Windows XP. You might want to pass NULL to the last parameter if using a empty string to disable visual styles.


Pages: 1 ... 8 9 [10]