Skip to content

Instantly share code, notes, and snippets.

@jakogut
Last active February 24, 2016 21:28
Show Gist options
  • Save jakogut/f429540cf8487ff24115 to your computer and use it in GitHub Desktop.
Save jakogut/f429540cf8487ff24115 to your computer and use it in GitHub Desktop.
#include <windows.h>
#include <stdio.h>
#define CMT_OK 1
typedef int (__stdcall *CmtInitDbQryDll)();
typedef int (__stdcall *CmtGetRecordDataByRecId)();
#define REQ_BUFF_SZ (strlen(db_request))
char *db_request = "<?xml version=\"1.0\" ?>"
"<?commitcrmxmlgetrecorddatarequest version=\"1.0\" ?>"
"<CommitCRMGetRecordDataRequest>"
" <ExternalApplicationName>Leak Test</ExternalApplicationName>"
" <GetRecordByRecId>CRDCKQVFTYBTJFWSN8E1</GetRecordByRecId>"
" <SelectFieldsList>FLDCRDCONTACT</SelectFieldsList>"
"</CommitCRMGetRecordDataRequest>";
#define RESP_BUFF_SZ (2 << 13)
char db_response[RESP_BUFF_SZ];
int main(void) {
char *library = "C:\\CommitCRM\\Server\\cmtdbqry.dll";
HINSTANCE DbQryDll = LoadLibraryEx(library, NULL, 0x100 | 0x1000);
if(DbQryDll == NULL) {
printf("Could not load library.\n");
return;
} else printf("Loaded library: %s at %p\n", library, DbQryDll);
CmtInitDbQryDll db_init = (CmtInitDbQryDll)GetProcAddress(DbQryDll, "CmtInitDbQryDll");
CmtGetRecordDataByRecId get_record_data =
(CmtGetRecordDataByRecId)GetProcAddress(DbQryDll, "CmtGetRecordDataByRecId");
char *appname = "Leak Test";
char *path = "C:\\CommitCRM\\Db";
int status = 0;
db_init(appname, path, &status);
if(status != CMT_OK) {
printf("Failed to initialize database connection.");
return;
}
while(status == CMT_OK)
get_record_data(db_request, REQ_BUFF_SZ, db_response, RESP_BUFF_SZ, &status);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment